diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index e421575..fe76292 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -22,7 +22,7 @@ jobs: uses: actions/checkout@v2.2.0 with: repository: kokkos/kokkos - ref: 3.1.00 + ref: 3.2.01 path: kokkos - name: Build kokkos working-directory: kokkos diff --git a/CMakeLists.txt b/CMakeLists.txt index f4488f0..e93aa8f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ # project settings cmake_minimum_required(VERSION 3.12) -project(AFE LANGUAGES CXX) +project(CFE LANGUAGES CXX) include(GNUInstallDirs) @@ -10,6 +10,24 @@ set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) #...without compiler extensions like gnu++11 +# Download and unpack googletest at configure time +include(FetchContent) +FetchContent_Declare( + googletest + URL https://github.com/google/googletest/archive/release-1.10.0.tar.gz +) +FetchContent_GetProperties(googletest) +if(NOT googletest_POPULATED) + FetchContent_Populate(googletest) + add_subdirectory(${googletest_SOURCE_DIR} ${googletest_BINARY_DIR}) +endif() + +# Prevent GoogleTest from overriding our compiler/linker options +# when building with Visual Studio +set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) + +enable_testing() + # find dependencies find_package(Cabana REQUIRED) diff --git a/advanced_examples/01_parallel_for/CMakeLists.txt b/advanced_examples/01_parallel_for/CMakeLists.txt index a81814e..c293e95 100644 --- a/advanced_examples/01_parallel_for/CMakeLists.txt +++ b/advanced_examples/01_parallel_for/CMakeLists.txt @@ -1,4 +1,4 @@ -if( Cabana_ENABLE_Cuda ) +if( Kokkos_ENABLE_CUDA ) if("${CMAKE_Fortran_COMPILER_ID}" STREQUAL "PGI") add_definitions(-DSIMD_SIZE=1 -DVEC_LEN=32 -DUSE_GPU=1) set(MPI_Fortran_COMPILE_FLAGS "-r -ta=tesla:cuda9.0 -Minfo=accel -Mcuda=cuda9.0") @@ -24,5 +24,5 @@ set_target_properties(AdvForParallelFor PROPERTIES COMPILE_FLAGS "${MPI_Fortran_ set_target_properties(AdvForParallelFor PROPERTIES LINK_FLAGS "${MPI_Fortran_LINK_FLAGS}") target_link_libraries(AdvForParallelFor Cabana::cabanacore ${MPI_Fortran_LIBRARIES} kokkos_fortran_wrappers) -add_test(NAME Fortran_advanced_example_01 COMMAND AdvForParallelFor) +add_test(NAME Fortran_AdvEx_01_ParFor COMMAND AdvForParallelFor) set_property(TARGET AdvForParallelFor PROPERTY LINKER_LANGUAGE Fortran) diff --git a/advanced_examples/02_push/CMakeLists.txt b/advanced_examples/02_push/CMakeLists.txt index 7252321..03a3c66 100644 --- a/advanced_examples/02_push/CMakeLists.txt +++ b/advanced_examples/02_push/CMakeLists.txt @@ -1,4 +1,4 @@ -if( Cabana_ENABLE_Cuda ) +if( Kokkos_ENABLE_CUDA ) if("${CMAKE_Fortran_COMPILER_ID}" STREQUAL "PGI") add_definitions(-DSIMD_SIZE=1 -DVEC_LEN=32 -DUSE_GPU=1) set(MPI_Fortran_COMPILE_FLAGS "-r -ta=tesla:cuda9.0 -Minfo=accel -Mcuda=cuda9.0") @@ -25,5 +25,5 @@ set_target_properties(AdvForPush PROPERTIES COMPILE_FLAGS "${MPI_Fortran_COMPILE set_target_properties(AdvForPush PROPERTIES LINK_FLAGS "${MPI_Fortran_LINK_FLAGS}") target_link_libraries(AdvForPush Cabana::cabanacore ${MPI_Fortran_LIBRARIES} kokkos_fortran_wrappers) -add_test(NAME Fortran_advanced_example_02 COMMAND AdvForPush) +add_test(NAME Fortran_AdvEx_02_Push COMMAND AdvForPush) set_property(TARGET AdvForPush PROPERTY LINKER_LANGUAGE Fortran) diff --git a/advanced_examples/03_scatter/CMakeLists.txt b/advanced_examples/03_scatter/CMakeLists.txt index ab6fb86..00f6f2b 100644 --- a/advanced_examples/03_scatter/CMakeLists.txt +++ b/advanced_examples/03_scatter/CMakeLists.txt @@ -1,4 +1,4 @@ -if( Cabana_ENABLE_Cuda ) +if( Kokkos_ENABLE_CUDA ) if("${CMAKE_Fortran_COMPILER_ID}" STREQUAL "PGI") add_definitions(-DSIMD_SIZE=1 -DVEC_LEN=32 -DUSE_GPU=1) set(MPI_Fortran_COMPILE_FLAGS "-r -ta=tesla:cuda9.0 -Minfo=accel -Mcuda=cuda9.0") @@ -25,5 +25,5 @@ set_target_properties(AdvForScatter PROPERTIES COMPILE_FLAGS "${MPI_Fortran_COMP set_target_properties(AdvForScatter PROPERTIES LINK_FLAGS "${MPI_Fortran_LINK_FLAGS}") target_link_libraries(AdvForScatter Cabana::cabanacore ${MPI_Fortran_LIBRARIES} kokkos_fortran_wrappers) -add_test(NAME Fortran_advanced_example_03 COMMAND AdvForScatter) +add_test(NAME Fortran_AdvEx_03_Scatter COMMAND AdvForScatter) set_property(TARGET AdvForScatter PROPERTY LINKER_LANGUAGE Fortran) diff --git a/advanced_examples/04_unmanaged_aosoa/CMakeLists.txt b/advanced_examples/04_unmanaged_aosoa/CMakeLists.txt index e1d3e55..6e7f52f 100644 --- a/advanced_examples/04_unmanaged_aosoa/CMakeLists.txt +++ b/advanced_examples/04_unmanaged_aosoa/CMakeLists.txt @@ -1,36 +1,37 @@ add_executable(ForParallelForUnmanaged Fortran_main.F90 Fortran_kernels.F90 parallel_for_example.cpp) -target_link_libraries(ForParallelForUnmanaged Cabana::cabanacore ${MPI_Fortran_LIBRARIES}) -add_test(NAME Fortran_advance_example_04 COMMAND ForParallelForUnmanaged) -set_property(TARGET ForParallelForUnmanaged PROPERTY LINKER_LANGUAGE Fortran) -add_definitions(${MPI_Fortran_COMPILE_FLAGS}) -include_directories(${MPI_Fortran_INCLUDE_PATH} ${CMAKE_CURRENT_BINARY_DIR}/../Fortran_features) -link_directories(${MPI_Fortran_LIBRARIES}) message(${CMAKE_Fortran_COMPILER_ID}) if (("${CMAKE_Fortran_COMPILER_ID}" STREQUAL "PGI") AND ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "PGI")) - if( Cabana_ENABLE_Cuda ) + if( Kokkos_ENABLE_CUDA ) target_compile_definitions(ForParallelForUnmanaged PUBLIC -DUSE_GPU=1) set(CMAKE_Fortran_FLAGS "-ta=tesla:cuda9.0 -Minfo=accel -Mcuda=cuda9.0") set(CMAKE_CXX_FLAGS "--relocatable-device-code=true") - elseif( Cabana_ENABLE_OpenMP ) + elseif( Kokkos_ENABLE_OPENMP ) target_compile_definitions(ForParallelForUnmanaged PUBLIC -DUSE_GPU=0) set(CMAKE_Fortran_FLAGS "-ta=multicore -mp") - elseif( Cabana_ENABLE_Serial ) + elseif( Kokkos_ENABLE_SERIAL ) target_compile_definitions(ForParallelForUnmanaged PUBLIC -DUSE_GPU=0) set(CMAKE_Fortran_FLAGS "-ta=host") endif() - + set(CMAKE_EXE_LINKER_FLAGS "-pgc++libs") else() - if( Cabana_ENABLE_Cuda ) + if( Kokkos_ENABLE_CUDA ) message("Only PGI is supported for compiling fortran cuda code. Right now we only accept building with PGI for both CXX and Fortran to avoid mixing compiler families.\n Skip.") return() - elseif( Cabana_ENABLE_OpenMP ) + elseif( Kokkos_ENABLE_OPENMP ) target_compile_definitions(ForParallelForUnmanaged PUBLIC -DUSE_GPU=0) set(CMAKE_Fortran_FLAGS "-fopenmp") - elseif( Cabana_ENABLE_Serial ) + elseif( Kokkos_ENABLE_SERIAL ) target_compile_definitions(ForParallelForUnmanaged PUBLIC -DUSE_GPU=0) endif() endif() + +target_link_libraries(ForParallelForUnmanaged Cabana::cabanacore ${MPI_Fortran_LIBRARIES}) +add_test(NAME Fortran_AdvEx_04_Unmanaged COMMAND ForParallelForUnmanaged) +set_property(TARGET ForParallelForUnmanaged PROPERTY LINKER_LANGUAGE Fortran) +add_definitions(${MPI_Fortran_COMPILE_FLAGS}) +include_directories(${MPI_Fortran_INCLUDE_PATH} ${CMAKE_CURRENT_BINARY_DIR}/../Fortran_features) +link_directories(${MPI_Fortran_LIBRARIES}) diff --git a/tutorial/01_hello_world/CMakeLists.txt b/tutorial/01_hello_world/CMakeLists.txt index 81f8a04..0ae30e1 100644 --- a/tutorial/01_hello_world/CMakeLists.txt +++ b/tutorial/01_hello_world/CMakeLists.txt @@ -1,3 +1,3 @@ add_executable(ForHelloWorld main.cpp hello_world.f90) target_link_libraries(ForHelloWorld Cabana::cabanacore) -add_test(NAME Fortran_tutorial_01 COMMAND ForHelloWorld) +add_test(NAME Fortran_Tutorial_01_HelloWorld COMMAND ForHelloWorld) diff --git a/tutorial/02_tuple/CMakeLists.txt b/tutorial/02_tuple/CMakeLists.txt index 2f5c6dc..a8c153d 100644 --- a/tutorial/02_tuple/CMakeLists.txt +++ b/tutorial/02_tuple/CMakeLists.txt @@ -1,3 +1,3 @@ - add_executable(ForTuple main.cpp tuple_example.f90) - target_link_libraries(ForTuple Cabana::cabanacore) - add_test(NAME Fortran_tutorial_02 COMMAND ForTuple) +add_executable(ForTuple main.cpp tuple_example.f90) +target_link_libraries(ForTuple Cabana::cabanacore) +add_test(NAME Fortran_Tutorial_02_Tuple COMMAND ForTuple) diff --git a/tutorial/03_struct_of_arrays/CMakeLists.txt b/tutorial/03_struct_of_arrays/CMakeLists.txt index 5f8e7ab..a9c4734 100644 --- a/tutorial/03_struct_of_arrays/CMakeLists.txt +++ b/tutorial/03_struct_of_arrays/CMakeLists.txt @@ -1,3 +1,3 @@ - add_executable(ForStructOfArrays main.cpp soa_example.F90) - target_link_libraries(ForStructOfArrays Cabana::cabanacore) - add_test(NAME Fortran_tutorial_03 COMMAND ForStructOfArrays) +add_executable(ForStructOfArrays main.cpp soa_example.F90) +target_link_libraries(ForStructOfArrays Cabana::cabanacore) +add_test(NAME Fortran_Tutorial_03_SoA COMMAND ForStructOfArrays) diff --git a/tutorial/04_aosoa/CMakeLists.txt b/tutorial/04_aosoa/CMakeLists.txt index 9b580c7..fe65e72 100644 --- a/tutorial/04_aosoa/CMakeLists.txt +++ b/tutorial/04_aosoa/CMakeLists.txt @@ -1,3 +1,3 @@ - add_executable(ForArrayOfStructsOfArrays main.cpp aosoa_example.F90) - target_link_libraries(ForArrayOfStructsOfArrays Cabana::cabanacore) - add_test(NAME Fortran_tutorial_04 COMMAND ForArrayOfStructsOfArrays) +add_executable(ForArrayOfStructsOfArrays main.cpp aosoa_example.F90) +target_link_libraries(ForArrayOfStructsOfArrays Cabana::cabanacore) +add_test(NAME Fortran_Tutorial_04_AoSoA COMMAND ForArrayOfStructsOfArrays) diff --git a/tutorial/05_parallel_for/CMakeLists.txt b/tutorial/05_parallel_for/CMakeLists.txt index 40d402c..72c0c1f 100644 --- a/tutorial/05_parallel_for/CMakeLists.txt +++ b/tutorial/05_parallel_for/CMakeLists.txt @@ -1,6 +1,6 @@ add_executable(ForParallelFor Fortran_main.f90 Fortran_kernels.F90 parallel_for_example.cpp) target_link_libraries(ForParallelFor Cabana::cabanacore) -add_test(NAME Fortran_tutorial_05 COMMAND ForParallelFor) +add_test(NAME Fortran_Tutorial_05_ParFor COMMAND ForParallelFor) set_property(TARGET ForParallelFor PROPERTY LINKER_LANGUAGE CXX) if (("${CMAKE_Fortran_COMPILER_ID}" STREQUAL "PGI") AND ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "PGI")) @@ -22,8 +22,10 @@ if (("${CMAKE_Fortran_COMPILER_ID}" STREQUAL "PGI") AND ("${CMAKE_CXX_COMPILER_I target_link_options(ForParallelFor "-pgc++libs") endif() else() + if( Kokkos_ENABLE_CUDA ) message("Only PGI is supported for compiling fortran cuda code. Right now we only accept building with PGI for both CXX and Fortran to avoid mixing compiler families.\n Skip.") return() + endif() endif() diff --git a/tutorial/06_kokkos_parallel_for/CMakeLists.txt b/tutorial/06_kokkos_parallel_for/CMakeLists.txt index 17d5787..6942912 100644 --- a/tutorial/06_kokkos_parallel_for/CMakeLists.txt +++ b/tutorial/06_kokkos_parallel_for/CMakeLists.txt @@ -1,6 +1,6 @@ add_executable(ForKKParallelFor Fortran_main.f90 Fortran_kernel.F90 hello_world.cpp) target_link_libraries(ForKKParallelFor Cabana::cabanacore) -add_test(NAME Fortran_tutorial_06 COMMAND ForKKParallelFor) +add_test(NAME Fortran_Tutorial_06_KParFor COMMAND ForKKParallelFor) set_property(TARGET ForKKParallelFor PROPERTY LINKER_LANGUAGE CXX) if(CMAKE_Fortran_COMPILER_ID STREQUAL "PGI") @@ -23,6 +23,8 @@ if(CMAKE_Fortran_COMPILER_ID STREQUAL "PGI") endif() else() - message("Only PGI is supported for compiling fortran cuda code.\n Skip.") - return() + if( Kokkos_ENABLE_CUDA ) + message("Only PGI is supported for compiling fortran cuda code.\n Skip.") + return() + endif() endif()