musa.h 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. /**
  2. * llama.cpp - commit 3f1ae2e32cde00c39b96be6d01c2997c29bae555 - do not edit this file
  3. *
  4. * MIT License
  5. *
  6. * Copyright (c) 2023-2024 The ggml authors
  7. *
  8. * Permission is hereby granted, free of charge, to any person obtaining a copy
  9. * of this software and associated documentation files (the "Software"), to deal
  10. * in the Software without restriction, including without limitation the rights
  11. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  12. * copies of the Software, and to permit persons to whom the Software is
  13. * furnished to do so, subject to the following conditions:
  14. *
  15. * The above copyright notice and this permission notice shall be included in all
  16. * copies or substantial portions of the Software.
  17. *
  18. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  19. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  21. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  22. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  23. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  24. * SOFTWARE.
  25. */
  26. #pragma once
  27. #include <musa_runtime.h>
  28. #include <musa.h>
  29. #include <mublas.h>
  30. #include <musa_fp16.h>
  31. #define CUBLAS_COMPUTE_16F CUDA_R_16F
  32. #define CUBLAS_COMPUTE_32F CUDA_R_32F
  33. #define CUBLAS_COMPUTE_32F_FAST_16F MUBLAS_COMPUTE_32F_FAST_16F
  34. #define CUBLAS_GEMM_DEFAULT MUBLAS_GEMM_DEFAULT
  35. #define CUBLAS_GEMM_DEFAULT_TENSOR_OP MUBLAS_GEMM_DEFAULT
  36. #define CUBLAS_OP_N MUBLAS_OP_N
  37. #define CUBLAS_OP_T MUBLAS_OP_T
  38. #define CUBLAS_STATUS_SUCCESS MUBLAS_STATUS_SUCCESS
  39. #define CUBLAS_TF32_TENSOR_OP_MATH MUBLAS_MATH_MODE_DEFAULT
  40. #define CUDA_R_16F MUSA_R_16F
  41. #define CUDA_R_32F MUSA_R_32F
  42. #define cublasComputeType_t cudaDataType_t
  43. #define cublasCreate mublasCreate
  44. #define cublasDestroy mublasDestroy
  45. #define cublasGemmEx mublasGemmEx
  46. #define cublasGemmBatchedEx mublasGemmBatchedEx
  47. #define cublasGemmStridedBatchedEx mublasGemmStridedBatchedEx
  48. #define cublasHandle_t mublasHandle_t
  49. #define cublasSetMathMode mublasSetMathMode
  50. #define cublasSetStream mublasSetStream
  51. #define cublasSgemm mublasSgemm
  52. #define cublasStatus_t mublasStatus_t
  53. #define cublasOperation_t mublasOperation_t
  54. #define cublasGetStatusString mublasStatus_to_string
  55. #define cudaDataType_t musaDataType_t
  56. #define cudaDeviceCanAccessPeer musaDeviceCanAccessPeer
  57. #define cudaDeviceDisablePeerAccess musaDeviceDisablePeerAccess
  58. #define cudaDeviceEnablePeerAccess musaDeviceEnablePeerAccess
  59. #define cudaDeviceProp musaDeviceProp
  60. #define cudaDeviceSynchronize musaDeviceSynchronize
  61. #define cudaError_t musaError_t
  62. #define cudaErrorPeerAccessAlreadyEnabled musaErrorPeerAccessAlreadyEnabled
  63. #define cudaErrorPeerAccessNotEnabled musaErrorPeerAccessNotEnabled
  64. #define cudaEventCreateWithFlags musaEventCreateWithFlags
  65. #define cudaEventDisableTiming musaEventDisableTiming
  66. #define cudaEventRecord musaEventRecord
  67. #define cudaEventSynchronize musaEventSynchronize
  68. #define cudaEvent_t musaEvent_t
  69. #define cudaEventDestroy musaEventDestroy
  70. #define cudaFree musaFree
  71. #define cudaFreeHost musaFreeHost
  72. #define cudaGetDevice musaGetDevice
  73. #define cudaGetDeviceCount musaGetDeviceCount
  74. #define cudaGetDeviceProperties musaGetDeviceProperties
  75. #define cudaGetErrorString musaGetErrorString
  76. #define cudaGetLastError musaGetLastError
  77. #define cudaHostRegister musaHostRegister
  78. #define cudaHostRegisterPortable musaHostRegisterPortable
  79. #define cudaHostRegisterReadOnly musaHostRegisterReadOnly
  80. #define cudaHostUnregister musaHostUnregister
  81. #define cudaLaunchHostFunc musaLaunchHostFunc
  82. #define cudaMalloc musaMalloc
  83. #define cudaMallocHost musaMallocHost
  84. #define cudaMallocManaged musaMallocManaged
  85. #define cudaMemcpy musaMemcpy
  86. #define cudaMemcpyAsync musaMemcpyAsync
  87. #define cudaMemcpyPeerAsync musaMemcpyPeerAsync
  88. #define cudaMemcpy2DAsync musaMemcpy2DAsync
  89. #define cudaMemcpyDeviceToDevice musaMemcpyDeviceToDevice
  90. #define cudaMemcpyDeviceToHost musaMemcpyDeviceToHost
  91. #define cudaMemcpyHostToDevice musaMemcpyHostToDevice
  92. #define cudaMemcpyKind musaMemcpyKind
  93. #define cudaMemset musaMemset
  94. #define cudaMemsetAsync musaMemsetAsync
  95. #define cudaMemGetInfo musaMemGetInfo
  96. #define cudaOccupancyMaxPotentialBlockSize musaOccupancyMaxPotentialBlockSize
  97. #define cudaSetDevice musaSetDevice
  98. #define cudaStreamCreateWithFlags musaStreamCreateWithFlags
  99. #define cudaStreamDestroy musaStreamDestroy
  100. #define cudaStreamFireAndForget musaStreamFireAndForget
  101. #define cudaStreamNonBlocking musaStreamNonBlocking
  102. #define cudaStreamPerThread musaStreamPerThread
  103. #define cudaStreamSynchronize musaStreamSynchronize
  104. #define cudaStreamWaitEvent musaStreamWaitEvent
  105. #define cudaStream_t musaStream_t
  106. #define cudaSuccess musaSuccess
  107. // Additional mappings for MUSA virtual memory pool
  108. #define CU_DEVICE_ATTRIBUTE_VIRTUAL_MEMORY_MANAGEMENT_SUPPORTED MU_DEVICE_ATTRIBUTE_VIRTUAL_ADDRESS_MANAGEMENT_SUPPORTED
  109. #define CU_MEM_ACCESS_FLAGS_PROT_READWRITE MU_MEM_ACCESS_FLAGS_PROT_READWRITE
  110. #define CU_MEM_ALLOC_GRANULARITY_RECOMMENDED MU_MEM_ALLOC_GRANULARITY_RECOMMENDED
  111. #define CU_MEM_ALLOCATION_TYPE_PINNED MU_MEM_ALLOCATION_TYPE_PINNED
  112. #define CU_MEM_LOCATION_TYPE_DEVICE MU_MEM_LOCATION_TYPE_DEVICE
  113. #define CUdevice MUdevice
  114. #define CUdeviceptr MUdeviceptr
  115. #define CUmemAccessDesc MUmemAccessDesc
  116. #define CUmemAllocationProp MUmemAllocationProp
  117. #define CUmemGenericAllocationHandle MUmemGenericAllocationHandle
  118. #define cuDeviceGet muDeviceGet
  119. #define cuDeviceGetAttribute muDeviceGetAttribute
  120. #define cuMemAddressFree muMemAddressFree
  121. #define cuMemAddressReserve muMemAddressReserve
  122. #define cuMemCreate muMemCreate
  123. #define cuMemGetAllocationGranularity muMemGetAllocationGranularity
  124. #define cuMemMap muMemMap
  125. #define cuMemRelease muMemRelease
  126. #define cuMemSetAccess muMemSetAccess
  127. #define cuMemUnmap muMemUnmap
  128. #define cudaFuncAttributeMaxDynamicSharedMemorySize musaFuncAttributeMaxDynamicSharedMemorySize
  129. #define cudaFuncSetAttribute musaFuncSetAttribute
  130. #define cudaMemcpy3DPeerParms musaMemcpy3DPeerParms
  131. #define make_cudaExtent make_musaExtent
  132. #define make_cudaPitchedPtr make_musaPitchedPtr
  133. // Additional mappings for MUSA graphs
  134. #define CUDA_SUCCESS MUSA_SUCCESS
  135. #define CUresult MUresult
  136. #define cuGetErrorString muGetErrorString
  137. #define cudaErrorGraphExecUpdateFailure musaErrorGraphExecUpdateFailure
  138. #define cudaErrorInvalidDeviceFunction musaErrorInvalidDeviceFunction
  139. #define cudaGraphDestroy musaGraphDestroy
  140. #define cudaGraphExecDestroy musaGraphExecDestroy
  141. #define cudaGraphExec_t musaGraphExec_t
  142. #define cudaGraphExecUpdate musaGraphExecUpdate
  143. #define cudaGraphExecUpdateResultInfo musaGraphExecUpdateResult
  144. #define cudaGraphGetNodes musaGraphGetNodes
  145. #define cudaGraphInstantiate musaGraphInstantiate
  146. #define cudaGraphKernelNodeGetParams musaGraphKernelNodeGetParams
  147. #define cudaGraphKernelNodeSetParams musaGraphKernelNodeSetParams
  148. #define cudaGraphLaunch musaGraphLaunch
  149. #define cudaGraphNodeGetType musaGraphNodeGetType
  150. #define cudaGraphNode_t musaGraphNode_t
  151. #define cudaGraphNodeType musaGraphNodeType
  152. #define cudaGraphNodeTypeKernel musaGraphNodeTypeKernel
  153. #define cudaGraph_t musaGraph_t
  154. #define cudaKernelNodeParams musaKernelNodeParams
  155. #define cudaStreamCaptureModeRelaxed musaStreamCaptureModeRelaxed
  156. #define cudaStreamEndCapture musaStreamEndCapture