-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'internal-instantiator' into develop
- Loading branch information
Showing
63 changed files
with
5,074 additions
and
552 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
.PHONY: all | ||
all: component_$(MPI_TYPE) | ||
|
||
|
||
CXXFLAGS += $(shell pkg-config --cflags libmuscle_mpi ymmsl) | ||
LDLIBS += $(shell pkg-config --libs libmuscle_mpi ymmsl) | ||
|
||
CXXFLAGS += -g | ||
|
||
component_$(MPI_TYPE): component.cpp | ||
mpicxx -o $@ $(CXXFLAGS) $^ $(LDLIBS) | ||
|
Empty file.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
#include <cstdlib> | ||
#include <fstream> | ||
#include <string> | ||
|
||
// This is a Linux-specific API, but this test always runs on Linux so that's okay. | ||
#define _GNU_SOURCE | ||
#include <sched.h> | ||
#include <unistd.h> | ||
|
||
#include "mpi.h" | ||
|
||
#include "libmuscle/libmuscle.hpp" | ||
#include "ymmsl/ymmsl.hpp" | ||
|
||
using std::ofstream; | ||
using std::to_string; | ||
|
||
using libmuscle::Instance; | ||
using libmuscle::Message; | ||
using ymmsl::Operator; | ||
|
||
|
||
/** Log where we are running so that the test can check for it. */ | ||
void log_location() { | ||
int rank; | ||
MPI_Comm_rank(MPI_COMM_WORLD, &rank); | ||
|
||
char nodeid[1024]; | ||
gethostname(nodeid, sizeof(nodeid)); | ||
|
||
cpu_set_t cpu_set; | ||
CPU_ZERO(&cpu_set); | ||
sched_getaffinity(0, sizeof(cpu_set_t), &cpu_set); | ||
|
||
{ | ||
ofstream outfile("out_" + to_string(rank) + ".txt"); | ||
outfile << nodeid << std::endl; | ||
|
||
bool first = true; | ||
for (int i = 0; i < CPU_SETSIZE; ++i) { | ||
if (CPU_ISSET(i, &cpu_set)) { | ||
if (!first) | ||
outfile << ","; | ||
outfile << i; | ||
first = false; | ||
} | ||
} | ||
outfile << std::endl; | ||
} | ||
} | ||
|
||
|
||
/** A simple dummy component. */ | ||
void component(int argc, char * argv[]) { | ||
const int root_rank = 0; | ||
int rank; | ||
MPI_Comm_rank(MPI_COMM_WORLD, &rank); | ||
|
||
Instance instance(argc, argv, { | ||
{Operator::F_INIT, {"init_in"}}, | ||
{Operator::O_I, {"inter_out"}}, | ||
{Operator::S, {"inter_in"}}, | ||
{Operator::O_F, {"final_out"}}}, | ||
MPI_COMM_WORLD, root_rank); | ||
|
||
// outfile << "Starting reuse loop" << std::endl; | ||
while (instance.reuse_instance()) { | ||
// F_INIT | ||
|
||
int64_t steps = instance.get_setting_as<int64_t>("steps"); | ||
|
||
instance.receive("init_in", Message(0.0)); | ||
|
||
for (int step = 0; step < steps; ++step) { | ||
// O_I | ||
if (rank == root_rank) { | ||
instance.send("inter_out", Message(step)); | ||
} | ||
|
||
// S | ||
instance.receive("inter_in", Message(0.0)); | ||
} | ||
|
||
// O_F | ||
if (rank == root_rank) { | ||
instance.send("final_out", Message(steps)); | ||
} | ||
} | ||
} | ||
|
||
|
||
int main(int argc, char * argv[]) { | ||
MPI_Init(&argc, &argv); | ||
log_location(); | ||
component(argc, argv); | ||
MPI_Finalize(); | ||
return EXIT_SUCCESS; | ||
} | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import logging | ||
import os | ||
import socket | ||
|
||
from libmuscle import Instance, Message | ||
from ymmsl import Operator | ||
|
||
|
||
def log_location() -> None: | ||
"""Log where we are running so that the test can check for it.""" | ||
print(socket.gethostname()) | ||
print(','.join(map(str, sorted(os.sched_getaffinity(0))))) | ||
|
||
|
||
def component() -> None: | ||
"""A simple dummy component. | ||
This sends and receives on all operators, allowing different coupling patterns | ||
with a single program. | ||
""" | ||
instance = Instance({ | ||
Operator.F_INIT: ['init_in'], | ||
Operator.O_I: ['inter_out'], | ||
Operator.S: ['inter_in'], | ||
Operator.O_F: ['final_out']}) | ||
|
||
while instance.reuse_instance(): | ||
# F_INIT | ||
steps = instance.get_setting('steps', 'int') | ||
|
||
instance.receive('init_in', default=Message(0.0)) | ||
|
||
for step in range(steps): | ||
# O_I | ||
instance.send('inter_out', Message(step)) | ||
|
||
# S | ||
instance.receive('inter_in', default=Message(0.0)) | ||
|
||
# O_F | ||
instance.send('final_out', Message(steps)) | ||
|
||
|
||
if __name__ == '__main__': | ||
logging.basicConfig() | ||
logging.getLogger().setLevel(logging.INFO) | ||
|
||
log_location() | ||
component() |
Oops, something went wrong.