Skip to content

Commit 87fe770

Browse files
author
Diptorup Deb
authored
Merge pull request #210 from diptorupd/build/build_script
Adds a python build script to build IMEX.
2 parents ec77c02 + 3ad0ccd commit 87fe770

File tree

12 files changed

+669
-37
lines changed

12 files changed

+669
-37
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,8 @@ CMakeLists.txt.user
175175

176176
# Build dir
177177
/cmake_build
178+
_build
179+
_install
178180

179181
# pip wheels
180182
*.whl

CMakeLists.txt

Lines changed: 51 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,28 @@ if (CMAKE_SYSTEM_NAME STREQUAL Windows)
4040
# add_link_options(-INTEGRITYCHECK) # require signatures of libs, only recommended
4141
endif()
4242
if (CMAKE_SYSTEM_NAME STREQUAL Linux)
43-
add_compile_options(-D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security -fno-delete-null-pointer-checks -fstack-protector-strong -fno-strict-overflow -Wall)
44-
add_compile_options(-fstack-clash-protection -fcf-protection=full) # v8.0 and newer
43+
string(CONCAT WARN_FLAGS
44+
"-Wall "
45+
"-Wextra "
46+
"-Winit-self "
47+
"-Wunused-function "
48+
"-Wuninitialized "
49+
"-Wmissing-declarations "
50+
"-fdiagnostics-color=auto "
51+
"-Wno-deprecated-declarations "
52+
)
53+
string(CONCAT SDL_FLAGS
54+
"-D_FORTIFY_SOURCE=2 "
55+
"-Wformat "
56+
"-Wformat-security "
57+
"-Werror=format-security "
58+
"-fno-delete-null-pointer-checks "
59+
"-fstack-protector-strong "
60+
"-fno-strict-overflow "
61+
"-fstack-clash-protection "
62+
"-fcf-protection=full "
63+
)
64+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARN_FLAGS} ${SDL_FLAGS}")
4565
# add_compile_options(-mcet) # v8.0 and newer # unrecognized command line option '-mcet', only recommended
4666
add_link_options(-Wl,-z,noexecstack,-z,relro,-z,now)
4767
endif()
@@ -51,18 +71,32 @@ if (CMAKE_SYSTEM_NAME STREQUAL Darwin)
5171
# add_compile_options(-mcet) # v8.0 and newer # unrecognized command line option '-mcet', only recommended
5272
endif()
5373

54-
option(DPNP_ENABLE "Use DPNP for some math functions" OFF)
55-
option(GPU_ENABLE "Enable GPU codegen" OFF)
56-
option(NUMBA_ENABLE "Enable numba-based python frontend" OFF)
57-
option(TBB_ENABLE "Enable TBB" OFF)
58-
59-
message(STATUS "DPNP_ENABLE ${DPNP_ENABLE}")
60-
message(STATUS "GPU_ENABLE ${GPU_ENABLE}")
61-
message(STATUS "BUILD_TESTING ${BUILD_TESTING}")
62-
message(STATUS "NUMBA_ENABLE ${NUMBA_ENABLE}")
63-
message(STATUS "TBB_ENABLE ${TBB_ENABLE}")
74+
option(IMEX_USE_DPNP
75+
"Use the dpnp Python NumPy-like library for some math functions"
76+
OFF
77+
)
78+
option(IMEX_ENABLE_IGPU_DIALECT
79+
"Enable GPU codegen"
80+
OFF
81+
)
82+
option(IMEX_ENABLE_NUMBA_FE
83+
"Enable numba-based python frontend"
84+
OFF
85+
)
86+
option(IMEX_ENABLE_TBB_SUPPORT
87+
"Enable TBB"
88+
OFF
89+
)
90+
option(IMEX_ENABLE_TESTS
91+
"Enable CTests"
92+
OFF
93+
)
6494

65-
include(CTest)
95+
message(STATUS "IMEX_USE_DPNP ${DPNIMEX_USE_DPNPP_ENABLE}")
96+
message(STATUS "IMEX_ENABLE_IGPU_DIALECT ${IMEX_ENABLE_IGPU_DIALECT}")
97+
message(STATUS "IMEX_ENABLE_TESTS ${IMEX_ENABLE_TESTS}")
98+
message(STATUS "IMEX_ENABLE_NUMBA_FE ${IMEX_ENABLE_NUMBA_FE}")
99+
message(STATUS "IMEX_ENABLE_TBB_SUPPORT ${IMEX_ENABLE_TBB_SUPPORT}")
66100

67101
macro(apply_llvm_compile_flags target)
68102
if (MSVC)
@@ -71,7 +105,7 @@ macro(apply_llvm_compile_flags target)
71105
target_compile_definitions(${target} PRIVATE ${LLVM_DEFINITIONS})
72106
endmacro()
73107

74-
if(GPU_ENABLE)
108+
if(IMEX_ENABLE_IGPU_DIALECT)
75109
if(DEFINED ENV{LEVEL_ZERO_VERSION_CHECK_OFF})
76110
find_package(LevelZero REQUIRED)
77111
else()
@@ -84,10 +118,11 @@ add_subdirectory(mlir)
84118
add_subdirectory(dpcomp_runtime)
85119
add_subdirectory(tools)
86120

87-
if(NUMBA_ENABLE)
121+
if(IMEX_ENABLE_NUMBA_FE)
88122
add_subdirectory(numba_dpcomp)
89123
endif()
90124

91-
if(BUILD_TESTING)
125+
if(IMEX_ENABLE_TESTS)
126+
include(CTest)
92127
add_subdirectory(test)
93128
endif()

dpcomp_runtime/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ project(dpcomp-runtime LANGUAGES CXX C)
1616

1717
include(GenerateExportHeader)
1818

