Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (541)
Games in Android Showcase (133)
games submitted by our members
Games in WIP (603)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Designating threads to specific cores?  (Read 3786 times)
0 Members and 1 Guest are viewing this topic.
Offline Conner_

Senior Newbie




~ Java Game Dev ~


« Posted 2011-09-27 01: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 Bitwise Duke »


Medals: 366
Projects: 2
Exp: 8 years



« Reply #1 - Posted 2011-09-27 02:04:42 »

All threads are distributed among cores automatically.

Myomyomyo.
Offline Conner_

Senior Newbie




~ Java Game Dev ~


« Reply #2 - Posted 2011-09-27 02: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! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline theagentd

« JGO Bitwise Duke »


Medals: 366
Projects: 2
Exp: 8 years



« Reply #3 - Posted 2011-09-27 02: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?

Myomyomyo.
Offline princec

« JGO Spiffy Duke »


Medals: 439
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #4 - Posted 2011-09-27 11: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 Overlord »


Medals: 848
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #5 - Posted 2011-09-27 11: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
Offline princec

« JGO Spiffy Duke »


Medals: 439
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #6 - Posted 2011-09-27 11: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 Overlord »


Medals: 848
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #7 - Posted 2011-09-27 11: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
Offline princec

« JGO Spiffy Duke »


Medals: 439
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #8 - Posted 2011-09-27 11: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
« Reply #9 - Posted 2011-09-27 12: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! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline princec

« JGO Spiffy Duke »


Medals: 439
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #10 - Posted 2011-09-27 12: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 Bitwise Duke »


Medals: 366
Projects: 2
Exp: 8 years



« Reply #11 - Posted 2011-09-27 14:17:54 »

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

Myomyomyo.
Offline princec

« JGO Spiffy Duke »


Medals: 439
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #12 - Posted 2011-09-27 14:33:24 »

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

Cas Smiley

Offline Roquen
« Reply #13 - Posted 2011-09-27 15: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 Kernel


Medals: 202



« Reply #14 - Posted 2011-09-27 15: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 Overlord »


Medals: 848
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #15 - Posted 2011-09-27 19: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
Offline princec

« JGO Spiffy Duke »


Medals: 439
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #16 - Posted 2011-09-27 20: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]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Mr.CodeIt (8 views)
2014-12-27 04:03:04

TheDudeFromCI (12 views)
2014-12-27 02:14:49

Mr.CodeIt (25 views)
2014-12-23 03:34:11

rwatson462 (56 views)
2014-12-15 09:26:44

Mr.CodeIt (46 views)
2014-12-14 19:50:38

BurntPizza (92 views)
2014-12-09 22:41:13

BurntPizza (113 views)
2014-12-08 04:46:31

JscottyBieshaar (83 views)
2014-12-05 12:39:02

SHC (94 views)
2014-12-03 16:27:13

CopyableCougar4 (102 views)
2014-11-29 21:32:03
Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!