diff --git a/CMakeLists.txt b/CMakeLists.txt index b849e1338..31e39bc04 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -610,7 +610,7 @@ add_definitions( -DHAVE_METIS_ -DLowerUnderscore -DPtr64Bits ) -set(directory_list base prec krylov util) # TODO: add cbind +set(directory_list base prec krylov util test) # TODO: add cbind foreach(directory ${directory_list}) add_subdirectory("${directory}") endforeach() diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 000000000..a21d76983 --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,94 @@ +if (NOT MPI_C_FOUND) + find_package(MPI REQUIRED) + + set(CMAKE_C_COMPILE_FLAGS ${CMAKE_C_COMPILE_FLAGS} ${MPI_C_COMPILE_FLAGS}) + set(CMAKE_C_LINK_FLAGS ${CMAKE_C_LINK_FLAGS} ${MPI_C_LINK_FLAGS}) + set(CMAKE_Fortran_COMPILE_FLAGS ${CMAKE_Fortran_COMPILE_FLAGS} ${MPI_Fortran_COMPILE_FLAGS}) + set(CMAKE_Fortran_LINK_FLAGS ${CMAKE_Fortran_LINK_FLAGS} ${MPI_Fortran_LINK_FLAGS}) + include_directories(BEFORE ${MPI_C_INCLUDE_PATH} ${MPI_Fortran_INCLUDE_PATH}) +endif() + +if("${CMAKE_Fortran_COMPILER_ID}" STREQUAL "GNU") + set(gfortran_compiler true) +endif() + +include(CheckIncludeFile) +CHECK_INCLUDE_FILE("alloca.h" HAVE_ALLOCA) +if(NOT HAVE_ALLOCA) + add_definitions(-DALLOCA_MISSING) + message(WARNING "Could not find . Assuming functionality is provided elsewhere.") +endif() + +set(old_cmake_required_includes "${CMAKE_REQUIRED_INCLUDES}") +if(CMAKE_REQUIRED_INCLUDES) + set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES};${MPI_C_INCLUDE_PATH}) +else() + set(CMAKE_REQUIRED_INCLUDES ${MPI_C_INCLUDE_PATH}) +endif() +set(old_cmake_required_flags "${CMAKE_REQUIRED_FLAGS}") +if(CMAKE_REQUIRED_FLAGS) + set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS};${MPI_C_COMPILE_FLAGS};${MPI_C_LINK_FLAGS}) +else() + set(CMAKE_REQUIRED_FLAGS ${MPI_C_COMPILE_FLAGS};${MPI_C_LINK_FLAGS}) +endif() +set(old_cmake_required_libraries "${CMAKE_REQUIRED_LIBRARIES}") +if(CMAKE_REQUIRED_LIBRARIES) + set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES};${MPI_C_LIBRARIES}) +else() + set(CMAKE_REQUIRED_LIBRARIES ${MPI_C_LIBRARIES}) +endif() + +set(MPI_HEADERS mpi.h) +include(CheckIncludeFiles) +CHECK_INCLUDE_FILES("mpi.h;mpi-ext.h" HAVE_MPI_EXT) +if(HAVE_MPI_EXT) + add_definitions(-DHAVE_MPI_EXT_H) + set(MPI_HEADERS ${MPI_HEADERS};mpi-ext.h) +endif() + +set(CMAKE_REQUIRED_INCLUDES ${old_cmake_required_includes}) +set(CMAKE_REQUIRED_FLAGS ${old_cmake_required_flags}) +set(CMAKE_REQUIRED_LIBRARIES ${old_cmake_required_libraries}) + +#--------------------------------------------------- +# Windows Intel MPI compatibility, see GH issue #435 +#--------------------------------------------------- +set(old_cmake_required_includes "${CMAKE_REQUIRED_INCLUDES}") +if(CMAKE_REQUIRED_INCLUDES) + set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES};${MPI_C_INCLUDE_PATH}) +else() + set(CMAKE_REQUIRED_INCLUDES ${MPI_C_INCLUDE_PATH}) +endif() +CHECK_INCLUDE_FILES("mpi.h" HAVE_MPI_H) + +include(CheckSymbolExists) +CHECK_SYMBOL_EXISTS(I_MPI_VERSION "mpi.h" HAVE_Intel_MPI) +if(HAVE_Intel_MPI AND WIN32) + add_definitions(-DUSE_GCC) +endif() +set(CMAKE_REQUIRED_INCLUDES ${old_cmake_required_includes}) + +set(PSBLAS_SO_VERSION 0) +if(gfortran_compiler) + if(NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 7.0.0) + set(PSBLAS_SO_VERSION 2) + elseif(NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 6.0.0) + set(PSBLAS_SO_VERSION 1) + endif() +endif() + +set(PSBLAS_MODDIR "${CMAKE_INSTALL_INCLUDEDIR}/${mod_dir_tail}") +set(MOD_DIR_FLAG "${CMAKE_Fortran_MODDIR_FLAG}") +set(MPI_LIBS "") +foreach( lib IN LISTS MPI_Fortran_LIBRARIES) + set(MPI_LIBS "${MPI_LIBS} \"${lib}\"") +endforeach() +string(STRIP "${MPI_LIBS}" MPI_LIBS) + +set(directory_list fileread hello kernel pargen torture util) +if (SERIAL_MPI) + set(directory_list ${directory_list} serial) +endif() +foreach(directory ${directory_list}) + add_subdirectory("${directory}") +endforeach() diff --git a/test/fileread/CMakeLists.txt b/test/fileread/CMakeLists.txt new file mode 100644 index 000000000..4362687d0 --- /dev/null +++ b/test/fileread/CMakeLists.txt @@ -0,0 +1,11 @@ +include_directories("${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_INCLUDEDIR}/${mod_dir_tail}") + +add_executable(psb_cf_sample psb_cf_sample.f90 getp.f90) +add_executable(psb_df_sample psb_df_sample.f90 getp.f90) +add_executable(psb_sf_sample psb_sf_sample.f90 getp.f90) +add_executable(psb_zf_sample psb_zf_sample.f90 getp.f90) + +target_link_libraries(psb_cf_sample krylov util base) +target_link_libraries(psb_df_sample krylov util base) +target_link_libraries(psb_sf_sample krylov util base) +target_link_libraries(psb_zf_sample krylov util base) diff --git a/test/hello/CMakeLists.txt b/test/hello/CMakeLists.txt new file mode 100644 index 000000000..e3884fad3 --- /dev/null +++ b/test/hello/CMakeLists.txt @@ -0,0 +1,7 @@ +include_directories("${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_INCLUDEDIR}/${mod_dir_tail}") + +add_executable(hello hello.f90) +add_executable(pingpong pingpong.f90) + +target_link_libraries(hello base) +target_link_libraries(pingpong base) diff --git a/test/kernel/CMakeLists.txt b/test/kernel/CMakeLists.txt new file mode 100644 index 000000000..f80eff8b7 --- /dev/null +++ b/test/kernel/CMakeLists.txt @@ -0,0 +1,9 @@ +include_directories("${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_INCLUDEDIR}/${mod_dir_tail}") + +add_executable(d_file_spmv d_file_spmv.f90) +add_executable(pdgenspmv pdgenspmv.f90) +add_executable(s_file_spmv s_file_spmv.f90) + +target_link_libraries(d_file_spmv util) +target_link_libraries(pdgenspmv util) +target_link_libraries(s_file_spmv util) diff --git a/test/pargen/CMakeLists.txt b/test/pargen/CMakeLists.txt new file mode 100644 index 000000000..443c1f6ef --- /dev/null +++ b/test/pargen/CMakeLists.txt @@ -0,0 +1,11 @@ +include_directories("${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_INCLUDEDIR}/${mod_dir_tail}") + +add_executable(psb_d_pde2d psb_d_pde2d.f90) +add_executable(psb_d_pde3d psb_d_pde3d.f90) +add_executable(psb_s_pde2d psb_s_pde2d.f90) +add_executable(psb_s_pde3d psb_s_pde3d.f90) + +target_link_libraries(psb_d_pde2d krylov util) +target_link_libraries(psb_d_pde3d krylov util) +target_link_libraries(psb_s_pde2d krylov util) +target_link_libraries(psb_s_pde3d krylov util) diff --git a/test/serial/CMakeLists.txt b/test/serial/CMakeLists.txt new file mode 100644 index 000000000..3556f8b39 --- /dev/null +++ b/test/serial/CMakeLists.txt @@ -0,0 +1,8 @@ +include_directories("${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_INCLUDEDIR}/${mod_dir_tail}") + +add_executable( d_matgen + psb_d_xyz_impl.f90 + psb_d_xyz_mat_mod.f90 + d_matgen.F90 # Main program +) +target_link_libraries(d_matgen base) diff --git a/test/torture/CMakeLists.txt b/test/torture/CMakeLists.txt new file mode 100644 index 000000000..7c5c27517 --- /dev/null +++ b/test/torture/CMakeLists.txt @@ -0,0 +1,11 @@ +include_directories("${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_INCLUDEDIR}/${mod_dir_tail}") + +add_executable(fortran_interface_test + psb_c_mvsv_tester.f90 + psb_d_mvsv_tester.f90 + psb_mvsv_tester.f90 + psb_s_mvsv_tester.f90 + psbtf.f90 # Main program + psb_z_mvsv_tester.f90 +) +target_link_libraries(fortran_interface_test base) diff --git a/test/util/CMakeLists.txt b/test/util/CMakeLists.txt new file mode 100644 index 000000000..a38e54c2a --- /dev/null +++ b/test/util/CMakeLists.txt @@ -0,0 +1,11 @@ +include_directories("${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_INCLUDEDIR}/${mod_dir_tail}") + +add_executable(dhb2mm dhb2mm.f90) +add_executable(dmm2hb dmm2hb.f90) +add_executable(zhb2mm zhb2mm.f90) +add_executable(zmm2hb zmm2hb.f90) + +target_link_libraries(dhb2mm util) +target_link_libraries(dmm2hb util) +target_link_libraries(zhb2mm util) +target_link_libraries(zmm2hb util)