first steps towards ptx generation
Some checks failed
CI / Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }} (x64, ubuntu-latest, 1.10) (push) Has been cancelled
CI / Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }} (x64, ubuntu-latest, 1.6) (push) Has been cancelled
CI / Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }} (x64, ubuntu-latest, pre) (push) Has been cancelled

This commit is contained in:
Daniel 2024-09-25 12:45:46 +02:00
parent d60cba7e4d
commit d875fc7325

View File

@ -1,3 +1,6 @@
module Transpiler
using CUDA
using ..ExpressionProcessing
# culoadtest(N, rand(["add.f32", "sub.f32", "mul.f32", "div.approx.f32"])) # culoadtest(N, rand(["add.f32", "sub.f32", "mul.f32", "div.approx.f32"]))
function culoadtest(N::Int32, op = "add.f32") function culoadtest(N::Int32, op = "add.f32")
@ -73,4 +76,47 @@ function culoadtest(N::Int32, op = "add.f32")
blocksPerGrid = (N + threadsPerBlock - 1) ÷ threadsPerBlock; blocksPerGrid = (N + threadsPerBlock - 1) ÷ threadsPerBlock;
@time CUDA.@sync cudacall(func, Tuple{CuPtr{Cfloat},CuPtr{Cfloat},CuPtr{Cfloat},Cint}, d_a, d_b, d_c, N; threads=threadsPerBlock, blocks=blocksPerGrid) @time CUDA.@sync cudacall(func, Tuple{CuPtr{Cfloat},CuPtr{Cfloat},CuPtr{Cfloat},Cint}, d_a, d_b, d_c, N; threads=threadsPerBlock, blocks=blocksPerGrid)
end end
function transpile(expression::ExpressionProcessing.PostfixType)
end
# TODO: Make version, target and address_size configurable
function get_cuda_header()::String
return "
.version 7.1
.target sm_52
.address_size 64
"
end
function get_kernel_signature(kernelName::String, parameters::Vector{Type})::String
signature = ".visible .entry " * kernelName
stringBuilder = IOBuffer()
print(stringBuilder, "(")
for i in eachindex(parameters)
type = type_to_cuda_type(parameters[i])
print(stringBuilder,
".param ", type, " ", kernelName, "_param_", i, ",")
end
print(stringBuilder, ")")
return String(take!(stringBuilder))
end
function type_to_cuda_type(type::Type)::String
if type == Int64
return ".s64"
elseif type == Float64
return ".f64"
else
return ".b64"
end
end
end