More than one thread in Openmp

Hello Friends,
I am trying to paralelize a great c program and now I am having problems for getting more than one thread.
I tried it inside my code, at first I put omp_set_dynamic(0) and after I put omp_set_num_threads(4), but I got only one thread.
These functions worked fine with a simple hello world code and I got to run 4 threads, but in my big code they didn't work. Could anybody help me? Any hint would be very good!...
Regards,
Glauber

Hi,
Thanks, It's a big code and was divided in 9 files, even so, I will post its most important parts.
That functions are called from sequential part before the parallel region as you will can see below:
// global.h
#if defined (OMP_ENABLED)
#     include "omp.h"
#endif
// main.c
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#include <string.h>
#include <stdarg.h>
#include "global.h"
#ifdef USE_READLINE
# include <readline/readline.h>
# include <readline/history.h>
static char **readline_completion(const char *, int, int);
#endif
# if defined (OMP_ENABLED)
int           proc_id; /* process ID (0, 1, ..., num_procs-1) */
int           num_procs; /* number of active processors */
# endif
int main (int argc, char *argv[])
     int i;
# if defined (OMP_ENABLED)
omp_set_dynamic(0);
omp_set_num_threads(4);
num_procs = omp_get_num_threads();
printf("Num procs: %i\n",num_procs);
if( num_procs <= 1)
exit(0);
# endif
//mcmc.c
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#include <string.h>
#include <ctype.h>
#include <limits.h>
#include <stdarg.h>
#include "global.h"
int RunChain (long int *seed)
     int          i, j, k, n, chn, stopChain;
     for (chn=0; chn<numLocalChains; chn++)
#if defined (OMP_ENABLED)
#pragma omp parallel for private(chn)
#endif
          for (chn=0; chn<numLocalChains; chn++)
If you need something else, please, return me
Thanks in advanced
Glauber

Similar Messages

  • Posting topic to more than one thread and in different categories...

    Is there anything in the TOU we can "refer" to when users post the same topic in more than one thread and to add to that, more then one category? Case in point: http://discussions.apple.com/thread.jspa?messageID=8806009#8806009 (This is just one example)
    Limnos had a valid point. If we had a section in the TOU we could copy/paste from, I think it would help if we could refer to authority, ie., TOU.
    Thanks!
    Carolyn

    I wouldn't get into too much of a flury about that with end users. Notify as needed and let the moderators decide if it needs to be deleted. A good rule of thumb is you want the discussions to have:
    Everyone should feel comfortable reading Submissions and participating in discussions.
    That's from Terms of Use.
    And then there is:
    You agree to not interfere with or disrupt the Site.
    I'm seeing that logically one can conclude directing users not to crosspost may be considering interference with the site. I may suggest someone post in another forum if a solution is not transparent in the forum they are using, but that's as far as I'm comfortable bending the rules.
    I'm trying hard to keep my thumbs away from the keyboard when I see duplicate posts.

  • More than one Thread accessing the same records in the database

    Hi, I have more than one thread accessing a synchronized method called getMinPrimaryKey() which gets the lowest of the primary key frm the table based on the a flag which is set to true. once it is retrieved the same method also sets the flag as false so it is not retrieved the second time. so next time a different thread calls this method it should retrieve the next available lowest primarmy key.
    but even when i have the method as synchronized different threads keep returning the same primary key instead of getting the next sequence. can some one let me know where I might go wrong and what could be the solution. is it because when once i retrieve the record and set the flag as false, i also need to commit it?, which could be the reason the select query still picks up the same primary key. please help me out on this.
    thanks,
    Harish

    Correction. If different threads always return the same key then your table isn't getting up dated. If different threads sometimes return the same key, then either the database is committing lazily, or else the threads are calling getMinPrimaryKey on different objects and so are not executing atomically with respect to each other.

  • Using of more than one thread

    How can I use 2 or more threads at a time in a Java applet? Can anyone give me a very simple code that uses 2 threads in a java applet......thanks
    And also, what if I want to use one of the thread for my text animation & the other for my word comparison? pls. do help me....

    Kira_Ikari
    Take a look at these, this is the kick-off page for a good tutorial:
    http://java.sun.com/docs/books/tutorial/essential/concurrency/
    These are targeted at j2me, but are well illustrated and are really good for getting a "feel" of how multithreaded programs operate under the hood:
    http://developers.sun.com:80/mobility/midp/articles/threading/
    developers.sun.com/mobility/midp/articles/tutorial2/
    Regards, Darryl

  • Can a thread do more than one thing at once?

    Hey all,
    I'm confused a little bit on how a thread might act in this situation:
    I have a server-client setup. The thread on the Client sits and waits to receive instructions from the server. When it does, it manipulates some ArrayLists I have in the Client in different ways depending on what the instructions from the server were. What would happen if I sent two instructions from the server, one right after the other, and they both had to manipulate the same ArrayList. I was going to synchronize the methods operating on the arraylists, but I didn't know if that would work since it's really just one thread. But then, since it's just one thread, can it do more than one thing at a time? Or will it queue them up somehow? Thanks!
    Matt

    Rhesus21 wrote:
    Hey all,
    I'm confused a little bit on how a thread might act in this situation:
    I have a server-client setup. The thread on the Client sits and waits to receive instructions from the server. In client-server applications, the clients make requests and the server performs them and sends back a response.
    It appears you have a central "server" which sends back updates/instructions to the client in a server-push approach.
    When it does, it manipulates some ArrayLists I have in the Client in different ways depending on what the instructions from the server were. What would happen if I sent two instructions from the server, one right after the other, and they both had to manipulate the same ArrayList. Are both instructions sent on the same connection? Does your client only read the next instruction after performing the previous one. Are you using multiple connections and do you create a thread for each connection?
    I was going to synchronize the methods operating on the arraylists, but I didn't know if that would work since it's really just one thread. If you have only one thread you don't need to use synchronized.
    But then, since it's just one thread, can it do more than one thing at a time? No.
    Or will it queue them up somehow? Yes. Each connection has a buffer at both ends. When the buffers fill the sender blocks waiting for the receiver to read the data.

  • More than one VI at a time (i.e. multitasking)

    Hello.
    I currently work in a lab where we use LabVIEW to control an multifunction instrument. We use the sofware both for data acquisition (through Ni-DAQ) and for physical control of things like stages, and frequency generators (e.g. through GPIB). There are a few programs that do very simple things (like move a stage with a joystick, or turn a laser on and off) that I would like to run continuously in the background while I run other more specialized software (like a data acquisiton routine). However, when I run more than one VI at the same time I run into very bad timing problems. Some of my programs require this kind of multitasking and I have implemented it using a sort of Master loop (similiar to the Master/S
    lave paradigm discussed on the NI website).
    If I were to purchase the compiler and build executables out of some of the VIs, would I be able to run these in the background while LabVIEW runs other VIs without running into timing issues?
    Also, if I build executables from some of the VIs would these VIs be able to access global variables that LabVIEW is using (I assume the answer is no, but I figured I'd ask).
    Thanks,
    Josh
    [email protected]
    =====================
    Joshua Shaevitz
    Department of Physics
    Stanford University
    Stanford, CA 94305

    First, do you know where your timing problems are coming from? Are some of those background tasks very processor intensive, or is the problem that you're sharing subVIs that aren't reentrant (and hence may be "blocking" each other)? Have you tried multithreading the application yet (running the motion control in one thread and the laser control in another, for instance)?
    Splitting your tasks between multiple executables might help, but it will almost certainly increase the overhead of each background task, and you will not have common access to global variables. You could, however, work around that by instituting a common data repository as one of your background tasks (presumably accessed through a messaging interface).
    In fact, I would probably suggest
    this as a method of performance optimizing your application anyway -- if you are using globals extensively for parallel operation, they might be part of the blocking problem.

  • Not able to link more than one EO to the VO.

    Hi All,
    I have to add a new column from another table to the existing VO.
    I have followed the below steps.
    Step1: I have created a new EO for the new table
    Step2: I have created a new VO which extends the existing VO.
    Step3: While extending the new VO, i have added the new EO and old EO is also there and modified the query as per my requirement.
    Step4: I have substituted the VO and bounced.
    Step5: Through personalization, I have added a new field to the page and assigned the new column name as view instance.
    Now when i run the page, values are not going to the database for the new column.
    When i clicked on Aboutthis page, VO is substituted with the new VO, but it is attached to only one EO which is the existing one, And the new EO link is missing.
    Can you please tell me whether i missed any steps or did any mistakes while performing the above steps.
    It is urgent, please help me ...
    Thanks,
    Manjula

    I am little bit confused.
    Can you tell me whether I can have more than one EO updateable in a VO or not?
    In my case, this is simple join, there is no Outer Joins in my query.
    Yes you can an have more than one EO updateable in a VO if there is no Outer Joins in query.Can you tell me the subject of the thread or threadid. I couldn't find the thread what you are saying.
    Actually that thread, i have followed the approach Tapash, mentioned ...at that time...but somehow it didn't worked in my case, anyways, you can surely give a try.I had 3-4 EOs with all outer joins.--Mukul                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • How do I create more than one "window"?

    Hi.
    I just started with JavaFX and know about the basics (at least I thought so).
    But: How do I create an application with more than one "window"?
    One stage has one scene with several components like buttons - ok... I already have a stage with a scene with buttons and actions - Now I want to click one of these buttons and then get to another stage (or scene or whatever) where I see some other textfield and buttons.
    How do I realize this with JavaFX? I did not find anyone example in the web? What am I missing? Do you not create this flow with JavaFX?
    Please can someone explain this to me (and if possible post a link where I can some code where this is implemented)?
    Thanks a lot...

    Recent thread: [Multiple stages app dev|http://forums.sun.com/thread.jspa?threadID=5405420]
    Other threads... well, hard to find back, I reckon.
    Simple example:
        // Some control/shape
          Circle
            centerX: 15
            centerY: 15
            radius: 10
            fill: Color.LAVENDER
            stroke: Color.PURPLE
            onMouseClicked: ShowDialog
          }and elsewhere:function ShowDialog(evt: MouseEvent): Void
      println("Circle pressed");
      var dialog: Stage = Stage
        title: "A Dialog"
        visible: true
        scene: Scene
          width: 300
          height: 50
          content:
            Text
              x: 5, y: 5
              font: Font { size: 24 }
              content: "I am a secondary window"
              textOrigin: TextOrigin.TOP
    }Apparently, you just have to create an instance of Stage to have it to appear.

  • How can i update more than one table at a time?

    i would like to update more than one table at a time. In Java Studio creator2 how can i do table updation?

    Hi,
    Please go through the below thread might be of help to you.
    http://forum.sun.com/jive/thread.jspa?forumID=123&threadID=51839
    RK

  • Can I create more than one instance of a native library?

    Hello all,
    I am using Java to access a Win32 DLL with JNI. Everything is working fine, but I have several threads using the same instance of the native library because it is loaded "statically" in the Java class which uses it, and I suspect I am getting a bottle-neck at the native library.
    Does anyone know if there is any way to load more than one "instance" of a native library?
    The use of System.loadLibrary() would indicate not, and my (limited) knowledge of the Windows environment would tell me that a "shared" library only has on instance. (confirm anyone?)
    I need to find a way around this bottle-neck issue... (and "no", before anyone suggests it, I can't ditch Windows!)
    Thanks.

    I am not sure about the behaviour of the dll as it's not mine. It's a COM DLL which I have "wrapped" in a standard windows DLL so I can expose the JNI methods. I assume because it's COM that it IS reentrant, but I am a bit of a novice when it comes to Windows and COM. I didn't install the COMponent either, it was installed as part of another application. (It's an antivirus COM dll that is part of an AV application)
    Thanks for your help though, I think I will just have to live with it.

  • How can I share iPhoto libraries across more than one computer?

    I am trying to find a solution for multiple users accessing a single iPhoto library.
    I want to have just one "master" library for my family, which we can all access via different computers.
    I also want to apply the same principle of a "master" library for iTunes and iMovie, plus all our files/documents - see the original question here: https://discussions.apple.com/thread/4940803.
    Does anybody have any suggestions?
    Thank you

    iPhoto has never been designed as a shared network database. What you want to do is currently not supported, Jerry, sorry.
    Some things to consider - assuming you are using the most recent iPhoto version:
    iPhoto '11 will not allow to have the library be opened by more than one user at a time. It will lock the iPhoto library, if it is already in use.
    The iPhoto library needs to be on a disk, that is formatted MacOS X Extended (Journaled), otherwise iPhoto will not open it. Most network volumes have a different formatting.
    Network access is considerably slower than the access to a locally connected drive. You will have a noticable decrease in performance when working over the network. Editing the images will be no joy, if each and every access to the databases inside the library needs a network access.
    Since iPhoto is not specified as a network database, there is no built-in protection against network drop-outs and transmission errors when doing database transactions. You will be risking to corrupt your iPhoto library.
    Save sharing options would be:
    Let the iPhoto library be managed by one user, but give read-access to your family members using the "Sharing" preferences. You can share all albums or selected albums on your local network for browsing.
    Put your iPhoto library on a portable drive and let each family member use the drive in turn.
    Use shared Photo Streams to share your photos.
    This is Apple's recommendation on how to share a library:
    iPhoto: Sharing libraries among multiple users
    Regards
    Léonie

  • Mailing more than one photo

    I would like to be able to email more than one photo at a time. That is if any developers are reading this thread.

    It is still not fixed for all - on my system MacOS 10.8, Aperture 3.3.2, Mail.app, it is working.
    See this thread for work-arounds:
    Mailing more than one image not working
    And send a bug-report to Apple, using the feedback form from the Aperture menu:
         Aperture > Provide Aperture Feedback
    Regards
    Léonie

  • TS4123 This is not correct solution. I have fresh copy of Windows 7 64 bit and I have the same problem.  Autorun only shows the Bonjour service.  It started when try to sync more than one iphone.

    This is not correct solution. I have fresh/new copy of Windows 7 64 bit and I have the same problem. 
    Autorun only shows the Apple Bonjour service.  It started when try to sync more than one iphone over WiFi. I have two iphones and an iPad. I turned off syncing over WiFi and still has high CPU utilization. One of the CPU's is pegged at 100%.  It is the AppleMobileDeviceService.exe process.

    For the record, I then followed the suggestion of MarcDCMB in https://discussions.apple.com/thread/4291206 of just manually restarting the Apple Mobile Device service in Windows services.msc once each time after starting iTunes and the service no longer hogs CPU after that service restart.  Not too painful as a work-around, and apparently an effective one, but clearly not a solution to the problem.  Again, as above, all the other solutions didn't work for me and I have no conflicting software as far as I can tell. So you'd have to say this Apple's problem.
    Also FTR, I am still on the 5.2.0.6 version of the Apple Mobile Device Support MSI and I don't know if that is relevant to this work-around working but my sense is that it is NOT relevant.  I'll report back on this thread if I re-upgrade and the problem returns in spite of the service-restart approach.

  • I have a desktop PC and a Macbook Pro.  Can I install my CC programs on more than one machine/OS at the same time?

    I'm looking to start using Adobe CC but I use more than one machine in my daily life - a Win8.1 PC and a Mac OSX laptop - can anyone tell me definitively whether I can install the desktop applications for CC on both and sync all my online files to whichever machine I happen to be using at the time?

    Cloud License allows 2 activations http://www.adobe.com/legal/licenses-terms.html
    -Install on a 2nd computer http://forums.adobe.com/thread/1452292?tstart=0
    -Windows or Mac does not matter... 2 on the same operating system, or 1 on each

  • How to use more than one JCo in one project?

    hi all,
    I want to use more than one r/3 systems and want to switch between them while running the application.
    For that, how can I use more than one JCo connection in one project and how to activate/deactivate them so as to switch in between them? And if that possible then what am I suppose to do in order to fetch the data from activated R/3 while running the application.
    Regards,

    Hi,
    Try this threads
    Multiple Client Logon in JCO
    Multiple JCO client connections
    Regards
    Saravanan K

Maybe you are looking for

  • REG : SYNC/ASYNC bridge

    Hi all,              I have a scenario where my sender is a syncronus and receiver is asyncronus. I have used sync/async bridge in BPM to acheive this.But when i send the input data from runtime workbench with QOS as BEST EFFORT i  got the following

  • How to create soap message through java using JAXM

    Hi, I'M REALLY NEW TO THIS JAVA WEB SERVICES. I need to send a soap messages from core java with using url and it goes to my servlet and able to retrieve the soap message and do the processing. I really don't the work flow too. I'm using JAXM for rec

  • Set up Family Sharing, but I'm not getting asked to approve

    I set up iOS8 on my new iPhone 6 and my kids' 5th gen iPod Touches. I set up Family sharing and gave both the kids their own accounts. When they want to buy an app they get a message for them to sign into the iTunes store. Then I get a message "Payme

  • How to get charEncoding property and set it to a perticular encoding?

    hi all, i would like to know 1)how to get browser encoding property 2) if the encoding is Western European(ISO) how can we change to arabic windows. i think i have to use like below request.getCharacterEncoding(); request.setCharacterEncoding(); but

  • My Film is gone

    Hi there, I've got a problem with my Premiere CS3. My computer was infected by a trojan three days ago and i was unable to fix the problem so i had to reinstall my windows xp. So I saved all my files - including my project in adobe premiere and all t