diff --git a/src/c/test/CMakeLists.txt b/src/c/test/CMakeLists.txt index 26f7fa05..5b3bc914 100644 --- a/src/c/test/CMakeLists.txt +++ b/src/c/test/CMakeLists.txt @@ -10,6 +10,7 @@ set(SMOKETESTS find_package(MPI REQUIRED) find_package(Threads REQUIRED) find_package(CUDA REQUIRED) +find_package(OpenMP REQUIRED) include_directories(${MPI_INCLUDE_PATH}) set(perfflow_deps "-L../runtime -lperfflow_runtime -lcrypto") @@ -25,6 +26,11 @@ foreach(TEST ${SMOKETESTS}) target_link_libraries(${TEST} ${perfflow_deps}) endforeach() +message(STATUS " [*] Adding test: smoketest_omp") +add_executable(smoketest_omp smoketest_omp.cpp) +set_source_files_properties(smoketest_omp.cpp COMPILE_FLAGS "-Xclang -load -Xclang ../weaver/weave/libWeavePass.so -fPIC") +target_link_libraries(smoketest_omp ${perfflow_deps} ${OpenMP_CXX_FLAGS}) + message(STATUS " [*] Adding test: smoketest_cuda") set(CUDA_NVCC_FLAGS "-ccbin ${CMAKE_CXX_COMPILER} -Xcompiler=-Xclang -Xcompiler=-load -Xcompiler=-Xclang -Xcompiler=../../../weaver/weave/libWeavePass.so") cuda_add_executable(smoketest_cuda smoketest_cuda_wrapper.cpp smoketest_cuda_kernel.cu) diff --git a/src/c/test/smoketest_omp.cpp b/src/c/test/smoketest_omp.cpp new file mode 100644 index 00000000..1b767dac --- /dev/null +++ b/src/c/test/smoketest_omp.cpp @@ -0,0 +1,38 @@ +/************************************************************\ + * Copyright 2021 Lawrence Livermore National Security, LLC + * (c.f. AUTHORS, NOTICE.LLNS, COPYING) + * + * This file is part of the Flux resource manager framework. + * For details, see https://github.com/flux-framework. + * + * SPDX-License-Identifier: LGPL-3.0 +\************************************************************/ + +#include +#include +#include + +#define N 3 + +__attribute__((annotate("@critical_path(pointcut='around')"))) +void foo(int threadid) +{ + long tid; + tid = (long)threadid; + printf("This is worker_thread() %ld \n", tid); +} + +int main() +{ + long id; + #pragma omp + { + printf("Nthreads %d\n", omp_get_num_threads()); + } + #pragma omp parallel for + for (id = 0; id <= N; id++) + { + int thread_id = omp_get_thread_num(); + foo(thread_id); + } +}