Java-Gaming.org Java4K winners: [ by our judges | by the community ]         
Featured games (67)
games approved by the League of Dukes
Games in Showcase (∞)
games submitted by our members



News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  Print  
  Designating threads to specific cores?  (Read 2243 times)
0 Members and 1 Guest are viewing this topic.
Offline Conner_

JGO n00b
*

Posts: 19


~ Java Game Dev ~


« on: 2011-09-26 21:40:05 »

Hey everyone,

My current project is a Minecraft server (as some of you know), and I'm trying to create the best thread pattern possible. I was wondering if there is a way for me to explicitly tell my system to plant a thread on a SPECIFIC core/processor thread. My system has 2 cores (2 threads each) and I know that the software will only every be run on rigs with 4+ available "processors" (as determined by Runtime#availableProcessors()). There are only four threads that I think I'll need to run, so I figured that if I could have each thread run on each core, it would work the best.

So, is there a way to do this? Or am I thinking this completely wrong, and I should do it a different way?

Thanks Cheesy

Find me on GitHub: connergdavis
My current project is called Obsidian Framework and is a private Minecraft server application used to play Multiplayer.
Offline theagentd

JGO Wizard
****

Posts: 1392
Medals: 88



« Reply #1 on: 2011-09-26 22:04:42 »

All threads are distributed among cores automatically.

There is no god.
Offline Conner_

JGO n00b
*

Posts: 19


~ Java Game Dev ~


« Reply #2 on: 2011-09-26 22:11:33 »

All threads are distributed among cores automatically.

That's what I thought. Sucks :/ Hopefully my computer can designate it well enough, lol.

Find me on GitHub: connergdavis
My current project is called Obsidian Framework and is a private Minecraft server application used to play Multiplayer.
Games published by our own members! Go get 'em!
Offline theagentd

JGO Wizard
****

Posts: 1392
Medals: 88



« Reply #3 on: 2011-09-26 22:44:22 »

Why wouldn't it be able to? Designating them yourself would be a bad idea, as the OS (and Java) can compensate for other programs. If you have another program running a single thread that suddenly starts hogging processing power, if both that program and your program had decided exactly what core to run on, one thread of your program would be severely slowed down. It's better to let the OS handle it and get even performance, as a task split up between multiple threads is only complete when all threads finish, right?

There is no god.
Offline princec
« League of Dukes »

JGO Kernel
*****

Posts: 8076
Medals: 91


Eh? Who? What? ... Me?


« Reply #4 on: 2011-09-27 07:04:56 »

It's not as sucky as it sounds - by and large the OS will absolutely try its level best to keep any particular thread on the core in which it started life. If it can't, for any reason, then it's because it reckons it can do a better job by moving it. So relax and enjoy coding and sleep soundly at night Smiley

Cas Smiley

Offline Riven
« League of Dukes »

JGO Kernel
*****

Posts: 5866
Medals: 255


Hand over your head.


« Reply #5 on: 2011-09-27 07:11:12 »

It's not as sucky as it sounds - by and large the OS will absolutely try its level best to keep any particular thread on the core in which it started life.

This is not my experience at all (on Windows). It will move all threads around, at an even pace. When running a single-threaded algorithm, all my 4 CPU cores are at 25% usage, not one at 100%.

Hi, appreciate more people! Σ ♥ = ¾

Learn how to award medals... and work your way up the social rankings
Offline princec
« League of Dukes »

JGO Kernel
*****

Posts: 8076
Medals: 91


Eh? Who? What? ... Me?


« Reply #6 on: 2011-09-27 07:17:47 »

Hm that is strange - mostly I get one core jammed at 100% in that situation.

Cas Smiley

Offline Riven
« League of Dukes »

JGO Kernel
*****

Posts: 5866
Medals: 255


Hand over your head.


« Reply #7 on: 2011-09-27 07:25:41 »

Relevant specs: Vista 64bit, Intel Q6600 stepping G.

Maybe it's a setting, somewhere, too.

Hi, appreciate more people! Σ ♥ = ¾

Learn how to award medals... and work your way up the social rankings
Offline princec
« League of Dukes »

JGO Kernel
*****

Posts: 8076
Medals: 91


Eh? Who? What? ... Me?


« Reply #8 on: 2011-09-27 07:37:16 »

Vista64, i7 here. But I've had the same experience on every system I've used I think but haven't really got any proof other than my extraordinarily unreliable memory. There are tweaks in the registry to alter this stuff but I've not meddled with them.

Cas Smiley

Offline Cero

JGO Neuromancer
****

Posts: 1050
Medals: 18



« Reply #9 on: 2011-09-27 08:25:10 »

Everyone complains about the PS3 architecture.
Admittedly much more complex with 7 async. cores or whatever, but I guess developers are very happy if they don't have to do that kind of stuff.

Games published by our own members! Go get 'em!
Offline princec
« League of Dukes »

JGO Kernel
*****

Posts: 8076
Medals: 91


Eh? Who? What? ... Me?


« Reply #10 on: 2011-09-27 08:51:43 »

I dunno, we're already doing async core programming now using VBOs etc. in OpenGL. It all makes sense really. It'd be nice if you could specify the cores to form into pipelines and stuff a la Transputers. That'd be awesome! Imagine a grid of 8x8 cores or something and you could design algorithms that piped data through in various routes.

Cas Smiley

Offline theagentd

JGO Wizard
****

Posts: 1392
Medals: 88



« Reply #11 on: 2011-09-27 10:17:54 »

WAIT...! Is it possible to do VBO uploads from different threads?!

There is no god.
Offline princec
« League of Dukes »

JGO Kernel
*****

Posts: 8076
Medals: 91


Eh? Who? What? ... Me?


« Reply #12 on: 2011-09-27 10:33:24 »

I think so, using shared context stuff. But you wouldn't want to, probably.

Cas Smiley

Offline Roquen

JGO Strike Force
***

Posts: 823
Medals: 25



« Reply #13 on: 2011-09-27 11:20:27 »

Transputers: I actually did some programming on some T212 at uni...it was a heck of a lot of fun.  (I'm totally not a geek or anything)
Offline sproingie

JGO Strike Force
***

Posts: 894
Medals: 55



« Reply #14 on: 2011-09-27 11:49:15 »

Laptop CPUs will typically bounce threads around between cores evenly as a heat management strategy.  They should still respect processor affinity settings if you set them explicitly.
Offline Riven
« League of Dukes »

JGO Kernel
*****

Posts: 5866
Medals: 255


Hand over your head.


« Reply #15 on: 2011-09-27 15:36:47 »

Ah, about 5 years ago I set PowerManagement to 'minimal'.

The relevant part seems to be that CPU min=25% and max=100%.

That probably toggles the massive amount of bouncing (or shall we say cache trashing).

Hi, appreciate more people! Σ ♥ = ¾

Learn how to award medals... and work your way up the social rankings
Offline princec
« League of Dukes »

JGO Kernel
*****

Posts: 8076
Medals: 91


Eh? Who? What? ... Me?


« Reply #16 on: 2011-09-27 16:15:58 »

Context switch between threads trash caches anyway even on single core, so probably nothing to worry about. But on a dual core there's definitely massive gains to be had when one busy thread hogs a core and all the other less busy threads just get the other core(s).

Cas Smiley

Pages: [1]
  Print  
 
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.091 seconds with 20 queries.