# Programming models

## Loki directives

Loki uses an internal set of directives as an intermediate annotation for data movement and parallelisation concepts. Transformations, such as the `SCCAnnotateTransformation`, insert these directives, or they can be written into the original Fortran source code. The `PragmaModelTransformation` should be used, as one of the final steps in a processing pipeline, to translate these directives to the corresponding instructions for the chosen programming model.

Currently, Loki supports OpenACC and some OpenMP. The following table gives a summary of how Loki directives are translated to the corresponding pragmas in either programming model:

Loki generic pragmas to pragma model mapping
Loki | OpenACC | OMP-GPU
--- | --- | ---
`create device(...)` | `declare create(...)` | `declare target(...)`
`update device(...) host(...)` | `update device(...) self(...)` |
`unstructured-data in(...) create(...) attach(...)` | `enter data copyin(...) create(...) attach(...)` | `target enter data map(to: ...) map(alloc: ...)`
`end unstructured-data out(...) delete(...) detach(...) [finalize]` | `exit data copyout(...) delete(...) detach(...) [finalize]` | `target exit data map(from: ...) map(delete: ...) map(release: ... ???)`
`structured-data inout(...) in(...) out(...) create(...) present(...)` | `data copy(...) copyin(...) copyout(...) create(...) present(...)` | `target data map(tofrom: ...) map(to: ...) map(from: ...) map(to: ...)`
`end structured-data inout(...) in(...) out(...)` | `end data` | `end target data`
`loop gang private(...) vlength(...)` | `parallel loop gang private(...) vector_length(...)` | `target teams distribute thread_limit(...) ???`
`end loop gang` | `end parallel loop` | `end target teams distribute`
`loop vector private(...) reduction(...)` | `loop vector private(...) reduction(...)` | `parallel do`
`end loop vector` |  | `end parallel do`
`loop seq` | `loop seq` |
`end loop seq` |  |
`routine vector` | `routine vector` |
`routine seq` | `routine seq` | `declare target`
`data device-present vars(...)` | `data present()` |
`device-present vars (...)` | `data present(...)` |
`end device-present vars(...)` | `end data` |
`device-ptr vars (...)` | `data deviceptr(...)` |
`end device-ptr vars(...)` | `end data` |
`omp-update-global-vars in(...)` |  | `target enter data map(to: ...)`