Skip to content

Commit 01214cd

Browse files
committed
Quick fix for building error with nvcc
1 parent d95a962 commit 01214cd

File tree

4 files changed

+31
-17
lines changed

4 files changed

+31
-17
lines changed

.conda-recipe/bld.bat

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@ call "C:\Program Files (x86)\Intel\oneAPI\setvars.bat"
66

77
:: Navigate to wrapper file for python module
88
cd %RECIPE_DIR%\..\python\src\magtense\lib
9-
del /Q /F %RECIPE_DIR%\..\python\src\magtense.egg-info
10-
del /Q /F %RECIPE_DIR%\..\python\build
9+
rmdir /S /Q %RECIPE_DIR%\..\python\src\magtense.egg-info
10+
rmdir /S /Q %RECIPE_DIR%\..\python\build
1111
make clean
12+
13+
:: As nvcc compilation in build environment throws an error
14+
copy %RECIPE_DIR%\..\source\MagTenseFortranCuda\cuda\MagTenseCudaBlas.o .
1215
make
1316

1417
:: Navigate to distribution script

python/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,11 @@ conda config --env --append channels intel
111111
# On Windows
112112
# conda config --env --append channels conda-forge
113113
114+
# Quick fix for error of nvcc during build on Windows
115+
# conda install -y -c nvidia/label/cuda-12.2.2 cuda-nvcc
116+
# cd MagTense/source/MagTenseFortranCuda/cuda/
117+
# nvcc -c MagTenseCudaBlas.cu -o MagTenseCudaBlas.o
118+
114119
# Version numbers have to be set in advance in pyproject.toml
115120
cd MagTense/python/
116121
python scripts/dist_conda.py

python/scripts/dist_conda.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,26 @@ def main(mt_version = '2.2.1', py_versions = ['3.11']):
1010
else:
1111
arch = "linux-64"
1212

13-
s_0 = "#=========================="
14-
s_1 = "# Compiler names and flags"
15-
1613
for py in py_versions:
1714
for cuda in ["cuda12"]:
18-
if cuda == "cpu":
19-
s_2 = "USE_CUDA = 0"
20-
else:
21-
s_2 = "USE_CUDA = 1"
22-
2315
with open("src/magtense/lib/Makefile", 'r') as source_file:
24-
lines_to_append = source_file.readlines()[4:]
16+
lines_to_append = source_file.readlines()[5:]
2517

2618
with open("scripts/temp.txt", "w") as file:
27-
file.write(s_0 + '\n')
28-
file.write(s_1 + '\n')
29-
file.write(s_0 + '\n')
30-
file.write(s_2 + '\n')
19+
file.write("#==========================\n")
20+
file.write("# Compiler names and flags\n")
21+
file.write("#==========================\n")
22+
23+
if cuda == "cpu":
24+
file.write("USE_CUDA = 0\n")
25+
else:
26+
file.write("USE_CUDA = 1\n")
27+
28+
if platform.system() == 'Windows':
29+
file.write("USE_NVCC = 0\n")
30+
else:
31+
file.write("USE_NVCC = 1\n")
32+
3133
file.writelines(lines_to_append)
3234

3335
shutil.move("scripts/temp.txt", "src/magtense/lib/Makefile")

python/src/magtense/lib/Makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# Compiler names and flags
33
#==========================
44
USE_CUDA = 1
5+
USE_NVCC = 1
56
USE_CVODE = 0
67
USE_MICROMAG = 1
78

@@ -22,6 +23,7 @@ ifeq (${F90}, gfortran)
2223
endif
2324

2425
CC = gcc
26+
CPP = icx
2527
CFLAGS = -fPIC
2628
CU = nvcc
2729
PYTHON_MODN = magtensesource
@@ -62,7 +64,6 @@ ifeq ($(OS),Windows_NT)
6264
LIB_OPT = -L. -llibsrc
6365
endif
6466

65-
CPP = icl
6667
CPPFLAGS = /Fo:${CUDA_WRAP}
6768
CUFLAGS = -I ${OPT}
6869
CUDA = -L${CONDA_PREFIX}/Lib/x64 -lcublas -lcudart -lcuda -lcusparse
@@ -93,7 +94,6 @@ else
9394
endif
9495

9596
EXTRA_OPT = --opt='${F90FLAGS}'
96-
CPP = icx
9797
CPPFLAGS = ${CFLAGS} -o ${CUDA_WRAP}
9898
CUFLAGS = -shared -Xcompiler -fPIC -I ${OPT}
9999
CUDA = -L${CONDA_PREFIX}/lib -lcublas -lcudart -lcuda -lcusparse
@@ -153,7 +153,11 @@ LIBSRC_WRAP_FILES = $(addsuffix .f90, ${LIBSRC_WRAP_SOURCES})
153153
#=======================================================================
154154
# Relevant suffixes
155155
#=======================================================================
156+
ifeq ($(USE_NVCC),0)
157+
.SUFFIXES: .f90 .cxx
158+
else
156159
.SUFFIXES: .f90 .cu .cxx
160+
endif
157161

158162
#=======================================================================
159163
#

0 commit comments

Comments
 (0)