2008/7/21 Peter W. Draper <[log in to unmask]>:
> On Mon, 21 Jul 2008, David Berry wrote:
>
>>>> And also, the Intel thread checker threw up reports about potential data
>>>> races within deuler.f.
>>>
>>> Looks like that would only be true if some SAVEing is enabled. Wonder
>>> what
>>> the default in g95 is.
>>
>> Compiling the following using g95 and no additional options, suggests
>> that locals are static:
>>
>>
>> program testf
>> call a( 1 )
>> call a( 2 )
>> end
>>
>> subroutine a( i )
>> if( i .eq. 1 ) fred = 1.234
>> write(*,*) fred
>> end
>>
>> In that fred retains it's value of 1.234 on the second call to "a".
>
> That's not a very good test, the memory is probably accessed in the same way
> for each call. Try:
>
> program testf
> call a( 1 )
> call b( 1 )
> call a( 2 )
> end
>
> subroutine a( i )
> if( i .eq. 1 ) fred = 1.234
> print *,'a = ', fred
> end
>
> subroutine b( i )
> if( i .eq. 1 ) fred = 4.321
> print *,'b = ', fred
> end
>
> That shows:
>
> > ./testf
> a = 1.23399997
> b = 4.3210001
> a = 4.3210001
>
> for me with g77, and also:
>
> > ./testf
> a = 1.234
> b = 4.321
> a = 4.321
>
> for g95. The flag needed for g95 is -fstatic:
>
> > ./testf
> a = 1.234
> b = 4.321
> a = 1.234
>
> Tried some simple array initialisations and they seemed to follow the
> correct pattern, so I remain confused about that report from checker.
>
> Just a thought in passing. I wonder if declaring Fortran routines to be
> RECURSIVE is actually the right thing to do, that must certainly guarantee
> that multiple instances of the same function can work concurrently.
And another thought that came to me whilst doing the holiday
packing... I wonder if CNF is the cause of the SLA data race problems?
The C wrapper for sla_deuler (and many other wrappers) use CNF to
allocate memory that is then passed to the fortran sla routine as an
array argument. Now I presume CNF is not thread safe, so it could be
possible for the allocation of integer identifiers for each malloced
memory block to go up the spout. Could it be possible that the same
integer identifier is being issued for different memory blocks? Or
maybe the other way round - different integer identifiers being
associated with the same memory block?
David
|