A place to discuss everything related to Newton Dynamics.
Moderators: Sascha Willems, walaber
by pHySiQuE » Sun Jul 15, 2012 5:43 pm
Around line 59 of dgThread.cpp, change this:
- Code: Select all
#ifdef DG_THREAD_EMULATION
dgThread::dgSemaphore::dgSemaphore ()
:m_sem (0)
{
}
To this:
- Code: Select all
#ifdef DG_THREAD_EMULATION
dgThread::dgSemaphore::dgSemaphore ()
:m_sem ()
{
}
Android NDK doesn't like using the 0 for a pointer.
-
pHySiQuE
-
- Posts: 608
- Joined: Fri Sep 02, 2011 9:54 pm
by Julio Jerez » Sun Jul 15, 2012 6:08 pm
but the secudn mode will leave un inlitlizes
can to try m_sem (NULL)
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by pHySiQuE » Sun Jul 15, 2012 6:44 pm
Using NULL gives me this error:
/svn/Leadwerks3D/Engine/Projects/Android2.2b/jni/../../../Source/../../../NewtonDynamics/coreLibrary_300/source/core/dgThread.cpp: In constructor 'dgThread::dgSemaphore::dgSemaphore()':
/svn/Leadwerks3D/Engine/Projects/Android2.2b/jni/../../../Source/../../../NewtonDynamics/coreLibrary_300/source/core/dgThread.cpp:62: error: no matching function for call to 'sem_t::sem_t(NULL)'
/Applications/AndroidSDK/android-ndk-r7/platforms/android-8/arch-arm/usr/include/semaphore.h:37: note: candidates are: sem_t::sem_t(const sem_t&)
/Applications/AndroidSDK/android-ndk-r7/platforms/android-8/arch-arm/usr/include/semaphore.h:37: note: sem_t::sem_t()
-
pHySiQuE
-
- Posts: 608
- Joined: Fri Sep 02, 2011 9:54 pm
by Julio Jerez » Sun Jul 15, 2012 8:59 pm
Ok I change dot this
- Code: Select all
dgThread::dgSemaphore::dgSemaphore ()
{
m_sem = NULL;
}
sinc and comple again.
If there any reason why you are compiling with thread in emulations. does not the android sdk supports POSIT threads?
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by pHySiQuE » Mon Jul 16, 2012 1:14 am
You're right, threads are working fine on Android.
-
pHySiQuE
-
- Posts: 608
- Joined: Fri Sep 02, 2011 9:54 pm
by Julio Jerez » Mon Jul 16, 2012 1:29 am
how many core does android has?
but even with a single core, I found that using twice as many threads per core yield better result. I can not explain why but that seems to be the case in window and linux.
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by pHySiQuE » Mon Jul 16, 2012 1:36 am
Okay, threading works on Mac and Android. On iOS, both the simulator and the actual device, the program stops with the error "Program received signal 'SIGABRT" on TickCallback in this function:
- Code: Select all
void dgMutexThread::Execute (dgInt32 threadID)
{
// suspend this tread until the call thread decide to
_ASSERTE (threadID == m_id);
while (!m_terminate) {
// wait for the main thread to signal an update
dgInterlockedExchange(&m_isBusy, 0);
SuspendExecution(m_myMutex);
dgInterlockedExchange(&m_isBusy, 1);
if (!m_terminate) {
TickCallback(threadID); // Program received signal '"SIGABRT"
// let main thread resume execution
m_callerMutex.Release();
}
}
dgInterlockedExchange(&m_isBusy, 0);
}
- Code: Select all
pure virtual method called[Switching to process 9219 thread 0x2403]
[Switching to process 9219 thread 0x2403]
Single stepping until exit from function __pthread_kill,
which has no line number information.
warning: Remote failure reply: E37
Current language: auto; currently c++
Single stepping until exit from function abort,
which has no line number information.
pure virtual method called[Switching to process 9731 thread 0x2603]
[Switching to process 9731 thread 0x2603]
I can live without threading on iOS, but it is strange.
-
pHySiQuE
-
- Posts: 608
- Joined: Fri Sep 02, 2011 9:54 pm
by carli2 » Mon Jul 16, 2012 1:56 am
Julio Jerez wrote:how many core does android has?
Depends on which ARM processor you use.
There are up to 4 cores in the latest Tegra chips.
Julio Jerez wrote:but even with a single core, I found that using twice as many threads per core yield better result. I can not explain why but that seems to be the case in window and linux.
Does your CPU have hyper threading? (All intel except atom have)
-
carli2
-
- Posts: 157
- Joined: Thu Nov 10, 2011 1:53 pm
by Julio Jerez » Mon Jul 16, 2012 2:18 am
yes My linux machine in a 2.4 pentium 4 hypertreading. But I had never seem multtreaded code or sse code actualy running faster than simple x87 until wrote the new dgTread class for core 300.
as far as I remember I was so disappointed with hypertreading than I dissabled at the bios level.
I am very saitified with the new dgthread class, it is sleep free, in core 200 it was not and after 2 maybe 4 threads It got dimishing returns.
now core 300 the ghread count can be unlimited. I put a limit to 16 but it is an arbirtrary number.
in core 300 in my sytem Intel7 each time I double the thread count the performance almost double until it reaches 8 threads, after that point it still gain performance but it is marginal. it never slower witch was the case before.
for this reason now Newton is thread even in a single core. unless it is compiled with thread emulation on
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by Julio Jerez » Mon Jul 16, 2012 2:20 am
pHySiQuE does than happens on Mac OSX or Iphone?
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by pHySiQuE » Mon Jul 16, 2012 2:31 am
Hmmm, I guess it happens on all of these:
-OSX
-iOS simulator
-iOS device
It's complaining about a "pure virtual method called" but I don't see why. In the debugger, it says the threadID is 0.
-
pHySiQuE
-
- Posts: 608
- Joined: Fri Sep 02, 2011 9:54 pm
by Julio Jerez » Mon Jul 16, 2012 7:58 am
Ok, Iit is probably teh atimic not working right in OSX, I am not using OSX specifc atomics, inestead GCC specific onces.
can you build the mac without thread for now, until I have time to debug that.
I am writing a native mac framework fo the Mac but I put in hold for teh momnet until O move the ething I am workng at the momnet a litle further alone.
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by pHySiQuE » Mon Jul 16, 2012 11:24 am
Sure, no prob.
-
pHySiQuE
-
- Posts: 608
- Joined: Fri Sep 02, 2011 9:54 pm
by pHySiQuE » Wed Jan 23, 2013 10:57 pm
In the latest version, I have DG_USE_THREAD_EMULATION defined. (I am attempting to build without threads.)
I get a crash in Xcode that says "Thread 13: signal SIGABRT" on line 62 of dgMutexThread:

- Screen Shot 2013-01-23 at 6.55.48 PM.jpg (155.81 KiB) Viewed 5612 times
-
pHySiQuE
-
- Posts: 608
- Joined: Fri Sep 02, 2011 9:54 pm
by Julio Jerez » Thu Jan 24, 2013 10:04 am
if you defined DG_USE_THREAD_EMULATION you should had a compiler error, in thgsio function
- Code: Select all
void dgThreadHive::QueueJob (dgWorkerThreadTaskCallback callback, void* const context0, void* const context1)
{
if (!m_beesCount) {
callback (context0, context1, 0);
} else {
#ifdef DG_USE_THREAD_EMULATION
callback (context0, context1, 0);
#else
dgThreadJob job (context0, context1, callback);
m_jobsPool.Push(job);
if (m_jobsPool.IsFull()) {
SynchronizationBarrier ();
}
#endif
}
}
I my last check int I modified the thread code to pass two parameters, primary and secundady, this is to simply the high level interface.
only one paratemt is hard to mass stiff like call pointer and data context without having to do lot of extra dat copied.
I forget to compile the non threaded version. It is fixed now.
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
Return to General Discussion
Who is online
Users browsing this forum: No registered users and 0 guests