Skip to content

Commit

Permalink
[OpenMP] [OMPD] Testcases for libompd
Browse files Browse the repository at this point in the history
This is part of the OMPD Path set started from review.
https://reviews.llvm.org/D100181

Reviewed By: @jdoerfert, @dreachem
  • Loading branch information
vigbalu committed Nov 11, 2022
1 parent bc6666a commit 1099498
Show file tree
Hide file tree
Showing 94 changed files with 1,704 additions and 0 deletions.
1 change: 1 addition & 0 deletions openmp/libompd/CMakeLists.txt
Expand Up @@ -16,5 +16,6 @@ if(LIBOMP_OMPD_SUPPORT)
add_subdirectory(src)
if(LIBOMP_OMPD_GDB_SUPPORT)
add_subdirectory(gdb-plugin)
add_subdirectory(test)
endif()
endif()
41 changes: 41 additions & 0 deletions openmp/libompd/test/CMakeLists.txt
@@ -0,0 +1,41 @@
if(LIBOMP_OMPD_SUPPORT)

if(NOT OPENMP_TEST_COMPILER_ID STREQUAL "Clang")
message(STATUS "LIBOMPD: Can only test with Clang compiler")
message(WARNING "LIBOMPD: The check-libompd target will not be available!")
return()
endif()

find_package(LLVM REQUIRED CONFIG)
list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_DIR}")
include(AddLLVM)
find_program(LLVM_LIT_PATH
NAMES llvm-lit lit
HINTS ${LLVM_TOOLS_BINARY_DIR}
PATHS ${LLVM_ROOT_DIR}/bin /usr/bin /usr/local/bin /opt/local/bin
DOC "llvm-lit executable. (Workaround for AddLLVM.cmake path not being set)"
)
if(LLVM_LIT_PATH)
set(LLVM_EXTERNAL_LIT ${LLVM_LIT_PATH})
endif()

find_program(FILECHECK_EXECUTABLE
NAMES Filecheck FileCheck
HINTS ${LLVM_TOOLS_BINARY_DIR}
PATHS ${LLVM_ROOT_DIR}/bin /usr/bin /usr/local/bin /opt/local/bin
DOC "Filecheck executable. (Workaround for AddLLVM.cmake path not being set)"
)
if(LLVM_FILECHECK_PATH)
set(LLVM_EXTERNAL_FILECHECK ${LLVM_FILECHECK_PATH})
endif()

set(PYTHON_PLUGIN ${ompd_BINARY_DIR}/gdb-plugin/python-module)

# Configure the lit.site.cfg.in file
set(AUTO_GEN_COMMENT "## Autogenerated by libomp configuration.\n# Do not edit!")
configure_file(lit.site.cfg.in lit.site.cfg @ONLY)
add_openmp_testsuite(check-ompd "Running OMPD tests"
${CMAKE_CURRENT_BINARY_DIR}
DEPENDS omp ompd ompd_gdb_plugin)

endif()
13 changes: 13 additions & 0 deletions openmp/libompd/test/api_tests/test_ompd_device_initialize.c
@@ -0,0 +1,13 @@
// RUN: %gdb-compile 2>&1 | tee %t.compile
// RUN: %gdb-test -x %s.cmd %t 2>&1 | tee %t.out | FileCheck %s
#include <omp.h>
#include <stdio.h>

int main() {
omp_set_num_threads(4);
#pragma omp parallel
{ printf("Parallel level 1, thread num = %d.\n", omp_get_thread_num()); }
return 0;
}
// CHECK-NOT: Failed
// CHECK-NOT: Skip
@@ -0,0 +1,3 @@
ompd init
b test_ompd_device_initialize.c:9
ompdtestapi ompd_device_initialize
16 changes: 16 additions & 0 deletions openmp/libompd/test/api_tests/test_ompd_enumerate_icvs.c
@@ -0,0 +1,16 @@
// RUN: %gdb-compile 2>&1 | tee %t.compile
// RUN: %gdb-test -x %s.cmd %t 2>&1 | tee %t.out | FileCheck %s

