Sponsored Content
Top Forums Programming C POSIX: Analyze a Boggle board using 100% CPU on a quad core. Post 302358442 by HeavyJ on Friday 2nd of October 2009 02:12:36 PM
Old 10-02-2009
C POSIX: Analyze a Boggle board using 100% CPU on a quad core.

I have written the worlds most advanced lexicon data structure in order to score a Boggle Board using a parallel algorithm.

I ran into a problem. Using mutexes and condition variables did not allow me to use 100% of the CPU resources on my quad core Q9450.

I wonder if the problem is that the worker threads call the same recursive function many thousands, to millions of times per second.

Should each thread have its own identical recursive function defined so that they are not all waiting to access the memory where the function is stored?

Thank You,

HeavyJ
 

9 More Discussions You Might Find Interesting

1. AIX

cpu and core

Hi, what is concept of core in ibm platform? I want to know how to find out no of core in cpu in aix i.e command how to find out value of core? Wheather any specification is there? (1 Reply)
Discussion started by: manoj.solaris
1 Replies

2. AIX

no of core in cpu for aix

is there command which will display no of core per cpu in aix? Regads, Manoj (1 Reply)
Discussion started by: manoj.solaris
1 Replies

3. UNIX for Advanced & Expert Users

Distinguishing between CPU and Core

Hi, I want to know if in UNIX is it possible to distinguish between a CPU and a core through any command? Thanks, Vineet (1 Reply)
Discussion started by: vineetd
1 Replies

4. Linux Benchmarks

AMD Phenom(tm) 9950 Quad-Core Processor, Ram: 3.6 GB, Foxconn 7da-s and Linux 2.6.26-2-amd64

