The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
.
google unix.com



High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Quad-Ren 0.3 (Default branch) iBot Software Releases - RSS News 0 03-02-2009 06:30 AM
Quad-Ren 0.2 (Default branch) iBot Software Releases - RSS News 0 02-18-2009 03:30 AM
Quad Ethernet hshapiro SUN Solaris 5 09-25-2007 09:10 PM
Quad or Duel Processors rfmurphy_6 Windows & DOS: Issues & Discussions 4 10-05-2005 08:13 AM
Quad Booting... jboswell BSD 1 03-02-2005 07:26 PM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-02-2009
HeavyJ HeavyJ is offline
Registered User
  
 

Join Date: Oct 2009
Location: Toronto
Posts: 18
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
  #2 (permalink)  
Old 10-02-2009
Corona688 Corona688 is offline
Registered User
  
 

Join Date: Aug 2005
Location: Saskatchewan
Posts: 1,929
Without seeing the code I can't tell why it's doing what. Each core will have some of its own cache so reading the same memory would not be a problem.
  #3 (permalink)  
Old 10-02-2009
HeavyJ HeavyJ is offline
Registered User
  
 

Join Date: Oct 2009
Location: Toronto
Posts: 18
Allow me to make myself very clear:

- The lexicon data structure is immutable.
- I have named it the ADTDAWG - Adamovsky Direct Tracking Directed Acyclic Word Graph, contained in 4 arrays of basic number types.
- The character set I have chosen is 14 of the best English letters.
- There is a thread that is responsible for words that begin with each of the letters in the character set.
- The threads all call the same recursive word-discovery function, and then modify a set of global time-stamps to eliminate the duplicate word problem.
- They will never try to modify the same time-stamp because they are responsible for a different subset of the lexicon.

- I used mutexes, and condition variables to communicate when work on the current board should begin, and when it has finished.

- My question is this - Do POSIX multi-threads really allow for an optimal implementation of a micro-parallel algorithm? Or am I doing something wrong, because I am only using 45% of the power of my Quad-Core, when I should be maxing it out?

Do you really want to look at the code that I wrote? At this point, I have every reason to believe that it will introduce mass confusion. It is well written, but it requires an in-depth knowledge of lexicon data structure optimization.

So you suggest that each core has a private cache? I would love to see a block diagram of how the Core2 layout works, so that I could stop spinning my wheels on this problem.

A single thread can score 1277 of the best 23 boards found to date, each with a score around 10769 points for the TWL06 lexicon.

That means that the recursive function is being called many, many, many times per second. Should this fact be a concern?
  #4 (permalink)  
Old 10-03-2009
fpmurphy's Avatar
fpmurphy fpmurphy is offline Forum Staff  
Moderator
  
 

Join Date: Dec 2003
Location: Florida
Posts: 1,913
Quote:
My question is this - Do POSIX multi-threads really allow for an optimal implementation of a micro-parallel algorithm? Or am I doing something wrong, because I am only using 45% of the power of my Quad-Core, when I should be maxing it out?
Who knows. You have not supplied us with any information that can enable us to help you. What operating system? What compiler and version? Which threading model? 1:1 or MxN or what? What compiler optimisations?

I will say this. POSIX threads would not be my choice for implementing a parallel algorithm.
  #5 (permalink)  
Old 10-03-2009
HeavyJ HeavyJ is offline
Registered User
  
 

Join Date: Oct 2009
Location: Toronto
Posts: 18
Ubuntu 9.04

g++

Done in a Terminal.

If you are serious about helping me use 100% CPU, I will send you the code (all of it). Know that I have spent a solid two months developing this work, and it is to my knowledge the most advanced program set of its kind.

Simply put, I will be very unhappy if I never hear from you again, after giving you any part of my code.

I graduated as an aerospace engineer in 2005, and I have never had a job in that industry, so I turned to an area of study with almost no material costs.

I used POSIX because it seems to be incorporated into the C standard. I have a serious problem using any code developed for particular machines or operating systems.

What would your choice be to implement a real micro-parallel algorithm such as my Boggle analysis scheme? Why is POSIX a bad choice for true parallel performance?

Thanks a lot, fpmurphy
  #6 (permalink)  
Old 10-04-2009
fpmurphy's Avatar
fpmurphy fpmurphy is offline Forum Staff  
Moderator
  
 

Join Date: Dec 2003
Location: Florida
Posts: 1,913
Quote:
I used POSIX because it seems to be incorporated into the C standard
POSIX is not part of either C89 or C99 standards.

I am not sure what you mean by a "micro-parallel algorithm". It is a new term to both myself and Google. Perhaps you would be kind enough to explain what you mean by this term.

Meanwhile, I suggest you look at GPGPU, CUDA and OpenCL.
  #7 (permalink)  
Old 10-04-2009
HeavyJ HeavyJ is offline
Registered User
  
 

Join Date: Oct 2009
Location: Toronto
Posts: 18
I suppose by standard, I mean that I don't need to download any libraries. I type g++ -pthread.

micro-parallel = algorithm cut up into its smallest independent units, so that the performance will be directly proportional to the number of processor cores up to the maximum number of independent units. Inter-thread communication needs to be close to instantaneous for this relation to hold.
Reply

Bookmarks

Tags
optimize, parallel, posix, thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 10:47 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0