Skip to content

Commit

Permalink
clean up launcher -nl suffix tests (chapel-lang#24465)
Browse files Browse the repository at this point in the history
The tests themselves were merged in PR chapel-lang#24555. This PR is now reduced
to some cleanup of test configuration and error messages.

[Reviewed by @jabraham17, thank you.]
  • Loading branch information
jhh67 authored Mar 8, 2024
2 parents 8008f6f + a6fabaf commit b7c8f8d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 26 deletions.
14 changes: 8 additions & 6 deletions runtime/src/launch/slurm-srun/launch-slurm-srun.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,20 @@ static const char* getTmpDir(void) {
// Returns 0 on success, 1 and prints an error message on failure
static int checkSlurmVersion(void) {
const int buflen = 256;
char version[buflen];
char versionBuf[buflen];
char *argv[3];
argv[0] = (char *) "sbatch";
argv[1] = (char *) "--version";
argv[2] = NULL;

memset(version, 0, buflen);
if (chpl_run_utility1K("sbatch", argv, version, buflen) <= 0) {
chpl_error("Error trying to determine slurm version", 0, 0);
char* version = getenv("CHPL_LAUNCHER_SLURM_VERSION");
if (version == NULL) {
version = versionBuf;
memset(version, 0, buflen);
if (chpl_run_utility1K("sbatch", argv, version, buflen) <= 0) {
chpl_error("Error trying to determine slurm version", 0, 0);
}
}

if (!strstr(version, "slurm")) {
printf("Error: This launcher is only compatible with native slurm\n");
printf("Output of \"sbatch --version\" was: %s\n", version);
Expand Down Expand Up @@ -590,7 +593,6 @@ static void chpl_launch_cleanup(void) {
int chpl_launch(int argc, char* argv[], int32_t numLocales,
int32_t numLocalesPerNode) {
int retcode;

// check the slurm version before continuing
if (checkSlurmVersion()) {
return 1;
Expand Down
22 changes: 2 additions & 20 deletions test/runtime/configMatters/launch/jhh/co-locales/co-locales.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,24 +62,11 @@ def setup():
class ColocaleArgs(unittest.TestCase):
@classmethod
def setUpClass(cls):
global numSockets
# Should not be set by default
if 'CHPL_RT_LOCALES_PER_NODE' in os.environ:
del os.environ['CHPL_RT_LOCALES_PER_NODE']

# Determine the number of sockets per node
cmd = ["sinfo", "--format=%X", "--noheader", "--exact"]
partition = os.environ.get('CHPL_LAUNCHER_PARTITION', None)
partition = os.environ.get('SLURM_PARTITION', partition)
if partition is not None:
cmd += ["--partition", partition]
if verbose:
print("Partition: ", partition)

numSockets = int(runCmd(cmd))
if numSockets == 1:
self.skipTest("Node has only one socket.")

os.environ['CHPL_LAUNCHER_SLURM_VERSION'] = 'slurm'
os.environ['CHPL_LAUNCHER_CORES_PER_LOCALE'] = '256'
def setUp(self):
if skipReason is not None:
self.skipTest(skipReason)
Expand Down Expand Up @@ -196,7 +183,6 @@ def test_15_env_override(self):
"""Arg overrides CHPL_RT_LOCALES_PER_NODE"""
self.env['CHPL_RT_LOCALES_PER_NODE'] = '4'
output = self.runCmd("./hello -nl 3x2 -v --dry-run")
print(output)
self.assertTrue('--nodes=3' in output or '-N 3' in output)
self.assertIn('--ntasks=6', output)

Expand Down Expand Up @@ -312,10 +298,6 @@ def main(argv):
name = os.path.join(getDir(compiler), argv[0])
del argv[1]

# Add sbatch and srun to our path
path = os.environ['PATH']
os.environ['PATH'] = os.path.join(os.getcwd(), "bin") + ":" + path

if skipReason is None:
# Compile the test program
cmd = compiler + ' hello.chpl'
Expand Down

0 comments on commit b7c8f8d

Please sign in to comment.