From a6a1abd98ebd8eea215e47c1b6547f1404ad9b7a Mon Sep 17 00:00:00 2001 From: slaren Date: Sun, 26 May 2024 18:47:42 +0200 Subject: [PATCH] simplify code, more consistent style --- ggml-cuda.cu | 10 +++------- ggml-cuda/common.cuh | 5 +---- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/ggml-cuda.cu b/ggml-cuda.cu index 456e7378d..6e2f525db 100644 --- a/ggml-cuda.cu +++ b/ggml-cuda.cu @@ -119,19 +119,15 @@ int ggml_cuda_get_device() { return id; } -// ggml_cuda_host_malloc -static inline cudaError_t ggml_cuda_device_malloc(void ** ptr, size_t size, int device) { -#if defined(GGML_USE_HIPBLAS) -#if defined(GGML_HIP_UMA) +static cudaError_t ggml_cuda_device_malloc(void ** ptr, size_t size, int device) { + ggml_cuda_set_device(device); +#if defined(GGML_USE_HIPBLAS) && defined(GGML_HIP_UMA) auto res = hipMallocManaged(ptr, size); if (res == hipSuccess) { // if error we "need" to know why... CUDA_CHECK(hipMemAdvise(*ptr, size, hipMemAdviseSetCoarseGrain, device)); } return res; -#else - return hipMalloc(ptr, size); -#endif #else return cudaMalloc(ptr, size); #endif diff --git a/ggml-cuda/common.cuh b/ggml-cuda/common.cuh index 4c41ee785..22872ca5c 100644 --- a/ggml-cuda/common.cuh +++ b/ggml-cuda/common.cuh @@ -79,11 +79,8 @@ #define cudaHostRegisterReadOnly hipHostRegisterReadOnly #define cudaHostUnregister hipHostUnregister #define cudaLaunchHostFunc hipLaunchHostFunc -#ifdef GGML_HIP_UMA -#define cudaMallocHost(ptr, size) hipHostMalloc(ptr, size) -#else +#define cudaMalloc hipMalloc #define cudaMallocHost(ptr, size) hipHostMalloc(ptr, size, hipHostMallocDefault) -#endif #define cudaMemcpy hipMemcpy #define cudaMemcpyAsync hipMemcpyAsync #define cudaMemcpyPeerAsync hipMemcpyPeerAsync