forum.alglib.net

ALGLIB forum
It is currently Tue Aug 09, 2022 2:13 am

All times are UTC


Forum rules


1. This forum can be used for discussion of both ALGLIB-related and general numerical analysis questions
2. This forum is English-only - postings in other languages will be removed.



Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: ALGLIB is thread-safe?
PostPosted: Fri Feb 01, 2013 8:15 pm 
Offline

Joined: Wed Jan 23, 2013 1:43 pm
Posts: 4
Briefly looking into the c++ source code for ALGLIB, it seems thread-safe to me. Are there any surprises? Can anybody confirm either way?

(I am looking to have different threads train different multinomial logistic models simultaneously...)


Top
 Profile  
 
 Post subject: Re: ALGLIB is thread-safe?
PostPosted: Sat Feb 02, 2013 10:49 am 
Offline
Site Admin

Joined: Fri May 07, 2010 7:06 am
Posts: 878
As long as different threads work with different objects, it is thread-safe.

However, any way of sharing object with different threads is potentially risky - even when this object is used in "read-only mode". Sometimes seemingly "read-only" operations in fact modify internal state of the object. Say, processing data with neural network does not modify network weights and you may decide that it is "read only". But in fact it involves modification of internal temporary buffer. So you can not call mlpprocess() from two different threads with same network.


Top
 Profile  
 
 Post subject: Re: ALGLIB is thread-safe?
PostPosted: Wed Feb 13, 2013 4:24 pm 
Offline

Joined: Wed Jan 23, 2013 1:43 pm
Posts: 4
Indeed, as you said, I did notice the modification of internal buffers of the "network" (multilayerperceptron) object within various functions. I am looking into the Multinomial Logsitc Regression training algorithm in detail (especially the gradient and Hessian functions called from mnltrainh) with the hope of multi-threading this training function, "mnltrainh".

Off the top of your head, can you say if any member objects of a "network" (multilayerperceptron) are modified other than the internal buffers? I am hoping that by replacing all instances of the internal buffers ("chunks" and "nwbuf") with local, temporary copies, then these algorithms will indeed be thread-safe. Can you offer any kind of reassurance or gut feeling either way?

Thank you!


Top
 Profile  
 
 Post subject: Re: ALGLIB is thread-safe?
PostPosted: Thu Feb 14, 2013 7:51 am 
Offline
Site Admin

Joined: Fri May 07, 2010 7:06 am
Posts: 878
As for MultilayerPerceptron object, following fields can be modified by at least one "seemingly-read-only" function:

Quote:
Neurons: array of Real;
DFDNET: array of Real;
DError: array of Real;
X, Y: array of Real;
XY: array of array of Real;// Matrix buffer
XYRow: array of Real; // Row buffer for sparse matrix
Chunks: array of array of Real; // Buffer for batch processing
NWBuf: array of Real; // Buffer, array[0..max(wcount,2*nout)-1]
IntegerBuf: array of Integer; // Integer buffer, array[4]


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: Bing [Bot] and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group