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

initial OpenMP smoketest #116

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
6 changes: 6 additions & 0 deletions src/c/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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)
Expand Down
38 changes: 38 additions & 0 deletions src/c/test/smoketest_omp.cpp
Original file line number Diff line number Diff line change
@@ -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 <omp.h>
#include <stdio.h>
#include <stdlib.h>

#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);
}
}