[Mlir-commits] [mlir] 5e78417 - [MLIR][CUDA] Use _alloca instead of alloca on Windows (#85853)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Wed Mar 20 00:32:22 PDT 2024


Author: Justin Holewinski
Date: 2024-03-20T00:32:19-07:00
New Revision: 5e78417db5acbcbfb33e6503e97be0734fca0631

URL: https://github.com/llvm/llvm-project/commit/5e78417db5acbcbfb33e6503e97be0734fca0631
DIFF: https://github.com/llvm/llvm-project/commit/5e78417db5acbcbfb33e6503e97be0734fca0631.diff

LOG: [MLIR][CUDA] Use _alloca instead of alloca on Windows (#85853)

MSVC/Windows does not support `alloca()`; instead it defines `_alloca()`
in `malloc.h`.

Added: 
    

Modified: 
    mlir/lib/ExecutionEngine/CudaRuntimeWrappers.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/ExecutionEngine/CudaRuntimeWrappers.cpp b/mlir/lib/ExecutionEngine/CudaRuntimeWrappers.cpp
index 9d406bdfc7cc9a..09dc30365e37c0 100644
--- a/mlir/lib/ExecutionEngine/CudaRuntimeWrappers.cpp
+++ b/mlir/lib/ExecutionEngine/CudaRuntimeWrappers.cpp
@@ -28,6 +28,7 @@
 #endif // MLIR_ENABLE_CUDA_CUSPARSE
 
 #ifdef _WIN32
+#include <malloc.h>
 #define MLIR_CUDA_WRAPPERS_EXPORT __declspec(dllexport)
 #else
 #define MLIR_CUDA_WRAPPERS_EXPORT __attribute__((visibility("default")))
@@ -287,7 +288,11 @@ extern "C" MLIR_CUDA_WRAPPERS_EXPORT void
 mgpuMemHostRegisterMemRef(int64_t rank, StridedMemRefType<char, 1> *descriptor,
                           int64_t elementSizeBytes) {
   // Only densely packed tensors are currently supported.
+#ifdef _WIN32
+  int64_t *denseStrides = (int64_t *)_alloca(rank * sizeof(int64_t));
+#else
   int64_t *denseStrides = (int64_t *)alloca(rank * sizeof(int64_t));
+#endif // _WIN32
   int64_t *sizes = descriptor->sizes;
   for (int64_t i = rank - 1, runningStride = 1; i >= 0; i--) {
     denseStrides[i] = runningStride;


        


More information about the Mlir-commits mailing list