diff --git a/mlir/include/mlir/ExecutionEngine/RunnerUtils.h b/mlir/include/mlir/ExecutionEngine/RunnerUtils.h --- a/mlir/include/mlir/ExecutionEngine/RunnerUtils.h +++ b/mlir/include/mlir/ExecutionEngine/RunnerUtils.h @@ -33,6 +33,7 @@ #include #include +#include #include #include "mlir/ExecutionEngine/CRunnerUtils.h" @@ -72,6 +73,10 @@ // Templated instantiation follows. //////////////////////////////////////////////////////////////////////////////// namespace impl { +using index_type = uint64_t; +using complex64 = std::complex; +using complex32 = std::complex; + template std::ostream &operator<<(std::ostream &os, const Vector &v); @@ -350,6 +355,12 @@ _mlir_ciface_printMemrefShapeF32(UnrankedMemRefType *m); extern "C" MLIR_RUNNERUTILS_EXPORT void _mlir_ciface_printMemrefShapeF64(UnrankedMemRefType *m); +extern "C" MLIR_RUNNERUTILS_EXPORT void +_mlir_ciface_printMemrefShapeInd(UnrankedMemRefType *m); +extern "C" MLIR_RUNNERUTILS_EXPORT void +_mlir_ciface_printMemrefShapeC32(UnrankedMemRefType *m); +extern "C" MLIR_RUNNERUTILS_EXPORT void +_mlir_ciface_printMemrefShapeC64(UnrankedMemRefType *m); extern "C" MLIR_RUNNERUTILS_EXPORT void _mlir_ciface_printMemrefI8(UnrankedMemRefType *m); @@ -361,6 +372,12 @@ _mlir_ciface_printMemrefF32(UnrankedMemRefType *m); extern "C" MLIR_RUNNERUTILS_EXPORT void _mlir_ciface_printMemrefF64(UnrankedMemRefType *m); +extern "C" MLIR_RUNNERUTILS_EXPORT void +_mlir_ciface_printMemrefInd(UnrankedMemRefType *m); +extern "C" MLIR_RUNNERUTILS_EXPORT void +_mlir_ciface_printMemrefC32(UnrankedMemRefType *m); +extern "C" MLIR_RUNNERUTILS_EXPORT void +_mlir_ciface_printMemrefC64(UnrankedMemRefType *m); extern "C" MLIR_RUNNERUTILS_EXPORT int64_t _mlir_ciface_nanoTime(); @@ -368,6 +385,9 @@ extern "C" MLIR_RUNNERUTILS_EXPORT void printMemrefI64(int64_t rank, void *ptr); extern "C" MLIR_RUNNERUTILS_EXPORT void printMemrefF32(int64_t rank, void *ptr); extern "C" MLIR_RUNNERUTILS_EXPORT void printMemrefF64(int64_t rank, void *ptr); +extern "C" MLIR_RUNNERUTILS_EXPORT void printMemrefInd(int64_t rank, void *ptr); +extern "C" MLIR_RUNNERUTILS_EXPORT void printMemrefC32(int64_t rank, void *ptr); +extern "C" MLIR_RUNNERUTILS_EXPORT void printMemrefC64(int64_t rank, void *ptr); extern "C" MLIR_RUNNERUTILS_EXPORT void printCString(char *str); extern "C" MLIR_RUNNERUTILS_EXPORT void @@ -381,6 +401,21 @@ extern "C" MLIR_RUNNERUTILS_EXPORT void _mlir_ciface_printMemref4dF32(StridedMemRefType *m); +extern "C" MLIR_RUNNERUTILS_EXPORT void +_mlir_ciface_printMemref1dI8(StridedMemRefType *m); +extern "C" MLIR_RUNNERUTILS_EXPORT void +_mlir_ciface_printMemref1dI32(StridedMemRefType *m); +extern "C" MLIR_RUNNERUTILS_EXPORT void +_mlir_ciface_printMemref1dI64(StridedMemRefType *m); +extern "C" MLIR_RUNNERUTILS_EXPORT void +_mlir_ciface_printMemref1dF64(StridedMemRefType *m); +extern "C" MLIR_RUNNERUTILS_EXPORT void +_mlir_ciface_printMemref1dInd(StridedMemRefType *m); +extern "C" MLIR_RUNNERUTILS_EXPORT void +_mlir_ciface_printMemref1dC32(StridedMemRefType *m); +extern "C" MLIR_RUNNERUTILS_EXPORT void +_mlir_ciface_printMemref1dC64(StridedMemRefType *m); + extern "C" MLIR_RUNNERUTILS_EXPORT void _mlir_ciface_printMemrefVector4x4xf32( StridedMemRefType, 2> *m); @@ -390,6 +425,15 @@ UnrankedMemRefType *actual, UnrankedMemRefType *expected); extern "C" MLIR_RUNNERUTILS_EXPORT int64_t _mlir_ciface_verifyMemRefF64( UnrankedMemRefType *actual, UnrankedMemRefType *expected); +extern "C" MLIR_RUNNERUTILS_EXPORT int64_t +_mlir_ciface_verifyMemRefInd(UnrankedMemRefType *actual, + UnrankedMemRefType *expected); +extern "C" MLIR_RUNNERUTILS_EXPORT int64_t +_mlir_ciface_verifyMemRefC32(UnrankedMemRefType *actual, + UnrankedMemRefType *expected); +extern "C" MLIR_RUNNERUTILS_EXPORT int64_t +_mlir_ciface_verifyMemRefC64(UnrankedMemRefType *actual, + UnrankedMemRefType *expected); extern "C" MLIR_RUNNERUTILS_EXPORT int64_t verifyMemRefI32(int64_t rank, void *actualPtr, @@ -400,5 +444,14 @@ extern "C" MLIR_RUNNERUTILS_EXPORT int64_t verifyMemRefF64(int64_t rank, void *actualPtr, void *expectedPtr); +extern "C" MLIR_RUNNERUTILS_EXPORT int64_t verifyMemRefInd(int64_t rank, + void *actualPtr, + void *expectedPtr); +extern "C" MLIR_RUNNERUTILS_EXPORT int64_t verifyMemRefC32(int64_t rank, + void *actualPtr, + void *expectedPtr); +extern "C" MLIR_RUNNERUTILS_EXPORT int64_t verifyMemRefC64(int64_t rank, + void *actualPtr, + void *expectedPtr); #endif // MLIR_EXECUTIONENGINE_RUNNERUTILS_H diff --git a/mlir/lib/ExecutionEngine/RunnerUtils.cpp b/mlir/lib/ExecutionEngine/RunnerUtils.cpp --- a/mlir/lib/ExecutionEngine/RunnerUtils.cpp +++ b/mlir/lib/ExecutionEngine/RunnerUtils.cpp @@ -51,6 +51,27 @@ std::cout << "\n"; } +extern "C" void +_mlir_ciface_printMemrefShapeInd(UnrankedMemRefType *M) { + std::cout << "Unranked Memref "; + printMemRefMetaData(std::cout, DynamicMemRefType(*M)); + std::cout << "\n"; +} + +extern "C" void +_mlir_ciface_printMemrefShapeC32(UnrankedMemRefType *M) { + std::cout << "Unranked Memref "; + printMemRefMetaData(std::cout, DynamicMemRefType(*M)); + std::cout << "\n"; +} + +extern "C" void +_mlir_ciface_printMemrefShapeC64(UnrankedMemRefType *M) { + std::cout << "Unranked Memref "; + printMemRefMetaData(std::cout, DynamicMemRefType(*M)); + std::cout << "\n"; +} + extern "C" void _mlir_ciface_printMemrefVector4x4xf32( StridedMemRefType, 2> *M) { impl::printMemRef(*M); @@ -76,6 +97,21 @@ impl::printMemRef(*M); } +extern "C" void +_mlir_ciface_printMemrefInd(UnrankedMemRefType *M) { + impl::printMemRef(*M); +} + +extern "C" void +_mlir_ciface_printMemrefC32(UnrankedMemRefType *M) { + impl::printMemRef(*M); +} + +extern "C" void +_mlir_ciface_printMemrefC64(UnrankedMemRefType *M) { + impl::printMemRef(*M); +} + extern "C" int64_t _mlir_ciface_nanoTime() { auto now = std::chrono::high_resolution_clock::now(); auto duration = now.time_since_epoch(); @@ -104,6 +140,24 @@ _mlir_ciface_printMemrefF64(&descriptor); } +// Assume index_type is in fact uint64_t. +static_assert(std::is_same::value, + "Expected index_type == uint64_t"); +extern "C" void printMemrefInd(int64_t rank, void *ptr) { + UnrankedMemRefType descriptor = {rank, ptr}; + _mlir_ciface_printMemrefInd(&descriptor); +} + +extern "C" void printMemrefC32(int64_t rank, void *ptr) { + UnrankedMemRefType descriptor = {rank, ptr}; + _mlir_ciface_printMemrefC32(&descriptor); +} + +extern "C" void printMemrefC64(int64_t rank, void *ptr) { + UnrankedMemRefType descriptor = {rank, ptr}; + _mlir_ciface_printMemrefC64(&descriptor); +} + extern "C" void printCString(char *str) { printf("%s", str); } extern "C" void _mlir_ciface_printMemref0dF32(StridedMemRefType *M) { @@ -122,6 +176,39 @@ impl::printMemRef(*M); } +extern "C" void _mlir_ciface_printMemref1dI8(StridedMemRefType *M) { + impl::printMemRef(*M); +} + +extern "C" void +_mlir_ciface_printMemref1dI32(StridedMemRefType *M) { + impl::printMemRef(*M); +} + +extern "C" void +_mlir_ciface_printMemref1dI64(StridedMemRefType *M) { + impl::printMemRef(*M); +} + +extern "C" void _mlir_ciface_printMemref1dF64(StridedMemRefType *M) { + impl::printMemRef(*M); +} + +extern "C" void +_mlir_ciface_printMemref1dInd(StridedMemRefType *M) { + impl::printMemRef(*M); +} + +extern "C" void +_mlir_ciface_printMemref1dC32(StridedMemRefType *M) { + impl::printMemRef(*M); +} + +extern "C" void +_mlir_ciface_printMemref1dC64(StridedMemRefType *M) { + impl::printMemRef(*M); +} + extern "C" int64_t _mlir_ciface_verifyMemRefI32(UnrankedMemRefType *actual, UnrankedMemRefType *expected) { @@ -140,6 +227,24 @@ return impl::verifyMemRef(*actual, *expected); } +extern "C" int64_t +_mlir_ciface_verifyMemRefInd(UnrankedMemRefType *actual, + UnrankedMemRefType *expected) { + return impl::verifyMemRef(*actual, *expected); +} + +extern "C" int64_t +_mlir_ciface_verifyMemRefC32(UnrankedMemRefType *actual, + UnrankedMemRefType *expected) { + return impl::verifyMemRef(*actual, *expected); +} + +extern "C" int64_t +_mlir_ciface_verifyMemRefC64(UnrankedMemRefType *actual, + UnrankedMemRefType *expected) { + return impl::verifyMemRef(*actual, *expected); +} + extern "C" int64_t verifyMemRefI32(int64_t rank, void *actualPtr, void *expectedPtr) { UnrankedMemRefType actualDesc = {rank, actualPtr}; @@ -161,4 +266,25 @@ return _mlir_ciface_verifyMemRefF64(&actualDesc, &expectedDesc); } +extern "C" int64_t verifyMemRefInd(int64_t rank, void *actualPtr, + void *expectedPtr) { + UnrankedMemRefType actualDesc = {rank, actualPtr}; + UnrankedMemRefType expectedDesc = {rank, expectedPtr}; + return _mlir_ciface_verifyMemRefInd(&actualDesc, &expectedDesc); +} + +extern "C" int64_t verifyMemRefC32(int64_t rank, void *actualPtr, + void *expectedPtr) { + UnrankedMemRefType actualDesc = {rank, actualPtr}; + UnrankedMemRefType expectedDesc = {rank, expectedPtr}; + return _mlir_ciface_verifyMemRefC32(&actualDesc, &expectedDesc); +} + +extern "C" int64_t verifyMemRefC64(int64_t rank, void *actualPtr, + void *expectedPtr) { + UnrankedMemRefType actualDesc = {rank, actualPtr}; + UnrankedMemRefType expectedDesc = {rank, expectedPtr}; + return _mlir_ciface_verifyMemRefC64(&actualDesc, &expectedDesc); +} + // NOLINTEND(*-identifier-naming)