brintos

brintos / llvm-project-archived public Read only

0
0
Text · 7.4 KiB · d4c0a76 Raw
157 lines · plain
1// RUN: mlir-opt %s --gpu-to-llvm | FileCheck %s2 3module attributes {gpu.container_module} {4 5  // CHECK-LABEL: func @matvec6  // CHECK: llvm.call @mgpuStreamCreate7  // CHECK: llvm.call @mgpuMemAlloc8  // CHECK: llvm.call @mgpuMemAlloc9  // CHECK: llvm.call @mgpuCreateCoo10  // CHECK: llvm.call @mgpuCreateDnVec11  // CHECK: llvm.call @mgpuSpMVBufferSize12  // CHECK: llvm.call @mgpuSpMV13  // CHECK: llvm.call @mgpuDestroySpMat14  // CHECK: llvm.call @mgpuDestroyDnVec15  // CHECK: llvm.call @mgpuStreamSynchronize16  // CHECK: llvm.call @mgpuStreamDestroy17  func.func @matvec(%arg0: index) {18    %token0 = gpu.wait async19    %mem1, %token1 = gpu.alloc async [%token0] (%arg0) : memref<?xindex>20    %mem2, %token2 = gpu.alloc async [%token1] (%arg0) : memref<?xf64>21    %spmat, %token4 = gpu.create_coo async [%token2] %arg0, %arg0, %arg0, %mem1, %mem1, %mem2 : memref<?xindex>, memref<?xindex>, memref<?xf64>22    %dnvec, %token5 = gpu.create_dn_tensor async [%token4] %mem2, %arg0 : index into memref<?xf64>23    %bufferSz, %token6 = gpu.spmv_buffer_size async [%token5] %spmat, %dnvec, %dnvec  into f6424    %token7 = gpu.spmv async [%token6] %spmat, %dnvec, %dnvec, %mem2 : memref<?xf64> into f6425    %token8 = gpu.destroy_sp_mat async [%token7] %spmat26    %token9 = gpu.destroy_dn_tensor async [%token8] %dnvec27    gpu.wait [%token9]28    return29  }30 31  // CHECK-LABEL: func @matmul32  // CHECK: llvm.call @mgpuStreamCreate33  // CHECK: llvm.call @mgpuMemAlloc34  // CHECK: llvm.call @mgpuMemAlloc35  // CHECK: llvm.call @mgpuCreateCsr36  // CHECK: llvm.call @mgpuCreateDnMat37  // CHECK: llvm.call @mgpuSpMMBufferSize38  // CHECK: llvm.call @mgpuSpMM39  // CHECK: llvm.call @mgpuDestroySpMat40  // CHECK: llvm.call @mgpuDestroyDnMat41  // CHECK: llvm.call @mgpuStreamSynchronize42  // CHECK: llvm.call @mgpuStreamDestroy43  func.func @matmul(%arg0: index) {44    %token0 = gpu.wait async45    %mem1, %token1 = gpu.alloc async [%token0] (%arg0) : memref<?xindex>46    %mem2, %token2 = gpu.alloc async [%token1] (%arg0) : memref<?xf64>47    %spmat, %token4 = gpu.create_csr async [%token2] %arg0, %arg0, %arg0, %mem1, %mem1, %mem2 : memref<?xindex>, memref<?xindex>, memref<?xf64>48    %dnmat, %token5 = gpu.create_dn_tensor async [%token4] %mem2, %arg0, %arg0 : index, index into memref<?xf64>49    %bufferSz, %token6 = gpu.spmm_buffer_size async [%token5] %spmat, %dnmat, %dnmat : index into f6450    %token7 = gpu.spmm async [%token6] %spmat, %dnmat, %dnmat, %mem2 : memref<?xf64> into f6451    %token8 = gpu.destroy_sp_mat async [%token7] %spmat52    %token9 = gpu.destroy_dn_tensor async [%token8] %dnmat53    gpu.wait [%token9]54    return55  }56 57  // CHECK-LABEL: func @spgemm58  // CHECK: llvm.call @mgpuStreamCreate59  // CHECK: llvm.call @mgpuMemAlloc60  // CHECK: llvm.call @mgpuMemAlloc61  // CHECK: llvm.call @mgpuCreateCsr62  // CHECK: llvm.call @mgpuCreateCsr63  // CHECK: llvm.call @mgpuCreateCsr64  // CHECK: llvm.call @mgpuSpGEMMCreateDescr65  // CHECK: llvm.call @mgpuSpGEMMWorkEstimation66  // CHECK: llvm.call @mgpuSpGEMMCompute67  // CHECK: llvm.call @mgpuSpMatGetSize68  // CHECK: llvm.call @mgpuSetCsrPointers69  // CHECK: llvm.call @mgpuSpGEMMCopy70  // CHECK: llvm.call @mgpuSpGEMMDestroyDescr71  // CHECK: llvm.call @mgpuDestroySpMat72  // CHECK: llvm.call @mgpuDestroySpMat73  // CHECK: llvm.call @mgpuDestroySpMat74  // CHECK: llvm.call @mgpuStreamSynchronize75  // CHECK: llvm.call @mgpuStreamDestroy76  func.func @spgemm(%arg0: index) {77    %token0 = gpu.wait async78    %mem1, %token1 = gpu.alloc async [%token0] (%arg0) : memref<?xindex>79    %mem2, %token2 = gpu.alloc async [%token1] (%arg0) : memref<?xf32>80    %spmatA, %token3 = gpu.create_csr async [%token2] %arg0, %arg0, %arg0, %mem1, %mem1, %mem2 : memref<?xindex>, memref<?xindex>, memref<?xf32>81    %spmatB, %token4 = gpu.create_csr async [%token3] %arg0, %arg0, %arg0, %mem1, %mem1, %mem2 : memref<?xindex>, memref<?xindex>, memref<?xf32>82    %spmatC, %token5 = gpu.create_csr async [%token4] %arg0, %arg0, %arg0, %mem1, %mem1, %mem2 : memref<?xindex>, memref<?xindex>, memref<?xf32>83    %spgemmDesc, %token6 = gpu.spgemm_create_descr async [%token5]84    %alloc = memref.alloc() : memref<0xi8>  // nullptr85    %c0 = arith.constant 0 : index86    %bufferSz1, %token7 = gpu.spgemm_work_estimation_or_compute async87                            [%token6]{WORK_ESTIMATION}88                            %spmatA, %spmatB, %spmatC,89                            %spgemmDesc, %c0, %alloc: f32 into memref<0xi8>90    %bufferSz2, %token8 = gpu.spgemm_work_estimation_or_compute async91                               [%token7]{COMPUTE}92                               %spmatA, %spmatB, %spmatC,93                               %spgemmDesc, %c0, %alloc: f32 into memref<0xi8>94    %rows, %cols, %nnz, %token9 = gpu.spmat_get_size async [%token8] %spmatC95    %token10 = gpu.set_csr_pointers async [%token8] %spmatC, %mem1, %mem1, %mem2 : memref<?xindex>, memref<?xindex>, memref<?xf32>96    %token11 = gpu.spgemm_copy async [%token10] %spmatA, %spmatB, %spmatC, %spgemmDesc: f3297    %token12 = gpu.spgemm_destroy_descr async [%token11] %spgemmDesc98    %token13 = gpu.destroy_sp_mat async [%token12] %spmatA99    %token14 = gpu.destroy_sp_mat async [%token13] %spmatB100    %token15 = gpu.destroy_sp_mat async [%token14] %spmatC101    gpu.wait [%token15]102    return103  }104 105  // CHECK-LABEL: func @sddmm106  // CHECK: llvm.call @mgpuStreamCreate107  // CHECK: llvm.call @mgpuMemAlloc108  // CHECK: llvm.call @mgpuMemAlloc109  // CHECK: llvm.call @mgpuCreateCsr110  // CHECK: llvm.call @mgpuCreateDnMat111  // CHECK: llvm.call @mgpuSDDMMBufferSize112  // CHECK: llvm.call @mgpuSDDMM113  // CHECK: llvm.call @mgpuDestroySpMat114  // CHECK: llvm.call @mgpuDestroyDnMat115  // CHECK: llvm.call @mgpuStreamSynchronize116  // CHECK: llvm.call @mgpuStreamDestroy117  func.func @sddmm(%arg0: index) {118    %token0 = gpu.wait async119    %mem1, %token1 = gpu.alloc async [%token0] (%arg0) : memref<?xindex>120    %mem2, %token2 = gpu.alloc async [%token1] (%arg0) : memref<?xf64>121    %spmat, %token4 = gpu.create_csr async [%token2] %arg0, %arg0, %arg0, %mem1, %mem1, %mem2 : memref<?xindex>, memref<?xindex>, memref<?xf64>122    %dnmat, %token5 = gpu.create_dn_tensor async [%token4] %mem2, %arg0, %arg0 : index, index into memref<?xf64>123    %bufferSz, %token6 = gpu.sddmm_buffer_size async [%token5] %dnmat, %dnmat, %spmat into f64124    %token7 = gpu.sddmm async [%token6]  %dnmat, %dnmat, %spmat, %mem2 : memref<?xf64> into f64125    %token8 = gpu.destroy_sp_mat async [%token7] %spmat126    %token9 = gpu.destroy_dn_tensor async [%token8] %dnmat127    gpu.wait [%token9]128    return129  }130 131  // CHECK-LABEL: func @csc_and_bsr132  // CHECK: llvm.call @mgpuStreamCreate133  // CHECK: llvm.call @mgpuMemAlloc134  // CHECK: llvm.call @mgpuMemAlloc135  // CHECK: llvm.call @mgpuCreateCsc136  // CHECK: llvm.call @mgpuCreateBsr137  // CHECK: llvm.call @mgpuDestroySpMat138  // CHECK: llvm.call @mgpuDestroySpMat139  // CHECK: llvm.call @mgpuStreamSynchronize140  // CHECK: llvm.call @mgpuStreamDestroy141  func.func @csc_and_bsr(%arg0: index) {142    %token0 = gpu.wait async143    %mem1, %token1 = gpu.alloc async [%token0] (%arg0) : memref<?xindex>144    %mem2, %token2 = gpu.alloc async [%token1] (%arg0) : memref<?xf64>145    %csc, %token3 = gpu.create_csc async [%token2]146      %arg0, %arg0, %arg0, %mem1, %mem1, %mem2147      : memref<?xindex>, memref<?xindex>, memref<?xf64>148    %bsr, %token4 = gpu.create_bsr async [%token3]149      %arg0, %arg0, %arg0, %arg0, %arg0, %mem1, %mem1, %mem2150      : memref<?xindex>, memref<?xindex>, memref<?xf64>151    %token5 = gpu.destroy_sp_mat async [%token4] %csc152    %token6 = gpu.destroy_sp_mat async [%token5] %bsr153    gpu.wait [%token6]154    return155  }156}157