mirror of
https://github.com/OpenMP/Examples.git
synced 2025-04-07 23:22:11 +01:00
28 lines
510 B
C
28 lines
510 B
C
/*
|
|
* @@name: target-unstructured-data.1.c
|
|
* @@type: C
|
|
* @@compilable: yes
|
|
* @@linkable: no
|
|
* @@expect: success
|
|
*/
|
|
#include <stdlib.h>
|
|
typedef struct {
|
|
double *A;
|
|
int N;
|
|
} Matrix;
|
|
|
|
void init_matrix(Matrix *mat, int n)
|
|
{
|
|
mat->A = (double *)malloc(n*sizeof(double));
|
|
mat->N = n;
|
|
#pragma omp target enter data map(alloc:mat->A[:n])
|
|
}
|
|
|
|
void free_matrix(Matrix *mat)
|
|
{
|
|
#pragma omp target exit data map(delete:mat->A[:mat->N])
|
|
mat->N = 0;
|
|
free(mat->A);
|
|
mat->A = NULL;
|
|
}
|