Note: The "Dual Core" problem, and its affect on games

Discussion in 'Game Development (Technical)' started by PoV, Jun 3, 2006.

  1. PoV

    PoV
    Indie Author

    Joined:
    Jul 27, 2004
    Messages:
    2,132
    Likes Received:
    0
    It's been discussed briefly in another topic, but not in much detail. It's also a similar problem to the laptop/power save fun that was an exciting discussion early last year, albiet new. So as a service to the community, I want to make more non dual core PC users aware of it.

    I'm sure many of you are well aware that there's these nifty CPU's out there that have the equivalent of 2 CPU's on a single chip. The hip kids like to call this "Dual Core". And early next year, we'll have these highly sophisticated systems with this space age technology they like to call "Quad Core".

    They point is, they're making there way in to consumer desktops. I opened up a Future Shop flyer (Like a Best Buy, but slightly more Canadian), and saw an impressive Dual Core AMD system for a mere $999 CAD (about $900 US). Now, that's an impressive price, and would make a great upgrade for a family sick of their 1 ghz eMachine. After all, the kids will be going to college soon.

    So sure, that sounds great. Just like every year there's some big change, it up's the minimum spec, and we can all write more complicated games. Hooray. How is that bad?

    It's not, but there's a problem, and unless you're on dual core, you're probably not aware of it. This sums up to something that seems to be named "Thread Affinity".

    Now, applications still work on Dual Core machines, but sometimes exibit strange behaviors. For some games it's performance. For others, for some odd reason, scrolling seems to break.

    A short list of games off the top of my head, with issues.
    - Kaptain Brawe. Game runs great (no framerate drop), but playfields can't scroll (stopping you from getting important items from certain rooms).
    - Balloon Express. Similarly, the playfield can't scroll (which is vital to the gameplay).
    - Warcraft 3. Game runs ok, with a little stutter. However, edge scrolling moves you a few steps, then instantly jumps you to the extreme far side of the map in the direction you were scrolling.
    - Adobe Audition 2. Not a game, and not ruined, but playing a sample, as it tracks along, the visual tracking stops dead. Not a critical issue, but annoying, as the sound still plays fine.

    There's a few things that can be done by the user (which is half the problem).

    As an AMD user, there's a pair of patches out there. One, a hotfix from Microsoft, and a driver of sorts from AMD. They fix some issues which I've forgotten. I tried find official references from AMD and Microsoft for the patches, but all I seem to find is game support forum posts and the files hosted locally on some game sites.

    Also, there was a time up until a few months ago when NVidia drivers broke several applications (Paint Shop Pro of all things). Latest Beta drives do the job though.

    However, these don't do anything for the above apps. Instead, there's a little trick you have to do once you run an application. You need to alt+tab your way out of the app first. Then with a stroke of CTRL+ALT+DEL to bring up the task manager in XP, you need to find the misbehaving application under processes. Right click on it and select "Set Affinity", and deselect a core (CPU 0 and 1 are always both selected). This fixes most problems, but is probably too much work for the less computer included users.

    And even still, there are apps that don't work correctly on a Dual Core. Tower, from last month's round up, for example.

    Now I don't have all the details about it, and that's why I've started this post. I'm an AMD X2 3800+ (Dual Core) user, and I experience these problems. An end use will have no desire to deal with this, and there's certainly things that we can do on the development end, since it's only a handful of applications that do this.

    I'm also curious to hear of issues Intel Core Duo users have had, if they differ at all.

    Please, do share if you have something.
     
  2. Genimo

    Indie Author

    Joined:
    Dec 23, 2005
    Messages:
    92
    Likes Received:
    0
  3. David De Candia

    Original Member

    Joined:
    Nov 21, 2005
    Messages:
    89
    Likes Received:
    0
    Well, I'm not sure if the following problem is just me doing something foolish with my code - but I thought I may as well mention it.

    I use a cpu-friendly sleep function to cap fps as described in

    http://www.geisswerks.com/ryan/FAQS/timing.html

    "Accurate FPS Limiting / High-precision 'Sleeps'"

    With dual-core machines this code isn't working for me (even after SetThreadAffinity) .The frame rate seemingly pays no attention to the cap. The same code using the multimedia timer works fine.

    I hesitated to mention it at first - since I thought it may be a 64bit issue generally, but given the dearth of replies I thought I'd raise it. I'd love it if someone could try this code and see if they can replicate my problem? Or just explain what I'm doing wrong?
     
  4. cliffski

    Moderator Original Member

    Joined:
    Jul 27, 2004
    Messages:
    3,897
    Likes Received:
    0
    This is scary. I presumed dual core machines would run a single process on a single core. how can they split a thread accross two CPUS if it wasn't coded for it???
     
  5. PoV

    PoV
    Indie Author

    Joined:
    Jul 27, 2004
    Messages:
    2,132
    Likes Received:
    0
    I can't be sure exactly what's going on, but it's quite possible that an application makes it's way to the other core when it's suspended, as per the normal operation of multi-tasking. In theory, as long as all the data is available, it shouldn't matter which core the application timeslice runs on, so long as it can still get it's data. Even in that case, there's no good explanation why a timer would get out of sync... short of caching, but that should introduce stutter everywhere. Then again I'm not even sure what the exact phenomenom causing these issues is, which is why I started this thread. As I mentioned, some games have minor performance problems (Warcraft 3 appears to drop to 50 fps instead of 60 with both cores), but it's the strange behaviors that seem more common. What almost seems creepier to me, is how common it is to see an application work perfectly fine.

    David: Have you tried limiting your app to a single core manually via "process" on the task manager (Set Affinity)? Does it work there?
     
  6. jetro

    Original Member

    Joined:
    Jan 21, 2005
    Messages:
    130
    Likes Received:
    0
  7. PoV

    PoV
    Indie Author

    Joined:
    Jul 27, 2004
    Messages:
    2,132
    Likes Received:
    0
    Cool, I've seen a few of those on the net. I had to use one to get an earlier version of Thunderbird to not prematurly time out it's attempt to contact my mail server.
     
  8. Mark Fassett

    Moderator Indie Author

    Joined:
    Jul 26, 2004
    Messages:
    541
    Likes Received:
    0
    From what I understand, the timing problems come in when things like AMD's cool & quiet technology turn on. This will allow both cores to not run at the same speed, and since, often, timing is done by measuring processor ticks, when it migrates to the other core, the new core can be far behind on it's ticks. This can cause the game to think it's much further ahead in time than it really is. Artificially limiting the number of ticks that you allow to pass between time checks can help solve some of this.
     
  9. GBGames

    Indie Author

    Joined:
    Jul 27, 2004
    Messages:
    1,255
    Likes Received:
    0
    It sounds like it is a lot of work to get legacy apps to work correctly. Wouldn't AMD offer developers tips on how to get around these issues?
     
  10. Mark Fassett

    Moderator Indie Author

    Joined:
    Jul 26, 2004
    Messages:
    541
    Likes Received:
    0
    It's not just AMD - you'd see the same problem with Intel dual core chips, as well as multi-processor systems that implement power saving features. That's not to say it wouldn't be nice to see some help in that area. The best solution would be to implement some single timing chip on the motherboard and not use the CPU clock for timing.
     
  11. David De Candia

    Original Member

    Joined:
    Nov 21, 2005
    Messages:
    89
    Likes Received:
    0
    In short, No. I don't know what to make of these results. FPS cap on my game is 100. Using QPC I sleep (as per code reference I posted earlier) to enforce this max cap.

    on this machine:

    AMD Athlon(tm) 64 X2 Dual Core Processor 4800+

    with SetThreadAffinity on the main game thread, FPS is 380. With Thread Affinity set manually via task manager, FPS is still 380.

    If I fall back on the multimedia timer, FPS is capped correctly at 100.
     
  12. Robert Cummings

    Original Member

    Joined:
    Apr 3, 2005
    Messages:
    1,155
    Likes Received:
    0
    In actual fact, it'll use both cores for most programs - it'll execute instructions on the available core, which will be either (just not simultaneously). You can set the affinity manually in the task manager if you must to force a core.
     

Share This Page

  • About Indie Gamer

    When the original Dexterity Forums closed in 2004, Indie Gamer was born and a diverse community has grown out of a passion for creating great games. Here you will find over 10 years of in-depth discussion on game design, the business of game development, and marketing/sales. Indie Gamer also provides a friendly place to meet up with other Developers, Artists, Composers and Writers.
  • Buy us a beer!

    Indie Gamer is delicately held together by a single poor bastard who thankfully gets help from various community volunteers. If you frequent this site or have found value in something you've learned here, help keep the site running by donating a few dollars (for beer of course)!

    Sure, I'll Buy You a Beer