Subj : Re: Should I use threads? To : comp.programming.threads From : Eric Sosman Date : Tue Jun 28 2005 03:24 pm zipito wrote: > Hi All! > > I'm trying to write own computational program for my physical task. > There is some problem: TIME. When I finished it (the first edition), it > takes something about 22 minutes for every integral, and I have about > 10000 of such type integrals to compute. Then I've changed some code in > algorithm for computing this integrals, Now program takes only 2-3 > seconds. :) But thats not good for me! Program needs about a year to > complete computation. This makes no sense. 10000 computations at three seconds apiece is only eight hours and twenty minutes. Even if each computation takes 22 minutes, all 10000 will take only 153 days. Neither is anything like "about a year." > I think, I will increase the computational speed, if I'll try to use > some parallel computations: I want to do my program computing at the > same time 5-6 integrals (or even more, if it's able). Can this be done > on one-processor running mashine. If yes, can you tell me: should I use > threads to do this? Or there is some different abilities? No, no, and no. Not on "conventional" uniprocessors, anyhow. > I'm using standart c++ library. For this moment I'm writting my program > for Windows. Once I've tried to recompile my code for linux, and it had > speeded up :). So the main goal is to use STANDART C++ Library, or > something, that is good-portable for linux. (At the end of writting, > this program, probably, will be running on multiprocessor machine, but > for debuging and testing, I will be able to use only my one > single-processor computer) On an N-processor machine you might be able to run as many as N simultaneous compute-bound threads, working on N integrals in parallel. Do the computations of the integrals interact in any way, or are they independent? If they are independent, I'd suggest running N copies of your single-threaded process instead of one N-threaded process; it's much simpler. -- Eric.Sosman@sun.com .