This repository has been archived by the owner on May 27, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce DevicePtr to track address space of pointers.
Optimize loads and stores using LLVM.jl.
- Loading branch information
Showing
12 changed files
with
398 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
julia 0.6 | ||
CUDAdrv 0.4.2 | ||
LLVM 0.3.6 | ||
CUDAdrv 0.5.0 | ||
LLVM 0.3.8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Utility functions for implementing intrinsics and other device code | ||
# Code generation utility functions | ||
|
||
# how to map primitive Julia types to LLVM data types | ||
const llvmtypes = Dict{Type,Symbol}( | ||
|
@@ -146,3 +146,32 @@ Base.@pure function datatype_align(::Type{T}) where {T} | |
field = T.layout + sizeof(UInt32) | ||
unsafe_load(convert(Ptr{UInt16}, field)) & convert(Int16, 2^9-1) | ||
end | ||
|
||
|
||
# create an LLVM function, given its return (LLVM) type and a vector of argument types | ||
function create_llvmf(ret::LLVMType, params::Vector{LLVMType}, name::String="")::LLVM.Function | ||
mod = LLVM.Module("llvmcall", jlctx[]) | ||
|
||
llvmf_typ = LLVM.FunctionType(ret, params) | ||
llvmf = LLVM.Function(mod, name, llvmf_typ) | ||
push!(function_attributes(llvmf), EnumAttribute("alwaysinline")) | ||
|
||
return llvmf | ||
end | ||
|
||
# call an LLVM function, given its return (Julia) type, a tuple-type for the arguments, | ||
# and an expression yielding a tuple of the actual argument values. | ||
function call_llvmf(llvmf::LLVM.Function, ret::Type, params::Type, args::Expr) | ||
quote | ||
Base.@_inline_meta | ||
Base.llvmcall(LLVM.ref($llvmf), $ret, $params, $args...) | ||
end | ||
end | ||
|
||
function Base.convert(::Type{LLVMType}, typ::Type) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
maleadt
Author
Member
|
||
isboxed_ref = Ref{Bool}() | ||
llvmtyp = LLVMType(ccall(:julia_type_to_llvm, LLVM.API.LLVMTypeRef, | ||
(Any, Ptr{Bool}), typ, isboxed_ref)) | ||
@assert !isboxed_ref[] | ||
return llvmtyp | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
doesn't this belong in LLVM.jl, not here?