MCPcopy Create free account
hub / github.com/NVIDIA/cuda-tile / mlirCudaTileWriteBytecodeToBuffer

Function mlirCudaTileWriteBytecodeToBuffer

lib/CAPI/Dialect/CudaTileDialect.cpp:662–686  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

660}
661
662MlirStringRef mlirCudaTileWriteBytecodeToBuffer(MlirOperation moduleOp) {
663 auto *op = unwrap(moduleOp);
664
665 // Extract cuda_tile::ModuleOp (handles both direct and nested cases)
666 auto cudaTileModule = extractCudaTileModuleOp(op);
667 if (!cudaTileModule)
668 return mlirStringRefCreateFromCString("");
669
670 // Allocate buffer that caller must free
671 std::string temp;
672 llvm::raw_string_ostream stream(temp);
673 if (failed(cuda_tile::writeBytecode(stream, cudaTileModule,
674 BytecodeVersion::kCurrentVersion)))
675 return mlirStringRefCreateFromCString("");
676
677 stream.flush();
678
679 // Allocate persistent buffer
680 char *buffer = static_cast<char *>(malloc(temp.size()));
681 if (!buffer)
682 return mlirStringRefCreateFromCString("");
683
684 memcpy(buffer, temp.data(), temp.size());
685 return mlirStringRefCreate(buffer, temp.size());
686}
687
688void mlirCudaTileFreeBuffer(MlirStringRef buffer) {
689 if (buffer.data && buffer.length > 0)

Callers 1

NB_MODULEFunction · 0.85

Calls 1

sizeMethod · 0.80

Tested by

no test coverage detected