cogentcore / core

A free and open source framework for building powerful, fast, elegant 2D and 3D apps that run on macOS, Windows, Linux, iOS, Android, and the web with a single Go codebase, allowing you to Code Once, Run Everywhere.
http://cogentcore.org/core
BSD 3-Clause "New" or "Revised" License
1.69k stars 80 forks source link

Mpich support #1190

Closed Ann-Geo closed 1 week ago

Ann-Geo commented 2 weeks ago

Describe the feature

Is there support for MPICH for this package: cogentcore.org/core/base/mpi For example, building the code like go build -tags mpich -o main ?

Relevant code

No response

rcoreilly commented 2 weeks ago

It has been a while since I looked at mpich vs openmpi etc but the relevant bits are in the top of the mpi.go and numeric.gen.go files:

#cgo pkg-config: ompi
#include "mpi.h"

You could do a quick workaround by changing those to whatever works for mpich

meanwhile, I'm not sure exactly how cgo works with tags etc to select this more systematically, but that is what we would need to do here. I'm happy to have a PR that implements this if you can get it working.

Ann-Geo commented 1 week ago

Thank you for your prompt reply. I was able to figure it out and get it working for MPICH library. This is what I changed in mpi.go and numeric_gen.go files

However, to extend this codebase to support both ompi and mpich how do I add both cases using conditional directives? For example for mpich build, it needs to skip the #cgo pkg-config: ompi. And similarly for ompi build, it should skip the FLAGS settings for mpich.

I tried a couple of ways using ifdef definitions and using two tags (//go:build mpich || ompi). But none of ways gave me successful build for either mpich or ompi. Would you have any suggestions ?

rcoreilly commented 1 week ago

It looks like you can use the build tags right in the #cgo directives -- I'll give it a try: https://groups.google.com/g/golang-nuts/c/H5KaCPTO49A