void omp_target_free(void *device_ptr, int device_num);
Summary The omp_target_free routine frees the device memory allocated by the omp_target_alloc routine.
Constraints on Arguments A program that calls omp_target_free with a non-null pointer that does not have a value returned from omp_target_alloc is non-conforming. The device_num argument must be greater than or equal to zero and less than or equal to the result of omp_get_num_devices().
Binding The binding task set for an omp_target_free region is the generating task, which is the target task generated by the call to the omp_target_free routine.
Effect The omp_target_free routine frees the memory in the device data environment associated with device_ptr. If device_ptr is NULL (or C_NULL_PTR, for Fortran), the operation is ignored.
The omp_target_free routine executes as if part of a target task that is generated by the call to the routine and that is an included task.
Synchronization must be inserted to ensure that all accesses to device_ptr are completed before the call to omp_target_free.
The omp_target_free routine requires an explicit interface and so might not be provided in omp_lib.h.
Execution Model Events The target-data-free-begin event occurs before a thread initiates a data free on a target device.
The target-data-free-end event occurs after a thread initiates a data free on a target device.
Tool Callbacks A thread dispatches a registered ompt_callback_target_data_op_emi callback with ompt_scope_begin as its endpoint argument for each occurrence of a target-data-free-begin event in that thread. Similarly, a thread dispatches a registered ompt_callback_target_data_op_emi callback with ompt_scope_end as its endpoint argument for each occurrence of a target-data-free-end event in that thread. These callbacks have type signature ompt_callback_target_data_op_emi_t.
A thread dispatches a registered ompt_callback_target_data_op callback for each occurrence of a target-data-free-begin event in that thread. The callback occurs in the context of the target task and has type signature ompt_callback_target_data_op_t.
Restrictions Restrictions to the omp_target_free routine are as follows.