brintos

brintos / llvm-project-archived public Read only

0
0
Text · 930 B · 9c8addf Raw
37 lines · c
1// RUN: %libomptarget-compile-generic2// RUN: env LIBOMPTARGET_INFO=63 %libomptarget-run-generic 2>&1 | \3// RUN:   %fcheck-generic4//5// REQUIRES: gpu6 7#include <assert.h>8#include <ompx.h>9#include <stdio.h>10#include <stdlib.h>11 12int main(int argc, char *argv[]) {13  const int num_blocks = 64;14  const int block_size = 64;15  const int N = num_blocks * block_size;16  int *data = (int *)malloc(N * sizeof(int));17 18  // CHECK: "PluginInterface" device 0 info: Launching kernel __omp_offloading_{{.*}} with [64,1,1] blocks and [64,1,1] threads in BARE mode19 20#pragma omp target teams ompx_bare num_teams(num_blocks) thread_limit(block_size) map(from: data[0:N])21  {22    int bid = ompx_block_id_x();23    int bdim = ompx_block_dim_x();24    int tid = ompx_thread_id_x();25    int idx = bid * bdim + tid;26    data[idx] = idx;27  }28 29  for (int i = 0; i < N; ++i)30    assert(data[i] == i);31 32  // CHECK: PASS33  printf("PASS\n");34 35  return 0;36}37