Skip to content

Commit

Permalink
Merge "[Smoke] Large memory allocation tests should only use availabl…
Browse files Browse the repository at this point in the history
…e memory (#1139)" into release/rocm-rel-6.3
  • Loading branch information
rocm-devops authored and Gerrit Code Review committed Nov 13, 2024
2 parents a26cc1c + fb4d2af commit 48c5e4e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 22 deletions.
6 changes: 4 additions & 2 deletions test/Makefile.defs
Original file line number Diff line number Diff line change
Expand Up @@ -356,8 +356,10 @@ endif
# Header include path + linker flag for libomptest based OMPT tests
OMPTEST = -I$(AOMP)/lib/omptest/include -lomptest

GPU_MEM_TOTAL_SIZE = $(shell $(AOMPHIP)/bin/rocm-smi --showmeminfo vram | grep -E "VRAM Total Memory" | grep -m1 -Eo " [0-9]+" | tr -d ' ')
GPU_MEM_USED_SIZE = $(shell $(AOMPHIP)/bin/rocm-smi --showmeminfo vram | grep -E "VRAM Total Used Memory" | grep -m1 -Eo " [0-9]+" | tr -d ' ')
GPU_MEM_SIZE_GIB := $(shell echo "scale=2; ( ($(GPU_MEM_TOTAL_SIZE) - $(GPU_MEM_USED_SIZE)) / (1024 * 1024 * 1024) )" | bc)

ifeq ($(ISVIRT),1)
GPU_MEM_SIZE = $(shell $(AOMPHIP)/bin/rocm-smi --showmeminfo vram | grep -E "VRAM Total Memory" | grep -m1 -Eo " [0-9]+" | tr -d ' ')
GPU_MEM_SIZE_GIB := $(shell bc -l <<< "$(GPU_MEM_SIZE)/1024 ^ 3")
ISVIRT_UNSUPPORTED = ISVIRT_COMPILE ISVIRT_RUNTIME
endif
4 changes: 0 additions & 4 deletions test/smoke/many_arrays/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@ CC = $(OMP_BIN) $(VERBOSE)
#-ccc-print-phases
#"-\#\#\#"



ifeq ($(ISVIRT),1)
ARGS = $(GPU_MEM_SIZE_GIB)
endif

RUNENV = LIBOMPTARGET_KERNEL_TRACE=2

Expand Down
32 changes: 16 additions & 16 deletions test/smoke/many_arrays/many_arrays.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,38 +186,38 @@ int vecadd(long size, std::string label) {
return rc;
}

int checkSize(long arraySize , float memSize, int initialExponent){
int exponent = 0;
float GiB = pow(1024,3);
float sizeGiB;
int checkSize(float memSize, int initialExponent, long smallSize, float reservedMemPercent) {
float GiB = 1 << 30;
int numArrays = 20;
float sizeGiB;

for (int i = initialExponent; i > 0; i--){
sizeGiB = (arraySize * numArrays * i) / GiB;
if (sizeGiB < memSize){
exponent = i;
return exponent;
for (int i = initialExponent; i > 0; i--) {
sizeGiB = ((pow(10, i) + smallSize) * numArrays * sizeof(double)) / GiB;
printf("sizeGiB: %f, memSize: %f, reservedMemPercent: %f\n", sizeGiB, memSize, reservedMemPercent);
if (sizeGiB < (memSize * (1 - reservedMemPercent/100))) {
return i;
}
}
return initialExponent;
}

int main(int argc, char * argv[])
{
int main(int argc, char * argv[]) {
int largeExponent = 8;
long smallSize = 1000;
float reservedMemPercent = 5;
int adjustedExponent = 0;
long smallSize = pow(10,3);
long largeSize = pow(10,largeExponent);
long largeSize;

// Expects size of GPU memory in GiB (Bytes/1024^3)
if (argc > 1){
float memSize = atof(argv[1]);
adjustedExponent = checkSize(largeSize, memSize, largeExponent);
largeSize = pow(10,adjustedExponent);
adjustedExponent = checkSize(memSize, largeExponent, smallSize, reservedMemPercent);
largeExponent = adjustedExponent;
printf("largeExponent: %d\n", adjustedExponent);
printf("adjustedExponent: %d\n", adjustedExponent);
}

largeSize = pow(10, largeExponent);

int rc = vecadd(smallSize, "small (10^3)");
if (rc) return rc;
std::string largeString = "large (10^";
Expand Down

0 comments on commit 48c5e4e

Please sign in to comment.