Skip to content
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

Build/build script #210

Merged
merged 2 commits into from
May 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ CMakeLists.txt.user

# Build dir
/cmake_build
_build
_install

# pip wheels
*.whl
67 changes: 51 additions & 16 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,28 @@ if (CMAKE_SYSTEM_NAME STREQUAL Windows)
# add_link_options(-INTEGRITYCHECK) # require signatures of libs, only recommended
endif()
if (CMAKE_SYSTEM_NAME STREQUAL Linux)
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)
add_compile_options(-fstack-clash-protection -fcf-protection=full) # v8.0 and newer
string(CONCAT WARN_FLAGS
"-Wall "
"-Wextra "
"-Winit-self "
"-Wunused-function "
"-Wuninitialized "
"-Wmissing-declarations "
"-fdiagnostics-color=auto "
"-Wno-deprecated-declarations "
)
string(CONCAT SDL_FLAGS
"-D_FORTIFY_SOURCE=2 "
"-Wformat "
"-Wformat-security "
"-Werror=format-security "
"-fno-delete-null-pointer-checks "
"-fstack-protector-strong "
"-fno-strict-overflow "
"-fstack-clash-protection "
"-fcf-protection=full "
)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARN_FLAGS} ${SDL_FLAGS}")
# add_compile_options(-mcet) # v8.0 and newer # unrecognized command line option '-mcet', only recommended
add_link_options(-Wl,-z,noexecstack,-z,relro,-z,now)
endif()
Expand All @@ -51,18 +71,32 @@ if (CMAKE_SYSTEM_NAME STREQUAL Darwin)
# add_compile_options(-mcet) # v8.0 and newer # unrecognized command line option '-mcet', only recommended
endif()

option(DPNP_ENABLE "Use DPNP for some math functions" OFF)
option(GPU_ENABLE "Enable GPU codegen" OFF)
option(NUMBA_ENABLE "Enable numba-based python frontend" OFF)
option(TBB_ENABLE "Enable TBB" OFF)

message(STATUS "DPNP_ENABLE ${DPNP_ENABLE}")
message(STATUS "GPU_ENABLE ${GPU_ENABLE}")
message(STATUS "BUILD_TESTING ${BUILD_TESTING}")
message(STATUS "NUMBA_ENABLE ${NUMBA_ENABLE}")
message(STATUS "TBB_ENABLE ${TBB_ENABLE}")
option(IMEX_USE_DPNP
"Use the dpnp Python NumPy-like library for some math functions"
OFF
)
option(IMEX_ENABLE_IGPU_DIALECT
"Enable GPU codegen"
OFF
)
option(IMEX_ENABLE_NUMBA_FE
"Enable numba-based python frontend"
OFF
)
option(IMEX_ENABLE_TBB_SUPPORT
"Enable TBB"
OFF
)
option(IMEX_ENABLE_TESTS
"Enable CTests"
OFF
)

include(CTest)
message(STATUS "IMEX_USE_DPNP ${DPNIMEX_USE_DPNPP_ENABLE}")
message(STATUS "IMEX_ENABLE_IGPU_DIALECT ${IMEX_ENABLE_IGPU_DIALECT}")
message(STATUS "IMEX_ENABLE_TESTS ${IMEX_ENABLE_TESTS}")
message(STATUS "IMEX_ENABLE_NUMBA_FE ${IMEX_ENABLE_NUMBA_FE}")
message(STATUS "IMEX_ENABLE_TBB_SUPPORT ${IMEX_ENABLE_TBB_SUPPORT}")

macro(apply_llvm_compile_flags target)
if (MSVC)
Expand All @@ -71,7 +105,7 @@ macro(apply_llvm_compile_flags target)
target_compile_definitions(${target} PRIVATE ${LLVM_DEFINITIONS})
endmacro()

if(GPU_ENABLE)
if(IMEX_ENABLE_IGPU_DIALECT)
if(DEFINED ENV{LEVEL_ZERO_VERSION_CHECK_OFF})
find_package(LevelZero REQUIRED)
else()
Expand All @@ -84,10 +118,11 @@ add_subdirectory(mlir)
add_subdirectory(dpcomp_runtime)
add_subdirectory(tools)

if(NUMBA_ENABLE)
if(IMEX_ENABLE_NUMBA_FE)
add_subdirectory(numba_dpcomp)
endif()

if(BUILD_TESTING)
if(IMEX_ENABLE_TESTS)
include(CTest)
add_subdirectory(test)
endif()
6 changes: 3 additions & 3 deletions dpcomp_runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ project(dpcomp-runtime LANGUAGES CXX C)

include(GenerateExportHeader)

if(TBB_ENABLE)
if(IMEX_ENABLE_TBB_SUPPORT)
find_package(TBB REQUIRED)
endif()

Expand All @@ -39,7 +39,7 @@ target_include_directories(${PROJECT_NAME} SYSTEM PRIVATE
${PROJECT_BINARY_DIR}
)

if(TBB_ENABLE)
target_compile_definitions(${PROJECT_NAME} PRIVATE TBB_ENABLE=1)
if(IMEX_ENABLE_TBB_SUPPORT)
target_compile_definitions(${PROJECT_NAME} PRIVATE IMEX_ENABLE_TBB_SUPPORT=1)
target_link_libraries(${PROJECT_NAME} TBB::tbb)
endif()
4 changes: 2 additions & 2 deletions dpcomp_runtime/lib/tbb_parallel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#ifdef TBB_ENABLE
#ifdef IMEX_ENABLE_TBB_SUPPORT

