-
Notifications
You must be signed in to change notification settings - Fork 126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cross-compile the benchmark in compiler Gym on X86 platform to RISCV platform #785
Comments
Hey @sparks-code sorry for the slow reply! Benchmark's have a command line invocation that is used to compile the bitcode down to a binary. If all you need to do is change some flags in the clang invocation, then you can do that by: On the other hand, if you need to recompile the C/C++ sources to bitcode, that may be a bit more tricky. Only a couple of the benchmark datasets ship as source files, the rest ship as bitcodes. Can I ask what your use case is, and if there are any benchmarks in particular that you are interested in? That may help me give better suggestions. Cheers, |
@ChrisCummins Thank you very much for your reply. I want to use compilerGym for code optimization on the RISCV platform,so I need to recompile the C/C++ source code to bitcode. Currently I am trying to recompile cbench-v1.1, can I ask if you you have any recommended relatively easy benchmarks to recompile? Or what else I need to do? I am waiting for your suggestions. |
You could take a look at Anghabench. It's 1M C functions that are shipped as source code and compiled to IR on-demand. You could hack on the command line here to compile to RISCV: CompilerGym/compiler_gym/envs/llvm/datasets/anghabench.py Lines 105 to 112 in 8d25c10
CSmith works largely the same: CompilerGym/compiler_gym/envs/llvm/datasets/csmith.py Lines 213 to 227 in 8d25c10
For CBench, I use this script to compile each of the benchmarks's sources to IR. You could adapt that: CompilerGym/compiler_gym/third_party/cbench/make_llvm_module.py Lines 20 to 35 in 8d25c10
Hope that helps! Cheers, |
import gym
import compiler_gym
env = gym.make("llvm-autophase-ic-v0")
dataset = env.datasets.dataset("benchmark://cbench-v1")
benchmark=env.datasets.benchmark("benchmark://cbench-v1/bzip2")
(benchmark.proto.dynamic_config.build_cmd.argument)
def eval_action(env, action: int):
with env.fork() as fkd:
return (fkd.step(action)[1], action)
for action in range(env.action_space.n):
print(eval_action(env,action)) hello, @ChrisCummins ,thank you for your help.I have compiled cbench to riscv platform ,upgraded llvm to 17 and made a corresponding replacement of the action space,I use the python script above to test my work is correct. But the output looks like this (0.0, 0) ServiceIsClosed Traceback (most recent call last) /root/CompilerGym/examples/llvm_autotuning/test_riscv.ipynb 单元格 4 in eval_action(env, action) File ~/anaconda3/envs/compiler_gym/lib/python3.8/site-packages/compiler_gym/envs/llvm/llvm_env.py:655, in LlvmEnv.fork(self) File ~/anaconda3/envs/compiler_gym/lib/python3.8/site-packages/compiler_gym/service/client_service_compiler_env.py:525, in ClientServiceCompilerEnv.fork(self) ServiceIsClosed: RPC communication failed because channel is closed It seems that when some action apply to the benchmark the environment crashed,so my question is, what should i do to ensure my action space is correct ? |
I would start by narrowing down the cause of the crash: Is it always the same action? Is it always on the same benchmark? Once you have figured out which action(s) are at fault it may be worth digging into the LLVM docs to ensure that the pass is being used as expected. Cheers, |
❓ Questions and Help
Hello, if I want to cross-compile the benchmark in compiler Gym on X86 platform to RISCV platform, what do I need to modify?
Additional Context
The text was updated successfully, but these errors were encountered: