From 5feb30ef3c9b694647c9868643f24802f606e8d6 Mon Sep 17 00:00:00 2001 From: Andrew Kallai Date: Thu, 14 Nov 2024 12:43:44 -0500 Subject: [PATCH 1/4] Adding test for assumes directive with no_openmp_constructs clause. --- .../assumes/test_assumes_noopenmpconstructs.c | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 tests/6.0/assumes/test_assumes_noopenmpconstructs.c diff --git a/tests/6.0/assumes/test_assumes_noopenmpconstructs.c b/tests/6.0/assumes/test_assumes_noopenmpconstructs.c new file mode 100644 index 000000000..c3c174798 --- /dev/null +++ b/tests/6.0/assumes/test_assumes_noopenmpconstructs.c @@ -0,0 +1,31 @@ +//-------------- test_assumes_noopenmpconstructs.c----------------------------------// +// OpenMP API Version 6.0 November 2024 +// Pg. 900, line 22 +// *********** +// DIRECTIVE:assumes +// CLAUSE:no_openmp_constructs +// *********** +// The no_openmp_constructs clause is used to guarantee that the section of code +// which applies to the assumes directive does not contain any OpenMP constructs. +//----------------------------------------------------------------------------// +#include "ompvv.h" + +#define N 4 + +int test_assumes_no_openmp_constructs() { + int A[4][N] = {0}; + int errors = 0; + + #pragma omp assumes + { + } + + return errors; +} + +int main() { + int errors = 0; + OMPVV_TEST_AND_SET(errors, test_assumes_no_openmp_constructs() != 0); + OMPVV_REPORT_AND_RETURN(errors); + return errors; +} From 7ffba44af6608437a75d2af5d819e0c2d9f4a568 Mon Sep 17 00:00:00 2001 From: Andrew Kallai Date: Thu, 14 Nov 2024 13:12:54 -0500 Subject: [PATCH 2/4] Added no_openmp_constructs clause into the code. --- tests/6.0/assumes/test_assumes_noopenmpconstructs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/6.0/assumes/test_assumes_noopenmpconstructs.c b/tests/6.0/assumes/test_assumes_noopenmpconstructs.c index c3c174798..b3c7c8fc7 100644 --- a/tests/6.0/assumes/test_assumes_noopenmpconstructs.c +++ b/tests/6.0/assumes/test_assumes_noopenmpconstructs.c @@ -7,17 +7,17 @@ // *********** // The no_openmp_constructs clause is used to guarantee that the section of code // which applies to the assumes directive does not contain any OpenMP constructs. -//----------------------------------------------------------------------------// +//---------------------------------------------------------------------------------// #include "ompvv.h" #define N 4 int test_assumes_no_openmp_constructs() { - int A[4][N] = {0}; int errors = 0; - #pragma omp assumes + #pragma omp assume no_openmp_constructs(1) { + } return errors; From 4cfe1428bae1d21620d5763daf190f0527c910bf Mon Sep 17 00:00:00 2001 From: Andrew Kallai Date: Thu, 14 Nov 2024 14:07:12 -0500 Subject: [PATCH 3/4] Added testing functionality to check for use with and without the clause argument being true. --- .../assume/test_assume_noopenmpconstructs.c | 81 +++++++++++++++++++ .../assumes/test_assumes_noopenmpconstructs.c | 31 ------- 2 files changed, 81 insertions(+), 31 deletions(-) create mode 100644 tests/6.0/assume/test_assume_noopenmpconstructs.c delete mode 100644 tests/6.0/assumes/test_assumes_noopenmpconstructs.c diff --git a/tests/6.0/assume/test_assume_noopenmpconstructs.c b/tests/6.0/assume/test_assume_noopenmpconstructs.c new file mode 100644 index 000000000..df25f65dd --- /dev/null +++ b/tests/6.0/assume/test_assume_noopenmpconstructs.c @@ -0,0 +1,81 @@ +//--------------test_assume_noopenmpconstructs.c----------------------------------// +// OpenMP API Version 6.0 November 2024 +// Pg. 900, line 22 +// *********** +// DIRECTIVE:assume +// CLAUSE:no_openmp_constructs +// *********** +// The no_openmp_constructs clause is used to guarantee that the section of code +// which applies to the assumes directive does not contain any OpenMP +// constructs. The argument supplied to the clause is the "can_assume" int +// variable. If the variable is 1, the no_openmp_constructs assumes that the +// assumption is true. If the variable is 0, the clause assumes that the +// assumption is false. If the argument is not specified (void) then the default +// assumption is true. If the clause is working correctly, then the array A will +// be updated with the expected values and the sum of those values will be +// checked for correctness. +//---------------------------------------------------------------------------------// +#include "ompvv.h" + +#define N 10 + +int test_assumes_no_openmp_constructs() { + int A[N] = {0}; + int errors = 0, sum = 0, can_assume = 0; + int i; + + #pragma omp assume no_openmp_constructs(can_assume) + { + for (i = 0; i < N; ++i) { + A[i] = i + 1; + } + } + + for (i = 0; i < N; ++i) { + sum += A[i]; + A[i] = 0; + } + + if (sum != N * (N + 1) / 2) + ++errors; + + sum = 0; + can_assume = 1; + #pragma omp assume no_openmp_constructs(can_assume) + { + for (i = 0; i < N; ++i) { + A[i] = 2 * (i + 1); + } + } + + for (i = 0; i < N; ++i) { + sum += A[i]; + A[i] = 0; + } + if (sum != 2 * N * (N + 1) / 2) + ++errors; + + sum = 0; + #pragma omp assume no_openmp_constructs(void) + { + for (i = 0; i < N; ++i) { + A[i] = 3 * (i + 1); + } + } + + for (i = 0; i < N; ++i) { + sum += A[i]; + } + + if (sum != 3 * N * (N + 1) / 2) + ++errors; + + return errors; +} + +int main() { + int errors = 0; + OMPVV_TEST_AND_SET(errors, test_assumes_no_openmp_constructs() != 0); + OMPVV_REPORT_AND_RETURN(errors); + return errors; +} diff --git a/tests/6.0/assumes/test_assumes_noopenmpconstructs.c b/tests/6.0/assumes/test_assumes_noopenmpconstructs.c deleted file mode 100644 index b3c7c8fc7..000000000 --- a/tests/6.0/assumes/test_assumes_noopenmpconstructs.c +++ /dev/null @@ -1,31 +0,0 @@ -//-------------- test_assumes_noopenmpconstructs.c----------------------------------// -// OpenMP API Version 6.0 November 2024 -// Pg. 900, line 22 -// *********** -// DIRECTIVE:assumes -// CLAUSE:no_openmp_constructs -// *********** -// The no_openmp_constructs clause is used to guarantee that the section of code -// which applies to the assumes directive does not contain any OpenMP constructs. -//---------------------------------------------------------------------------------// -#include "ompvv.h" - -#define N 4 - -int test_assumes_no_openmp_constructs() { - int errors = 0; - - #pragma omp assume no_openmp_constructs(1) - { - - } - - return errors; -} - -int main() { - int errors = 0; - OMPVV_TEST_AND_SET(errors, test_assumes_no_openmp_constructs() != 0); - OMPVV_REPORT_AND_RETURN(errors); - return errors; -} From d1808be4a06aa8b8674ee50e862301c861b178b5 Mon Sep 17 00:00:00 2001 From: Andrew Kallai Date: Thu, 6 Feb 2025 13:27:16 -0500 Subject: [PATCH 4/4] Added openmp construct and removed void. --- tests/6.0/assume/test_assume_noopenmpconstructs.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/6.0/assume/test_assume_noopenmpconstructs.c b/tests/6.0/assume/test_assume_noopenmpconstructs.c index df25f65dd..48fdb8a16 100644 --- a/tests/6.0/assume/test_assume_noopenmpconstructs.c +++ b/tests/6.0/assume/test_assume_noopenmpconstructs.c @@ -10,7 +10,7 @@ // constructs. The argument supplied to the clause is the "can_assume" int // variable. If the variable is 1, the no_openmp_constructs assumes that the // assumption is true. If the variable is 0, the clause assumes that the -// assumption is false. If the argument is not specified (void) then the default +// assumption is false. If the argument is not specified (empty) then the default // assumption is true. If the clause is working correctly, then the array A will // be updated with the expected values and the sum of those values will be // checked for correctness. @@ -26,6 +26,7 @@ int test_assumes_no_openmp_constructs() { #pragma omp assume no_openmp_constructs(can_assume) { + #pragma omp parallel for for (i = 0; i < N; ++i) { A[i] = i + 1; } @@ -56,7 +57,7 @@ int test_assumes_no_openmp_constructs() { ++errors; sum = 0; - #pragma omp assume no_openmp_constructs(void) + #pragma omp assume no_openmp_constructs() { for (i = 0; i < N; ++i) { A[i] = 3 * (i + 1);