#include <omp.h>
#include <stdio.h>

int main() {

omp_set_num_threads(2);
#pragma omp parallel
{ printf("Parallel level 1, thread num = %d.\n", omp_get_thread_num()); }
return 0;
}

// CHECK-NOT: Failed
// CHECK-NOT: Skip
4 changes: 4 additions & 0 deletions openmp/libompd/test/api_tests/test_ompd_enumerate_icvs.c.cmd
@@ -0,0 +1,4 @@
ompd init
b test_ompd_enumerate_icvs.c:11
c
ompdtestapi ompd_enumerate_icvs
16 changes: 16 additions & 0 deletions openmp/libompd/test/api_tests/test_ompd_enumerate_states.c
@@ -0,0 +1,16 @@
// RUN: %gdb-compile 2>&1 | tee %t.compile
// RUN: %gdb-test -x %s.cmd %t 2>&1 | tee %t.out | FileCheck %s

#include <omp.h>
#include <stdio.h>

int main() {

omp_set_num_threads(2);
#pragma omp parallel
{ printf("Parallel level 1, thread num = %d.\n", omp_get_thread_num()); }
return 0;
}

// CHECK-NOT: Failed
// CHECK-NOT: Skip
@@ -0,0 +1,4 @@
ompd init
b test_ompd_enumerate_states.c:11
c
ompdtestapi ompd_enumerate_states
18 changes: 18 additions & 0 deletions openmp/libompd/test/api_tests/test_ompd_finalize.c
@@ -0,0 +1,18 @@
// RUN: %gdb-compile 2>&1 | tee %t.compile
// RUN: %gdb-test -x %s.cmd %t 2>&1 | tee %t.out | FileCheck %s
// RUN: %gdb-test -x %s.cmd2 %t 2>&1 | tee %t.out2 \
// RUN: | FileCheck --check-prefix CMD2 %s
#include <omp.h>
#include <stdio.h>

int main() {
omp_set_num_threads(4);
#pragma omp parallel
{ printf("Parallel level 1, thread num = %d.\n", omp_get_thread_num()); }
return 0;
}
// CHECK-NOT: Failed
// CHECK-NOT: Skip

// CMD2: Run 'ompd init' before running any of the ompd commands
// CMD2: Error in Initialization
4 changes: 4 additions & 0 deletions openmp/libompd/test/api_tests/test_ompd_finalize.c.cmd
@@ -0,0 +1,4 @@
ompd init
b test_ompd_finalize.c:11
c
ompdtestapi ompd_finalize
3 changes: 3 additions & 0 deletions openmp/libompd/test/api_tests/test_ompd_finalize.c.cmd2
@@ -0,0 +1,3 @@
b main
r
ompdtestapi ompd_finalize
14 changes: 14 additions & 0 deletions openmp/libompd/test/api_tests/test_ompd_get_api_version.c
@@ -0,0 +1,14 @@
// RUN: %gdb-compile 2>&1 | tee %t.compile
// RUN: %gdb-test -x %s.cmd %t 2>&1 | tee %t.out | FileCheck %s

#include <omp.h>
#include <stdio.h>

int main() {
omp_set_num_threads(4);
#pragma omp parallel
{ printf("Parallel level 1, thread num = %d.\n", omp_get_thread_num()); }
return 0;
}
// CHECK-NOT: Failed
// CHECK-NOT: Skip
4 changes: 4 additions & 0 deletions openmp/libompd/test/api_tests/test_ompd_get_api_version.c.cmd
@@ -0,0 +1,4 @@
ompd init
b test_ompd_get_api_version.c:10
c
ompdtestapi ompd_get_api_version
16 changes: 16 additions & 0 deletions openmp/libompd/test/api_tests/test_ompd_get_curr_parallel_handle.c
@@ -0,0 +1,16 @@
// RUN: %gdb-compile 2>&1 | tee %t.compile
// RUN: %gdb-test -x %s.cmd %t 2>&1 | tee %t.out \
// RUN: | FileCheck -check-prefix=CMD %s
// RUN: %gdb-test -x %s.cmd2 %t 2>&1 | tee %t.out2 | FileCheck %s
#include <omp.h>
#include <stdio.h>

