mirror of
https://github.com/OpenMP/Examples.git
synced 2025-04-07 23:22:11 +01:00
37 lines
619 B
C
37 lines
619 B
C
/*
|
|
* @@name: target_mapper_map.1c
|
|
* @@type: C
|
|
* @@compilable: yes, omp_5.0
|
|
* @@linkable: no
|
|
* @@expect: success
|
|
*/
|
|
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
#define N 100
|
|
|
|
typedef struct myvec{
|
|
size_t len;
|
|
double *data;
|
|
} myvec_t;
|
|
|
|
#pragma omp declare mapper(myvec_t v) \
|
|
map(v, v.data[0:v.len])
|
|
void init(myvec_t *s);
|
|
|
|
int main(){
|
|
|
|
myvec_t s;
|
|
|
|
s.data = (double *)calloc(N,sizeof(double));
|
|
s.len = N;
|
|
|
|
#pragma omp target
|
|
init(&s);
|
|
|
|
printf("s.data[%d]=%lf\n",N-1,s.data[N-1]); //s.data[99]=99.000000
|
|
}
|
|
|
|
void init(myvec_t *s)
|
|
{ for(int i=0; i<s->len; i++) s->data[i]=i; }
|
|
|