Link to home
Start Free TrialLog in
Avatar of Stelios_Antoniou
Stelios_Antoniou

asked on

threads in delphi

Hello,
I am using Delphi to program a Finite Elements program, i.e. a program for the analysis of structures (mainly buildings) in different types of loading, e.g. gravity, wind, earthquake etc. The program uses a main procedure that assembles all the data from the members of the structure (columns, beams and slabs) and gathers them in a special matrix, called the 'stiffness matrix'. This process consumes up to the 80% of the total analysis time (that can go up to several hours for large buildings, such as skyscrapers, and  a series of 1000 or more analysis steps, e.g in earthquakes). Hence, programming it with multi-threading is crucial.

Noting that I am new in multi-threading...
1) which is the best way to  program this? Using the TThread component, or using a specialised library, such as  OmniThreadLibrary? Which are the pros and cons of each solution?
2) Regarding OmniThreadLibrary, I noted that it has a special method ParallelTask that executes the same code on multiple cores. Provided that OmniThreadLibrary is indeed a good solution, how can I use it to pass arguments in the threaded procedure? In the non-threaded code I am using something like:

For elemID := 0 to pred(NoElements) do
begin
     AssembleA10(N1,N2,elemID,elemTyp,ElemMatrix_12x12);
end;

Open in new window


N1,N2elemID,elemTyp are integers and ElemMatrix_12x12 is a 12x12 array of real.

Thank you in advance,
Avatar of Geert G
Geert G
Flag of Belgium image

have you found his book ?
http://www.thedelphigeek.com/2012/08/parallel-programming-with.html

the sample contains a lot of information

you'll have to use TOmniValue and the container types to pass data around amongst the threads
This comparison has some ideas:
http://www.thedelphigeek.com/2010/03/speed-comparison-variant-tvalue-and.html
Avatar of Stelios_Antoniou
Stelios_Antoniou

ASKER

Thanks Geert_Gruwez.
I had a look at the book, and it seems to be very good, more or less what I was looking for.

So this means that you suggest that I use the OmniThreadLibrary? Which are its advantages and disadvantages with respect to TThread?
ASKER CERTIFIED SOLUTION
Avatar of Geert G
Geert G
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you both for the response. What I understood is that I need to start studying immediately