int main() {
omp_set_num_threads(2);
#pragma omp parallel
{ printf("Parallel level 1, thread num = %d.\n", omp_get_thread_num()); }
return 0;
}
// CMD: Return code is stale_handle
// CHECK-NOT: Failed
// CHECK-NOT: Skip
@@ -0,0 +1,3 @@
ompd init
b test_ompd_get_curr_parallel_handle.c:11
ompdtestapi ompd_get_curr_parallel_handle
@@ -0,0 +1,4 @@
ompd init
b test_ompd_get_curr_parallel_handle.c:11
c
ompdtestapi ompd_get_curr_parallel_handle
30 changes: 30 additions & 0 deletions openmp/libompd/test/api_tests/test_ompd_get_curr_task_handle.c
@@ -0,0 +1,30 @@
// RUN: %gdb-compile 2>&1 | tee %t.compile
// RUN: %gdb-test -x %s.cmd %t 2>&1 | tee %t.out | FileCheck %s

#include <omp.h>
#include <stdio.h>
int get_fib_num(int num) {
int t1, t2;
if (num < 2)
return num;
else {
#pragma omp task shared(t1)
t1 = get_fib_num(num - 1);
#pragma omp task shared(t2)
t2 = get_fib_num(num - 2);
#pragma omp taskwait
return t1 + t2;
}
}

int main() {
int ret = 0;
omp_set_num_threads(2);
#pragma omp parallel
{ ret = get_fib_num(10); }
printf("Fib of 10 is %d", ret);
return 0;
}

// CHECK-NOT: Failed
// CHECK-NOT: Skip
@@ -0,0 +1,4 @@
ompd init
b test_ompd_get_curr_task_handle.c:14
c
ompdtestapi ompd_get_curr_task_handle
30 changes: 30 additions & 0 deletions openmp/libompd/test/api_tests/test_ompd_get_display_control_vars.c
@@ -0,0 +1,30 @@
// RUN: %gdb-compile 2>&1 | tee %t.compile
// RUN: %gdb-test -x %s.cmd %t 2>&1 | tee %t.out | FileCheck %s

#include <omp.h>
#include <stdio.h>
int get_fib_num(int num) {
int t1, t2;
if (num < 2)
return num;
else {
#pragma omp task shared(t1)
t1 = get_fib_num(num - 1);
#pragma omp task shared(t2)
t2 = get_fib_num(num - 2);
#pragma omp taskwait
return t1 + t2;
}
}

int main() {
int ret = 0;
omp_set_num_threads(2);
#pragma omp parallel
{ ret = get_fib_num(10); }
printf("Fib of 10 is %d", ret);
return 0;
}

// CHECK-NOT: Failed
// CHECK-NOT: Skip
@@ -0,0 +1,4 @@
ompd init
b test_ompd_get_display_control_vars.c:14
c
ompdtestapi ompd_get_display_control_vars
@@ -0,0 +1,19 @@
// RUN: %gdb-compile 2>&1 | tee %t.compile
// RUN: %gdb-test -x %s.cmd %t 2>&1 | tee %t.out | FileCheck %s

#include <omp.h>
#include <stdio.h>

int main() {
omp_set_num_threads(4);
#pragma omp parallel
{
printf("Parallel level 1, thread num = %d.\n", omp_get_thread_num());
omp_set_num_threads(3);
#pragma omp parallel
{ printf("Parallel level 2, thread num = %d", omp_get_thread_num()); }
}
return 0;
}
// CHECK-NOT: Failed
// CHECK-NOT: Skip
@@ -0,0 +1,4 @@
ompd init
b test_ompd_get_enclosing_parallel_handle.c:14
c
ompdtestapi ompd_get_enclosing_parallel_handle
@@ -0,0 +1,30 @@
// RUN: %gdb-compile 2>&1 | tee %t.compile
// RUN: %gdb-test -x %s.cmd %t 2>&1 | tee %t.out | FileCheck %s

