Created
December 25, 2015 05:04
-
-
Save gbluma/f236ea949754244c703a to your computer and use it in GitHub Desktop.
Felix integrates with MPI C++ so easy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.PHONY: test | |
test: | |
flx --pkgconfig-path+=. -c --static -o mpi mpi.flx | |
mpirun -np 5 mpi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export requires header """ #include "mpi.h" """, package "mpi"; | |
cproc master_proc () = { | |
println$ "Hello from felix coordinator"; | |
} | |
cproc worker_proc (id:int) = { | |
println$ "Hello from felix worker!: " + id.str; | |
} | |
proc init_app() = { | |
cstmt """ | |
MPI::Init($1, $2); | |
int p = MPI::COMM_WORLD.Get_size(); | |
int id = MPI::COMM_WORLD.Get_rank(); | |
if (id == 0) $3(); // master process | |
else $4(id); // worker process | |
MPI::Finalize(); | |
""" (System::argc, System::_argv, master_proc, worker_proc) ; | |
} | |
init_app(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cflags: -I/usr/lib/openmpi/include -I/usr/lib/openmpi/include/openmpi | |
cflags: -L/usr/lib -L/usr/lib/openmpi/lib | |
requires_slibs: -lpthread -lmpi_cxx -lmpi -ldl -lhwloc |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Hello from felix worker!: 4 | |
Hello from felix coordinator | |
Hello from felix worker!: 2 | |
Hello from felix worker!: 3 | |
Hello from felix worker!: 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment