This is an archive of the discontinued LLVM Phabricator instance.

[libomptarget][nfc] Move hostcall required test to rtl
ClosedPublic

Authored by JonChesterfield on May 24 2021, 5:17 PM.

Details

Summary

[libomptarget][nfc] Move hostcall required test to rtl

Remove a global, fix minor race. First of N patches to bring up hostcall.

Diff Detail

Event Timeline

JonChesterfield requested review of this revision.May 24 2021, 5:17 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 24 2021, 5:17 PM

Hostcall exists as a libraries in rocm, aomp and my github. Trunk has hooks - mostly weak symbols - to allow the host plugin source to work with or without it present.

The variable that is checked for (before and after this change) is introduced by a common variable in the GPU entry point for hostcalls. The idea is to only spin up the thread(s) associated with hostcall if the GPU will use it.

__asm__("; hostcall_invoke: record need for hostcall support\n\t"
        ".type needs_hostcall_buffer,@object\n\t"
        ".global needs_hostcall_buffer\n\t"
        ".comm needs_hostcall_buffer,4":::);

This removes one of the remaining uses of the symbol info table.

Side point on races - I think it is possible for one thread to start loading a binary, get immediately suspended, and a second thread to then launch a kernel that is supposed to come from that binary. The locking scheme in this plugin probably doesn't handle that. Hopefully libomptarget does have locking that makes that work, otherwise the cuda plugin is probably also racy.

foad removed a subscriber: foad.May 25 2021, 1:59 AM
JonChesterfield added a comment.EditedMay 25 2021, 5:48 AM

Was reviewed on aomp, will wait a little while before landing this to match.

Edit: though this is NFC on trunk, after landing here it'll reach rocm, where it will be tested by the usual pipeline

JonChesterfield accepted this revision.May 25 2021, 2:43 PM
This revision is now accepted and ready to land.May 25 2021, 2:43 PM
This revision was landed with ongoing or failed builds.May 25 2021, 2:47 PM
This revision was automatically updated to reflect the committed changes.

Your commit message looks like

commit df005fa364ae3914231f98f80acc120fcf782c26
Author: Jon Chesterfield <jonathanchesterfield@gmail.com>
Date:   Tue May 25 22:43:16 2021 +0100

    [libomptarget][nfc] Move hostcall required test to rtl

    [libomptarget][nfc] Move hostcall required test to rtl

    Remove a global, fix minor race. First of N patches to bring up hostcall.

    Reviewed By: JonChesterfield

    Differential Revision: https://reviews.llvm.org/D103058

Notice the duplicate subject line? This appears to be a recurring issue with your commits, so it might be something in your workflow?

JonChesterfield added a comment.EditedMay 25 2021, 3:16 PM

Thanks for pointing it out! I was under the impression that the contents of 'Summary' as shown in Phabricator turns into the commit message.

Looks like the commit message I'm creating is the title from phabricator, then a newline, then the summary, so the workflow change is probably to write less in the Summary field.

I'm committing a patch by:

git checkout main && git reset --hard origin/main && git pull # clean slate
arc patch D1000
git checkout main
git cherry-pick D1000
git log -n2 # eyeball it
git push

combined with creating patches with arc diff, I think the failure mode must be in my use of arcanist.

Edited the WIP diffs to, I hope, avoid continuing in this pattern.