Skip to content

Commit

Permalink
update empirical code (#9)
Browse files Browse the repository at this point in the history
- make OpenMP optional
- generate static binaries by default (for copying to new machines)

Signed-off-by: Hammond, Jeff R <[email protected]>
  • Loading branch information
Jeff Hammond authored Jan 1, 2020
1 parent 85e4153 commit 9df412c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
CC = icc
INTEL_STATIC = -static-intel -no-intel-extensions
CFLAGS = -Wall -g3 -O3 -fopenmp -std=c99

CFLAGS += -DDEBUG
Expand All @@ -10,7 +11,7 @@ all: test.x time.x empirical.x
# Unfortunately, the assembly syntax used in this code
# does not compile with GCC or Clang.
empirical.x: empirical.c
icc -O0 -qopenmp -std=gnu99 -fasm-blocks $< -o $@
icc -O0 -std=gnu99 -fasm-blocks ${INTEL_STATIC} $< -o $@

test.x: test.o vpu-count.o
$(CC) $(CFLAGS) $^ -o $@
Expand Down
11 changes: 7 additions & 4 deletions empirical.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@

#include <immintrin.h>

#if 1
#if _OPENMP
#include <omp.h>
#else
#elif USE_MPI
#include <mpi.h>
#endif

Expand Down Expand Up @@ -206,7 +206,7 @@ int measure(void)

int main(void)
{
#if 1
#if _OPENMP
#pragma omp parallel
{
int vpu = measure();
Expand All @@ -215,7 +215,7 @@ int main(void)
printf("vpu=%d\n", vpu);
}
}
#else
#elif USE_MPI
MPI_Init(NULL,NULL);
int rank;
MPI_Comm_rank(MPI_COMM_WORLD,&rank);
Expand All @@ -224,6 +224,9 @@ int main(void)
MPI_Barrier(MPI_COMM_WORLD);
printf("%d: vpu=%d\n", rank, vpu);
MPI_Finalize();
#else
int vpu = measure();
printf("vpu=%d\n", vpu);
#endif
return 0;
}

0 comments on commit 9df412c

Please sign in to comment.