10
1
mirror of https://github.com/pfloos/quack synced 2025-01-03 01:55:57 +01:00

dRPA-CUDA: saving

This commit is contained in:
Abdallah Ammar 2024-11-26 14:36:42 +01:00
parent cff0232eb5
commit 3009ffe8f7
4 changed files with 43 additions and 36 deletions

View File

@ -1,63 +1,45 @@
NVCC = nvcc
NFLAGS = -O2 --compiler-options '-fPIC'
NDFLAGS = --shared
NVFLAGS = -O2 --compiler-options '-O2 -Wall'
CC = gcc
CFLAGS = -fPIC -O2 -Wall -g
CFLAGS = -O2 -Wall -g
FC = gfortran
FFLAGS = -O2 -Wall -g
SRC_DIR = src
INC_DIR = include
BIN_DIR = bin
BLD_DIR = build
$(shell mkdir -p $(BIN_DIR))
$(shell mkdir -p $(BLD_DIR))
CU_SRC = $(wildcard $(SRC_DIR)/*.cu)
CU_OBJ = $(CU_SRC:$(SRC_DIR)/%.cu=$(BLD_DIR)/%.o)
C_SRC = $(SRC_DIR)/ph_drpa.c
C_OBJ = $(BLD_DIR)/ph_drpa.o
C_SRC = $(wildcard $(SRC_DIR)/*.c)
C_OBJ = $(CU_SRC:$(SRC_DIR)/%.c=$(BLD_DIR)/%.o)
F_SRC = $(SRC_DIR)/cu_quack_module.f90
F_OBJ = $(BLD_DIR)/cu_quack_module.f90
MAIN_SRC = $(SRC_DIR)/cu_quack.f90
MAIN_OBJ = $(BLD_DIR)/cu_quack.o
OUTPUT_LIB = $(BLD_DIR)/libcuquack.so
CUDA_LIBS = -lcudart -lcublas
F_OBJ = $(BLD_DIR)/cu_quack_module.o
OUTPUT_LIB = $(BLD_DIR)/cuda.a
all: $(OUTPUT_LIB)
$(OUTPUT_LIB): $(CU_OBJ) $(C_OBJ)
$(NVCC) $(NFLAGS) $(NLDFLAGS) $^ -o $@ $(CUDA_LIBS) -I$(INC_DIR)
$(OUTPUT_LIB): $(CU_OBJ) $(C_OBJ) $(F_OBJ)
ar rcs $(OUTPUT_LIB) $(CU_OBJ) $(C_OBJ) $(F_OBJ)
$(BLD_DIR)/%.o: $(SRC_DIR)/%.cu
$(NVCC) $(NFLAGS) -c $< -o $@ -I$(INC_DIR)
$(CU_OBJ): $(CU_SRC)
$(NVCC) $(NVFLAGS) -c -o $@ $< -I$(INC_DIR)
$(C_OBJ): $(C_SRC)
@for src in $(C_SRC); do \
obj=$(BLD_DIR)/$$(basename $${src} .c).o; \
echo "$(CC) $(CFLAGS) -c $$src -o $$obj -I$(INC_DIR)"; \
$(CC) $(CFLAGS) -c $$src -o $$obj -I$(INC_DIR); \
done
$(CC) $(CFLAGS) -c -o $@ $< -I$(INC_DIR)
$(F_OBJ): $(F_SRC)
$(FC) $(FFLAGS) -c $< -o $@ -J$(BLD_DIR)
$(MAIN_OBJ): $(MAIN_SRC)
$(FC) $(FFLAGS) -c $< -o $@ -J$(BLD_DIR)
$(FC) $(FFLAGS) -c -o $@ $< -J$(BLD_DIR)
.PHONY: clean
clean:
rm -f $(BLD_DIR)/*.o $(BLD_DIR)/*.so $(BLD_DIR)/*.mod $(BIN_DIR)/*
rm -f $(BLD_DIR)/*

View File

@ -0,0 +1,26 @@
module cu_quack_module
use, intrinsic :: iso_c_binding
implicit none
interface
! ---
subroutine ph_drpa(nO, nBas, eps, ERI) bind(C, name = "cutc_int")
import c_int, c_double
integer(c_int), intent(in), value :: nO, nBas
real(c_double), intent(in) :: eps(nBas)
real(c_double), intent(in) :: ERI(nBas,nBas,nBas,nBas)
end subroutine ph_drpa
! ---
end interface
end module cu_quack_module

View File

@ -9,8 +9,6 @@
int ph_drpa(int nO, int nBas, double *h_eps, double *h_ERI) {
double *d_eps;
double *d_ERI;

View File

@ -81,7 +81,7 @@ elif sys.platform.lower() == "linux" or os.path.exists('/proc/version'):
else:
if check_compiler_exists('ifort'):
compiler = """
FC = ifort -qmkl=parallel -qopenmp
FC = ifort -mkl=parallel -qopenmp
AR = ar crs
FFLAGS = -I$IDIR -module $IDIR -traceback -g -Ofast -xHost
CC = icc
@ -182,9 +182,10 @@ build_main = "\n".join([
rule_git_clone,
])
exe_dirs = [ "QuAcK"]
exe_dirs = ["QuAcK"]
lib_dirs = list(filter(lambda x: os.path.isdir(x) and \
x not in exe_dirs, os.listdir(".")))
x not in ["cuda"] and \
x not in exe_dirs, os.listdir(".")))
def create_ninja_in_libdir(directory):
def write_rule(f, source_file, replace):