43 lines · plain
1// RUN: mlir-opt %s -convert-openmp-to-llvm | mlir-translate -mlir-to-llvmir | FileCheck %s2 3// This file contains MLIR test cases for omp.target_allocmem and omp.target_freemem4 5// CHECK-LABEL: test_alloc_free_i646// CHECK: %[[ALLOC:.*]] = call ptr @omp_target_alloc(i64 8, i32 0)7// CHECK: %[[PTRTOINT:.*]] = ptrtoint ptr %[[ALLOC]] to i648// CHECK: %[[INTTOPTR:.*]] = inttoptr i64 %[[PTRTOINT]] to ptr9// CHECK: call void @omp_target_free(ptr %[[INTTOPTR]], i32 0)10// CHECK: ret void11llvm.func @test_alloc_free_i64() -> () {12 %device = llvm.mlir.constant(0 : i32) : i3213 %1 = omp.target_allocmem %device : i32, i6414 omp.target_freemem %device, %1 : i32, i6415 llvm.return16}17 18// CHECK-LABEL: test_alloc_free_vector_1d_f3219// CHECK: %[[ALLOC:.*]] = call ptr @omp_target_alloc(i64 64, i32 0)20// CHECK: %[[PTRTOINT:.*]] = ptrtoint ptr %[[ALLOC]] to i6421// CHECK: %[[INTTOPTR:.*]] = inttoptr i64 %[[PTRTOINT]] to ptr22// CHECK: call void @omp_target_free(ptr %[[INTTOPTR]], i32 0)23// CHECK: ret void24llvm.func @test_alloc_free_vector_1d_f32() -> () {25 %device = llvm.mlir.constant(0 : i32) : i3226 %1 = omp.target_allocmem %device : i32, vector<16xf32>27 omp.target_freemem %device, %1 : i32, i6428 llvm.return29}30 31// CHECK-LABEL: test_alloc_free_vector_2d_f3232// CHECK: %[[ALLOC:.*]] = call ptr @omp_target_alloc(i64 1024, i32 0)33// CHECK: %[[PTRTOINT:.*]] = ptrtoint ptr %[[ALLOC]] to i6434// CHECK: %[[INTTOPTR:.*]] = inttoptr i64 %[[PTRTOINT]] to ptr35// CHECK: call void @omp_target_free(ptr %[[INTTOPTR]], i32 0)36// CHECK: ret void37llvm.func @test_alloc_free_vector_2d_f32() -> () {38 %device = llvm.mlir.constant(0 : i32) : i3239 %1 = omp.target_allocmem %device : i32, vector<16x16xf32>40 omp.target_freemem %device, %1 : i32, i6441 llvm.return42}43