Effectors not thread-safe?



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 04/12/2012 at 07:40, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   12-14 
    Platform:   Windows  ;   
    Language(s) :

    ---------
    Hi,

    I am sampling effectors from within a Multiprocessor thread and it seems the message call is not thread safe? It returns scrambled data. When calling it from a single thread it works just fine.

    Is there a valid workaround (excluding locking) to make it work in a MP context? (I don't want to precompute single-threaded if avoidable)



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 09/12/2012 at 12:54, xxxxxxxx wrote:

    Any info on this or maybe a confirm on this issue?

    Thanks in advance!



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 11/12/2012 at 00:23, xxxxxxxx wrote:

    Hi,

    Sorry for the delay. Here's the information I got from the development team:

    Messages aren't necessarily thread synchronous in CINEMA (depending on how they're called).
    In general it should be fine, however we must lock the MoData AutoLocks before use in an MP environment.

    It's also important to understand that the CINEMA object system is not a threadsafe environment, the viewport, interface and render engine run in separate threads.
    Multithreading in this environment therefore must be aware of this and work accordingly.
    If you're trying to execute the effectors from a thread outside of the standard object scheduler then you may well run into problems and conflicts as a result.

    The effectors can store local data that has no threadlocks as they don't expect to be accessed and executed simultaneously (normally they're only accessed from the main scheduler), 
    and which may cause problems, especially with things like the delay effector.



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 11/12/2012 at 06:35, xxxxxxxx wrote:

    Hi,

    thanks first of all! Okay, so the conclusion is not to expect them to be safe especially in the case of unlocked MoData passed along and in a threaded context. Clear.

    However, I am using the MSG_SAMPLE_EFFECTOR_VALUE call for sampling the strength of the effector, it does not contain any MoData. I would expect such an arbitrary single point value sampling function to be MP safe (as for example a point illumination sampling in VolumeData is because it aims at arbitrary input). Is my assumption wrong?

    What I mean is that I wouldn't expect for example a noise effector to raise any issues. I understand there may be internal local data that may screw up in an threaded context especially when there is a temporal dependancy as can be expected in a delay effector, but a noise effector point sampling I would expect not to run into such trouble, even in an MP context. No offense, just listing my thoughts.

    I am sampling from my own MP thread running in a scenehook execute (which I am aware is called in a threaded context according to the docs). I also tried copying the effector to sample that one but the copy just does nothing if not in the scene it appears (is that right or do I have to do anything else once I copied an effector that is in the document node's list? kind of reinitialising it or so?)

    Thanks again! Very appreciated


Log in to reply