Skip to content

Commit

Permalink
Add simple test to verify OpenMP offload
Browse files Browse the repository at this point in the history
Verify simple OpenMP loop running on device,
to check OpenMP offload working
  • Loading branch information
jeanlucf22 authored and nicolasbock committed May 27, 2022
1 parent c6bfe81 commit 6bd7275
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
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;
}

0 comments on commit 6bd7275

Please sign in to comment.