Skip to content

Commit

Permalink
Merge pull request #14 from gvallee/fix/mvapich2_version
Browse files Browse the repository at this point in the history
Fix the detection of the MVAPICH version
  • Loading branch information
gvallee authored Mar 7, 2023
2 parents db12f57 + d71ca80 commit 38025e3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cmd/mpi_detect/mpi_detect.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ func main() {
fmt.Printf("unable to detect the MPI implementation installed in %s: %s\n", *dirFlag, err)
os.Exit(1)
}
fmt.Printf("Detected MPI:\n%s %s\n", i.ID, i.Version)
fmt.Printf("Detected MPI: %s\nVersion: %s\n", i.ID, i.Version)
}
12 changes: 9 additions & 3 deletions internal/pkg/mvapich2/mvapich2.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ const (

// ID is the internal ID for MVAPICH2
ID = "mvapich2"

VersionPrefix1 = "MVAPICH2 Version: "

VersionPrefix2 = "Version: "
)

// GetExtraMpirunArgs returns the set of arguments required for the mpirun command for the target platform
Expand All @@ -45,9 +49,11 @@ func parseMVAPICH2InfoOutputForVersion(output string) (string, error) {
return "", fmt.Errorf("empty output from version command")
}
lines := strings.Split(output, "\n")
str := strings.TrimPrefix(lines[0], "MVAPICH2 Version:")
str = strings.TrimLeft(str, " ")
return str, nil
version := lines[0]
version = strings.TrimPrefix(version, VersionPrefix1)
version = strings.TrimPrefix(version, VersionPrefix2)
version = strings.TrimPrefix(version, ID+"-")
return version, nil
}

// DetectFromDir tries to figure out which version of OpenMPI is installed in a given directory
Expand Down

0 comments on commit 38025e3

Please sign in to comment.