Definition | Back to Top |
It can precede a DO loop or FORALL, asserting that iterations may be executed independently.
The NEW clause in an INDEPENDENT directive may cause scalars or arrays to be "privatized" by the compiler.
Syntax of the INDEPENDENT directive:
INDEPENDENT [ , NEW variable(s) ]
General Examples | Back to Top |
!HPF$ INDEPENDENT DO i = 1, 100 a(i) = b(i) c(i) = d(i) END DOIn example 1 it is easy to see that there are no data dependencies and that the loop may be safely parallelized, so it is safe to give the compiler the information that the loop is "INDEPENDENT". However, it is probably also unnecessary in such a simple loop.
Example 2:
!HPF$ INDEPENDENT DO i = 100 a(b(i)) = c(i) END DOIn example 2, the compiler may "play it safe" and not parallelize this loop if it cannot prove that there are no repeated values in b(i). If the programmer knows this information, it is useful to share that with the compiler via the directive.
Tariff Program Examples | Back to Top |
!HPF$ INDEPENDENT,NEW(k,test,apath)
do 2225 j = 1, ndemm
do 2245, k = 1, nsupm
test = (-supp(k) - thxlin(k,j)) * (1. + tar(k,j)) + demp(j)
apath = max(0., apatho(k,j) + (rho * test))
apathn(k, j) = apath
demand(j) = demand(j) + apath
2245 continue
2225 continue
Move the program display to this section
!HPF$ INDEPENDENT,NEW(k,test,apath)
do 12225 j = 1, ndemm
do 12230 k = 1, nsupm
test =(-supp(k) - thxlin(k, j))*(1. + tar(k, j)) + demp(j)
apath = max( 0., apatho(k, j) + rho * test)
apathn(k, j) = apath
demand(j) = demand(j) + apath
12230 continue
12225 continue
Move the program display to this section
In both loops, the NEW option must be used to indicate that the variables listed should be treated as if they were allocated anew for each iteration, or private within the loop body.
Exercise (long) | Back to Top |
This lab may be run using the Virtual Workshop Companion Web interface, which allows you to work through the lab exercise without opening a telnet session. If you would like to use the VW Companion, click on the preceding link, which will open up a separate browser window from which you will supply your userid and password. The rest of the interface will be launched from there.
Whether you prefer to log in or to use the VW Companion, you'll need to select the instructions for the lab, which will come up in this window.
Back to Top |