blob: ae427a529cfae13e3f4ffac490fdf76504029c75 [file]
#!/usr/bin/env expect
############################################################################
# Purpose: Test of Slurm functionality
# Test of MPICH2 task spawn logic
############################################################################
# Copyright (C) 2002 The Regents of the University of California.
# Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
# Written by Morris Jette <jette1@llnl.gov>
# CODE-OCEC-09-009. All rights reserved.
#
# This file is part of Slurm, a resource management program.
# For details, see <https://slurm.schedmd.com/>.
# Please also read the included file: DISCLAIMER.
#
# Slurm is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
# Software Foundation; either version 2 of the License, or (at your option)
# any later version.
#
# Slurm is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along
# with Slurm; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
############################################################################
source ./globals
set file_in "$test_dir/input"
set file_out "$test_dir/output"
set file_err "$test_dir/error"
set server_prog "$test_name.server"
set client_prog "$test_name.client"
set job_id 0
#
# Test for existence of mpi compiler
#
if {[run_command_status "$mpicc --version"]} {
skip "This test requires $mpicc"
}
proc cleanup {} {
global job_id server_prog client_prog
cancel_job $job_id
file delete $server_prog ${server_prog}.o
file delete $client_prog ${client_prog}.o
}
#
# Test is only works with mpi/pmi2 plugin.
#
set invalid 1
log_user 0
spawn $scontrol show config
expect {
-re "pmi2" {
set invalid 0
exp_continue
}
timeout {
fail "scontrol not responding"
}
eof {
wait
}
}
log_user 1
if {$invalid == 1} {
skip "Test compatible only with MpiDefault=pmi2"
}
#
# Delete left-over program and rebuild it
#
cleanup
run_command -fail "$mpicc -o $server_prog ${server_prog}.c"
run_command -fail "$mpicc -o $client_prog ${client_prog}.c"
# Delete left-over stdout/err files
file delete $file_out $file_err
#
# Build input script file
#
# Run the server as an external launcher. The $server_prog will not consume
# any resources, and will call MPI_Comm_spawn(), which internally will launch
# another srun with -n set to the spawn count passed as the last argument.
# The job is exclusive, so spawn one task per CPU on the allocated node.
#
set spawn_count [get_total_cpus]
make_bash_script $file_in "$srun --external-launcher $server_prog $client_prog $spawn_count"
#
# Spawn an sbatch job that uses stdout/err and confirm their contents
#
set timeout $max_job_delay
set job_id [submit_job -fail "--exclusive --output=$file_out --error=$file_err -t1 $file_in"]
#
# Wait for job to complete
#
wait_for_job -fail $job_id "DONE"
#
# Check for desired output in stdout
#
set expected_msg $spawn_count
set expected_sum [expr {$spawn_count * ($spawn_count - 1)}]
wait_for_file -fail $file_out
set complete 0
set matches 0
set rank_sum 0
spawn $bin_cat $file_out
#
# The following regex sums all the numbers that appear in strings like this to
# match with expected_sum:
#
# Rank[2] on <hostname> just received msg from Rank 1
# Rank[3] on <hostname> just received msg from Rank 2
# Rank[0] on <hostname> just received msg from Rank 3
# Rank[1] on <hostname> just received msg from Rank 0
#
# So 0+1+2+3 + 0+1+2+3 = 12 (expected_sum)
#
expect {
-re "Rank.($number). on $re_word_str just received msg from Rank ($number)" {
incr rank_sum $expect_out(1,string)
incr rank_sum $expect_out(2,string)
incr matches
exp_continue
}
eof {
wait
}
}
set failure_message ""
if {$matches == 0} {
set failure_message "No MPI communications occurred. The version of MPI you are using may be incompatible with the configured switch. Core files may be present from failed MPI tasks"
} elseif {$matches != $expected_msg} {
set failure_message "Unexpected output ($matches of $expected_msg)"
} elseif {$rank_sum != $expected_sum} {
set failure_message "Invalid rank values ($rank_sum != $expected_sum)"
}
if {$failure_message != ""} {
set matches 0
spawn head $file_err
expect {
-re "Error creating CQ" {
incr matches
exp_continue
}
eof {
wait
}
}
if {$matches != 0} {
log_warn "If using MVAPICH thenc onfigure \"PropagateResourceLimitsExcept=MEMLOCK\". Also start slurmd with \"ulimit -l unlimited\""
} else {
log_debug "Check contents of $file_err"
}
fail $failure_message
}