Page MenuHomePhabricator

[OpenMP 5.0] Fix user-defined mapper privatization in tasks
ClosedPublic

Authored by ABataev on Jul 23 2020, 3:51 PM.

Details

Summary

This patch fixes the problem that user-defined mapper array is not correctly privatized inside a task. This problem causes openmp/libomptarget/test/offloading/target_depend_nowait.cpp fails.

Diff Detail

Event Timeline

lildmh created this revision.Jul 23 2020, 3:51 PM
grokos added a subscriber: grokos.Jul 23 2020, 4:33 PM

I tried the patch and indeed it fixes the problem with target_depend_nowait.cpp. I'll let someone else do the review though.

I'm not enough invested in the compiler implementation to judge this patch.
I can confirm that this patch fixes the segmentation fault I have seen.

Are these tests supposed to work for offloading to nvidia GPU as well?
I tried and added:

// RUN: %libomptarget-compilexx-run-and-check-nvptx64-nvidia-cuda

which gives me:

ptxas /tmp/target_depend_nowait-37c5c4.s, line 355; error   : Call has wrong number of parameters
ptxas /tmp/target_depend_nowait-37c5c4.s, line 628; error   : Call has wrong number of parameters
ptxas /tmp/target_depend_nowait-37c5c4.s, line 2331; warning : Instruction 'vote' without '.sync' may produce unpredictable results on sm_70 and later architectures
ptxas /tmp/target_depend_nowait-37c5c4.s, line 2331; warning : Instruction 'vote' without '.sync' is deprecated since PTX ISA version 6.0 and will be discontinued in a future PTX ISA version
ptxas fatal   : Ptx assembly aborted due to errors

I guess this error is not directly related to your patch?

clang/lib/CodeGen/CGOpenMPRuntime.cpp
10524

Does this mean, that a task is only created if depend clauses are provided?
Does waiting with taskwait work without this wrapper task?

lildmh marked an inline comment as done.Jul 24 2020, 8:29 AM

The problem you had is probably not related to this patch. A lot of libomptarget tests are not working for nvptx now. I suppose someone is going to fix them.

clang/lib/CodeGen/CGOpenMPRuntime.cpp
10524

The case you describe, which is to have a task wrapped around target, is solved with modification on line 9592
This part is to deal with other cases, which is consistent with line 10455 if you look a bit further

ABataev added inline comments.Jul 27 2020, 8:47 AM
clang/lib/CodeGen/CGOpenMPRuntime.cpp
8915

Do you really need this IsTask flag? The array is created always when Info.NumberOfPtrs > 0. Maybe, just do not check for HasMapper here?

10524

Better to add a flag RequiresOuterTask = D.hasClausesOfKind<OMPDependClause>() and use it here and where the task is generated (line 10455)

lildmh marked 2 inline comments as done.Jul 27 2020, 10:51 AM
lildmh added inline comments.
clang/lib/CodeGen/CGOpenMPRuntime.cpp
8915

This is an optimization. The mapper array can be optimized out when there is no actual mappers, so supposed to have less memory accesses in this common case. Not checking HasMapper will disable this optimization.

10524

Sure, please accept this patch after that.

ye-luo added a subscriber: ye-luo.Aug 13 2020, 3:00 PM

What is the current status of this patch?
@lildmh could you update this patch? I'd like to test it against
https://bugs.llvm.org/show_bug.cgi?id=47122

Add a test

@ABataev did you ask for a codegen test, or is the runtime test openmp/libomptarget/test/offloading/target_depend_nowait.cpp enough?
The test fails without this patch and succeeds with this patch.

Add a test

@ABataev did you ask for a codegen test, or is the runtime test openmp/libomptarget/test/offloading/target_depend_nowait.cpp enough?
The test fails without this patch and succeeds with this patch.

Yes, I know that it fails, but each functional change in the frontend must have the corresponding test in clang itself.

I'll add a test to it. Please give me some time as I am busy with other stuffs.

It looks like @lildmh is not able to provide a test any time soon. @grokos Could you take over this mapper patch as well? I think the current segfault state is rather unfortunate.

i applied this patch to our downstream build for amdgcn. it resolves the problem i was seeing with traps on tests with task wait depend tests from sollve.
perhaps rebase it to latest llvm.

I can update this patch in a week when I'm back from vacation.

[AMD Official Use Only - Internal Distribution Only]

Hi Alexey
Any ETA on this one ?

Get Outlook for iOShttps://aka.ms/o0ukef


From: Alexey Bataev via Phabricator <reviews@reviews.llvm.org>
Sent: Tuesday, September 8, 2020 1:39:06 PM
To: lildmh@gmail.com <lildmh@gmail.com>; protze.joachim@gmail.com <protze.joachim@gmail.com>; jdoerfert@anl.gov <jdoerfert@anl.gov>; a.bataev@hotmail.com <a.bataev@hotmail.com>
Cc: Lieberman, Ron <Ron.Lieberman@amd.com>; xw111luoye@gmail.com <xw111luoye@gmail.com>; georgios.rokos@intel.com <georgios.rokos@intel.com>; Liu, Yaxun (Sam) <Yaxun.Liu@amd.com>; zhang.guansong@gmail.com <zhang.guansong@gmail.com>; stefomeister@gmail.com <stefomeister@gmail.com>
Subject: [PATCH] D84470: [OpenMP 5.0] Fix user-defined mapper privatization in tasks

[CAUTION: External Email]

ABataev added a comment.

I can update this patch in a week when I'm back from vacation.

CHANGES SINCE LAST ACTION

https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Freviews.llvm.org%2FD84470%2Fnew%2F&amp;data=02%7C01%7Cron.lieberman%40amd.com%7C6582a2f2d31d4bbf9b4a08d8541e16cb%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637351835496784231&amp;sdata=8%2BJbFULmzVN%2FdafC0QYX%2B9LwN7d1HFZ9Qxt6k4y85%2FA%3D&amp;reserved=0

https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Freviews.llvm.org%2FD84470&amp;data=02%7C01%7Cron.lieberman%40amd.com%7C6582a2f2d31d4bbf9b4a08d8541e16cb%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637351835496794187&amp;sdata=gyj3%2B4K3oPlvedNjOzbsnosciYUIxuTOoKq%2BsfnsAOQ%3D&amp;reserved=0

Hi Ron, hope to prepare it by the end of this week, maybe earlier, if everything goes well. I have some technical issues, but anyway will update the patch and the tests.

ABataev commandeered this revision.Sep 16 2020, 1:31 PM
ABataev edited reviewers, added: lildmh; removed: ABataev.
ABataev updated this revision to Diff 292330.Sep 16 2020, 1:32 PM

Updated + added clang test.

Herald added a project: Restricted Project. · View Herald TranscriptSep 16 2020, 1:32 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript

The latest patch applied cleanly to our downstream port.
builds fine, tests very nicely as well. All the failing SOLLVE task wait depend tests now pass.

The latest patch applied cleanly to our downstream port.
builds fine, tests very nicely as well. All the failing SOLLVE task wait depend tests now pass.

Could you accept it then?

ronlieb accepted this revision.Sep 17 2020, 6:21 AM

accepted. not sure if there were any outstanding comments from Johannes. your call

This revision is now accepted and ready to land.Sep 17 2020, 6:21 AM
This revision was landed with ongoing or failed builds.Sep 17 2020, 8:22 AM
This revision was automatically updated to reflect the committed changes.