Skip to content

Commit 507a7ed

Browse files
doru1004ronlieb
authored andcommitted
Enable check-openmp in AOMP.
The way to run the AOMP check-make tests is: cd build/llvm-project AOMP=~/rocm/aomp AOMP_GPU=gfx90a make check-openmp -j32 Change-Id: Icec3bb75cce3c166fc7b6c010028a27ca2fdd6ad
1 parent 893cdfa commit 507a7ed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+284
-67
lines changed

openmp/libomptarget/include/OpenMP/Mapping.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,6 @@ struct HostDataToTargetTy {
7272
const uintptr_t TgtAllocBegin; // allocated target memory
7373
const uintptr_t TgtPtrBegin; // mapped target memory = TgtAllocBegin + padding
7474

75-
const bool IsUSMAlloc; // used to track maps under USM mode (optional)
76-
7775
private:
7876
static const uint64_t INFRefCount = ~(uint64_t)0;
7977
static std::string refCountToStr(uint64_t RefCount) {
@@ -127,10 +125,9 @@ struct HostDataToTargetTy {
127125
HostDataToTargetTy(uintptr_t BP, uintptr_t B, uintptr_t E,
128126
uintptr_t TgtAllocBegin, uintptr_t TgtPtrBegin,
129127
bool UseHoldRefCount, map_var_info_t Name = nullptr,
130-
bool IsINF = false, bool IsUSMAlloc = false)
128+
bool IsINF = false)
131129
: HstPtrBase(BP), HstPtrBegin(B), HstPtrEnd(E), HstPtrName(Name),
132130
TgtAllocBegin(TgtAllocBegin), TgtPtrBegin(TgtPtrBegin),
133-
IsUSMAlloc(IsUSMAlloc),
134131
States(std::make_unique<StatesTy>(UseHoldRefCount ? 0
135132
: IsINF ? INFRefCount
136133
: 1,

openmp/libomptarget/include/Shared/PluginAPI.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ bool __tgt_rtl_has_USM_capable_dGPU(void);
4242

4343
bool __tgt_rtl_are_allocations_for_maps_on_apus_disabled(void);
4444

45-
bool __tgt_rtl_is_no_maps_check(void);
46-
4745
bool __tgt_rtl_is_fine_grained_memory_enabled(void);
4846

4947
// Set up environement e.g. depending on the values of the env vars

openmp/libomptarget/include/Shared/PluginAPI.inc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ PLUGIN_API_HANDLE(has_apu_device, true);
5353
PLUGIN_API_HANDLE(has_USM_capable_dGPU, true);
5454
PLUGIN_API_HANDLE(are_allocations_for_maps_on_apus_disabled, true);
5555
PLUGIN_API_HANDLE(requested_prepopulate_gpu_page_table, true);
56-
PLUGIN_API_HANDLE(is_no_maps_check, true);
5756
PLUGIN_API_HANDLE(is_fine_grained_memory_enabled, true);
5857
PLUGIN_API_HANDLE(is_system_supporting_managed_memory, true);
5958
PLUGIN_API_HANDLE(number_of_team_procs, true);

openmp/libomptarget/plugins-nextgen/amdgpu/src/rtl.cpp

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -848,9 +848,16 @@ struct AMDGPUKernelTy : public GenericKernelTy {
848848
ThreadLimitClause[0] += GenericDevice.getWarpSize();
849849
}
850850

851-
return std::min(MaxNumThreads, (ThreadLimitClause[0] > 0)
852-
? ThreadLimitClause[0]
853-
: PreferredNumThreads);
851+
// Limit number of threads taking into consideration the user
852+
// environment variable OMP_TEAMS_THREAD_LIMIT if provided.
853+
uint32_t CurrentMaxNumThreads = MaxNumThreads;
854+
if (TeamsThreadLimitEnvVar > 0)
855+
CurrentMaxNumThreads = std::min(
856+
static_cast<uint32_t>(TeamsThreadLimitEnvVar), CurrentMaxNumThreads);
857+
858+
return std::min(CurrentMaxNumThreads,
859+
(ThreadLimitClause[0] > 0) ? ThreadLimitClause[0] :
860+
PreferredNumThreads);
854861
}
855862
uint64_t getNumBlocks(GenericDeviceTy &GenericDevice,
856863
uint32_t NumTeamsClause[3], uint64_t LoopTripCount,
@@ -4026,8 +4033,6 @@ struct AMDGPUPluginTy final : public GenericPluginTy {
40264033
return PrepopulateGPUPageTable;
40274034
}
40284035

4029-
bool IsNoMapsCheck() override final { return NoUSMMapChecks; }
4030-
40314036
bool IsFineGrainedMemoryEnabled() override final {
40324037
return EnableFineGrainedMemory;
40334038
}
@@ -4047,19 +4052,13 @@ struct AMDGPUPluginTy final : public GenericPluginTy {
40474052
if (!Initialized)
40484053
FATAL_MESSAGE(1, "%s", "parseEnvVars was called on uninitialized plugin");
40494054

4050-
NoMapChecks = BoolEnvar("OMPX_DISABLE_MAPS", true);
40514055
DisableUsmMaps = BoolEnvar("OMPX_DISABLE_USM_MAPS", false);
40524056
HsaXnack = BoolEnvar("HSA_XNACK", false);
40534057
APUPrefault = BoolEnvar("OMPX_EAGER_ZERO_COPY_MAPS", false);
40544058
ZeroCopyForMapsOnUsm = BoolEnvar("OMPX_APU_MAPS", false);
40554059
}
40564060

40574061
void setUpEnv() override final {
4058-
4059-
if (NoMapChecks.get() == false) {
4060-
NoUSMMapChecks = false;
4061-
}
4062-
40634062
if (DisableUsmMaps.get() == true) {
40644063
EnableFineGrainedMemory = true;
40654064
}
@@ -4360,10 +4359,6 @@ struct AMDGPUPluginTy final : public GenericPluginTy {
43604359
// page table.
43614360
bool PrepopulateGPUPageTable{false};
43624361

4363-
// Set by OMPX_DISABLE_MAPS environment variable.
4364-
// When active (default value), maps are ignored by the runtime
4365-
bool NoUSMMapChecks{true};
4366-
43674362
// Set by OMPX_DISABLE_USM_MAPS environment variable.
43684363
// If set, fine graned memory is used for maps instead of coarse grained.
43694364
bool EnableFineGrainedMemory{false};

openmp/libomptarget/plugins-nextgen/common/include/PluginInterface.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1104,8 +1104,6 @@ struct GenericPluginTy {
11041104

11051105
virtual bool requestedPrepopulateGPUPageTable() { return false; }
11061106

1107-
virtual bool IsNoMapsCheck() { return false; }
1108-
11091107
virtual bool IsFineGrainedMemoryEnabled() { return false; }
11101108

11111109
virtual bool IsSystemSupportingManagedMemory() { return false; }

openmp/libomptarget/plugins-nextgen/common/src/PluginInterface.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1853,8 +1853,6 @@ bool __tgt_rtl_requested_prepopulate_gpu_page_table() {
18531853
return Plugin::get().requestedPrepopulateGPUPageTable();
18541854
}
18551855

1856-
bool __tgt_rtl_is_no_maps_check() { return Plugin::get().IsNoMapsCheck(); }
1857-
18581856
bool __tgt_rtl_is_fine_grained_memory_enabled() {
18591857
return Plugin::get().IsFineGrainedMemoryEnabled();
18601858
}
@@ -1935,7 +1933,8 @@ void *__tgt_rtl_data_alloc(int32_t DeviceId, int64_t Size, void *HostPtr,
19351933
assert(*AllocOrErr && "Null pointer upon successful allocation");
19361934

19371935
// Method has no effect when the CUDA Plugin is used.
1938-
if (Kind == TARGET_ALLOC_SHARED)
1936+
// This method can only be called if HostPtr is not null.
1937+
if (HostPtr && Kind == TARGET_ALLOC_SHARED)
19391938
__tgt_rtl_set_coarse_grain_mem_region(DeviceId, HostPtr, Size);
19401939

19411940
return *AllocOrErr;

openmp/libomptarget/plugins-nextgen/common/src/trace.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -350,16 +350,6 @@ bool __tgt_rtl_is_fine_grained_memory_enabled() {
350350
#define __tgt_rtl_is_fine_grained_memory_enabled(...) \
351351
__tgt_rtl_is_fine_grained_memory_enabled_impl(__VA_ARGS__)
352352

353-
static bool __tgt_rtl_is_no_maps_check_impl();
354-
bool __tgt_rtl_is_no_maps_check() {
355-
auto t = detail::log<bool>(__func__);
356-
bool r = __tgt_rtl_is_no_maps_check_impl();
357-
t.res(r);
358-
return r;
359-
}
360-
#define __tgt_rtl_is_no_maps_check(...) \
361-
__tgt_rtl_is_no_maps_check_impl(__VA_ARGS__)
362-
363353
static int32_t __tgt_rtl_launch_kernel_sync_impl(int32_t device_id,
364354
void *tgt_entry_ptr,
365355
void **tgt_args,

openmp/libomptarget/src/OpenMP/Mapping.cpp

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -280,19 +280,6 @@ TargetPointerResultTy MappingInfoTy::getTargetPointer(
280280
Device.RTL->prepopulate_page_table) {
281281
Device.RTL->prepopulate_page_table(Device.DeviceID, HstPtrBegin, Size);
282282
}
283-
284-
if (!Device.RTL->is_no_maps_check()) {
285-
// even under unified_shared_memory need to check for correctness of
286-
// use of map clauses. Device pointer is same as host ptr in this case
287-
LR.TPR.setEntry(HDTTMap
288-
->emplace(new HostDataToTargetTy(
289-
(uintptr_t)HstPtrBase, (uintptr_t)HstPtrBegin,
290-
(uintptr_t)HstPtrBegin + Size,
291-
(uintptr_t)HstPtrBegin, (uintptr_t)HstPtrBegin,
292-
HasHoldModifier, HstPtrName, /*IsInf=*/true,
293-
/*IsUSMAlloc=*/true))
294-
.first->HDTT);
295-
}
296283
}
297284
DP("Return HstPtrBegin " DPxMOD " Size=%" PRId64 " for unified shared "
298285
"memory\n",
@@ -402,8 +389,7 @@ TargetPointerResultTy MappingInfoTy::getTgtPtrBegin(
402389
LR.TPR.Flags.IsPresent = true;
403390

404391
if ((LR.Flags.IsContained ||
405-
(!MustContain && (LR.Flags.ExtendsBefore || LR.Flags.ExtendsAfter))) &&
406-
!LR.TPR.getEntry()->IsUSMAlloc) {
392+
(!MustContain && (LR.Flags.ExtendsBefore || LR.Flags.ExtendsAfter)))) {
407393

408394
LR.TPR.Flags.IsLast =
409395
LR.TPR.getEntry()->decShouldRemove(UseHoldRefCount, ForceDelete);
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// RUN: %libomptarget-compile-generic -O0 && %libomptarget-run-generic 2>&1 | %fcheck-generic
2+
// RUN: %libomptarget-compileopt-run-and-check-generic
3+
4+
#include <assert.h>
5+
#include <stdio.h>
6+
7+
int main() {
8+
int i = 1;
9+
#pragma omp target
10+
assert(i > 0);
11+
12+
// CHECK: PASS
13+
printf("PASS\n");
14+
return 0;
15+
}

openmp/libomptarget/test/api/assert.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// XFAIL: amdgcn-amd-amdhsa
12
// RUN: %libomptarget-compile-run-and-check-generic
23
// RUN: %libomptarget-compileopt-run-and-check-generic
34

0 commit comments

Comments
 (0)