Skip to content

Commit

Permalink
Refactor new Ariel automake files
Browse files Browse the repository at this point in the history
  • Loading branch information
plavin committed Aug 9, 2024
1 parent 0f34122 commit 32617c2
Show file tree
Hide file tree
Showing 25 changed files with 567 additions and 393 deletions.
10 changes: 10 additions & 0 deletions config/sst_check_ariel_mpi.m4
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,16 @@ AC_DEFUN([SST_CHECK_ARIEL_MPI], [
dnl will save them in new variables.
ARIEL_MPICC=$MPICC
ARIEL_MPICXX=$MPICXX
ARIEL_MPI_CFLAGS=$($MPICC -showme:compile)
ARIEL_MPI_LIBS=$($MPICC -showme:link)
dnl ARIEL_MPI_CFLAGS=$MPICC
dnl ARIEL_MPI_LIBS=$MPICXX
AC_MSG_NOTICE([-> Patrick <- ARIEL_MPI_CFLAGS is $ARIEL_MPI_CFLAGS])
AC_MSG_NOTICE([-> Patrick <- ARIEL_MPI_LIBS is $ARIEL_MPI_LIBS])
AS_IF([test "$sst_check_ariel_mpi_happy" = "yes"], [
AC_DEFINE([ENABLE_ARIEL_MPI], [1], [Enable Ariel MPI features])
])
AM_CONDITIONAL([SST_USE_ARIEL_MPI], [test "$sst_check_ariel_mpi_happy" = "yes"])
])

27 changes: 20 additions & 7 deletions src/sst/elements/ariel/api/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
CC=$(ARIEL_MPICC)
CXX=$(ARIEL_MPICXX)
CFLAGS+=-fopenmp
CXXFLAGS+=fopenmp
lib_LTLIBRARIES = libarielapi.la
libarielapi_la_SOURCES = arielapi.c arielapi.h
include_HEADERS = arielapi.h
if SST_USE_ARIEL_MPI
CFLAGS+=-fopenmp $(ARIEL_MPI_CFLAGS)
CC_LOCAL = $(ARIEL_MPICC)
else
CC_LOCAL = $(CC)
endif

all-local: libarielapi.so libarielapi.a

libarielapi.so: arielapi.c arielapi.h
$(CC_LOCAL) -DENABLE_ARIEL_MPI $(AM_CFLAGS) $(ARIEL_MPI_CFLAGS) -fPIC -shared -o libarielapi.so arielapi.c -fopenmp

arielapi.o: arielapi.c arielapi.h
$(CC_LOCAL) -DENABLE_ARIEL_MPI $(AM_CFLAGS) $(ARIEL_MPI_CFLAGS) -c -o arielapi.o arielapi.c -fopenmp

libarielapi.a: arielapi.o
ar rcs $@ $^

clean-local:
rm arielapi.o libarielapi.a libarielapi.so
13 changes: 6 additions & 7 deletions src/sst/elements/ariel/api/arielapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#if __has_include(<mpi.h>)
#if ENABLE_ARIEL_MPI
#include <mpi.h>
#define HAVE_MPI_H
#endif

/* These definitions are replaced during simulation */
Expand Down Expand Up @@ -63,7 +62,7 @@ void omp_parallel_region() {
}
}
#else
printf("ERROR: libarielapi.c: libarielapi was compiled without OpenMP enabled\n");
printf("ERROR: arielapi.c: libarielapi was compiled without OpenMP enabled\n");
exit(1);
#endif
}
Expand All @@ -78,29 +77,29 @@ int _api_mpi_init() {
// Custom version of MPI_Init. We override the normal version in order to call an
// OpenMP parallel region to ensure threads are numbered properly by the frontend.
int MPI_Init(int *argc, char ***argv) {
#ifdef HAVE_MPI_H
#ifdef ENABLE_ARIEL_MPI
// Communicate to the frontend that we have replaced the nomal MPI_Init with
// the one in the Ariel API
_api_mpi_init();
omp_parallel_region();
return PMPI_Init(argc, argv);
#else
printf("Error: arielapi.c: MPI_Init called in arielapi.c but this file was compiled without MPI. Please recompile the API with `CC=mpicc make`.\n");
printf("Error: arielapi.c: MPI_Init called in arielapi.c but this file was compiled without MPI. Please recompile the API with `CC=mpicc make`12341234.\n");
exit(1);
#endif
}

// Custom version of MPI_Init_thread. We override the normal verison in order to call an
// OpenMP parallel region to ensure threads are numbered properly by the frontend.
int MPI_Init_thread(int *argc, char ***argv, int required, int *provided) {
#ifdef HAVE_MPI_H
#ifdef ENABLE_ARIEL_MPI
// Communicate to the frontend that we have replaced the nomal MPI_Init_thread with
// the one in the Ariel API
_api_mpi_init();
omp_parallel_region();
return PMPI_Init_thread(argc, argv, required, provided);
#else
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");
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");
exit(1);
#endif
}
4 changes: 4 additions & 0 deletions src/sst/elements/ariel/configure.m4
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@ AC_DEFUN([SST_ariel_CONFIG], [
AC_SUBST([ARIEL_MPICC])
AC_SUBST([ARIEL_MPICXX])
AC_SUBST([ARIEL_MPI_CFLAGS])
AC_SUBST([ARIEL_MPI_LIBS])
AC_CONFIG_FILES([src/sst/elements/ariel/api/Makefile])
AC_CONFIG_FILES([src/sst/elements/ariel/mpi/Makefile])
AC_CONFIG_FILES([src/sst/elements/ariel/tests/testMPI/Makefile])
AC_CONFIG_FILES([src/sst/elements/ariel/frontend/simple/examples/stream/Makefile])
AS_IF([test "$sst_check_ariel" = "yes"], [$1], [$2])
])
2 changes: 2 additions & 0 deletions src/sst/elements/ariel/frontend/pin3/fesimple.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1922,7 +1922,9 @@ VOID InstrumentRoutine(RTN rtn, VOID* args)
}

void fork_disable_child_output(THREADID threadid, const CONTEXT *ctx, VOID *v) {
#ifdef ARIEL_DEBUG
fprintf(stderr, "Warning: fesimple cannot trace forked processes. Disabling Pin for pid %d\n", getpid());
#endif
PIN_Detach();
}

Expand Down
19 changes: 0 additions & 19 deletions src/sst/elements/ariel/frontend/simple/examples/stream/Makefile

This file was deleted.

12 changes: 12 additions & 0 deletions src/sst/elements/ariel/frontend/simple/examples/stream/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
API_DIR = ../../../../api

all-local: stream stream_mlm

clean-local:
rm -f stream stream_mlm

stream:
$(CXX) stream.c -o stream -I$(API_DIR) -L$(API_DIR) -larielapi

stream_mlm:
$(CXX) stream_malloc.c -o stream_mlm -I$(API_DIR) -L$(API_DIR) -larielapi
Loading

0 comments on commit 32617c2

Please sign in to comment.