06-08-2010 08:49 AM
Hi,
I want that three different DLLs run in the same thread but this thread must not be the "UI Thread". I there a way to force them to do so?
Best regards
Solved! Go to Solution.
06-08-2010 09:20 AM
You don't explain why you want this, but I believe you should be able to accomplish this by setting the execution system of the VIs calling those DLLs to something other than UI or Standard. The help says that setting the CLFN to run in any thread will inherit the setting from the VI.
Note that if you have UI code (property nodes, etc.) the VI will execute at least that part in the UI thread.
06-08-2010 09:50 AM
Thank you for your answer.
I have a few DLLs that include Cuda code, because of this every "cuda dll" has to run on the same thread, else the won#t communicate properly whith each other.
I've now tried to set the properties of the sub vis that include my dlls to "other1" (Preferred Execution System) and set the dlls to "run in any thread" but that does not work how it seems. At the moment it's still only working if I set the dlls to "UI Thread" -what I don't want.
06-08-2010 11:02 AM
06-08-2010 12:29 PM
Using this library is no choice for me for a few reasons. I use a 64 bit system and thgis library only supports 32 bit systems, beside this the compute context they use there is way to complex for the things that I want to do and the disadvantage at this complexity is, that it's really hard to find out what exactly they do and you only hardly can find out of whose type their data structures there are.
I know that the key doing this must be the cuda context functions but I hoped to prevent the use of them by finding an other way because there are many open questions about how to use these things correctly and they are not documented very well how it seems.
06-08-2010 12:55 PM
Do the DLL calls really have to execute in the same thread? Or is it just required that they not execute at the same time? In the latter case, you could consider using a semaphore to protect your DLL calls, or perhaps putting all the DLL calls into a single subVI with a case structure to decide which call to make. This second option might become more complicated if all the calls have different sets of inputs or outputs.
Using another Execution System other than the UI Thread won't work, because those Execution Systems each get 4-8 threads to run with.
06-08-2010 01:28 PM
Jarrod S. wrote:Do the DLL calls really have to execute in the same thread? Or is it just required that they not execute at the same time? In the latter case, you could consider using a semaphore to protect your DLL calls, or perhaps putting all the DLL calls into a single subVI with a case structure to decide which call to make. This second option might become more complicated if all the calls have different sets of inputs or outputs.
Using another Execution System other than the UI Thread won't work, because those Execution Systems each get 4-8 threads to run with.
Ho about...
Putting all of the calls into an Action Engine configured to run in "other1" (for example) and then use "threadconfig" to configure that for only one thread.
Write a wrapper for each call to the AE and ....
Done?
Ben
06-08-2010 01:34 PM
No, they are still aren't called at the same time, they really must be called from the same thread or the cuda compute context from the first dll that created it must be given to the new thread of the other dll.
If there is really no other way to get sure that all dlls will be executed by the same thread expect the UI thread t must be done by this way how it seems.
Perhaps somebody can then help me answering the question how I can transfer a context that has the type cuContext (can be a structure or something like that but there's no documentation of it to find) from one (the dll that creates this context) to another.
At the moment I cast it to an uint32_t pointer and give this to the next dll where I cast it back to the cuContext type -that's not very elegant in my opinion and I don't know if this could be the reason for errors.
06-08-2010 01:36 PM
Steimers wrote:No, they are still aren't called at the same time, they really must be called from the same thread or the cuda compute context from the first dll that created it must be given to the new thread of the other dll.
If there is really no other way ...
Did you try what i suggested?
Ben
06-08-2010 01:42 PM - edited 06-08-2010 01:43 PM
Oh I just was writing my answer as yours arrived so I just read it.
The action engine sounds interesting but I've never heard of it before so I will read the whole article at first and try it tomorrow. Perhaps I need to ask one or two things about it before, I will ask if it's so.