Skip to content

Instantly share code, notes, and snippets.

@gbluma
Created December 25, 2015 05:04
Show Gist options
  • Save gbluma/f236ea949754244c703a to your computer and use it in GitHub Desktop.
Save gbluma/f236ea949754244c703a to your computer and use it in GitHub Desktop.
Felix integrates with MPI C++ so easy
.PHONY: test
test:
flx --pkgconfig-path+=. -c --static -o mpi mpi.flx
mpirun -np 5 mpi
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();
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
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