Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add simple test to verify OpenMP offload #607

Merged
merged 1 commit into from
May 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions tests/C-tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
include_directories(${PROJECT_SOURCE_DIR}/src/C-interface)

if(BML_OMP_OFFLOAD)
add_executable(test-openmp_offload test_openmp_offload.c)
target_link_libraries(test-openmp_offload bml ${LINK_LIBRARIES})
set_target_properties(test-openmp_offload
PROPERTIES
COMPILE_FLAGS ${OpenMP_C_FLAGS}
LINK_FLAGS ${OpenMP_C_FLAGS})
add_test(openmp_offload ${BML_NONMPI_PRECOMMAND} ${BML_NONMPI_PRECOMMAND_ARGS}
${CMAKE_CURRENT_BINARY_DIR}/test-openmp_offload)
endif()

set(SOURCES_TYPED
add_matrix_typed.c
adjacency_matrix_typed.c
Expand Down
17 changes: 17 additions & 0 deletions tests/C-tests/test_openmp_offload.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <omp.h>

int
main(
int argc,
char **argv)
{
int is_device = 1;

#pragma omp target map(from : is_device)
{
is_device = omp_is_initial_device();
}

// returns 0 if executed on device, 1 otherwise
return is_device;
}