Skip to content

Commit

Permalink
Use hipHostMalloc on AMD GPUs
Browse files Browse the repository at this point in the history
  • Loading branch information
mtaillefumier authored and oschuett committed Jul 5, 2021
1 parent af2d904 commit 043d63b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/offload/offload_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ void offload_create_buffer(const int length, offload_buffer **buffer) {
// With size 0 cudaMallocHost doesn't null the pointer and cudaFreeHost fails.
(*buffer)->host_buffer = NULL;
offload_set_device();
OFFLOAD_CHECK(
hipMallocHost((void **)&(*buffer)->host_buffer, requested_size));
OFFLOAD_CHECK(hipHostMalloc((void **)&(*buffer)->host_buffer, requested_size,
hipHostMallocDefault));
OFFLOAD_CHECK(hipMalloc((void **)&(*buffer)->device_buffer, requested_size));
#else
(*buffer)->host_buffer = malloc(requested_size);
Expand All @@ -65,7 +65,7 @@ void offload_free_buffer(offload_buffer *buffer) {
OFFLOAD_CHECK(cudaFreeHost(buffer->host_buffer));
OFFLOAD_CHECK(cudaFree(buffer->device_buffer));
#elif defined(__OFFLOAD_HIP)
OFFLOAD_CHECK(hipFreeHost(buffer->host_buffer));
OFFLOAD_CHECK(hipHostFree(buffer->host_buffer));
OFFLOAD_CHECK(hipFree(buffer->device_buffer));
#else
free(buffer->host_buffer);
Expand Down

0 comments on commit 043d63b

Please sign in to comment.