From: Patrik J. <pa...@uc...> - 2002-10-15 15:24:06
|
hi julian, >Hi Patrik, > >Seems to me like the temporary array "temp" should be >a thread local variable, so that each thread creates >its own temp array. That way, there are no dependencies >between threads and no need for threads to use a mutex. that's the case, but the problem is that the threads are operating on separate pieces of large arrays (values and results, in the example, would be a subset of a larger array), and blitz will (and must) use a mutex to safeguard its internal reference count since every sub-array will be referencing the MemoryBlock of the large parent array. (that's why my code used to crash.) i guess one way of solving the problem would be to make it possible to tell blitz that an array (referencing an existing memoryblock) should never delete the memoryblock and hence never use reference counting or need to use a mutex. then it's up to the user to make sure the proper mode is being used. i don't suppose there's currently a way of doing that, is there? maybe a special class ReferenceArray, with all the usual pitfalls of an object reference?? I'll post the actual code as soon as i can, but I'm currently on strike so i'm not in my office... regards, /patrik >vector<Range> ranges(10); >Array<double,2> values(5,30); >Array<double,2> results(5,10); > >iterator j=ranges.begin(); >int l=0; >while(j!=ranges.end()) { > firstIndex i; > secondIndex k; > Array<double,1> temp( values(Range::all(),*j++)); > results(Range::all(),l++) = sum(temp,k) > } -- ======================================================== Patrik Jonsson (831)459-3809 Dept. of Astronomy & Astrophysics University of California Santa Cruz, CA 95064 USA The author is suffering from repetitive strain injury. Brevity is a necessity, not an indication of attitude. _______________________________________________ Blitz-support mailing list Bli...@oo... http://www.oonumerics.org/mailman/listinfo.cgi/blitz-support |