Skip to content

Commit

Permalink
Compute total physical memory correctly when there are co-locales
Browse files Browse the repository at this point in the history
Signed-off-by: John H. Hartman <[email protected]>
  • Loading branch information
jhh67 committed Jan 7, 2025
1 parent af560a8 commit ce7c356
Show file tree
Hide file tree
Showing 10 changed files with 166 additions and 43 deletions.
30 changes: 23 additions & 7 deletions test/distributions/robust/arithmetic/kernels/HPCCProblemSize.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,31 @@ module HPCCProblemSize {
returnLog2=false, // whether to return log2(probSize)
memFraction=4, // fraction of mem to use (eg, 1/4)
type retType = int(64)): retType { // type to return

//
// Compute the total memory available to the benchmark using a sum
// reduction over the amount of physical memory (in bytes) owned
// by the set of locales on which we're running. Then compute the
// number of bytes we want to use as defined by memFraction and the
// number that will be required by each index in the problem size.
// Compute the total memory available to the benchmark. If there is one
// locale per node, then compute the total using a sum reduction over the
// amount of physical memory (in bytes) owned by the set of locales on
// which we're running. Otherwise, sum the physical memory of unique
// nodes as determined by each locale's hostname. Then compute the number
// of bytes each locale will use as defined by memFraction and the
// maximum number of co-locales on any node, and the size of each index.
//
const totalMem = + reduce Locales.physicalMemory(unit = MemUnits.Bytes),
memoryTarget = totalMem / memFraction,

var totalMem = 0;
if (max reduce Locales.numColocales > 1) {
var nodes: domain(string, parSafe=false);
for loc in Locales {
if (nodes.contains(loc.hostname) == false) {
nodes += loc.hostname;
totalMem += loc.physicalMemory(unit = MemUnits.Bytes);
}
}
} else {
totalMem = + reduce Locales.physicalMemory(unit = MemUnits.Bytes);
}

const memoryTarget = totalMem / memFraction,
bytesPerIndex = numArrays * numBytes(elemType);

//
Expand Down
32 changes: 24 additions & 8 deletions test/gpu/sidelnik/hpcc/probSize.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,32 @@ module HPCCProblemSize {
returnLog2=false, // whether to return log2(probSize)
memFraction=4, // fraction of mem to use (eg, 1/4)
type retType = int(64)): retType { // type to return

//
// Compute the total memory available to the benchmark using a sum
// reduction over the amount of physical memory (in bytes) owned
// by the set of locales on which we're running. Then compute the
// number of bytes we want to use as defined by memFraction and the
// number that will be required by each index in the problem size.
// Compute the total memory available to the benchmark. If there is one
// locale per node, then compute the total using a sum reduction over the
// amount of physical memory (in bytes) owned by the set of locales on
// which we're running. Otherwise, sum the physical memory of unique
// nodes as determined by each locale's hostname. Then compute the number
// of bytes each locale will use as defined by memFraction and the
// maximum number of co-locales on any node, and the size of each index.
//
const totalMem = + reduce Locales.physicalMemory(unit = MemUnits.Bytes),
memoryTarget = totalMem / memFraction,
bytesPerIndex = numArrays * numBytes(elemType);

var totalMem = 0;
if (max reduce Locales.numColocales > 1) {
var nodes: domain(string, parSafe=false);
for loc in Locales {
if (nodes.contains(loc.hostname) == false) {
nodes += loc.hostname;
totalMem += loc.physicalMemory(unit = MemUnits.Bytes);
}
}
} else {
totalMem = + reduce Locales.physicalMemory(unit = MemUnits.Bytes);
}

const memoryTarget = totalMem / memFraction,
bytesPerIndex = numArrays * numBytes(elemType);

//
// Use these values to compute a base number of indices
Expand Down
2 changes: 1 addition & 1 deletion test/performance/array/distCreate.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ config const dist = distType.block;
config const mode = diagMode.performance;

// assume homogeneity
const totMem = here.physicalMemory(unit = MemUnits.Bytes);
const totMem = here.physicalMemory(unit = MemUnits.Bytes) / here.numColocales;
config const memFraction = 4;

config const createArrays = true;
Expand Down
2 changes: 1 addition & 1 deletion test/performance/comm/low-level/arrayTransfer.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ config const op = opGet;
config type elemType = int(8);

config const memFraction = 10;
config const maxMem = here.physicalMemory(unit = MemUnits.Bytes) / memFraction;
config const maxMem = here.physicalMemory(unit = MemUnits.Bytes) / memFraction / here.numColocales;

config const xferMB = maxMem / 2**20;
config var xferMem = xferMB * 2**20;
Expand Down
27 changes: 25 additions & 2 deletions test/performance/compiler/bradc/probSize.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,31 @@ module HPCCProblemSize {
config const memRatio = 4;

proc computeProblemSize(type elemType, numArrays, returnLog2 = false) {
const totalMem = + reduce Locales.physicalMemory(unit = MemUnits.Bytes),
memoryTarget = totalMem / memRatio,

//
// Compute the total memory available to the benchmark. If there is one
// locale per node, then compute the total using a sum reduction over the
// amount of physical memory (in bytes) owned by the set of locales on
// which we're running. Otherwise, sum the physical memory of unique
// nodes as determined by each locale's hostname. Then compute the number
// of bytes each locale will use as defined by memFraction and the
// maximum number of co-locales on any node, and the size of each index.
//

var totalMem = 0;
if (max reduce Locales.numColocales > 1) {
var nodes: domain(string, parSafe=false);
for loc in Locales {
if (nodes.contains(loc.hostname) == false) {
nodes += loc.hostname;
totalMem += loc.physicalMemory(unit = MemUnits.Bytes);
}
}
} else {
totalMem = + reduce Locales.physicalMemory(unit = MemUnits.Bytes);
}

const memoryTarget = totalMem / memRatio,
bytesPerIndex = numArrays * numBytes(elemType);

var numIndices = (memoryTarget / bytesPerIndex): int;
Expand Down
2 changes: 1 addition & 1 deletion test/reductions/vass/reductions-perf.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ config type elemType = int;

// large array for a single reduction
config const n00perLocale =
if perf then here.physicalMemory() / 4 / numBytes(elemType) else 1000000;
if perf then here.physicalMemory() / 4 / numBytes(elemType) / here.numColocales else 1000000;
config const n00 = numLocales * n00perLocale;

// small arrays for multiple reductions
Expand Down
29 changes: 22 additions & 7 deletions test/release/examples/benchmarks/hpcc/HPCCProblemSize.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,29 @@ module HPCCProblemSize {
memFraction=4, // fraction of mem to use (eg, 1/4)
type retType = int): retType { // type to return
//
// Compute the total memory available to the benchmark using a sum
// reduction over the amount of physical memory (in bytes) owned
// by the set of locales on which we're running. Then compute the
// number of bytes we want to use as defined by memFraction and the
// number that will be required by each index in the problem size.
// Compute the total memory available to the benchmark. If there is one
// locale per node, then compute the total using a sum reduction over the
// amount of physical memory (in bytes) owned by the set of locales on
// which we're running. Otherwise, sum the physical memory of unique
// nodes as determined by each locale's hostname. Then compute the number
// of bytes each locale will use as defined by memFraction and the
// maximum number of co-locales on any node, and the size of each index.
//
const totalMem = + reduce Locales.physicalMemory(unit = MemUnits.Bytes),
memoryTarget = totalMem / memFraction,

var totalMem = 0;
if (max reduce Locales.numColocales > 1) {
var nodes: domain(string, parSafe=false);
for loc in Locales {
if (nodes.contains(loc.hostname) == false) {
nodes += loc.hostname;
totalMem += loc.physicalMemory(unit = MemUnits.Bytes);
}
}
} else {
totalMem = + reduce Locales.physicalMemory(unit = MemUnits.Bytes);
}

const memoryTarget = totalMem / memFraction,
bytesPerIndex = numArrays * numBytes(elemType);

//
Expand Down
30 changes: 23 additions & 7 deletions test/studies/hpcc/HPL/bradc/HPCCProblemSize.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,31 @@ module HPCCProblemSize {
returnLog2=false, // whether to return log2(probSize)
memFraction=4, // fraction of mem to use (eg, 1/4)
type retType = int(64)): retType { // type to return

//
// Compute the total memory available to the benchmark using a sum
// reduction over the amount of physical memory (in bytes) owned
// by the set of locales on which we're running. Then compute the
// number of bytes we want to use as defined by memFraction and the
// number that will be required by each index in the problem size.
// Compute the total memory available to the benchmark. If there is one
// locale per node, then compute the total using a sum reduction over the
// amount of physical memory (in bytes) owned by the set of locales on
// which we're running. Otherwise, sum the physical memory of unique
// nodes as determined by each locale's hostname. Then compute the number
// of bytes each locale will use as defined by memFraction and the
// maximum number of co-locales on any node, and the size of each index.
//
const totalMem = + reduce Locales.physicalMemory(unit = MemUnits.Bytes),
memoryTarget = totalMem / memFraction,

var totalMem = 0;
if (max reduce Locales.numColocales > 1) {
var nodes: domain(string, parSafe=false);
for loc in Locales {
if (nodes.contains(loc.hostname) == false) {
nodes += loc.hostname;
totalMem += loc.physicalMemory(unit = MemUnits.Bytes);
}
}
} else {
totalMem = + reduce Locales.physicalMemory(unit = MemUnits.Bytes);
}

const memoryTarget = totalMem / memFraction,
bytesPerIndex = numArrays * numBytes(elemType);

//
Expand Down
29 changes: 22 additions & 7 deletions test/studies/hpcc/RA/diten/probSize.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,29 @@ module HPCCProblemSize {
memFraction=4, // fraction of mem to use (eg, 1/4)
type retType = int(64)): retType { // type to return
//
// Compute the total memory available to the benchmark using a sum
// reduction over the amount of physical memory (in bytes) owned
// by the set of locales on which we're running. Then compute the
// number of bytes we want to use as defined by memFraction and the
// number that will be required by each index in the problem size.
// Compute the total memory available to the benchmark. If there is one
// locale per node, then compute the total using a sum reduction over the
// amount of physical memory (in bytes) owned by the set of locales on
// which we're running. Otherwise, sum the physical memory of unique
// nodes as determined by each locale's hostname. Then compute the number
// of bytes each locale will use as defined by memFraction and the
// maximum number of co-locales on any node, and the size of each index.
//
const totalMem = + reduce Locales.physicalMemory(unit = MemUnits.Bytes),
memoryTarget = totalMem / memFraction,

var totalMem = 0;
if (max reduce Locales.numColocales > 1) {
var nodes: domain(string, parSafe=false);
for loc in Locales {
if (nodes.contains(loc.hostname) == false) {
nodes += loc.hostname;
totalMem += loc.physicalMemory(unit = MemUnits.Bytes);
}
}
} else {
totalMem = + reduce Locales.physicalMemory(unit = MemUnits.Bytes);
}

const memoryTarget = totalMem / memFraction,
bytesPerIndex = numArrays * numBytes(elemType);

//
Expand Down
26 changes: 24 additions & 2 deletions test/studies/hpcc/common/probSize.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,30 @@ module HPCCProblemSize {
proc computeProblemSize(
type elemType, numArrays, returnLog2 = false, memRatio=4)
{
const totalMem = + reduce Locales.physicalMemory(unit = MemUnits.Bytes),
memoryTarget = totalMem / memRatio,
//
// Compute the total memory available to the benchmark. If there is one
// locale per node, then compute the total using a sum reduction over the
// amount of physical memory (in bytes) owned by the set of locales on
// which we're running. Otherwise, sum the physical memory of unique
// nodes as determined by each locale's hostname. Then compute the number
// of bytes each locale will use as defined by memFraction and the
// maximum number of co-locales on any node, and the size of each index.
//

var totalMem = 0;
if (max reduce Locales.numColocales > 1) {
var nodes: domain(string, parSafe=false);
for loc in Locales {
if (nodes.contains(loc.hostname) == false) {
nodes += loc.hostname;
totalMem += loc.physicalMemory(unit = MemUnits.Bytes);
}
}
} else {
totalMem = + reduce Locales.physicalMemory(unit = MemUnits.Bytes);
}

const memoryTarget = totalMem / memRatio,
bytesPerIndex = numArrays * numBytes(elemType);

var numIndices = memoryTarget / bytesPerIndex;
Expand Down

0 comments on commit ce7c356

Please sign in to comment.