Skip to content

UW-HARVEST/harvest

Repository files navigation

HARVEST code

A place to put HARVEST code that has not yet been migrated into its own repository.

Building the Rust code

First, you will need to install libClang if you do not already have it. If you use ubuntu, this you can do this by runing:

apt-get install libclang-dev

If you have rustup installed, you can build the code by running:

cargo build --release

If you do not use rustup, you will need a sufficiently-new stable Rust compiler (see rust-toolchain.toml for a toolchain version that is known to work).

LLM server

You will also need an LLM server. This can be local, or remote. A couple options are given below:

Local Ollama instance

You can follow Ollama's download instructions, or download its Docker image.

Once you have it installed, you need to download a model. By default, harvest_translate uses codellama:7b:

ollama pull codellama:7b                       # If installed in your system
docker container run ollama pull codellama:7b  # If using Docker

You will need to have Ollama running to run harvest_translate.

Remote OpenAI instance

First, you'll need to provision an OpenAI API key.

Then, you'll need to set up a custom Harvest config file:

[tools.raw_source_to_cargo_llm]
backend = "openai"
model = "gpt-4o"
api_key = "your_key_here" # Will be read from environment if empty
address = ""  # Not needed for OpenAI
max_tokens = 16384

You should place this config at the OS-dependent harvest config location, which you can find by running:

cargo run -- --print-config-path

Running

Some of the examples below assume you have a local copy of the TRACTOR Test-Corpus repository in export TEST_CORPUS_PATH=/path/to/test-corpus.

Translate C code to Rust

cargo run --bin=translate --release -- /path/to/c/code -o /path/to/output

Test-Corpus Example:

cargo run --bin=translate --release -- $TEST_CORPUS_PATH/Public-Tests/B01_synthetic/001_helloworld/test_case/ -o example_output/

Running a set of TRACTOR benchmarks

cargo run --bin=benchmark --release -- /path/to/input/dir /path/to/output/dir

Example: run all benchmarks

cargo run --bin=benchmark --release -- $TEST_CORPUS_PATH/Public-Tests/B01_synthetic example_output/

Optional: add --filter= to keep only matching benchmarks (by directory name)

Example: run only library benchmarks (directories ending with _lib)

cargo run --bin=benchmark --release -- $TEST_CORPUS_PATH/Public-Tests/B01_synthetic example_output/ --filter=".*_lib$"

Example: run only benchmarks starting with B01

cargo run --bin=benchmark --release -- $TEST_CORPUS_PATH/Public-Tests example_output/ --filter="^B01"

Optional: add --exclude= to exclude matching benchmarks (by directory name) Note: --filter and --exclude are mutually exclusive

Example: exclude library benchmarks (directories ending with _lib)

cargo run --bin=benchmark --release -- $TEST_CORPUS_PATH/Public-Tests/B01_synthetic example_output/ --exclude=".*_lib$"

Example: exclude benchmarks starting with test_

cargo run --bin=benchmark --release -- $TEST_CORPUS_PATH/Public-Tests example_output/ --exclude="^test_"

Configuration

Print config file location:

cargo run --bin=translate -- --print-config-path

You can find more information on configuration in [doc/Configuration.md].

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages