This is an archive of the discontinued LLVM Phabricator instance.

[OpenMP] Fix affinity API for KMP_AFFINITY=none|compact|scatter
ClosedPublic

Authored by jlpeyton on Apr 11 2018, 10:14 AM.

Details

Summary

Currently, the affinity API reports garbage for the initial place list and any
thread's place lists when using KMP_AFFINITY=none|compact|scatter.
This patch does two things:

  1. for KMP_AFFINITY=none, Creates a one entry table for the places, this way, the initial place list is just a single place with all the proc ids in it. We also set the initial place of any thread to 0 instead of KMP_PLACE_ALL so that the thread reports that single place (place 0) instead of garbage (-1) when using the affinity API.
  1. When non-OMP_PROC_BIND affinity is used (including KMP_AFFINITY=compact|scatter), a thread's place list is populated correctly. We assume that each thread is assigned to a single place. This is implemented in two of the affinity API functions

Diff Detail

Repository
rOMP OpenMP

Event Timeline

jlpeyton created this revision.Apr 11 2018, 10:14 AM
This revision is now accepted and ready to land.Apr 11 2018, 12:43 PM
This revision was automatically updated to reflect the committed changes.
twoh added a subscriber: twoh.Apr 24 2018, 11:40 PM

Hello @jlpeyton @tlwilmar, is there a chance that this breaks runtime/test/ompt/misc/api_calls_from_other_thread.cpp test? ompt_get_num_places() is expected to return 0 from the test but with this patch it returns 1, and I think it is because kmp_affinity_num_masks is set to 1 from kmp_create_affinity_none_places().

Hello @jlpeyton @tlwilmar, is there a chance that this breaks runtime/test/ompt/misc/api_calls_from_other_thread.cpp test? ompt_get_num_places() is expected to return 0 from the test but with this patch it returns 1, and I think it is because kmp_affinity_num_masks is set to 1 from kmp_create_affinity_none_places().

Yes, I will fix this. Thanks for pointing it out!