This project is read-only.

Compiling/using enhsim on Linux... weird results.

Aug 13, 2009 at 3:24 AM

I downloaded the enhsim sources and tried to compile it.  Well, compilation goes ok... after a few moments of tinkering... (renamed stdafx.cpp to stdafx.cxx to get it out of the way).

 

Compile:

$#  g++ -O0 -fno-strict-aliasing -march=native -mtune=core2 -DHAVE_SSE2 -msse2 *.cpp -o enhsim

...no errors with that. But, the output of "enhsim config.txt" is rather weird (a clip from end of it):

DPS                 PPM       MPS
white               0.00      14.34%    0.00
windfury            0.00      12.51%    0.00
flametongue         0.00      4.76%     0.00
stormstrike         0.00      4.82%     0.00      0.00      40.00%
spirit wolves       0.01      63.58%    0.00      0.00      60.00%

---

...which doesn't at all match with result of "enhsim.exe config.txt" (executed the windoze console app with wine):

DPS                 PPM       MPS
white               1285.64   31.99%    96.52
windfury            535.21    13.32%    6.62
flametongue         339.92    8.46%     63.66
stormstrike         242.72    6.04%     6.32      34.80     15.71%
lava lash           148.96    3.71%     7.98      21.98     9.92%
magma totem         330.43    8.22%     2.59      48.25     21.77%
earth shock         395.37    9.84%     8.96      57.92     26.14%
lightning bolt      449.64    11.19%    7.63      55.90     25.22%
lightning shield    154.85    3.85%     1.22      0.00      0.00%
spirit wolves       135.90    3.38%     0.33      2.75      1.24%

 

What gives?

May 19, 2010 at 8:30 AM

After number of hacking found, that it happens in the following expression at skills.cpp:

int64 casttime = floor(casting_time_ / sim.spell_haste_divider_ * (1.0 - (0.2 * sim.maelstrom_weapon_->stack_)));

The problem is that (1.0 - (0.2 * sim.maelstrom_weapon_->stack_)) equation doesn't round to zero and gives something like -5.1241234e-17. That negates the whole expression giving casttime = -1.

Solved it by adding -ffloat-store to g++ options.

 

May 19, 2010 at 9:18 AM

Setting this option also significantly reduces the computation time, because floats are not stored in registers.

So this issue can also be fixed by patching:

 

*** skills.cpp  2010-05-19 12:00:51.117511830 +0400
--- skills.cpp.new      2010-05-19 12:02:44.244146019 +0400
***************
*** 547,553 ****
        sim.global_cooldown_->cd_ = true;
        sim.addLowPrioEvent(sim.spell_gcd_duration_, sim.global_cooldown_, 0, sim.randomLag());

!       int64 casttime = floor(casting_time_ / sim.spell_haste_divider_ * (1.0 - (0.2 * sim.maelstrom_weapon_->stack_)));
        sim.spell_casting_->startCasting(this, casttime, !(sim.maelstrom_weapon_->stack_ > 0));

        return true;
--- 547,553 ----
        sim.global_cooldown_->cd_ = true;
        sim.addLowPrioEvent(sim.spell_gcd_duration_, sim.global_cooldown_, 0, sim.randomLag());

!       int64 casttime = sim.maelstrom_weapon_->stack_ == 5 ? 0 : floor(casting_time_ / sim.spell_haste_divider_ * (1.0 - (0.2 * sim.maelstrom_weapon_->stack_)));
        sim.spell_casting_->startCasting(this, casttime, !(sim.maelstrom_weapon_->stack_ > 0));

        return true;
***************
*** 619,625 ****
        sim.global_cooldown_->cd_ = true;
        sim.addLowPrioEvent(sim.spell_gcd_duration_, sim.global_cooldown_, 0, sim.randomLag());

!       int64 casttime = floor(casting_time_ / sim.spell_haste_divider_ * (1.0 - (0.2 * sim.maelstrom_weapon_->stack_)));
        sim.spell_casting_->startCasting(this, casttime, !(sim.maelstrom_weapon_->stack_ > 0));

        return true;
--- 619,625 ----
        sim.global_cooldown_->cd_ = true;
        sim.addLowPrioEvent(sim.spell_gcd_duration_, sim.global_cooldown_, 0, sim.randomLag());

!       int64 casttime = sim.maelstrom_weapon_->stack_ == 5 ? 0 : floor(casting_time_ / sim.spell_haste_divider_ * (1.0 - (0.2 * sim.maelstrom_weapon_->stack_)));
        sim.spell_casting_->startCasting(this, casttime, !(sim.maelstrom_weapon_->stack_ > 0));

        return true;

 

Actually, the wine version is still faster anyways:

For 6000h of simulating default config(from compiled release archive) on my core2 notebook, I have:

32s with wine version (not counting wine initialization)

43s with -ffloat-store

36s with patched version

Native versions compiled with -O3 option


There's also one small issue when doing linux compilation:

configfactory.h includes ConfigFactory.h file - a different file, than configfactory.h in Linux

The same thing happens with SetBonuses.h in stats.cpp

Oct 24, 2010 at 8:41 PM

Just an FYI, these should be fixed now.  Tell me if something else needs to be changed.