Skip to content

Commit e33a632

Browse files
committed
backup work on new ariel fork impl
1 parent df6a40f commit e33a632

File tree

10 files changed

+90
-75
lines changed

10 files changed

+90
-75
lines changed

config/sst_check_ariel_mpi.m4

Lines changed: 0 additions & 53 deletions
This file was deleted.

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ LTDL_INIT([recursive])
4848

4949
AC_CACHE_SAVE
5050

51-
SST_CHECK_ARIEL_MPI([], [AC_MSG_ERROR([Can't enable Ariel MPI])])
51+
#SST_CHECK_ARIEL_MPI([], [AC_MSG_ERROR([Can't enable Ariel MPI])])
5252

5353
SST_CORE_CHECK_INSTALL()
5454

src/sst/elements/ariel/Makefile.am

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
SUBDIRS = api
2-
if SST_USE_ARIEL_MPI
3-
SUBDIRS += mpi
4-
endif
1+
SUBDIRS = api mpi
52

63
AM_CPPFLAGS += \
74
-I$(top_srcdir)/src

src/sst/elements/ariel/api/Makefile.am

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
if SST_USE_ARIEL_MPI
2-
CC_LOCAL = $(ARIEL_MPICC)
3-
CFLAGS_LOCAL = -fopenmp $(ARIEL_MPI_CFLAGS) -DENABLE_ARIEL_MPI=1
4-
else
5-
CC_LOCAL = $(CC)
6-
CFLAGS_LOCAL =
7-
endif
8-
91
AM_CPPFLAGS += \
102
$(MPI_CPPFLAGS) \
113
-I$(top_srcdir)/src

src/sst/elements/ariel/api/arielapi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ int MPI_Init_thread(int *argc, char ***argv, int required, int *provided) {
9999
omp_parallel_region();
100100
return PMPI_Init_thread(argc, argv, required, provided);
101101
#else
102-
printf("Error: arielapi.c: MPI_Init_thread called in arielapi.c but this file was compiled without MPI. Please recompile the API with `CC=mpicc make`123123.\n");
102+
printf("Error: arielapi.c: MPI_Init_thread called in arielapi.c but this file was compiled without MPI. Please recompile the API with `CC=mpicc make`.\n");
103103
exit(1);
104104
#endif
105105
}

src/sst/elements/ariel/arielcpu.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ class ArielCPU : public SST::Component {
6767
{"mpilauncher", "Specify a launcher to be used for MPI executables in conjuction with <launcher>", STRINGIZE(MPILAUNCHER_EXECUTABLE)},
6868
{"mpiranks", "Number of ranks to be launched by <mpilauncher>. Only <mpitracerank> will be traced by <launcher>.", "1" },
6969
{"mpitracerank", "Rank to be traced by <launcher>.", "0" },
70+
{"mpitraceall", "Rank to be traced by <launcher>.", "false" },
7071
{"envparamcount", "Number of environment parameters to supply to the Ariel executable, default=-1 (use SST environment)", "-1"},
7172
{"envparamname%(envparamcount)d", "Sets the environment parameter name", ""},
7273
{"envparamval%(envparamcount)d", "Sets the environment parameter value", ""},

src/sst/elements/ariel/frontend/pin3/pin3frontend.cc

Lines changed: 72 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@
1313
// information, see the LICENSE file in the top level directory of the
1414
// distribution.
1515

16-
1716
#include <sst_config.h>
18-
1917
#include "pin3frontend.h"
2018

19+
#ifdef SST_CONFIG_HAVE_MPI
20+
//TODO?
21+
#endif
22+
2123
#include <signal.h>
2224
#if !defined(SST_COMPILE_MACOSX)
2325
#include <sys/prctl.h>
@@ -30,9 +32,7 @@
3032
#include <fcntl.h>
3133
#include <stdio.h>
3234
#include <fcntl.h>
33-
3435
#include <time.h>
35-
3636
#include <string.h>
3737

3838
#define ARIEL_INNER_STRINGIZE(input) #input
@@ -111,7 +111,13 @@ Pin3Frontend::Pin3Frontend(ComponentId_t id, Params& params, uint32_t cores, uin
111111
output->verbose(CALL_INFO, 1, 0, "Base pipe name: %s\n", shmem_region_name.c_str());
112112

113113
// MPI Launcher options
114-
mpimode = params.find<int>("mpimode", 0);
114+
//mpimode = params.find<int>("mpimode", 0);
115+
#ifdef USE_MPI
116+
mpimode = 1;
117+
#else
118+
mpimode = 0;
119+
#endif
120+
115121
if (mpimode) {
116122
mpilauncher = params.find<std::string>("mpilauncher", ARIEL_STRINGIZE(MPILAUNCHER_EXECUTABLE));
117123
mpiranks = params.find<int>("mpiranks", 1);
@@ -322,10 +328,16 @@ void Pin3Frontend::init(unsigned int phase)
322328
// Init the child_pid = 0, this prevents problems in emergencyShutdown()
323329
// if forkPINChild() calls fatal (i.e. the child_pid would not be set)
324330
child_pid = 0;
325-
if (mpimode == 1) {
331+
if (mpimode == 0) { // TODO CHANGE BACK
326332
// Ariel will fork the MPI launcher which will itself fork pin
327-
child_pid = forkPINChild(mpilauncher.c_str(), execute_args, execute_env, redirect_info);
333+
printf("--------------------\n");
334+
printf(" --- MPI PIN ---\n");
335+
printf("--------------------\n");
336+
child_pid = forkPINChildMPI(mpilauncher.c_str(), execute_args, execute_env, redirect_info);
328337
} else {
338+
printf("--------------------\n");
339+
printf(" --- Regular PIN ---\n");
340+
printf("--------------------\n");
329341
child_pid = forkPINChild(appLauncher.c_str(), execute_args, execute_env, redirect_info);
330342
}
331343
output->verbose(CALL_INFO, 1, 0, "Returned from launching PIN. Waiting for child to attach.\n");
@@ -348,6 +360,59 @@ ArielTunnel* Pin3Frontend::getTunnel() {
348360
return tunnel;
349361
}
350362

363+
int Pin3Frontend::forkPINChildMPI(const char* app, char** args, std::map<std::string, std::string>& app_env, redirect_info_t redirect_info) {
364+
#ifdef USE_MPI
365+
if(isSimulationRunModeInit())
366+
return 0;
367+
#endif
368+
369+
// Convert app to non-const
370+
371+
char *app2 = (char*)malloc(std::strlen(app) + 1);
372+
if (!app2) return 0; // TODO proper error condition
373+
std::strcpy(app2, app);
374+
375+
// Find where the PIN arguments end
376+
int app_idx = -1;
377+
for (int i = 0; args[i] != NULL; i++) {
378+
if (strcmp(args[i], "--") == 0) {
379+
app_idx = i+1;
380+
break;
381+
}
382+
}
383+
if (app_idx == -1) {
384+
// TODO: Error not found
385+
}
386+
387+
for (int i = app_idx; args[i] != NULL; i++) {
388+
printf(" app %d - %s\n", i, args[1]);
389+
}
390+
391+
int count = 1;
392+
char *array_of_commands[] = {args[0]};
393+
char *argv[] = {"20", NULL};
394+
char **array_of_argv[] = {args+1};
395+
int array_of_maxprocs[] = {1};
396+
397+
/* Working for 1 rank
398+
int count = 1;
399+
char *array_of_commands[] = {args[0]};
400+
char *argv[] = {"20", NULL};
401+
char **array_of_argv[] = {args+1};
402+
int array_of_maxprocs[] = {1};
403+
*/
404+
405+
int ret = SST::Core::Interprocess::SST_MPI_Comm_spawn_multiple(count,
406+
array_of_commands,
407+
array_of_argv,
408+
array_of_maxprocs);
409+
410+
//TODO: Check ret and exit is non-zero
411+
free(app2);
412+
413+
return 1;
414+
}
415+
351416
int Pin3Frontend::forkPINChild(const char* app, char** args, std::map<std::string, std::string>& app_env, redirect_info_t redirect_info) {
352417
// If user only wants to init the simulation then we do NOT fork the binary
353418
if(isSimulationRunModeInit())

src/sst/elements/ariel/frontend/pin3/pin3frontend.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include <string>
2828
#include <map>
2929

30+
3031
#include "arielfrontend.h"
3132
#include "ariel_shmem.h"
3233

@@ -93,6 +94,7 @@ class Pin3Frontend : public ArielFrontend {
9394
private:
9495

9596
int forkPINChild(const char* app, char** args, std::map<std::string, std::string>& app_env, redirect_info_t redirect_info);
97+
int forkPINChildMPI(const char* app, char** args, std::map<std::string, std::string>& app_env, redirect_info_t redirect_info);
9698

9799
SST::Output* output;
98100

@@ -112,6 +114,10 @@ class Pin3Frontend : public ArielFrontend {
112114
int mpitracerank;
113115
bool use_mpilauncher;
114116

117+
#ifdef USE_MPI
118+
MPI_Comm intercomm;
119+
#endif
120+
115121

116122
char **execute_args;
117123
std::map<std::string, std::string> execute_env;

src/sst/elements/ariel/tests/testMPI/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,7 @@ hello:
99
mpicxx hello.cc -o hello -I$(API_DIR) -L$(API_DIR) -larielapi -fopenmp
1010
reduce:
1111
mpicxx reduce.cc -o reduce -I$(API_DIR) -L$(API_DIR) -larielapi -fopenmp
12+
13+
reduce-noapi:
14+
mpicxx reduce-noapi.cc -o reduce-noapi -fopenmp
15+

src/sst/elements/ariel/tests/testMPI/ariel-reduce.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import sst
22
import sys
33
import os
4+
from pathlib import Path
45

56
# Detect if we will use MPI mode or not
67
mpi_mode = True
@@ -39,11 +40,13 @@
3940
## Set component parameters and fill subcomponent slots
4041
#########################################################################
4142
# Core: 2.4GHz, 2 accesses/cycle, STREAM (triad) pattern generator with 1000 elements per array
43+
exe = "./reduce"
44+
full_exe = str(Path(exe).resolve())
4245
core.addParams({
4346
"clock" : "2.4GHz",
4447
"verbose" : 1,
4548
#"executable" : "./hello-nompi"
46-
"executable" : "./reduce",
49+
"executable" : full_exe,
4750
#"executable" : "/home/prlavin/projects/reference-paper-2024/apps/install/bin/amg",
4851
"arielmode" : 0,
4952
"corecount" : ncores,

0 commit comments

Comments
 (0)