Skip to content

Commit

Permalink
restore BUILD_* options
Browse files Browse the repository at this point in the history
 * support both BUILD_* and COMPUTE_BACKEND options
  • Loading branch information
wkpark committed Feb 6, 2024
1 parent bb5f6b9 commit c4f9773
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,39 +23,47 @@ set(METAL_FILES csrc/mps_kernels.metal)
# C++ sources are always included
list(APPEND SRC_FILES ${CPP_FILES})

set(COMPUTE_BACKEND "cpu" CACHE STRING "The compute backend to use (cpu, cuda, mps)")
set(COMPUTE_BACKEND "" CACHE STRING "The compute backend to use (cpu, cuda, mps)")
set_property(CACHE COMPUTE_BACKEND PROPERTY STRINGS cpu cuda mps)
option(PTXAS_VERBOSE "Pass through -v flag to PTX Assembler" OFF)

if(APPLE)
set(CMAKE_OSX_DEPLOYMENT_TARGET 13.1)
endif()

option(BUILD_CUDA "Build bitsandbytes with CUDA support" OFF)
option(BUILD_MPS "Build bitsandbytes with MPS support" OFF)
option(NO_CUBLASLT "Disable CUBLAS" OFF)

set(BNB_OUTPUT_NAME "bitsandbytes")

message(STATUS "Building with backend ${COMPUTE_BACKEND}")
if("${COMPUTE_BACKEND}" STREQUAL "")
else()
message(STATUS "Building with backend ${COMPUTE_BACKEND}")
endif()

if(${COMPUTE_BACKEND} STREQUAL "cuda")
if("${COMPUTE_BACKEND}" STREQUAL "cuda")
if(APPLE)
message(FATAL_ERROR "CUDA is not supported on macOS" )
endif()
option(NO_CUBLASLT "Disable CUBLAS" OFF)
set(BUILD_CUDA ON)
set(BUILD_MPS OFF)
message(STATUS "NO_CUBLASLT := ${NO_CUBLASLT}")
elseif(${COMPUTE_BACKEND} STREQUAL "mps")
elseif("${COMPUTE_BACKEND}" STREQUAL "mps")
if(NOT APPLE)
message(FATAL_ERROR "MPS is only supported on macOS" )
endif()
set(BUILD_CUDA OFF)
set(BUILD_MPS ON)
else()
set(BUILD_CUDA OFF)
set(BUILD_MPS OFF)
endif()


if(BUILD_CUDA)
if(APPLE)
message(FATAL_ERROR "CUDA is not supported on macOS" )
endif()
message(STATUS "Building with BUILD_CUDA...")
enable_language(CUDA) # This will fail if CUDA is not found
find_package(CUDAToolkit REQUIRED)

Expand Down Expand Up @@ -120,6 +128,7 @@ elseif(BUILD_MPS)
if(NOT APPLE)
message(FATAL_ERROR "MPS is only supported on macOS" )
endif()
message(STATUS "Building with BUILD_MPS...")

enable_language(OBJCXX)

Expand Down

0 comments on commit c4f9773

Please sign in to comment.