diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9e3a954ffdb..3b2d1f50ffe 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -108,6 +108,9 @@ stages: (( $(ctest -N | tail -1 | sed 's/Total Tests: //') != 0 )) || exit 1 - ctest -V - ninja test_install + - pushd test_install + - ninja install + - popd - | if [ "${RUN_EXAMPLES}" == "ON" ]; then export EX_ARG="reference" diff --git a/CMakeLists.txt b/CMakeLists.txt index af8ee6e40bd..27fad6f01d4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -351,12 +351,15 @@ else() set(GINKGO_TEST_INSTALL_HIP_COMMAND "${Ginkgo_BINARY_DIR}/test_install/test_install_hip") endif() endif() + +file(MAKE_DIRECTORY ${Ginkgo_BINARY_DIR}/test_install) add_custom_target(test_install COMMAND ${CMAKE_COMMAND} -G${CMAKE_GENERATOR} -H${Ginkgo_SOURCE_DIR}/test_install -B${Ginkgo_BINARY_DIR}/test_install -DCMAKE_PREFIX_PATH=${CMAKE_INSTALL_PREFIX}/${GINKGO_INSTALL_CONFIG_DIR} -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -DCMAKE_CUDA_COMPILER=${CMAKE_CUDA_COMPILER} + WORKING_DIRECTORY ${Ginkgo_BINARY_DIR}/test_install # `--config cfg` is ignored by single-configuration generator. # `$` is always be the same as `CMAKE_BUILD_TYPE` in # single-configuration generator. diff --git a/include/ginkgo/core/base/executor.hpp b/include/ginkgo/core/base/executor.hpp index ecd8dbc0cad..baeea6b7d63 100644 --- a/include/ginkgo/core/base/executor.hpp +++ b/include/ginkgo/core/base/executor.hpp @@ -317,9 +317,9 @@ private: \ * int main() { * // create executors * auto omp = OmpExecutor::create(); - * auto cuda = CudaExecutor::create(omp, 0); - * auto hip = HipExecutor::create(omp, 0); - * auto dpcpp = DpcppExecutor::create(omp, 0); + * auto cuda = CudaExecutor::create(0, omp); + * auto hip = HipExecutor::create(0, omp); + * auto dpcpp = DpcppExecutor::create(0, omp); * auto ref = ReferenceExecutor::create(); * * // create the operation diff --git a/test_exportbuild/CMakeLists.txt b/test_exportbuild/CMakeLists.txt index fd8ec8afc48..79b538f437c 100644 --- a/test_exportbuild/CMakeLists.txt +++ b/test_exportbuild/CMakeLists.txt @@ -13,6 +13,8 @@ if(MSVC) endif() endif() +# Here, we use test install without any data. We instantiate the +# interface only. add_executable(test_exportbuild ../test_install/test_install.cpp) target_compile_features(test_exportbuild PUBLIC cxx_std_14) target_link_libraries(test_exportbuild PRIVATE Ginkgo::ginkgo) diff --git a/test_install/CMakeLists.txt b/test_install/CMakeLists.txt index 6396b6ba88b..4c5fc9eea58 100644 --- a/test_install/CMakeLists.txt +++ b/test_install/CMakeLists.txt @@ -7,6 +7,11 @@ find_package(Ginkgo REQUIRED # Alternatively, use `cmake -DCMAKE_PREFIX_PATH=` to specify the install directory ) +# Copy the data to the build 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) + if(MSVC) if(GINKGO_BUILD_SHARED_LIBS) ginkgo_switch_to_windows_dynamic("CXX") @@ -20,8 +25,13 @@ endif() include(CheckLanguage) check_language(CUDA) +set(HAS_REFERENCE 0) +if (GINKGO_BUILD_REFERENCE) + set(HAS_REFERENCE 1) +endif() add_executable(test_install test_install.cpp) target_compile_features(test_install PUBLIC cxx_std_14) +target_compile_definitions(test_install PRIVATE HAS_REFERENCE=${HAS_REFERENCE}) target_link_libraries(test_install PRIVATE Ginkgo::ginkgo) if(GINKGO_BUILD_CUDA) @@ -33,25 +43,35 @@ if(GINKGO_BUILD_CUDA) ginkgo_switch_to_windows_static("CUDA") endif() endif() - add_executable(test_install_cuda test_install_cuda.cu) + 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 + PRIVATE "$<$:${GINKGO_CUDA_ARCH_FLAGS}>") + target_compile_definitions(test_install_cuda PRIVATE HAS_CUDA=1) + target_compile_definitions(test_install_cuda PRIVATE HAS_REFERENCE=${HAS_REFERENCE}) target_link_libraries(test_install_cuda PRIVATE Ginkgo::ginkgo) endif() if(GINKGO_BUILD_HIP) find_package(HIP REQUIRED) - set_source_files_properties(test_install.hip.cpp PROPERTIES HIP_SOURCE_PROPERTY_FORMAT TRUE) + set_source_files_properties(test_install.cpp PROPERTIES HIP_SOURCE_PROPERTY_FORMAT TRUE) # The library was compiled with `-fPIC` when in shared library mode if (GINKGO_BUILD_SHARED_LIBS) set (GINKGO_PIC_OPTION "-fPIC") set (GINKGO_CUDA_PIC_OPTION "-Xcompiler '-fPIC'") endif() - hip_add_executable(test_install_hip test_install.hip.cpp + if (CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA") + set(TESTINSTALL_CUDA_ARCH_FLAGS "${GINKGO_CUDA_ARCH_FLAGS}") + endif() + hip_add_executable(test_install_hip test_install.cpp HIPCC_OPTIONS "-std=c++14" CLANG_OPTIONS "${GINKGO_PIC_OPTION}" - NVCC_OPTIONS "${GINKGO_CUDA_PIC_OPTION}") + NVCC_OPTIONS "${GINKGO_CUDA_PIC_OPTION}" "${TESTINSTALL_CUDA_ARCH_FLAGS}") target_link_libraries(test_install_hip PRIVATE Ginkgo::ginkgo) + target_compile_definitions(test_install_hip PRIVATE HAS_HIP=1) + target_compile_definitions(test_install_hip PRIVATE HAS_REFERENCE=${HAS_REFERENCE}) # If we always link with CXX there is no RPATH issue set_target_properties(test_install_hip PROPERTIES LINKER_LANGUAGE CXX) @@ -59,3 +79,21 @@ if(GINKGO_BUILD_HIP) # Instead of using CXX, it's possible to instead use # target_link_libraries(test_install_hip PRIVATE ${GINKGO_INSTALL_RPATH_FOR_HIP}) endif() + +# Installation step +set(TESTINSTALL_INSTALL_DIR "${GINKGO_INSTALL_PREFIX}/smoke_tests") +set(TESTINSTALL_INSTALL_DATADIR "${TESTINSTALL_INSTALL_DIR}/data") +set(CMAKE_INSTALL_RPATH_USE_LINK_PATH ON) + +set_target_properties(test_install PROPERTIES INSTALL_RPATH "${GINKGO_INSTALL_LIBRARY_DIR}") +install(TARGETS test_install RUNTIME DESTINATION ${TESTINSTALL_INSTALL_DIR}) +if(GINKGO_BUILD_CUDA) + set_target_properties(test_install_cuda PROPERTIES INSTALL_RPATH "${GINKGO_INSTALL_LIBRARY_DIR}") + install(TARGETS test_install_cuda RUNTIME DESTINATION ${TESTINSTALL_INSTALL_DIR}) +endif() +if(GINKGO_BUILD_HIP) + set_target_properties(test_install_hip PROPERTIES INSTALL_RPATH "${GINKGO_INSTALL_LIBRARY_DIR}") + install(TARGETS test_install_hip RUNTIME DESTINATION ${TESTINSTALL_INSTALL_DIR}) +endif() +install(DIRECTORY "${TestInstall_BINARY_DIR}/data/" + DESTINATION "${TESTINSTALL_INSTALL_DATADIR}") diff --git a/test_install/data/A.mtx b/test_install/data/A.mtx new file mode 100644 index 00000000000..c67437da567 --- /dev/null +++ b/test_install/data/A.mtx @@ -0,0 +1,114 @@ +%%MatrixMarket matrix coordinate integer symmetric +%------------------------------------------------------------------------------- +% UF Sparse Matrix Collection, Tim Davis +% http://www.cise.ufl.edu/research/sparse/matrices/JGD_Trefethen/Trefethen_20b +% name: JGD_Trefethen/Trefethen_20b +% [Diagonal matrices with primes, Nick Trefethen, Oxford Univ.] +% id: 2203 +% date: 2008 +% author: N. Trefethen +% ed: J.-G. Dumas +% fields: name title A id date author ed kind notes +% kind: combinatorial problem +%------------------------------------------------------------------------------- +% notes: +% Diagonal matrices with primes, Nick Trefethen, Oxford Univ. +% From Jean-Guillaume Dumas' Sparse Integer Matrix Collection, +% http://ljk.imag.fr/membres/Jean-Guillaume.Dumas/simc.html +% +% Problem 7 of the Hundred-dollar, Hundred-digit Challenge Problems, +% SIAM News, vol 35, no. 1. +% +% 7. Let A be the 20,000 x 20,000 matrix whose entries are zero +% everywhere except for the primes 2, 3, 5, 7, . . . , 224737 along the +% main diagonal and the number 1 in all the positions A(i,j) with +% |i-j| = 1,2,4,8, . . . ,16384. What is the (1,1) entry of inv(A)? +% +% http://www.siam.org/news/news.php?id=388 +% +% Filename in JGD collection: Trefethen/trefethen_20__19_minor.sms +%------------------------------------------------------------------------------- +19 19 83 +1 1 3 +2 1 1 +3 1 1 +5 1 1 +9 1 1 +17 1 1 +2 2 5 +3 2 1 +4 2 1 +6 2 1 +10 2 1 +18 2 1 +3 3 7 +4 3 1 +5 3 1 +7 3 1 +11 3 1 +19 3 1 +4 4 11 +5 4 1 +6 4 1 +8 4 1 +12 4 1 +5 5 13 +6 5 1 +7 5 1 +9 5 1 +13 5 1 +6 6 17 +7 6 1 +8 6 1 +10 6 1 +14 6 1 +7 7 19 +8 7 1 +9 7 1 +11 7 1 +15 7 1 +8 8 23 +9 8 1 +10 8 1 +12 8 1 +16 8 1 +9 9 29 +10 9 1 +11 9 1 +13 9 1 +17 9 1 +10 10 31 +11 10 1 +12 10 1 +14 10 1 +18 10 1 +11 11 37 +12 11 1 +13 11 1 +15 11 1 +19 11 1 +12 12 41 +13 12 1 +14 12 1 +16 12 1 +13 13 43 +14 13 1 +15 13 1 +17 13 1 +14 14 47 +15 14 1 +16 14 1 +18 14 1 +15 15 53 +16 15 1 +17 15 1 +19 15 1 +16 16 59 +17 16 1 +18 16 1 +17 17 61 +18 17 1 +19 17 1 +18 18 67 +19 18 1 +19 19 71 diff --git a/test_install/data/b.mtx b/test_install/data/b.mtx new file mode 100644 index 00000000000..05d92ecc6f7 --- /dev/null +++ b/test_install/data/b.mtx @@ -0,0 +1,21 @@ +%%MatrixMarket matrix array real general +19 1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 diff --git a/test_install/data/x0.mtx b/test_install/data/x0.mtx new file mode 100644 index 00000000000..91d470cdbcd --- /dev/null +++ b/test_install/data/x0.mtx @@ -0,0 +1,21 @@ +%%MatrixMarket matrix array real general +19 1 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 diff --git a/test_install/test_install.cpp b/test_install/test_install.cpp index f55fef3fd0a..fb9f479c06a 100644 --- a/test_install/test_install.cpp +++ b/test_install/test_install.cpp @@ -34,21 +34,139 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include +#include +#include #include #include +#include #include #include #include #include +void assert_similar_matrices(const gko::matrix::Dense<> *m1, + const gko::matrix::Dense<> *m2, double prec) +{ + assert(m1->get_size()[0] == m2->get_size()[0]); + assert(m1->get_size()[1] == m2->get_size()[1]); + for (gko::size_type i = 0; i < m1->get_size()[0]; ++i) { + for (gko::size_type j = 0; j < m2->get_size()[1]; ++j) { + assert(std::abs(m1->at(i, j) - m2->at(i, j)) < prec); + } + } +} + + +template +void check_spmv(std::shared_ptr exec, + const gko::matrix_data &A_raw, + const gko::matrix::Dense<> *b, gko::matrix::Dense<> *x) +{ + auto test = Mtx::create(exec); +#if HAS_REFERENCE + auto x_clone = gko::clone(x); + test->read(A_raw); + test->apply(b, gko::lend(x_clone)); + // x_clone has the device result if using HIP or CUDA, otherwise it is + // reference only + +#if defined(HAS_HIP) || defined(HAS_CUDA) + // If we are on a device, we need to run a reference test to compare against + auto exec_ref = exec->get_master(); + auto test_ref = Mtx::create(exec_ref); + auto x_ref = gko::clone(exec_ref, x); + test_ref->read(A_raw); + test_ref->apply(b, gko::lend(x_ref)); + + // Actually check that `x_clone` is similar to `x_ref` + auto x_clone_ref = gko::clone(exec_ref, gko::lend(x_clone)); + assert_similar_matrices(gko::lend(x_clone_ref), gko::lend(x_ref), 1e-14); +#endif // defined(HAS_HIP) || defined(HAS_CUDA) +#endif // HAS_REFERENCE +} + + +template +void check_solver(std::shared_ptr exec, + const gko::matrix_data &A_raw, + const gko::matrix::Dense<> *b, gko::matrix::Dense<> *x) +{ + using Mtx = gko::matrix::Csr<>; + auto A = + gko::share(Mtx::create(exec, std::make_shared())); + + auto num_iters = 20u; + double reduction_factor = 1e-7; + auto solver_gen = + Solver::build() + .with_criteria( + gko::stop::Iteration::build().with_max_iters(num_iters).on( + exec), + gko::stop::ResidualNorm<>::build() + .with_reduction_factor(reduction_factor) + .on(exec)) + .on(exec); +#if HAS_REFERENCE + A->read(A_raw); + auto x_clone = gko::clone(x); + solver_gen->generate(A)->apply(b, gko::lend(x_clone)); + // x_clone has the device result if using HIP or CUDA, otherwise it is + // reference only + +#if defined(HAS_HIP) || defined(HAS_CUDA) + // If we are on a device, we need to run a reference test to compare against + auto exec_ref = exec->get_master(); + auto A_ref = gko::share( + Mtx::create(exec_ref, std::make_shared())); + A_ref->read(A_raw); + auto solver_gen_ref = + Solver::build() + .with_criteria( + gko::stop::Iteration::build().with_max_iters(num_iters).on( + exec_ref), + gko::stop::ResidualNorm<>::build() + .with_reduction_factor(reduction_factor) + .on(exec_ref)) + .on(exec_ref); + auto x_ref = gko::clone(exec_ref, x); + solver_gen->generate(A_ref)->apply(b, gko::lend(x_ref)); + + // Actually check that `x_clone` is similar to `x_ref` + auto x_clone_ref = gko::clone(exec_ref, gko::lend(x_clone)); + assert_similar_matrices(gko::lend(x_clone_ref), gko::lend(x_ref), 1e-12); +#endif // defined(HAS_HIP) || defined(HAS_CUDA) +#endif // HAS_REFERENCE +} + + // core/base/polymorphic_object.hpp class PolymorphicObjectTest : public gko::PolymorphicObject {}; -int main(int, char **) +int main() { - auto refExec = gko::ReferenceExecutor::create(); +#if defined(HAS_CUDA) + auto exec = gko::CudaExecutor::create(0, gko::ReferenceExecutor::create()); +#elif defined(HAS_HIP) + auto exec = gko::HipExecutor::create(0, gko::ReferenceExecutor::create()); +#else + auto exec = gko::ReferenceExecutor::create(); +#endif + + using vec = gko::matrix::Dense<>; +#if HAS_REFERENCE + auto b = gko::read(std::ifstream("data/b.mtx"), exec); + auto x = gko::read(std::ifstream("data/x0.mtx"), exec); + std::ifstream A_file("data/A.mtx"); + auto A_raw = gko::read_raw(A_file); +#else + // Instantiate dummy data, they will be unused + auto b = vec::create(exec); + auto x = vec::create(exec); + gko::matrix_data A_raw{}; +#endif + // core/base/abstract_factory.hpp { using type1 = int; @@ -177,12 +295,12 @@ int main(int, char **) // core/factorization/par_ilu.hpp { - auto test = gko::factorization::ParIlu<>::build().on(refExec); + auto test = gko::factorization::ParIlu<>::build().on(exec); } // core/log/convergence.hpp { - auto test = gko::log::Convergence<>::create(refExec); + auto test = gko::log::Convergence<>::create(exec); } // core/log/record.hpp @@ -192,202 +310,177 @@ int main(int, char **) // core/log/stream.hpp { - auto test = gko::log::Stream<>::create(refExec); + auto test = gko::log::Stream<>::create(exec); } #if GKO_HAVE_PAPI_SDE // core/log/papi.hpp { - auto test = gko::log::Papi<>::create(refExec); + auto test = gko::log::Papi<>::create(exec); } #endif // GKO_HAVE_PAPI_SDE // core/matrix/coo.hpp { using Mtx = gko::matrix::Coo<>; - auto test = Mtx::create(refExec, gko::dim<2>{2, 2}, 2); + check_spmv(exec, A_raw, gko::lend(b), gko::lend(x)); } // core/matrix/csr.hpp { using Mtx = gko::matrix::Csr<>; - auto test = Mtx::create(refExec, gko::dim<2>{2, 2}, 2, - std::make_shared(2)); + auto test = Mtx::create(exec, std::make_shared()); } // core/matrix/dense.hpp { using Mtx = gko::matrix::Dense<>; - auto test = Mtx::create(refExec, gko::dim<2>{2, 2}); + check_spmv(exec, A_raw, gko::lend(b), gko::lend(x)); } // core/matrix/ell.hpp { using Mtx = gko::matrix::Ell<>; - auto test = Mtx::create(refExec, gko::dim<2>{2, 2}, 2); + check_spmv(exec, A_raw, gko::lend(b), gko::lend(x)); } // core/matrix/hybrid.hpp { using Mtx = gko::matrix::Hybrid<>; - auto test = Mtx::create(refExec, gko::dim<2>{2, 2}, 2, 2, 1); + check_spmv(exec, A_raw, gko::lend(b), gko::lend(x)); } // core/matrix/identity.hpp { using Mtx = gko::matrix::Identity<>; - auto test = Mtx::create(refExec); + auto test = Mtx::create(exec); } // core/matrix/permutation.hpp { using Mtx = gko::matrix::Permutation<>; - auto test = Mtx::create(refExec, gko::dim<2>{2, 2}); + auto test = Mtx::create(exec, gko::dim<2>{2, 2}); } // core/matrix/sellp.hpp { using Mtx = gko::matrix::Sellp<>; - auto test = Mtx::create(refExec, gko::dim<2>{2, 2}, 2); + check_spmv(exec, A_raw, gko::lend(b), gko::lend(x)); } // core/matrix/sparsity_csr.hpp { using Mtx = gko::matrix::SparsityCsr<>; - auto test = Mtx::create(refExec, gko::dim<2>{2, 2}); + auto test = Mtx::create(exec, gko::dim<2>{2, 2}); } // core/multigrid/amgx_pgm.hpp { - auto test = gko::multigrid::AmgxPgm<>::build().on(refExec); + auto test = gko::multigrid::AmgxPgm<>::build().on(exec); } // core/preconditioner/ilu.hpp { - auto test = gko::preconditioner::Ilu<>::build().on(refExec); + auto test = gko::preconditioner::Ilu<>::build().on(exec); } // core/preconditioner/isai.hpp { - auto test_l = gko::preconditioner::LowerIsai<>::build().on(refExec); - auto test_u = gko::preconditioner::UpperIsai<>::build().on(refExec); + auto test_l = gko::preconditioner::LowerIsai<>::build().on(exec); + auto test_u = gko::preconditioner::UpperIsai<>::build().on(exec); } // core/preconditioner/jacobi.hpp { using Bj = gko::preconditioner::Jacobi<>; - auto test = Bj::build().with_max_block_size(1u).on(refExec); + auto test = Bj::build().with_max_block_size(1u).on(exec); } // core/solver/bicgstab.hpp { using Solver = gko::solver::Bicgstab<>; - auto test = Solver::build() - .with_criteria( - gko::stop::Iteration::build().with_max_iters(1u).on( - refExec)) - .on(refExec); + check_solver(exec, A_raw, gko::lend(b), gko::lend(x)); } // core/solver/cb_gmres.hpp { using Solver = gko::solver::CbGmres<>; - auto test = Solver::build() - .with_criteria( - gko::stop::Iteration::build().with_max_iters(1u).on( - refExec)) - .on(refExec); + check_solver(exec, A_raw, gko::lend(b), gko::lend(x)); } // core/solver/cg.hpp { using Solver = gko::solver::Cg<>; - auto test = Solver::build() - .with_criteria( - gko::stop::Iteration::build().with_max_iters(1u).on( - refExec)) - .on(refExec); + check_solver(exec, A_raw, gko::lend(b), gko::lend(x)); } // core/solver/cgs.hpp { using Solver = gko::solver::Cgs<>; - auto test = Solver::build() - .with_criteria( - gko::stop::Iteration::build().with_max_iters(1u).on( - refExec)) - .on(refExec); + check_solver(exec, A_raw, gko::lend(b), gko::lend(x)); } // core/solver/fcg.hpp { using Solver = gko::solver::Fcg<>; - auto test = Solver::build() - .with_criteria( - gko::stop::Iteration::build().with_max_iters(1u).on( - refExec)) - .on(refExec); + check_solver(exec, A_raw, gko::lend(b), gko::lend(x)); } // core/solver/gmres.hpp { using Solver = gko::solver::Gmres<>; - auto test = Solver::build() - .with_criteria( - gko::stop::Iteration::build().with_max_iters(1u).on( - refExec)) - .on(refExec); + check_solver(exec, A_raw, gko::lend(b), gko::lend(x)); } // core/solver/ir.hpp { using Solver = gko::solver::Ir<>; - auto test = Solver::build() - .with_criteria( - gko::stop::Iteration::build().with_max_iters(1u).on( - refExec)) - .on(refExec); + auto test = + Solver::build() + .with_criteria( + gko::stop::Iteration::build().with_max_iters(1u).on(exec)) + .on(exec); } // core/solver/lower_trs.hpp { using Solver = gko::solver::LowerTrs<>; - auto test = Solver::build().on(refExec); + auto test = Solver::build().on(exec); } // core/stop/ { // iteration.hpp auto iteration = - gko::stop::Iteration::build().with_max_iters(1u).on(refExec); + gko::stop::Iteration::build().with_max_iters(1u).on(exec); // time.hpp auto time = gko::stop::Time::build() .with_time_limit(std::chrono::milliseconds(10)) - .on(refExec); + .on(exec); // residual_norm.hpp auto main_res = gko::stop::ResidualNorm<>::build() .with_reduction_factor(1e-10) .with_baseline(gko::stop::mode::absolute) - .on(refExec); + .on(exec); auto implicit_res = gko::stop::ImplicitResidualNorm<>::build() .with_reduction_factor(1e-10) .with_baseline(gko::stop::mode::absolute) - .on(refExec); + .on(exec); auto res_red = gko::stop::ResidualNormReduction<>::build() .with_reduction_factor(1e-10) - .on(refExec); + .on(exec); auto rel_res = gko::stop::RelativeResidualNorm<>::build().with_tolerance(1e-10).on( - refExec); + exec); auto abs_res = gko::stop::AbsoluteResidualNorm<>::build().with_tolerance(1e-10).on( - refExec); + exec); // stopping_status.hpp auto stop_status = gko::stopping_status{}; @@ -396,10 +489,17 @@ int main(int, char **) auto combined = gko::stop::Combined::build() .with_criteria(std::move(time), std::move(iteration)) - .on(refExec); - } - - std::cout << "test_install: the Ginkgo installation was correctly detected " + .on(exec); + } +#if defined(HAS_CUDA) + auto extra_info = "(CUDA)"; +#elif defined(HAS_HIP) + auto extra_info = "(HIP)"; +#else + auto extra_info = "(REFERENCE)"; +#endif + std::cout << "test_install" << extra_info + << ": the Ginkgo installation was correctly detected " "and is complete." << std::endl; diff --git a/test_install/test_install.hip.cpp b/test_install/test_install.hip.cpp deleted file mode 100644 index 65708b0cffa..00000000000 --- a/test_install/test_install.hip.cpp +++ /dev/null @@ -1,386 +0,0 @@ -/************************************************************* -Copyright (c) 2017-2021, the Ginkgo authors -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -1. Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright -notice, this list of conditions and the following disclaimer in the -documentation and/or other materials provided with the distribution. - -3. Neither the name of the copyright holder nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*************************************************************/ - -#include - - -#include - - -#include -#include -#include -#include -#include -#include -#include - - -// core/base/polymorphic_object.hpp -class PolymorphicObjectTest : public gko::PolymorphicObject {}; - - -int main(int, char **) -{ - auto refExec = gko::ReferenceExecutor::create(); - auto hipExec = gko::HipExecutor::create(0, refExec); - // core/base/abstract_factory.hpp - { - using type1 = int; - using type2 = double; - static_assert( - std::is_same< - gko::AbstractFactory::abstract_product_type, - type1>::value, - "abstract_factory.hpp not included properly!"); - } - - // core/base/array.hpp - { - using type1 = int; - using ArrayType = gko::Array; - ArrayType{}; - } - - // core/base/combination.hpp - { - using type1 = int; - static_assert( - std::is_same::value_type, type1>::value, - "combination.hpp not included properly!"); - } - - // core/base/composition.hpp - { - using type1 = int; - static_assert( - std::is_same::value_type, type1>::value, - "composition.hpp not included properly"); - } - - // core/base/dim.hpp - { - using type1 = int; - gko::dim<3, type1>{4, 4, 4}; - } - - // core/base/exception.hpp - { - gko::Error(std::string("file"), 12, - std::string("Test for an error class.")); - } - - // core/base/exception_helpers.hpp - { - auto test = gko::dim<2>{3}; - GKO_ASSERT_IS_SQUARE_MATRIX(test); - } - - // core/base/executor.hpp - { - gko::ReferenceExecutor::create(); - } - - // core/base/math.hpp - { - using testType = double; - static_assert(gko::is_complex() == false, - "math.hpp not included properly!"); - } - - // core/base/matrix_data.hpp - { - gko::matrix_data<>{}; - } - - // core/base/mtx_io.hpp - { - static_assert(gko::layout_type::array != gko::layout_type::coordinate, - "mtx_io.hpp not included properly!"); - } - - // core/base/name_demangling.hpp - { - auto testVar = 3.0; - gko::name_demangling::get_static_type(testVar); - } - - // core/base/polymorphic_object.hpp - { - gko::PolymorphicObject *test; - (void)test; // silence unused variable warning - } - - // core/base/range.hpp - { - gko::span{12}; - } - - // core/base/range_accessors.hpp - { - auto testVar = 12; - gko::range>(&testVar, 1u, - 1u, 1u); - } - - // core/base/perturbation.hpp - { - using type1 = int; - static_assert( - std::is_same::value_type, type1>::value, - "perturbation.hpp not included properly"); - } - - // core/base/std_extensions.hpp - { - static_assert(std::is_same, void>::value, - "std_extensions.hpp not included properly!"); - } - - // core/base/types.hpp - { - static_assert(gko::size_type{12} == 12, - "types.hpp not included properly"); - } - - // core/base/utils.hpp - { - gko::null_deleter{}; - } - - // core/base/version.hpp - { - gko::version_info::get().header_version; - } - - // core/factorization/par_ilu.hpp - { - gko::factorization::ParIlu<>::build().on(hipExec); - } - - // core/log/convergence.hpp - { - gko::log::Convergence<>::create(hipExec); - } - - // core/log/record.hpp - { - gko::log::executor_data{}; - } - - // core/log/stream.hpp - { - gko::log::Stream<>::create(hipExec); - } - -#if GKO_HAVE_PAPI_SDE - // core/log/papi.hpp - { - gko::log::Papi<>::create(hipExec); - } -#endif // GKO_HAVE_PAPI_SDE - - // core/matrix/coo.hpp - { - using Mtx = gko::matrix::Coo<>; - Mtx::create(hipExec, gko::dim<2>{2, 2}, 2); - } - - // core/matrix/csr.hpp - { - using Mtx = gko::matrix::Csr<>; - Mtx::create(hipExec, gko::dim<2>{2, 2}, 2, - std::make_shared(2)); - } - - // core/matrix/dense.hpp - { - using Mtx = gko::matrix::Dense<>; - Mtx::create(hipExec, gko::dim<2>{2, 2}); - } - - // core/matrix/ell.hpp - { - using Mtx = gko::matrix::Ell<>; - Mtx::create(hipExec, gko::dim<2>{2, 2}, 2); - } - - // core/matrix/hybrid.hpp - { - using Mtx = gko::matrix::Hybrid<>; - Mtx::create(hipExec, gko::dim<2>{2, 2}, 2, 2, 1); - } - - // core/matrix/identity.hpp - { - using Mtx = gko::matrix::Identity<>; - Mtx::create(hipExec); - } - - // core/matrix/permutation.hpp - { - using Mtx = gko::matrix::Permutation<>; - Mtx::create(hipExec, gko::dim<2>{2, 2}); - } - - // core/matrix/sellp.hpp - { - using Mtx = gko::matrix::Sellp<>; - Mtx::create(hipExec, gko::dim<2>{2, 2}, 2); - } - - // core/matrix/sparsity_csr.hpp - { - using Mtx = gko::matrix::SparsityCsr<>; - Mtx::create(hipExec, gko::dim<2>{2, 2}); - } - - // core/preconditioner/ilu.hpp - { - gko::preconditioner::Ilu<>::build().on(hipExec); - } - - // core/preconditioner/jacobi.hpp - { - using Bj = gko::preconditioner::Jacobi<>; - Bj::build().with_max_block_size(1u).on(hipExec); - } - - // core/solver/bicgstab.hpp - { - using Solver = gko::solver::Bicgstab<>; - Solver::build() - .with_criteria( - gko::stop::Iteration::build().with_max_iters(1u).on(hipExec)) - .on(hipExec); - } - - // core/solver/cg.hpp - { - using Solver = gko::solver::Cg<>; - Solver::build() - .with_criteria( - gko::stop::Iteration::build().with_max_iters(1u).on(hipExec)) - .on(hipExec); - } - - // core/solver/cgs.hpp - { - using Solver = gko::solver::Cgs<>; - Solver::build() - .with_criteria( - gko::stop::Iteration::build().with_max_iters(1u).on(hipExec)) - .on(hipExec); - } - - // core/solver/fcg.hpp - { - using Solver = gko::solver::Fcg<>; - Solver::build() - .with_criteria( - gko::stop::Iteration::build().with_max_iters(1u).on(hipExec)) - .on(hipExec); - } - - // core/solver/gmres.hpp - { - using Solver = gko::solver::Gmres<>; - Solver::build() - .with_criteria( - gko::stop::Iteration::build().with_max_iters(1u).on(hipExec)) - .on(hipExec); - } - - // core/solver/ir.hpp - { - using Solver = gko::solver::Ir<>; - Solver::build() - .with_criteria( - gko::stop::Iteration::build().with_max_iters(1u).on(hipExec)) - .on(hipExec); - } - - // core/solver/lower_trs.hpp - { - using Solver = gko::solver::LowerTrs<>; - Solver::build().on(hipExec); - } - - // core/stop/ - { - // iteration.hpp - auto iteration = - gko::stop::Iteration::build().with_max_iters(1u).on(hipExec); - - // time.hpp - auto time = gko::stop::Time::build() - .with_time_limit(std::chrono::milliseconds(10)) - .on(hipExec); - - // residual_norm.hpp - gko::stop::ResidualNormReduction<>::build() - .with_reduction_factor(1e-10) - .on(hipExec); - - gko::stop::ResidualNorm<>::build() - .with_reduction_factor(1e-10) - .with_baseline(gko::stop::mode::absolute) - .on(hipExec); - - gko::stop::ImplicitResidualNorm<>::build() - .with_reduction_factor(1e-10) - .with_baseline(gko::stop::mode::absolute) - .on(hipExec); - - gko::stop::RelativeResidualNorm<>::build().with_tolerance(1e-10).on( - hipExec); - - gko::stop::AbsoluteResidualNorm<>::build().with_tolerance(1e-10).on( - hipExec); - - // stopping_status.hpp - gko::stopping_status{}; - - // combined.hpp - auto combined = - gko::stop::Combined::build() - .with_criteria(std::move(time), std::move(iteration)) - .on(hipExec); - } - - std::cout - << "test_install_hip: the Ginkgo installation was correctly detected " - "and is complete." - << std::endl; - - return 0; -} diff --git a/test_install/test_install_cuda.cu b/test_install/test_install_cuda.cu deleted file mode 100644 index 1c404236110..00000000000 --- a/test_install/test_install_cuda.cu +++ /dev/null @@ -1,388 +0,0 @@ -/************************************************************* -Copyright (c) 2017-2021, the Ginkgo authors -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -1. Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright -notice, this list of conditions and the following disclaimer in the -documentation and/or other materials provided with the distribution. - -3. Neither the name of the copyright holder nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*************************************************************/ - -#include - - -#include -#include -#include -#include -#include -#include -#include - - -// core/base/polymorphic_object.hpp -class PolymorphicObjectTest : public gko::PolymorphicObject {}; - - -int main(int, char **) -{ - auto refExec = gko::ReferenceExecutor::create(); - auto cudaExec = gko::CudaExecutor::create(0, refExec); - // core/base/abstract_factory.hpp - { - using type1 = int; - using type2 = double; - static_assert( - std::is_same< - gko::AbstractFactory::abstract_product_type, - type1>::value, - "abstract_factory.hpp not included properly!"); - } - - // core/base/array.hpp - { - using type1 = int; - using ArrayType = gko::Array; - ArrayType{}; - } - - // core/base/combination.hpp - { - using type1 = int; - static_assert( - std::is_same::value_type, type1>::value, - "combination.hpp not included properly!"); - } - - // core/base/composition.hpp - { - using type1 = int; - static_assert( - std::is_same::value_type, type1>::value, - "composition.hpp not included properly"); - } - - // core/base/dim.hpp - { - using type1 = int; - gko::dim<3, type1>{4, 4, 4}; - } - - // core/base/exception.hpp - { - gko::Error(std::string("file"), 12, - std::string("Test for an error class.")); - } - - // core/base/exception_helpers.hpp - { - auto test = gko::dim<2>{3}; - GKO_ASSERT_IS_SQUARE_MATRIX(test); - } - - // core/base/executor.hpp - { - gko::ReferenceExecutor::create(); - } - - // core/base/math.hpp - { - using testType = double; - static_assert(gko::is_complex() == false, - "math.hpp not included properly!"); - } - - // core/base/matrix_data.hpp - { - gko::matrix_data<>{}; - } - - // core/base/mtx_io.hpp - { - static_assert(gko::layout_type::array != gko::layout_type::coordinate, - "mtx_io.hpp not included properly!"); - } - - // core/base/name_demangling.hpp - { - auto testVar = 3.0; - gko::name_demangling::get_static_type(testVar); - } - - // core/base/polymorphic_object.hpp - { - gko::PolymorphicObject *test; - (void)test; // silence unused variable warning - } - - // core/base/range.hpp - { - gko::span{12}; - } - - // core/base/range_accessors.hpp - { - auto testVar = 12; - gko::range>(&testVar, 1u, - 1u, 1u); - } - - // core/base/perturbation.hpp - { - using type1 = int; - static_assert( - std::is_same::value_type, type1>::value, - "perturbation.hpp not included properly"); - } - - // core/base/std_extensions.hpp - { - static_assert(std::is_same, void>::value, - "std_extensions.hpp not included properly!"); - } - - // core/base/types.hpp - { - static_assert(gko::size_type{12} == 12, - "types.hpp not included properly"); - } - - // core/base/utils.hpp - { - gko::null_deleter{}; - } - - // core/base/version.hpp - { - gko::version_info::get().header_version; - } - - // core/factorization/par_ilu.hpp - { - gko::factorization::ParIlu<>::build().on(cudaExec); - } - - // core/log/convergence.hpp - { - gko::log::Convergence<>::create(cudaExec); - } - - // core/log/record.hpp - { - gko::log::executor_data{}; - } - - // core/log/stream.hpp - { - gko::log::Stream<>::create(cudaExec); - } - -#if GKO_HAVE_PAPI_SDE - // core/log/papi.hpp - { - gko::log::Papi<>::create(cudaExec); - } -#endif // GKO_HAVE_PAPI_SDE - - // core/matrix/coo.hpp - { - using Mtx = gko::matrix::Coo<>; - Mtx::create(cudaExec, gko::dim<2>{2, 2}, 2); - } - - // core/matrix/csr.hpp - { - using Mtx = gko::matrix::Csr<>; - Mtx::create(cudaExec, gko::dim<2>{2, 2}, 2, - std::make_shared(2)); - } - - // core/matrix/dense.hpp - { - using Mtx = gko::matrix::Dense<>; - Mtx::create(cudaExec, gko::dim<2>{2, 2}); - } - - // core/matrix/ell.hpp - { - using Mtx = gko::matrix::Ell<>; - Mtx::create(cudaExec, gko::dim<2>{2, 2}, 2); - } - - // core/matrix/hybrid.hpp - { - using Mtx = gko::matrix::Hybrid<>; - Mtx::create(cudaExec, gko::dim<2>{2, 2}, 2, 2, 1); - } - - // core/matrix/identity.hpp - { - using Mtx = gko::matrix::Identity<>; - Mtx::create(cudaExec); - } - - // core/matrix/permutation.hpp - { - using Mtx = gko::matrix::Permutation<>; - Mtx::create(cudaExec, gko::dim<2>{2, 2}); - } - - // core/matrix/sellp.hpp - { - using Mtx = gko::matrix::Sellp<>; - Mtx::create(cudaExec, gko::dim<2>{2, 2}, 2); - } - - // core/matrix/sparsity_csr.hpp - { - using Mtx = gko::matrix::SparsityCsr<>; - Mtx::create(cudaExec, gko::dim<2>{2, 2}); - } - - // core/multigrid/amgx_pgm.hpp - { - gko::multigrid::AmgxPgm<>::build().on(cudaExec); - } - - // core/preconditioner/ilu.hpp - { - gko::preconditioner::Ilu<>::build().on(cudaExec); - } - - // core/preconditioner/jacobi.hpp - { - using Bj = gko::preconditioner::Jacobi<>; - Bj::build().with_max_block_size(1u).on(cudaExec); - } - - // core/solver/bicgstab.hpp - { - using Solver = gko::solver::Bicgstab<>; - Solver::build() - .with_criteria( - gko::stop::Iteration::build().with_max_iters(1u).on(cudaExec)) - .on(cudaExec); - } - - // core/solver/cg.hpp - { - using Solver = gko::solver::Cg<>; - Solver::build() - .with_criteria( - gko::stop::Iteration::build().with_max_iters(1u).on(cudaExec)) - .on(cudaExec); - } - - // core/solver/cgs.hpp - { - using Solver = gko::solver::Cgs<>; - Solver::build() - .with_criteria( - gko::stop::Iteration::build().with_max_iters(1u).on(cudaExec)) - .on(cudaExec); - } - - // core/solver/fcg.hpp - { - using Solver = gko::solver::Fcg<>; - Solver::build() - .with_criteria( - gko::stop::Iteration::build().with_max_iters(1u).on(cudaExec)) - .on(cudaExec); - } - - // core/solver/gmres.hpp - { - using Solver = gko::solver::Gmres<>; - Solver::build() - .with_criteria( - gko::stop::Iteration::build().with_max_iters(1u).on(cudaExec)) - .on(cudaExec); - } - - // core/solver/ir.hpp - { - using Solver = gko::solver::Ir<>; - Solver::build() - .with_criteria( - gko::stop::Iteration::build().with_max_iters(1u).on(cudaExec)) - .on(cudaExec); - } - - // core/solver/lower_trs.hpp - { - using Solver = gko::solver::LowerTrs<>; - Solver::build().on(cudaExec); - } - - // core/stop/ - { - // iteration.hpp - auto iteration = - gko::stop::Iteration::build().with_max_iters(1u).on(cudaExec); - - // time.hpp - auto time = gko::stop::Time::build() - .with_time_limit(std::chrono::milliseconds(10)) - .on(cudaExec); - - // residual_norm.hpp - gko::stop::ResidualNormReduction<>::build() - .with_reduction_factor(1e-10) - .on(cudaExec); - - gko::stop::ResidualNorm<>::build() - .with_reduction_factor(1e-10) - .with_baseline(gko::stop::mode::absolute) - .on(cudaExec); - - gko::stop::ImplicitResidualNorm<>::build() - .with_reduction_factor(1e-10) - .with_baseline(gko::stop::mode::absolute) - .on(cudaExec); - - gko::stop::RelativeResidualNorm<>::build().with_tolerance(1e-10).on( - cudaExec); - - gko::stop::AbsoluteResidualNorm<>::build().with_tolerance(1e-10).on( - cudaExec); - - // stopping_status.hpp - gko::stopping_status{}; - - // combined.hpp - auto combined = - gko::stop::Combined::build() - .with_criteria(std::move(time), std::move(iteration)) - .on(cudaExec); - } - - std::cout - << "test_install_cuda: the Ginkgo installation was correctly detected " - "and is complete." - << std::endl; - - return 0; -}