- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
if i do as follows in fortran
...
integer,allocatable::a(:)
...
allocate(a(n))
...
!dir$ offload target(mic) inout(a)
!$omp parallel do...
inside the do loop a is being passed to subroutines and assigned values. is it ok to put a inside inout as above? or is there anything still needed? Thanks!
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Looks like that should work. I believe the array size is known at run-time and included in the array descriptor passed with the offload so length(n) modifier is not needed for the code you outlined. If you do not need the initial values of A from the host then you could avoid the data transfer of those initial values using OUT vs. INOUT.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks! Also, what happens internally regarding the alloc_if/free_if. As far as I understand default for those is true, so in my case space for "a" allocated on coprocessor before copying the data from host to coprocessor, then the data copied into data space, then the final results of "a" are copied from coprocessor to host space of "a", and at the end coprocessor deallocates space allocated for "a" on coprocessor. Am I right?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Here's the detail I could not recall earlier and just found in the Fortran UG under the LENGTH ( element-count-expr ) on the OFFLOAD topic.
A Fortran array variable can be one of four major types: explicit-shape, assumed-shape, deferred-shape and assumed-size. The runtime descriptor for the first three types makes that array variable's size known at compile time or at runtime.
...
By default, the compiler copies explicit-shape, assumed-shape and deferred-shape arrays in their entirety. They do not need an element-count-expr. However, you can use an optional element-count-expr to specify the total number of elements to copy, which limits the number of elements copied back and forth in the last dimension of the array.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, you are correct about the behavior of the alloc_if/free_if.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks a lot!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You're welcome.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page