Skip to content

Commit 8ff75aa

Browse files
author
Maochao Xiao
committed
both GNU and NVIDIA compilers supported
1 parent e14dd27 commit 8ff75aa

File tree

10 files changed

+305
-296
lines changed

10 files changed

+305
-296
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,4 @@
3232
*.app
3333

3434
# build
35-
./build
35+
build/

Makefile

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,32 @@
1-
# FC = nvfortran
2-
FC = mpifort
1+
# Compiler type: GNU or NVIDIA
2+
COMPILER = NVIDIA
33
# Set SINGLE_PRECISION to 1 to use single precision, otherwise use double precision
4+
SINGLE_PRECISION = 0
5+
# SmartRedis installation directory
6+
SMARTREDIS_INSTALL_DIR = /leonardo/home/userexternal/mxiao000/code/smartredis-nvidia/install
7+
8+
# Set module flag based on compiler type
9+
ifeq ($(COMPILER),GNU)
10+
FC = mpifort
11+
MODULE_FLAG = -J
12+
else ifeq ($(COMPILER),NVIDIA)
13+
FC = mpifort
14+
MODULE_FLAG = -module
15+
else
16+
$(error Invalid COMPILER value. Must be GNU or NVIDIA)
17+
endif
18+
419
# For a library dealing with MPI communication and data processing,
520
# -O2 is typically sufficient and recommended for production use.
6-
SINGLE_PRECISION = 1
7-
FCFLAGS = -O2 -fPIC -I/scratch/yuningw/reinforcement_learning/04-SmartSOD2D-Reproduce/envs/gpu_smartredis/install/include -cpp
21+
FCFLAGS = -O2 -fPIC -I$(SMARTREDIS_INSTALL_DIR)/include -cpp
822

923
# Add single precision flag if enabled, i.e. make SINGLE_PRECISION=1
1024
ifeq ($(SINGLE_PRECISION),1)
1125
FCFLAGS += -D_SINGLE_PRECISION
1226
endif
1327

1428
# Add SmartRedis library paths and libraries
15-
LDFLAGS = -L/scratch/yuningw/reinforcement_learning/04-SmartSOD2D-Reproduce/envs/gpu_smartredis/install/lib
29+
LDFLAGS = -L$(SMARTREDIS_INSTALL_DIR)/lib
1630
LIBS = -lsmartredis -lsmartredis-fortran
1731

1832
# Directory structure
@@ -21,11 +35,8 @@ OBJ_DIR = $(BUILD_DIR)
2135
MOD_DIR = $(BUILD_DIR)/include
2236
LIB_DIR = $(BUILD_DIR)/lib
2337

24-
25-
# YW add
2638
FCFLAGS += -I$(MOD_DIR)
2739

28-
2940
# Source files (adjust paths if necessary)
3041
SRCS = src/precision.f90 src/smartredis_mpi.f90
3142
OBJS = $(patsubst src/%.f90,$(OBJ_DIR)/%.o,$(SRCS))
@@ -42,7 +53,7 @@ create_dirs:
4253
mkdir -p $(LIB_DIR)
4354

4455
$(OBJ_DIR)/%.o: src/%.f90
45-
$(FC) $(FCFLAGS) -module $(MOD_DIR) -c $< -o $@
56+
$(FC) $(FCFLAGS) $(MODULE_FLAG) $(MOD_DIR) -c $< -o $@
4657

4758
$(LIB_STATIC): $(OBJS)
4859
ar rcs $@ $(OBJS)
@@ -51,4 +62,14 @@ $(LIB_SHARED): $(OBJS)
5162
$(FC) -shared -o $@ $(OBJS) $(LDFLAGS) $(LIBS)
5263

5364
clean:
54-
rm -rf $(BUILD_DIR)
65+
rm -rf $(BUILD_DIR)
66+
67+
# Debug targets to print variables
68+
debug:
69+
@echo "COMPILER_TYPE=$(COMPILER_TYPE)"
70+
@echo "FC=$(FC)"
71+
@echo "FCFLAGS=$(FCFLAGS)"
72+
73+
# Generic target to print any variable, usage: make print-VARIABLE_NAME
74+
print-%:
75+
@echo $*=$($*)

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ The library is functional and in active use. Development is ongoing to implement
4343
SmartRedis-MPI is developed and maintained by a dedicated team of researchers and developers. We are grateful for the contributions of:
4444

