1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

oos in c2c?

Discussion in 'Civ4 - Caveman 2 Cosmos' started by keldath, Aug 28, 2014.

  1. keldath

    keldath LivE LonG AnD PrOsPeR

    Joined:
    Dec 20, 2005
    Messages:
    6,665
    Location:
    israel
    hello good people of c2c,

    i wish to know if c2c has oos in it under multiplayer - mostly direct ip.

    thank you in advance and a good weekend.
     
  2. AIAndy

    AIAndy Deity

    Joined:
    Jun 8, 2011
    Messages:
    3,414
    Little to no OOS as long as the number of pipeline threads is reduced to 1 in the global defines XML (as that code has some non deterministic behavior in the order that units are created which unfortunately influences the unit IDs and therefore causes OOS).

    I have been playing a direct IP game of C2C with a friend lately and entire evenings go by without a single OOS.
     
  3. keldath

    keldath LivE LonG AnD PrOsPeR

    Joined:
    Dec 20, 2005
    Messages:
    6,665
    Location:
    israel
    ohh how nice ,

    whats a pipeline ?


    thank you for the fats answer aiandy!
     
  4. AIAndy

    AIAndy Deity

    Joined:
    Jun 8, 2011
    Messages:
    3,414
    An approach to multithreading the city (and city AI) processing that Koshling added to C2C.
    That significantly improves turn times on multi core processors (which are common nowadays) and for the most part is even safe for multiplayer but it does mess up the order of unit ids of newly created units so to make this work properly in multiplayer would need some more effort.
     
  5. Sn0bb

    Sn0bb Chieftain

    Joined:
    Jun 21, 2012
    Messages:
    14
    So the problems of simultaneous turns have been fixed mostly (if not completely)? Year or two ago it was impossible to play in MP due constant OoS errors.

    Also maybe a detailed information could be made on how to make the MultiPlayer work for novices.
     
  6. AIAndy

    AIAndy Deity

    Joined:
    Jun 8, 2011
    Messages:
    3,414
    TB has invested some serious effort in understanding them, tracking them down and fixing them.
    Apart from that single global defines XML change I don't think there are any special things you have to do.

    Well, there is one advice: If any OOS happens, both players need to restart the game and rehost/rejoin. Going to the main menu is not enough.
     
  7. Thunderbrd

    Thunderbrd C2C War Dog

    Joined:
    Jan 2, 2010
    Messages:
    27,816
    Gender:
    Male
    Location:
    Las Vegas
    In the C:\Program Files (x86)\Firaxis Games\Sid Meier's Civilization 4\Beyond the Sword\Mods\Caveman2Cosmos\Assets\XML\A_New_Dawn_GlobalDefines.xml you'll find NUM_CITY_PIPELINE_THREADS set to 4. All machines should turn this to 1.

    There's still a few OOS errors lurking, some in pathing so the less automation and far sending of units the better (you can sometimes resolve these by deleting the unit that's just taken a position differing from what shows on another system or moving it back to the position the other system shows if you can in the same round.)

    Also, never use the special preset build queues... those are a sure bet to cause OOS errors according to our playtesting.

    On team play, wonder building can be a problem - although it may allow you to due to some caching issues, make sure before setting a World Wonder to build you check first that your team member isn't building it already. That'll spark an OOS as well.

    But it should be pretty playable in Direct IP. Most of the OOS errors have been repaired. (Thanks for the props AIAndy!)
     
  8. Afforess

    Afforess The White Wizard

    Joined:
    Jul 31, 2007
    Messages:
    12,239
    Location:
    Austin, Texas
    Is there a reason C2C hasn't pulled in my change to auto-update the pipeline threads based on Cores present and whether the game is in MP? There is zero reason or excuse for making players fiddle with XML to make MP work.

    Edit: Code included, below

    Code:
    CvPipeline*	CvPlayer::createCityTurnPipeline()
    {
    	SYSTEM_INFO sysinfo;
    	GetSystemInfo(&sysinfo);
    	DWORD numCPU = sysinfo.dwNumberOfProcessors;
    	int iMaxThreads = std::max(1, ((int)numCPU / 2));
    	int iThreads = (GC.getGameINLINE().isGameMultiPlayer() ? 1 : std::min(iMaxThreads, std::max(1, 1 + getNumCities() / 8)));
    
    	CvPipeline*			pResult = new CvPipeline(iThreads);
    ...
    
     
  9. Thunderbrd

    Thunderbrd C2C War Dog

    Joined:
    Jan 2, 2010
    Messages:
    27,816
    Gender:
    Male
    Location:
    Las Vegas
    Well.... other projects were afoot. ;) Thanks though. I'll try to get that in this weekend.
     
  10. keldath

    keldath LivE LonG AnD PrOsPeR

    Joined:
    Dec 20, 2005
    Messages:
    6,665
    Location:
    israel
    hail to afforess!

    thanks all.
     
  11. alberts2

    alberts2 Emperor

    Joined:
    Aug 16, 2012
    Messages:
    1,947
    Gender:
    Male
    Location:
    Germany
    The MP part of your change is OK for C2C but for the SP we need to change your code.
    C2C is bloated like hell and needs more PipelineThreads compared with AND, everything below 4 is slower on my system.

    AND is different because after reducing PipelineThreads from 4 to 2 it was faster.
     
  12. Afforess

    Afforess The White Wizard

    Joined:
    Jul 31, 2007
    Messages:
    12,239
    Location:
    Austin, Texas
    I didn't bring up the SP change, I only was saying you should bring in the MP change.

    As an aside though, setting the pipeline threads without respect to the users processor count is bad, and could make things slower, not faster. Extra threads that can not be handled in parallel are additional overhead.
     
  13. Stormwind

    Stormwind King

    Joined:
    Dec 7, 2008
    Messages:
    697
    Are hyperthreading "cores" counted or or has anybody tested if HT is good/bad for the number of pipelines used?
     
  14. Afforess

    Afforess The White Wizard

    Joined:
    Jul 31, 2007
    Messages:
    12,239
    Location:
    Austin, Texas
    Hyperthreading cores are counted by the system as individual cores. I have a quad core i7 with hyperthreading, my core count reported by the windows API call above is 8.
     
  15. alberts2

    alberts2 Emperor

    Joined:
    Aug 16, 2012
    Messages:
    1,947
    Gender:
    Male
    Location:
    Germany
    Was that the reason for numCPU / 2 ?
    I have only a quad core i5 without hyperthreading that means only two cores are used by AND at the moment.
     
  16. Afforess

    Afforess The White Wizard

    Joined:
    Jul 31, 2007
    Messages:
    12,239
    Location:
    Austin, Texas
    That and also consider that just because a system has 4 cores, does not mean all 4 cores are usable to every application. Consider that the OS is likely to use resources as well, plus any background applications. I think I might change it to numCPU -1 instead of / 2 but the idea still stands.
     
  17. alberts2

    alberts2 Emperor

    Joined:
    Aug 16, 2012
    Messages:
    1,947
    Gender:
    Male
    Location:
    Germany
    But my tests with C2C showed using all cores is still faster on my system.


    I found a few other issues with the pipeline e.g. it is possible that AI players build the same wonder in multiple cities. But at least they can only finish it once.
     
  18. Koshling

    Koshling Vorlon

    Joined:
    Apr 11, 2011
    Messages:
    9,254
    Whether you want to map physical cores, or logical cores (will differ with hyper-threading), depends a lot on memory access patterns, since each physical core has it's own L2 cache, and switching between threads on a physical core, even if they are on different logical cores, can cause cache eviction if the working set union is greater than the cache size. This can lead to lower performance if you try to use all logical cores than if you just use all physical (i.e. - leave half the logical idle). Similarly allowing a thread to switch between physical cores when it is rescheduled can have nasty CPU cache implications, since it will have moved to a different L2 cache mid-way through what it was doing. For that reason some workloads behave better if you pin a thread to a particular core.

    I do not know where the memory-access patterns of C2C put it in the spectrum, but if I had to guess, I would say the working set for city processing is actually reasonably small, so allowing full use of logical cores is probably best.

    We did a lot of workload analysis to find the best settings in Sancho (and ended up finding different results worked best on different hardware, so made it configurable) - this is discussed a little here: Sancho multi-threading
     
  19. Iceciro

    Iceciro Special Ability: Decimate

    Joined:
    Jul 12, 2006
    Messages:
    1,944
    Location:
    in ur empire, takin ur cities
    Aside from the cores (which I set) what's the correct way to do things for a multiplayer, direct IP connection game when it comes to setting up BUG and the revDCM settings?
     
  20. Afforess

    Afforess The White Wizard

    Joined:
    Jul 31, 2007
    Messages:
    12,239
    Location:
    Austin, Texas
    Unless C2C has changed it - the BUG and RevDCM settings sync themselves across all players. Options that should not be changed mid-game, or by non-host players are greyed out. Options that can be changed mid-game are available in MP. Changes to them in-game will sync across all machines.

    That was written by me ages ago as part of RAND...2011ish probably.
     

Share This Page