Plug-ins, Hosts, Apps,
Hardware, Soundware
Developers
(Brands)
Videos Groups
Whats's in?
Banks & Patches
Download & Upload
Music Search
KVR
   
KVR Forum » DSP and Plug-in Development
Thread Read
OpenMP and Apple CoreAudio compatibility
Wild Hades
KVRist
- profile
- pm
PostPosted: Mon Aug 20, 2012 11:53 pm reply with quote
Hello guys,

I've started to use OpenMP under Windows a few weeks ago and I've got it to work without much troubles.
I'm using it just to parallelize the stereo processing of my plug-ins, so that the main thread processes the left channel and a child thread processes the right one.
The code itself is nothing fancy, I'm simply using parallel sections around my processing loops.

As I've said, everything is running fine under Windows, but as soon as I've ported my code to OSX, I've been experiencing crashes whenever I've tried to run the parallelized sections.

I've been doing some research and found this:
http://osdir.com/ml/coreaudio-api/2009-05/msg00018.html

which is exactly the same issue I'm facing, according to the debugger (EXC_BAD_ACCESS on gomp_resolve_num_threads).
Reading that newsletter, it seems that there may be compatibility issues between OpenMP and CoreAudio threads (which run in time constraint thread context).

Has anybody been able to use OpenMP with CoreAudio? Or can anybody confirm that it is just not possible to use them together?

I'm using OSX 10.6 with XCode 3.2 (GCC 4.2)

Thanks in advance
^ Joined: 06 Sep 2007  Member: #159297  
stratum
KVRist
- profile
- pm
PostPosted: Tue Aug 21, 2012 2:27 am reply with quote
I think you are using the wrong approach to improve performance of your plugins. I would avoid that kind of parallelization at all costs and prefer to use vectorized processing (http://en.wikipedia.org/wiki/Streaming_SIMD_Extensions  ) instead. If you have already done that, the next step is not using a different thread for each channel. Managing different audio threads is the hosts responsibility and I'd prefer not to do anything that could interfere with it.
----
~stratum~
^ Joined: 29 May 2012  Member: #281392  
Wild Hades
KVRist
- profile
- pm
PostPosted: Tue Aug 21, 2012 3:16 am reply with quote
I get your point, but vectorized processing is not an option in my case, as it would require a complete rewrite of the DSP code and it may not even provide that much performance increase depending on the algorithms (even with 16byte aligned data, I've experienced performance decreases a lot of times because of the slow SSE registry data storing and loading).
I know that is better to let the host manage audio threads, but plug-ins are basically black boxes, so there is no way for the host to parallelize stereo processing inside of them.
It may interfere with other plug-ins processing, as you say, in fact my idea was to test the performance and potential issues and decide if it's worth it or not.

Just to clarify, my question is related to the OpenMP/CoreAudio compatibility, I'm not asking for the best solution to parallelize my code.

Thanks for your suggestions, anyway
^ Joined: 06 Sep 2007  Member: #159297  
stratum
KVRist
- profile
- pm
PostPosted: Tue Aug 21, 2012 9:32 am reply with quote
Wild Hades wrote:


Just to clarify, my question is related to the OpenMP/CoreAudio compatibility, I'm not asking for the best solution to parallelize my code.

Thanks for your suggestions, anyway


I dont think that the problem is that OpenMP and CoreAudio is incompatible, but just that the basic approach is flawed and it will not always work. If you have tested it on windows with a particular host and it has worked without a problem, that's fine (with that host), but it may fail similarly with another host on windows.
----
~stratum~
^ Joined: 29 May 2012  Member: #281392  
Wild Hades
KVRist
- profile
- pm
PostPosted: Tue Aug 21, 2012 1:20 pm reply with quote
In case someone is facing the same issue, I've got it to work by compiling the plug-in with GCC 4.7 from MacPorts.

Cheers
^ Joined: 06 Sep 2007  Member: #159297  
cheppner
KVRist
- profile
- pm
PostPosted: Fri Aug 31, 2012 8:37 am reply with quote
Wild Hades wrote:
In case someone is facing the same issue, I've got it to work by compiling the plug-in with GCC 4.7 from MacPorts.

Cheers

Hello,

I've tried to use OpenMP with CoreAudio and the main problem was that it did something that disturbed the Realtime-Thread the host was offering me.

We then decided to use boost::thread instead which works almost perfectly Smile

Also I want to say that it is indeed better to use SIMD processing - when you can. But when the cpu is at max for a single plugin, it helps to give the users an option for multi threading!

Cheers,
- Clemens
^ Joined: 20 Aug 2010  Member: #237880  
otristan
KVRian
- profile
- pm
- www
PostPosted: Wed Sep 05, 2012 7:05 am reply with quote
Did it worked fine with low latency callbacks like with a buffer size of 128 ?

Thx
----
Olivier Tristan
Developer - UVI Team
http://www.uvi.net
http://blog.uvi.net
^ Joined: 28 Mar 2005  Member: #63153  
cheppner
KVRist
- profile
- pm
PostPosted: Mon Sep 17, 2012 2:23 am reply with quote
otristan wrote:
Did it worked fine with low latency callbacks like with a buffer size of 128 ?

Thx

Sorry for the late reply, I just came back from vacation...

Yes I think it did but it was sort-of cpu dependent! Old cpus (before i5/i7 2nd gen or older amd) showed some limitations but that might have been due to the lack of an on-cpu memory controller.

Also, on windows, it only worked when keeping the threads alive all the time - stopping and opening new ones hurt the performance significantly. That said, it's smarter this way anyways Wink

Cheers,
- Clemens
^ Joined: 20 Aug 2010  Member: #237880  
otristan
KVRian
- profile
- pm
- www
PostPosted: Mon Sep 17, 2012 4:36 am reply with quote
It make sense to use a pool of thread indeed.

Good to know that it works ok on modern CPU though.
----
Olivier Tristan
Developer - UVI Team
http://www.uvi.net
http://blog.uvi.net
^ Joined: 28 Mar 2005  Member: #63153  
All times are GMT - 8 Hours

Printable version
Page 1 of 1
Display posts from previous:   
ReplyNew TopicPrevious TopicNext Topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Username: Password:  
KVR Developer Challenge 2012