From 63cc3177e4f4ee93c34007e3b962875d093e4899 Mon Sep 17 00:00:00 2001 From: Tobias Ribizel Date: Wed, 10 Mar 2021 21:56:14 +0100 Subject: [PATCH 01/11] make example builds stand-alone capable --- examples/CMakeLists.txt | 16 ++++++++-- .../CMakeLists.txt | 15 +++++++--- examples/cb-gmres/CMakeLists.txt | 16 +++++++--- examples/custom-logger/CMakeLists.txt | 16 +++++++--- examples/custom-matrix-format/CMakeLists.txt | 30 +++++++++++-------- .../custom-stopping-criterion/CMakeLists.txt | 20 +++++++++---- examples/ginkgo-overhead/CMakeLists.txt | 14 ++++++--- examples/ginkgo-ranges/CMakeLists.txt | 14 ++++++--- examples/heat-equation/CMakeLists.txt | 23 +++++++------- .../ilu-preconditioned-solver/CMakeLists.txt | 16 +++++++--- examples/inverse-iteration/CMakeLists.txt | 16 +++++++--- .../CMakeLists.txt | 16 +++++++--- examples/iterative-refinement/CMakeLists.txt | 16 +++++++--- examples/minimal-cuda-solver/CMakeLists.txt | 16 +++++++--- examples/mixed-precision-ir/CMakeLists.txt | 16 +++++++--- .../nine-pt-stencil-solver/CMakeLists.txt | 14 ++++++--- examples/papi-logging/CMakeLists.txt | 22 +++++++++----- examples/par-ilu-convergence/CMakeLists.txt | 16 +++++++--- examples/performance-debugging/CMakeLists.txt | 16 +++++++--- examples/poisson-solver/CMakeLists.txt | 14 ++++++--- examples/preconditioned-solver/CMakeLists.txt | 15 +++++++--- examples/preconditioner-export/CMakeLists.txt | 16 +++++++--- examples/simple-solver-logging/CMakeLists.txt | 16 +++++++--- examples/simple-solver/CMakeLists.txt | 16 +++++++--- .../three-pt-stencil-solver/CMakeLists.txt | 14 ++++++--- 25 files changed, 299 insertions(+), 120 deletions(-) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 43b6f027990..559dea1b5c1 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -19,21 +19,31 @@ set(EXAMPLES_EXEC_LIST set(EXAMPLES_LIST ${EXAMPLES_EXEC_LIST} - custom-matrix-format custom-stopping-criterion ginkgo-overhead - heat-equation minimal-cuda-solver - papi-logging par-ilu-convergence performance-debugging preconditioner-export simple-solver-logging) +if(GINKGO_BUILD_CUDA AND GINKGO_BUILD_OMP) + list(APPEND EXAMPLES_LIST custom-matrix-format) +endif() + if(GINKGO_BUILD_EXTLIB_EXAMPLE) list(APPEND EXAMPLES_LIST external-lib-interfacing) endif() +find_package(OpenCV) +if(OpenCV_FOUND) + list(APPEND EXAMPLES_LIST heat-equation) +endif() + +if(GINKGO_HAVE_PAPI_SDE) + list(APPEND EXAMPLES_LIST papi-logging) +endif() + foreach(example ${EXAMPLES_LIST}) add_subdirectory(${example}) endforeach() diff --git a/examples/adaptiveprecision-blockjacobi/CMakeLists.txt b/examples/adaptiveprecision-blockjacobi/CMakeLists.txt index 5073564c8d1..b3d83725d0f 100644 --- a/examples/adaptiveprecision-blockjacobi/CMakeLists.txt +++ b/examples/adaptiveprecision-blockjacobi/CMakeLists.txt @@ -1,5 +1,12 @@ -set(target_name "adaptiveprecision-blockjacobi") -add_executable(${target_name} ${target_name}.cpp) -target_link_libraries(${target_name} Ginkgo::ginkgo) -target_include_directories(${target_name} PRIVATE ${PROJECT_SOURCE_DIR}) +cmake_minimum_required(VERSION 3.9) +project(adaptiveprecision-blockjacobi) + +# We only need to find Ginkgo if we build this example stand-alone +if (NOT GINKGO_BUILD_EXAMPLES) + find_package(Ginkgo 1.3.0 REQUIRED) +endif() + +add_executable(adaptiveprecision-blockjacobi adaptiveprecision-blockjacobi.cpp) +target_link_libraries(adaptiveprecision-blockjacobi Ginkgo::ginkgo) + configure_file(data/A.mtx data/A.mtx COPYONLY) diff --git a/examples/cb-gmres/CMakeLists.txt b/examples/cb-gmres/CMakeLists.txt index e3265883919..0234e4128ac 100644 --- a/examples/cb-gmres/CMakeLists.txt +++ b/examples/cb-gmres/CMakeLists.txt @@ -1,5 +1,13 @@ -set(target_name "cb-gmres") -add_executable(${target_name} ${target_name}.cpp) -target_link_libraries(${target_name} Ginkgo::ginkgo) -target_include_directories(${target_name} PRIVATE ${PROJECT_SOURCE_DIR}) +cmake_minimum_required(VERSION 3.9) +project(cb-gmres) + +# We only need to find Ginkgo if we build this example stand-alone +if (NOT GINKGO_BUILD_EXAMPLES) + find_package(Ginkgo 1.3.0 REQUIRED) +endif() + +add_executable(cb-gmres cb-gmres.cpp) +target_link_libraries(cb-gmres Ginkgo::ginkgo) + +# Copy the data files to the execution directory configure_file("${Ginkgo_SOURCE_DIR}/matrices/test/ani1.mtx" data/A.mtx COPYONLY) diff --git a/examples/custom-logger/CMakeLists.txt b/examples/custom-logger/CMakeLists.txt index d7978bed813..cf6fb7f4521 100644 --- a/examples/custom-logger/CMakeLists.txt +++ b/examples/custom-logger/CMakeLists.txt @@ -1,7 +1,15 @@ -set(target_name "custom-logger") -add_executable(${target_name} ${target_name}.cpp) -target_link_libraries(${target_name} Ginkgo::ginkgo) -target_include_directories(${target_name} PRIVATE ${PROJECT_SOURCE_DIR}) +cmake_minimum_required(VERSION 3.9) +project(custom-logger) + +# We only need to find Ginkgo if we build this example stand-alone +if (NOT GINKGO_BUILD_EXAMPLES) + find_package(Ginkgo 1.3.0 REQUIRED) +endif() + +add_executable(custom-logger custom-logger.cpp) +target_link_libraries(custom-logger Ginkgo::ginkgo) + +# Copy the data files to the execution directory configure_file(data/A.mtx data/A.mtx COPYONLY) configure_file(data/b.mtx data/b.mtx COPYONLY) configure_file(data/x0.mtx data/x0.mtx COPYONLY) diff --git a/examples/custom-matrix-format/CMakeLists.txt b/examples/custom-matrix-format/CMakeLists.txt index 52e52c1bca4..c008a86f7b0 100644 --- a/examples/custom-matrix-format/CMakeLists.txt +++ b/examples/custom-matrix-format/CMakeLists.txt @@ -1,14 +1,18 @@ -if (GINKGO_BUILD_CUDA AND GINKGO_BUILD_OMP) - enable_language(CUDA) - set(CMAKE_CUDA_STANDARD 14) - set(CMAKE_CUDA_STANDARD_REQUIRED ON) - set(target_name "custom-matrix-format") - add_executable(${target_name} - ${target_name}.cpp - stencil_kernel.cu) - target_link_libraries(${target_name} Ginkgo::ginkgo) - target_include_directories(${target_name} PRIVATE - ${PROJECT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) - # workaround for clang-cuda/g++ interaction - set_target_properties(${target_name} PROPERTIES POSITION_INDEPENDENT_CODE ON) +cmake_minimum_required(VERSION 3.9) +project(custom-matrix-format CXX CUDA) + +# We only need to find Ginkgo if we build this example stand-alone +if (NOT GINKGO_BUILD_EXAMPLES) + find_package(Ginkgo 1.3.0 REQUIRED) endif() + +set(CMAKE_CUDA_STANDARD 14) +set(CMAKE_CUDA_STANDARD_REQUIRED ON) + +add_executable(custom-matrix-format + custom-matrix-format.cpp + stencil_kernel.cu) +target_link_libraries(custom-matrix-format Ginkgo::ginkgo) + +# workaround for clang-cuda/g++ interaction +set_target_properties(custom-matrix-format PROPERTIES POSITION_INDEPENDENT_CODE ON) diff --git a/examples/custom-stopping-criterion/CMakeLists.txt b/examples/custom-stopping-criterion/CMakeLists.txt index 0a2196b814b..7d1db25a116 100644 --- a/examples/custom-stopping-criterion/CMakeLists.txt +++ b/examples/custom-stopping-criterion/CMakeLists.txt @@ -1,12 +1,20 @@ -set(target_name "custom-stopping-criterion") +cmake_minimum_required(VERSION 3.9) +project(custom-stopping-criterion) + +# We only need to find Ginkgo if we build this example stand-alone +if (NOT GINKGO_BUILD_EXAMPLES) + find_package(Ginkgo 1.3.0 REQUIRED) +endif() set(THREADS_PREFER_PTHREAD_FLAG ON) find_package(Threads REQUIRED) -add_executable(${target_name} - ${target_name}.cpp) -target_link_libraries(${target_name} Ginkgo::ginkgo + +add_executable(custom-stopping-criterion + custom-stopping-criterion.cpp) + +target_link_libraries(custom-stopping-criterion Ginkgo::ginkgo Threads::Threads) -target_include_directories(${target_name} - PRIVATE ${PROJECT_SOURCE_DIR}) + +# Copy the data files to the execution directory configure_file(data/A.mtx data/A.mtx COPYONLY) configure_file(data/b.mtx data/b.mtx COPYONLY) configure_file(data/x0.mtx data/x0.mtx COPYONLY) diff --git a/examples/ginkgo-overhead/CMakeLists.txt b/examples/ginkgo-overhead/CMakeLists.txt index 6f42ba09eb1..16328502185 100644 --- a/examples/ginkgo-overhead/CMakeLists.txt +++ b/examples/ginkgo-overhead/CMakeLists.txt @@ -1,4 +1,10 @@ -set(target_name "ginkgo-overhead") -add_executable(${target_name} ${target_name}.cpp) -target_link_libraries(${target_name} Ginkgo::ginkgo) -target_include_directories(${target_name} PRIVATE ${PROJECT_SOURCE_DIR}) +cmake_minimum_required(VERSION 3.9) +project(ginkgo-overhead) + +# We only need to find Ginkgo if we build this example stand-alone +if (NOT GINKGO_BUILD_EXAMPLES) + find_package(Ginkgo 1.3.0 REQUIRED) +endif() + +add_executable(ginkgo-overhead ginkgo-overhead.cpp) +target_link_libraries(ginkgo-overhead Ginkgo::ginkgo) diff --git a/examples/ginkgo-ranges/CMakeLists.txt b/examples/ginkgo-ranges/CMakeLists.txt index fc5ffa05f9c..943d8c2aef2 100644 --- a/examples/ginkgo-ranges/CMakeLists.txt +++ b/examples/ginkgo-ranges/CMakeLists.txt @@ -1,4 +1,10 @@ -set(target_name "ginkgo-ranges") -add_executable(${target_name} ${target_name}.cpp) -target_link_libraries(${target_name} Ginkgo::ginkgo) -target_include_directories(${target_name} PRIVATE ${PROJECT_SOURCE_DIR}) +cmake_minimum_required(VERSION 3.9) +project(ginkgo-ranges) + +# We only need to find Ginkgo if we build this example stand-alone +if (NOT GINKGO_BUILD_EXAMPLES) + find_package(Ginkgo 1.3.0 REQUIRED) +endif() +add_executable(ginkgo-ranges ginkgo-ranges.cpp) +target_link_libraries(ginkgo-ranges Ginkgo::ginkgo) +target_include_directories(ginkgo-ranges PRIVATE ${PROJECT_SOURCE_DIR}) diff --git a/examples/heat-equation/CMakeLists.txt b/examples/heat-equation/CMakeLists.txt index 75ba544a218..9de0f9ea83a 100644 --- a/examples/heat-equation/CMakeLists.txt +++ b/examples/heat-equation/CMakeLists.txt @@ -1,12 +1,15 @@ -set(target_name "heat-equation") -find_package(OpenCV) +cmake_minimum_required(VERSION 3.9) +project(heat-equation) -if (OpenCV_FOUND) - add_executable(${target_name} ${target_name}.cpp) - target_link_libraries(${target_name} Ginkgo::ginkgo ${OpenCV_LIBS}) - target_include_directories(${target_name} PRIVATE ${PROJECT_SOURCE_DIR}) - configure_file(data/initial.mtx data/initial.mtx COPYONLY) - configure_file(data/source.mtx data/source.mtx COPYONLY) -else() - message("OpenCV not found, skipping heat-equation example") +# We only need to find Ginkgo if we build this example stand-alone +if (NOT GINKGO_BUILD_EXAMPLES) + find_package(Ginkgo 1.3.0 REQUIRED) endif() +find_package(OpenCV REQUIRED) + +add_executable(heat-equation heat-equation.cpp) +target_link_libraries(heat-equation Ginkgo::ginkgo ${OpenCV_LIBS}) + +# Copy the data files to the execution directory +configure_file(data/initial.mtx data/initial.mtx COPYONLY) +configure_file(data/source.mtx data/source.mtx COPYONLY) diff --git a/examples/ilu-preconditioned-solver/CMakeLists.txt b/examples/ilu-preconditioned-solver/CMakeLists.txt index f33f050c356..6e971588215 100644 --- a/examples/ilu-preconditioned-solver/CMakeLists.txt +++ b/examples/ilu-preconditioned-solver/CMakeLists.txt @@ -1,7 +1,15 @@ -set(target_name "ilu-preconditioned-solver") -add_executable(${target_name} ${target_name}.cpp) -target_link_libraries(${target_name} Ginkgo::ginkgo) -target_include_directories(${target_name} PRIVATE ${PROJECT_SOURCE_DIR}) +cmake_minimum_required(VERSION 3.9) +project(ilu-preconditioned-solver) + +# We only need to find Ginkgo if we build this example stand-alone +if (NOT GINKGO_BUILD_EXAMPLES) + find_package(Ginkgo 1.3.0 REQUIRED) +endif() + +add_executable(ilu-preconditioned-solver ilu-preconditioned-solver.cpp) +target_link_libraries(ilu-preconditioned-solver Ginkgo::ginkgo) + +# Copy the data files to the execution directory configure_file(data/A.mtx data/A.mtx COPYONLY) configure_file(data/b.mtx data/b.mtx COPYONLY) configure_file(data/x0.mtx data/x0.mtx COPYONLY) diff --git a/examples/inverse-iteration/CMakeLists.txt b/examples/inverse-iteration/CMakeLists.txt index b7f9789eb65..03aa016b340 100644 --- a/examples/inverse-iteration/CMakeLists.txt +++ b/examples/inverse-iteration/CMakeLists.txt @@ -1,5 +1,13 @@ -set(target_name "inverse-iteration") -add_executable(${target_name} ${target_name}.cpp) -target_link_libraries(${target_name} Ginkgo::ginkgo) -target_include_directories(${target_name} PRIVATE ${PROJECT_SOURCE_DIR}) +cmake_minimum_required(VERSION 3.9) +project(inverse-iteration) + +# We only need to find Ginkgo if we build this example stand-alone +if (NOT GINKGO_BUILD_EXAMPLES) + find_package(Ginkgo 1.3.0 REQUIRED) +endif() + +add_executable(inverse-iteration inverse-iteration.cpp) +target_link_libraries(inverse-iteration Ginkgo::ginkgo) + +# Copy the data files to the execution directory configure_file(data/A.mtx data/A.mtx COPYONLY) diff --git a/examples/ir-ilu-preconditioned-solver/CMakeLists.txt b/examples/ir-ilu-preconditioned-solver/CMakeLists.txt index 6b4c267d6a3..76a11d405f1 100644 --- a/examples/ir-ilu-preconditioned-solver/CMakeLists.txt +++ b/examples/ir-ilu-preconditioned-solver/CMakeLists.txt @@ -1,5 +1,13 @@ -set(target_name "ir-ilu-preconditioned-solver") -add_executable(${target_name} ${target_name}.cpp) -target_link_libraries(${target_name} Ginkgo::ginkgo) -target_include_directories(${target_name} PRIVATE ${PROJECT_SOURCE_DIR}) +cmake_minimum_required(VERSION 3.9) +project(ir-ilu-preconditioned-solver) + +# We only need to find Ginkgo if we build this example stand-alone +if (NOT GINKGO_BUILD_EXAMPLES) + find_package(Ginkgo 1.3.0 REQUIRED) +endif() + +add_executable(ir-ilu-preconditioned-solver ir-ilu-preconditioned-solver.cpp) +target_link_libraries(ir-ilu-preconditioned-solver Ginkgo::ginkgo) + +# Copy the data files to the execution directory configure_file(data/A.mtx data/A.mtx COPYONLY) diff --git a/examples/iterative-refinement/CMakeLists.txt b/examples/iterative-refinement/CMakeLists.txt index 01d5600cdea..47c3942ae43 100644 --- a/examples/iterative-refinement/CMakeLists.txt +++ b/examples/iterative-refinement/CMakeLists.txt @@ -1,5 +1,13 @@ -set(target_name "iterative-refinement") -add_executable(${target_name} ${target_name}.cpp) -target_link_libraries(${target_name} Ginkgo::ginkgo) -target_include_directories(${target_name} PRIVATE ${PROJECT_SOURCE_DIR}) +cmake_minimum_required(VERSION 3.9) +project(iterative-refinement) + +# We only need to find Ginkgo if we build this example stand-alone +if (NOT GINKGO_BUILD_EXAMPLES) + find_package(Ginkgo 1.3.0 REQUIRED) +endif() + +add_executable(iterative-refinement iterative-refinement.cpp) +target_link_libraries(iterative-refinement Ginkgo::ginkgo) + +# Copy the data files to the execution directory configure_file(data/A.mtx data/A.mtx COPYONLY) diff --git a/examples/minimal-cuda-solver/CMakeLists.txt b/examples/minimal-cuda-solver/CMakeLists.txt index 4aa13017904..ffc9274e16b 100644 --- a/examples/minimal-cuda-solver/CMakeLists.txt +++ b/examples/minimal-cuda-solver/CMakeLists.txt @@ -1,7 +1,15 @@ -set(target_name "minimal-cuda-solver") -add_executable(${target_name} ${target_name}.cpp) -target_link_libraries(${target_name} Ginkgo::ginkgo) -target_include_directories(${target_name} PRIVATE ${PROJECT_SOURCE_DIR}) +cmake_minimum_required(VERSION 3.9) +project(minimal-cuda-solver) + +# We only need to find Ginkgo if we build this example stand-alone +if (NOT GINKGO_BUILD_EXAMPLES) + find_package(Ginkgo 1.3.0 REQUIRED) +endif() + +add_executable(minimal-cuda-solver minimal-cuda-solver.cpp) +target_link_libraries(minimal-cuda-solver Ginkgo::ginkgo) + +# Copy the data files to the execution directory configure_file(data/A.mtx data/A.mtx COPYONLY) configure_file(data/b.mtx data/b.mtx COPYONLY) configure_file(data/x0.mtx data/x0.mtx COPYONLY) diff --git a/examples/mixed-precision-ir/CMakeLists.txt b/examples/mixed-precision-ir/CMakeLists.txt index 109810c8657..8c23e367a82 100644 --- a/examples/mixed-precision-ir/CMakeLists.txt +++ b/examples/mixed-precision-ir/CMakeLists.txt @@ -1,5 +1,13 @@ -set(target_name "mixed-precision-ir") -add_executable(${target_name} ${target_name}.cpp) -target_link_libraries(${target_name} Ginkgo::ginkgo) -target_include_directories(${target_name} PRIVATE ${PROJECT_SOURCE_DIR}) +cmake_minimum_required(VERSION 3.9) +project(mixed-precision-ir) + +# We only need to find Ginkgo if we build this example stand-alone +if (NOT GINKGO_BUILD_EXAMPLES) + find_package(Ginkgo 1.3.0 REQUIRED) +endif() + +add_executable(mixed-precision-ir mixed-precision-ir.cpp) +target_link_libraries(mixed-precision-ir Ginkgo::ginkgo) + +# Copy the data files to the execution directory configure_file(data/A.mtx data/A.mtx COPYONLY) diff --git a/examples/nine-pt-stencil-solver/CMakeLists.txt b/examples/nine-pt-stencil-solver/CMakeLists.txt index bed21d0f93d..510f0e85f07 100644 --- a/examples/nine-pt-stencil-solver/CMakeLists.txt +++ b/examples/nine-pt-stencil-solver/CMakeLists.txt @@ -1,4 +1,10 @@ -set(target_name "nine-pt-stencil-solver") -add_executable(${target_name} ${target_name}.cpp) -target_link_libraries(${target_name} Ginkgo::ginkgo) -target_include_directories(${target_name} PRIVATE ${PROJECT_SOURCE_DIR}) +cmake_minimum_required(VERSION 3.9) +project(nine-pt-stencil-solver) + +# We only need to find Ginkgo if we build this example stand-alone +if (NOT GINKGO_BUILD_EXAMPLES) + find_package(Ginkgo 1.3.0 REQUIRED) +endif() + +add_executable(nine-pt-stencil-solver nine-pt-stencil-solver.cpp) +target_link_libraries(nine-pt-stencil-solver Ginkgo::ginkgo) diff --git a/examples/papi-logging/CMakeLists.txt b/examples/papi-logging/CMakeLists.txt index a5f079025ba..e3836ecbe3b 100644 --- a/examples/papi-logging/CMakeLists.txt +++ b/examples/papi-logging/CMakeLists.txt @@ -1,9 +1,15 @@ -if (GINKGO_HAVE_PAPI_SDE) - set(target_name "papi-logging") - add_executable(${target_name} ${target_name}.cpp) - target_link_libraries(${target_name} ginkgo PAPI::PAPI) - target_include_directories(${target_name} PRIVATE ${PROJECT_SOURCE_DIR}) - configure_file(data/A.mtx data/A.mtx COPYONLY) - configure_file(data/b.mtx data/b.mtx COPYONLY) - configure_file(data/x0.mtx data/x0.mtx COPYONLY) +cmake_minimum_required(VERSION 3.9) +project(papi-logging) + +# We only need to find Ginkgo if we build this example stand-alone +if (NOT GINKGO_BUILD_EXAMPLES) + find_package(Ginkgo 1.3.0 REQUIRED) endif() + +add_executable(papi-logging papi-logging.cpp) +target_link_libraries(papi-logging ginkgo PAPI::PAPI) + +# Copy the data files to the execution directory +configure_file(data/A.mtx data/A.mtx COPYONLY) +configure_file(data/b.mtx data/b.mtx COPYONLY) +configure_file(data/x0.mtx data/x0.mtx COPYONLY) diff --git a/examples/par-ilu-convergence/CMakeLists.txt b/examples/par-ilu-convergence/CMakeLists.txt index a81f0520a9a..ca2d88db12c 100644 --- a/examples/par-ilu-convergence/CMakeLists.txt +++ b/examples/par-ilu-convergence/CMakeLists.txt @@ -1,5 +1,13 @@ -set(target_name "par-ilu-convergence") -add_executable(${target_name} ${target_name}.cpp) -target_link_libraries(${target_name} Ginkgo::ginkgo) -target_include_directories(${target_name} PRIVATE ${PROJECT_SOURCE_DIR}) +cmake_minimum_required(VERSION 3.9) +project(par-ilu-convergence) + +# We only need to find Ginkgo if we build this example stand-alone +if (NOT GINKGO_BUILD_EXAMPLES) + find_package(Ginkgo 1.3.0 REQUIRED) +endif() + +add_executable(par-ilu-convergence par-ilu-convergence.cpp) +target_link_libraries(par-ilu-convergence Ginkgo::ginkgo) + +# Copy the data files to the execution directory configure_file(data/A.mtx data/A.mtx COPYONLY) diff --git a/examples/performance-debugging/CMakeLists.txt b/examples/performance-debugging/CMakeLists.txt index 6ca05939515..6161b858d22 100644 --- a/examples/performance-debugging/CMakeLists.txt +++ b/examples/performance-debugging/CMakeLists.txt @@ -1,5 +1,13 @@ -set(target_name "performance-debugging") -add_executable(${target_name} ${target_name}.cpp) -target_link_libraries(${target_name} Ginkgo::ginkgo) -target_include_directories(${target_name} PRIVATE ${PROJECT_SOURCE_DIR}) +cmake_minimum_required(VERSION 3.9) +project(performance-debugging) + +# We only need to find Ginkgo if we build this example stand-alone +if (NOT GINKGO_BUILD_EXAMPLES) + find_package(Ginkgo 1.3.0 REQUIRED) +endif() + +add_executable(performance-debugging performance-debugging.cpp) +target_link_libraries(performance-debugging Ginkgo::ginkgo) + +# Copy the data files to the execution directory configure_file(data/A.mtx data/A.mtx COPYONLY) diff --git a/examples/poisson-solver/CMakeLists.txt b/examples/poisson-solver/CMakeLists.txt index 5fc1e2ad83f..6c20c0fe087 100644 --- a/examples/poisson-solver/CMakeLists.txt +++ b/examples/poisson-solver/CMakeLists.txt @@ -1,4 +1,10 @@ -set(target_name "poisson-solver") -add_executable(${target_name} ${target_name}.cpp) -target_link_libraries(${target_name} Ginkgo::ginkgo) -target_include_directories(${target_name} PRIVATE ${PROJECT_SOURCE_DIR}) +cmake_minimum_required(VERSION 3.9) +project(poisson-solver) + +# We only need to find Ginkgo if we build this example stand-alone +if (NOT GINKGO_BUILD_EXAMPLES) + find_package(Ginkgo 1.3.0 REQUIRED) +endif() + +add_executable(poisson-solver poisson-solver.cpp) +target_link_libraries(poisson-solver Ginkgo::ginkgo) diff --git a/examples/preconditioned-solver/CMakeLists.txt b/examples/preconditioned-solver/CMakeLists.txt index a2c7898fd49..002f4ae7218 100644 --- a/examples/preconditioned-solver/CMakeLists.txt +++ b/examples/preconditioned-solver/CMakeLists.txt @@ -1,7 +1,14 @@ -set(target_name "preconditioned-solver") -add_executable(${target_name} ${target_name}.cpp) -target_link_libraries(${target_name} Ginkgo::ginkgo) -target_include_directories(${target_name} PRIVATE ${PROJECT_SOURCE_DIR}) +cmake_minimum_required(VERSION 3.9) +project(preconditioned-solver) + +# We only need to find Ginkgo if we build this example stand-alone +if (NOT GINKGO_BUILD_EXAMPLES) + find_package(Ginkgo 1.3.0 REQUIRED) +endif() +add_executable(preconditioned-solver preconditioned-solver.cpp) +target_link_libraries(preconditioned-solver Ginkgo::ginkgo) + +# Copy the data files to the execution directory configure_file(data/A.mtx data/A.mtx COPYONLY) configure_file(data/b.mtx data/b.mtx COPYONLY) configure_file(data/x0.mtx data/x0.mtx COPYONLY) diff --git a/examples/preconditioner-export/CMakeLists.txt b/examples/preconditioner-export/CMakeLists.txt index 04134b532af..81969576dcb 100644 --- a/examples/preconditioner-export/CMakeLists.txt +++ b/examples/preconditioner-export/CMakeLists.txt @@ -1,5 +1,13 @@ -set(target_name "preconditioner-export") -add_executable(${target_name} ${target_name}.cpp) -target_link_libraries(${target_name} Ginkgo::ginkgo) -target_include_directories(${target_name} PRIVATE ${PROJECT_SOURCE_DIR}) +cmake_minimum_required(VERSION 3.9) +project(preconditioner-export) + +# We only need to find Ginkgo if we build this example stand-alone +if (NOT GINKGO_BUILD_EXAMPLES) + find_package(Ginkgo 1.3.0 REQUIRED) +endif() + +add_executable(preconditioner-export preconditioner-export.cpp) +target_link_libraries(preconditioner-export Ginkgo::ginkgo) + +# Copy the data files to the execution directory configure_file(data/A.mtx data/A.mtx COPYONLY) diff --git a/examples/simple-solver-logging/CMakeLists.txt b/examples/simple-solver-logging/CMakeLists.txt index 545a1d9977c..1927690945e 100644 --- a/examples/simple-solver-logging/CMakeLists.txt +++ b/examples/simple-solver-logging/CMakeLists.txt @@ -1,7 +1,15 @@ -set(target_name "simple-solver-logging") -add_executable(${target_name} ${target_name}.cpp) -target_link_libraries(${target_name} Ginkgo::ginkgo) -target_include_directories(${target_name} PRIVATE ${PROJECT_SOURCE_DIR}) +cmake_minimum_required(VERSION 3.9) +project(simple-solver-logging) + +# We only need to find Ginkgo if we build this example stand-alone +if (NOT GINKGO_BUILD_EXAMPLES) + find_package(Ginkgo 1.3.0 REQUIRED) +endif() + +add_executable(simple-solver-logging simple-solver-logging.cpp) +target_link_libraries(simple-solver-logging Ginkgo::ginkgo) + +# Copy the data files to the execution directory configure_file(data/A.mtx data/A.mtx COPYONLY) configure_file(data/b.mtx data/b.mtx COPYONLY) configure_file(data/x0.mtx data/x0.mtx COPYONLY) diff --git a/examples/simple-solver/CMakeLists.txt b/examples/simple-solver/CMakeLists.txt index f30cb01ffca..5603fea0377 100644 --- a/examples/simple-solver/CMakeLists.txt +++ b/examples/simple-solver/CMakeLists.txt @@ -1,7 +1,15 @@ -set(target_name "simple-solver") -add_executable(${target_name} ${target_name}.cpp) -target_link_libraries(${target_name} Ginkgo::ginkgo) -target_include_directories(${target_name} PRIVATE ${PROJECT_SOURCE_DIR}) +cmake_minimum_required(VERSION 3.9) +project(simple-solver) + +# We only need to find Ginkgo if we build this example stand-alone +if (NOT GINKGO_BUILD_EXAMPLES) + find_package(Ginkgo 1.3.0 REQUIRED) +endif() + +add_executable(simple-solver simple-solver.cpp) +target_link_libraries(simple-solver Ginkgo::ginkgo) + +# Copy the data files to the execution directory configure_file(data/A.mtx data/A.mtx COPYONLY) configure_file(data/b.mtx data/b.mtx COPYONLY) configure_file(data/x0.mtx data/x0.mtx COPYONLY) diff --git a/examples/three-pt-stencil-solver/CMakeLists.txt b/examples/three-pt-stencil-solver/CMakeLists.txt index c12b2ee7ff2..34842e283af 100644 --- a/examples/three-pt-stencil-solver/CMakeLists.txt +++ b/examples/three-pt-stencil-solver/CMakeLists.txt @@ -1,4 +1,10 @@ -set(target_name "three-pt-stencil-solver") -add_executable(${target_name} ${target_name}.cpp) -target_link_libraries(${target_name} Ginkgo::ginkgo) -target_include_directories(${target_name} PRIVATE ${PROJECT_SOURCE_DIR}) +cmake_minimum_required(VERSION 3.9) +project(three-pt-stencil-solver) + +# We only need to find Ginkgo if we build this example stand-alone +if (NOT GINKGO_BUILD_EXAMPLES) + find_package(Ginkgo 1.3.0 REQUIRED) +endif() + +add_executable(three-pt-stencil-solver three-pt-stencil-solver.cpp) +target_link_libraries(three-pt-stencil-solver Ginkgo::ginkgo) From 789100642bf1285cb2e1feb68264fd2158aaba7b Mon Sep 17 00:00:00 2001 From: Tobias Ribizel Date: Wed, 10 Mar 2021 21:57:17 +0100 Subject: [PATCH 02/11] add OpenMP version requirement --- cmake/autodetect_executors.cmake | 2 +- omp/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/autodetect_executors.cmake b/cmake/autodetect_executors.cmake index c432a92d593..71e2456edbc 100644 --- a/cmake/autodetect_executors.cmake +++ b/cmake/autodetect_executors.cmake @@ -2,7 +2,7 @@ set(GINKGO_HAS_OMP OFF) set(GINKGO_HAS_CUDA OFF) set(GINKGO_HAS_DPCPP OFF) set(GINKGO_HAS_HIP OFF) -find_package(OpenMP) +find_package(OpenMP 3.0) include(CheckLanguage) check_language(CUDA) try_compile(GKO_CAN_COMPILE_DPCPP ${PROJECT_BINARY_DIR}/dpcpp diff --git a/omp/CMakeLists.txt b/omp/CMakeLists.txt index 87cbc30cd53..625cb2bc870 100644 --- a/omp/CMakeLists.txt +++ b/omp/CMakeLists.txt @@ -1,4 +1,4 @@ -find_package(OpenMP REQUIRED) +find_package(OpenMP 3.0 REQUIRED) add_library(ginkgo_omp $ "") target_sources(ginkgo_omp From 44defb1ebb58b55cef53559b8ef1dd8e3be12392 Mon Sep 17 00:00:00 2001 From: Tobias Ribizel Date: Wed, 10 Mar 2021 21:57:51 +0100 Subject: [PATCH 03/11] add /bigobj flags on Windows by default --- .github/workflows/windows-cygwin.yml | 2 +- .github/workflows/windows-mingw.yml | 2 +- .github/workflows/windows-msvc-cuda.yml | 2 +- .github/workflows/windows-msvc-ref.yml | 2 +- CMakeLists.txt | 7 +++++++ 5 files changed, 11 insertions(+), 4 deletions(-) diff --git a/.github/workflows/windows-cygwin.yml b/.github/workflows/windows-cygwin.yml index dbbba5f1e1c..ac890430d17 100644 --- a/.github/workflows/windows-cygwin.yml +++ b/.github/workflows/windows-cygwin.yml @@ -39,7 +39,7 @@ jobs: path C:\tools\cygwin\bin;%GITHUB_WORKSPACE%\build\windows_shared_library mkdir build cd build - bash -c "cmake -DCMAKE_CXX_FLAGS=-Wa,-mbig-obj -DBUILD_SHARED_LIBS=${{ matrix.config.shared }} -DCMAKE_BUILD_TYPE=${{ matrix.config.build_type }} -DGINKGO_COMPILER_FLAGS=${{ matrix.config.cflags }} .." + bash -c "cmake -DBUILD_SHARED_LIBS=${{ matrix.config.shared }} -DCMAKE_BUILD_TYPE=${{ matrix.config.build_type }} -DGINKGO_COMPILER_FLAGS=${{ matrix.config.cflags }} .." bash -c "make -j4" bash -c "ctest . --output-on-failure" shell: cmd diff --git a/.github/workflows/windows-mingw.yml b/.github/workflows/windows-mingw.yml index 7cfa250757b..a7e1b9b8597 100644 --- a/.github/workflows/windows-mingw.yml +++ b/.github/workflows/windows-mingw.yml @@ -36,7 +36,7 @@ jobs: path %PATH:C:\Program Files\Git\usr\bin;=%;%GITHUB_WORKSPACE%\build\windows_shared_library mkdir build cd build - cmake -G "MinGW Makefiles" -DCMAKE_CXX_FLAGS=-Wa,-mbig-obj -DBUILD_SHARED_LIBS=${{ matrix.config.shared }} -DCMAKE_BUILD_TYPE=${{ matrix.config.build_type }} -DGINKGO_COMPILER_FLAGS=${{ matrix.config.cflags }} .. + cmake -G "MinGW Makefiles" -DBUILD_SHARED_LIBS=${{ matrix.config.shared }} -DCMAKE_BUILD_TYPE=${{ matrix.config.build_type }} -DGINKGO_COMPILER_FLAGS=${{ matrix.config.cflags }} .. cmake --build . -j4 ctest . --output-on-failure shell: cmd diff --git a/.github/workflows/windows-msvc-cuda.yml b/.github/workflows/windows-msvc-cuda.yml index 28468950af8..616409b9e3e 100644 --- a/.github/workflows/windows-msvc-cuda.yml +++ b/.github/workflows/windows-msvc-cuda.yml @@ -46,5 +46,5 @@ jobs: $env:PATH="$env:PATH;$pwd\build\windows_shared_library" mkdir build cd build - cmake -DCMAKE_CXX_FLAGS=/bigobj -DGINKGO_BUILD_CUDA=ON -DGINKGO_BUILD_OMP=OFF -DGINKGO_MIXED_PRECISION=${{ matrix.config.mixed }} -DGINKGO_CUDA_ARCHITECTURES=60 .. + cmake -DGINKGO_BUILD_CUDA=ON -DGINKGO_BUILD_OMP=OFF -DGINKGO_MIXED_PRECISION=${{ matrix.config.mixed }} -DGINKGO_CUDA_ARCHITECTURES=60 .. cmake --build . -j4 --config Release diff --git a/.github/workflows/windows-msvc-ref.yml b/.github/workflows/windows-msvc-ref.yml index 833f3692676..9a62ad3ca80 100644 --- a/.github/workflows/windows-msvc-ref.yml +++ b/.github/workflows/windows-msvc-ref.yml @@ -35,7 +35,7 @@ jobs: $env:PATH="$env:PATH;$pwd\build\windows_shared_library" mkdir build cd build - cmake -DCMAKE_CXX_FLAGS=/bigobj -DBUILD_SHARED_LIBS=${{ matrix.config.shared }} -DCMAKE_CXX_FLAGS_DEBUG="/MDd /Zi /Ob1 /Od /RTC1" -DGINKGO_BUILD_CUDA=OFF -DGINKGO_BUILD_OMP=OFF -DGINKGO_MIXED_PRECISION=${{ matrix.config.mixed }} .. + cmake -DBUILD_SHARED_LIBS=${{ matrix.config.shared }} -DCMAKE_CXX_FLAGS_DEBUG="/MDd /Zi /Ob1 /Od /RTC1" -DGINKGO_BUILD_CUDA=OFF -DGINKGO_BUILD_OMP=OFF -DGINKGO_MIXED_PRECISION=${{ matrix.config.mixed }} .. cmake --build . -j4 --config ${{ matrix.config.build_type }} ctest . -C ${{ matrix.config.build_type }} --output-on-failure diff --git a/CMakeLists.txt b/CMakeLists.txt index e999611aa57..2faa372e6ff 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,6 +18,13 @@ include(cmake/hip_path.cmake) include(cmake/autodetect_executors.cmake) include(cmake/build_type_helpers.cmake) +if (MSVC) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj") +endif() +if (MINGW OR CYGWIN) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wa,-mbig-obj") +endif() + # Ginkgo configuration options option(GINKGO_DEVEL_TOOLS "Add development tools to the build system" OFF) option(GINKGO_BUILD_TESTS "Generate build files for unit tests" ON) From 8d637d6930e4f6192815240a744b919a2f890b9d Mon Sep 17 00:00:00 2001 From: Tobias Ribizel Date: Wed, 10 Mar 2021 22:11:24 +0100 Subject: [PATCH 04/11] don't modify CRT linking flags on windows --- CMakeLists.txt | 24 ++++++++---------------- cmake/GinkgoConfig.cmake.in | 4 ---- cmake/install_helpers.cmake | 11 ----------- cmake/windows_helpers.cmake | 22 ---------------------- cuda/CMakeLists.txt | 7 ------- test_exportbuild/CMakeLists.txt | 10 ---------- test_install/CMakeLists.txt | 17 ----------------- third_party/gtest/CMakeLists.txt | 2 +- 8 files changed, 9 insertions(+), 88 deletions(-) delete mode 100644 cmake/windows_helpers.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 2faa372e6ff..9ab053c1ad3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -227,22 +227,6 @@ if(GINKGO_BUILD_HIP) endif() endif() - -if(MSVC) - # This is modified from - # https://gitlab.kitware.com/cmake/community/wikis/FAQ#dynamic-replace - include(cmake/windows_helpers.cmake) - if(BUILD_SHARED_LIBS) - ginkgo_switch_to_windows_dynamic("CXX") - ginkgo_switch_to_windows_dynamic("C") - set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE) - else() - ginkgo_switch_to_windows_static("CXX") - ginkgo_switch_to_windows_static("C") - set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS FALSE) - endif() -endif() - # Try to find the third party packages before using our subdirectories include(cmake/package_helpers.cmake) ginkgo_find_package(GTest "GTest::GTest;GTest::Main" FALSE 1.8.1) @@ -261,6 +245,14 @@ add_subdirectory(third_party) # Third-party tools and libraries include(cmake/build_helpers.cmake) include(cmake/install_helpers.cmake) +if(MSVC) + if(BUILD_SHARED_LIBS) + set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE) + else() + set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS FALSE) + endif() +endif() + configure_file(${Ginkgo_SOURCE_DIR}/include/ginkgo/config.hpp.in ${Ginkgo_BINARY_DIR}/include/ginkgo/config.hpp @ONLY) diff --git a/cmake/GinkgoConfig.cmake.in b/cmake/GinkgoConfig.cmake.in index 8e5de759102..2387d4b8848 100644 --- a/cmake/GinkgoConfig.cmake.in +++ b/cmake/GinkgoConfig.cmake.in @@ -145,10 +145,6 @@ set(GINKGO_OPENMP_LIBRARIES @OpenMP_CXX_LIBRARIES@) set(GINKGO_OPENMP_FLAGS "@OpenMP_CXX_FLAGS@") -if (WIN32 OR CYGWIN) - include(${CMAKE_CURRENT_LIST_DIR}/windows_helpers.cmake) -endif() - # NOTE: we do not export benchmarks, examples, tests or devel tools # so `third_party` libraries are currently unneeded. diff --git a/cmake/install_helpers.cmake b/cmake/install_helpers.cmake index ad49d46b268..077c17c5ebc 100644 --- a/cmake/install_helpers.cmake +++ b/cmake/install_helpers.cmake @@ -124,22 +124,11 @@ function(ginkgo_install) "${Ginkgo_BINARY_DIR}/GinkgoConfig.cmake" INSTALL_DESTINATION "${GINKGO_INSTALL_CONFIG_DIR}" ) - set(HELPERS "windows_helpers.cmake") - foreach (helper ${HELPERS}) - configure_file(${Ginkgo_SOURCE_DIR}/cmake/${helper} - ${Ginkgo_BINARY_DIR}/${helper} COPYONLY) - endforeach() install(FILES "${Ginkgo_BINARY_DIR}/GinkgoConfig.cmake" "${Ginkgo_BINARY_DIR}/GinkgoConfigVersion.cmake" DESTINATION "${GINKGO_INSTALL_CONFIG_DIR}" ) - if (WIN32 OR CYGWIN) - install(FILES - "${Ginkgo_SOURCE_DIR}/cmake/windows_helpers.cmake" - DESTINATION "${GINKGO_INSTALL_CONFIG_DIR}" - ) - endif() install(EXPORT Ginkgo NAMESPACE Ginkgo:: FILE GinkgoTargets.cmake diff --git a/cmake/windows_helpers.cmake b/cmake/windows_helpers.cmake deleted file mode 100644 index 5f517a555ad..00000000000 --- a/cmake/windows_helpers.cmake +++ /dev/null @@ -1,22 +0,0 @@ -function(ginkgo_switch_windows_link lang from to) - foreach(flag_var - "CMAKE_${lang}_FLAGS" "CMAKE_${lang}_FLAGS_DEBUG" "CMAKE_${lang}_FLAGS_RELEASE" - "CMAKE_${lang}_FLAGS_MINSIZEREL" "CMAKE_${lang}_FLAGS_RELWITHDEBINFO" - ) - if(${flag_var} MATCHES "/${from}") - string(REGEX REPLACE "/${from}" "/${to}" ${flag_var} "${${flag_var}}") - endif(${flag_var} MATCHES "/${from}") - if(${flag_var} MATCHES "-${from}") - string(REGEX REPLACE "-${from}" "-${to}" ${flag_var} "${${flag_var}}") - endif(${flag_var} MATCHES "-${from}") - set(${flag_var} "${${flag_var}}" CACHE STRING "" FORCE) - endforeach() -endfunction() - -macro(ginkgo_switch_to_windows_static lang) - ginkgo_switch_windows_link(${lang} "MD" "MT") -endmacro() - -macro(ginkgo_switch_to_windows_dynamic lang) - ginkgo_switch_windows_link(${lang} "MT" "MD") -endmacro() diff --git a/cuda/CMakeLists.txt b/cuda/CMakeLists.txt index 842f4b75259..8ba183d1635 100644 --- a/cuda/CMakeLists.txt +++ b/cuda/CMakeLists.txt @@ -16,13 +16,6 @@ if(MSVC) if("${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES}" STREQUAL "") set(CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES "${CMAKE_CUDA_ROOT_DIR}/lib/x64") endif() - - # This is modified from https://gitlab.kitware.com/cmake/community/wikis/FAQ#dynamic-replace - if(BUILD_SHARED_LIBS) - ginkgo_switch_to_windows_dynamic("CUDA") - else() - ginkgo_switch_to_windows_static("CUDA") - endif() endif() include(CudaArchitectureSelector) diff --git a/test_exportbuild/CMakeLists.txt b/test_exportbuild/CMakeLists.txt index 79b538f437c..52a8d3851cd 100644 --- a/test_exportbuild/CMakeLists.txt +++ b/test_exportbuild/CMakeLists.txt @@ -3,16 +3,6 @@ project(GinkgoExportBuildTest LANGUAGES CXX) find_package(Ginkgo REQUIRED) -if(MSVC) - if(GINKGO_BUILD_SHARED_LIBS) - ginkgo_switch_to_windows_dynamic("CXX") - ginkgo_switch_to_windows_dynamic("C") - else() - ginkgo_switch_to_windows_static("CXX") - ginkgo_switch_to_windows_static("C") - endif() -endif() - # Here, we use test install without any data. We instantiate the # interface only. add_executable(test_exportbuild ../test_install/test_install.cpp) diff --git a/test_install/CMakeLists.txt b/test_install/CMakeLists.txt index cb4b08de706..69797e0b70c 100644 --- a/test_install/CMakeLists.txt +++ b/test_install/CMakeLists.txt @@ -18,16 +18,6 @@ configure_file(data/A.mtx data/A.mtx COPYONLY) configure_file(data/b.mtx data/b.mtx COPYONLY) configure_file(data/x0.mtx data/x0.mtx COPYONLY) -if(MSVC) - if(GINKGO_BUILD_SHARED_LIBS) - ginkgo_switch_to_windows_dynamic("CXX") - ginkgo_switch_to_windows_dynamic("C") - else() - ginkgo_switch_to_windows_static("CXX") - ginkgo_switch_to_windows_static("C") - endif() -endif() - include(CheckLanguage) check_language(CUDA) @@ -42,13 +32,6 @@ target_link_libraries(test_install PRIVATE Ginkgo::ginkgo) if(GINKGO_BUILD_CUDA) enable_language(CUDA) - if(MSVC) - if(GINKGO_BUILD_SHARED_LIBS) - ginkgo_switch_to_windows_dynamic("CUDA") - else() - ginkgo_switch_to_windows_static("CUDA") - endif() - endif() configure_file(test_install.cpp test_install.cu COPYONLY) add_executable(test_install_cuda ${CMAKE_CURRENT_BINARY_DIR}/test_install.cu) target_compile_options(test_install_cuda diff --git a/third_party/gtest/CMakeLists.txt b/third_party/gtest/CMakeLists.txt index 31da9c5eda3..691fd2fa5f6 100644 --- a/third_party/gtest/CMakeLists.txt +++ b/third_party/gtest/CMakeLists.txt @@ -5,7 +5,7 @@ if(MSVC) "https://github.com/google/googletest.git" "6a7ed316a5cdc07b6d26362c90770787513822d4" # Work around the linking errors when compiling gtest with CUDA - "-Dgtest_disable_pthreads=ON" "-Dgtest_force_shared_crt=${BUILD_SHARED_LIBS}") + "-Dgtest_disable_pthreads=ON" "-Dgtest_force_shared_crt=ON") else() ginkgo_load_git_package(gtest_external "https://github.com/google/googletest.git" From 9bde0a0ae70e19c4cb107950430d136d316de63c Mon Sep 17 00:00:00 2001 From: Tobias Ribizel Date: Thu, 11 Mar 2021 00:03:53 +0100 Subject: [PATCH 05/11] store DLLs in runtime instead of library path --- .github/workflows/windows-cygwin.yml | 2 +- .github/workflows/windows-mingw.yml | 2 +- .github/workflows/windows-msvc-ref.yml | 2 +- cmake/install_helpers.cmake | 3 ++- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/windows-cygwin.yml b/.github/workflows/windows-cygwin.yml index ac890430d17..2cb1291efb7 100644 --- a/.github/workflows/windows-cygwin.yml +++ b/.github/workflows/windows-cygwin.yml @@ -49,5 +49,5 @@ jobs: path C:\tools\cygwin\bin cd build bash -c "make install" - bash -c "export PATH=/usr/local/lib:$PATH && make test_install" + bash -c "export PATH=/usr/local/bin:$PATH && make test_install" shell: cmd diff --git a/.github/workflows/windows-mingw.yml b/.github/workflows/windows-mingw.yml index a7e1b9b8597..5b79da0b3be 100644 --- a/.github/workflows/windows-mingw.yml +++ b/.github/workflows/windows-mingw.yml @@ -44,7 +44,7 @@ jobs: - name: install run: | set PATH=%PATH:C:\Program Files\Git\bin;=% - set PATH=%PATH:C:\Program Files\Git\usr\bin;=%;C:\Program Files (x86)\Ginkgo\lib + set PATH=%PATH:C:\Program Files\Git\usr\bin;=%;C:\Program Files (x86)\Ginkgo\bin cd build cmake --install . cmake --build . --target test_install diff --git a/.github/workflows/windows-msvc-ref.yml b/.github/workflows/windows-msvc-ref.yml index 9a62ad3ca80..edf79726f9f 100644 --- a/.github/workflows/windows-msvc-ref.yml +++ b/.github/workflows/windows-msvc-ref.yml @@ -41,7 +41,7 @@ jobs: - name: install run: | - $env:PATH="$env:PATH;C:\Program Files (x86)\Ginkgo\lib" + $env:PATH="$env:PATH;C:\Program Files (x86)\Ginkgo\bin" cd build cmake --install . --config ${{ matrix.config.build_type }} cmake --build . --target test_install --config ${{ matrix.config.build_type }} diff --git a/cmake/install_helpers.cmake b/cmake/install_helpers.cmake index 077c17c5ebc..3991796a147 100644 --- a/cmake/install_helpers.cmake +++ b/cmake/install_helpers.cmake @@ -4,6 +4,7 @@ include(GNUInstallDirs) set(GINKGO_INSTALL_INCLUDE_DIR "${CMAKE_INSTALL_INCLUDEDIR}") set(GINKGO_INSTALL_LIBRARY_DIR "${CMAKE_INSTALL_LIBDIR}") +set(GINKGO_INSTALL_RUNTIME_DIR "${CMAKE_INSTALL_BINDIR}") set(GINKGO_INSTALL_PKGCONFIG_DIR "${CMAKE_INSTALL_LIBDIR}/pkgconfig") set(GINKGO_INSTALL_CONFIG_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/Ginkgo") set(GINKGO_INSTALL_MODULE_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/Ginkgo/Modules") @@ -56,7 +57,7 @@ function(ginkgo_install_library name) EXPORT Ginkgo LIBRARY DESTINATION "${GINKGO_INSTALL_LIBRARY_DIR}" ARCHIVE DESTINATION "${GINKGO_INSTALL_LIBRARY_DIR}" - RUNTIME DESTINATION "${GINKGO_INSTALL_LIBRARY_DIR}" + RUNTIME DESTINATION "${GINKGO_INSTALL_RUNTIME_DIR}" ) else () # install .so and .a files From e0764f4e6ee005fed02464190ae13fbbdaf05bbe Mon Sep 17 00:00:00 2001 From: Tobias Ribizel Date: Thu, 11 Mar 2021 00:49:45 +0100 Subject: [PATCH 06/11] store output libraries in a single path --- .github/workflows/windows-cygwin.yml | 2 +- .github/workflows/windows-mingw.yml | 2 +- .github/workflows/windows-msvc-cuda.yml | 1 - .github/workflows/windows-msvc-ref.yml | 1 - CMakeLists.txt | 15 +------ INSTALL.md | 45 ++----------------- README.md | 6 +-- cmake/build_helpers.cmake | 59 +++---------------------- cmake/create_test.cmake | 25 ++++++++--- cmake/get_info.cmake | 4 +- 10 files changed, 34 insertions(+), 126 deletions(-) diff --git a/.github/workflows/windows-cygwin.yml b/.github/workflows/windows-cygwin.yml index 2cb1291efb7..317e3608253 100644 --- a/.github/workflows/windows-cygwin.yml +++ b/.github/workflows/windows-cygwin.yml @@ -36,7 +36,7 @@ jobs: - name: configure run: | - path C:\tools\cygwin\bin;%GITHUB_WORKSPACE%\build\windows_shared_library + path C:\tools\cygwin\bin mkdir build cd build bash -c "cmake -DBUILD_SHARED_LIBS=${{ matrix.config.shared }} -DCMAKE_BUILD_TYPE=${{ matrix.config.build_type }} -DGINKGO_COMPILER_FLAGS=${{ matrix.config.cflags }} .." diff --git a/.github/workflows/windows-mingw.yml b/.github/workflows/windows-mingw.yml index 5b79da0b3be..beeeb34d840 100644 --- a/.github/workflows/windows-mingw.yml +++ b/.github/workflows/windows-mingw.yml @@ -33,7 +33,7 @@ jobs: bcdedit /set IncreaseUserVa 3072 editbin /LARGEADDRESSAWARE "C:\Program Files\Git\mingw64\bin\cc1plus.exe" path %PATH:C:\Program Files\Git\bin;=% - path %PATH:C:\Program Files\Git\usr\bin;=%;%GITHUB_WORKSPACE%\build\windows_shared_library + path %PATH:C:\Program Files\Git\usr\bin;=% mkdir build cd build cmake -G "MinGW Makefiles" -DBUILD_SHARED_LIBS=${{ matrix.config.shared }} -DCMAKE_BUILD_TYPE=${{ matrix.config.build_type }} -DGINKGO_COMPILER_FLAGS=${{ matrix.config.cflags }} .. diff --git a/.github/workflows/windows-msvc-cuda.yml b/.github/workflows/windows-msvc-cuda.yml index 616409b9e3e..fba49eb6adb 100644 --- a/.github/workflows/windows-msvc-cuda.yml +++ b/.github/workflows/windows-msvc-cuda.yml @@ -43,7 +43,6 @@ jobs: $env:ChocolateyInstall = Convert-Path "$((Get-Command choco).Path)\..\.." Import-Module "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1" refreshenv - $env:PATH="$env:PATH;$pwd\build\windows_shared_library" mkdir build cd build cmake -DGINKGO_BUILD_CUDA=ON -DGINKGO_BUILD_OMP=OFF -DGINKGO_MIXED_PRECISION=${{ matrix.config.mixed }} -DGINKGO_CUDA_ARCHITECTURES=60 .. diff --git a/.github/workflows/windows-msvc-ref.yml b/.github/workflows/windows-msvc-ref.yml index edf79726f9f..c2df41390c1 100644 --- a/.github/workflows/windows-msvc-ref.yml +++ b/.github/workflows/windows-msvc-ref.yml @@ -32,7 +32,6 @@ jobs: - name: configure run: | - $env:PATH="$env:PATH;$pwd\build\windows_shared_library" mkdir build cd build cmake -DBUILD_SHARED_LIBS=${{ matrix.config.shared }} -DCMAKE_CXX_FLAGS_DEBUG="/MDd /Zi /Ob1 /Od /RTC1" -DGINKGO_BUILD_CUDA=OFF -DGINKGO_BUILD_OMP=OFF -DGINKGO_MIXED_PRECISION=${{ matrix.config.mixed }} .. diff --git a/CMakeLists.txt b/CMakeLists.txt index 9ab053c1ad3..92fa3abdfa6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,6 +25,8 @@ if (MINGW OR CYGWIN) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wa,-mbig-obj") endif() +set(GINKGO_LIBRARY_PATH "${PROJECT_BINARY_DIR}/lib") + # Ginkgo configuration options option(GINKGO_DEVEL_TOOLS "Add development tools to the build system" OFF) option(GINKGO_BUILD_TESTS "Generate build files for unit tests" ON) @@ -114,19 +116,6 @@ if(GINKGO_BENCHMARK_ENABLE_TUNING) set(GINKGO_BUILD_EXAMPLES OFF) endif() -if(BUILD_SHARED_LIBS AND (WIN32 OR CYGWIN) AND (GINKGO_BUILD_TESTS OR GINKGO_BUILD_EXAMPLES OR GINKGO_BUILD_BENCHMARKS)) - # Change shared libraries output only if this build has executable program - # with shared libraries. - set(GINKGO_CHANGED_SHARED_LIBRARY TRUE) - option(GINKGO_CHECK_PATH "Tell Ginkgo to check if the environment variable PATH is available for this build." ON) - set(GINKGO_WINDOWS_SHARED_LIBRARY_RELPATH "windows_shared_library" CACHE STRING - "Set Ginkgo's shared library relative path in windows. Current default is `windows_shared_library`. \ - This absolute path ${PROJECT_BINARY_DIR}/GINKGO_WINDOWS_SHARED_LIBRARY_RELPATH must be in the environment variable PATH.") - set(GINKGO_WINDOWS_SHARED_LIBRARY_PATH ${PROJECT_BINARY_DIR}/${GINKGO_WINDOWS_SHARED_LIBRARY_RELPATH}) -else() - set(GINKGO_CHANGED_SHARED_LIBRARY FALSE) -endif() - if(GINKGO_BUILD_TESTS AND (GINKGO_BUILD_CUDA OR GINKGO_BUILD_OMP OR GINKGO_BUILD_HIP OR GINKGO_BUILD_DPCPP)) message(STATUS "GINKGO_BUILD_TESTS is ON, enabling GINKGO_BUILD_REFERENCE") set(GINKGO_BUILD_REFERENCE ON CACHE BOOL "Compile reference CPU kernels" FORCE) diff --git a/INSTALL.md b/INSTALL.md index 4fcc60d9ae4..0f558d155e3 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -116,14 +116,6 @@ Ginkgo adds the following additional switches to control what is being built: this option see the [`ARCHITECTURES` specification list](https://github.com/ginkgo-project/CudaArchitectureSelector/blob/master/CudaArchitectureSelector.cmake#L58) section in the documentation of the CudaArchitectureSelector CMake module. -* `-DGINKGO_WINDOWS_SHARED_LIBRARY_RELPATH=` where is a relative - path built with `PROJECT_BINARY_DIR`. Users must add the absolute path - (`PROJECT_BINARY_DIR`/`GINKGO_WINDOWS_SHARED_LIBRARY_RELPATH`) into the - environment variable PATH when building shared libraries and executable - program, default is `windows_shared_library`. -* `-DGINKGO_CHECK_PATH={ON, OFF}` checks if the environment variable PATH is valid. - It is checked only when building shared libraries and executable program, - default is `ON`. For example, to build everything (in debug mode), use: @@ -139,50 +131,21 @@ generators. Other CMake generators are untested. ### Building Ginkgo in Windows Depending on the configuration settings, some manual work might be required: -* Build Ginkgo as shared library: - Add `PROJECT_BINARY_DIR/GINKGO_WINDOWS_SHARED_LIBRARY_RELPATH` into the environment variable `PATH`. - `GINKGO_WINDOWS_SHARED_LIBRARY_RELPATH` is `windows_shared_library` by default. More Details are available in the [Installation page](./INSTALL.md). - * cmd: `set PATH=;%PATH%` - * powershell: `$env:PATH=";$env:PATH"` - - CMake will give the following error message if the path is not correct. - ``` - Did not find this build in the environment variable PATH. Please add into the environment variable PATH. - ``` - where `` is the needed ``. * Build Ginkgo with Debug mode: Some Debug build specific issues can appear depending on the machine and environment. The known issues are the following: - 1. `bigobj` issue: encountering `too many sections` needs the compilation flags `/bigobj` or `-Wa,-mbig-obj` - 2. `ld` issue: encountering `ld: error: export ordinal too large` needs the compilation flag `-O1` + 1. `ld` issue: encountering `ld: error: export ordinal too large` needs the compilation flag `-O1` The following are the details for different environments: * _Microsoft Visual Studio_: - 1. `bigobj` issue - * `cmake -DCMAKE_CXX_FLAGS=/bigobj ` which might overwrite the default settings. - * add `/bigobj` into the environment variable `CXXFLAGS` (only available in the first cmake configuration) - * cmd: `set CXXFLAGS=/bigobj` - * powershell: `$env:CXXFLAGS=/bigobj` - 2. `ld` issue (_Microsoft Visual Studio_ does not have this issue) + 1. `ld` issue (_Microsoft Visual Studio_ does not have this issue) * _Cygwin_: - 1. `bigobj` issue - * add `-Wa,-mbig-obj -O1` into the environment variable `CXXFLAGS` (only available in the first cmake configuration) - * `export CXXFLAGS="-Wa,-mbig-obj -O1"` - * `cmake -DCMAKE_CXX_FLAGS=-Wa,-mbig-obj `, which might overwrite the default settings. - 2. `ld` issue (If building Ginkgo as static library, this is not needed) + 1. `ld` issue (If building Ginkgo as static library, this is not needed) * `cmake -DGINKGO_COMPILER_FLAGS="-Wpedantic -O1" ` (`GINKGO_COMPILER_FLAGS` is `-Wpedantic` by default) * add `-O1` in the environement variable `CXX_FLAGS` or `CMAKE_CXX_FLAGS` * _MinGW_: - 1. `bigobj` issue - * add `-Wa,-mbig-obj -O1` into the environment variable `CXXFLAGS` (only available in the first cmake configuration) - * cmd: `set CXXFLAGS="-Wa,-mbig-obj"` - * powershell: `$env:CXXFLAGS="-Wa,-mbig-obj"` - * `cmake -DCMAKE_CXX_FLAGS=-Wa,-mbig-obj `, which might overwrite the default settings. - 2. `ld` issue (If building Ginkgo as static library, this is not needed) + 1. `ld` issue (If building Ginkgo as static library, this is not needed) * `cmake -DGINKGO_COMPILER_FLAGS="-Wpedantic -O1" ` (`GINKGO_COMPILER_FLAGS` is `-Wpedantic` by default) * add `-O1` in the environement variable `CXX_FLAGS` or `CMAKE_CXX_FLAGS` -* Possible issue when switching static/shared of Ginkgo with MSVC in the same build directory:\ - If an issue occurs from mixing MD/MT runtime library when enabling `GINKGO_BUILD_BENCHMARKS`, it means the third-party flags are not updated correctly. - To update the third party flags, turn off `GINKGO_SKIP_DEPENDENCY_UPDATE` (`-DGINKGO_SKIP_DEPENDENCY_UPDATE=OFF`). * Build Ginkgo in _MinGW_:\ If encountering the issue `cc1plus.exe: out of memory allocating 65536 bytes`, please follow the workaround in [reference](https://www.intel.com/content/www/us/en/programmable/support/support-resources/knowledge-base/embedded/2016/cc1plus-exe--out-of-memory-allocating-65536-bytes.html), diff --git a/README.md b/README.md index 7c099cc738d..5510deaebe0 100644 --- a/README.md +++ b/README.md @@ -89,13 +89,9 @@ The Ginkgo OMP module has the following __additional__ requirements: * _MinGW_ or _Cygwin_ Depending on the configuration settings, some manual work might be required. More details are availble in [windows section in INSTALL.md](INSTALL.md#building-ginkgo-in-windows): -* Build Ginkgo as shared library: - Add `PROJECT_BINARY_DIR/GINKGO_WINDOWS_SHARED_LIBRARY_RELPATH` into the environment variable `PATH`. - `GINKGO_WINDOWS_SHARED_LIBRARY_RELPATH` is `windows_shared_library` by default. * Build Ginkgo with Debug mode: Some Debug build specific issues can appear depending on the machine and environment. The known issues are the following: - 1. `bigobj` issue: encountering `too many sections` needs the compilation flags `\bigobj` or `-Wa,-mbig-obj` - 2. `ld` issue: encountering `ld: error: export ordinal too large` needs the compilation flag `-O1` + 1. `ld` issue: encountering `ld: error: export ordinal too large` needs the compilation flag `-O1` * Build Ginkgo in _MinGW_: If encountering the issue `cc1plus.exe: out of memory allocating 65536 bytes`, please follow the workaround in [reference](https://www.intel.com/content/www/us/en/programmable/support/support-resources/knowledge-base/embedded/2016/cc1plus-exe--out-of-memory-allocating-65536-bytes.html), diff --git a/cmake/build_helpers.cmake b/cmake/build_helpers.cmake index 34689ecefc5..456398a0d1c 100644 --- a/cmake/build_helpers.cmake +++ b/cmake/build_helpers.cmake @@ -26,26 +26,11 @@ function(ginkgo_compile_features name) # Set an appropriate SONAME set_property(TARGET "${name}" PROPERTY SOVERSION "${Ginkgo_VERSION}") - if(GINKGO_CHANGED_SHARED_LIBRARY) - # Put all shared libraries and corresponding imported libraries into the specified path - set_property(TARGET "${name}" PROPERTY - RUNTIME_OUTPUT_DIRECTORY "${GINKGO_WINDOWS_SHARED_LIBRARY_PATH}") - set_property(TARGET "${name}" PROPERTY - ARCHIVE_OUTPUT_DIRECTORY "${GINKGO_WINDOWS_SHARED_LIBRARY_PATH}") - if(MSVC) - # MSVC would create subfolder according to build_type. Ginkgo forces the output be the same whatever build_type is. - foreach(CONFIG ${CMAKE_CONFIGURATION_TYPES}) - string(TOUPPER ${CONFIG} CONFIG ) - set_property(TARGET "${name}" PROPERTY - RUNTIME_OUTPUT_DIRECTORY_${CONFIG} "${GINKGO_WINDOWS_SHARED_LIBRARY_PATH}") - set_property(TARGET "${name}" PROPERTY - ARCHIVE_OUTPUT_DIRECTORY_${CONFIG} "${GINKGO_WINDOWS_SHARED_LIBRARY_PATH}") - endforeach() - endif() - if(GINKGO_CHECK_PATH) - ginkgo_check_shared_library("${CMAKE_SHARED_LIBRARY_PREFIX}${name}${CMAKE_SHARED_LIBRARY_SUFFIX}") - endif() - endif() + # Put all shared libraries and corresponding imported libraries into the specified path + set_property(TARGET "${name}" PROPERTY + RUNTIME_OUTPUT_DIRECTORY "${GINKGO_LIBRARY_PATH}") + set_property(TARGET "${name}" PROPERTY + ARCHIVE_OUTPUT_DIRECTORY "${GINKGO_LIBRARY_PATH}") if (GINKGO_CHECK_CIRCULAR_DEPS) target_link_libraries("${name}" PRIVATE "${GINKGO_CIRCULAR_DEPS_FLAGS}") @@ -104,40 +89,6 @@ function(ginkgo_check_headers target) endif() endfunction() -function(ginkgo_check_shared_library name) - # Cygwin uses : not ; to split path - if(CYGWIN) - string(REPLACE ":" ";" ENV_PATH "$ENV{PATH}") - else() - set(ENV_PATH "$ENV{PATH}") - endif() - set(PATH_LIST ${ENV_PATH}) - set(PASSED_TEST FALSE) - foreach(ITEM IN LISTS PATH_LIST) - string(REPLACE "\\" "/" ITEM "${ITEM}") - if("${ITEM}" STREQUAL "${GINKGO_WINDOWS_SHARED_LIBRARY_PATH}") - set(PASSED_TEST TRUE) - break() - else() - # If any path before this build, the path must not contain the ginkgo shared library - find_file(EXISTING_DLL "${name}" PATHS "${ITEM}" NO_DEFAULT_PATH) - if(NOT "${EXISTING_DLL}" STREQUAL "EXISTING_DLL-NOTFOUND") - # clean the EXISTING_DLL before termination - unset(EXISTING_DLL CACHE) - message(FATAL_ERROR "Detect ${name} in ${ITEM} eariler than this build. " - "Please add ${GINKGO_WINDOWS_SHARED_LIBRARY_PATH} before other ginkgo path.") - endif() - # do not keep this variable in cache - unset(EXISTING_DLL CACHE) - endif() - endforeach() - if(NOT PASSED_TEST) - # Did not find this build in the environment variable PATH - message(FATAL_ERROR "Did not find this build in the environment variable PATH. " - "Please add ${GINKGO_WINDOWS_SHARED_LIBRARY_PATH} into the environment variable PATH.") - endif() -endfunction() - macro(ginkgo_modify_flags name) # add escape before " # the result var is ${name}_MODIFY diff --git a/cmake/create_test.cmake b/cmake/create_test.cmake index d7a420c2066..c5285b0c10a 100644 --- a/cmake/create_test.cmake +++ b/cmake/create_test.cmake @@ -21,7 +21,9 @@ function(ginkgo_create_test test_name) target_link_libraries(${TEST_TARGET_NAME} PRIVATE "${GINKGO_CIRCULAR_DEPS_FLAGS}") endif() target_link_libraries(${TEST_TARGET_NAME} PRIVATE ginkgo GTest::Main GTest::GTest ${ARGN}) - add_test(NAME ${REL_BINARY_DIR}/${test_name} COMMAND ${TEST_TARGET_NAME}) + add_test(NAME ${REL_BINARY_DIR}/${test_name} + COMMAND ${TEST_TARGET_NAME} + WORKING_DIRECTORY "$") endfunction(ginkgo_create_test) function(ginkgo_create_dpcpp_test test_name) @@ -47,7 +49,9 @@ function(ginkgo_create_dpcpp_test test_name) target_link_libraries(${TEST_TARGET_NAME} PRIVATE "${GINKGO_CIRCULAR_DEPS_FLAGS}") endif() target_link_libraries(${TEST_TARGET_NAME} PRIVATE ginkgo GTest::Main GTest::GTest ${ARGN}) - add_test(NAME ${REL_BINARY_DIR}/${test_name} COMMAND ${TEST_TARGET_NAME}) + add_test(NAME ${REL_BINARY_DIR}/${test_name} + COMMAND ${TEST_TARGET_NAME} + WORKING_DIRECTORY "$") endfunction(ginkgo_create_dpcpp_test) function(ginkgo_create_thread_test test_name) @@ -73,7 +77,9 @@ function(ginkgo_create_thread_test test_name) endif() target_link_libraries(${TEST_TARGET_NAME} PRIVATE ginkgo GTest::Main GTest::GTest Threads::Threads ${ARGN}) - add_test(NAME ${REL_BINARY_DIR}/${test_name} COMMAND ${TEST_TARGET_NAME}) + add_test(NAME ${REL_BINARY_DIR}/${test_name} + COMMAND ${TEST_TARGET_NAME} + WORKING_DIRECTORY "$") endfunction(ginkgo_create_thread_test) function(ginkgo_create_test_cpp_cuda_header test_name) @@ -97,7 +103,9 @@ function(ginkgo_create_test_cpp_cuda_header test_name) target_link_libraries(${TEST_TARGET_NAME} PRIVATE "${GINKGO_CIRCULAR_DEPS_FLAGS}") endif() target_link_libraries(${TEST_TARGET_NAME} PRIVATE ginkgo GTest::Main GTest::GTest ${ARGN}) - add_test(NAME ${REL_BINARY_DIR}/${test_name} COMMAND ${TEST_TARGET_NAME}) + add_test(NAME ${REL_BINARY_DIR}/${test_name} + COMMAND ${TEST_TARGET_NAME} + WORKING_DIRECTORY "$") endfunction(ginkgo_create_test_cpp_cuda_header) function(ginkgo_create_cuda_test test_name) @@ -121,10 +129,11 @@ function(ginkgo_create_cuda_test test_name) target_link_libraries(${TEST_TARGET_NAME} PRIVATE "${GINKGO_CIRCULAR_DEPS_FLAGS}") endif() target_link_libraries(${TEST_TARGET_NAME} PRIVATE ginkgo GTest::Main GTest::GTest ${ARGN}) - add_test(NAME ${REL_BINARY_DIR}/${test_name} COMMAND ${TEST_TARGET_NAME}) + add_test(NAME ${REL_BINARY_DIR}/${test_name} + COMMAND ${TEST_TARGET_NAME} + WORKING_DIRECTORY "$") endfunction(ginkgo_create_cuda_test) - function(ginkgo_create_hip_test test_name) file(RELATIVE_PATH REL_BINARY_DIR ${PROJECT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}) @@ -180,5 +189,7 @@ function(ginkgo_create_hip_test test_name) endif() target_link_libraries(${TEST_TARGET_NAME} PRIVATE ginkgo GTest::Main GTest::GTest ${ARGN}) - add_test(NAME ${REL_BINARY_DIR}/${test_name} COMMAND ${TEST_TARGET_NAME}) + add_test(NAME ${REL_BINARY_DIR}/${test_name} + COMMAND ${TEST_TARGET_NAME} + WORKING_DIRECTORY "$") endfunction(ginkgo_create_hip_test) diff --git a/cmake/get_info.cmake b/cmake/get_info.cmake index bae1e864a02..99c387d30d3 100644 --- a/cmake/get_info.cmake +++ b/cmake/get_info.cmake @@ -171,10 +171,10 @@ ginkgo_print_generic_header(${minimal_log} " Developer Tools:") ginkgo_print_generic_header(${detailed_log} " Developer Tools:") ginkgo_print_foreach_variable(${minimal_log} "GINKGO_DEVEL_TOOLS;GINKGO_WITH_CLANG_TIDY;GINKGO_WITH_IWYU" - "GINKGO_CHECK_CIRCULAR_DEPS;GINKGO_CHECK_PATH;GINKGO_WITH_CCACHE") + "GINKGO_CHECK_CIRCULAR_DEPS;GINKGO_WITH_CCACHE") ginkgo_print_foreach_variable(${detailed_log} "GINKGO_DEVEL_TOOLS;GINKGO_WITH_CLANG_TIDY;GINKGO_WITH_IWYU" - "GINKGO_CHECK_CIRCULAR_DEPS;GINKGO_CHECK_PATH;GINKGO_WITH_CCACHE") + "GINKGO_CHECK_CIRCULAR_DEPS;GINKGO_WITH_CCACHE") ginkgo_print_module_footer(${detailed_log} " CCACHE:") ginkgo_print_variable(${detailed_log} "CCACHE_PROGRAM") ginkgo_print_env_variable(${detailed_log} "CCACHE_DIR") From ed0886849d8706e99a5e4e9049bb1bfa41462f72 Mon Sep 17 00:00:00 2001 From: Tobias Ribizel Date: Tue, 13 Apr 2021 11:59:21 +0200 Subject: [PATCH 07/11] update examples to use Ginkgo 1.4.0 --- examples/adaptiveprecision-blockjacobi/CMakeLists.txt | 2 +- examples/cb-gmres/CMakeLists.txt | 2 +- examples/custom-logger/CMakeLists.txt | 2 +- examples/custom-matrix-format/CMakeLists.txt | 2 +- examples/custom-stopping-criterion/CMakeLists.txt | 2 +- examples/ginkgo-overhead/CMakeLists.txt | 2 +- examples/ginkgo-ranges/CMakeLists.txt | 2 +- examples/heat-equation/CMakeLists.txt | 2 +- examples/ilu-preconditioned-solver/CMakeLists.txt | 2 +- examples/inverse-iteration/CMakeLists.txt | 2 +- examples/ir-ilu-preconditioned-solver/CMakeLists.txt | 2 +- examples/iterative-refinement/CMakeLists.txt | 2 +- examples/minimal-cuda-solver/CMakeLists.txt | 2 +- examples/mixed-precision-ir/CMakeLists.txt | 2 +- examples/nine-pt-stencil-solver/CMakeLists.txt | 2 +- examples/papi-logging/CMakeLists.txt | 2 +- examples/par-ilu-convergence/CMakeLists.txt | 2 +- examples/performance-debugging/CMakeLists.txt | 2 +- examples/poisson-solver/CMakeLists.txt | 2 +- examples/preconditioned-solver/CMakeLists.txt | 2 +- examples/preconditioner-export/CMakeLists.txt | 2 +- examples/simple-solver-logging/CMakeLists.txt | 2 +- examples/simple-solver/CMakeLists.txt | 2 +- examples/three-pt-stencil-solver/CMakeLists.txt | 2 +- 24 files changed, 24 insertions(+), 24 deletions(-) diff --git a/examples/adaptiveprecision-blockjacobi/CMakeLists.txt b/examples/adaptiveprecision-blockjacobi/CMakeLists.txt index b3d83725d0f..c3cb3183d22 100644 --- a/examples/adaptiveprecision-blockjacobi/CMakeLists.txt +++ b/examples/adaptiveprecision-blockjacobi/CMakeLists.txt @@ -3,7 +3,7 @@ project(adaptiveprecision-blockjacobi) # We only need to find Ginkgo if we build this example stand-alone if (NOT GINKGO_BUILD_EXAMPLES) - find_package(Ginkgo 1.3.0 REQUIRED) + find_package(Ginkgo 1.4.0 REQUIRED) endif() add_executable(adaptiveprecision-blockjacobi adaptiveprecision-blockjacobi.cpp) diff --git a/examples/cb-gmres/CMakeLists.txt b/examples/cb-gmres/CMakeLists.txt index 0234e4128ac..dc9b4befdf5 100644 --- a/examples/cb-gmres/CMakeLists.txt +++ b/examples/cb-gmres/CMakeLists.txt @@ -3,7 +3,7 @@ project(cb-gmres) # We only need to find Ginkgo if we build this example stand-alone if (NOT GINKGO_BUILD_EXAMPLES) - find_package(Ginkgo 1.3.0 REQUIRED) + find_package(Ginkgo 1.4.0 REQUIRED) endif() add_executable(cb-gmres cb-gmres.cpp) diff --git a/examples/custom-logger/CMakeLists.txt b/examples/custom-logger/CMakeLists.txt index cf6fb7f4521..1bc89d54e63 100644 --- a/examples/custom-logger/CMakeLists.txt +++ b/examples/custom-logger/CMakeLists.txt @@ -3,7 +3,7 @@ project(custom-logger) # We only need to find Ginkgo if we build this example stand-alone if (NOT GINKGO_BUILD_EXAMPLES) - find_package(Ginkgo 1.3.0 REQUIRED) + find_package(Ginkgo 1.4.0 REQUIRED) endif() add_executable(custom-logger custom-logger.cpp) diff --git a/examples/custom-matrix-format/CMakeLists.txt b/examples/custom-matrix-format/CMakeLists.txt index c008a86f7b0..c6de4475eb9 100644 --- a/examples/custom-matrix-format/CMakeLists.txt +++ b/examples/custom-matrix-format/CMakeLists.txt @@ -3,7 +3,7 @@ project(custom-matrix-format CXX CUDA) # We only need to find Ginkgo if we build this example stand-alone if (NOT GINKGO_BUILD_EXAMPLES) - find_package(Ginkgo 1.3.0 REQUIRED) + find_package(Ginkgo 1.4.0 REQUIRED) endif() set(CMAKE_CUDA_STANDARD 14) diff --git a/examples/custom-stopping-criterion/CMakeLists.txt b/examples/custom-stopping-criterion/CMakeLists.txt index 7d1db25a116..7009e575bc5 100644 --- a/examples/custom-stopping-criterion/CMakeLists.txt +++ b/examples/custom-stopping-criterion/CMakeLists.txt @@ -3,7 +3,7 @@ project(custom-stopping-criterion) # We only need to find Ginkgo if we build this example stand-alone if (NOT GINKGO_BUILD_EXAMPLES) - find_package(Ginkgo 1.3.0 REQUIRED) + find_package(Ginkgo 1.4.0 REQUIRED) endif() set(THREADS_PREFER_PTHREAD_FLAG ON) find_package(Threads REQUIRED) diff --git a/examples/ginkgo-overhead/CMakeLists.txt b/examples/ginkgo-overhead/CMakeLists.txt index 16328502185..82512ea0567 100644 --- a/examples/ginkgo-overhead/CMakeLists.txt +++ b/examples/ginkgo-overhead/CMakeLists.txt @@ -3,7 +3,7 @@ project(ginkgo-overhead) # We only need to find Ginkgo if we build this example stand-alone if (NOT GINKGO_BUILD_EXAMPLES) - find_package(Ginkgo 1.3.0 REQUIRED) + find_package(Ginkgo 1.4.0 REQUIRED) endif() add_executable(ginkgo-overhead ginkgo-overhead.cpp) diff --git a/examples/ginkgo-ranges/CMakeLists.txt b/examples/ginkgo-ranges/CMakeLists.txt index 943d8c2aef2..ebefcf103a3 100644 --- a/examples/ginkgo-ranges/CMakeLists.txt +++ b/examples/ginkgo-ranges/CMakeLists.txt @@ -3,7 +3,7 @@ project(ginkgo-ranges) # We only need to find Ginkgo if we build this example stand-alone if (NOT GINKGO_BUILD_EXAMPLES) - find_package(Ginkgo 1.3.0 REQUIRED) + find_package(Ginkgo 1.4.0 REQUIRED) endif() add_executable(ginkgo-ranges ginkgo-ranges.cpp) target_link_libraries(ginkgo-ranges Ginkgo::ginkgo) diff --git a/examples/heat-equation/CMakeLists.txt b/examples/heat-equation/CMakeLists.txt index 9de0f9ea83a..c13a69e8fb7 100644 --- a/examples/heat-equation/CMakeLists.txt +++ b/examples/heat-equation/CMakeLists.txt @@ -3,7 +3,7 @@ project(heat-equation) # We only need to find Ginkgo if we build this example stand-alone if (NOT GINKGO_BUILD_EXAMPLES) - find_package(Ginkgo 1.3.0 REQUIRED) + find_package(Ginkgo 1.4.0 REQUIRED) endif() find_package(OpenCV REQUIRED) diff --git a/examples/ilu-preconditioned-solver/CMakeLists.txt b/examples/ilu-preconditioned-solver/CMakeLists.txt index 6e971588215..eb35d1f4254 100644 --- a/examples/ilu-preconditioned-solver/CMakeLists.txt +++ b/examples/ilu-preconditioned-solver/CMakeLists.txt @@ -3,7 +3,7 @@ project(ilu-preconditioned-solver) # We only need to find Ginkgo if we build this example stand-alone if (NOT GINKGO_BUILD_EXAMPLES) - find_package(Ginkgo 1.3.0 REQUIRED) + find_package(Ginkgo 1.4.0 REQUIRED) endif() add_executable(ilu-preconditioned-solver ilu-preconditioned-solver.cpp) diff --git a/examples/inverse-iteration/CMakeLists.txt b/examples/inverse-iteration/CMakeLists.txt index 03aa016b340..a9ec2edfcca 100644 --- a/examples/inverse-iteration/CMakeLists.txt +++ b/examples/inverse-iteration/CMakeLists.txt @@ -3,7 +3,7 @@ project(inverse-iteration) # We only need to find Ginkgo if we build this example stand-alone if (NOT GINKGO_BUILD_EXAMPLES) - find_package(Ginkgo 1.3.0 REQUIRED) + find_package(Ginkgo 1.4.0 REQUIRED) endif() add_executable(inverse-iteration inverse-iteration.cpp) diff --git a/examples/ir-ilu-preconditioned-solver/CMakeLists.txt b/examples/ir-ilu-preconditioned-solver/CMakeLists.txt index 76a11d405f1..00d7af61a04 100644 --- a/examples/ir-ilu-preconditioned-solver/CMakeLists.txt +++ b/examples/ir-ilu-preconditioned-solver/CMakeLists.txt @@ -3,7 +3,7 @@ project(ir-ilu-preconditioned-solver) # We only need to find Ginkgo if we build this example stand-alone if (NOT GINKGO_BUILD_EXAMPLES) - find_package(Ginkgo 1.3.0 REQUIRED) + find_package(Ginkgo 1.4.0 REQUIRED) endif() add_executable(ir-ilu-preconditioned-solver ir-ilu-preconditioned-solver.cpp) diff --git a/examples/iterative-refinement/CMakeLists.txt b/examples/iterative-refinement/CMakeLists.txt index 47c3942ae43..112f70634cf 100644 --- a/examples/iterative-refinement/CMakeLists.txt +++ b/examples/iterative-refinement/CMakeLists.txt @@ -3,7 +3,7 @@ project(iterative-refinement) # We only need to find Ginkgo if we build this example stand-alone if (NOT GINKGO_BUILD_EXAMPLES) - find_package(Ginkgo 1.3.0 REQUIRED) + find_package(Ginkgo 1.4.0 REQUIRED) endif() add_executable(iterative-refinement iterative-refinement.cpp) diff --git a/examples/minimal-cuda-solver/CMakeLists.txt b/examples/minimal-cuda-solver/CMakeLists.txt index ffc9274e16b..cd04ddb68de 100644 --- a/examples/minimal-cuda-solver/CMakeLists.txt +++ b/examples/minimal-cuda-solver/CMakeLists.txt @@ -3,7 +3,7 @@ project(minimal-cuda-solver) # We only need to find Ginkgo if we build this example stand-alone if (NOT GINKGO_BUILD_EXAMPLES) - find_package(Ginkgo 1.3.0 REQUIRED) + find_package(Ginkgo 1.4.0 REQUIRED) endif() add_executable(minimal-cuda-solver minimal-cuda-solver.cpp) diff --git a/examples/mixed-precision-ir/CMakeLists.txt b/examples/mixed-precision-ir/CMakeLists.txt index 8c23e367a82..242b525d2af 100644 --- a/examples/mixed-precision-ir/CMakeLists.txt +++ b/examples/mixed-precision-ir/CMakeLists.txt @@ -3,7 +3,7 @@ project(mixed-precision-ir) # We only need to find Ginkgo if we build this example stand-alone if (NOT GINKGO_BUILD_EXAMPLES) - find_package(Ginkgo 1.3.0 REQUIRED) + find_package(Ginkgo 1.4.0 REQUIRED) endif() add_executable(mixed-precision-ir mixed-precision-ir.cpp) diff --git a/examples/nine-pt-stencil-solver/CMakeLists.txt b/examples/nine-pt-stencil-solver/CMakeLists.txt index 510f0e85f07..b9a3fc8421e 100644 --- a/examples/nine-pt-stencil-solver/CMakeLists.txt +++ b/examples/nine-pt-stencil-solver/CMakeLists.txt @@ -3,7 +3,7 @@ project(nine-pt-stencil-solver) # We only need to find Ginkgo if we build this example stand-alone if (NOT GINKGO_BUILD_EXAMPLES) - find_package(Ginkgo 1.3.0 REQUIRED) + find_package(Ginkgo 1.4.0 REQUIRED) endif() add_executable(nine-pt-stencil-solver nine-pt-stencil-solver.cpp) diff --git a/examples/papi-logging/CMakeLists.txt b/examples/papi-logging/CMakeLists.txt index e3836ecbe3b..a8f0f8a260c 100644 --- a/examples/papi-logging/CMakeLists.txt +++ b/examples/papi-logging/CMakeLists.txt @@ -3,7 +3,7 @@ project(papi-logging) # We only need to find Ginkgo if we build this example stand-alone if (NOT GINKGO_BUILD_EXAMPLES) - find_package(Ginkgo 1.3.0 REQUIRED) + find_package(Ginkgo 1.4.0 REQUIRED) endif() add_executable(papi-logging papi-logging.cpp) diff --git a/examples/par-ilu-convergence/CMakeLists.txt b/examples/par-ilu-convergence/CMakeLists.txt index ca2d88db12c..b5e0c8492e5 100644 --- a/examples/par-ilu-convergence/CMakeLists.txt +++ b/examples/par-ilu-convergence/CMakeLists.txt @@ -3,7 +3,7 @@ project(par-ilu-convergence) # We only need to find Ginkgo if we build this example stand-alone if (NOT GINKGO_BUILD_EXAMPLES) - find_package(Ginkgo 1.3.0 REQUIRED) + find_package(Ginkgo 1.4.0 REQUIRED) endif() add_executable(par-ilu-convergence par-ilu-convergence.cpp) diff --git a/examples/performance-debugging/CMakeLists.txt b/examples/performance-debugging/CMakeLists.txt index 6161b858d22..97cf82cb0ff 100644 --- a/examples/performance-debugging/CMakeLists.txt +++ b/examples/performance-debugging/CMakeLists.txt @@ -3,7 +3,7 @@ project(performance-debugging) # We only need to find Ginkgo if we build this example stand-alone if (NOT GINKGO_BUILD_EXAMPLES) - find_package(Ginkgo 1.3.0 REQUIRED) + find_package(Ginkgo 1.4.0 REQUIRED) endif() add_executable(performance-debugging performance-debugging.cpp) diff --git a/examples/poisson-solver/CMakeLists.txt b/examples/poisson-solver/CMakeLists.txt index 6c20c0fe087..fcbc831a6e5 100644 --- a/examples/poisson-solver/CMakeLists.txt +++ b/examples/poisson-solver/CMakeLists.txt @@ -3,7 +3,7 @@ project(poisson-solver) # We only need to find Ginkgo if we build this example stand-alone if (NOT GINKGO_BUILD_EXAMPLES) - find_package(Ginkgo 1.3.0 REQUIRED) + find_package(Ginkgo 1.4.0 REQUIRED) endif() add_executable(poisson-solver poisson-solver.cpp) diff --git a/examples/preconditioned-solver/CMakeLists.txt b/examples/preconditioned-solver/CMakeLists.txt index 002f4ae7218..bd2fcd3cb60 100644 --- a/examples/preconditioned-solver/CMakeLists.txt +++ b/examples/preconditioned-solver/CMakeLists.txt @@ -3,7 +3,7 @@ project(preconditioned-solver) # We only need to find Ginkgo if we build this example stand-alone if (NOT GINKGO_BUILD_EXAMPLES) - find_package(Ginkgo 1.3.0 REQUIRED) + find_package(Ginkgo 1.4.0 REQUIRED) endif() add_executable(preconditioned-solver preconditioned-solver.cpp) target_link_libraries(preconditioned-solver Ginkgo::ginkgo) diff --git a/examples/preconditioner-export/CMakeLists.txt b/examples/preconditioner-export/CMakeLists.txt index 81969576dcb..8195bf8a969 100644 --- a/examples/preconditioner-export/CMakeLists.txt +++ b/examples/preconditioner-export/CMakeLists.txt @@ -3,7 +3,7 @@ project(preconditioner-export) # We only need to find Ginkgo if we build this example stand-alone if (NOT GINKGO_BUILD_EXAMPLES) - find_package(Ginkgo 1.3.0 REQUIRED) + find_package(Ginkgo 1.4.0 REQUIRED) endif() add_executable(preconditioner-export preconditioner-export.cpp) diff --git a/examples/simple-solver-logging/CMakeLists.txt b/examples/simple-solver-logging/CMakeLists.txt index 1927690945e..1d5e75912e0 100644 --- a/examples/simple-solver-logging/CMakeLists.txt +++ b/examples/simple-solver-logging/CMakeLists.txt @@ -3,7 +3,7 @@ project(simple-solver-logging) # We only need to find Ginkgo if we build this example stand-alone if (NOT GINKGO_BUILD_EXAMPLES) - find_package(Ginkgo 1.3.0 REQUIRED) + find_package(Ginkgo 1.4.0 REQUIRED) endif() add_executable(simple-solver-logging simple-solver-logging.cpp) diff --git a/examples/simple-solver/CMakeLists.txt b/examples/simple-solver/CMakeLists.txt index 5603fea0377..ed067ec02e1 100644 --- a/examples/simple-solver/CMakeLists.txt +++ b/examples/simple-solver/CMakeLists.txt @@ -3,7 +3,7 @@ project(simple-solver) # We only need to find Ginkgo if we build this example stand-alone if (NOT GINKGO_BUILD_EXAMPLES) - find_package(Ginkgo 1.3.0 REQUIRED) + find_package(Ginkgo 1.4.0 REQUIRED) endif() add_executable(simple-solver simple-solver.cpp) diff --git a/examples/three-pt-stencil-solver/CMakeLists.txt b/examples/three-pt-stencil-solver/CMakeLists.txt index 34842e283af..661f064b36a 100644 --- a/examples/three-pt-stencil-solver/CMakeLists.txt +++ b/examples/three-pt-stencil-solver/CMakeLists.txt @@ -3,7 +3,7 @@ project(three-pt-stencil-solver) # We only need to find Ginkgo if we build this example stand-alone if (NOT GINKGO_BUILD_EXAMPLES) - find_package(Ginkgo 1.3.0 REQUIRED) + find_package(Ginkgo 1.4.0 REQUIRED) endif() add_executable(three-pt-stencil-solver three-pt-stencil-solver.cpp) From e58282eeff367b557a87f140a3227c20f1d500f8 Mon Sep 17 00:00:00 2001 From: Tobias Ribizel Date: Tue, 13 Apr 2021 12:02:31 +0200 Subject: [PATCH 08/11] review updates Co-authored-by: Yuhsiang M. Tsai --- examples/custom-matrix-format/CMakeLists.txt | 4 +--- examples/ginkgo-ranges/CMakeLists.txt | 1 - 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/examples/custom-matrix-format/CMakeLists.txt b/examples/custom-matrix-format/CMakeLists.txt index c6de4475eb9..89b5f7f737d 100644 --- a/examples/custom-matrix-format/CMakeLists.txt +++ b/examples/custom-matrix-format/CMakeLists.txt @@ -9,9 +9,7 @@ endif() set(CMAKE_CUDA_STANDARD 14) set(CMAKE_CUDA_STANDARD_REQUIRED ON) -add_executable(custom-matrix-format - custom-matrix-format.cpp - stencil_kernel.cu) +add_executable(custom-matrix-format custom-matrix-format.cpp stencil_kernel.cu) target_link_libraries(custom-matrix-format Ginkgo::ginkgo) # workaround for clang-cuda/g++ interaction diff --git a/examples/ginkgo-ranges/CMakeLists.txt b/examples/ginkgo-ranges/CMakeLists.txt index ebefcf103a3..c3cd06954c9 100644 --- a/examples/ginkgo-ranges/CMakeLists.txt +++ b/examples/ginkgo-ranges/CMakeLists.txt @@ -7,4 +7,3 @@ if (NOT GINKGO_BUILD_EXAMPLES) endif() add_executable(ginkgo-ranges ginkgo-ranges.cpp) target_link_libraries(ginkgo-ranges Ginkgo::ginkgo) -target_include_directories(ginkgo-ranges PRIVATE ${PROJECT_SOURCE_DIR}) From 4503012eb27851d057427a8d4032548af66cb7d9 Mon Sep 17 00:00:00 2001 From: Tobias Ribizel Date: Tue, 13 Apr 2021 15:55:49 +0200 Subject: [PATCH 09/11] store .so files in lib/ as well --- cmake/build_helpers.cmake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cmake/build_helpers.cmake b/cmake/build_helpers.cmake index 456398a0d1c..8ef56577f16 100644 --- a/cmake/build_helpers.cmake +++ b/cmake/build_helpers.cmake @@ -31,6 +31,8 @@ function(ginkgo_compile_features name) RUNTIME_OUTPUT_DIRECTORY "${GINKGO_LIBRARY_PATH}") set_property(TARGET "${name}" PROPERTY ARCHIVE_OUTPUT_DIRECTORY "${GINKGO_LIBRARY_PATH}") + set_property(TARGET "${name}" PROPERTY + LIBRARY_OUTPUT_DIRECTORY "${GINKGO_LIBRARY_PATH}") if (GINKGO_CHECK_CIRCULAR_DEPS) target_link_libraries("${name}" PRIVATE "${GINKGO_CIRCULAR_DEPS_FLAGS}") From 979539dd6beb13c3b2d667e1711797efd3857f74 Mon Sep 17 00:00:00 2001 From: Tobias Ribizel Date: Tue, 13 Apr 2021 15:56:20 +0200 Subject: [PATCH 10/11] fix example build.sh --- examples/build-setup.sh | 24 +++++++++++------------- examples/cb-gmres/build.sh | 3 +++ examples/custom-matrix-format/build.sh | 9 ++------- 3 files changed, 16 insertions(+), 20 deletions(-) diff --git a/examples/build-setup.sh b/examples/build-setup.sh index 45c827e07d3..b71f97f627a 100644 --- a/examples/build-setup.sh +++ b/examples/build-setup.sh @@ -2,27 +2,25 @@ # copy libraries LIBRARY_DIRS="core core/device_hooks reference omp cuda hip" -LIBRARY_NAMES="ginkgo ginkgo_reference ginkgo_omp ginkgo_cuda ginkgo_hip ginkgo_dpcpp" +LIBRARY_NAMES="ginkgo ginkgo_reference ginkgo_omp ginkgo_cuda ginkgo_hip ginkgo_dpcpp ginkgo_device" SUFFIXES=".so .dylib .dll d.so d.dylib d.dll" VERSION="1.4.0" -for prefix in ${LIBRARY_DIRS}; do - for name in ${LIBRARY_NAMES}; do - for suffix in ${SUFFIXES}; do - cp ${BUILD_DIR}/${prefix}/lib${name}${suffix}.${VERSION} \ - ${THIS_DIR} 2>/dev/null - if [ -e "${THIS_DIR}/lib${name}${suffix}.${VERSION}" ] - then - ln -s ${THIS_DIR}/lib${name}${suffix}.${VERSION} ${THIS_DIR}/lib${name}${suffix} 2>/dev/null - fi - done +for name in ${LIBRARY_NAMES}; do + for suffix in ${SUFFIXES}; do + cp ${BUILD_DIR}/lib/lib${name}${suffix}.${VERSION} \ + ${THIS_DIR} 2>/dev/null + if [ -e "${THIS_DIR}/lib${name}${suffix}.${VERSION}" ] + then + ln -s ${THIS_DIR}/lib${name}${suffix}.${VERSION} ${THIS_DIR}/lib${name}${suffix} 2>/dev/null + fi done done # figure out correct compiler flags if ls ${THIS_DIR} | grep -F "libginkgo." >/dev/null; then - LINK_FLAGS="-lginkgo -lginkgo_omp -lginkgo_cuda -lginkgo_reference -lginkgo_hip -lginkgo_dpcpp -Wl,-rpath,${THIS_DIR}" + LINK_FLAGS="-lginkgo -lginkgo_omp -lginkgo_cuda -lginkgo_reference -lginkgo_hip -lginkgo_dpcpp -lginkgo_device -Wl,-rpath,${THIS_DIR}" else - LINK_FLAGS="-lginkgod -lginkgo_ompd -lginkgo_cudad -lginkgo_referenced -lginkgo_hipd -lginkgo_dpcppd -Wl,-rpath,${THIS_DIR}" + LINK_FLAGS="-lginkgod -lginkgo_ompd -lginkgo_cudad -lginkgo_referenced -lginkgo_hipd -lginkgo_dpcppd -lginkgo_deviced -Wl,-rpath,${THIS_DIR}" fi if [ -z "${CXX}" ]; then CXX="c++" diff --git a/examples/cb-gmres/build.sh b/examples/cb-gmres/build.sh index 9cbd24ca500..da7e54829b6 100755 --- a/examples/cb-gmres/build.sh +++ b/examples/cb-gmres/build.sh @@ -10,6 +10,9 @@ THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" &>/dev/null && pwd ) source ${THIS_DIR}/../build-setup.sh +mkdir -p data +cp ${THIS_DIR}/../../matrices/test/ani1.mtx data/A.mtx + # build ${CXX} -std=c++14 -o ${THIS_DIR}/cb-gmres ${THIS_DIR}/cb-gmres.cpp \ -I${THIS_DIR}/../../include -I${BUILD_DIR}/include \ diff --git a/examples/custom-matrix-format/build.sh b/examples/custom-matrix-format/build.sh index 1821aa72bd5..10c2d188666 100755 --- a/examples/custom-matrix-format/build.sh +++ b/examples/custom-matrix-format/build.sh @@ -12,13 +12,8 @@ source ${THIS_DIR}/../build-setup.sh CXX="nvcc" -# figure out correct compiler flags -if ls ${THIS_DIR} | grep -F "libginkgo." >/dev/null; then - LINK_FLAGS="-lginkgo -lginkgo_omp -lginkgo_cuda -lginkgo_reference -lginkgo_dpcpp -lginkgo_hip -Xlinker -rpath -Xlinker ${THIS_DIR}" -else - LINK_FLAGS="-lginkgod -lginkgo_ompd -lginkgo_cudad -lginkgo_referenced -lginkgo_dpcppd -lginkgo_hipd -Xlinker -rpath -Xlinker ${THIS_DIR}" -fi - +# adjust to nvcc style link flags +LINK_FLAGS="${LINK_FLAGS/-Wl,-rpath,/-Xlinker -rpath -Xlinker }" # build ${CXX} -std=c++14 -o ${THIS_DIR}/custom-matrix-format \ From 59c8e23592069e0a4b77990d83e8eb6abdbaf3ad Mon Sep 17 00:00:00 2001 From: Tobias Ribizel Date: Fri, 7 May 2021 16:14:13 +0200 Subject: [PATCH 11/11] review updates Co-authored-by: Author: Terry Cojean --- CMakeLists.txt | 2 -- INSTALL.md | 17 +++-------------- README.md | 14 ++++---------- cmake/build_helpers.cmake | 2 ++ examples/build-setup.sh | 1 - examples/custom-matrix-format/CMakeLists.txt | 8 +++++++- examples/papi-logging/CMakeLists.txt | 4 ++++ 7 files changed, 20 insertions(+), 28 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 92fa3abdfa6..b1b4a258978 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,8 +25,6 @@ if (MINGW OR CYGWIN) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wa,-mbig-obj") endif() -set(GINKGO_LIBRARY_PATH "${PROJECT_BINARY_DIR}/lib") - # Ginkgo configuration options option(GINKGO_DEVEL_TOOLS "Add development tools to the build system" OFF) option(GINKGO_BUILD_TESTS "Generate build files for unit tests" ON) diff --git a/INSTALL.md b/INSTALL.md index 0f558d155e3..dad87874b26 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -132,20 +132,9 @@ generators. Other CMake generators are untested. ### Building Ginkgo in Windows Depending on the configuration settings, some manual work might be required: * Build Ginkgo with Debug mode: - Some Debug build specific issues can appear depending on the machine and environment. The known issues are the following: - 1. `ld` issue: encountering `ld: error: export ordinal too large` needs the compilation flag `-O1` - - The following are the details for different environments: - * _Microsoft Visual Studio_: - 1. `ld` issue (_Microsoft Visual Studio_ does not have this issue) - * _Cygwin_: - 1. `ld` issue (If building Ginkgo as static library, this is not needed) - * `cmake -DGINKGO_COMPILER_FLAGS="-Wpedantic -O1" ` (`GINKGO_COMPILER_FLAGS` is `-Wpedantic` by default) - * add `-O1` in the environement variable `CXX_FLAGS` or `CMAKE_CXX_FLAGS` - * _MinGW_: - 1. `ld` issue (If building Ginkgo as static library, this is not needed) - * `cmake -DGINKGO_COMPILER_FLAGS="-Wpedantic -O1" ` (`GINKGO_COMPILER_FLAGS` is `-Wpedantic` by default) - * add `-O1` in the environement variable `CXX_FLAGS` or `CMAKE_CXX_FLAGS` + Some Debug build specific issues can appear depending on the machine and environment: + When you encounter the error message `ld: error: export ordinal too large`, add the compilation flag `-O1` + by adding `-DCMAKE_CXX_FLAGS=-O1` to the CMake invocation. * Build Ginkgo in _MinGW_:\ If encountering the issue `cc1plus.exe: out of memory allocating 65536 bytes`, please follow the workaround in [reference](https://www.intel.com/content/www/us/en/programmable/support/support-resources/knowledge-base/embedded/2016/cc1plus-exe--out-of-memory-allocating-65536-bytes.html), diff --git a/README.md b/README.md index 5510deaebe0..47715cccf75 100644 --- a/README.md +++ b/README.md @@ -88,16 +88,10 @@ The Ginkgo CUDA module has the following __additional__ requirements: The Ginkgo OMP module has the following __additional__ requirements: * _MinGW_ or _Cygwin_ -Depending on the configuration settings, some manual work might be required. More details are availble in [windows section in INSTALL.md](INSTALL.md#building-ginkgo-in-windows): -* Build Ginkgo with Debug mode: - Some Debug build specific issues can appear depending on the machine and environment. The known issues are the following: - 1. `ld` issue: encountering `ld: error: export ordinal too large` needs the compilation flag `-O1` -* Build Ginkgo in _MinGW_: - If encountering the issue `cc1plus.exe: out of memory allocating 65536 bytes`, please follow the workaround in - [reference](https://www.intel.com/content/www/us/en/programmable/support/support-resources/knowledge-base/embedded/2016/cc1plus-exe--out-of-memory-allocating-65536-bytes.html), - or compile ginkgo again might work. - -__NOTE:__ _Microsoft Visual Studio_ only supports OpenMP 2.0, so it can not compile the ginkgo OMP module. +In these environments, two problems can be encountered, the solution for which is described in the +[windows section in INSTALL.md](INSTALL.md#building-ginkgo-in-windows): +* `ld: error: export ordinal too large` needs the compilation flag `-O1` +* `cc1plus.exe: out of memory allocating 65536 bytes` requires a modification of the environment __NOTE:__ Some restrictions will also apply on the version of C and C++ standard libraries installed on the system. This needs further investigation. diff --git a/cmake/build_helpers.cmake b/cmake/build_helpers.cmake index 8ef56577f16..3a264660733 100644 --- a/cmake/build_helpers.cmake +++ b/cmake/build_helpers.cmake @@ -1,3 +1,5 @@ +set(GINKGO_LIBRARY_PATH "${PROJECT_BINARY_DIR}/lib") + function(ginkgo_default_includes name) # set include path depending on used interface target_include_directories("${name}" diff --git a/examples/build-setup.sh b/examples/build-setup.sh index b71f97f627a..d5698c8f7e7 100644 --- a/examples/build-setup.sh +++ b/examples/build-setup.sh @@ -1,7 +1,6 @@ #!/bin/bash # copy libraries -LIBRARY_DIRS="core core/device_hooks reference omp cuda hip" LIBRARY_NAMES="ginkgo ginkgo_reference ginkgo_omp ginkgo_cuda ginkgo_hip ginkgo_dpcpp ginkgo_device" SUFFIXES=".so .dylib .dll d.so d.dylib d.dll" VERSION="1.4.0" diff --git a/examples/custom-matrix-format/CMakeLists.txt b/examples/custom-matrix-format/CMakeLists.txt index 89b5f7f737d..c0821a2cf35 100644 --- a/examples/custom-matrix-format/CMakeLists.txt +++ b/examples/custom-matrix-format/CMakeLists.txt @@ -4,13 +4,19 @@ project(custom-matrix-format CXX CUDA) # We only need to find Ginkgo if we build this example stand-alone if (NOT GINKGO_BUILD_EXAMPLES) find_package(Ginkgo 1.4.0 REQUIRED) + find_package(OpenMP 3.0 REQUIRED) +endif() + +if(NOT (GINKGO_BUILD_CUDA AND GINKGO_BUILD_OMP)) + message(FATAL_ERROR + "This example needs Ginkgo built with CUDA and OpenMP support") endif() set(CMAKE_CUDA_STANDARD 14) set(CMAKE_CUDA_STANDARD_REQUIRED ON) add_executable(custom-matrix-format custom-matrix-format.cpp stencil_kernel.cu) -target_link_libraries(custom-matrix-format Ginkgo::ginkgo) +target_link_libraries(custom-matrix-format Ginkgo::ginkgo OpenMP::OpenMP_CXX) # workaround for clang-cuda/g++ interaction set_target_properties(custom-matrix-format PROPERTIES POSITION_INDEPENDENT_CODE ON) diff --git a/examples/papi-logging/CMakeLists.txt b/examples/papi-logging/CMakeLists.txt index a8f0f8a260c..d7db0ef89fa 100644 --- a/examples/papi-logging/CMakeLists.txt +++ b/examples/papi-logging/CMakeLists.txt @@ -6,6 +6,10 @@ if (NOT GINKGO_BUILD_EXAMPLES) find_package(Ginkgo 1.4.0 REQUIRED) endif() +if (NOT GINKGO_HAVE_PAPI_SDE) + message(FATAL_ERROR "This example needs Ginkgo built with PAPI support") +endif() + add_executable(papi-logging papi-logging.cpp) target_link_libraries(papi-logging ginkgo PAPI::PAPI)