#include <omp.h>
#include <stdio.h>
int get_fib_num(int num) {
int t1, t2;
if (num < 2)
return num;
else {
#pragma omp task shared(t1)
t1 = get_fib_num(num - 1);
#pragma omp task shared(t2)
t2 = get_fib_num(num - 2);
#pragma omp taskwait
return t1 + t2;
}
}

int main() {
int ret = 0;
omp_set_num_threads(2);
#pragma omp parallel
{ ret = get_fib_num(10); }
printf("Fib of 10 is %d", ret);
return 0;
}

// CHECK-NOT: Failed
// CHECK-NOT: Skip
@@ -0,0 +1,5 @@
ompd init
b test_ompd_get_generating_task_handle.c:14
c
c
ompdtestapi ompd_get_generating_task_handle
30 changes: 30 additions & 0 deletions openmp/libompd/test/api_tests/test_ompd_get_icv_from_scope.c
@@ -0,0 +1,30 @@
// RUN: %gdb-compile 2>&1 | tee %t.compile
// RUN: %gdb-test -x %s.cmd %t 2>&1 | tee %t.out | FileCheck %s

#include <omp.h>
#include <stdio.h>
int get_fib_num(int num) {
int t1, t2;
if (num < 2)
return num;
else {
#pragma omp task shared(t1)
t1 = get_fib_num(num - 1);
#pragma omp task shared(t2)
t2 = get_fib_num(num - 2);
#pragma omp taskwait
return t1 + t2;
}
}

int main() {
int ret = 0;
omp_set_num_threads(2);
#pragma omp parallel
{ ret = get_fib_num(10); }
printf("Fib of 10 is %d", ret);
return 0;
}

// CHECK-NOT: Failed
// CHECK-NOT: Skip
@@ -0,0 +1,4 @@
ompd init
b test_ompd_get_icv_from_scope.c:14
c
ompdtestapi ompd_get_icv_from_scope
@@ -0,0 +1,16 @@
// RUN: %gdb-compile 2>&1 | tee %t.compile
// RUN: %gdb-test -x %s.cmd %t 2>&1 | tee %t.out | FileCheck %s

#include <omp.h>
#include <stdio.h>

int main() {

omp_set_num_threads(2);
#pragma omp parallel
{ printf("Parallel level 1, thread num = %d.\n", omp_get_thread_num()); }
return 0;
}

// CHECK-NOT: Failed
// CHECK-NOT: Skip
@@ -0,0 +1,4 @@
ompd init
b test_ompd_get_icv_string_from_scope.c:11
c
ompdtestapi ompd_get_icv_string_from_scope
14 changes: 14 additions & 0 deletions openmp/libompd/test/api_tests/test_ompd_get_omp_version.c
@@ -0,0 +1,14 @@
// RUN: %gdb-compile 2>&1 | tee %t.compile
// RUN: %gdb-test -x %s.cmd %t 2>&1 | tee %t.out | FileCheck %s

#include <omp.h>
#include <stdio.h>

int main() {
omp_set_num_threads(4);
#pragma omp parallel
{ printf("Parallel level 1, thread num = %d.\n", omp_get_thread_num()); }
return 0;
}
// CHECK-NOT: Failed
// CHECK-NOT: Skip
4 changes: 4 additions & 0 deletions openmp/libompd/test/api_tests/test_ompd_get_omp_version.c.cmd
@@ -0,0 +1,4 @@
ompd init
b test_ompd_get_omp_version.c:10
c
ompdtestapi ompd_get_omp_version

0 comments on commit 1099498

Please sign in to comment.