Re: OpenMP troubles
Re: OpenMP troubles
- Subject: Re: OpenMP troubles
- From: Steve Christensen <email@hidden>
- Date: Tue, 31 May 2011 11:46:30 -0700
In the cases you mentioned, your code is running on the main thread for the dialog case; and likely either the main- or a single background thread in a standalone app. Motion and FCP tend to run the -renderFrame::: methods on multiple background threads, as needed, so you could simply be running into a thread-safety issue where you have multiple concurrent threads, each calling omp_get_max_threads(). (It may appear that this should be a non-issue since it's a "get" function, the implementation may be writing state to a global/shared variable, so concurrent calls could bite you.)
As Darrin mentioned, it sounds like it'd be safer to call omp_get_max_threads() from your plugin's -initWithAPIManager: method. And if omp_get_max_threads() is a constant value, you could just initialize it once for all instances of your plugin. If you do actually need to call it in your render method, you may need to protect it with a lock so that only once instance at a time is touching it.
On May 31, 2011, at 9:39 AM, Darrin Cardani wrote:
> Matt,
>
> I'm sorry to say that I know nothing about OpenMP, so I have no idea what to suggest. I'm trying to think of safe ways you could call it on the main thread. Generally, you don't want to call [-NSObject performSelectorOnMainThread:withObject:waitUntilDone:] during a render, as you'll likely end up in a dead-lock (at least if you do waitUntilDone). When are you trying to call this? Could it be done in your -initWithAPIManager: method and cached? I'm not positive, but I think -initWithAPIManager: happens on the main thread because it's always invoked as a result of a UI action.
>
> Darrin
>
> On May 27, 2011, at 6:25 PM, Matt Rhodes wrote:
>
>> Note: This seems to be a known bug.
>> http://gcc.gnu.org/ml/gcc-bugs/2008-05/msg01145.html
>>
>> Is there a workaround?
>>
>> Thanks.
>>
>> m
>>
>> On May 27, 2011, at 6:16 PM, Matt Rhodes wrote:
>>
>>> Hey Team.
>>>
>>> Has anyone had trouble using OpenMP in an FxPlug?
>>>
>>> I have it running fine in standalone apps (Carbon and Cocoa).
>>> I also have it running in other hosts (like After Effects).
>>>
>>> But the same code is "crashing" when executed in Motion.
>>> It's failing on my first call to anything OpenMP-related,
>>> in this case:
>>> maxThreads = omp_get_max_threads() ;
>>>
>>> I'm not in an OpenMP loop, so this should execute simply.
>>>
>>> I've found that I can use OpenMP inside our modal dialog box,
>>> just not when rendering to the Motion interface (that is, during
>>> a -renderFrame call).
>>>
>>> Any help is appreciated. We'd rather not disable this rendering speed-up.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Pro-apps-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden