omp_target_alloc

Purpose

The omp_target_alloc function allocates memory in a device data environment.

Prototype

void* omp_target_alloc(size_t size, int device_num);

Parameters

size
Specifies the size in bytes of the storage memory to be allocated.
device_num
Must be the device number of the host device or be non-negative and less than the number of target devices.

Usage

Pointer arithmetic is not supported on the device address that is returned by this function.

You can free the storage that is returned by this function only by using the omp_target_free function; otherwise, the compiler behavior is unspecified.

If it cannot allocate the memory in the device data environment dynamically, it returns NULL.

GPU begins You cannot call this function on a target device. GPU ends



Voice your opinion on getting help information Ask IBM compiler experts a technical question in the IBM XL compilers forum Reach out to us