Skip to content

Commit

Permalink
Initialize CUDA target lazily (#541)
Browse files Browse the repository at this point in the history
  • Loading branch information
elliottslaughter authored Apr 22, 2022
1 parent 43c883c commit 868748e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/cudalib.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ terralib.CUDAParams.entries = { { "gridDimX", uint },
function cudalib.toptx(module,dumpmodule,version,profile)
dumpmodule,version = not not dumpmodule,assert(tonumber(version))
profile = profile or {fastmath=false}
local cu = terralib.newcompilationunit(terra.cudatarget, false, profile) -- TODO: add nvptx target options here
local cu = terralib.newcompilationunit(terra.getcudatarget(), false, profile) -- TODO: add nvptx target options here
local annotations = terra.newlist{} -- list of annotations { functionname, annotationname, annotationvalue } to be tagged
local function addkernel(k,fn)
fn:setinlined(true)
Expand Down
8 changes: 6 additions & 2 deletions src/terralib.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4239,8 +4239,12 @@ if terra.cudalibpaths and terra.cudahome then
end
end

if terra.cudahome then
terra.cudatarget = terra.newtarget {Triple = 'nvptx64-nvidia-cuda', FloatABIHard = true}
local cudatarget
function terra.getcudatarget()
if cudatarget == nil then
cudatarget = terra.newtarget {Triple = 'nvptx64-nvidia-cuda', FloatABIHard = true}
end
return cudatarget
end


Expand Down

0 comments on commit 868748e

Please sign in to comment.