Skip to content

Commit

Permalink
[OpenMP] Target memory allocator fallback to default when no device a…
Browse files Browse the repository at this point in the history
…vailable

Differential Revision: https://reviews.llvm.org/D144525
  • Loading branch information
nawrinsu committed Feb 22, 2023
1 parent f5a6560 commit ae46cd7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions openmp/runtime/src/i18n/en_US.txt
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,7 @@ AffHWSubsetAttrInvalid "KMP_HW_SUBSET ignored: %1$s: attribute value %2$s
AffHWSubsetAllFiltered "KMP_HW_SUBSET ignored: all hardware resources would be filtered, please reduce the filter."
AffHWSubsetAttrsNonHybrid "KMP_HW_SUBSET ignored: Too many attributes specified. This machine is not a hybrid architecutre."
AffHWSubsetIgnoringAttr "KMP_HW_SUBSET: ignoring %1$s attribute. This machine is not a hybrid architecutre."
TargetMemNotAvailable "Target memory not available, will use default allocator."

# --------------------------------------------------------------------------------------------------
-*- HINTS -*-
Expand Down
8 changes: 6 additions & 2 deletions openmp/runtime/src/kmp_alloc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1588,8 +1588,10 @@ void *__kmp_alloc(int gtid, size_t algn, size_t size,
ptr = kmp_target_alloc_shared(size, device);
else // allocator == llvm_omp_target_device_mem_alloc
ptr = kmp_target_alloc_device(size, device);
return ptr;
} else {
KMP_INFORM(TargetMemNotAvailable);
}
return ptr;
}

if (allocator >= kmp_max_mem_alloc && KMP_IS_TARGET_MEM_SPACE(al->memspace)) {
Expand All @@ -1602,8 +1604,10 @@ void *__kmp_alloc(int gtid, size_t algn, size_t size,
ptr = kmp_target_alloc_shared(size, device);
else // al->memspace == llvm_omp_target_device_mem_space
ptr = kmp_target_alloc_device(size, device);
return ptr;
} else {
KMP_INFORM(TargetMemNotAvailable);
}
return ptr;
}

if (__kmp_memkind_available) {
Expand Down

0 comments on commit ae46cd7

Please sign in to comment.