19-
if(TBB_ENABLE)
19+
if(IMEX_ENABLE_TBB_SUPPORT)
2020
find_package(TBB REQUIRED)
2121
endif()
2222

@@ -39,7 +39,7 @@ target_include_directories(${PROJECT_NAME} SYSTEM PRIVATE
3939
${PROJECT_BINARY_DIR}
4040
)
4141

42-
if(TBB_ENABLE)
43-
target_compile_definitions(${PROJECT_NAME} PRIVATE TBB_ENABLE=1)
42+
if(IMEX_ENABLE_TBB_SUPPORT)
43+
target_compile_definitions(${PROJECT_NAME} PRIVATE IMEX_ENABLE_TBB_SUPPORT=1)
4444
target_link_libraries(${PROJECT_NAME} TBB::tbb)
4545
endif()

dpcomp_runtime/lib/tbb_parallel.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
#ifdef TBB_ENABLE
15+
#ifdef IMEX_ENABLE_TBB_SUPPORT
1616

1717
#include <array>
1818
#include <cassert>
@@ -246,4 +246,4 @@ DPCOMP_RUNTIME_EXPORT void dpcompParallelFinalize() {
246246
globalContext.reset();
247247
}
248248
}
249-
#endif // TBB_ENABLE
249+
#endif // IMEX_ENABLE_TBB_SUPPORT

mlir/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ add_subdirectory(include/mlir-extensions/dialect/plier)
4141
add_subdirectory(include/mlir-extensions/dialect/plier_util)
4242
add_subdirectory(include/mlir-extensions/dialect/gpu_runtime/IR)
4343

44-
if (GPU_ENABLE)
44+
if (IMEX_ENABLE_IGPU_DIALECT)
4545
add_subdirectory(tools)
4646
endif()
4747

numba_dpcomp/numba_dpcomp/math_runtime/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ target_include_directories(${PROJECT_NAME} PRIVATE
3131
${PROJECT_BINARY_DIR}
3232
)
3333

34-
if(DPNP_ENABLE)
34+
if(IMEX_USE_DPNP)
3535
target_include_directories(${PROJECT_NAME} PRIVATE
3636
${DPNP_INCLUDE_DIR}
3737
)
@@ -45,5 +45,5 @@ if(DPNP_ENABLE)
4545
INSTALL_RPATH "${DPNP_RPATH}"
4646
)
4747

48-
target_compile_definitions(${PROJECT_NAME} PRIVATE DPNP_ENABLE=1)
48+
target_compile_definitions(${PROJECT_NAME} PRIVATE IMEX_USE_DPNP=1)
4949
endif()

numba_dpcomp/numba_dpcomp/math_runtime/lib/numpy_linalg.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@
1616

1717
#include "common.hpp"
1818

19-
#ifdef DPNP_ENABLE
19+
#ifdef IMEX_USE_DPNP
2020
#include <dpnp_iface.hpp>
2121
#endif
2222

2323
namespace {
2424
template <typename T>
2525
void eigImpl(Memref<2, const T> *input, Memref<1, T> *vals,
2626
Memref<2, T> *vecs) {
27-
#ifdef DPNP_ENABLE
27+
#ifdef IMEX_USE_DPNP
2828
dpnp_eig_c<T, T>(input->data, vals->data, vecs->data, input->dims[0]);
2929
#else
3030
(void)input;

numba_dpcomp/numba_dpcomp/mlir_compiler/CMakeLists.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,12 @@ target_include_directories(${PROJECT_NAME} SYSTEM PRIVATE
101101
PRIVATE
102102
./lib)
103103

104-
if(DPNP_ENABLE)
105-
target_compile_definitions(${PROJECT_NAME} PRIVATE DPNP_ENABLE=1)
104+
if(IMEX_USE_DPNP)
105+
target_compile_definitions(${PROJECT_NAME} PRIVATE IMEX_USE_DPNP=1)
106106
endif()
107107

108-
if(GPU_ENABLE)
109-
target_compile_definitions(${PROJECT_NAME} PRIVATE GPU_ENABLE=1)
108+
if(IMEX_ENABLE_IGPU_DIALECT)
109+
target_compile_definitions(${PROJECT_NAME} PRIVATE IMEX_ENABLE_IGPU_DIALECT=1)
110110
endif()
111111

112112
set(CMAKE_INSTALL_BINDIR ./numba_dpcomp/numba_dpcomp)
@@ -117,7 +117,7 @@ install(TARGETS dpcomp-runtime dpcomp-math-runtime dpcomp-python-runtime mlir_co
117117
LIBRARY DESTINATION numba_dpcomp/numba_dpcomp
118118
)
119119

120-
if(GPU_ENABLE)
120+
if(IMEX_ENABLE_IGPU_DIALECT)
121121
install(TARGETS dpcomp-gpu-runtime
122122
LIBRARY DESTINATION numba_dpcomp/numba_dpcomp
123123
)

numba_dpcomp/numba_dpcomp/mlir_compiler/lib/lowering.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,7 @@ static void createPipeline(plier::PipelineRegistry &registry,
711711
registerParallelToTBBPipeline(registry);
712712

713713
if (settings.enableGpuPipeline) {
714-
#ifdef GPU_ENABLE
714+
#ifdef IMEX_ENABLE_IGPU_DIALECT
715715
registerLowerToGPUPipeline(registry);
716716
// TODO(nbpatel): Add Gpu->GpuRuntime & GpuRuntimetoLlvm Transformation
717717
#else

numba_dpcomp/numba_dpcomp/mlir_compiler/lib/py_module.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
namespace {
2222
bool is_dpnp_supported() {
23-
#ifdef DPNP_ENABLE
23+
#ifdef IMEX_USE_DPNP
2424
return true;
2525
#else
2626
return false;

0 commit comments

Comments
 (0)