4545
- **Maochao Xiao** ([@soaringxmc](https://github.com/soaringxmc)) - Code implementation and library design
46+
- **Yuning Wang** ([@fantasy98](https://github.com/Fantasy98)) - Code implementation
4647
- **Bernat Font** ([@b-fg](https://github.com/b-fg)) - Library design
4748
- **Marius Kurz** ([@m-kurz](https://github.com/m-kurz)) - Library design
4849

@@ -54,7 +55,7 @@ SmartRedis-MPI has benefited from the expertise and support of many individuals
5455
We are grateful for the valuable discussions with:
5556
- Francisco Alcántara Ávila
5657
- Di Zhou
57-
- Yuning Wang
58+
- Pol Suárez Morales
5859
- Ting Zhu
5960

6061
Special thanks for the guidance and support provided by:

build/include/precision.mod

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
V34 :0x24 precision
22
13 precision.f90 S624 0
3-
05/05/2025 14:50:44
3+
05/11/2025 16:18:05
44
use iso_fortran_env private
55
use iso_c_binding private
66
use mpi private
@@ -23,9 +23,9 @@ D 79 23 6 1 11 58 0 0 0 0 0
2323
0 58 11 11 58 58
2424
D 82 26 686 8 685 7
2525
D 91 26 689 8 688 7
26-
S 624 24 0 0 0 9 1 0 3189 10005 0 A 0 0 0 0 B 0 0 0 0 0 0 0 0 0 0 0 0 21 0 0 0 0 0 0 0 0 8 0 0 0 0 0 0 precision
27-
S 626 23 0 0 0 6 1098 624 5016 4 0 A 0 0 0 0 B 400000 9 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 624 0 0 0 0 mpi_real
28-
S 627 23 0 0 0 6 1051 624 5025 4 0 A 0 0 0 0 B 400000 9 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 624 0 0 0 0 mpi_double_precision
26+
S 624 24 0 0 0 9 1 0 3189 10005 0 A 0 0 0 0 B 0 0 0 0 0 0 0 0 0 0 0 0 20 0 0 0 0 0 0 0 0 7 0 0 0 0 0 0 precision
27+
S 626 23 0 0 0 6 1098 624 5016 4 0 A 0 0 0 0 B 400000 8 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 624 0 0 0 0 mpi_real
28+
S 627 23 0 0 0 6 1051 624 5025 4 0 A 0 0 0 0 B 400000 8 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 624 0 0 0 0 mpi_double_precision
2929
S 630 3 0 0 0 6 1 1 0 0 0 A 0 0 0 0 B 0 0 0 0 0 0 0 0 0 8 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6
3030
S 632 3 0 0 0 6 1 1 0 0 0 A 0 0 0 0 B 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6
3131
S 637 3 0 0 0 6 1 1 0 0 0 A 0 0 0 0 B 0 0 0 0 0 0 0 0 0 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6
@@ -43,14 +43,14 @@ R 723 6 45 iso_c_binding c_null_ptr$ac
4343
R 725 6 47 iso_c_binding c_null_funptr$ac
4444
R 726 26 48 iso_c_binding ==
4545
R 728 26 50 iso_c_binding !=
46-
S 753 3 0 0 0 6 1 1 0 0 0 A 0 0 0 0 B 0 0 0 0 0 0 0 0 0 13 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6
46+
S 770 3 0 0 0 6 1 1 0 0 0 A 0 0 0 0 B 0 0 0 0 0 0 0 0 0 17 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6
4747
R 1051 16 217 mpi mpi_double_precision
4848
R 1098 16 264 mpi mpi_real
49-
S 7875 16 1 0 0 6 7876 624 37013 4 400000 A 0 0 0 0 B 0 11 0 0 0 0 0 0 4 35 0 0 0 0 0 0 0 0 0 0 0 0 0 624 0 0 0 0 sp
50-
S 7876 16 0 0 0 6 7878 624 37016 4 400000 A 0 0 0 0 B 0 11 0 0 0 0 0 0 8 16 0 0 0 0 0 0 0 0 0 0 0 0 0 624 0 0 0 0 dp
51-
S 7878 16 0 0 0 6 7879 624 37019 800004 400000 A 0 0 0 0 B 0 11 0 0 0 0 0 0 8 16 0 0 0 0 0 0 0 0 0 0 0 0 0 624 0 0 0 0 i8
52-
S 7879 16 0 0 0 6 7880 624 37022 800004 400000 A 0 0 0 0 B 0 15 0 0 0 0 0 0 4 35 0 0 0 0 0 0 0 0 0 0 0 0 0 624 0 0 0 0 rp
53-
S 7880 16 0 0 0 6 0 624 37025 800004 400000 A 0 0 0 0 B 0 16 0 0 0 0 0 0 13 168 0 0 0 0 0 0 0 0 0 0 0 0 0 624 0 0 0 0 mpi_real_rp
49+
S 7687 16 0 0 0 6 7688 624 36396 4 400000 A 0 0 0 0 B 0 10 0 0 0 0 0 0 4 35 0 0 0 0 0 0 0 0 0 0 0 0 0 624 0 0 0 0 sp
50+
S 7688 16 1 0 0 6 7690 624 36399 4 400000 A 0 0 0 0 B 0 10 0 0 0 0 0 0 8 16 0 0 0 0 0 0 0 0 0 0 0 0 0 624 0 0 0 0 dp
51+
S 7690 16 0 0 0 6 7691 624 36402 800004 400000 A 0 0 0 0 B 0 10 0 0 0 0 0 0 8 16 0 0 0 0 0 0 0 0 0 0 0 0 0 624 0 0 0 0 i8
52+
S 7691 16 0 0 0 6 7692 624 36405 800004 400000 A 0 0 0 0 B 0 17 0 0 0 0 0 0 8 16 0 0 0 0 0 0 0 0 0 0 0 0 0 624 0 0 0 0 rp
53+
S 7692 16 0 0 0 6 0 624 36408 800004 400000 A 0 0 0 0 B 0 18 0 0 0 0 0 0 17 187 0 0 0 0 0 0 0 0 0 0 0 0 0 624 0 0 0 0 mpi_real_rp
5454
A 16 2 0 0 0 6 630 0 0 0 16 0 0 0 0 0 0 0 0 0 0 0
5555
A 33 2 0 0 0 6 632 0 0 0 33 0 0 0 0 0 0 0 0 0 0 0
5656
A 35 2 0 0 0 6 637 0 0 0 35 0 0 0 0 0 0 0 0 0 0 0
@@ -62,7 +62,7 @@ A 73 1 0 3 0 70 666 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6262
A 77 1 0 5 0 76 668 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6363
A 131 1 0 0 0 82 723 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6464
A 134 1 0 0 0 91 725 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
65-
A 168 2 0 0 0 6 753 0 0 0 168 0 0 0 0 0 0 0 0 0 0 0
65+
A 187 2 0 0 0 6 770 0 0 0 187 0 0 0 0 0 0 0 0 0 0 0
6666
Z
6767
J 29 1 1
6868
V 61 58 7 0

0 commit comments

Comments
 (0)