Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use default flag during host malloc #594

Merged
merged 1 commit into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/compiler/dynamic_memory.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ function create_malloc_hostcall!()
holder = Device.HostCallHolder(
Ptr{Cvoid}, Tuple{Csize_t}; continuous=true,
) do bytesize
buf = Mem.HostBuffer(bytesize, HIP.hipHostAllocMapped)
buf = Mem.HostBuffer(bytesize, HIP.hipHostAllocDefault)
dev_ptr = Mem.device_ptr(buf)
@assert buf.ptr == dev_ptr # TODO
return dev_ptr
end

# Create host pinned memory and store HostCall in it.
# It will be then accessed by kernels from kernel state.
buf = Mem.HostBuffer(sizeof(holder.hc), HIP.hipHostAllocMapped)
buf = Mem.HostBuffer(sizeof(holder.hc), HIP.hipHostAllocDefault)
ptr = Base.unsafe_convert(
Ptr{Device.HostCall{Ptr{Cvoid}, Tuple{Csize_t}}}, buf)
Base.unsafe_store!(ptr, holder.hc)
Expand All @@ -33,7 +33,7 @@ function create_free_hostcall!()
return
end

buf = Mem.HostBuffer(sizeof(holder.hc), HIP.hipHostAllocMapped)
buf = Mem.HostBuffer(sizeof(holder.hc), HIP.hipHostAllocDefault)
ptr = Base.unsafe_convert(
Ptr{Device.HostCall{Nothing, Tuple{Ptr{Cvoid}}}}, buf)
Base.unsafe_store!(ptr, holder.hc)
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/exceptions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const _exception_flags = Dict{HIP.HIPDevice, Mem.HostBuffer}()

function create_exception!(mod::HIP.HIPModule)
exception_flag = get!(_exception_flags, mod.dev,
Mem.HostBuffer(sizeof(Int), HIP.hipHostAllocMapped))
Mem.HostBuffer(sizeof(Int), HIP.hipHostAllocDefault))
return Mem.device_ptr(exception_flag)
end

Expand Down
4 changes: 2 additions & 2 deletions src/compiler/output_context.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function create_output_context!(#= TODO mod::HIP.HIPModule =#)
end

# Pointer to HostCall to be read from device.
buf = Mem.HostBuffer(sizeof(holder.hc), HIP.hipHostAllocMapped)
buf = Mem.HostBuffer(sizeof(holder.hc), HIP.hipHostAllocDefault)
ptr = Base.unsafe_convert(Ptr{Device.OUTPUT_CONTEXT_TYPE}, buf)
Base.unsafe_store!(ptr, holder.hc)
return holder, buf
Expand Down Expand Up @@ -47,7 +47,7 @@ function create_printf_output_context!()
return
end
# Pointer to HostCall to be read from device.
buf = Mem.HostBuffer(sizeof(holder.hc), HIP.hipHostAllocMapped)
buf = Mem.HostBuffer(sizeof(holder.hc), HIP.hipHostAllocDefault)
ptr = Base.unsafe_convert(
Ptr{Device.PRINTF_OUTPUT_CONTEXT_TYPE}, buf)
Base.unsafe_store!(ptr, holder.hc)
Expand Down
4 changes: 2 additions & 2 deletions src/device/gcn/hostcall.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function HostCall(
end
end
buf_len = max(sizeof(UInt64), buf_len) # make room for return buffer pointer
buf = Mem.HostBuffer(buf_len, AMDGPU.HIP.hipHostAllocMapped)
buf = Mem.HostBuffer(buf_len, AMDGPU.HIP.hipHostAllocDefault)

buf_ptr = LLVMPtr{UInt8, AS.Global}(Base.unsafe_convert(Ptr{UInt8}, buf))
host_signal_store!(HSA.Signal(signal_handle), READY_SENTINEL)
Expand Down Expand Up @@ -138,7 +138,7 @@ function HostCallHolder(
(ret_buf.ptr == C_NULL)
if do_realloc
ret_len = sizeof(ret)
ret_buf = Mem.HostBuffer(ret_len, AMDGPU.HIP.hipHostAllocMapped)
ret_buf = Mem.HostBuffer(ret_len, AMDGPU.HIP.hipHostAllocDefault)
push!(ret_bufs, ret_buf)
end

Expand Down
6 changes: 3 additions & 3 deletions src/exception_handler.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,16 @@ struct ExceptionHolder
n_buffers = 50
n_str_buffers = 100

exception_flag = Mem.HostBuffer(sizeof(Int32), HIP.hipHostAllocMapped)
exception_flag = Mem.HostBuffer(sizeof(Int32), HIP.hipHostAllocDefault)
gate = ROCArray(UInt64[0])
buffers_counter = ROCArray(Int32[0])
str_buffers_counter = ROCArray(Int32[0])

errprintf_buffers = [
Mem.HostBuffer(buf_len, HIP.hipHostAllocMapped)
Mem.HostBuffer(buf_len, HIP.hipHostAllocDefault)
for _ in 1:n_buffers]
str_buffers = [
Mem.HostBuffer(str_len, HIP.hipHostAllocMapped)
Mem.HostBuffer(str_len, HIP.hipHostAllocDefault)
for _ in 1:n_str_buffers]

errprintf_buffers_dev = ROCArray(Mem.device_ptr.(errprintf_buffers))
Expand Down
Loading