Aptech Systems, Inc. Worldwide Headquarters
Aptech Systems, Inc.
2350 East Germann Road, Suite #21
Chandler, AZ 85286
Ready to Get Started?
Request Quote & Product Information
Training & Events
Step-by-step, informative lessons for those who want to dive into GAUSS and achieve their goals, fast.
Have a Specific Question?
Q&A: Register and Login
Premier Support and Platinum Premier Support are annually renewable membership programs that provide you with important benefits including technical support, product maintenance, and substantial cost-saving features for your GAUSS System or the GAUSS Engine.
Join our community to see why our users are considered some of the most active and helpful in the industry!
Where to Buy
Recent Tagsapplications character vectors CML CMLMT Constrained Optimization datasets dates dlibrary dllcall error error handling errors Excel file i/o floating network GAUSS Engine graphics GUI hotkeys installation Java API license licensing linux loading data loops matrices matrix manipulation Maxlik MaxLikMT Memory multidimensional array optimization Optmum output PQG graphics procs RAM random numbers string functions strings structures threading Time Series writing data
Time Series 2.0 MT
Find out more now
Time Series MT 2.1
Find out more now
Threads and computers with different number of cores
My coauthor and I have computers with a different number of cores (I have 4 and he has 8). I have written a program using up to 8 simultaneous threads which runs in my machine, but is this the most efficient way of writting the program given that it is going to be executed in two different machines? Just in case it matters I have GAUSS 9 and he has GAUSS 12.
In this particular case, it probably works out perfect, because GAUSS 12 has automatic internal threading of many functions. GAUSS 9 does not have this feature. So, your coauthor with more cores will be creating more threads anyway.
In the general case, though, if your threaded section if you have abstracted the section of code that is run in parallel, then you can use #define to control the number of threads fairly easily. Here is a trivial example:
new; #define TWO_THREADS 1 #ifdef TWO_THREADS #define NUM_THREADS 2 #endif #ifdef TWO_THREADS threadStat a = rndn(1,1); threadStat b = rndn(1,1); threadJoin; print "running with 2 threads"; #else threadStat a = rndn(1,1); threadStat b = rndn(1,1); threadStat c = rndn(1,1); threadStat d = rndn(1,1); threadJoin; print "runing with 4 threads"; #endif
As is, the code above will execute the the block of code with two threads. If you comment out the line:
//#define TWO_THREADS 1
like this, you will run the second section with 4 threads.
The way that you would use it is to place the first section:
#define TWO_THREADS 1 #ifdef TWO_THREADS #define NUM_THREADS 2 #endif
at the top of your program so it can easily be found and turned on/off. Then the threaded block could be anywhere in your file.