#include <array>
#include <cassert>
Expand Down Expand Up @@ -246,4 +246,4 @@ DPCOMP_RUNTIME_EXPORT void dpcompParallelFinalize() {
globalContext.reset();
}
}
#endif // TBB_ENABLE
#endif // IMEX_ENABLE_TBB_SUPPORT
2 changes: 1 addition & 1 deletion mlir/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ add_subdirectory(include/mlir-extensions/dialect/plier)
add_subdirectory(include/mlir-extensions/dialect/plier_util)
add_subdirectory(include/mlir-extensions/dialect/gpu_runtime/IR)

if (GPU_ENABLE)
if (IMEX_ENABLE_IGPU_DIALECT)
add_subdirectory(tools)
endif()

Expand Down
4 changes: 2 additions & 2 deletions numba_dpcomp/numba_dpcomp/math_runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ target_include_directories(${PROJECT_NAME} PRIVATE
${PROJECT_BINARY_DIR}
)

if(DPNP_ENABLE)
if(IMEX_USE_DPNP)
target_include_directories(${PROJECT_NAME} PRIVATE
${DPNP_INCLUDE_DIR}
)
Expand All @@ -45,5 +45,5 @@ if(DPNP_ENABLE)
INSTALL_RPATH "${DPNP_RPATH}"
)

target_compile_definitions(${PROJECT_NAME} PRIVATE DPNP_ENABLE=1)
target_compile_definitions(${PROJECT_NAME} PRIVATE IMEX_USE_DPNP=1)
endif()
4 changes: 2 additions & 2 deletions numba_dpcomp/numba_dpcomp/math_runtime/lib/numpy_linalg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@

#include "common.hpp"

#ifdef DPNP_ENABLE
#ifdef IMEX_USE_DPNP
#include <dpnp_iface.hpp>
#endif

namespace {
template <typename T>
void eigImpl(Memref<2, const T> *input, Memref<1, T> *vals,
Memref<2, T> *vecs) {
#ifdef DPNP_ENABLE
#ifdef IMEX_USE_DPNP
dpnp_eig_c<T, T>(input->data, vals->data, vecs->data, input->dims[0]);
#else
(void)input;
Expand Down
10 changes: 5 additions & 5 deletions numba_dpcomp/numba_dpcomp/mlir_compiler/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,12 @@ target_include_directories(${PROJECT_NAME} SYSTEM PRIVATE
PRIVATE
./lib)

if(DPNP_ENABLE)
target_compile_definitions(${PROJECT_NAME} PRIVATE DPNP_ENABLE=1)
if(IMEX_USE_DPNP)
target_compile_definitions(${PROJECT_NAME} PRIVATE IMEX_USE_DPNP=1)
endif()

if(GPU_ENABLE)
target_compile_definitions(${PROJECT_NAME} PRIVATE GPU_ENABLE=1)
if(IMEX_ENABLE_IGPU_DIALECT)
target_compile_definitions(${PROJECT_NAME} PRIVATE IMEX_ENABLE_IGPU_DIALECT=1)
endif()

set(CMAKE_INSTALL_BINDIR ./numba_dpcomp/numba_dpcomp)
Expand All @@ -117,7 +117,7 @@ install(TARGETS dpcomp-runtime dpcomp-math-runtime dpcomp-python-runtime mlir_co
LIBRARY DESTINATION numba_dpcomp/numba_dpcomp
)

if(GPU_ENABLE)
if(IMEX_ENABLE_IGPU_DIALECT)
install(TARGETS dpcomp-gpu-runtime
LIBRARY DESTINATION numba_dpcomp/numba_dpcomp
)
Expand Down
2 changes: 1 addition & 1 deletion numba_dpcomp/numba_dpcomp/mlir_compiler/lib/lowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,7 @@ static void createPipeline(plier::PipelineRegistry &registry,
registerParallelToTBBPipeline(registry);

if (settings.enableGpuPipeline) {
#ifdef GPU_ENABLE
#ifdef IMEX_ENABLE_IGPU_DIALECT
registerLowerToGPUPipeline(registry);
// TODO(nbpatel): Add Gpu->GpuRuntime & GpuRuntimetoLlvm Transformation
#else
Expand Down
2 changes: 1 addition & 1 deletion numba_dpcomp/numba_dpcomp/mlir_compiler/lib/py_module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

namespace {
bool is_dpnp_supported() {
#ifdef DPNP_ENABLE
#ifdef IMEX_USE_DPNP
return true;
#else
return false;
Expand Down
8 changes: 4 additions & 4 deletions numba_dpcomp/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@
"-DCMAKE_INSTALL_PREFIX=" + CMAKE_INSTALL_PREFIX,
"-DPython3_NumPy_INCLUDE_DIRS=" + NUMPY_INCLUDE_DIR,
"-DPython3_FIND_STRATEGY=LOCATION",
"-DNUMBA_ENABLE=ON",
"-DTBB_ENABLE=ON",
"-DIMEX_ENABLE_NUMBA_FE=ON",
"-DIMEX_ENABLE_TBB_SUPPORT=ON",
]

# DPNP
Expand All @@ -76,7 +76,7 @@
cmake_cmd += [
"-DDPNP_LIBRARY_DIR=" + DPNP_LIBRARY_DIR,
"-DDPNP_INCLUDE_DIR=" + DPNP_INCLUDE_DIR,
"-DDPNP_ENABLE=ON",
"-DIMEX_USE_DPNP=ON",
]
print("Found DPNP at", DPNP_LIBRARY_DIR)
except ImportError:
Expand All @@ -89,7 +89,7 @@
else:
print("LEVEL_ZERO_DIR is", LEVEL_ZERO_DIR)
cmake_cmd += [
"-DGPU_ENABLE=ON",
"-DIMEX_ENABLE_IGPU_DIALECT=ON",
]

try:
Expand Down
Loading