Moderators: Sascha Willems, walaber
jay3d wrote:Hi guys! The amazing thing is that the MingW compiled version gets to the speed to the SSE enabled version of MSVC compiled one without even turning on SSE in the example , which is a big advantage of speed compiling with GCC 4.5.2Cheers!Jay
jay3d wrote:Hi guys!
Long time I didn't post here, but from now on I will try to contribute to this wonderful Newton project
And lets start with a compile of NGD with MingW64(GCC 4.5.2) in 32-bit mode, I tested it and it fairly stable, but I need someone nice to test it too
link: http://www.mediafire.com/?x7fb0je0hyhbg55
The amazing thing is that the MingW compiled version gets to the speed to the SSE enabled version of MSVC compiled one without even turning on SSE in the example , which is a big advantage of speed compiling with GCC 4.5.2
Cheers!
Jay
0.22499999404, 0.47187501192, 0.1400000006
-0.22499999404, 0.47187501192, 0.1400000006
0.14687499404, 0.55000001192, 0.1400000006
-0.14687499404, 0.55000001192, 0.1400000006
0.22499999404, -0.12187501788, 0.1400000006
-0.22499999404, -0.12187501788, 0.1400000006
0.14687499404, -0.20000001788, 0.1400000006
-0.14687499404, -0.20000001788, 0.1400000006
0.22499999404, 0.47187501192, -0.1400000006
-0.22499999404, 0.47187501192, -0.1400000006
0.14687499404, 0.55000001192, -0.1400000006
-0.14687499404, 0.55000001192, -0.1400000006
0.22499999404, -0.12187501788, -0.1400000006
-0.22499999404, -0.12187501788, -0.1400000006
0.14687499404, -0.20000001788, -0.1400000006
-0.14687499404, -0.20000001788, -0.1400000006
bool dgCollisionConvexHull::Create (dgInt32 count, dgInt32 strideInBytes, const dgFloat32* const vertexArray, dgFloat32 tolerance)
{
_ASSERTE (0);
/*
Julio Jerez wrote:Jay3d if I am correct in tha you are using the corrent SVN, all you nee to do is update an dteh hull stuff is fixed.
sorry about that inconvenient.
Index: packages/dContainers/dThread.cpp
===================================================================
--- packages/dContainers/dThread.cpp (revision 456)
+++ packages/dContainers/dThread.cpp (working copy)
@@ -17,8 +17,8 @@
#include <Windows.h>
#include <crtdbg.h>
#endif
-
-#ifdef _LINUX_VER
+
+#ifdef _POSIX_VER
#include <pthread.h>
#include <semaphore.h>
#include <unistd.h>
@@ -28,7 +28,7 @@
static inline void dInterlockedIncrement (int* const Addend )
{
- #if (defined (_LINUX_VER))
+ #if (defined (_POSIX_VER))
__sync_fetch_and_add ((int32_t*)Addend, 1 );
#endif
@@ -44,7 +44,7 @@
static inline void dInterlockedDecrement(int* const Addend)
{
- #if (defined (_LINUX_VER))
+ #if (defined (_POSIX_VER))
__sync_fetch_and_sub ((int32_t*)Addend, 1 );
#endif
@@ -60,7 +60,7 @@
static inline int dInterlockedExchange (int* spin, int testValue)
{
- #if (defined (_LINUX_VER))
+ #if (defined (_POSIX_VER))
return __sync_val_compare_and_swap((int32_t*)spin, !testValue, testValue);
#endif
@@ -89,7 +89,7 @@
m_threadhandle = _beginthreadex( NULL, 0, TaskCallback, this, 0, NULL);
#endif
-#if (defined (_LINUX_VER) || defined (_MAC_VER))
+#if (defined (_POSIX_VER) || defined (_MAC_VER))
pthread_create( &m_threadhandle, NULL, TaskCallback, this);
#endif
}
@@ -105,7 +105,7 @@
#if defined (_MSC_VER)
unsigned _stdcall dThread::TaskCallback(void *param)
#endif
-#if (defined (_LINUX_VER) || defined (_MAC_VER))
+#if (defined (_POSIX_VER) || defined (_MAC_VER))
void* dThread::TaskCallback(void *param)
#endif
{
@@ -169,7 +169,7 @@
Sleep(0);
#endif
- #if (defined (_LINUX_VER) || defined (_MAC_VER))
+ #if (defined (_POSIX_VER) || defined (_MAC_VER))
sched_yield();
#endif
}
Index: packages/dContainers/dThread.h
===================================================================
--- packages/dContainers/dThread.h (revision 456)
+++ packages/dContainers/dThread.h (working copy)
@@ -13,7 +13,16 @@
#ifndef __DTHREAD_H__
#define __DTHREAD_H__
+#if ( defined (_LINUX_VER) || defined (_MINGW_32_VER) || defined (_MINGW_64_VER) )
+ #define _POSIX_VER
+ #include <pthread.h>
+#endif
+#if ( defined (_MINGW_32_VER) || defined (_MINGW_64_VER) )
+ #include <stdint.h>
+ #include <crtdbg.h>
+#endif
+
class dThread
{
public:
@@ -37,7 +46,7 @@
static unsigned _stdcall TaskCallback(void *param);
#endif
-#if (defined (_LINUX_VER) || defined (_MAC_VER))
+#if (defined (_POSIX_VER) || defined (_MAC_VER))
static void* TaskCallback(void *Param);
#endif
@@ -50,9 +59,9 @@
uintptr_t m_threadhandle;
#endif
-#if (defined (_LINUX_VER) || defined (_MAC_VER))
+#if (defined (_POSIX_VER) || defined (_MAC_VER))
pthread_t m_threadhandle;
#endif
};
-#endif
\ No newline at end of file
+#endif
Index: packages/dMath/dMathDefines.h
===================================================================
--- packages/dMath/dMathDefines.h (revision 456)
+++ packages/dMath/dMathDefines.h (working copy)
@@ -16,6 +16,10 @@
#include <math.h>
#include <float.h>
+#if ( defined (_MINGW_32_VER) || defined (_MINGW_64_VER) )
+ #include <crtdbg.h>
+#endif
+
#ifndef dFloat
#ifdef __USE_DOUBLE_PRECISION__
typedef double dFloat;
@@ -36,14 +40,14 @@
#define dAcos(x) dFloat (acos (dFloat(x)))
#define dAtan2(x,y) dFloat (atan2 (dFloat(x), dFloat(y)))
-#ifndef _MSC_VER
+#if ( !defined (_MSC_VER) && !defined (_MINGW_32_VER) && !defined (_MINGW_64_VER) )
#define _ASSERTE(x)
- #ifndef min
- #define min(a,b) ((a < b) ? (a) : (b))
- #define max(a,b) ((a > b) ? (a) : (b))
- #endif
#endif
+#ifndef min
+ #define min(a,b) ((a < b) ? (a) : (b))
+ #define max(a,b) ((a > b) ? (a) : (b))
+#endif
#ifdef _MSC_VER
#ifdef _DEBUG
Index: packages/thirdParty/tinyxml/tinyxmlparser.cpp
===================================================================
--- packages/thirdParty/tinyxml/tinyxmlparser.cpp (revision 456)
+++ packages/thirdParty/tinyxml/tinyxmlparser.cpp (working copy)
@@ -354,7 +354,7 @@
}
else
{
- while ( *p && IsWhiteSpace( *p ) || *p == '\n' || *p =='\r' )
+ while ( ( *p && IsWhiteSpace( *p ) ) || *p == '\n' || *p =='\r' )
++p;
}
Index: dgTypes.cpp
===================================================================
--- dgTypes.cpp (revision 465)
+++ dgTypes.cpp (working copy)
@@ -190,33 +190,41 @@
void cpuid(dgUnsigned32 op, dgUnsigned32 reg[4])
{
asm volatile(
+#ifdef _MINGW_64_VER
+ "pushq %%rbx \n\t" /* save %rbx */
+#else
"pushl %%ebx \n\t" /* save %ebx */
+#endif
"cpuid \n\t"
"movl %%ebx, %1 \n\t" /* save what cpuid just put in %ebx */
+#ifdef _MINGW_64_VER
+ "popq %%rbx \n\t" /* restore the old %rbx */
+#else
"popl %%ebx \n\t" /* restore the old %ebx */
+#endif
: "=a"(reg[0]), "=r"(reg[1]), "=c"(reg[2]), "=d"(reg[3])
: "a"(op)
: "cc");
Julio Jerez wrote:Tell me something how do I apply the patch, should I copy and Paste the code and save as a file, then run SVN Patch util?
Index: dgThreads.cpp
===================================================================
--- dgThreads.cpp (revision 456)
+++ dgThreads.cpp (working copy)
@@ -26,11 +26,11 @@
static inline void dgThreadYield()
{
- #if (defined (_WIN_32_VER) || defined (_WIN_64_VER) || defined (_MINGW_32_VER) || defined (_MINGW_64_VER))
+ #if (defined (_WIN_32_VER) || defined (_WIN_64_VER))
Sleep(0);
#endif
- #if (defined (_LINUX_VER) || defined (_MAC_VER))
+ #if (defined (_POSIX_VER) || defined (_MAC_VER))
#ifndef _MAC_IPHONE
sched_yield();
#endif
@@ -40,13 +40,13 @@
static inline void dgSpinLock (dgInt32 *spin)
{
- #if (defined (_WIN_32_VER) || defined (_WIN_64_VER) || defined (_MINGW_32_VER) || defined (_MINGW_64_VER))
+ #if (defined (_WIN_32_VER) || defined (_WIN_64_VER))
while (InterlockedExchange((long*) spin, 1)) {
Sleep(0);
}
#endif
- #if (defined (_LINUX_VER))
+ #if (defined (_POSIX_VER))
while(! __sync_bool_compare_and_swap((int32_t*)spin, 0, 1) ) {
sched_yield();
}
@@ -70,11 +70,11 @@
static inline void dgInterlockedIncrement (dgInt32* Addend )
{
- #if (defined (_WIN_32_VER) || defined (_WIN_64_VER) || defined (_MINGW_32_VER) || defined (_MINGW_64_VER))
+ #if (defined (_WIN_32_VER) || defined (_WIN_64_VER))
InterlockedIncrement((long*) Addend);
#endif
- #if (defined (_LINUX_VER))
+ #if (defined (_POSIX_VER))
__sync_fetch_and_add ((int32_t*)Addend, 1 );
#endif
@@ -87,11 +87,11 @@
static inline void dgInterlockedDecrement(dgInt32* Addend)
{
- #if (defined (_WIN_32_VER) || defined (_WIN_64_VER) || defined (_MINGW_32_VER) || defined (_MINGW_64_VER))
+ #if (defined (_WIN_32_VER) || defined (_WIN_64_VER))
InterlockedDecrement((long*) Addend);
#endif
- #if (defined (_LINUX_VER))
+ #if (defined (_POSIX_VER))
__sync_fetch_and_sub ((int32_t*)Addend, 1 );
#endif
@@ -104,7 +104,7 @@
dgThreads::dgThreads()
{
- #if (defined (_WIN_32_VER) || defined (_WIN_64_VER) || defined (_MINGW_32_VER) || defined (_MINGW_64_VER))
+ #if (defined (_WIN_32_VER) || defined (_WIN_64_VER))
SYSTEM_INFO sysInfo;
GetSystemInfo(&sysInfo);
m_numberOfCPUCores = dgInt32 (sysInfo.dwNumberOfProcessors);
@@ -113,17 +113,23 @@
memset (m_threadhandles, 0, sizeof (m_threadhandles));
#endif
- #if (defined (_LINUX_VER))
- m_numberOfCPUCores = sysconf(_SC_NPROCESSORS_ONLN);
+ #if (defined (_POSIX_VER))
+ #if (defined (_MINGW_32_VER) || defined (_MINGW_64_VER))
+ SYSTEM_INFO sysInfo;
+ GetSystemInfo(&sysInfo);
+ m_numberOfCPUCores = dgInt32 (sysInfo.dwNumberOfProcessors);
+ #else
+ m_numberOfCPUCores = sysconf(_SC_NPROCESSORS_ONLN);
+ #endif
m_numOfThreads = 0;
m_exit = false;
@@ -210,7 +216,7 @@
DestroydgThreads();
}
- #if (defined (_WIN_32_VER) || defined (_WIN_64_VER) || defined (_MINGW_32_VER) || defined (_MINGW_64_VER))
+ #if (defined (_WIN_32_VER) || defined (_WIN_64_VER))
if ((threads > 1) && (m_numberOfCPUCores > 1)) {
m_numOfThreads = GetMin (threads, m_numberOfCPUCores);
@@ -230,7 +236,7 @@
#endif
- #if (defined (_LINUX_VER) || defined (_MAC_VER))
+ #if (defined (_POSIX_VER) || defined (_MAC_VER))
if ((threads > 1) && (m_numberOfCPUCores > 1)) {
#ifdef _MAC_IPHONE
m_numOfThreads = 0;
@@ -254,13 +260,13 @@
void dgThreads::DestroydgThreads()
{
- #if (defined (_WIN_32_VER) || defined (_WIN_64_VER) || defined (_MINGW_32_VER) || defined (_MINGW_64_VER))
+ #if (defined (_WIN_32_VER) || defined (_WIN_64_VER))
_ASSERTE (m_workInProgress == 0);
while(m_workInProgress > 0){
@@ -292,7 +298,7 @@
m_numOfThreads = 0;
#endif
- #if (defined (_LINUX_VER) || defined (_MAC_VER))
+ #if (defined (_POSIX_VER) || defined (_MAC_VER))
while(m_workInProgress > 0){
usleep(100000);
@@ -330,20 +336,20 @@
job->ThreadExecute();
} else {
- #if (defined (_WIN_32_VER) || defined (_WIN_64_VER) || defined (_MINGW_32_VER) || defined (_MINGW_64_VER))
+ #if (defined (_WIN_32_VER) || defined (_WIN_64_VER))
dgInterlockedIncrement(&m_workInProgress);
if(WaitForSingleObject(m_emptySlot,INFINITE) != WAIT_OBJECT_0){
return(0);
}
- EnterCriticalSection(&m_criticalSection);
+ EnterCriticalSection(&m_criticalSection);
m_queue[m_topIndex] = job;
m_topIndex = (m_topIndex + 1) % DG_MAXQUEUE;
ReleaseSemaphore(m_workToDo,1,NULL);
LeaveCriticalSection(&m_criticalSection);
#endif
- #if (defined (_LINUX_VER) || defined (_MAC_VER))
+ #if (defined (_POSIX_VER) || defined (_MAC_VER))
dgInterlockedIncrement(&m_workInProgress);
while ( m_emptySlot == 0 ) {
dgThreadYield();
@@ -362,10 +368,10 @@
-#if (defined (_WIN_32_VER) || defined (_WIN_64_VER) || defined (_MINGW_32_VER) || defined (_MINGW_64_VER))
+#if (defined (_WIN_32_VER) || defined (_WIN_64_VER))
dgUnsigned32 _stdcall dgThreads::ThreadExecute(void *param)
#endif
-#if (defined (_LINUX_VER) || defined (_MAC_VER))
+#if (defined (_POSIX_VER) || defined (_MAC_VER))
void* dgThreads::ThreadExecute(void *param)
#endif
{
@@ -377,7 +383,7 @@
dgInt32 dgThreads::GetWork(dgWorkerThread** job)
{
- #if (defined (_WIN_32_VER) || defined (_WIN_64_VER) || defined (_MINGW_32_VER) || defined (_MINGW_64_VER))
+ #if (defined (_WIN_32_VER) || defined (_WIN_64_VER))
HANDLE hWaitHandles[2];
hWaitHandles[0] = m_workToDo;
hWaitHandles[1] = m_exit;
@@ -386,15 +392,15 @@
return 0;
}
- EnterCriticalSection(&m_criticalSection);
+ EnterCriticalSection(&m_criticalSection);
*job = m_queue[m_bottomIndex];
m_bottomIndex = (m_bottomIndex + 1) % DG_MAXQUEUE;
ReleaseSemaphore(m_emptySlot,1,NULL);
LeaveCriticalSection(&m_criticalSection);
#endif
- #if (defined (_LINUX_VER) || defined (_MAC_VER))
- for (;;) {
+ #if (defined (_POSIX_VER) || defined (_MAC_VER))
+ for (;;) {
while ( m_workToDo == 0 ) {
dgThreadYield();
}
Index: dgThreads.h
===================================================================
--- dgThreads.h (revision 456)
+++ dgThreads.h (working copy)
@@ -24,7 +24,18 @@
#define DG_MAXQUEUE 16
+#if ( defined (_LINUX_VER) || defined (_MINGW_32_VER) || defined (_MINGW_64_VER) )
+ #define _POSIX_VER
+ #include <pthread.h>
+ #include <semaphore.h>
+ #include <unistd.h>
+#endif
+#if ( defined (_MINGW_32_VER) || defined (_MINGW_64_VER) )
+ #include <stdint.h>
+ #include <crtdbg.h>
+#endif
+
class dgWorkerThread
{
public:
@@ -65,17 +76,17 @@
{
dgInt32 m_ticks;
dgInt32 m_threadIndex;
- dgThreads* m_manager;
+ dgThreads* m_manager;
};
void DoWork(dgInt32 threadIndex);
dgInt32 GetWork(dgWorkerThread** cWork);
-#if (defined (_WIN_32_VER) || defined (_WIN_64_VER) || defined (_MINGW_32_VER) || defined (_MINGW_64_VER))
+#if (defined (_WIN_32_VER) || defined (_WIN_64_VER))
static dgUnsigned32 _stdcall ThreadExecute(void *Param);
#endif
-#if (defined (_LINUX_VER) || defined (_MAC_VER))
+#if (defined (_POSIX_VER) || defined (_MAC_VER))
static void* ThreadExecute(void *Param);
#endif
@@ -86,7 +97,7 @@
dgInt32 m_workInProgress;
mutable dgInt32 m_globalSpinLock;
-#if (defined (_WIN_32_VER) || defined (_WIN_64_VER) || defined (_MINGW_32_VER) || defined (_MINGW_64_VER))
+#if (defined (_WIN_32_VER) || defined (_WIN_64_VER))
HANDLE m_exit;
HANDLE m_workToDo;
HANDLE m_emptySlot;
@@ -95,7 +106,7 @@
HANDLE m_threadhandles[DG_MAXIMUN_THREADS];
#endif
-#if (defined (_LINUX_VER) || defined (_MAC_VER))
+#if (defined (_POSIX_VER) || defined (_MAC_VER))
bool m_exit;
dgInt32 m_emptySlot;
dgInt32 m_workToDo;
Users browsing this forum: No registered users and 9 guests