Hurray the Linux build is now working.
The biggest bug was that some of the Tool make files still had the sse4.1 options
This made the code crash on the start and kgdb is not capable of debugging code if it crashes before main.
anyway the code now works in linux, and multithreading just work as well, the cool thing is that in my old Intel 2.4 hg Pentium, which is a hyper threaded by that I have turned off at the bios level,
if I set the treading code to 16 thread most demo run twice almost as fast.
This is treading on a single core, therefore I expect that in real dual and quad core the code should yield linear or better than linear performance gain by increasing the number of cores.
It seems that four thread per core is the optimal ratio at least in this machine, however adding more thread does not make it worse.
It seems that threading in Linux is better than in windows 7, or at least it is no worse.
In the demos, mouse picking and the keyboard does not work yet, next time I will fix those, but for now all demo run and it confirmed the thread seem to offer performance game linear with the thread count. 1
6 thread in my single core yield 34 fps in the terrain demos, while a single core is only 21.
This is better than I was expecting for an older machine.
fio rteh Mac teh problem taht I have now is that teh GUI does not have a posrt fo OSX, bascially teh run teh Linux version with and X11 server, I have to leran hwo to do that so that I can run etst teh mutthreadin code.
however they are only tow function that nee to be check or impelmnetd, this two
- Code: Select all
inline dgInt32 dgAtomicExchangeAndAdd (dgInt32* const addend, dgInt32 amount)
{
// it is a pity that pthread does not supports cross platform atomics, it would be nice if it did
// return PTW32_INTERLOCKED_EXCHANGE_ADD_LONG ((long*) addend, long (amount));
#if (defined (_WIN_32_VER) || defined (_WIN_64_VER) || defined (_MINGW_32_VER) || defined (_MINGW_64_VER))
return _InterlockedExchangeAdd((long*) addend, long (amount));
#endif
#if (defined (_LINUX_VER))
return __sync_fetch_and_add ((int32_t*)addend, amount );
#endif
#if (defined (_MAC_VER))
dgInt32 count = OSAtomicAdd32Barrier (amount, (int32_t*)addend);
return count - *addend;
#endif
}
inline dgInt32 dgInterlockedExchange(dgInt32* const ptr, dgInt32 value)
{
// it is a pity that pthread does not supports cross platform atomics, it would be nice if it did
// return PTW32_INTERLOCKED_EXCHANGE_LONG ((long*) ptr, value);
#if (defined (_WIN_32_VER) || defined (_WIN_64_VER) || defined (_MINGW_32_VER) || defined (_MINGW_64_VER))
return _InterlockedExchange((long*) ptr, value);
#endif
#if (defined (_LINUX_VER))
//return __sync_fetch_and_add ((int32_t*)ptr, value );
__sync_synchronize();
return __sync_lock_test_and_set((int32_t*)ptr, value);
#endif
#if (defined (_MAC_VER))
// bool OSAtomicCompareAndSwapLongBarrier(long oldValue, long newValue, volatile long *theValue);
// compare oldValue to *theValue, and set *theValue to newValue if the comparison is equal. The comparison
// and assignment occur as one atomic operation.
// somehow this does no work in macs, I need to test it.
//int32_t oldVal = *ptr;
//OSAtomicCompareAndSwapLongBarrier(oldVal, value, (int32_t*)ptr);
//return oldVal;
#endif
}
I beleive the first one I thnk it is right, it is the secund that I have doubts