Skip to content

Commit b9fa444

Browse files
committed
better examples makefiles
1 parent 10bb64b commit b9fa444

File tree

5 files changed

+82
-26
lines changed

5 files changed

+82
-26
lines changed

examples/Makefile

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
all: allclean allmake
2+
allmake: cpumat_make mpimat_make parmat_make
3+
allrun: cpumat_run mpimat_run parmat_run
4+
allclean: cpumat_clean mpimat_clean parmat_clean
5+
6+
7+
8+
cpumat: cpumat_clean cpumat_make
9+
10+
cpumat_make: cpumat_clean
11+
( cd cpu; make -j )
12+
13+
cpumat_run: cpumat_make
14+
( cd cpu; ./cpumat )
15+
16+
cpumat_clean:
17+
( cd cpu; make clean; )
18+
19+
20+
21+
gpumat: gpumat_clean gpumat_make
22+
23+
gpumat_make: gpumat_clean
24+
( cd gpu; make -j )
25+
26+
gpumat_run: gpumat_make
27+
( cd gpu; ./gpumat )
28+
29+
gpumat_clean:
30+
( cd gpu; make clean; )
31+
32+
33+
34+
mpimat: mpimat_clean mpimat_make
35+
36+
mpimat_make: mpimat_clean
37+
( cd mpi; make -j )
38+
39+
mpimat_run: mpimat_make
40+
( cd mpi; make run )
41+
42+
mpimat_clean:
43+
( cd mpi; make clean )
44+
45+
46+
47+
parmat: parmat_clean parmat_make
48+
49+
parmat_make: parmat_clean
50+
( cd par; make -j )
51+
52+
parmat_run: parmat_make
53+
( cd par; make run )
54+
55+
parmat_clean:
56+
( cd par; make clean )

examples/cpu/Makefile

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,19 @@
1-
CXX = g++
2-
CXXFLAGS = -I../../src -O2
3-
LDFLAGS = -fopenmp -llapack -lblas
4-
5-
WARNFLAGS = -Wall -pedantic -Wextra
1+
-include ../make.inc
62

73

84
all: clean cpumat det matmult svd
95

106
cpumat:
11-
$(CXX) $(CXXFLAGS) $(WARNFLAGS) cpumat.cpp -o cpumat $(LDFLAGS)
7+
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(WARNFLAGS) cpumat.cpp -o cpumat $(CPU_LDFLAGS)
128

139
det:
14-
$(CXX) $(CXXFLAGS) $(WARNFLAGS) det.cpp -o det $(LDFLAGS)
10+
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(WARNFLAGS) det.cpp -o det $(CPU_LDFLAGS)
1511

1612
matmult:
17-
$(CXX) $(CXXFLAGS) $(WARNFLAGS) matmult.cpp -o matmult $(LDFLAGS)
13+
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(WARNFLAGS) matmult.cpp -o matmult $(CPU_LDFLAGS)
1814

1915
svd:
20-
$(CXX) $(CXXFLAGS) $(WARNFLAGS) svd.cpp -o svd $(LDFLAGS)
16+
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(WARNFLAGS) svd.cpp -o svd $(CPU_LDFLAGS)
2117

2218
clean:
2319
rm -rf cpumat det matmult svd

examples/make.inc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
CXX=g++
2+
MPICXX = mpicxx
3+
4+
CPPFLAGS = -I../../src/
5+
CXXFLAGS = -O2 -march=native -std=c++17
6+
7+
WARNFLAGS = -Wall -pedantic -Wextra
8+
9+
CPU_LDFLAGS = -fopenmp -llapack -lblas
10+
GPU_LDFLAGS = -lcudart -lcublas -lcusolver -lnvidia-ml
11+
MPI_LDFLAGS = -fopenmp -lscalapack-openmpi
12+
PAR_LDFLAGS = -fopenmp

examples/mpi/Makefile

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,23 @@
1-
MPICXX = mpicxx
2-
CXXFLAGS = -I../../src
3-
OMPFLAGS = -fopenmp
4-
MPI_LDFLAGS = -lscalapack-openmpi
5-
6-
WARNFLAGS = -Wall -pedantic -Wextra
1+
-include ../make.inc
72

83

94
all: clean convert det matmult mpimat svd
105

116

127
convert:
13-
$(MPICXX) $(CXXFLAGS) $(WARNFLAGS) $(OMPFLAGS) convert.cpp -o convert $(MPI_LDFLAGS)
8+
$(MPICXX) $(CPPFLAGS) $(CXXFLAGS) $(WARNFLAGS) convert.cpp -o convert $(MPI_LDFLAGS)
149

1510
det:
16-
$(MPICXX) $(CXXFLAGS) $(WARNFLAGS) $(OMPFLAGS) det.cpp -o det $(MPI_LDFLAGS)
11+
$(MPICXX) $(CPPFLAGS) $(CXXFLAGS) $(WARNFLAGS) det.cpp -o det $(MPI_LDFLAGS)
1712

1813
matmult:
19-
$(MPICXX) $(CXXFLAGS) $(WARNFLAGS) $(OMPFLAGS) matmult.cpp -o matmult $(MPI_LDFLAGS)
14+
$(MPICXX) $(CPPFLAGS) $(CXXFLAGS) $(WARNFLAGS) matmult.cpp -o matmult $(MPI_LDFLAGS)
2015

2116
mpimat:
22-
$(MPICXX) $(CXXFLAGS) $(WARNFLAGS) $(OMPFLAGS) mpimat.cpp -o mpimat $(MPI_LDFLAGS)
17+
$(MPICXX) $(CPPFLAGS) $(CXXFLAGS) $(WARNFLAGS) mpimat.cpp -o mpimat $(MPI_LDFLAGS)
2318

2419
svd:
25-
$(MPICXX) $(CXXFLAGS) $(WARNFLAGS) $(OMPFLAGS) svd.cpp -o svd $(MPI_LDFLAGS)
20+
$(MPICXX) $(CPPFLAGS) $(CXXFLAGS) $(WARNFLAGS) svd.cpp -o svd $(MPI_LDFLAGS)
2621

2722

2823
clean:

examples/par/Makefile

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
1-
MPICXX = mpicxx
2-
CXXFLAGS = -I../../src
3-
4-
WARNFLAGS = -Wall -pedantic -Wextra
1+
-include ../make.inc
52

63

74
all: clean comm_hello comm_jid
85

96
comm_hello:
10-
$(MPICXX) $(CXXFLAGS) $(WARNFLAGS) comm_hello.cpp -o comm_hello
7+
$(MPICXX) $(CPPFLAGS) $(CXXFLAGS) $(WARNFLAGS) comm_hello.cpp -o comm_hello $(PAR_LDFLAGS)
118

129
comm_jid:
13-
$(MPICXX) $(CXXFLAGS) $(WARNFLAGS) comm_jid.cpp -o comm_jid
10+
$(MPICXX) $(CPPFLAGS) $(CXXFLAGS) $(WARNFLAGS) comm_jid.cpp -o comm_jid $(PAR_LDFLAGS)
1411

1512
clean:
1613
rm -rf comm_hello comm_jid

0 commit comments

Comments
 (0)