- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Trying to get my head around asynchronous offloading in Fortran. Tried an example from Jim Jeffers and James Reinders book (page 232). It doesn't run.
Code:
program main
implicit none
integer, parameter :: n = 4096
real, allocatable :: f1(:), f2(:), result
!dir$ attributes offload:mic :: f1, f2
integer :: signal_1, signal_2
!dir$ attributes align : 64 :: f1
!dir$ attributes align : 64 :: f2
allocate(f1(n))
allocate(f2(n))
f1 = 1.0
!dir$ offload_transfer target(mic:0) in(f1) signal(signal_1)
f2 = 3.14
!dir$ offload_transfer target(mic:0) in(f2) signal(signal_2)
!dir$ offload begin target(mic:0) wait(signal_1,signal_2) out(result)
result = f1(434) + f2(222)
!dir$ end offload
print *, "result = ", result
end program main
I run this and get the error:
offload error: device 0 does not have a pending signal for wait((nil))
forrtl: error (76): Abort trap signal
Image PC Routine Line Source
libc.so.6 00007FFFF70C8B35 Unknown Unknown Unknown
libc.so.6 00007FFFF70CA111 Unknown Unknown Unknown
liboffload.so.5 00007FFFF7639AC2 Unknown Unknown Unknown
liboffload.so.5 00007FFFF7643420 Unknown Unknown Unknown
a.out 0000000000403DD0 Unknown Unknown Unknown
a.out 00000000004039EC Unknown Unknown Unknown
libc.so.6 00007FFFF70B4C16 Unknown Unknown Unknown
a.out 0000000000403879 Unknown Unknown Unknown
Aborted
Why doesn't it work? :(
Question 2:
How is the signal / wait thing implemented? Is it a semaphore? If I want to do an asynchronous transfer as part of some other subroutine, can I return the signal integer and use it in an offload wait elsewhere in the code or do I have to use a pointer to some memory to do that?
Jim
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I managed some progress on my own. So this now works:
program main
implicit none
integer, parameter :: n = 4096
real, allocatable :: f1(:), f2(:)
real :: result
!dir$ attributes offload:mic :: f1, f2
integer :: signal_1, signal_2
!dir$ attributes offload:mic :: signal_1, signal_2
signal_1 = 1
signal_2 = 2
allocate(f1(n))
allocate(f2(n))
!dir$ offload_transfer target(mic:0) nocopy(f1,f2: LENGTH(n) ALLOC, RETAIN)
f1 = 1.0
!dir$ offload_transfer target(mic:0) in(f1: REUSE, RETAIN) signal(signal_1)
f2 = 3.14
!dir$ offload_transfer target(mic:0) in(f2: REUSE, RETAIN) signal(signal_2)
!dir$ offload begin target(mic:0) wait(signal_1,signal_2) out(result)
result = f1(434) + f2(222)
!dir$ end offload
print *, "result = ", result
end program main
I have to set the values of the signals by hand???? This seems a bit odd. I assumed it would be like non-blocking communication in MPI.
What's really going on here?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You have piqued my curiousity. I'm going to ask around and find out for you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The “tag” in the SIGNAL clause is treated as a memory reference internally. All “tag” variables must only be set to unique initial values. The variable does not capture the “state” of the internal associated signal itself during execution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for your response.
So is the example in the compiler manual is wrong/outdated then? - http://software.intel.com/sites/products/documentation/doclib/stdxe/2013/composerxe/compiler/fortran-lin/index.htm#GUID-98C9A65B-6307-4798-AA12-25E469B74818.htm#GUID-98C9A65B-6307-4798-AA12-25E469B74818
Also in the examples they set the signal variables to have the offload attribute. Why is this? Upon testing it seems to work the same without it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Recent changes in the handling of the signal variable affected the book and User guide examples; unfortunately making then incomplete/incorrect. We apologize for the confusing/incorrect examples.
The offload attribute is not needed on the signal variables.
The first example with signal variables sin1, sin2, sout1, sout2 is incorrect and should have initialized each to a unique value (e.g. 1, 2, 3, 4) in main() or the module. The declaration within the module need *not* appear within the scope of the !dir$ OPTIONS /offload_attribute_target directive either. The current 13.1 compiler issues an erroneous warning when you move the declaration to after the !dir$ end options. You can safely ignore the warning. The next major release due out later this year will not issue the warning.
The second example with signal variables ktag and gtag is also incorrect by failing to initialize either ktag or gtag to an initial value. In that particular example both could be initialized to the same value since only one is used at a time.
The examples in the documentation will be corrected.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Righto. I understand how it works now. The examples that come with the compiler are actually correct. I'll know in future to check those for the most up-to-date way of using the new offload features.
Thanks for your help!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, the samples included in the product installation are good first resource. Unfortunately documentation changes lag actual functional changes, where functional changes appear in update releases but most often doc updates only appear in the next major new release.
Glad I could help. Wish you well going forward.

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