Skip to content

Commit

Permalink
CMakeLists.txt: support sampler test
Browse files Browse the repository at this point in the history
  • Loading branch information
vlkale authored Apr 1, 2024
1 parent 99d589d commit d13efe8
Showing 1 changed file with 42 additions and 6 deletions.
48 changes: 42 additions & 6 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@
# Arguments:
# TARGET_NAME : name of the test (required)
# SOURCE_FILE : source file, defaults to <TARGET_NAME>.cpp (optional)
# KOKKOS_TOOLS_LIBS : the test environment will received the variable 'KOKKOS_TOOLS_LIBS' that is set as the path
# KOKKOS_TOOLS_LIBS : the test environment will receive the variable 'KOKKOS_TOOLS_LIBS' that is set as the path
# to the target file of this argument (optional)
function(kp_add_executable_and_test)
# KOKKOS_TOOLS_SAMPLER_VERBOSE : the test environment will receive the variable 'KOKKOS_TOOLS_SAMPLER_VERBOSE' that is set as the value of 1 for printing the sample has been taken
# KOKKOS_TOOLS_GLOBALFENCES : test environment receives the variable 'KOKKOS_TOOLS_GLOBALFENCES' that is set as the value of 1 to turn the tool's auto-fencing on.
# KOKKOS_TOOLS_SAMPLER_SKIP : test environment receives the variable 'KOKKOS_TOOLS_SAMPLER_SKIP' that is set as the value of the number of Kokkos kernel invocations to skip before a tooling activity is invoked.

cmake_parse_arguments(kaeat_args "" "TARGET_NAME;SOURCE_FILE;KOKKOS_TOOLS_LIBS" "" ${ARGN})
function(kp_add_executable_and_test)
cmake_parse_arguments(kaeat_args "" "TARGET_NAME;SOURCE_FILE;KOKKOS_TOOLS_SAMPLER_VERBOSE;KOKKOS_TOOLS_GLOBALFENCES;KOKKOS_TOOLS_SAMPLER_SKIP" "KOKKOS_TOOLS_LIBS" ${ARGN})

if(NOT DEFINED kaeat_args_TARGET_NAME)
message(FATAL_ERROR "'TARGET_NAME' is a required argument.")
Expand Down Expand Up @@ -38,13 +41,45 @@ function(kp_add_executable_and_test)
)

if(DEFINED kaeat_args_KOKKOS_TOOLS_LIBS)
set(TOOL_LIBS_FILES)
foreach(TOOL_LIB ${kaeat_args_KOKKOS_TOOLS_LIBS})
list(APPEND TOOL_LIBS_FILES "$<TARGET_FILE:${TOOL_LIB}>")
endforeach()
string(REPLACE ";" "\;" TOOL_LIBS_FILES "${TOOL_LIBS_FILES}")

set_property(
TEST ${kaeat_args_TARGET_NAME}
APPEND
PROPERTY
ENVIRONMENT "KOKKOS_TOOLS_LIBS=$<TARGET_FILE:${kaeat_args_KOKKOS_TOOLS_LIBS}>"
APPEND PROPERTY ENVIRONMENT "KOKKOS_TOOLS_LIBS=${TOOL_LIBS_FILES}"
)
endif()

if(DEFINED kaeat_args_KOKKOS_TOOLS_SAMPLER_VERBOSE)
set_property(
TEST ${kaeat_args_TARGET_NAME}
APPEND
PROPERTY
ENVIRONMENT "KOKKOS_TOOLS_SAMPLER_VERBOSE=${kaeat_args_KOKKOS_TOOLS_SAMPLER_VERBOSE}"
)
endif()

if(DEFINED kaeat_args_KOKKOS_TOOLS_GLOBALFENCES)
set_property(
TEST ${kaeat_args_TARGET_NAME}
APPEND
PROPERTY
ENVIRONMENT "KOKKOS_TOOLS_GLOBALFENCES=${kaeat_args_KOKKOS_TOOLS_GLOBALFENCES}"
)
endif()

if (DEFINED kaeat_args_KOKKOS_TOOLS_SAMPLER_SKIP)
set_property(
TEST ${kaeat_args_TARGET_NAME}
APPEND
PROPERTY
ENVIRONMENT "KOKKOS_TOOLS_SAMPLER_SKIP=${kaeat_args_KOKKOS_TOOLS_SAMPLER_SKIP}"
)

endif()

endfunction(kp_add_executable_and_test)

Expand All @@ -59,3 +94,4 @@ target_sources(
target_link_libraries(test_common PUBLIC GTest::gtest GTest::gmock Kokkos::kokkos)

add_subdirectory(space-time-stack)
add_subdirectory(sampler)

0 comments on commit d13efe8

Please sign in to comment.