# Memory Directives

([Main README](README.md))

## Single kernel memory operations

These directives can be used for invoking GPU memory operations for a single kernel.

**map([\<var\>])**  
Maps a variable to and from host.

**map(from:[\<var\>])**  
Maps a variable from host.

**map(to:[\<var\>])**  
Maps a variable to host after the kernel finsihes.

**map(fromto:[\<var\>])**  
Maps a variable from host and back after the kernel finishes.

**map(alloc:[\<var\>])**  
Allocate space for the variable on device.

## Allocative memory operations

There are also directives that you can use to allocate memory on the device and is accessible by the kernel.

One can allocate memory on the device with:  
```!$OMP target enter data map (\<specifier\>)```  
Where the specifier is one of the operations listed in the section above.

One can deallocate memory on the device (after the kernel finishes) with:  
```!$OMP target exit data map (delete:<var>)```  
where the data is deleted. If you want to copy over the data, you can use:  
```!$OMP target exit data map (from:<var>)```
