mirror of
https://github.com/facebookresearch/faiss.git
synced 2026-10-12 02:13:36 +00:00
Fix FAISS build with ROCm7 (#4567)
Summary: Pull Request resolved: https://github.com/facebookresearch/faiss/pull/4567 D80101131 enabled FAISS library to build with AMD GPUs. However, certain libraries are written using previous version of ROCm / hipBLAS libraries and fails to build with ROCm7 (hipBLAS 3). This library is a dependency of MVAI (minimal_viable_ai) so the build is currently broken for MVAI package with ROCm7. New hipBLAS has API renamed that landed with ROCm 7 (hipBLAS 3.x). Specifically, `hipblasDatatype_t` was removed and replaced by two separate types: - `hipDataType` for A/B/C/scale datatypes - `hipblasComputeType_t` for the GEMM compute type To make sure it build with both old and new versions, we need to add additional compile-time check to pick the right APIs. Reviewed By: leitian Differential Revision: D81293871 fbshipit-source-id: 755758ef485a74b35651412c5dbd3bc728145a07
This commit is contained in:
committed by
Facebook GitHub Bot
parent
50b3eb48d2
commit
d98ff432b9
@@ -22,19 +22,26 @@ struct GetCudaType;
|
||||
|
||||
#ifdef USE_AMD_ROCM
|
||||
|
||||
#if ((hipblasVersionMajor == 2 && defined(HIPBLAS_V2)) || \
|
||||
hipblasVersionMajor >= 3)
|
||||
using hipDataTypeCompat = hipDataType;
|
||||
#else
|
||||
using hipDataTypeCompat = hipblasDatatype_t;
|
||||
#endif
|
||||
|
||||
template <>
|
||||
struct GetCudaType<float> {
|
||||
static constexpr hipblasDatatype_t Type = HIPBLAS_R_32F;
|
||||
static constexpr hipDataTypeCompat Type = HIPBLAS_R_32F;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct GetCudaType<half> {
|
||||
static constexpr hipblasDatatype_t Type = HIPBLAS_R_16F;
|
||||
static constexpr hipDataTypeCompat Type = HIPBLAS_R_16F;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct GetCudaType<__hip_bfloat16> {
|
||||
static constexpr hipblasDatatype_t Type = HIPBLAS_R_16B;
|
||||
static constexpr hipDataTypeCompat Type = HIPBLAS_R_16B;
|
||||
};
|
||||
|
||||
#else
|
||||
@@ -76,6 +83,13 @@ cublasStatus_t rawGemm(
|
||||
auto cBT = GetCudaType<BT>::Type;
|
||||
|
||||
#ifdef USE_AMD_ROCM
|
||||
#if ((hipblasVersionMajor == 2 && defined(HIPBLAS_V2)) || \
|
||||
hipblasVersionMajor >= 3)
|
||||
auto computeType = HIPBLAS_COMPUTE_32F;
|
||||
#else
|
||||
auto computeType = HIPBLAS_R_32F;
|
||||
#endif
|
||||
|
||||
return hipblasGemmEx(
|
||||
handle,
|
||||
transa,
|
||||
@@ -94,7 +108,7 @@ cublasStatus_t rawGemm(
|
||||
C,
|
||||
HIPBLAS_R_32F,
|
||||
ldc,
|
||||
HIPBLAS_R_32F,
|
||||
computeType,
|
||||
HIPBLAS_GEMM_DEFAULT);
|
||||
#else
|
||||
|
||||
@@ -177,6 +191,13 @@ cublasStatus_t rawBatchGemm(
|
||||
|
||||
// Always accumulate in f32
|
||||
#ifdef USE_AMD_ROCM
|
||||
#if ((hipblasVersionMajor == 2 && defined(HIPBLAS_V2)) || \
|
||||
hipblasVersionMajor >= 3)
|
||||
auto computeType = HIPBLAS_COMPUTE_32F;
|
||||
#else
|
||||
auto computeType = HIPBLAS_R_32F;
|
||||
#endif
|
||||
|
||||
return hipblasGemmStridedBatchedEx(
|
||||
handle,
|
||||
transa,
|
||||
@@ -199,7 +220,7 @@ cublasStatus_t rawBatchGemm(
|
||||
ldc,
|
||||
strideC,
|
||||
batchCount,
|
||||
HIPBLAS_R_32F,
|
||||
computeType,
|
||||
HIPBLAS_GEMM_DEFAULT);
|
||||
#else
|
||||
return cublasGemmStridedBatchedEx(
|
||||
|
||||
Reference in New Issue
Block a user