Skip to content

Commit bb5ff15

Browse files
authored
Merge pull request #273 from FourierFlows/ncc/drop-has-cuda
Drop the in-house `@has_cuda` macro
2 parents 9a86c9d + eaa0a8f commit bb5ff15

File tree

3 files changed

+6
-17
lines changed

3 files changed

+6
-17
lines changed

src/FourierFlows.jl

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ $(EXPORTS)
88
module FourierFlows
99

1010
export
11-
# Helper variables and macros for determining if machine is CUDA-enabled.
12-
@has_cuda,
13-
1411
Device,
1512
CPU,
1613
GPU,
@@ -114,16 +111,10 @@ include("timesteppers.jl")
114111
# Physics
115112
include("diffusion.jl")
116113

117-
"""
118-
@has_cuda expr
119-
A macro to compile and execute `expr` only if CUDA is installed and available.
120-
"""
121-
macro has_cuda(expr)
122-
return has_cuda() ? :($(esc(expr))) : :(nothing)
123-
end
124-
125114
# CUDA functionality
126-
@has_cuda include("CuFourierFlows.jl")
115+
if CUDA.has_cuda()
116+
include("CuFourierFlows.jl")
117+
end
127118

128119
function __init__()
129120
threads = Threads.nthreads()
@@ -132,7 +123,7 @@ function __init__()
132123
FFTW.set_num_threads(threads)
133124
end
134125

135-
@has_cuda begin
126+
if CUDA.has_cuda()
136127
@debug "CUDA-enabled GPU(s) detected:"
137128
for (gpu, dev) in enumerate(CUDA.devices())
138129
@debug "$dev: $(CUDA.name(dev))"

test/createffttestfunctions.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ function create_testfuncs(g::ThreeDGrid{Tg,<:Array}) where Tg
139139
end
140140

141141

142-
@has_cuda begin
142+
if CUDA.has_cuda()
143143
function create_testfuncs(g::OneDGrid{Tg, <:CuArray}) where Tg
144144
cpugrid = OneDGrid(g.nx, g.Lx)
145145
out = create_testfuncs(cpugrid)

test/runtests.jl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ using
33
LinearAlgebra,
44
Printf,
55
JLD2,
6-
CUDA,
76
Test
87

98
using
@@ -15,8 +14,7 @@ using FourierFlows: parsevalsum2
1514
using LinearAlgebra: mul!, ldiv!, norm
1615

1716
# the devices on which tests will run
18-
devices = (CPU(),)
19-
@has_cuda devices = (CPU(), GPU())
17+
devices = CUDA.has_cuda() ? (CPU(), GPU()) : (CPU(),)
2018

2119
const rtol_fft = 1e-12
2220
const rtol_output = 1e-12

0 commit comments

Comments
 (0)