Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[smoke] - Additional dynamic memory detection #1166

Open
wants to merge 1 commit into
base: aomp-dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions test/smoke/clang-337336/Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
OVERFLOW_GUARD =1
include ../../Makefile.defs

TESTNAME = clang-337336
Expand Down
20 changes: 17 additions & 3 deletions test/smoke/clang-337336/clang-337336.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,32 @@
const size_t SIZE = 3 * 1024L * 1024L;
const unsigned int NUM_TEAMS = 3;

int main()
int main(int argc, char * argv[])
{
unsigned int NKERNELS = 10;
if (argc > 1){
float memSize = atof(argv[1]);
float sizeGiB;
float reservedMemPercent = 10;
for (int i = NKERNELS; i > 0; i--) {
sizeGiB = (i * (double)SIZE * sizeof(double) / GB);
printf("sizeGiB: %f, memSize: %f, reservedMemPercent: %f\n", sizeGiB, memSize, reservedMemPercent);
if (sizeGiB < (memSize * (1 - reservedMemPercent/100))) {
NKERNELS = i;
break;
}
}
printf("NKERNELS reduced to: %d\n", NKERNELS);
}
int dummy = 0;

printf("TOtal Memory = %.6lf GB\n\n", (double)SIZE * sizeof(double) / GB);
printf("Total Memory = %.6lf GB\n\n", NKERNELS * (double)SIZE * sizeof(double) / GB);

#pragma omp target
{
dummy += 1;
}
{
unsigned int const NKERNELS = 10;
double *p[NKERNELS];
unsigned const check = 9;

Expand Down
1 change: 1 addition & 0 deletions test/smoke/clang_udel_saxpy/Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
OVERFLOW_GUARD=1
include ../../Makefile.defs

TESTNAME = clang_udel_saxpy
Expand Down
17 changes: 17 additions & 0 deletions test/smoke/clang_udel_saxpy/clang_udel_saxpy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,23 @@ string to_string(nanoseconds ns) {

int main(int argc, char **argv) {
int n = 500000000;
int numArrays = 2;
if (argc > 1){
float memSize = atof(argv[1]);
float sizeGiB;
float GiB = 1 << 30;
float reservedMemPercent = 5;
for (int i = n; i > 0; i -= n/10) {
sizeGiB = (i * numArrays * sizeof(double) / GiB);
printf("sizeGiB: %f, memSize: %f, reservedMemPercent: %f\n", sizeGiB, memSize, reservedMemPercent);
if (sizeGiB < (memSize * (1 - reservedMemPercent/100))) {
n = i;
break;
}
}
printf("n reduced to: %d\n", n);
}

double a = 3.;
vector<double> x(n, 1.), y(n, 2.);
vector<double> xcpu(x), xgpu(x), xloop(x);
Expand Down