CPU/Speed: AMD Phenom(tm) 9950 Quad-Core Processor Ram: 3.6 GB Motherboard: Foxconn 7da-s Bus: Cache: Controller: Disk: Load: Kernel: Linux 2.6.26-2-amd64 Kernel ELF?: pgms: ============================================================== BYTE UNIX Benchmarks (Version... (0 Replies)
Discussion started by: migracho
0 Replies

5. AIX

What is a cpu core ?

Hi Friends- What does it mean by 2 cpu cores, 3 cpu cores? Does it mean 2 separate cpus or what is it exactly ? Kindly explain a bit in detail. Thanks panditt (4 Replies)
Discussion started by: deshaipet
4 Replies

6. Solaris

Share CPU core

Hi, I have 2 physical processor UltraSPARC-T2 with 32 virtual processors I want to execute a perl program on 10 virtual processors. I try prset command, but I don't see a difference. psrset -c "created processor set 2" 1 2 3 4 5 6 7 8 9 10" psrset -b 2 `pgrep program.pl` Maybe... (8 Replies)
Discussion started by: falloutsam
8 Replies

7. HP-UX

how can i know this processor quad or dual core ?

hi every body i want to know if i have server with hp-ux os if i did "machinfo" i will see no of cpu = for example 16 how can i know this is dual or quad core . thanks (2 Replies)
Discussion started by: maxim42
2 Replies

8. Solaris

does a cpu/memory board have a firmware ??

please help does a cpu/memory module have a firmware ?? and do i need to check it before install the cpu/memory module in the motherboard ?? thnx (2 Replies)
Discussion started by: bahjatm
2 Replies

9. Red Hat

No of CPU's and No of Core

I would like to understand how many number of CPUs and cores do I have on my server based on following out put.. Few observations... Please correct me if I am wrong Since Physical ID is same CPU is singe It has 8 virtual processors Hyper thrading is enabled since no of siblings are... (1 Reply)
Discussion started by: parth_buch
1 Replies
PARALLELCPU(1p) 					User Contributed Perl Documentation					   PARALLELCPU(1p)

NAME
PDL::ParallelCPU - Parallel Processor MultiThreading Support in PDL (Experimental) DESCRIPTION
PDL has support (currently experimental) for splitting up numerical processing between multiple parallel processor threads (or pthreads) using the set_autopthread_targ and set_autopthread_size functions. This can improve processing performance (by greater than 2-4X in most cases) by taking advantage of multi-core and/or multi-processor machines. SYNOPSIS
use PDL; # Set target of 4 parallel pthreads to create, with a lower limit of # 5Meg elements for splitting processing into parallel pthreads. set_autopthread_targ(4); set_autopthread_size(5); $a = zeroes(5000,5000); # Create 25Meg element array $b = $a + 5; # Processing will be split up into multiple pthreads # Get the actual number of pthreads for the last # processing operation. $actualPthreads = get_autopthread_actual(); Terminology The use of the term threading can be confusing with PDL, because it can refer to PDL threading, as defined in the PDL::Threading docs, or to processor multi-threading. To reduce confusion with the existing PDL threading terminology, this document uses pthreading to refer to processor multi-threading, which is the use of multiple processor threads to split up numerical processing into parallel operations. Functions that control PDL PThreads This is a brief listing and description of the PDL pthreading functions, see the PDL::Core docs for detailed information. set_autopthread_targ Set the target number of processor-threads (pthreads) for multi-threaded processing. Setting auto_pthread_targ to 0 means that no pthreading will occur. See PDL::Core for details. set_autopthread_size Set the minimum size (in Meg-elements or 2**20 elements) of the largest PDL involved in a function where auto-pthreading will be performed. For small PDLs, it probably isn't worth starting multiple pthreads, so this function is used to define a minimum threshold where auto-pthreading won't be attempted. See PDL::Core for details. get_autopthread_actual Get the actual number of pthreads executed for the last pdl processing function. See PDL::get_autopthread_actual for details. Global Control of PDL PThreading using Environment Variables PDL PThreading can be globally turned on, without modifying existing code by setting environment variables PDL_AUTOPTHREAD_TARG and PDL_AUTOPTHREAD_SIZE before running a PDL script. These environment variables are checked when PDL starts up and calls to set_autopthread_targ and set_autopthread_size functions made with the environment variable's values. For example, if the environment var PDL_AUTOPTHREAD_TARG is set to 3, and PDL_AUTOPTHREAD_SIZE is set to 10, then any pdl script will run as if the following lines were at the top of the file: set_autopthread_targ(3); set_autopthread_size(10); How It Works The auto-pthreading process works by analyzing threaded array dimensions in PDL operations and splitting up processing based on the thread dimension sizes and desired number of pthreads (i.e. the pthread target or pthread_targ). The offsets and increments that PDL uses to step thru the data in memory are modified for each pthread so each one sees a different set of data when performing processing. Example $a = sequence(20,4,3); # Small 3-D Array, size 20,4,3 # Setup auto-pthreading: set_autopthread_targ(2); # Target of 2 pthreads set_autopthread_size(0); # Zero so that the small PDLs in this example will be pthreaded # This will be split up into 2 pthreads $c = maximum($a); For the above example, the maximum function has a signature of "(a(n); [o]c())", which means that the first dimension of $a (size 20) is a Core dimension of the maximum function. The other dimensions of $a (size 4,3) are threaded dimensions (i.e. will be threaded-over in the maximum function. The auto-pthreading algorithm examines the threaded dims of size (4,3) and picks the 4 dimension, since it is evenly divisible by the autopthread_targ of 2. The processing of the maximum function is then split into two pthreads on the size-4 dimension, with dim indexes 0,2 processed by one pthread and dim indexes 1,3 processed by the other pthread. Limitations Must have POSIX Threads Enabled Auto-PThreading only works if your PDL installation was compiled with POSIX threads enabled. This is normally the case if you are running on linux, or other unix variants. Non-Threadsafe Code Not all the libraries that PDL intefaces to are thread-safe, i.e. they aren't written to operate in a multi-threaded environment without crashing or causing side-effects. Some examples in the PDL core is the fft function and the pnmout functions. To operate properly with these types of functions, the PPCode flag NoPthread has been introduced to indicate a function as not being pthread-safe. See PDL::PP docs for details. Size of PDL Dimensions and PThread Target Due to the way a PDL is split-up for operation using multiple pthreads, the size of a dimension must be evenly divisible by the pthread target. For example, if a PDL has threaded dimension sizes of (4,3,3) and the auto_pthread_targ has been set to 2, then the first threaded dimension (size 4) will be picked to be split up into two pthreads of size 2 and 2. However, if the threaded dimension sizes are (3,3,3) and the auto_pthread_targ is still 2, then pthreading won't occur, because no threaded dimensions are divisible by 2. The algorithm that picks the actual number of pthreads has some smarts (but could probably be improved) to adjust down from the auto_pthread_targ to get a number of pthreads that can evenly divide one of the threaded dimensions. For example, if a PDL has threaded dimension sizes of (9,2,2) and the auto_pthread_targ is 4, the algorithm will see that no dimension is divisible by 4, then adjust down the target to 3, resulting in splitting up the first threaded dimension (size 9) into 3 pthreads. Speed improvement might be less than you expect. If you have a 8 core machine and call auto_pthread_targ with 8 to generate 8 parallel pthreads, you probably won't get a 8X improvement in speed, due to memory bandwidth issues. Even though you have 8 separate CPUs crunching away on data, you will have (for most common machine architectures) common RAM that now becomes your bottleneck. For simple calculations (e.g simple additions) you can run into a performance limit at about 4 pthreads. For more complex calculations the limit will be higher. COPYRIGHT
Copyright 2011 John Cerney. You can distribute and/or modify this document under the same terms as the current Perl license. See: http://dev.perl.org/licenses/ perl v5.14.2 2012-01-02 PARALLELCPU(1p)
All times are GMT -4. The time now is 05:40 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy