Setting up use of a DLL for Multithreading operations.

Hi all,
I have been working the past few weeks converting a slow part of our labview code into C++ and hoping that from there I can use CUDA to further optimize and speed up the process.
I just finished writing everything in C++, and the program works well, but it is already much slower than the old code. This is due to the fact that the old code could multithreading and use up the entire processing power of my processor, while my current code does not seem to want to do this.
I know that there are many settings from labview to visual studios to even my code itself to allow for mutlithreaded operations, and allow them to happen safely.
I was wondering if anyone could help me identify these settings so I can move forward with my optimization.
I will tell you what I have looked at and done so far:
First I made sure that my program takes all the Array Handles and Numeric values, and assigns them to local variables in my program. I believe this makes my program reentrant safe.
Then in VC++ 2008, I added some settings to my project settings: Under C++ Optimization, I have Maximize Speed(/O2), enabled intrinsic functions, and favored fast code.
In code generation, I have my runtime library as Multithreaded debug dll.
Then in labview, the DLL is nested 2 SubVIs deep. The main VI has no special settings that I am aware of, but the first SubVI is set to time critical priority, and reentrant execution, while the final subVI which holds my DLL is set to subroutine, and reentrant execution.
FInally my DLL has run in any thread selected, and debugging turned off.
Am I doing this correctly? Are there parts missing in my program that I need to write to allow for this sort of functionality?
Thanks!

Deturbanator wrote:
Thank you for your reply.
I assign parameters to local variables for exactly the problem you described, shared resources. For example, this program in particular works on a video file, and completes a process on a frame by frame image. I assume that if I do not copy the values to a local variable, the array handle for the image will change between different instances of the program, and this might be bad if we are at first analyzing frame 3, and then suddenly, it changes to frame 5.
Is this not something I should be concerned with, does labview take care of this already? It seems there is a lot of magic happening behind the walls and options of labview
And I agree, Labview is quite good, and I did not expect a big boost from converting my code to C++. However I see no reason it should be any slower than the existing labview code, if most of the functionality is just rewritten in C++. The real reason for the code conversion, was to eventually write certain parts in CUDA, which I felt would be easiest once the code is in C++.
I guess my real question is what are the "hoops and rings" i need to jump through to match the labview efficiency?
thank again!
It's still not clear to me what you expect by the use of local varaibles in terms of parallel execution. Or maybe you are not talking about function local variables but module local variables outside the function???? If that is the case, then you have probably totally misunderstood the fundamentals of multithreading safe code.
When LabVIEW calls a function through the Call Library Node, it will make sure that all the parameters passed to that function stay valid for the duration of the call. Once the function returns to the LabVIEW diagram LabVIEW considers it safe to do with the buffers as it likes, including moving them in memory, resizing them, reusing them for other stuff, or simply deallocating them. So saving such a parameter to a function local variable makes no difference, since the function local variable will exist just as long as the parameter is guranteed to be valid. And saving it to a module local variable is either creating a pretty sure race condition or even crash, if you just save the reference, since the buffer the reference is pointing to will not be guranteed to stay valid after the function returns. And if you save it to a local variable by copying its contents it will be safe, but a performance problem, as you create a copy of the data.
So what are you really doing here? Some example code could certainly help to understand what you are doing, as I have a hunch that what you call a local variable is in fact more a global variable although you may declare it as static and make it in that way local to your code module (but still global to all functions in that module).
Generally if you want your C code to process data asynchronously however (meaning working on it after the function returns control to LabVIEW, then you can't avoid to copy the buffers.
As to the hoops and rings to jump through there is no simple explanation. In fact there have been entire books written about multithreading, and more importantly correct multiprocessor programming.
Rolf Kalbermatter
CIT Engineering Netherlands
a division of Test & Measurement Solutions

Similar Messages

  • Hown can I set up using a downloaded song for my ringertone

    how can I use a downloaded song for my ringtone

    You need to get the original set of discs that came with the Macbook Pro and reinstall the system software.
    Insert the disc and hold down C while booting the machine.  Eventually you will get a menu and you want to reinstall the system software.
    The calendars were deleting because they were still attached to your husband's MobileMe/iCloud account. Reinstalling through the system software discs should not affect your husband's calendars and will allow a fresh shart for your son letting him set up his own account on the Mac.
    If you do not have the set of CDs from that Macbook Pro you can get a new set from Apple for a nominal cost. DO NOT use the CDs that came with the new Macbook Pro. They are not compatible.

  • How to set up use of relative URLs for a BSP application

    Dear all,
    I need to access a BSP application through our external portal.
    This is failing because generated URLs are absolute URLs (they mention physical server name, not known of course on the internet) where they should be relative URLs (they use external portal URL as prefix).
    How to set this up?
    I'm logged on http://myportal.com/irj/portal and want to call a BSP application. To build this page, my internet client (Internet Explorer) tries to get elements from the server. Looking at HTTP trace, I can see that my IE is trying to reach the physical server, not known on internet of course, then page loading fails.
    Ex absolute URL : http://myservername.domain.com/sap/bw/[...]/image1.gif
    This is the behavior I can see at the moment.
    Relative URL : http://myportal.com/sap/bw/[...]/image1.gif
    This is what I'd like to see.
    Many thanks in advance for your help.
    François

    Any idea ?

  • DLL for LOB operations

    Hi
    I am trying to use the createTemporary()
    method provided by the Oracle OCI Driver
    to insert a BLOB into the database.
    I have the oracle client installed in my
    PC. While executing the above said method
    an "UnsatisfiedLinkError" is reported.
    It says "lob_createTemporary" not found.
    I am of the opinion that this could be
    a .dll that gets installed with the Oracle
    client. Do we need to do any custom
    installation for installing DLLs related
    to LOBs while we install the oracle client?
    Regards
    Ramkumar

    Hi
    I am trying to use the createTemporary()
    method provided by the Oracle OCI Driver
    to insert a BLOB into the database.
    I have the oracle client installed in my
    PC. While executing the above said method
    an "UnsatisfiedLinkError" is reported.
    It says "lob_createTemporary" not found.
    I am of the opinion that this could be
    a .dll that gets installed with the Oracle
    client. Do we need to do any custom
    installation for installing DLLs related
    to LOBs while we install the oracle client?
    Regards
    Ramkumar

  • How to compile a dll for JNI in the CMD correctly

    Now I find alot of old threads on using the mno command in cygwin to created dlls to use as an interface between c and Java, however I know this command is no longer available in cygwin and so I took the advid of downloading minGW and using this in the CMD instead.
    However every example I try to compile and run this way throws the unsatified link error when the native function is to be called by the Java program. I believe it must be a compiling error creating a mismatch between the native function and the function to be called.
    Here is the method I'm using to comile dlls for JNI, it is from the FAQ section of the minGw website:
    gcc -Wall -D_JNI_IMPLEMENTATION_ -Wl,--kill-at
    -Ic:/j2sdk1.4.1_02/include -Ic:/j2sdk1.4.1_02/include/win32
    -shared someJavaImp.c -o JavaImp.dll
    Is this how dll should be compiled? If not any suggestions?

    sudsey wrote:
    I know how to program well in C and Java, I just need to know the proper way to compile a dll for JNI.1. Get the MS IDE
    2. Create a dll project - it must NOT be a managed dll
    3. All done.

  • Profile Option: HZ: Display Accounts for All Operating Units

    I just noticed this profile option, but cannot find any documentation stating what it does. Does anyone know? Offhand, it sounds like the customer account is now org-striped, in addition to the sites, but I don't see any other evidence of this.
    Thanks.

    Have you looked at note 369821.1.?
    It says,
    If you want to review all of the Quotes for all organizations then you need to set the profile "HZ: Display Accounts for All Operating Units" to "Yes" at the site level. After that you will be able to see all the transactions in OCO for all organizations. Sandeep Gandhi

  • HT204053 The entire family has used one itunes account for years. How do we all set up separate iCloud accounts now?

    The entire family has used one itunes account for years. How do we all set up separate iCloud accounts now? Or should we? 5 macbooks, 2 ipads, 4 iphones, 2 itouch, 2 imacs.   How does one decide what to sync, share and what not to? Green Jeans.

    You need to start by understanding the distinction between iTunes and iCloud - Apple confuse the issue by referring to 'iTunes Match' as part of iCloud. It isn't.
    You don't have to have the same login (Apple ID) for iTunes and iCloud; many people don't and there's no problem about it.
    Your iCloud ID gets you email, calendars, contacts, iWork documents and PhotoStream syncing between devices.
    Your iTunes ID gets you the iTunes Store, the App Store for iOS, the Mac App Store for OSX,, 'iTunes in the Cloud' (downloading of purchased items to any logged-in device) and 'iTunes Match' (uploading of songs not purchased in the iTunes Store).
    Your family members can easily each get their own iCloud account to keep email etc. separate - in each case they will need a different non-Apple email address (a free one from Yahoo etc. would do) to set up the ID. If they are sharing a Mac they need to be using a separate user account.
    They can have their own iCloud accounts and still all sign into the same iTunes account: or they can open their own iTunes accounts using their new iCloud Apple IDs.
    BUT they cannot transfer items purchased under the present iTunes ID to different iTunes IDs.

  • HT204053 What's the best way to set up a family of devices in order to use one apple id for purchases on itunes and the app store?

    we are trying to face time between devices, but it won't work whn multiple devices are tied to one apple id.
    How do you designate one id to pay for purchases and one so that we can facetime from device to device?

    The ID used for purchasing is in Settings>Store.  This ID does not need to be the same one used for other services such as FaceTime, iMessage, etc. (in fact you're far better off if you use separate Apple IDs for these other services).  To change the ID used for iMessage, go to Settings>Messages>Receive At, tap the ID at the top, sign out, then sign back in using a separate (and unique) ID.  You can similarly change the ID used for FaceTime in Settings>FaceTime.  To sycn data with iCloud such as calendars, contacts, etc., without merging your data across devices, set up different iCloud account with different Apple IDs for each device.  You can go to Settings>iCloud and turn off syncing for your data, and when prompted, choose to keep the data on the device.  Then scroll to the bottom and tap Delete Account.  Then set up a new iCloud account using a different Apple ID for each device and turn data syncing back on in Settings>iCloud.
    This article may be of interest: http://www.macstories.net/stories/ios-5-icloud-tips-sharing-an-apple-id-with-you r-family/.

  • How to set up local server to use a remote server for login authentication?

    Thank you in advance for any help you can offer.
    We are trying to set up a "sub-network" (dont' know if this is the right terminology) using a 10.4 Server OS, to manage a set of clients... the trick is that the client login/home directory information is on a different remote server, and shall remain there, for the most part.
    To make it easy to understand here's the environment:
    *Local Server:* 10.4 G4 Server Quicksilver 1G dual--we have total control of this one
    *Main/remote server:* 10.5 Xserve.. don't know which vintage--we have very very very little input on this machine.. effectively at the mercy of the sysadmin of this system who is very conservative in changing anything (hence the need for a separate server to install applications and client machine-specific profiles, etc since the Xserve admin refuses do it). This serves MacBooks/MacBookPros and few iMacs. (no Windows PC.. as that group of comptuers have their own server)
    client: ~20 eMacs/iBooks all running 10.4.
    use environment: elementary school-->very low network demand (no e-mail, just running local apps linking to server(s) for licensing and login, and some file saving small files on remote server, user preferences, etc).
    The remote server (the Xserve) has all the login authentication, as well as the home directories. every school year, the directories get updated as new students enroll and old students graduate. Currently all the clients are directly linked to the Xserve via LDAP while we bring the local server on-line.
    the local sever (our G4 Quicksilver) will have few network applications that will support the client machines. We also will be setting up computer accounts and groups for our clients so that we can properly set their environments (the Xserve admin will not do this on the Xserve, so currently all the clients are connecting to the server as a "guest computer" from what little I understand watching what was done)
    now, what is the best way to approach this type of set up with minimal "inconvenience" of the Xserve admin?
    I am pretty experienced with standalone UNIX and macOS X administration, but a novice to this whole Server and network setup thing. Any suggestions, instructions, pointers to URLs with how-tos is much appreciated. I am not afraid to use Terminal (grew up on UNIX before GUI), etc., and willing to try safe but unconventional setups if that is what's needed...
    thanks for any help!

    Oh never mind.... I figured it out myself helps to read up on the manuals. d'oh. sorry for the bandwidth waste...

  • How to set up FSCM 9.0 Application for Customers to use ?

    Folks,
    Hello. I have just installed FSCM 9.0 ( all of its modules) and run the application in Browser successfully. The Database is a clean System Database without any Demo data (Production Database).
    In order for Customers to type in their data into the application, we need to set up CharFiled, SpeedType, SetID, common data in Controls Tables in the Database. In Menu, there is "Setup Financial/Supply Chain", and under PeopleTools, there is "Setup Manager". But I don't understand where to start to set up the application FSCM 9.0 application.
    Do any folks understand the procedure to set up FSCM 9.0 application for Customers to use step by step ?
    Thanks.

    Folks,
    Hello. Thanks a lot for replying.
    I have installed FSCM 9.0 all of 50 modules. I just want to implement General Ledger module. Thus, I create a project named "General Ledger" in Setup Manager under PeopleTools as follows:
    PeopleTools -> Setup Manager -> Manage Implementation Project -> Create New Project by Product -> select "General Ledger" ->View Summary -> Save -> Type in "General Ledger" in Project Name Box -> Click ok -> click "generate setup tasks" -> click "setup task generation status"
    It has been for a long time, I still see "Run Status" is always "Queued". The button "View Setup Task" does not become clear. This means the process is not completed.
    Do we need to configure Process Scheduler at first before run Setup Manager ? If yes, how to configure Process Scheduler for Setup Manager to generate a list of setup tasks of a project ?
    Thanks.

  • Hi. I am using the iPhone 4S and when I'm searching for places using Google it does not automatically detect my location. How do I change this? FYI...under settings i have it set at "Use new precise locations from my device."

    Hi. I am using the iPhone 4S and when I'm searching for places using Google it does not automatically detect my location. How do I change this? FYI...under settings i have it set at "Use new precise locations from my device."

    If you are missing using google maps - try the Nokia map app called "here"

  • HT5622 We are a family of 4, each with their own apple device. Is it best for us to set up individual apple ID's for things like ITunes? If we do can the same e-mail address be used for all of them or do we need to create e-mails for the kids? Thank-you

    We are a family of 4, each with their own apple device. Is it best for us to set up individual apple ID's for things like ITunes? If we do can the same e-mail address be used for all of them or do we need to create e-mails for the kids?
    Thank-you

    1. Yes, it is.
    2. You may be able to use the same address by adding a plussed suffix to it, such as [email protected] If that doesn't work, create separate emails.
    (103279)

  • HOW TO?: Need help setting up 3 different iCloud accounts for my kids (so each has own iMessanger)using same Apple ID (mine) ....they don't have their own separate email addresses to work from...how do I do this?

    Need help setting up 3 different iCloud accounts for my kids (so each has own iMessanger)using same Apple ID (mine) ....they don't have their own separate email addresses to work from...how do I do this?

    Any devices connected to the same icloud account can sync all the data on that account.  For this reason an icloud account is really for a single user.
    On a mac, if each user has their own account, then the itunes for that mac account should be set up to connect to that user's icloud account (System preferences>icloud).

  • My daughter has been using my iTunes account to buy music and apps. I now want to set up a separate iTunes account for her, with a different login. How can we transfer the music and apps she has already bought to her new iTunes account?

    My daughter has been using my iTunes account to buy music and apps. I now want to set up a separate iTunes account for her, with a different login. How can we transfer the music and apps she has already bought to her new iTunes account?

    Hello, thank you for your prompt answer. I did have an idea that Home sharing might be the answer but could not quite figure out how to do it. I have enabled home sharing in my iTunes account, put in username and password, clicked on creat etc. But the homs sharing icon doew not appear in the left side of iTunes. So I got stuck. Any further ideas?

  • HT201088 I am considering starting Family Sharing.  Should I set up a new Apple ID for the Family Sharing or should I use my personal Apple ID?

    I am considering starting Family Sharing.  Should I set up a new Apple ID for Family Sharing or should I use my personal ID?

    On your Mac, try to access your gmail account. There should be a link you click for "Forgot My Password". Click it and try to retrieve your password.
     Cheers, Tom

Maybe you are looking for