@@ -11,18 +11,12 @@ endif()
1111
1212set (CMAKE_C_COMPILER "clang" )
1313set (CMAKE_CXX_COMPILER "clang++" )
14- set (CMAKE_CXX_STANDARD 17 )
14+ set (CMAKE_CXX_STANDARD 11 )
1515
1616
1717set (PROJECT_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR} " )
1818set (PROJECT_BINARY_DIR "${CMAKE_BINARY_DIR} " )
1919
20- find_package (chpl REQUIRED HINTS ${PROJECT_ROOT_DIR} /cmake/chapel )
21- list (APPEND CMAKE_MODULE_PATH "${PROJECT_ROOT_DIR} /cmake" )
22- list (APPEND CMAKE_MODULE_PATH "${PROJECT_ROOT_DIR} /cmake/chapel" )
23-
24- project (MyProject LANGUAGES CXX C CHPL)
25-
2620
2721# For ExternalProject_Add
2822include (FetchContent )
@@ -34,6 +28,10 @@ include(ExternalProject)
3428
3529# Where to place PyTorch after installation
3630set (PYTORCH_INSTALL_DIR "${PROJECT_BINARY_DIR} /pytorch-install" )
31+ set (PYTORCH_BUILD_DIR "${PROJECT_BINARY_DIR} /pytorch-prefix/src/pytorch-build" )
32+
33+ set (PYTORCH_INSTALL_PREFIX "${PROJECT_BINARY_DIR} /pytorch-install-prefix" )
34+ file (MAKE_DIRECTORY "${PYTORCH_INSTALL_PREFIX} " )
3735
3836# ExternalProject_Add can fetch from Git, a local path, or a release tarball.
3937# Here, for simplicity, we'll fetch from Git. In practice, you might want
@@ -64,17 +62,26 @@ ExternalProject_Add(
6462 -DUSE_CUDA=OFF # Disable CUDA
6563 -DUSE_CUDNN=OFF # Disable cuDNN
6664 -DUSE_MKLDNN=OFF # Disable MKLDNN for simplicity
65+ # -DBUILD_BINARY=ON
66+ # -DUSE_DISTRIBUTED=ON
67+ # -DBUILD_STATIC_RUNTIME_BENCHMARK=ON
68+ # -DBUILD_LITE_INTERPRETER=ON
69+ # -DUSE_STATIC_MKL=ON
70+ # -DSTATIC_DISPATCH_BACKEND=ON
71+ # -DCAFFE2_USE_MSVC_STATIC_RUNTIME=ON
72+ -DUSE_DISTRIBUTED=ON
6773 -DCMAKE_BUILD_TYPE=Release
68- -DCMAKE_INSTALL_PREFIX=${PYTORCH_INSTALL_DIR}
74+ -DCMAKE_INSTALL_PREFIX=${PYTORCH_INSTALL_PREFIX}
75+ # -DCMAKE_POLICY_VERSION_MINIMUM=3.5
6976
7077 INSTALL_DIR ${PYTORCH_INSTALL_DIR} # Where to install
7178
72- LOG_DOWNLOAD ON
73- LOG_UPDATE ON
74- LOG_PATCH ON
75- LOG_CONFIGURE ON
79+ # LOG_DOWNLOAD ON
80+ # LOG_UPDATE ON
81+ # LOG_PATCH ON
82+ # LOG_CONFIGURE ON
7683 # LOG_BUILD ON
77- LOG_INSTALL ON
84+ # LOG_INSTALL ON
7885
7986)
8087
@@ -83,6 +90,23 @@ file(GLOB_RECURSE PYTORCH_INCLUDES "${PYTORCH_INSTALL_DIR}/include" "*.h")
8390file (GLOB_RECURSE PYTORCH_LIBS "${PYTORCH_INSTALL_DIR} /lib" "*.a" )
8491
8592
93+ set (PYTORCH_LIBS_LINKER_ARGS "" ) # Will hold the list of "-l..." flags.
94+ foreach (lib_path IN LISTS PYTORCH_LIBS)
95+ # Get just the filename without the directory or extension
96+ get_filename_component (lib_name "${lib_path} " NAME_WE )
97+ # If it starts with "lib", strip that off
98+ string (REGEX REPLACE "^lib" "" lib_name "${lib_name} " )
99+ # Now prepend "-l" to the actual library name
100+ list (APPEND MY_LIBS "-l${lib_name} " )
101+ endforeach ()
102+
103+
104+ find_package (chpl REQUIRED HINTS ${PROJECT_ROOT_DIR} /cmake/chapel )
105+ list (APPEND CMAKE_MODULE_PATH "${PROJECT_ROOT_DIR} /cmake" )
106+ list (APPEND CMAKE_MODULE_PATH "${PROJECT_ROOT_DIR} /cmake/chapel" )
107+
108+ project (MyProject LANGUAGES CXX C CHPL)
109+
86110# ------------------------------------------------------------------------------
87111# 2) Create an INTERFACE library to wrap the installed static libs
88112# ------------------------------------------------------------------------------
@@ -99,6 +123,7 @@ add_dependencies(torch_interface pytorch)
99123target_include_directories (torch_interface INTERFACE
100124 "${PYTORCH_INSTALL_DIR} /include"
101125 "${PYTORCH_INSTALL_DIR} /include/torch/csrc/api/include"
126+ # "${PYTORCH_BUILD_DIR}/aten/src/include"
102127)
103128
104129# Link the relevant static libraries. For a minimal CPU-only build,
@@ -126,17 +151,22 @@ add_executable(CHPLTest lib/CHPLTest.chpl)
126151add_library (torchbridge STATIC "${PROJECT_ROOT_DIR} /lib/bridge.cpp" "${PROJECT_ROOT_DIR} /include/bridge.h" )
127152add_dependencies (torchbridge torch_interface )
128153
129- target_include_directories (torchbridge PUBLIC
154+ target_include_directories (torchbridge PRIVATE
130155 "${PYTORCH_INSTALL_DIR} /include"
131156 "${PYTORCH_INSTALL_DIR} /include/torch/csrc/api/include"
132157 "${PROJECT_ROOT_DIR} /include"
158+ # "${PYTORCH_BUILD_DIR}/aten/src/include"
133159)
134160# target_link_directories(torchbridge PUBLIC
135161# "${PYTORCH_INSTALL_DIR}/lib"
136162# )
137163target_link_libraries (torchbridge
138- torch_interface
139- ${PYTORCH_LIBS}
164+ PRIVATE
165+ torch_interface
166+ ${PYTORCH_LIBS}
167+ pthread
168+ dl
169+ rt
140170 )
141171
142172
@@ -145,23 +175,29 @@ target_link_libraries(torchbridge
145175
146176add_executable (Bridge lib/Bridge.chpl include /bridge.h )
147177# add_dependencies(TorchBridge torchbridge)
178+ add_dependencies (Bridge torchbridge )
148179
149180target_link_options (Bridge
150181 PRIVATE
151182 "${PROJECT_ROOT_DIR} /include/bridge.h"
152183 "-L${PROJECT_BINARY_DIR} "
184+ "-ltorchbridge"
153185 -L.
154186 "-ltorchbridge"
155- "-I${PROJECT_BINARY_DIR} "
156- "-L${PYTORCH_INSTALL_DIR} /lib"
157- "-I${PYTORCH_INSTALL_DIR} /include"
158- "-I${PYTORCH_INSTALL_DIR} /include/torch/csrc/api/include"
159- "-ltorch"
160- "-ltorch_cpu"
161- "-lcpuinfo"
162- "-lc10"
163- "-lpthread"
164- "-ldl"
187+ # "-I${PROJECT_BINARY_DIR}"
188+ # "-L${PYTORCH_INSTALL_DIR}/lib"
189+ # "-I${PYTORCH_INSTALL_DIR}/include"
190+ # "-I${PYTORCH_INSTALL_DIR}/include/torch/csrc/api/include"
191+ # "-ltorch"
192+ # "-ltorch_cpu"
193+ # "-lcpuinfo"
194+ # "-lc10"
195+ # "-lsleef"
196+ # "-lclog"
197+ # "-lprotoc"
198+ # ${PYTORCH_LIBS_LINKER_ARGS}
199+ # "-lpthread"
200+ # "-ldl"
165201 )
166202
167203
0 commit comments