This is an archive of the discontinued LLVM Phabricator instance.

[openmp-target-tests] OpenMP 4.5 Target data test cases
Needs ReviewPublic

Authored by sergiop on Jun 27 2017, 11:06 AM.

Details

Summary

This patch contains test cases for offloading in openmp 4.5. Specifically, these test cases cover the 'target data' construct.

test_target_data_if.c
test_target_data_map_array_sections.c
test_target_data_use_device_ptr.c
test_target_data_map.c
test_target_data_map_classes.cpp
test_target_data_map_devices.c

Diff Detail

Event Timeline

sergiop created this revision.Jun 27 2017, 11:06 AM
Hahnfeld added subscribers: jlpeyton, Hahnfeld.

Hi,

I don't see any new files...? I'm also not entirely sure that we should have Fortran tests? @jlpeyton

The changes to offloading_success.{c,cpp} are already in the tree, please rebase your changes to the latest commit.
Phabricator say "Context not available". Did you generate the patches with the -U option? See http://llvm.org/docs/Phabricator.html#requesting-a-review-via-the-web-interface

Regards,
Jonas

sergiop updated this revision to Diff 104506.Jun 28 2017, 2:08 PM

Hi Jonas,

Thank you for the comments. I generated again the patch following your comments.

Best regards,

Sergio

Hahnfeld edited edge metadata.Jun 29 2017, 4:11 AM

Thank you for the comments. I generated again the patch following your comments.

Now the patch looks like the changes done by clang-format to already existing tests?

sergiop updated this revision to Diff 104925.Jun 30 2017, 1:48 PM

Jonas,

I squashed all the commits into one. Now, I see that Diff has the creation of the new files.

Let me know if this patch works.

Best

sergiop retitled this revision from OpenMP 4.5 Target data test cases to [openmp-target-tests] OpenMP 4.5 Target data test cases.Jul 5 2017, 11:04 AM

Hi Jonas

Did you have further comments on this commit?

Thanks
Sunita

Jonas,

I squashed all the commits into one. Now, I see that Diff has the creation of the new files.

Let me know if this patch works.

Best

Jonas,

I squashed all the commits into one. Now, I see that Diff has the creation of the new files.

Let me know if this patch works.

Best

Jonas,

I squashed all the commits into one. Now, I see that Diff has the creation of the new files.

Let me know if this patch works.

Best

Hi Jonas

Did you have further comments on this commit?

Thanks
Sunita

Sorry that it's taken so long! Still not sure about the Fortran test as clang will currently not be able to handle this.

Additionally, these tests currently won't pass because omp_is_initial_device() will return 1 when offloading to the host, correct? See D35719 why we had to disable libomptarget for 5.0.

Find some more comments inline. In general, the tests should be brought to a consistent coding style (braces, end-comments, comment style and so on).

libomptarget/test/offloading/target_data/test_target_data_map.c
28

Please, add braces here. This is really hard to read and the style must be consistent accross the tests.

(The same applies to all other places in this file where this occurrs)

71–74

This does not test to. Did you mean to use += 1?

75

s/data target/target data/

204

s/cheking/checking/

libomptarget/test/offloading/target_data/test_target_data_map_array_sections.c
384

If I remember correctly, this will not force an array of length N. To avoid this misleading information, would you mind changing the signature to int *?

libomptarget/test/offloading/target_data/test_target_data_map_classes.cpp
35

Do we need an object on the heap, does this also work with the stack? If it should, please add another test method to check that.

43–44

I don't really understand the purpose of this test: Wouldn't it be more intuitive if the user hadn't to worry about how the array got there? What would happen if mapping obj->h_array directly, would compiler and runtime perform this work?

libomptarget/test/offloading/target_data/test_target_data_map_devices.c
26–27

I know that this variable allocation on the stack works, but could you change this to a malloc to avoid this rather ugly part of the C language?

131

Does this really work with libomptarget? If so, is this mandated by the standard and do we want to test this?

libomptarget/test/offloading/target_data/test_target_data_use_device_ptr.c
31

array_device[i]?

Hi Jonas

Did you have further comments on this commit?

Thanks
Sunita

Sorry that it's taken so long! Still not sure about the Fortran test as clang will currently not be able to handle this.

Additionally, these tests currently won't pass because omp_is_initial_device() will return 1 when offloading to the host, correct? See D35719 why we had to disable libomptarget for 5.0.

Find some more comments inline. In general, the tests should be brought to a consistent coding style (braces, end-comments, comment style and so on).

Great!! Thanks Jonas, we will fix these shortly.
Sunita

sergiop marked 8 inline comments as done.Aug 13 2017, 1:27 PM

Hi Jonas,

We addressed your comments about the code + removed the fortran file (you're right, sorry about that). I'm submitting an update to the patch.

Thank you for the time. Best

libomptarget/test/offloading/target_data/test_target_data_map_classes.cpp
43–44

Unfortunately, the mapping is a shallow copy of the object. This means that the address of the array is not translated automatically.

libomptarget/test/offloading/target_data/test_target_data_map_devices.c
131

In the spec there is not restriction about assigning computation/data movement to a device that has an id higher than the number of actual devices.

sergiop updated this revision to Diff 110892.EditedAug 13 2017, 1:33 PM
sergiop marked 2 inline comments as done.
sergiop edited the summary of this revision. (Show Details)

Updated the patch with respect to the comments. Special focus on: 1) not using omp_is_initial_device as a condition to fail or pass, 2) removing fortran files, 3) consistent style.

test_target_data_if.c
test_target_data_map_array_sections.c
test_target_data_use_device_ptr.c
test_target_data_map.c
test_target_data_map_classes.cpp
test_target_data_map_devices.c

  1. Is there as specific reason for using both puts and printf? There are also calls to printf without formatting arguments...
  2. Do these tests actually pass with a current version of clang?
libomptarget/test/offloading/target_data/test_target_data_if.c
38–40

Again thinking about this, the check may be wrong: The OpenMP standard says that the target data and target constructs execute on the host, if the if clause evaluates to false. This check is assuming that it doesn't execute at all, right?

libomptarget/test/offloading/target_data/test_target_data_map_array_sections.c
428

Please change this signature as well.

435

Same

libomptarget/test/offloading/target_data/test_target_data_map_devices.c
131

"The device expression must evaluate to a non-negative integer value less than the value of omp_get_num_devices()."
OpenMP 4.5, p. 97

Hahnfeld requested changes to this revision.Nov 1 2017, 2:11 PM
This revision now requires changes to proceed.Nov 1 2017, 2:11 PM
AndreyChurbanov added inline comments.
libomptarget/test/offloading/target_data/test_target_data_if.c
38–40

This check looks like a dead code. The size gets three values - 256 to execute on host, 512 and 758 to execute on device. Neither of these values is less than 256, so (size < 256) is the same as false.

Maybe the intention was to check all 1024 values, and zeros should hold for (i >= size).

This revision now requires review to proceed.Mar 30 2021, 10:14 AM