Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add bits to help with omp_place testing #3

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ COMMON_SOURCES = \

lib_LTLIBRARIES = libmoc.la
libmoc_la_SOURCES = $(COMMON_SOURCES)
libmoc_la_LIBADD =
libmoc_la_LIBADD = -lpmix -lmpi
41 changes: 41 additions & 0 deletions test/Makefile.devel
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Manually edit paths for OMPIX and LLVM include/lib dirs

CC=clang
CFLAGS=-fopenmp -g
MPI_COMPILE_FLAGS=$(shell mpicc --showme:compile)
MPI_LINK_FLAGS=$(shell mpicc --showme:link)

OMPIX_INC_DIR=/home/tjn/projects/ompi-ecp/install/include
OMPIX_LIB_DIR=/home/tjn/projects/ompi-ecp/install/lib

LLVM_INC_DIR=/home/tjn/projects/ompi-ecp/source/llvm/release_50/install/debug/include
LLVM_LIB_DIR=/home/tjn/projects/ompi-ecp/source/llvm/release_50/install/debug/lib

#all: dbg prod
all: dbg

dbg: mpi_omp_hello_dbg

#prod: mpi_omp_hello_prod

# # Production build of LLVM
# mpi_omp_hello_prod: mpi_omp_hello.c
# $(CC) -I/home/tjn/projects/ompi-ecp/source/llvm/release_50/install/release/include \
# -I/home/tjn/projects/ompi-ecp/install/include \
# -L/home/tjn/projects/ompi-ecp/install/lib \
# $(MPI_COMPILE_FLAGS) $(CFLAGS) $(MPI_LINK_FLAGS) \
# -o mpi_omp_hello.prod mpi_omp_hello.c -lpmix -lmoc

# Debug build of LLVM
mpi_omp_hello_dbg: mpi_omp_hello.c
$(CC) -I$(LLVM_INC_DIR) \
-I$(OMPIX_INC_DIR) \
-L$(LLVM_LIB_DIR) \
-L$(OMPIX_LIB_DIR) \
$(MPI_COMPILE_FLAGS) $(CFLAGS) $(MPI_LINK_FLAGS) \
-o mpi_omp_hello.dbg mpi_omp_hello.c -lpmix -lmoc

clean:
rm -f mpi_omp_hello
rm -f mpi_omp_hello.prod
rm -f mpi_omp_hello.dbg
20 changes: 19 additions & 1 deletion test/mpi_omp_hello.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,15 @@ main (int argc, char *argv[])
{
int nthreads, tid;
moc_info_t *moc_policy_info;
int rank;

fprintf (stderr, "[%s:%s:%d] Calling MPI_Init()...\n", __FILE__, __func__, __LINE__);
MPI_Init (&argc, &argv);
fprintf (stderr, "[%s:%s:%d] MPI_Init() succeeded\n", __FILE__, __func__, __LINE__);

MPI_Comm_rank(MPI_COMM_WORLD, &rank);
fprintf (stderr, "[%s:%s:%d] HELLO PID: %d RANK: %d\n", __FILE__, __func__, __LINE__, (int)getpid(), rank);

MOC_Init (MPI_COMM_WORLD);

MOC_INFO_CREATE (moc_policy_info, 1);
Expand All @@ -51,7 +55,21 @@ main (int argc, char *argv[])
if (tid == 0)
{
nthreads = omp_get_num_threads();
printf("Number of threads = %d\n", nthreads);
printf("[RANK:%d,TID:%d] Number of threads = %d\n", rank, tid, nthreads);
}

{
int i, nprocs, procids, nplaces;
nplaces = omp_get_num_places();

printf("[RANK:%d,TID:%d] num_places = %d\n", rank, tid, nplaces);
for (i = 0; i < nplaces; i++) {
nprocs = omp_get_place_num_procs(i);
omp_get_place_proc_ids(i, &procids);

printf(" [RANK:%d,TID:%d,PLACE:%d] num_places = %d, places_num_procs = %d, places_procids = %d\n",
rank, tid, i, nplaces, nprocs, procids);
}
}

} /* All threads join master thread and disband */
Expand Down