Commit 5e5b8eac authored by Alvarez, Gonzalo's avatar Alvarez, Gonzalo
Browse files

mpi: bug fixes

parent ce18756d
......@@ -23,5 +23,5 @@ int main(int argc, char* argv[])
internode.parallelFor(0, n, [](SizeType i, SizeType){std::cout << i;});
std::cout<<"\n--------------------------\n";
system("hostname");
}
......@@ -4,15 +4,17 @@ use strict;
use warnings;
use utf8;
my ($file) = @ARGV;
my ($file, $mpiJobs) = @ARGV;
defined($file) or die "USAGE: $0 filename\n";
my %h;
my $firstNode;
open(FILE, "<", "$file") or die "$0: Cannot open $file : $!\n";
while (<FILE>) {
chomp;
next if (/^#/ or $_ eq "");
my $f = $_;
$firstNode = $f;
if (!defined($h{"$f"})) {
$h{"$f"} = 1;
} else {
......@@ -22,14 +24,18 @@ while (<FILE>) {
close(FILE);
my $nodes = scalar(keys %h);
die "$0: Nodes $nodes must be a multiple of mpiJobs $mpiJobs\n" if ($mpiJobs % $nodes != 0);
die "$0: No nodes!\n" if ($nodes == 0 or !defined($firstNode));
my $ppn = $h{"$firstNode"};
my $repeat = $mpiJobs/$nodes;
my $firstcall = 1;
my $maxn = 1;
while ($maxn > 0) {
$maxn = 0;
for (my $i = 0; $i < $repeat; ++$i) {
foreach my $key (sort keys %h) {
my $n = $h{"$key"};
next if ($n == 0);
$maxn += $n;
if ($firstcall) {
$firstcall = 0;
} else {
......@@ -37,7 +43,6 @@ while ($maxn > 0) {
}
print "$key";
--$h{"$key"};
}
}
......
......@@ -179,7 +179,7 @@ void info(std::ostream& os)
char* key = new char[MPI_MAX_INFO_KEY + 1];
char *value = new char[MPI_MAX_INFO_VAL + 1];
for (SizeType i = 0; i < nkeys; ++i) {
for (int i = 0; i < nkeys; ++i) {
ret = MPI_Info_get_nthkey(MPI_INFO_ENV, i, key);
checkError(ret, "MPI_Info_get_nthkey");
......@@ -190,7 +190,7 @@ void info(std::ostream& os)
if (!flag || valuelen <= 0 || valuelen >= MPI_MAX_INFO_VAL) continue;
ret = MPI_Info_Get(MPI_INFO_ENV, key, &valuelen, value, &flag);
ret = MPI_Info_get(MPI_INFO_ENV, key, valuelen, value, &flag);
checkError(ret, "MPI_Info_Get");
os<<"MPI_INFO_ENV key="<<key<<" value="<<value<<"\n";
......
......@@ -103,6 +103,12 @@ void init(int* argc, char **argv[]);
void finalize();
bool hasMpi();
void info(std::ostream&);
void version(std::ostream&);
SizeType commSize(CommType mpiComm);
SizeType commRank(CommType mpiComm);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment