Tilted Forum Project Discussion Community  

Go Back   Tilted Forum Project Discussion Community > Interests > Tilted Technology


 
 
LinkBack Thread Tools
Old 12-13-2005, 01:10 PM   #1 (permalink)
Insane
 
[Java] Utilizing multiple processors (well, HT "processors")

Basically, I'm wondering how to use both "processors" of a 3.2E hyperthreaded processor. I'm running a java program right now, but Task Manager shows it using only 50% of the CPU. I realize the 3.2E doesn't have 2 true processors, but programs like Folding@Home and any of the other @Home programs are able to utilize both the actual processor and the hyperthreading pseudo-processor. How exactly would I go about doing this as well?
wombatman is offline  
Old 12-13-2005, 06:32 PM   #2 (permalink)
Insane
 
It appears that after some searching, I've found the answer to my question. Looks like I'm gonna have to learn some stuff about threads. Should be a blast.
wombatman is offline  
Old 12-13-2005, 07:34 PM   #3 (permalink)
Insane
 
I'm pretty much talking to myself right now, but I figured I'd update with what I've gotten going so far.

I was able to implement a basic two thread setup with the program I was running previously (searching for large prime factors for RSA contest). However, not only did it not use more than ~50% of the CPU as before, but each thread took about twice as long.

Does anyone have some idea why this is? And, more importantly, how I can implement the 2 threads within the program so that they are actually using more than 50% of the CPU like the @Home programs?
wombatman is offline  
Old 12-13-2005, 11:41 PM   #4 (permalink)
Adequate
 
cyrnel's Avatar
 
Location: In my angry-dome.
It's been a while so don't throw rocks.

There are lots of potential performance issues with concurrent execution. Most involve scarce resources, be they shared memory, input/output streams, processor units, or just blocking for synchronization. Then there's efficiency. Semaphores & conventional locks add overhead that kills for iterative tasks. What's your code look like? Do you have anything preparing work queues or are the threads stepping on each others' feet to get their jobs done?

Here's a page from SUn on their concurrency utilities:

http://java.sun.com/j2se/1.5.0/docs/.../overview.html

Lots of strategy guides out there. Should be plenty of examples for primes in google.
__________________
There are a vast number of people who are uninformed and heavily propagandized, but fundamentally decent. The propaganda that inundates them is effective when unchallenged, but much of it goes only skin deep. If they can be brought to raise questions and apply their decent instincts and basic intelligence, many people quickly escape the confines of the doctrinal system and are willing to do something to help others who are really suffering and oppressed." -Manufacturing Consent: Noam Chomsky and the Media, p. 195
cyrnel is offline  
Old 12-14-2005, 12:30 AM   #5 (permalink)
Insane
 
Well, the prime check works wonderfully. It does about 100,000 numbers (they're all about 106 digits long and that's skipping even numbers of course, so that's a good amount) in about 30 seconds. When I tried to do threading, each thread took 70 seconds, although I didn't check to see how many numbers they went through. For implementation of the threads, I just added "extends Thread" to my class and defined a run() section. Inside this section, it checks for the name of the thread. If it's "Test1" it goes to a certain number to start checking. If it's anything else, it goes to a second number to start.

The two threads start from staggered numbers and decrease by 4 while checking primality so as to avoid overlapping (I hope). I'm just not sure if using my original single function (the 30 second one) or the 2 threads at about 70 seconds apiece. Would love an opinion on this as well.

Edit: Realized I didn't really answer your questions. While I would prefer not to post the code (it's all original stuff using BigInteger), suffice it to say that it simply loops, starting from a given number and every 500 primes (this can be changed) it writes out to a file, which is simply a safeguard in case something messes up and the computer shuts down or anything. Also, any prime found is checked as a possible factor of the RSA number. There is no queueing of any kind outside of the threading as I haven't the faintest how to do so. Hope this helps.


Edit #2: Well, I just watched my threads run again, and it seems that while they take double the time...they're both finishing about the same time. That is, each thread is taking about the same amount of time as before. I think. I'm still a bit confused, but I'm going to let it run overnight.

If anyone can provide some recommendations on how to improve the speeds of these threads, I would be much obliged.

Last edited by wombatman; 12-14-2005 at 12:43 AM..
wombatman is offline  
 

Tags
java, multiple, processors, utilizing, well


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 -8. The time now is 03:03 AM.

Tilted Forum Project

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Search Engine Optimization by vBSEO 3.6.0 PL2
© 2002-2012 Tilted Forum Project

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62