Thanks Tim. 

I am doing this and it seems that  the type (Float64) of a given 
SharedArray is not corectly "detected" when it is inside a parallel loop. 
The code for a serial loop has no
::Any and the code with @parallel for has many.

But as I am not an expert in reading the output of @code_warntype, I can be 
wrong. I will study this in more details.

Thanks again for your response.



On Wednesday, July 8, 2015 at 5:43:12 PM UTC-3, Tim Holy wrote:
>
> In general you should write your code to avoid Anys. Depending on where 
> you 
> are losing type information, it's possible that scale! or using temp 
> variables 
> with different names will help you. 
>
> --Tim 
>
> On Wednesday, July 08, 2015 04:53:36 AM Eduardo Lenz wrote: 
> > Hi. 
> > 
> > The only difference between P1 and P2 is that A  and B are 
> > of type ::Any in P2 and just B is ::Any in P1 (As expected). 
> > 
> > So it seems that 
> > 
> > A = convert(SharedArray,A) 
> > 
> > makes A  "not type stable" and any operation using it will suffer, 
> specially 
> > the (silly) operation A'*A*A*A*A*A' I used to spend some time inside the 
> > loop. 
> > 
> > As a small test, I changed the code to 
> > 
> >  C = sdata(A) 
> >  B[i] = norm(C'*C*C*C*C') 
> > 
> > and the execution time is now equivalent to the first example. 
> > 
> > Is there any way to make a SharedArray type stable ? 
> > 
> > Thanks. 
> > 
> > On Wednesday, July 8, 2015 at 8:17:07 AM UTC-3, Eduardo Lenz wrote: 
> > > Thanks Tim. I will take a look. 
> > > 
> > > On Wednesday, July 8, 2015 at 12:02:56 AM UTC-3, Tim Holy wrote: 
> > >> Without having spent the time to look carefully, one obvious point is 
> > >> that you 
> > >> have some serious type-instability in your SharedArray function. If 
> > >> you're 
> > >> running 0.4, try using @code_warntype and tweak your implementation 
> until 
> > >> it 
> > >> is type stable. 
> > >> 
> > >> --Tim 
> > >> 
> > >> On Tuesday, July 07, 2015 08:19:58 AM Eduardo Lenz wrote: 
> > >> > Hi. 
> > >> > 
> > >> > I was studying parallel methods with some silly routines. After 
> some 
> > >> 
> > >> tries, 
> > >> 
> > >> > I realized that reading Shared Arrays is slower than reading 
> regular 
> > >> > arrays, although I cannot understand the reason. I am using the 
> latest 
> > >> > version in Nightly. 
> > >> > 
> > >> > As an example,  routine P2 takes more time than routine P1, and the 
> > >> 
> > >> only 
> > >> 
> > >> > difference is the fact that A is Shared. Is it expected ? 
> > >> > 
> > >> > https://gist.github.com/CodeLenz/776c138c2c49dbd4a2d5 
> > >> > 
> > >> > Thanks for your help. 
>
>

Reply via email to