Skip to content

Commit

Permalink
cmake gpu support
Browse files Browse the repository at this point in the history
  • Loading branch information
Amazingkivas committed Nov 5, 2024
1 parent df20cb1 commit fdaed42
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
10 changes: 7 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 2.8)
cmake_minimum_required(VERSION 3.0)

project(FDTD)

Expand All @@ -15,6 +15,11 @@ include_directories(3rdparty)
UNSET(Kokkos_DIR CACHE)
set(Kokkos_DIR 3rdparty/kokkos/build/)

set(Kokkos_NVCC_WRAPPER "${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/kokkos/bin/nvcc_wrapper")
set(Kokkos_COMPILE_LAUNCHER "${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/kokkos/bin/kokkos_launch_compiler")
set(Kokkos_HOST_COMPILER "g++")


if(NOT DEFINED Kokkos_ENABLE_CONTAINERS)
set(Kokkos_ENABLE_CONTAINERS ON)
endif()
Expand Down Expand Up @@ -57,9 +62,8 @@ add_custom_command(

add_custom_target(create_kokkoscore ALL DEPENDS ${KOKKOS_CORE_LIB})


find_package(Kokkos REQUIRED)

add_subdirectory(project)
add_subdirectory(test)
add_subdirectory(samples)
add_subdirectory(samples)
4 changes: 2 additions & 2 deletions src/FDTD_kokkos/FDTD_kokkos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ void FDTD::update_fields(bool write_result, Axis write_axis, std::string base_pa
Kokkos::deep_copy(By_host, By);
Kokkos::deep_copy(Bz_host, Bz);

std::vector<Field> return_data{ Ex_host, Ey_host, Ez_host, Bx_host, By_host, Bz_host };
std::vector<Field> return_data{ Ex, Ey, Ez, Bx, By, Bz };
if (write_result)
write_spherical(return_data, write_axis, base_path, t);
}
Expand Down Expand Up @@ -301,7 +301,7 @@ void FDTD::update_fields(bool write_result, Axis write_axis, std::string base_pa
Kokkos::deep_copy(By_host, By);
Kokkos::deep_copy(Bz_host, Bz);

std::vector<Field> return_data{ Ex_host, Ey_host, Ez_host, Bx_host, By_host, Bz_host };
std::vector<Field> return_data{ Ex, Ey, Ez, Bx, By, Bz };
if (write_result)
write_spherical(return_data, write_axis, base_path, t);
}
Expand Down
4 changes: 2 additions & 2 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ add_subdirectory(../3rdparty/googletest ../3rdparty/googletest/build EXCLUDE_FRO
add_executable(${target} ${srcs} ${hdrs})
add_dependencies(${target} gtest)
target_link_directories(${target} PUBLIC ${CMAKE_BINARY_DIR}/googletest/lib)
target_link_libraries(${target} PUBLIC gtest gtest_main)
target_link_libraries(${target} PRIVATE gtest gtest_main)

target_link_libraries(${target} Kokkos::kokkos)
target_link_libraries(${target} PRIVATE Kokkos::kokkos)

add_compile_options(/wd4996)

0 comments on commit fdaed42

Please sign in to comment.