-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #371 from SOLLVE/fix_issue_81_pt4
Adding 3 new .F90 tests per issue #81 and fixing related .c files - pt 4
- Loading branch information
Showing
4 changed files
with
204 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
!===--- test_target_parallel.F90 --------------------------------------------===// | ||
! | ||
! OpenMP API Version 4.5 Nov 2015 | ||
! | ||
! This test checks for the combined construct target and parallel. It | ||
! creates a parallel region inside of the target devices. | ||
! | ||
!===-------------------------------------------------------------------------===// | ||
|
||
#include "ompvv.F90" | ||
|
||
#define N 1024 | ||
|
||
PROGRAM test_target_parallel | ||
USE iso_fortran_env | ||
USE ompvv_lib | ||
USE omp_lib | ||
implicit none | ||
|
||
OMPVV_TEST_OFFLOADING | ||
|
||
OMPVV_TEST_VERBOSE(target_parallel() .ne. 0) | ||
|
||
OMPVV_REPORT_AND_RETURN() | ||
|
||
CONTAINS | ||
INTEGER FUNCTION target_parallel() | ||
INTEGER :: errors, i, summation | ||
INTEGER, DIMENSION(OMPVV_NUM_THREADS_DEVICE) :: thread_id | ||
CHARACTER(len=400) :: threadMsg | ||
errors = 0 | ||
|
||
DO i = 1, OMPVV_NUM_THREADS_DEVICE | ||
thread_id(i) = 0 | ||
END DO | ||
|
||
!$omp target parallel num_threads(OMPVV_NUM_THREADS_DEVICE) map(from: summation, thread_id) | ||
thread_id(omp_get_thread_num() + 1) = omp_get_num_threads() | ||
!$omp end target parallel | ||
|
||
|
||
OMPVV_WARNING_IF(thread_id(1) .eq. 1, "The number of threads in the parallel region was 1. & | ||
&This is not a specifications error but we could not confirm the parallel region.") | ||
|
||
DO i = 1, thread_id(1) | ||
OMPVV_TEST_AND_SET(errors, thread_id(i) .ne. thread_id(1)) | ||
WRITE (threadMsg, *) "The number of threads recorded by thread", i, & | ||
& " was", thread_id(i), ". Expected was", thread_id(1) | ||
OMPVV_INFOMSG(threadMsg) | ||
END DO | ||
|
||
target_parallel = errors | ||
END FUNCTION target_parallel | ||
END PROGRAM test_target_parallel | ||
|
75 changes: 75 additions & 0 deletions
75
...get_teams_distribute_parallel_for/test_target_teams_distribute_parallel_for_num_teams.F90
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
!===-- test_target_teams_distribute_parallel_for_num_teams.F90 ------------===// | ||
! | ||
! OpenMP API Version 4.5 Nov 2015 | ||
! | ||
! Test to check the num_teams clause. This clause changes the upper limit of | ||
! the number of teams inside the target teams region. | ||
! | ||
!===-------------------------------------------------------------------------===// | ||
|
||
#include "ompvv.F90" | ||
#define N 1024 | ||
|
||
PROGRAM test_target_teams_distribute_parallel_for_num_teams | ||
USE iso_fortran_env | ||
USE ompvv_lib | ||
USE omp_lib | ||
implicit none | ||
|
||
OMPVV_TEST_VERBOSE(target_teams_distribute_parallel_for_num_teams() .ne. 0) | ||
|
||
OMPVV_REPORT_AND_RETURN() | ||
|
||
CONTAINS | ||
INTEGER FUNCTION target_teams_distribute_parallel_for_num_teams() | ||
INTEGER :: errors, i, nt, raiseWarningOneTeam, raiseWarningDifNum, prevNumTeams | ||
INTEGER, DIMENSION(4) :: tested_num_teams = (/1, 10, 100, 10000/) | ||
INTEGER, DIMENSION(N) :: num_teams | ||
CHARACTER(len=400) :: numTeamsMsg, difNumReportedMsg, difNumTeamsMsg | ||
errors = 0 | ||
i = 0 | ||
raiseWarningOneTeam = 0 | ||
|
||
DO nt = 1, 4 | ||
WRITE(numTeamsMsg, *) "Testing for num_teams(", tested_num_teams(nt), ")" | ||
OMPVV_INFOMSG(numTeamsMsg) | ||
|
||
! initialize the num_teams array | ||
DO i = 1, N | ||
num_teams(i) = -1 | ||
END DO | ||
|
||
!$omp target teams distribute parallel do map(tofrom: num_teams) num_teams(tested_num_teams(nt)) | ||
DO i = 1, N | ||
num_teams(i) = omp_get_num_teams() | ||
END DO | ||
|
||
raiseWarningDifNum = 0 | ||
prevNumTeams = -1 | ||
|
||
DO i = 1, N | ||
WRITE(difNumReportedMsg, *) num_teams(i), "teams reported" | ||
OMPVV_INFOMSG_IF(prevNumTeams .ne. num_teams(i), difNumReportedMsg) | ||
prevNumTeams = num_teams(i) | ||
OMPVV_TEST_AND_SET(errors, num_teams(i) .le. 0 .or. (num_teams(i) .gt. tested_num_teams(nt))) | ||
IF (num_teams(i) .ne. tested_num_teams(nt)) THEN | ||
raiseWarningDifNum = 1 | ||
END IF | ||
IF (num_teams(i) == 1) THEN | ||
raiseWarningOneTeam = raiseWarningOneTeam + 1 | ||
END IF | ||
END DO | ||
|
||
!We want to raise a warning when the number of teams does not match the desired value | ||
WRITE(difNumTeamsMsg, *) "When testing for num_teams(", tested_num_teams(nt), "), the actual & | ||
&number of teams was different. Not a compliance error with the specification." | ||
OMPVV_WARNING_IF(raiseWarningDifNum .ne. 0, difNumTeamsMsg) | ||
END DO | ||
|
||
OMPVV_WARNING_IF(raiseWarningOneTeam .eq. 4*N, "The num_teams clause always resulted in a single team. Although & | ||
&this is compliant with the specification, it is not expected.") | ||
|
||
target_teams_distribute_parallel_for_num_teams = errors | ||
END FUNCTION target_teams_distribute_parallel_for_num_teams | ||
END PROGRAM test_target_teams_distribute_parallel_for_num_teams | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
!===--- test_target_update_from.F90 -----------------------------------------===// | ||
! | ||
! OpenMP API Version 4.5 Nov 2015 | ||
! | ||
! This test checks the target update motion clause 'from' by mapping an array | ||
! to the device with map-type 'to', changing the values of array on the device, | ||
! and finally using the update 'from' motion clause to assign the value of the | ||
! list item. Back on the host, measures are taken to ensure the value was properly | ||
! updated. | ||
! | ||
!===-------------------------------------------------------------------------===// | ||
|
||
#include "ompvv.F90" | ||
|
||
#define N 1024 | ||
|
||
PROGRAM test_target_update_from | ||
USE iso_fortran_env | ||
USE ompvv_lib | ||
USE omp_lib | ||
implicit none | ||
|
||
OMPVV_TEST_OFFLOADING | ||
|
||
OMPVV_TEST_VERBOSE(target_update_from() .ne. 0) | ||
|
||
OMPVV_REPORT_AND_RETURN() | ||
|
||
CONTAINS | ||
INTEGER FUNCTION target_update_from() | ||
INTEGER :: errors, i | ||
INTEGER, DIMENSION(N) :: a, b, c | ||
errors = 0 | ||
i = 0 | ||
|
||
DO i = 1, N | ||
a(i) = 10 | ||
b(i) = 2 | ||
c(i) = 0 | ||
END DO | ||
|
||
!$omp target enter data map(to: a, b) | ||
!$omp target | ||
DO i = 1, N | ||
b(i) = (a(i) + b(i)) | ||
END DO | ||
!$omp end target | ||
|
||
!$omp target update from(b) | ||
|
||
DO i = 1, N | ||
OMPVV_TEST_AND_SET_VERBOSE(errors, b(i) .ne. 12) | ||
END DO | ||
|
||
!$omp target | ||
DO i = 1, N | ||
c(i) = (2 * b(i)) | ||
END DO | ||
!$omp end target | ||
|
||
DO i = 1, N | ||
OMPVV_TEST_AND_SET_VERBOSE(errors, c(i) .ne. 24) | ||
END DO | ||
|
||
target_update_from = errors | ||
|
||
END FUNCTION target_update_from | ||
END PROGRAM test_target_update_from |