Skip to content

Commit

Permalink
Merge pull request #608 from mostafaelhoushi/fixing-cmake-opt-loops-env
Browse files Browse the repository at this point in the history
Fix CMake Linux for opt-loops
  • Loading branch information
mostafaelhoushi authored Mar 7, 2022
2 parents 275414a + 0509377 commit 9ffdd06
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 15 deletions.
3 changes: 3 additions & 0 deletions compiler_gym/third_party/autophase/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,6 @@ cg_cc_binary(
${LLVM_DEFINITIONS}
PUBLIC
)

ADD_CUSTOM_TARGET(link_compute_autophase_target ALL
COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_BINARY_DIR}/compiler_gym/third_party/autophase/compute_autophase ${CMAKE_SOURCE_DIR}/compiler_gym/third_party/autophase/compute_autophase-prelinked)
15 changes: 9 additions & 6 deletions compiler_gym/third_party/programl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

cg_add_all_subdirs()

llvm_map_components_to_libnames(_LLVM_LIBS analysis core irreader support)
llvm_map_components_to_libnames(_LLVM_LIBS analysis core irreader support passes)
cg_cc_binary(
NAME
compute_programl
Expand All @@ -14,17 +14,20 @@ cg_cc_binary(
COPTS
"-DGOOGLE_PROTOBUF_NO_RTTI"
"-fno-rtti"
DEPS
nlohmann_json::nlohmann_json
ProGraML::graph::format::node_link_graph
ProGraML::ir::llvm::llvm-10
ProGraML::proto::programl_cc
ABS_DEPS
glog::glog
${_LLVM_LIBS}
ProGraML::graph::format::node_link_graph
ProGraML::ir::llvm::llvm-10
ProGraML::proto::programl_cc
nlohmann_json::nlohmann_json
protobuf::libprotobuf
INCLUDES
${LLVM_INCLUDE_DIRS}
DEFINES
${LLVM_DEFINITIONS}
PUBLIC
)

ADD_CUSTOM_TARGET(link_compute_programl_target ALL
COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_BINARY_DIR}/compiler_gym/third_party/programl/compute_programl ${CMAKE_SOURCE_DIR}/compiler_gym/third_party/programl/compute_programl)
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def benchmark_from_parsed_uri(self, uri: BenchmarkUri) -> Benchmark:
with compiler_gym.make(
"loops-opt-py-v0",
benchmark="loops-opt-v0/add",
observation_space="ir",
observation_space="Programl",
reward_space="runtime",
) as env:
compiler_gym.set_debug_level(4) # TODO: check why this has no effect
Expand Down
4 changes: 2 additions & 2 deletions examples/loop_optimizations_service/service_py/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ cg_py_library(
"loops_opt_service.py"
DATA
examples::loop_optimizations_service::opt_loops::opt_loops
compiler_gym::third_party::autophase:compute_autophase
compiler_gym::third_party::programl:compute_programl
compiler_gym::third_party::autophase::compute_autophase
compiler_gym::third_party::programl::compute_programl
DEPS
PUBLIC
)
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
from compiler_gym.third_party.autophase import AUTOPHASE_FEATURE_NAMES
from compiler_gym.third_party.inst2vec import Inst2vecEncoder
from compiler_gym.util.commands import run_command
from compiler_gym.util.runfiles_path import runfiles_path
from compiler_gym.util.runfiles_path import runfiles_path # noqa

_INST2VEC_ENCODER = Inst2vecEncoder()

Expand Down Expand Up @@ -270,8 +270,9 @@ def get_observation(self, observation_space: ObservationSpace) -> Event:
elif observation_space.name == "Autophase":
Autophase_str = run_command(
[
runfiles_path(
"compiler_gym/third_party/autophase/compute_autophase-prelinked"
os.path.join(
os.path.dirname(__file__),
"../../../compiler_gym/third_party/autophase/compute_autophase-prelinked",
),
self._llvm_path,
],
Expand All @@ -286,8 +287,9 @@ def get_observation(self, observation_space: ObservationSpace) -> Event:
elif observation_space.name == "AutophaseDict":
Autophase_str = run_command(
[
runfiles_path(
"compiler_gym/third_party/autophase/compute_autophase-prelinked"
os.path.join(
os.path.dirname(__file__),
"../../../compiler_gym/third_party/autophase/compute_autophase-prelinked",
),
self._llvm_path,
],
Expand All @@ -302,7 +304,10 @@ def get_observation(self, observation_space: ObservationSpace) -> Event:
elif observation_space.name == "Programl":
Programl_str = run_command(
[
runfiles_path("compiler_gym/third_party/programl/compute_programl"),
os.path.join(
os.path.dirname(__file__),
"../../../compiler_gym/third_party/programl/compute_programl",
),
self._llvm_path,
],
timeout=30,
Expand Down

0 comments on commit 9ffdd06

Please sign in to comment.