diff options
Diffstat (limited to 'openmp/libompd')
94 files changed, 1704 insertions, 0 deletions
diff --git a/openmp/libompd/CMakeLists.txt b/openmp/libompd/CMakeLists.txt index 7720af1..d6cb8c0 100644 --- a/openmp/libompd/CMakeLists.txt +++ b/openmp/libompd/CMakeLists.txt @@ -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() diff --git a/openmp/libompd/test/CMakeLists.txt b/openmp/libompd/test/CMakeLists.txt new file mode 100644 index 0000000..81ca00e --- /dev/null +++ b/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() diff --git a/openmp/libompd/test/api_tests/test_ompd_device_initialize.c b/openmp/libompd/test/api_tests/test_ompd_device_initialize.c new file mode 100644 index 0000000..442199b --- /dev/null +++ b/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 diff --git a/openmp/libompd/test/api_tests/test_ompd_device_initialize.c.cmd b/openmp/libompd/test/api_tests/test_ompd_device_initialize.c.cmd new file mode 100644 index 0000000..e148392 --- /dev/null +++ b/openmp/libompd/test/api_tests/test_ompd_device_initialize.c.cmd @@ -0,0 +1,3 @@ +ompd init +b test_ompd_device_initialize.c:9 +ompdtestapi ompd_device_initialize diff --git a/openmp/libompd/test/api_tests/test_ompd_enumerate_icvs.c b/openmp/libompd/test/api_tests/test_ompd_enumerate_icvs.c new file mode 100644 index 0000000..2970d48 --- /dev/null +++ b/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 diff --git a/openmp/libompd/test/api_tests/test_ompd_enumerate_icvs.c.cmd b/openmp/libompd/test/api_tests/test_ompd_enumerate_icvs.c.cmd new file mode 100644 index 0000000..dd1d596 --- /dev/null +++ b/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 diff --git a/openmp/libompd/test/api_tests/test_ompd_enumerate_states.c b/openmp/libompd/test/api_tests/test_ompd_enumerate_states.c new file mode 100644 index 0000000..2970d48 --- /dev/null +++ b/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 diff --git a/openmp/libompd/test/api_tests/test_ompd_enumerate_states.c.cmd b/openmp/libompd/test/api_tests/test_ompd_enumerate_states.c.cmd new file mode 100644 index 0000000..9853e11 --- /dev/null +++ b/openmp/libompd/test/api_tests/test_ompd_enumerate_states.c.cmd @@ -0,0 +1,4 @@ +ompd init +b test_ompd_enumerate_states.c:11 +c +ompdtestapi ompd_enumerate_states diff --git a/openmp/libompd/test/api_tests/test_ompd_finalize.c b/openmp/libompd/test/api_tests/test_ompd_finalize.c new file mode 100644 index 0000000..b7ff98d --- /dev/null +++ b/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 diff --git a/openmp/libompd/test/api_tests/test_ompd_finalize.c.cmd b/openmp/libompd/test/api_tests/test_ompd_finalize.c.cmd new file mode 100644 index 0000000..084d99c --- /dev/null +++ b/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 diff --git a/openmp/libompd/test/api_tests/test_ompd_finalize.c.cmd2 b/openmp/libompd/test/api_tests/test_ompd_finalize.c.cmd2 new file mode 100644 index 0000000..1de6669 --- /dev/null +++ b/openmp/libompd/test/api_tests/test_ompd_finalize.c.cmd2 @@ -0,0 +1,3 @@ +b main +r +ompdtestapi ompd_finalize diff --git a/openmp/libompd/test/api_tests/test_ompd_get_api_version.c b/openmp/libompd/test/api_tests/test_ompd_get_api_version.c new file mode 100644 index 0000000..dc71361 --- /dev/null +++ b/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 diff --git a/openmp/libompd/test/api_tests/test_ompd_get_api_version.c.cmd b/openmp/libompd/test/api_tests/test_ompd_get_api_version.c.cmd new file mode 100644 index 0000000..41ad348 --- /dev/null +++ b/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 diff --git a/openmp/libompd/test/api_tests/test_ompd_get_curr_parallel_handle.c b/openmp/libompd/test/api_tests/test_ompd_get_curr_parallel_handle.c new file mode 100644 index 0000000..bcc41f3 --- /dev/null +++ b/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 diff --git a/openmp/libompd/test/api_tests/test_ompd_get_curr_parallel_handle.c.cmd b/openmp/libompd/test/api_tests/test_ompd_get_curr_parallel_handle.c.cmd new file mode 100644 index 0000000..6acb277 --- /dev/null +++ b/openmp/libompd/test/api_tests/test_ompd_get_curr_parallel_handle.c.cmd @@ -0,0 +1,3 @@ +ompd init +b test_ompd_get_curr_parallel_handle.c:11 +ompdtestapi ompd_get_curr_parallel_handle diff --git a/openmp/libompd/test/api_tests/test_ompd_get_curr_parallel_handle.c.cmd2 b/openmp/libompd/test/api_tests/test_ompd_get_curr_parallel_handle.c.cmd2 new file mode 100644 index 0000000..5d24e66 --- /dev/null +++ b/openmp/libompd/test/api_tests/test_ompd_get_curr_parallel_handle.c.cmd2 @@ -0,0 +1,4 @@ +ompd init +b test_ompd_get_curr_parallel_handle.c:11 +c +ompdtestapi ompd_get_curr_parallel_handle diff --git a/openmp/libompd/test/api_tests/test_ompd_get_curr_task_handle.c b/openmp/libompd/test/api_tests/test_ompd_get_curr_task_handle.c new file mode 100644 index 0000000..4aebd9c --- /dev/null +++ b/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 diff --git a/openmp/libompd/test/api_tests/test_ompd_get_curr_task_handle.c.cmd b/openmp/libompd/test/api_tests/test_ompd_get_curr_task_handle.c.cmd new file mode 100644 index 0000000..66d30fb --- /dev/null +++ b/openmp/libompd/test/api_tests/test_ompd_get_curr_task_handle.c.cmd @@ -0,0 +1,4 @@ +ompd init +b test_ompd_get_curr_task_handle.c:14 +c +ompdtestapi ompd_get_curr_task_handle diff --git a/openmp/libompd/test/api_tests/test_ompd_get_display_control_vars.c b/openmp/libompd/test/api_tests/test_ompd_get_display_control_vars.c new file mode 100644 index 0000000..4aebd9c --- /dev/null +++ b/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 diff --git a/openmp/libompd/test/api_tests/test_ompd_get_display_control_vars.c.cmd b/openmp/libompd/test/api_tests/test_ompd_get_display_control_vars.c.cmd new file mode 100644 index 0000000..ef94e2b --- /dev/null +++ b/openmp/libompd/test/api_tests/test_ompd_get_display_control_vars.c.cmd @@ -0,0 +1,4 @@ +ompd init +b test_ompd_get_display_control_vars.c:14 +c +ompdtestapi ompd_get_display_control_vars diff --git a/openmp/libompd/test/api_tests/test_ompd_get_enclosing_parallel_handle.c b/openmp/libompd/test/api_tests/test_ompd_get_enclosing_parallel_handle.c new file mode 100644 index 0000000..cd7f3dd --- /dev/null +++ b/openmp/libompd/test/api_tests/test_ompd_get_enclosing_parallel_handle.c @@ -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 diff --git a/openmp/libompd/test/api_tests/test_ompd_get_enclosing_parallel_handle.c.cmd b/openmp/libompd/test/api_tests/test_ompd_get_enclosing_parallel_handle.c.cmd new file mode 100644 index 0000000..e17b003 --- /dev/null +++ b/openmp/libompd/test/api_tests/test_ompd_get_enclosing_parallel_handle.c.cmd @@ -0,0 +1,4 @@ +ompd init +b test_ompd_get_enclosing_parallel_handle.c:14 +c +ompdtestapi ompd_get_enclosing_parallel_handle diff --git a/openmp/libompd/test/api_tests/test_ompd_get_generating_task_handle.c b/openmp/libompd/test/api_tests/test_ompd_get_generating_task_handle.c new file mode 100644 index 0000000..4aebd9c --- /dev/null +++ b/openmp/libompd/test/api_tests/test_ompd_get_generating_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 diff --git a/openmp/libompd/test/api_tests/test_ompd_get_generating_task_handle.c.cmd b/openmp/libompd/test/api_tests/test_ompd_get_generating_task_handle.c.cmd new file mode 100644 index 0000000..11d9af5 --- /dev/null +++ b/openmp/libompd/test/api_tests/test_ompd_get_generating_task_handle.c.cmd @@ -0,0 +1,5 @@ +ompd init +b test_ompd_get_generating_task_handle.c:14 +c +c +ompdtestapi ompd_get_generating_task_handle diff --git a/openmp/libompd/test/api_tests/test_ompd_get_icv_from_scope.c b/openmp/libompd/test/api_tests/test_ompd_get_icv_from_scope.c new file mode 100644 index 0000000..4aebd9c --- /dev/null +++ b/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 diff --git a/openmp/libompd/test/api_tests/test_ompd_get_icv_from_scope.c.cmd b/openmp/libompd/test/api_tests/test_ompd_get_icv_from_scope.c.cmd new file mode 100644 index 0000000..c44938e --- /dev/null +++ b/openmp/libompd/test/api_tests/test_ompd_get_icv_from_scope.c.cmd @@ -0,0 +1,4 @@ +ompd init +b test_ompd_get_icv_from_scope.c:14 +c +ompdtestapi ompd_get_icv_from_scope diff --git a/openmp/libompd/test/api_tests/test_ompd_get_icv_string_from_scope.c b/openmp/libompd/test/api_tests/test_ompd_get_icv_string_from_scope.c new file mode 100644 index 0000000..2970d48 --- /dev/null +++ b/openmp/libompd/test/api_tests/test_ompd_get_icv_string_from_scope.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 diff --git a/openmp/libompd/test/api_tests/test_ompd_get_icv_string_from_scope.c.cmd b/openmp/libompd/test/api_tests/test_ompd_get_icv_string_from_scope.c.cmd new file mode 100644 index 0000000..3b64dd8 --- /dev/null +++ b/openmp/libompd/test/api_tests/test_ompd_get_icv_string_from_scope.c.cmd @@ -0,0 +1,4 @@ +ompd init +b test_ompd_get_icv_string_from_scope.c:11 +c +ompdtestapi ompd_get_icv_string_from_scope diff --git a/openmp/libompd/test/api_tests/test_ompd_get_omp_version.c b/openmp/libompd/test/api_tests/test_ompd_get_omp_version.c new file mode 100644 index 0000000..dc71361 --- /dev/null +++ b/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 diff --git a/openmp/libompd/test/api_tests/test_ompd_get_omp_version.c.cmd b/openmp/libompd/test/api_tests/test_ompd_get_omp_version.c.cmd new file mode 100644 index 0000000..be086b3 --- /dev/null +++ b/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 diff --git a/openmp/libompd/test/api_tests/test_ompd_get_omp_version_string.c b/openmp/libompd/test/api_tests/test_ompd_get_omp_version_string.c new file mode 100644 index 0000000..442199b --- /dev/null +++ b/openmp/libompd/test/api_tests/test_ompd_get_omp_version_string.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 diff --git a/openmp/libompd/test/api_tests/test_ompd_get_omp_version_string.c.cmd b/openmp/libompd/test/api_tests/test_ompd_get_omp_version_string.c.cmd new file mode 100644 index 0000000..a87836e --- /dev/null +++ b/openmp/libompd/test/api_tests/test_ompd_get_omp_version_string.c.cmd @@ -0,0 +1,2 @@ +ompd init +ompdtestapi ompd_get_omp_version_string diff --git a/openmp/libompd/test/api_tests/test_ompd_get_scheduling_task_handle.c b/openmp/libompd/test/api_tests/test_ompd_get_scheduling_task_handle.c new file mode 100644 index 0000000..4aebd9c --- /dev/null +++ b/openmp/libompd/test/api_tests/test_ompd_get_scheduling_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 diff --git a/openmp/libompd/test/api_tests/test_ompd_get_scheduling_task_handle.c.cmd b/openmp/libompd/test/api_tests/test_ompd_get_scheduling_task_handle.c.cmd new file mode 100644 index 0000000..662bd17 --- /dev/null +++ b/openmp/libompd/test/api_tests/test_ompd_get_scheduling_task_handle.c.cmd @@ -0,0 +1,4 @@ +ompd init +b test_ompd_get_scheduling_task_handle.c:14 +c +ompdtestapi ompd_get_scheduling_task_handle diff --git a/openmp/libompd/test/api_tests/test_ompd_get_state.c b/openmp/libompd/test/api_tests/test_ompd_get_state.c new file mode 100644 index 0000000..2970d48 --- /dev/null +++ b/openmp/libompd/test/api_tests/test_ompd_get_state.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 diff --git a/openmp/libompd/test/api_tests/test_ompd_get_state.c.cmd b/openmp/libompd/test/api_tests/test_ompd_get_state.c.cmd new file mode 100644 index 0000000..34c328e --- /dev/null +++ b/openmp/libompd/test/api_tests/test_ompd_get_state.c.cmd @@ -0,0 +1,4 @@ +ompd init +b test_ompd_get_state.c:11 +c +ompdtestapi ompd_get_state diff --git a/openmp/libompd/test/api_tests/test_ompd_get_task_frame.c b/openmp/libompd/test/api_tests/test_ompd_get_task_frame.c new file mode 100644 index 0000000..4aebd9c --- /dev/null +++ b/openmp/libompd/test/api_tests/test_ompd_get_task_frame.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 diff --git a/openmp/libompd/test/api_tests/test_ompd_get_task_frame.c.cmd b/openmp/libompd/test/api_tests/test_ompd_get_task_frame.c.cmd new file mode 100644 index 0000000..a19eebd --- /dev/null +++ b/openmp/libompd/test/api_tests/test_ompd_get_task_frame.c.cmd @@ -0,0 +1,4 @@ +ompd init +b test_ompd_get_task_frame.c:14 +c +ompdtestapi ompd_get_task_frame diff --git a/openmp/libompd/test/api_tests/test_ompd_get_task_function.c b/openmp/libompd/test/api_tests/test_ompd_get_task_function.c new file mode 100644 index 0000000..4aebd9c --- /dev/null +++ b/openmp/libompd/test/api_tests/test_ompd_get_task_function.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 diff --git a/openmp/libompd/test/api_tests/test_ompd_get_task_function.c.cmd b/openmp/libompd/test/api_tests/test_ompd_get_task_function.c.cmd new file mode 100644 index 0000000..0db859cb --- /dev/null +++ b/openmp/libompd/test/api_tests/test_ompd_get_task_function.c.cmd @@ -0,0 +1,4 @@ +ompd init +b test_ompd_get_task_function.c:14 +c +ompdtestapi ompd_get_task_function diff --git a/openmp/libompd/test/api_tests/test_ompd_get_task_in_parallel.c b/openmp/libompd/test/api_tests/test_ompd_get_task_in_parallel.c new file mode 100644 index 0000000..0bd3359 --- /dev/null +++ b/openmp/libompd/test/api_tests/test_ompd_get_task_in_parallel.c @@ -0,0 +1,15 @@ +// 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 diff --git a/openmp/libompd/test/api_tests/test_ompd_get_task_in_parallel.c.cmd b/openmp/libompd/test/api_tests/test_ompd_get_task_in_parallel.c.cmd new file mode 100644 index 0000000..ca5c553 --- /dev/null +++ b/openmp/libompd/test/api_tests/test_ompd_get_task_in_parallel.c.cmd @@ -0,0 +1,4 @@ +ompd init +b test_ompd_get_task_in_parallel.c:10 +c +ompdtestapi ompd_get_task_in_parallel diff --git a/openmp/libompd/test/api_tests/test_ompd_get_task_parallel_handle.c b/openmp/libompd/test/api_tests/test_ompd_get_task_parallel_handle.c new file mode 100644 index 0000000..4aebd9c --- /dev/null +++ b/openmp/libompd/test/api_tests/test_ompd_get_task_parallel_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 diff --git a/openmp/libompd/test/api_tests/test_ompd_get_task_parallel_handle.c.cmd b/openmp/libompd/test/api_tests/test_ompd_get_task_parallel_handle.c.cmd new file mode 100644 index 0000000..e5d4f5d --- /dev/null +++ b/openmp/libompd/test/api_tests/test_ompd_get_task_parallel_handle.c.cmd @@ -0,0 +1,4 @@ +ompd init +b test_ompd_get_task_parallel_handle.c:14 +c +ompdtestapi ompd_get_task_parallel_handle diff --git a/openmp/libompd/test/api_tests/test_ompd_get_thread_handle.c b/openmp/libompd/test/api_tests/test_ompd_get_thread_handle.c new file mode 100644 index 0000000..7b08fb4 --- /dev/null +++ b/openmp/libompd/test/api_tests/test_ompd_get_thread_handle.c @@ -0,0 +1,15 @@ +// 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 | 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 diff --git a/openmp/libompd/test/api_tests/test_ompd_get_thread_handle.c.cmd b/openmp/libompd/test/api_tests/test_ompd_get_thread_handle.c.cmd new file mode 100644 index 0000000..70e6409 --- /dev/null +++ b/openmp/libompd/test/api_tests/test_ompd_get_thread_handle.c.cmd @@ -0,0 +1,4 @@ +ompd init +b test_ompd_get_thread_handle.c:11 +c +ompdtestapi ompd_get_thread_handle diff --git a/openmp/libompd/test/api_tests/test_ompd_get_thread_handle.c.cmd2 b/openmp/libompd/test/api_tests/test_ompd_get_thread_handle.c.cmd2 new file mode 100644 index 0000000..5409445 --- /dev/null +++ b/openmp/libompd/test/api_tests/test_ompd_get_thread_handle.c.cmd2 @@ -0,0 +1,3 @@ +ompd init +b test_ompd_get_thread_handle.c:11 +ompdtestapi ompd_get_thread_handle diff --git a/openmp/libompd/test/api_tests/test_ompd_get_thread_id.c b/openmp/libompd/test/api_tests/test_ompd_get_thread_id.c new file mode 100644 index 0000000..dc71361 --- /dev/null +++ b/openmp/libompd/test/api_tests/test_ompd_get_thread_id.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 diff --git a/openmp/libompd/test/api_tests/test_ompd_get_thread_id.c.cmd b/openmp/libompd/test/api_tests/test_ompd_get_thread_id.c.cmd new file mode 100644 index 0000000..48776fa --- /dev/null +++ b/openmp/libompd/test/api_tests/test_ompd_get_thread_id.c.cmd @@ -0,0 +1,4 @@ +ompd init +b test_ompd_get_thread_id.c:10 +c +ompdtestapi ompd_get_thread_id diff --git a/openmp/libompd/test/api_tests/test_ompd_get_thread_in_parallel.c b/openmp/libompd/test/api_tests/test_ompd_get_thread_in_parallel.c new file mode 100644 index 0000000..dc71361 --- /dev/null +++ b/openmp/libompd/test/api_tests/test_ompd_get_thread_in_parallel.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 diff --git a/openmp/libompd/test/api_tests/test_ompd_get_thread_in_parallel.c.cmd b/openmp/libompd/test/api_tests/test_ompd_get_thread_in_parallel.c.cmd new file mode 100644 index 0000000..c2e619d --- /dev/null +++ b/openmp/libompd/test/api_tests/test_ompd_get_thread_in_parallel.c.cmd @@ -0,0 +1,4 @@ +ompd init +b test_ompd_get_thread_in_parallel.c:10 +c +ompdtestapi ompd_get_thread_in_parallel diff --git a/openmp/libompd/test/api_tests/test_ompd_get_tool_data.c b/openmp/libompd/test/api_tests/test_ompd_get_tool_data.c new file mode 100644 index 0000000..2970d48 --- /dev/null +++ b/openmp/libompd/test/api_tests/test_ompd_get_tool_data.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 diff --git a/openmp/libompd/test/api_tests/test_ompd_get_tool_data.c.cmd b/openmp/libompd/test/api_tests/test_ompd_get_tool_data.c.cmd new file mode 100644 index 0000000..76871eb --- /dev/null +++ b/openmp/libompd/test/api_tests/test_ompd_get_tool_data.c.cmd @@ -0,0 +1,4 @@ +ompd init +b test_ompd_get_tool_data.c:11 +c +ompdtestapi ompd_get_tool_data diff --git a/openmp/libompd/test/api_tests/test_ompd_get_version_string.c b/openmp/libompd/test/api_tests/test_ompd_get_version_string.c new file mode 100644 index 0000000..dc71361 --- /dev/null +++ b/openmp/libompd/test/api_tests/test_ompd_get_version_string.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 diff --git a/openmp/libompd/test/api_tests/test_ompd_get_version_string.c.cmd b/openmp/libompd/test/api_tests/test_ompd_get_version_string.c.cmd new file mode 100644 index 0000000..1d52366 --- /dev/null +++ b/openmp/libompd/test/api_tests/test_ompd_get_version_string.c.cmd @@ -0,0 +1,3 @@ +ompd init +b test_ompd_get_version_string.c:10 +ompdtestapi ompd_get_version_string diff --git a/openmp/libompd/test/api_tests/test_ompd_initialize.c b/openmp/libompd/test/api_tests/test_ompd_initialize.c new file mode 100644 index 0000000..442199b --- /dev/null +++ b/openmp/libompd/test/api_tests/test_ompd_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 diff --git a/openmp/libompd/test/api_tests/test_ompd_initialize.c.cmd b/openmp/libompd/test/api_tests/test_ompd_initialize.c.cmd new file mode 100644 index 0000000..311be1dcf --- /dev/null +++ b/openmp/libompd/test/api_tests/test_ompd_initialize.c.cmd @@ -0,0 +1,4 @@ +ompd init +b 7 +ompdtestapi ompd_initialize + diff --git a/openmp/libompd/test/api_tests/test_ompd_parallel_handle_compare.c b/openmp/libompd/test/api_tests/test_ompd_parallel_handle_compare.c new file mode 100644 index 0000000..cd7f3dd --- /dev/null +++ b/openmp/libompd/test/api_tests/test_ompd_parallel_handle_compare.c @@ -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 diff --git a/openmp/libompd/test/api_tests/test_ompd_parallel_handle_compare.c.cmd b/openmp/libompd/test/api_tests/test_ompd_parallel_handle_compare.c.cmd new file mode 100644 index 0000000..a916577 --- /dev/null +++ b/openmp/libompd/test/api_tests/test_ompd_parallel_handle_compare.c.cmd @@ -0,0 +1,4 @@ +ompd init +b test_ompd_parallel_handle_compare.c:14 +c +ompdtestapi ompd_parallel_handle_compare diff --git a/openmp/libompd/test/api_tests/test_ompd_process_initialize.c b/openmp/libompd/test/api_tests/test_ompd_process_initialize.c new file mode 100644 index 0000000..dc71361 --- /dev/null +++ b/openmp/libompd/test/api_tests/test_ompd_process_initialize.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 diff --git a/openmp/libompd/test/api_tests/test_ompd_process_initialize.c.cmd b/openmp/libompd/test/api_tests/test_ompd_process_initialize.c.cmd new file mode 100644 index 0000000..6ccfa9c --- /dev/null +++ b/openmp/libompd/test/api_tests/test_ompd_process_initialize.c.cmd @@ -0,0 +1,3 @@ +ompd init +b test_ompd_process_initialize.c:10 +ompdtestapi ompd_process_initialize diff --git a/openmp/libompd/test/api_tests/test_ompd_rel_address_space_handle.c b/openmp/libompd/test/api_tests/test_ompd_rel_address_space_handle.c new file mode 100644 index 0000000..dc71361 --- /dev/null +++ b/openmp/libompd/test/api_tests/test_ompd_rel_address_space_handle.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 diff --git a/openmp/libompd/test/api_tests/test_ompd_rel_address_space_handle.c.cmd b/openmp/libompd/test/api_tests/test_ompd_rel_address_space_handle.c.cmd new file mode 100644 index 0000000..fdac4f9 --- /dev/null +++ b/openmp/libompd/test/api_tests/test_ompd_rel_address_space_handle.c.cmd @@ -0,0 +1,3 @@ +ompd init +b test_ompd_rel_address_space_handle.c:10 +ompdtestapi ompd_rel_address_space_handle diff --git a/openmp/libompd/test/api_tests/test_ompd_rel_display_control_vars.c b/openmp/libompd/test/api_tests/test_ompd_rel_display_control_vars.c new file mode 100644 index 0000000..4aebd9c --- /dev/null +++ b/openmp/libompd/test/api_tests/test_ompd_rel_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 diff --git a/openmp/libompd/test/api_tests/test_ompd_rel_display_control_vars.c.cmd b/openmp/libompd/test/api_tests/test_ompd_rel_display_control_vars.c.cmd new file mode 100644 index 0000000..7c159db --- /dev/null +++ b/openmp/libompd/test/api_tests/test_ompd_rel_display_control_vars.c.cmd @@ -0,0 +1,4 @@ +ompd init +b test_ompd_rel_display_control_vars.c:14 +c +ompdtestapi ompd_rel_display_control_vars diff --git a/openmp/libompd/test/api_tests/test_ompd_rel_parallel_handle.c b/openmp/libompd/test/api_tests/test_ompd_rel_parallel_handle.c new file mode 100644 index 0000000..dc71361 --- /dev/null +++ b/openmp/libompd/test/api_tests/test_ompd_rel_parallel_handle.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 diff --git a/openmp/libompd/test/api_tests/test_ompd_rel_parallel_handle.c.cmd b/openmp/libompd/test/api_tests/test_ompd_rel_parallel_handle.c.cmd new file mode 100644 index 0000000..8ee9f07 --- /dev/null +++ b/openmp/libompd/test/api_tests/test_ompd_rel_parallel_handle.c.cmd @@ -0,0 +1,4 @@ +ompd init +b test_ompd_rel_parallel_handle.c:10 +c +ompdtestapi ompd_rel_parallel_handle diff --git a/openmp/libompd/test/api_tests/test_ompd_rel_task_handle.c b/openmp/libompd/test/api_tests/test_ompd_rel_task_handle.c new file mode 100644 index 0000000..4aebd9c --- /dev/null +++ b/openmp/libompd/test/api_tests/test_ompd_rel_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 diff --git a/openmp/libompd/test/api_tests/test_ompd_rel_task_handle.c.cmd b/openmp/libompd/test/api_tests/test_ompd_rel_task_handle.c.cmd new file mode 100644 index 0000000..61f98a9 --- /dev/null +++ b/openmp/libompd/test/api_tests/test_ompd_rel_task_handle.c.cmd @@ -0,0 +1,4 @@ +ompd init +b test_ompd_rel_task_handle.c:14 +c +ompdtestapi ompd_rel_task_handle diff --git a/openmp/libompd/test/api_tests/test_ompd_rel_thread_handle.c b/openmp/libompd/test/api_tests/test_ompd_rel_thread_handle.c new file mode 100644 index 0000000..dc71361 --- /dev/null +++ b/openmp/libompd/test/api_tests/test_ompd_rel_thread_handle.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 diff --git a/openmp/libompd/test/api_tests/test_ompd_rel_thread_handle.c.cmd b/openmp/libompd/test/api_tests/test_ompd_rel_thread_handle.c.cmd new file mode 100644 index 0000000..c8eeb25 --- /dev/null +++ b/openmp/libompd/test/api_tests/test_ompd_rel_thread_handle.c.cmd @@ -0,0 +1,4 @@ +ompd init +b test_ompd_rel_thread_handle.c:10 +c +ompdtestapi ompd_rel_thread_handle diff --git a/openmp/libompd/test/api_tests/test_ompd_task_handle_compare.c b/openmp/libompd/test/api_tests/test_ompd_task_handle_compare.c new file mode 100644 index 0000000..4aebd9c --- /dev/null +++ b/openmp/libompd/test/api_tests/test_ompd_task_handle_compare.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 diff --git a/openmp/libompd/test/api_tests/test_ompd_task_handle_compare.c.cmd b/openmp/libompd/test/api_tests/test_ompd_task_handle_compare.c.cmd new file mode 100644 index 0000000..12b36c0 --- /dev/null +++ b/openmp/libompd/test/api_tests/test_ompd_task_handle_compare.c.cmd @@ -0,0 +1,5 @@ +ompd init +b test_ompd_task_handle_compare.c:14 +c +c +ompdtestapi ompd_task_handle_compare diff --git a/openmp/libompd/test/api_tests/test_ompd_thread_handle_compare.c b/openmp/libompd/test/api_tests/test_ompd_thread_handle_compare.c new file mode 100644 index 0000000..52663ae --- /dev/null +++ b/openmp/libompd/test/api_tests/test_ompd_thread_handle_compare.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(3); +#pragma omp parallel + { printf("Parallel level 1, thread num = %d.\n", omp_get_thread_num()); } + return 0; +} +// CHECK-NOT: Failed +// CHECK-NOT: Skip diff --git a/openmp/libompd/test/api_tests/test_ompd_thread_handle_compare.c.cmd b/openmp/libompd/test/api_tests/test_ompd_thread_handle_compare.c.cmd new file mode 100644 index 0000000..24e84df --- /dev/null +++ b/openmp/libompd/test/api_tests/test_ompd_thread_handle_compare.c.cmd @@ -0,0 +1,4 @@ +ompd init +b test_ompd_thread_handle_compare.c:10 +c +ompdtestapi ompd_thread_handle_compare diff --git a/openmp/libompd/test/lit.cfg b/openmp/libompd/test/lit.cfg new file mode 100644 index 0000000..df881d0 --- /dev/null +++ b/openmp/libompd/test/lit.cfg @@ -0,0 +1,83 @@ +# -*- Python -*- vim: set ft=python ts=4 sw=4 expandtab tw=79: +# Configuration file for the 'lit' test runner. + +import os +import re +import subprocess +import lit.formats + +# Tell pylint that we know config and lit_config exist somewhere. +if 'PYLINT_IMPORT' in os.environ: + config = object() + lit_config = object() + +def append_dynamic_library_path(path): + if config.operating_system == 'Windows': + name = 'PATH' + sep = ';' + elif config.operating_system == 'Darwin': + name = 'DYLD_LIBRARY_PATH' + sep = ':' + else: + name = 'LD_LIBRARY_PATH' + sep = ':' + if name in config.environment: + config.environment[name] = path + sep + config.environment[name] + else: + config.environment[name] = path +# config.environment['PYTHONPATH'] = config.ompd_module + sep + config.environment['PYTHON_PATH'] + +# name: The name of this test suite. +config.name = 'ompd-test' + +# suffixes: A list of file extensions to treat as test files. +config.suffixes = ['.c'] + +# test_source_root: The root path where tests are located. +#config.test_source_root = os.path.dirname(__file__) +config.test_source_root = config.ompd_test_src + +# test_exec_root: The root object directory where output is placed +config.test_exec_root = config.ompd_obj_root + +# test format +config.test_format = lit.formats.ShTest() + +# compiler flags +config.test_flags = " -I " + config.test_source_root + " -I " + config.ompt_include_dir + \ + " " + config.test_extra_flags + " -L " + config.library_dir + +append_dynamic_library_path(config.library_dir) +append_dynamic_library_path(config.ompd_library_dir) + +# Disable OMPT tests if FileCheck was not found +if config.test_filecheck == "": + lit_config.note("Not testing OMPT_OMPD because FileCheck was not found") + +if 'Linux' in config.operating_system: + config.available_features.add("linux") + +# to run with icc INTEL_LICENSE_FILE must be set +if 'INTEL_LICENSE_FILE' in os.environ: + config.environment['INTEL_LICENSE_FILE'] = os.environ['INTEL_LICENSE_FILE'] +if 'OMP_NUM_THREADS' in os.environ: + config.environment['OMP_NUM_THREADS'] = os.environ['OMP_NUM_THREADS'] +#config.environment['ompd'] = "/home/gu620893/LLVM-openmp-master/install/" + +config.substitutions.append(("%gdb-compile-and-run", "%gdb-compile && %gdb-run")) + +config.substitutions.append(("%gdb-compile", + "%test_c_compiler -fopenmp -g -gdwarf-4 %s -o %t " + config.test_flags)) +config.substitutions.append(("%test_c_compiler", config.test_c_compiler)) +config.substitutions.append(("%gdb-run", + "env OMP_DEBUG=enabled gdb -x " + config.ompd_obj_root + "/../gdb-plugin/python-module/ompd/__init__.py -x " \ + + config.ompd_test_src + "/test.cmd %t ")) + +config.substitutions.append(("%gdb-test", + "env OMP_DEBUG=enabled gdb -x " + config.ompd_obj_root + "/../gdb-plugin/python-module/ompd/__init__.py ")) + +config.substitutions.append(("%ompt-tool", + config.ompt_plugin)) + +config.substitutions.append(("FileCheck", config.test_filecheck)) + diff --git a/openmp/libompd/test/lit.site.cfg.in b/openmp/libompd/test/lit.site.cfg.in new file mode 100644 index 0000000..63b8c97 --- /dev/null +++ b/openmp/libompd/test/lit.site.cfg.in @@ -0,0 +1,21 @@ +@AUTO_GEN_COMMENT@ + +config.test_c_compiler = "@OPENMP_TEST_C_COMPILER@" +config.test_compiler_features = @OPENMP_TEST_COMPILER_FEATURES@ +config.test_filecheck = "@OPENMP_FILECHECK_EXECUTABLE@" +config.test_not = "@OPENMP_NOT_EXECUTABLE@" +config.test_openmp_flags = "@OPENMP_TEST_OPENMP_FLAGS@" +config.test_extra_flags = "@OPENMP_TEST_FLAGS@" +config.ompd_obj_root = "@CMAKE_CURRENT_BINARY_DIR@" +config.ompd_test_src = "@CMAKE_CURRENT_SOURCE_DIR@" +config.library_dir = "@LIBOMP_LIBRARY_DIR@" +config.ompd_library_dir = "@CMAKE_CURRENT_BINARY_DIR@/../src/" +config.omp_header_directory = "@LIBOMP_BINARY_DIR@/src" +config.operating_system = "@CMAKE_SYSTEM_NAME@" + +config.ompt_plugin = "@OMPT_PLUGIN@" +config.ompt_include_dir = "@LIBOMP_INCLUDE_DIR@" +config.ompd_module = "@CMAKE_CURRENT_BINARY_DIR@/../gdb-plugin/python-module/ompd/" + +# Let the main config do the real work. +lit_config.load_config(config, "@CMAKE_CURRENT_SOURCE_DIR@/lit.cfg") diff --git a/openmp/libompd/test/ompt_plugin.h b/openmp/libompd/test/ompt_plugin.h new file mode 100644 index 0000000..4488e68 --- /dev/null +++ b/openmp/libompd/test/ompt_plugin.h @@ -0,0 +1,200 @@ +#include <dlfcn.h> +#include <omp-tools.h> +#include <omp.h> +#include <stdio.h> +#include <stdlib.h> +#include <sys/types.h> +#include <unistd.h> + +typedef struct omp_t_data { + // Thread data + ompt_state_t ompt_state; + ompt_wait_id_t ompt_wait_id; + int omp_thread_num; + ompt_data_t *ompt_thread_data; + // Parallel data + int omp_num_threads; + int omp_level; + int omp_active_level; + ompt_data_t *ompt_parallel_data; + // Task data + int omp_max_threads; + int omp_parallel; + int omp_final; + int omp_dynamic; + int omp_nested; + int omp_max_active_levels; + omp_sched_t omp_kind; + int omp_modifier; + omp_proc_bind_t omp_proc_bind; + ompt_frame_t *ompt_frame_list; + ompt_data_t *ompt_task_data; +} omp_t_data_t; + +static __thread omp_t_data_t thread_data; + +static ompt_function_lookup_t ompt_lookup; +// NOLINTNEXTLINE "Used in Macro:register_callback_t below." +static ompt_set_callback_t ompt_set_callback; +static ompt_get_callback_t ompt_get_callback; +static ompt_get_state_t ompt_get_state; +static ompt_get_task_info_t ompt_get_task_info; +static ompt_get_thread_data_t ompt_get_thread_data; +static ompt_get_parallel_info_t ompt_get_parallel_info; +static ompt_get_unique_id_t ompt_get_unique_id; +static ompt_get_num_procs_t ompt_get_num_procs; +static ompt_get_num_places_t ompt_get_num_places; +static ompt_get_place_proc_ids_t ompt_get_place_proc_ids; +static ompt_get_place_num_t ompt_get_place_num; +static ompt_get_partition_place_nums_t ompt_get_partition_place_nums; +static ompt_get_proc_id_t ompt_get_proc_id; +static ompt_enumerate_states_t ompt_enumerate_states; +static ompt_enumerate_mutex_impls_t ompt_enumerate_mutex_impls; +static int checks = 0; + +static void on_ompt_callback_implicit_task(ompt_scope_endpoint_t endpoint, + ompt_data_t *parallel_data, + ompt_data_t *task_data, + unsigned int team_size, + unsigned int thread_num, int flags) { + if (endpoint == ompt_scope_begin) + task_data->value = ompt_get_unique_id(); +} + +static void on_ompt_callback_thread_begin(ompt_thread_t thread_type, + ompt_data_t *t_data) { + t_data->value = ompt_get_unique_id(); +} + +static void on_ompt_callback_parallel_begin( + ompt_data_t *encountering_task_data, + const ompt_frame_t *encountering_task_frame, ompt_data_t *parallel_data, + uint32_t requested_team_size, int flag, const void *codeptr_ra) { + parallel_data->value = ompt_get_unique_id(); +} + +#define register_callback_t(name, type) \ + do { \ + type f_##name = &on_##name; \ + if (ompt_set_callback(name, (ompt_callback_t)f_##name) == ompt_set_never) \ + printf("0: Could not register callback '" #name "'\n"); \ + } while (0) + +#define register_callback(name) register_callback_t(name, name##_t) + +static int ompt_initialize(ompt_function_lookup_t lookup, + int initial_device_num, ompt_data_t *tool_data) { + ompt_lookup = lookup; + // TODO: remove: printf("runtime_version: %s, omp_version: %i\n", + // runtime_version, omp_version); + + // TODO: remove macro + // #define declare_inquery_fn(F) F = (F##_t)lookup(#F); + // FOREACH_OMPT_INQUIRY_FN(declare_inquery_fn) + // #undef declare_inquery_fn + + ompt_set_callback_t ompt_set_callback = + (ompt_set_callback_t)lookup("ompt_set_callback"); + ompt_get_callback = (ompt_get_callback_t)lookup("ompt_get_callback"); + ompt_get_state = (ompt_get_state_t)lookup("ompt_get_state"); + ompt_get_task_info = (ompt_get_task_info_t)lookup("ompt_get_task_info"); + ompt_get_thread_data = (ompt_get_thread_data_t)lookup("ompt_get_thread_data"); + ompt_get_parallel_info = + (ompt_get_parallel_info_t)lookup("ompt_get_parallel_info"); + ompt_get_unique_id = (ompt_get_unique_id_t)lookup("ompt_get_unique_id"); + + ompt_get_num_procs = (ompt_get_num_procs_t)lookup("ompt_get_num_procs"); + ompt_get_num_places = (ompt_get_num_places_t)lookup("ompt_get_num_places"); + ompt_get_place_proc_ids = + (ompt_get_place_proc_ids_t)lookup("ompt_get_place_proc_ids"); + ompt_get_place_num = (ompt_get_place_num_t)lookup("ompt_get_place_num"); + ompt_get_partition_place_nums = + (ompt_get_partition_place_nums_t)lookup("ompt_get_partition_place_nums"); + ompt_get_proc_id = (ompt_get_proc_id_t)lookup("ompt_get_proc_id"); + ompt_enumerate_states = + (ompt_enumerate_states_t)lookup("ompt_enumerate_states"); + ompt_enumerate_mutex_impls = + (ompt_enumerate_mutex_impls_t)lookup("ompt_enumerate_mutex_impls"); + + register_callback(ompt_callback_implicit_task); + register_callback(ompt_callback_thread_begin); + register_callback(ompt_callback_parallel_begin); + + return 1; // activate tool +} + +static void ompt_finalize(ompt_data_t *tool_data) {} + +// "This func will be invoked by OpenMP implementation, refer spec: 4.2.1" +// NOLINTNEXTLINE +static ompt_start_tool_result_t *ompt_start_tool(unsigned int omp_version, + const char *runtime_version) { + static ompt_start_tool_result_t ompt_start_tool_result = { + &ompt_initialize, &ompt_finalize, {0}}; + return &ompt_start_tool_result; +} + +static void collectParallelData(omp_t_data_t *data) { + data->omp_num_threads = omp_get_num_threads(); + data->omp_level = omp_get_level(); + data->omp_active_level = omp_get_active_level(); + ompt_get_parallel_info(0, &(data->ompt_parallel_data), NULL); +} + +static void collectTaskData(omp_t_data_t *data) { + data->omp_max_threads = omp_get_max_threads(); + data->omp_parallel = omp_in_parallel(); + data->omp_final = omp_in_final(); + data->omp_dynamic = omp_get_dynamic(); + data->omp_nested = omp_get_max_active_levels() > 1; + data->omp_max_active_levels = omp_get_max_active_levels(); + omp_get_schedule(&(data->omp_kind), &(data->omp_modifier)); + data->omp_proc_bind = omp_get_proc_bind(); + ompt_get_task_info(0, NULL, &(data->ompt_task_data), &(data->ompt_frame_list), + NULL, NULL); +} + +static void collectThreadData(omp_t_data_t *data) { + data->omp_thread_num = omp_get_thread_num(); + data->ompt_state = (ompt_state_t)ompt_get_state(&(data->ompt_wait_id)); + data->ompt_thread_data = ompt_get_thread_data(); +} + +#ifdef __cplusplus +extern "C" { +#endif +__attribute__((noinline)) static void *breakToolTest(omp_t_data_t *data) { + return data; +} +#ifdef __cplusplus +} +#endif + +#ifdef __cplusplus +extern "C" { +#endif +static void *ompd_tool_break(void *n) { + (void)n; + asm(""); + return NULL; +} +#ifdef __cplusplus +} +#endif + +// NOLINTNEXTLINE "This func will be invoked in testcases." +static void *ompd_tool_test(void *n) { + collectThreadData(&thread_data); + collectParallelData(&thread_data); + collectTaskData(&thread_data); + breakToolTest(&thread_data); + checks++; + ompd_tool_break(NULL); + return NULL; +} + +__attribute__((__constructor__)) static void init(void) {} + +__attribute__((__destructor__)) static void fini(void) { + printf("Finished %i testsuites.\n", checks); +} diff --git a/openmp/libompd/test/openmp_examples/example_1.c b/openmp/libompd/test/openmp_examples/example_1.c new file mode 100644 index 0000000..016ecc4 --- /dev/null +++ b/openmp/libompd/test/openmp_examples/example_1.c @@ -0,0 +1,34 @@ +// RUN: %gdb-compile-and-run 2>&1 | tee %t.out | FileCheck %s + +#include "../ompt_plugin.h" +#include <omp.h> +#include <pthread.h> +#include <stdio.h> +#include <unistd.h> + +void createPthreads() { + int numThreads = 2; + pthread_t threads[numThreads]; + int i; + for (i = 0; i < numThreads; ++i) + pthread_create(&threads[i], NULL, ompd_tool_break, NULL); + + for (i = 0; i < numThreads; ++i) + pthread_join(threads[i], NULL); +} + +int main() { + omp_set_num_threads(4); + printf("Application: Process %d started.\n", getpid()); + createPthreads(); // thread_data is set to 0x0 if called + +// Parallel region 1 +#pragma omp parallel + { ompd_tool_test(0); } + + return 0; +} + +// CHECK-NOT: OMPT-OMPD mismatch +// CHECK-NOT: Python Exception +// CHECK-NOT: The program is not being run. diff --git a/openmp/libompd/test/openmp_examples/example_2.c b/openmp/libompd/test/openmp_examples/example_2.c new file mode 100644 index 0000000..45a8874 --- /dev/null +++ b/openmp/libompd/test/openmp_examples/example_2.c @@ -0,0 +1,39 @@ +// RUN: %gdb-compile 2>&1 | tee %t.compile +// RUN: env OMP_SCHEDULE=static,5 %gdb-run 2>&1 | tee %t.out | FileCheck %s + +#include "../ompt_plugin.h" +#include <omp.h> +#include <pthread.h> +#include <stdio.h> +#include <unistd.h> + +int main() { + printf("Application: Process %d started.\n", getpid()); + + omp_set_num_threads(3); + omp_set_max_active_levels(10); + +#pragma omp parallel // parallel region begins + { + printf("Outer region - thread_ID: %d\n", omp_get_thread_num()); + +#pragma omp parallel num_threads(2) // nested parallel region 1 + { + printf("Inner region - thread_ID: %d\n", omp_get_thread_num()); + +#pragma omp parallel num_threads(2) // nested parallel region 2 + { + int i; +#pragma omp for + for (i = 0; i < 10; i++) + ompd_tool_test(0); + } + } + } + + return 0; +} + +// CHECK-NOT: OMPT-OMPD mismatch +// CHECK-NOT: Python Exception +// CHECK-NOT: The program is not being run. diff --git a/openmp/libompd/test/openmp_examples/example_3.c b/openmp/libompd/test/openmp_examples/example_3.c new file mode 100644 index 0000000..27007e3 --- /dev/null +++ b/openmp/libompd/test/openmp_examples/example_3.c @@ -0,0 +1,35 @@ +// RUN: %gdb-compile 2>&1 | tee %t.compile +// RUN: env OMP_SCHEDULE=static %gdb-run 2>&1 | tee %t.out | FileCheck %s + +#include "../ompt_plugin.h" +#include <omp.h> +#include <stdio.h> +#include <unistd.h> + +void bar() { + int i; +#pragma omp parallel for num_threads(2) + for (i = 0; i < 10; i++) + ompd_tool_test(0); +} + +void foo() { + omp_set_max_active_levels(10); +#pragma omp parallel num_threads(2) + { + if (omp_get_thread_num() == 0) + ompd_tool_test(0); + else + bar(); + } +} + +int main() { + printf("Process %d started.\n", getpid()); + foo(); + return 0; +} + +// CHECK-NOT: OMPT-OMPD mismatch +// CHECK-NOT: Python Exception +// CHECK-NOT: The program is not being run. diff --git a/openmp/libompd/test/openmp_examples/example_4.c b/openmp/libompd/test/openmp_examples/example_4.c new file mode 100644 index 0000000..66ec53f --- /dev/null +++ b/openmp/libompd/test/openmp_examples/example_4.c @@ -0,0 +1,39 @@ +// RUN: %gdb-compile-and-run 2>&1 | tee %t.out | FileCheck %s + +#include "../ompt_plugin.h" +#include <omp.h> +#include <pthread.h> +#include <stdio.h> +#include <unistd.h> + +int main() { + printf("Application: Process %d started.\n", getpid()); + omp_set_num_threads(3); + omp_set_max_active_levels(10); + +#pragma omp parallel // parallel region begins + { + printf("Outer region - thread_ID: %d\n", omp_get_thread_num()); + +#pragma omp parallel num_threads(2) // nested parallel region 1 + { + printf("Inner region - thread_ID: %d\n", omp_get_thread_num()); + +#pragma omp parallel num_threads(2) // nested parallel region 2 + { + int i; +#pragma omp for + for (i = 0; i < 4; i++) + printf("Thread %i of %i working on %i\n", omp_get_thread_num(), + omp_get_max_threads(), i); + ompd_tool_test(0); + } + } + } + + return 0; +} + +// CHECK-NOT: OMPT-OMPD mismatch +// CHECK-NOT: Python Exception +// CHECK-NOT: The program is not being run. diff --git a/openmp/libompd/test/openmp_examples/example_5.c b/openmp/libompd/test/openmp_examples/example_5.c new file mode 100644 index 0000000..bff87a1 --- /dev/null +++ b/openmp/libompd/test/openmp_examples/example_5.c @@ -0,0 +1,39 @@ +// RUN: %gdb-compile 2>&1 | tee %t.compile +// RUN: env OMP_SCHEDULE=guided %gdb-run 2>&1 | tee %t.out | FileCheck %s + +#include "../ompt_plugin.h" +#include <omp.h> +#include <pthread.h> +#include <stdio.h> +#include <unistd.h> + +int main() { + printf("Application: Process %d started.\n", getpid()); + + omp_set_num_threads(3); + omp_set_max_active_levels(10); + +#pragma omp parallel // parallel region begins + { + printf("Outer region - thread_ID: %d\n", omp_get_thread_num()); + +#pragma omp parallel num_threads(1) // nested parallel region 1 + { + printf("Inner region - thread_ID: %d\n", omp_get_thread_num()); + +#pragma omp parallel num_threads(2) // nested parallel region 2 + { + int i; +#pragma omp for + for (i = 0; i < 15; i++) + ompd_tool_test(0); + } + } + } + + return 0; +} + +// CHECK-NOT: OMPT-OMPD mismatch +// CHECK-NOT: Python Exception +// CHECK-NOT: The program is not being run. diff --git a/openmp/libompd/test/openmp_examples/example_task.c b/openmp/libompd/test/openmp_examples/example_task.c new file mode 100644 index 0000000..769ff3f --- /dev/null +++ b/openmp/libompd/test/openmp_examples/example_task.c @@ -0,0 +1,39 @@ +// RUN: %gdb-compile-and-run 2>&1 | tee %t.out | FileCheck %s + +#include "../ompt_plugin.h" +#include <omp.h> +#include <pthread.h> +#include <stdio.h> +#include <unistd.h> + +void f(int i) { + if (i <= 0) { + ompd_tool_test(0); + } else { + printf("f(%i) start task 1\n", i); +#pragma omp task + f(i - 1); + printf("f(%i) start task 2\n", i); +#pragma omp task + f(i - 1); + printf("f(%i) start task 3\n", i); +#pragma omp task + f(i - 1); +#pragma omp taskwait + } +} + +int main() { + printf("Application: Process %d started.\n", getpid()); + omp_set_num_threads(8); + omp_set_max_active_levels(10); + +#pragma omp parallel sections + { f(4); } + + return 0; +} + +// CHECK-NOT: OMPT-OMPD mismatch +// CHECK-NOT: Python Exception +// CHECK-NOT: The program is not being run. diff --git a/openmp/libompd/test/openmp_examples/fibonacci.c b/openmp/libompd/test/openmp_examples/fibonacci.c new file mode 100644 index 0000000..3399e68 --- /dev/null +++ b/openmp/libompd/test/openmp_examples/fibonacci.c @@ -0,0 +1,37 @@ +// RUN: %gdb-compile-and-run 2>&1 | tee %t.out | FileCheck %s + +#include "../ompt_plugin.h" +#include <omp.h> +#include <stdio.h> +#include <stdlib.h> + +int fib(int n) { + int i, j; + if (n < 2) { + ompd_tool_test(0); + return n; + } else { +#pragma omp task shared(i) + i = fib(n - 1); +#pragma omp task shared(j) + j = fib(n - 2); +#pragma omp taskwait + return i + j; + } +} + +int main(int argc, char **argv) { + int n = 5; + if (argc > 1) + n = atoi(argv[1]); +#pragma omp parallel + { +#pragma omp single + printf("fib(%i) = %i\n", n, fib(n)); + } + return 0; +} + +// CHECK-NOT: OMPT-OMPD mismatch +// CHECK-NOT: Python Exception +// CHECK-NOT: The program is not being run. diff --git a/openmp/libompd/test/openmp_examples/nested.c b/openmp/libompd/test/openmp_examples/nested.c new file mode 100644 index 0000000..eb9cef9 --- /dev/null +++ b/openmp/libompd/test/openmp_examples/nested.c @@ -0,0 +1,51 @@ +// RUN: %gdb-compile 2>&1 | tee %t.compile +// RUN: env OMP_SCHEDULE=guided,10 %gdb-run 2>&1 | tee %t.out | FileCheck %s + +#include "../ompt_plugin.h" +#include <omp.h> +#include <stdio.h> +#include <unistd.h> + +int main() { + printf("Application: Process %d started.\n", getpid()); + + int i; + omp_set_num_threads(3); + omp_set_max_active_levels(10); + +#pragma omp parallel // parallel region begins + { + printf("outer parallel region Thread ID == %d\n", omp_get_thread_num()); + /* Code for work to be done by outer parallel region threads over here. */ + + if (omp_get_thread_num() == 2) + sleep(1); + +#pragma omp parallel num_threads(2) // nested parallel region + { + /* Code for work to be done by inner parallel region threads over here. */ + printf("inner parallel region thread id %d\n", omp_get_thread_num()); + + // if (omp_get_thread_num() == 1) sleep(1000); + +#pragma omp parallel num_threads(2) // + { + +#pragma omp for + for (i = 0; i < 20; i++) { + // Some independent iterative computation to be done. + printf(""); + ompd_tool_test(0); + } + } + } + } + + // sleep(1000); + + return 0; +} + +// CHECK-NOT: OMPT-OMPD mismatch +// CHECK-NOT: Python Exception +// CHECK-NOT: The program is not being run. diff --git a/openmp/libompd/test/openmp_examples/ompd_bt.c b/openmp/libompd/test/openmp_examples/ompd_bt.c new file mode 100644 index 0000000..60d8c08 --- /dev/null +++ b/openmp/libompd/test/openmp_examples/ompd_bt.c @@ -0,0 +1,48 @@ +// RUN: %gdb-compile 2>&1 | tee %t.compile +// RUN: %gdb-test -x %S/ompd_bt.cmd %t 2>&1 | tee %t.out | FileCheck %s + +#include <omp.h> + +void subdomain(float *x, int istart, int ipoints) { + int i; + + for (i = 0; i < ipoints; i++) + x[istart + i] = 123.456; +} + +void sub(float *x, int npoints) { + int iam, nt, ipoints, istart; + +#pragma omp parallel default(shared) private(iam, nt, ipoints, istart) + { + iam = omp_get_thread_num(); + nt = omp_get_num_threads(); + ipoints = npoints / nt; /* size of partition */ + istart = iam * ipoints; /* starting array index */ + if (iam == nt - 1) /* last thread may do more */ + ipoints = npoints - istart; + subdomain(x, istart, ipoints); + } +} + +int main() { + + omp_set_num_threads(5); + float array[10000]; + + sub(array, 10000); + + return 0; +} + +// CHECK: Loaded OMPD lib successfully! + +// CHECK: Enabled filter for "bt" output successfully. +// CHECK-NOT: {{__kmp.*}} + +// CHECK: Disabled filter for "bt" output successfully +// CHECK: {{__kmp.*}} + +// CHECK-NOT: Python Exception +// CHECK-NOT: The program is not being run. +// CHECK-NOT: No such file or directory diff --git a/openmp/libompd/test/openmp_examples/ompd_bt.cmd b/openmp/libompd/test/openmp_examples/ompd_bt.cmd new file mode 100644 index 0000000..9b8f2c2 --- /dev/null +++ b/openmp/libompd/test/openmp_examples/ompd_bt.cmd @@ -0,0 +1,10 @@ +ompd init +b ompd_bt.c:9 +c +ompd bt on +bt +c +ompd bt off +bt +d 3 +c diff --git a/openmp/libompd/test/openmp_examples/ompd_icvs.c b/openmp/libompd/test/openmp_examples/ompd_icvs.c new file mode 100644 index 0000000..de1c25c --- /dev/null +++ b/openmp/libompd/test/openmp_examples/ompd_icvs.c @@ -0,0 +1,49 @@ +// RUN: %gdb-compile 2>&1 | tee %t.compile +// RUN: env OMP_SCHEDULE=dynamic,2 %gdb-test -x %S/ompd_icvs.cmd %t 2>&1 | tee +// %t.out | FileCheck %s + +#include <omp.h> +#include <stdio.h> +int main(void) { + omp_set_max_active_levels(3); + omp_set_dynamic(0); + omp_set_num_threads(9); +#pragma omp parallel + { + omp_set_num_threads(5); +#pragma omp parallel + { +#pragma omp single + { printf("Inner: num_thds=%d\n", omp_get_num_threads()); } + } +#pragma omp barrier + omp_set_max_active_levels(0); +#pragma omp parallel + { +#pragma omp single + { printf("Inner: num_thds=%d\n", omp_get_num_threads()); } + } +#pragma omp barrier +#pragma omp single + { printf("Outer: num_thds=%d\n", omp_get_num_threads()); } + } + return 0; +} +// CHECK: Loaded OMPD lib successfully! + +// CHECK: run-sched-var task dynamic,2 +// CHECK: levels-var parallel 2 +// CHECK: active-levels-var parallel 2 +// CHECK: team-size-var parallel 5 + +// CHECK: levels-var parallel 2 +// CHECK: active-levels-var parallel 1 +// CHECK: team-size-var parallel 1 + +// CHECK: levels-var parallel 1 +// CHECK: active-levels-var parallel 1 +// CHECK: team-size-var parallel 9 + +// CHECK-NOT: Python Exception +// CHECK-NOT: The program is not being run. +// CHECK-NOT: No such file or directory diff --git a/openmp/libompd/test/openmp_examples/ompd_icvs.cmd b/openmp/libompd/test/openmp_examples/ompd_icvs.cmd new file mode 100644 index 0000000..2b7941c --- /dev/null +++ b/openmp/libompd/test/openmp_examples/ompd_icvs.cmd @@ -0,0 +1,14 @@ +ompd init +b ompd_icvs.c:17 +b ompd_icvs.c:24 +b ompd_icvs.c:28 +c +ompd icvs +d 3 +c +ompd icvs +d 4 +c +ompd icvs +d 5 +c diff --git a/openmp/libompd/test/openmp_examples/ompd_parallel.c b/openmp/libompd/test/openmp_examples/ompd_parallel.c new file mode 100644 index 0000000..c0cb35f --- /dev/null +++ b/openmp/libompd/test/openmp_examples/ompd_parallel.c @@ -0,0 +1,45 @@ +// RUN: %gdb-compile 2>&1 | tee %t.compile +// RUN: %gdb-test -x %S/ompd_parallel.cmd %t 2>&1 | tee %t.out | FileCheck %s + +#include <omp.h> +#include <stdio.h> + +int main() { + omp_set_max_active_levels(3); + omp_set_num_threads(7); +#pragma omp parallel + { + omp_set_num_threads(5); +#pragma omp parallel + { + omp_set_num_threads(3); +#pragma omp parallel + { printf("In nested level:3, team size = %d.\n", omp_get_num_threads()); } + + printf("In nested level:2, team size = %d.\n", omp_get_num_threads()); + } + printf("In nested level:1, team size = %d.\n", omp_get_num_threads()); + } + + return 0; +} + +// CHECK: Loaded OMPD lib successfully! +// CHECK: Nesting Level 3: Team Size: 3 +// CHECK: ompd_parallel.c{{[ ]*}}:16 +// CHECK: Nesting Level 2: Team Size: 5 +// CHECK: ompd_parallel.c{{[ ]*}}:13 +// CHECK: Nesting Level 1: Team Size: 7 +// CHECK: ompd_parallel.c{{[ ]*}}:10 + +// CHECK: Nesting Level 2: Team Size: 5 +// CHECK: ompd_parallel.c{{[ ]*}}:13 +// CHECK: Nesting Level 1: Team Size: 7 +// CHECK: ompd_parallel.c{{[ ]*}}:10 + +// CHECK: Nesting Level 1: Team Size: 7 +// CHECK: ompd_parallel.c{{[ ]*}}:10 + +// CHECK-NOT: Python Exception +// CHECK-NOT: The program is not being run. +// CHECK-NOT: No such file or directory diff --git a/openmp/libompd/test/openmp_examples/ompd_parallel.cmd b/openmp/libompd/test/openmp_examples/ompd_parallel.cmd new file mode 100644 index 0000000..6186ff7 --- /dev/null +++ b/openmp/libompd/test/openmp_examples/ompd_parallel.cmd @@ -0,0 +1,14 @@ +ompd init +b ompd_parallel.c:17 +b ompd_parallel.c:19 +b ompd_parallel.c:21 +c +ompd parallel +d 3 +c +ompd parallel +d 4 +c +ompd parallel +d 5 +c diff --git a/openmp/libompd/test/openmp_examples/parallel.c b/openmp/libompd/test/openmp_examples/parallel.c new file mode 100644 index 0000000..2e7a66c --- /dev/null +++ b/openmp/libompd/test/openmp_examples/parallel.c @@ -0,0 +1,26 @@ +// RUN: %gdb-compile-and-run 2>&1 | tee %t.out | FileCheck %s + +#include "../ompt_plugin.h" +#include <stdio.h> +#include <stdlib.h> + +int main(int argc, char **argv) { + int n = 5; + if (argc > 1) + n = atoi(argv[1]); + int i = 0; + int a[1000]; +#pragma omp parallel for + for (i = 0; i < 100; ++i) { +#pragma omp task + { + a[i] = 42; + ompd_tool_test(0); + } + } + return 0; +} + +// CHECK-NOT: OMPT-OMPD mismatch +// CHECK-NOT: Python Exception +// CHECK-NOT: The program is not being run. diff --git a/openmp/libompd/test/test.cmd b/openmp/libompd/test/test.cmd new file mode 100644 index 0000000..4dbbb94 --- /dev/null +++ b/openmp/libompd/test/test.cmd @@ -0,0 +1,3 @@ +ompd init +continue +quit
\ No newline at end of file |