diff --git a/mlir/lib/ExecutionEngine/CRunnerUtils.cpp b/mlir/lib/ExecutionEngine/CRunnerUtils.cpp index 41c619566b55d..668b65d0801e3 100644 --- a/mlir/lib/ExecutionEngine/CRunnerUtils.cpp +++ b/mlir/lib/ExecutionEngine/CRunnerUtils.cpp @@ -147,9 +147,11 @@ extern "C" double rtclock() { #endif // _WIN32 } -extern "C" void *mlirAlloc(uint64_t size) { return malloc(size); } +// NOLINTBEGIN(*-identifier-naming) -extern "C" void *mlirAlignedAlloc(uint64_t alignment, uint64_t size) { +extern "C" void *_mlir_alloc(uint64_t size) { return malloc(size); } +extern "C" void *_mlir_malloc(uint64_t size) { return malloc(size); } +extern "C" void *_mlir_aligned_alloc(uint64_t alignment, uint64_t size) { #ifdef _WIN32 return _aligned_malloc(size, alignment); #elif defined(__APPLE__) @@ -163,9 +165,9 @@ extern "C" void *mlirAlignedAlloc(uint64_t alignment, uint64_t size) { #endif } -extern "C" void mlirFree(void *ptr) { free(ptr); } +extern "C" void _mlir_free(void *ptr) { free(ptr); } -extern "C" void mlirAlignedFree(void *ptr) { +extern "C" void _mlir_aligned_free(void *ptr) { #ifdef _WIN32 _aligned_free(ptr); #else @@ -213,4 +215,6 @@ IMPL_STDSORT(F64, double) IMPL_STDSORT(F32, float) #undef IMPL_STDSORT +// NOLINTEND(*-identifier-naming) + #endif // MLIR_CRUNNERUTILS_DEFINE_FUNCTIONS diff --git a/mlir/test/python/execution_engine.py b/mlir/test/python/execution_engine.py index d569fcef32bfd..3b3037dc78b2b 100644 --- a/mlir/test/python/execution_engine.py +++ b/mlir/test/python/execution_engine.py @@ -777,7 +777,7 @@ def testNanoTime(): run(testNanoTime) -# Test that nano time clock is available. +# Test dump to object file. # CHECK-LABEL: TEST: testDumpToObjectFile def testDumpToObjectFile(): fd, object_path = tempfile.mkstemp(suffix=".o") @@ -787,13 +787,35 @@ def testDumpToObjectFile(): module = Module.parse( """ module { - func.func @main() attributes { llvm.emit_c_interface } { - return + func.func @main(%arg0: memref<1xf32>) -> memref<1xf32> attributes {llvm.emit_c_interface} { + %out_memref = memref.alloc() : memref<1xf32> + %c0 = arith.constant 0 : index + %load_value = memref.load %arg0[%c0] : memref<1xf32> + memref.store %load_value, %out_memref[%c0] : memref<1xf32> + func.return %out_memref : memref<1xf32> } }""" ) - execution_engine = ExecutionEngine(lowerToLLVM(module), opt_level=3) + if sys.platform == "win32": + shared_libs = [ + "../../../../bin/mlir_runner_utils.dll", + "../../../../bin/mlir_c_runner_utils.dll", + ] + elif sys.platform == "darwin": + shared_libs = [ + "../../../../lib/libmlir_runner_utils.dylib", + "../../../../lib/libmlir_c_runner_utils.dylib", + ] + else: + shared_libs = [ + MLIR_RUNNER_UTILS, + MLIR_C_RUNNER_UTILS, + ] + + execution_engine = ExecutionEngine( + lowerToLLVM(module), opt_level=3, shared_libs=shared_libs + ) # CHECK: Object file exists: True print(f"Object file exists: {os.path.exists(object_path)}")