-
Notifications
You must be signed in to change notification settings - Fork 90
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
Add cmake-format, and a pre-commit hook for it #1755
base: develop
Are you sure you want to change the base?
Changes from all commits
26fc28c
979a5c2
a177376
4d33643
e36c6a1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,144 +1,184 @@ | ||
if (NOT CMAKE_BUILD_TYPE STREQUAL "Release") | ||
message(WARNING | ||
"Ginkgo is not being built in \"Release\" mode, benchmark performance " | ||
"will be affected") | ||
if(NOT CMAKE_BUILD_TYPE STREQUAL "Release") | ||
message( | ||
WARNING | ||
"Ginkgo is not being built in \"Release\" mode, benchmark performance " | ||
"will be affected" | ||
) | ||
endif() | ||
|
||
function(ginkgo_benchmark_add_tuning_maybe name) | ||
if(GINKGO_BENCHMARK_ENABLE_TUNING) | ||
target_sources(${name} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../utils/tuning_variables.cpp) | ||
target_sources( | ||
${name} | ||
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../utils/tuning_variables.cpp | ||
) | ||
endif() | ||
endfunction() | ||
|
||
function(ginkgo_benchmark_cusparse_linops type def) | ||
add_library(cusparse_linops_${type} utils/cuda_linops.cpp) | ||
if(CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA") | ||
# remove false positive CUDA warnings when calling one<T>() and zero<T>() | ||
target_compile_options(cusparse_linops_${type} | ||
PRIVATE | ||
$<$<COMPILE_LANGUAGE:CUDA>:--expt-relaxed-constexpr>) | ||
# remove false positive CUDA warnings when calling one<T>() and | ||
# zero<T>() | ||
target_compile_options( | ||
cusparse_linops_${type} | ||
PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:--expt-relaxed-constexpr> | ||
) | ||
endif() | ||
if(GINKGO_CUDA_CUSTOM_THRUST_NAMESPACE) | ||
target_compile_definitions(cusparse_linops_${type} PRIVATE THRUST_CUB_WRAPPED_NAMESPACE=gko) | ||
target_compile_definitions( | ||
cusparse_linops_${type} PRIVATE THRUST_CUB_WRAPPED_NAMESPACE=gko | ||
) | ||
endif() | ||
# make the dependency public to catch issues | ||
target_compile_definitions(cusparse_linops_${type} PUBLIC ${def}) | ||
target_compile_definitions(cusparse_linops_${type} PRIVATE GKO_COMPILING_CUDA) | ||
target_link_libraries(cusparse_linops_${type} PRIVATE Ginkgo::ginkgo CUDA::cudart CUDA::cublas CUDA::cusparse) | ||
target_compile_definitions( | ||
cusparse_linops_${type} PRIVATE GKO_COMPILING_CUDA | ||
) | ||
target_link_libraries( | ||
cusparse_linops_${type} PRIVATE Ginkgo::ginkgo CUDA::cudart | ||
CUDA::cublas CUDA::cusparse | ||
) | ||
ginkgo_compile_features(cusparse_linops_${type}) | ||
endfunction() | ||
|
||
function(ginkgo_benchmark_hipsparse_linops type def) | ||
add_library(hipsparse_linops_${type} utils/hip_linops.hip.cpp) | ||
set_source_files_properties(utils/hip_linops.hip.cpp PROPERTIES LANGUAGE HIP) | ||
set_source_files_properties( | ||
utils/hip_linops.hip.cpp PROPERTIES LANGUAGE HIP | ||
) | ||
if(GINKGO_CUDA_CUSTOM_THRUST_NAMESPACE) | ||
target_compile_definitions(hipsparse_linops_${type} PRIVATE THRUST_CUB_WRAPPED_NAMESPACE=gko) | ||
target_compile_definitions( | ||
hipsparse_linops_${type} PRIVATE THRUST_CUB_WRAPPED_NAMESPACE=gko | ||
) | ||
endif() | ||
target_compile_definitions(hipsparse_linops_${type} PUBLIC ${def}) | ||
target_compile_definitions(hipsparse_linops_${type} PRIVATE GKO_COMPILING_HIP) | ||
target_include_directories(hipsparse_linops_${type} SYSTEM PRIVATE ${HIPBLAS_INCLUDE_DIRS} ${HIPSPARSE_INCLUDE_DIRS}) | ||
target_link_libraries(hipsparse_linops_${type} PRIVATE Ginkgo::ginkgo ${HIPSPARSE_LIBRARIES}) | ||
target_compile_definitions( | ||
hipsparse_linops_${type} PRIVATE GKO_COMPILING_HIP | ||
) | ||
target_include_directories( | ||
hipsparse_linops_${type} SYSTEM PRIVATE ${HIPBLAS_INCLUDE_DIRS} | ||
${HIPSPARSE_INCLUDE_DIRS} | ||
) | ||
target_link_libraries( | ||
hipsparse_linops_${type} PRIVATE Ginkgo::ginkgo ${HIPSPARSE_LIBRARIES} | ||
) | ||
ginkgo_compile_features(hipsparse_linops_${type}) | ||
endfunction() | ||
|
||
function(ginkgo_benchmark_onemkl_linops type def) | ||
add_library(onemkl_linops_${type} utils/dpcpp_linops.dp.cpp) | ||
# make the dependency public to catch issues | ||
target_compile_definitions(onemkl_linops_${type} PUBLIC ${def}) | ||
target_link_libraries(onemkl_linops_${type} PRIVATE Ginkgo::ginkgo MKL::MKL_DPCPP) | ||
target_link_libraries( | ||
onemkl_linops_${type} PRIVATE Ginkgo::ginkgo MKL::MKL_DPCPP | ||
) | ||
ginkgo_compile_features(onemkl_linops_${type}) | ||
endfunction() | ||
|
||
|
||
# Generates an executable for one precision. Each executable will be linked to | ||
# `ginkgo`, `gflags` and `nlohmann-json`. | ||
# Note: This should only be used by `ginkgo_add_typed_benchmark_executables` | ||
# `ginkgo`, `gflags` and `nlohmann-json`. Note: This should only be used by | ||
# `ginkgo_add_typed_benchmark_executables` | ||
# | ||
# \param name name for the executable to create (including type suffix) | ||
# \param use_lib_linops Boolean indicating if linking against hipsparse/cusparse | ||
# is necessary | ||
# \param macro_def preprocessor macro name that will be defined during | ||
# building (to compile for a specific type) | ||
# All remaining arguments will be treated as source files | ||
function(ginkgo_add_single_benchmark_executable name use_lib_linops macro_def type) | ||
# \param name name for the executable to create (including type | ||
# suffix) \param use_lib_linops Boolean indicating if linking against | ||
# hipsparse/cusparse is necessary \param macro_def preprocessor macro name | ||
# that will be defined during building (to compile for a specific type) All | ||
# remaining arguments will be treated as source files | ||
Comment on lines
+83
to
+87
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It destories the format |
||
function(ginkgo_add_single_benchmark_executable name use_lib_linops macro_def | ||
type | ||
) | ||
add_executable("${name}" ${ARGN}) | ||
target_link_libraries("${name}" ginkgo gflags nlohmann_json::nlohmann_json) | ||
# always include the device timer | ||
if (GINKGO_BUILD_CUDA) | ||
if(GINKGO_BUILD_CUDA) | ||
target_compile_definitions("${name}" PRIVATE HAS_CUDA_TIMER=1) | ||
target_link_libraries("${name}" cuda_timer) | ||
endif() | ||
if (GINKGO_BUILD_HIP) | ||
if(GINKGO_BUILD_HIP) | ||
target_compile_definitions("${name}" PRIVATE HAS_HIP_TIMER=1) | ||
target_link_libraries("${name}" hip_timer) | ||
endif() | ||
if (GINKGO_BUILD_SYCL) | ||
if(GINKGO_BUILD_SYCL) | ||
target_compile_definitions("${name}" PRIVATE HAS_DPCPP_TIMER=1) | ||
target_link_libraries("${name}" dpcpp_timer) | ||
endif() | ||
if (GINKGO_BUILD_MPI) | ||
if(GINKGO_BUILD_MPI) | ||
target_compile_definitions(${name} PRIVATE HAS_MPI_TIMER=1) | ||
target_link_libraries(${name} mpi_timer) | ||
endif() | ||
target_compile_definitions("${name}" PRIVATE "${macro_def}") | ||
ginkgo_benchmark_add_tuning_maybe("${name}") | ||
if("${use_lib_linops}") | ||
if (GINKGO_BUILD_CUDA) | ||
if(GINKGO_BUILD_CUDA) | ||
target_compile_definitions("${name}" PRIVATE HAS_CUDA=1) | ||
target_link_libraries("${name}" cusparse_linops_${type}) | ||
endif() | ||
if (GINKGO_BUILD_HIP) | ||
if(GINKGO_BUILD_HIP) | ||
target_compile_definitions("${name}" PRIVATE HAS_HIP=1) | ||
target_link_libraries("${name}" hipsparse_linops_${type}) | ||
endif() | ||
if (GINKGO_BUILD_SYCL) | ||
if(GINKGO_BUILD_SYCL) | ||
target_compile_definitions("${name}" PRIVATE HAS_DPCPP=1) | ||
target_link_libraries("${name}" onemkl_linops_${type}) | ||
endif() | ||
endif() | ||
endfunction(ginkgo_add_single_benchmark_executable) | ||
|
||
|
||
# Generates an executable for each supported precision. Each executable will be | ||
# linked to `ginkgo`, `gflags` and `nlohmann-json`. | ||
# | ||
# \param name base-name for the executable to create | ||
# \param use_lib_linops Boolean indicating if linking against hipsparse/cusparse | ||
# is necessary | ||
# All remaining arguments will be treated as source files | ||
# \param name base-name for the executable to create \param | ||
# use_lib_linops Boolean indicating if linking against hipsparse/cusparse is | ||
# necessary All remaining arguments will be treated as source files | ||
Comment on lines
+131
to
+133
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. format issue |
||
function(ginkgo_add_typed_benchmark_executables name use_lib_linops) | ||
ginkgo_add_single_benchmark_executable( | ||
"${name}" "${use_lib_linops}" "GKO_BENCHMARK_USE_DOUBLE_PRECISION" "d" ${ARGN}) | ||
"${name}" "${use_lib_linops}" "GKO_BENCHMARK_USE_DOUBLE_PRECISION" "d" | ||
${ARGN} | ||
) | ||
ginkgo_add_single_benchmark_executable( | ||
"${name}_single" "${use_lib_linops}" "GKO_BENCHMARK_USE_SINGLE_PRECISION" "s" ${ARGN}) | ||
"${name}_single" "${use_lib_linops}" | ||
"GKO_BENCHMARK_USE_SINGLE_PRECISION" "s" ${ARGN} | ||
) | ||
ginkgo_add_single_benchmark_executable( | ||
"${name}_dcomplex" "${use_lib_linops}" "GKO_BENCHMARK_USE_DOUBLE_COMPLEX_PRECISION" "z" ${ARGN}) | ||
"${name}_dcomplex" "${use_lib_linops}" | ||
"GKO_BENCHMARK_USE_DOUBLE_COMPLEX_PRECISION" "z" ${ARGN} | ||
) | ||
ginkgo_add_single_benchmark_executable( | ||
"${name}_scomplex" "${use_lib_linops}" "GKO_BENCHMARK_USE_SINGLE_COMPLEX_PRECISION" "c" ${ARGN}) | ||
"${name}_scomplex" "${use_lib_linops}" | ||
"GKO_BENCHMARK_USE_SINGLE_COMPLEX_PRECISION" "c" ${ARGN} | ||
) | ||
endfunction(ginkgo_add_typed_benchmark_executables) | ||
|
||
|
||
if (GINKGO_BUILD_CUDA) | ||
if(GINKGO_BUILD_CUDA) | ||
ginkgo_benchmark_cusparse_linops(d GKO_BENCHMARK_USE_DOUBLE_PRECISION) | ||
ginkgo_benchmark_cusparse_linops(s GKO_BENCHMARK_USE_SINGLE_PRECISION) | ||
ginkgo_benchmark_cusparse_linops(z GKO_BENCHMARK_USE_DOUBLE_COMPLEX_PRECISION) | ||
ginkgo_benchmark_cusparse_linops(c GKO_BENCHMARK_USE_SINGLE_COMPLEX_PRECISION) | ||
ginkgo_benchmark_cusparse_linops( | ||
z GKO_BENCHMARK_USE_DOUBLE_COMPLEX_PRECISION | ||
) | ||
ginkgo_benchmark_cusparse_linops( | ||
c GKO_BENCHMARK_USE_SINGLE_COMPLEX_PRECISION | ||
) | ||
add_library(cuda_timer utils/cuda_timer.cpp) | ||
target_link_libraries(cuda_timer PRIVATE ginkgo CUDA::cudart) | ||
ginkgo_compile_features(cuda_timer) | ||
endif() | ||
if (GINKGO_BUILD_HIP) | ||
if(GINKGO_BUILD_HIP) | ||
ginkgo_benchmark_hipsparse_linops(d GKO_BENCHMARK_USE_DOUBLE_PRECISION) | ||
ginkgo_benchmark_hipsparse_linops(s GKO_BENCHMARK_USE_SINGLE_PRECISION) | ||
ginkgo_benchmark_hipsparse_linops(z GKO_BENCHMARK_USE_DOUBLE_COMPLEX_PRECISION) | ||
ginkgo_benchmark_hipsparse_linops(c GKO_BENCHMARK_USE_SINGLE_COMPLEX_PRECISION) | ||
ginkgo_benchmark_hipsparse_linops( | ||
z GKO_BENCHMARK_USE_DOUBLE_COMPLEX_PRECISION | ||
) | ||
ginkgo_benchmark_hipsparse_linops( | ||
c GKO_BENCHMARK_USE_SINGLE_COMPLEX_PRECISION | ||
) | ||
set_source_files_properties(utils/hip_timer.hip.cpp PROPERTIES LANGUAGE HIP) | ||
add_library(hip_timer utils/hip_timer.hip.cpp) | ||
target_link_libraries(hip_timer PRIVATE ginkgo) | ||
ginkgo_compile_features(hip_timer) | ||
endif() | ||
|
||
if (GINKGO_BUILD_SYCL) | ||
if(GINKGO_BUILD_SYCL) | ||
ginkgo_benchmark_onemkl_linops(d GKO_BENCHMARK_USE_DOUBLE_PRECISION) | ||
ginkgo_benchmark_onemkl_linops(s GKO_BENCHMARK_USE_SINGLE_PRECISION) | ||
ginkgo_benchmark_onemkl_linops(z GKO_BENCHMARK_USE_DOUBLE_COMPLEX_PRECISION) | ||
|
@@ -150,7 +190,7 @@ if (GINKGO_BUILD_SYCL) | |
ginkgo_compile_features(dpcpp_timer) | ||
endif() | ||
|
||
if (GINKGO_BUILD_MPI) | ||
if(GINKGO_BUILD_MPI) | ||
add_library(mpi_timer ${Ginkgo_SOURCE_DIR}/benchmark/utils/mpi_timer.cpp) | ||
target_link_libraries(mpi_timer PRIVATE ginkgo) | ||
ginkgo_compile_features(mpi_timer) | ||
|
@@ -165,14 +205,16 @@ add_subdirectory(solver) | |
add_subdirectory(sparse_blas) | ||
add_subdirectory(spmv) | ||
add_subdirectory(tools) | ||
if (GINKGO_BUILD_TESTS) | ||
if(GINKGO_BUILD_TESTS) | ||
add_subdirectory(test) | ||
endif() | ||
|
||
configure_file(run_all_benchmarks.sh run_all_benchmarks.sh COPYONLY) | ||
|
||
add_custom_target(benchmark) | ||
add_custom_command( | ||
TARGET benchmark POST_BUILD | ||
TARGET benchmark | ||
POST_BUILD | ||
COMMAND bash run_all_benchmarks.sh >/dev/null | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
ginkgo_add_typed_benchmark_executables(multi_vector_distributed "NO" multi_vector.cpp) | ||
ginkgo_add_typed_benchmark_executables( | ||
multi_vector_distributed "NO" multi_vector.cpp | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
ginkgo_add_typed_benchmark_executables(matrix_generator "NO" matrix_generator.cpp) | ||
ginkgo_add_typed_benchmark_executables( | ||
matrix_generator "NO" matrix_generator.cpp | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
ginkgo_add_typed_benchmark_executables(matrix_statistics "NO" matrix_statistics.cpp) | ||
ginkgo_add_typed_benchmark_executables( | ||
matrix_statistics "NO" matrix_statistics.cpp | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
ginkgo_add_typed_benchmark_executables(sparse_blas "NO" sparse_blas.cpp operations.cpp) | ||
ginkgo_add_typed_benchmark_executables( | ||
sparse_blas "NO" sparse_blas.cpp operations.cpp | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is kind of uncontinued project