Closed camots closed 5 years ago
Thanks for the feedback. We are looking into this ... should be fixed with the next release.
This should be fixed ... please let us know.
I tried the updated version, however, it crashes at the exact same location with the same error message:
Thread 1: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
Best regards
Could we get repro steps? Does it happen when initializing the app ? Is there a log file and call stack you could share? We can't seem to replicate this locally at the moment.
Thanks
Yes, it happens in the initialisation phase. The debugger stops at void AsteroidSimulation::Init(uint32_t rngSeed, uint32_t numAsteroids, uint32_t numMeshes, uint32_t vertexCountPerMesh, uint32_t textureCount)
All variables have unreasonable values. For example numAsteorids is 352400800 I can provide any information from the debugger.
Process: 04_ExecuteIndirect [23375] Path: /Users/USER/*/04_ExecuteIndirect.app/Contents/MacOS/04_ExecuteIndirect Identifier: com.confetti.Unit-Tests.04-ExecuteIndirect Version: 1.0 (1) Code Type: X86-64 (Native) Parent Process: ??? [1] Responsible: 04_ExecuteIndirect [23375] User ID: 502
Date/Time: 2019-04-26 07:47:45.019 +0200 OS Version: Mac OS X 10.14.4 (18E226) Report Version: 12 Anonymous UUID: 3B326211-30C1-D2E9-3F56-EBEC2032BD7E
Sleep/Wake UUID: AAF8C109-D623-4107-9A2C-D85C0DD4B015
Time Awake Since Boot: 280000 seconds Time Since Wake: 540 seconds
System Integrity Protection: enabled
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Exception Type: EXC_BAD_INSTRUCTION (SIGILL) Exception Codes: 0x0000000000000001, 0x0000000000000000 Exception Note: EXC_CORPSE_NOTIFY
Termination Signal: Illegal instruction: 4 Termination Reason: Namespace SIGNAL, Code 0x4 Terminating Process: exc handler [23375]
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread 0 com.confetti.Unit-Tests.04-ExecuteIndirect 0x0000000103327c4b AsteroidSimulation::Init(unsigned int, unsigned int, unsigned int, unsigned int, unsigned int) + 11 (AsteroidSim.cpp:91) 1 com.confetti.Unit-Tests.04-ExecuteIndirect 0x0000000103315768 ExecuteIndirect::Init() + 3688 (04_ExecuteIndirect.cpp:442) 2 com.confetti.Unit-Tests.04-ExecuteIndirect 0x000000010341ea3d -[MetalKitApplication initWithMetalDevice:renderDestinationProvider:view:] + 1501 (macOSBase.mm:412) 3 com.confetti.Unit-Tests.04-ExecuteIndirect 0x000000010341dcd6 -[GameViewController viewDidLoad] + 1526 4 com.apple.AppKit 0x00007fff335893e7 -[NSViewController _sendViewDidLoad] + 94 5 com.apple.AppKit 0x00007fff33586923 _noteLoadCompletionForObject + 646 6 com.apple.AppKit 0x00007fff333fc6e8 -[NSIBObjectData nibInstantiateWithOwner:options:topLevelObjects:] + 2045 7 com.apple.AppKit 0x00007fff333fa388 loadNib + 401 8 com.apple.AppKit 0x00007fff333f9868 +[NSBundle(NSNibLoading) _loadNibFile:nameTable:options:withZone:ownerBundle:] + 696 9 com.apple.AppKit 0x00007fff333f94ad -[NSBundle(NSNibLoading) loadNibNamed:owner:topLevelObjects:] + 204 10 com.apple.AppKit 0x00007fff333f926f +[NSBundle(NSNibLoading) loadNibNamed:owner:] + 446 11 com.apple.AppKit 0x00007fff333ed2dd NSApplicationMain + 502 12 com.confetti.Unit-Tests.04-ExecuteIndirect 0x000000010341d6da macOSMain(int, char const*, IApp) + 42 (macOSBase.mm:227) 13 com.confetti.Unit-Tests.04-ExecuteIndirect 0x0000000103313f67 main + 71 (04_ExecuteIndirect.cpp:1762) 14 libdyld.dylib 0x00007fff6229f3d5 start + 1
Thread 1: 0 libsystem_pthread.dylib 0x00007fff6248c3f0 start_wqthread + 0
Thread 2: 0 libsystem_pthread.dylib 0x00007fff6248c3f0 start_wqthread + 0
Thread 3: 0 libsystem_pthread.dylib 0x00007fff6248c3f0 start_wqthread + 0
Thread 4: 0 libsystem_pthread.dylib 0x00007fff6248c3f0 start_wqthread + 0
Thread 5: 0 libsystem_pthread.dylib 0x00007fff6248c3f0 start_wqthread + 0
Thread 6:: CVDisplayLink 0 libsystem_kernel.dylib 0x00007fff623d786a __psynch_cvwait + 10 1 libsystem_pthread.dylib 0x00007fff624905a1 _pthread_cond_wait + 773 2 com.apple.CoreVideo 0x00007fff37b13a4b CVDisplayLink::waitUntil(unsigned long long) + 229 3 com.apple.CoreVideo 0x00007fff37b12ffa CVDisplayLink::runIOThread() + 482 4 libsystem_pthread.dylib 0x00007fff6248d2eb _pthread_body + 126 5 libsystem_pthread.dylib 0x00007fff62490249 _pthread_start + 66 6 libsystem_pthread.dylib 0x00007fff6248c40d thread_start + 13
Thread 7: 0 com.confetti.Unit-Tests.04-ExecuteIndirect 0x00000001034b1a86 DYLD-STUB$$tinystl::vector<UpdateRequest, tinystl::allocator>::empty() const + 0 1 com.confetti.Unit-Tests.04-ExecuteIndirect 0x0000000103371e15 streamerThreadFunc(void) + 517 (ResourceLoader.cpp:664) 2 com.confetti.Unit-Tests.04-ExecuteIndirect 0x0000000103423420 ThreadFunctionStatic(void) + 48 (macOSThreadManager.cpp:51) 3 libsystem_pthread.dylib 0x00007fff6248d2eb _pthread_body + 126 4 libsystem_pthread.dylib 0x00007fff62490249 _pthread_start + 66 5 libsystem_pthread.dylib 0x00007fff6248c40d thread_start + 13
Thread 8: 0 libsystem_kernel.dylib 0x00007fff623d786a __psynch_cvwait + 10 1 libsystem_pthread.dylib 0x00007fff6249056e _pthread_cond_wait + 722 2 com.confetti.Unit-Tests.04-ExecuteIndirect 0x00000001034235b5 ConditionVariable::Wait(Mutex const&) + 37 (macOSThreadManager.cpp:68) 3 com.confetti.Unit-Tests.04-ExecuteIndirect 0x00000001034870e0 taskThreadFunc(void) + 192 (ThreadSystem.cpp:64) 4 com.confetti.Unit-Tests.04-ExecuteIndirect 0x0000000103423420 ThreadFunctionStatic(void) + 48 (macOSThreadManager.cpp:51) 5 libsystem_pthread.dylib 0x00007fff6248d2eb _pthread_body + 126 6 libsystem_pthread.dylib 0x00007fff62490249 _pthread_start + 66 7 libsystem_pthread.dylib 0x00007fff6248c40d thread_start + 13
Thread 9: 0 libsystem_kernel.dylib 0x00007fff623d786a __psynch_cvwait + 10 1 libsystem_pthread.dylib 0x00007fff6249056e _pthread_cond_wait + 722 2 com.confetti.Unit-Tests.04-ExecuteIndirect 0x00000001034235b5 ConditionVariable::Wait(Mutex const&) + 37 (macOSThreadManager.cpp:68) 3 com.confetti.Unit-Tests.04-ExecuteIndirect 0x00000001034870e0 taskThreadFunc(void) + 192 (ThreadSystem.cpp:64) 4 com.confetti.Unit-Tests.04-ExecuteIndirect 0x0000000103423420 ThreadFunctionStatic(void) + 48 (macOSThreadManager.cpp:51) 5 libsystem_pthread.dylib 0x00007fff6248d2eb _pthread_body + 126 6 libsystem_pthread.dylib 0x00007fff62490249 _pthread_start + 66 7 libsystem_pthread.dylib 0x00007fff6248c40d thread_start + 13
Thread 10: 0 libsystem_kernel.dylib 0x00007fff623d786a __psynch_cvwait + 10 1 libsystem_pthread.dylib 0x00007fff6249056e _pthread_cond_wait + 722 2 com.confetti.Unit-Tests.04-ExecuteIndirect 0x00000001034235b5 ConditionVariable::Wait(Mutex const&) + 37 (macOSThreadManager.cpp:68) 3 com.confetti.Unit-Tests.04-ExecuteIndirect 0x00000001034870e0 taskThreadFunc(void) + 192 (ThreadSystem.cpp:64) 4 com.confetti.Unit-Tests.04-ExecuteIndirect 0x0000000103423420 ThreadFunctionStatic(void) + 48 (macOSThreadManager.cpp:51) 5 libsystem_pthread.dylib 0x00007fff6248d2eb _pthread_body + 126 6 libsystem_pthread.dylib 0x00007fff62490249 _pthread_start + 66 7 libsystem_pthread.dylib 0x00007fff6248c40d thread_start + 13
Thread 11: 0 libsystem_kernel.dylib 0x00007fff623d786a __psynch_cvwait + 10 1 libsystem_pthread.dylib 0x00007fff6249056e _pthread_cond_wait + 722 2 com.confetti.Unit-Tests.04-ExecuteIndirect 0x00000001034235b5 ConditionVariable::Wait(Mutex const&) + 37 (macOSThreadManager.cpp:68) 3 com.confetti.Unit-Tests.04-ExecuteIndirect 0x00000001034870e0 taskThreadFunc(void) + 192 (ThreadSystem.cpp:64) 4 com.confetti.Unit-Tests.04-ExecuteIndirect 0x0000000103423420 ThreadFunctionStatic(void) + 48 (macOSThreadManager.cpp:51) 5 libsystem_pthread.dylib 0x00007fff6248d2eb _pthread_body + 126 6 libsystem_pthread.dylib 0x00007fff62490249 _pthread_start + 66 7 libsystem_pthread.dylib 0x00007fff6248c40d thread_start + 13
Thread 0 crashed with X86 Thread State (64-bit): rax: 0x0000000000000000 rbx: 0x00006000037c5700 rcx: 0x00000000000003e8 rdx: 0x000000000000c350 rdi: 0x00000001034e67f8 rsi: 0x000000000000007b rbp: 0x00007ffeec8eb380 rsp: 0x00007ffeec8eafd0 r8: 0x000000000000035a r9: 0x000000000000000a r10: 0x00007fff9502360c r11: 0x0000000000000246 r12: 0x00007f8df1603890 r13: 0x00007f8df1609cb0 r14: 0x0000000000000058 r15: 0x00007f8df1603890 rip: 0x0000000103327c4b rfl: 0x0000000000010202 cr2: 0x000000011323c000
Logical CPU: 2 Error Code: 0x00000000 Trap Number: 6
Binary Images:
0x103312000 - 0x1034d7fff +com.confetti.Unit-Tests.04-ExecuteIndirect (1.0 - 1) <4566F433-C925-3354-B1B9-12E4CA1D3527> /Users/USER/*/04_ExecuteIndirect.app/Contents/MacOS/04_ExecuteIndirect
0x1058b8000 - 0x1058bb047 libobjc-trampolines.dylib (756.2) <74D736F6-9BA0-3DFA-A02D-4076B1CE5ABA> /usr/lib/libobjc-trampolines.dylib
0x1066ce000 - 0x1067386ef dyld (655.1.1)
External Modification Summary: Calls made by other processes targeting this process: task_for_pid: 1 thread_create: 0 thread_set_state: 0 Calls made by this process: task_for_pid: 0 thread_create: 0 thread_set_state: 0 Calls made by all processes on this machine: task_for_pid: 973733 thread_create: 0 thread_set_state: 3904
VM Region Summary: ReadOnly portion of Libraries: Total=374.9M resident=0K(0%) swapped_out_or_unallocated=374.9M(100%) Writable regions: Total=738.9M written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=738.9M(100%)
VIRTUAL REGION
REGION TYPE SIZE COUNT (non-coalesced) =========== ======= ======= Activity Tracing 256K 1 CoreAnimation 4K 1 CoreServices 6656K 2 CoreUI image file 388K 4 Foundation 4K 1 IOKit 7940K 1 Kernel Alloc Once 8K 1 MALLOC 329.6M 29 MALLOC guard page 32K 8 MALLOC_LARGE (reserved) 4384K 1 reserved VM address space (unallocated) MALLOC_NANO (reserved) 384.0M 1 reserved VM address space (unallocated) STACK GUARD 56.0M 12 Stack 13.6M 12 VM_ALLOCATE 48K 3 DATA 23.6M 227 FONT_DATA 4K 1 LINKEDIT 223.3M 4 TEXT 151.6M 230 __UNICODE 564K 1 mapped file 41.8M 13 shared memory 744K 10 =========== ======= ======= TOTAL 1.2G 563 TOTAL, minus reserved VM space 855.8M 563
Thank you very much for your help
Best regards
Great, we'll look at this. Is there also a log file next to the built application ?
Yes there is. It's content is The-Forge/Examples_3/Unit_Tests/macOS Xcode/Bin/Debug/04_ExecuteIndirect.log.
It's content is:
[ Fri Apr 26 07:50:54 2019 ] INFO: Opened log file /Volumes/home/*/work/The-Forge/Examples_3/Unit_Tests/macOS Xcode/Bin/Debug/04_ExecuteIndirect.log [ Fri Apr 26 07:50:54 2019 ] INFO: [initRenderer] Current Gpu Name: AMD Radeon RX Vega 56 [ Fri Apr 26 07:50:54 2019 ] INFO: [initRenderer] Current Gpu Vendor ID: 0x1002 [ Fri Apr 26 07:50:54 2019 ] INFO: [initRenderer] Current Gpu Model ID: 0x687f
macOS Requirements: macOS Mojave 10.14.4 beta (18E174f)
Xcode 10.2 beta (10P82s)
The Forge is currently tested on the following macOS devices:
We would send this bug to apple for their driver development team ... please note we do not test on Mac Pro ... at the moment we do not have a Mac Pro in the office.
Hi,
I did some debugging an found out that the problem is due to missing fnma support of my processor intel xeon x5650.
What I did: I've written a simple main program like this:
int main(void) { const uint32_t gNumAsteroids = 50000U; // 50000 is optimal. const uint32_t gTextureCount = 10; const uint32_t gImageCount = 3; uint32_t numVerticesPerMesh = 858;
AsteroidSimulation gAsteroidSim; gAsteroidSim.numLODs = 3; gAsteroidSim.Init(123, gNumAsteroids, 1000, numVerticesPerMesh, gTextureCount); return 0; }
I reduced the AsteroidSimulation::Init method to simply 2 statements:
void AsteroidSimulation::Init(uint32_t rngSeed, uint32_t numAsteroids, uint32_t numMeshes, uint32_t vertexCountPerMesh, uint32_t textureCount) { std::cout << numAsteroids << "\n"; float xxx = 1.0; }
Now if compile this code by
g++ -I. -g -std=c++11 main.cpp AsteroidSim.cpp
I get:
AsteroidSim.cpp:238:5: error: always_inline function '_mm_fmadd_ps' requires target feature 'fma', but would be inlined into function 'update' that is compiled without support for 'fma'
Then I compile with -mfma: g++ -I. -g -std=c++11 -mfma main.cpp AsteroidSim.cpp
Compilation is successful, but the program crashes in AsteroidSimulation::Init with EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
It means my processor has no fnma support. I can check with sysctl -n hw.optional.fma
The result is 0, indicating missing fnma support.
My question: Is fnma support absolutely necessary or are there any compiler-flags or defines which allow execution on non fnma supported CPUs?
Best regards
Problem solved!
I was playing a little bit more with the code and was able to compile and run 04_ExecuteInDirect on my MacPro 5.1
First: In AsteoridSim.cpp, line 176 I added a defined(NO_FMA): ...
// XBoxOne/iOS don't support some of these SSE instructions. // 0xC000001D: Illegal Instruction // Implement it without SSE
dynamicAsteroid.transform = orbit dynamicAsteroid.transform rotate;
...
Second: For AsteoridSim.cpp I removed the compilation flags -mavx2 -mfma and replaced it with -DNO_FMA
That's all! Now 04_ExecuteInDirect is nicely on my MacPro 5.1 using the graphics power of my AMD Vega RX 56
Can you add something like like this (NO_FMA) to support CPU's without vx2 or fma support?
Best regards
Another (better) solution:
The problem on my machine (MacPro 5.1, 12 core, Westmere) was caused by the _mm_fmadd_ps instructions which are only available if your CPU supports fma instructions. Unfortunately these are not available on Westmere processors of the MacPro 5.1. However you can replace _mm_fmadd_ps(a, b, c) by _mm_add_ps(_mm_mul_ps(a, b), c). It will probably not make a big difference in terms of performance.
The code below shows the modification in AsteoridSim.cpp:
In line 220, instead of intermediateSSE[i] =_mm_fmadd_ps(orbitSSE[0], vx, _mm_fmadd_ps(orbitSSE[1], vy, _mm_fmadd_ps(orbitSSE[2], vz, _mm_mul_ps(orbitSSE[3], vw))));
you can replace the _mm_fmad_ps(.. by _mm_add_ps(_mm_mul_ps.. The modified statement looks like this:
intermediateSSE[i] = _mm_add_ps(_mm_mul_ps(orbitSSE[0], vx), _mm_add_ps(_mm_mul_ps(orbitSSE[1], vy), _mm_add_ps(_mm_mul_ps(orbitSSE[2], vz), _mm_mul_ps(orbitSSE[3], vw))));
and analogeously a few lines below:
transformSSE[i] = _mm_add_ps(_mm_mul_ps(intermediateSSE[0], vx), _mm_add_ps(_mm_mul_ps(intermediateSSE[1], vy), _mm_add_ps(_mm_mul_ps(intermediateSSE[2], vz), _mm_mul_ps(intermediateSSE[3], vw))));
Then you have to remove the -mfma -mavx2 compilation flags for AsteoridSim.cpp
Best regards
That is super awesome! Thanks for providing this fix. We will add it.
Should be resolved. Let us know!
I've tested the Unit Tests on my Mac Pro 2010 / Vega 56 running MacOS Mojave 10.14.4. Xcode: Version 10.2.1 (10E1001) The examples are running fine except the 04_ExecuteIndirect.
It crashes directly at the beginning of void AsteroidSimulation::Init(uint32_t rngSeed, uint32_t numAsteroids, uint32_t numMeshes, uint32_t vertexCountPerMesh, uint32_t textureCount)
The error reported by the debugger is: Thread 1: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
Can anybody help?
Regards