OpenMP thread number

Hello,
I add OpenMP directives in my code, do "setenv OMP_NUM_THREADS 4", then run the code. When the code is running, I use "top" utility to look at this running job. One column "THR" in the "top" screen shows "6" for this job. I only set to use at most 4 threads, why are there "6" threads? I then tested different thread numbers, when I set thread number to 1,2,3,4, respectively, the running process actually uses 3,4,5,6 threads respectively. So, even if I want it to run serially by set 1 thread, it still create 3 threads.
If I compile the real serial code which has no OpenMP directives at all, the code would run as a real serial code, "top" indicates only 1 thread is created.
This kind of behavior is not expected, anything wrong with SUN compiler or parallel run time system? I am using Studio8 compiler on 4-processor SUN fire V880 system.
Anybody has similar experience?
Thanks for any input or comments.
Jeff

It's likely that you're running on Solaris 8 or older, and not
using the 1-to-1 libthread. (/usr/lib/lwp on Solaris 8)
That threads library creates extra threads for "internal" use,
like catching signals.
The OMP variable controls how many threads the OMP library
creates, not how many will be in the process.
The extra threads don't normally run code except during special
cases like signal processing.
On newer versions of Solaris you can use "prstat -L" to get a top-like
display showing all active LWP's. This would be a good tool to see
how many threads are actually doing work at once in your OpenMP program.
--chris

Similar Messages

  • Thread number limitation on Sun One Web Server 6.1 on Solaris 9

    Hi.
    I am testing my servlet on Web Server 6.1 on Solaris 9 (SPARC). I am logging start of HTTPServlet.doPost() method and end of it, by calling GenericServlet.log() method for perfomance check.
    When I request more than two request(it takes long time) simultaneously from browser, my servlet logs like:
    doPost start
    doPost start
    doPost end
    doPost start
    doPost end
    doPost start
    :that is ,two requests is processed concurrent by threads, and another requests waiting, and after each running thread ends, waiting request is processed one by one.
    I think there is some limitation of thread or connections, so I checked magnus.conf. But RqThrottle is set to 128. And I cannot find any thread number settings.
    My magnus.conf is as follows.
    # The NetsiteRoot, ServerName, and ServerID directives are DEPRECATED.
    # They will not be supported in future releases of the Web Server.
    NetsiteRoot /export/home0/SUNWwbsvr
    ServerName test03
    ServerID https-test03
    RqThrottle 128
    DNS off
    Security off
    PidLog /export/home0/SUNWwbsvr/https-test03/logs/pid
    User webservd
    StackSize 131072
    TempDir /tmp/https-test03-8ac62f09
    UseNativePoll off
    PostThreadsEarly on
    KernelThreads off
    Init fn=flex-init access="$accesslog" format.access="%Ses->client.ip% - %Req->vars.auth-user% [%SYSDATE%] \"%Req->reqpb.clf-request%\" %Req->srvhdrs.clf-status% %Req->srvhdrs.content-length%"
    Init fn="load-modules" shlib="/export/home0/SUNWwbsvr/bin/https/lib/libj2eeplugin.so" shlib_flags="(global|now)"Why web server do not process more than two requests concurrent? Which server configuration should I check?
    Thanks in advance.

    I don't think I ever ran into that kind of a limit. Does the servlet use database connections (maybe the connection pool is empty) or other critical sections / large synchronized blocks?
    Try a minimal servlet that takes a while to execute:
        doGet(...)
            log("sleep starting " + Thread.currentThread().getName());
            try {
                Thread.sleep(30000);
            } catch (Exception e) { }
            log("sleep done " + Thread.currentThread().getName());
            response.getOutputStream().println("good morning");

  • Thread number per connection crash 4.16

    We are using a program in a loop, we add 500 entry in 2 minutes. If the
    thread number per connection is set to 5 or 10, the Netscape Directory
    Server 4.16 got disorderly shutdown and dump a core. If we set this as 1,
    the server works fine.
    Could you please tell me what is the problem? Is this version not reliable?
    Thanks,
    Peter

    Peter Pan wrote:
    We are using a program in a loop, we add 500 entry in 2 minutes. If the
    thread number per connection is set to 5 or 10, the Netscape Directory
    Server 4.16 got disorderly shutdown and dump a core. If we set this as 1,
    the server works fine.
    Could you please tell me what is the problem? Is this version not reliable?What does it say in your error log? Is the number of threads per connection times the number of connections greater than the
    threadnumber? Are you sure you have tuned your kernel parameters to allow a large number of threads per process and per kernel?
    >
    >
    Thanks,
    Peter

  • Thread number limit

    Hi !
    Is there a thread number limit in a JVM ?
    Thanks
    Ludovic

    The OS limits the number of threads which can be run without significant overhead.
    This is 100 - 1000 depending on the OS.

  • Log4J - Unable to get Thread number in log4j

    Hi
    Please post me the log4j config file used in Sun One Application server 7.0. I am unable to retrive the thread number in logs using my existing log config file.
    existing log line sample :
    Aug 01 17:48:52 DEBUG [service-j2ee]
    Thanks in advance.
    Vishnu Deevi

    Hi Sadasivam,
        Could you explain me how did you resolved this.
    BR
    Raju

  • How to change the thread number for user account

    I remember that for each user account, we can limit the maximum thread number it can create for a user process. But how to change this number?
    Thanks,
    Iris

    Hi ,
    I do not think that there is a way to control the number of "threads per user".
    Are you referring to "thread id" ? Please elaborate on your requirement.
    You may want to take a look at the complete list of process sizing tunables
    at:
    http://docs.sun.com/ab2/coll.707.1/SOLTUNEPARAMREF/@Ab2PageView/idmatch(CHAPTER2-4)?Ab2Lang=C&Ab2Enc=iso-8859-1#CHAPTER2-4
    The link can also be accessed as:
    http://docs.sun.com
    Collection Titles
    Solaris Tunable Parameters Collection
    Solaris Tunable Parameters Reference Manual HTH
    Gopinath.
    Developer Technical Support
    Sun Microsystems Inc

  • JRUN thread number

    Hello,
    I was looking for logs and the field "threadId".
    I've found that "JRPP-X" is for JRUN thread and the X is a
    number.
    My X increases, about +200 per day for 60k connections... So
    I'm wondering if it means that there are memory/thread leak or
    something like that...
    Thanks,
    Y.

    Your threads will fall down to the minhandler count on a
    server that is idle or lightly used. So, threads will go away. In
    short, the thread ID incrementing does not show any negative
    behavior by itself.

  • J2ee Hanging and thread number growing

    Hello all,
    Nearly every day our XI system hangs. The Abap stack works
    normally, but the Java stack no longer allows any connections (http,
    visual admin).
    After the "WaitingTaskCount" KPI reaches its threshold (RZ20 - Kernel->Application Threads Pool -> WaitingTasksCount), the j2ee engine is hanging. We noticed a very high number of thread (442). When we telnet on the
    J2ee engine on port 50008, we jump from the dispatcher to the server and we execute a garbage collector, the j2ee engine is available again but
    it hangs again 2 hours after.
    Regards,
    Vincent

    Nadim,
    Please check SAP Note 764417 - Information for troubleshooting of the SAP J2EE
    Engine 6.40.
    It is very useful to have a full thread dump if the J2EE Engine is running with high
    CPU consumption, or an Out of Memory error. See SAP Note 710154 - How to
    create a thread dump for J2EE Engine 6.30. I think SAP recommend that you create the thread dump once the J2EE Engine is running properly and once when an error occurs.
    ---Satish

  • Set execution thread number

    I am running WLS6.1SP1, and in the tab configuration/tunning, I did not see a place
    that let me set the number of execution threads, does any body know where to set
    it ?
    thanks
    zhou

    I found this on weblogic.developer.interest.performance just minutes after my last post:
    1. Click on "Servers" folder in tree to expand it to where you can see the server you want to work with (if necessary).
    2. Right-mouse click of the server you want to work with. This will display a track pop-up menu. Select the "View Execute Queues" menu option.
    3. Click the link for the "default" execute queue in the HTML table that is displayed. Afterwards, you should see the screen you are accustomed to using to adjust the execute threads count.
    4. Change the value in the field next to the "Thread Count" label and click the "Apply" button.
    I don't know why I didn't think of that...
    Dave
    On Mon, 03 Jun 2002 19:08:16 GMT, [email protected] (David W. Archer) wrote:
    I think it's missing from the GUI. It's in config.xml as:
    <Server ...>
    <ExecuteQueue Name="default" ThreadCount="50"/>
    /Server>
    On 11 Apr 2002 12:43:04 -0800, "x zhou" <[email protected]> wrote:
    I am running WLS6.1SP1, and in the tab configuration/tunning, I did not see a place
    that let me set the number of execution threads, does any body know where to set
    it ?
    thanks
    zhou

  • Find sequence and thread number of Oracle 10g Database

    Hallo!I am a newbie Oracle DBA studying for OCP.I am trying various methods of performing flashback of the database.
    Out of these options there is one that uses the sequence and thread numbers of the database as below
    RMAN> FLASHBACK DATABASE
    2> TO SEQUENCE=223 THREAD=1;
    How can I find out current sequence and thread numbers of the db to enable me implement such a flashback strategy?
    Thanks.

    Current sequence# is the one with status = CURRENT
    SELECT group#, thread#, sequence#, status FROM v$log;Lukasz

  • Tuning the good number of thread with Work Manager?

    Hi,
    I search some best practice or experience return on the max thread number on a weblogic managed server
    I try to explain: with WLS 8.1 and execute queue it was hard to tune the good number of thread but possible (with some processor and for an application we find that after 30 concurrent thread, there's lower performance because of switch on processeur, for others it was 45 for example)
    Now i can see sometimes more than 500 thread on one JVM and it seem to be very much for me!!
    we face some problem of response time in PRODUCTION, i can see sometimes more than 100 Stuck thread on a resource, so i think it's the reason of bad response time. But with Work Manager, it increase the number of thread to accept others request and the CPU stay at acceptable level (less than 50%) because the stuckthread are do nothing (waiting for resource)
    So i don't understand the good tuning to apply since WorkManager...ok it isn't normal to have a lot of stuck thread but if there's no matter about the max number of thread, is it useful to stop and restart managed server?
    do you think we can have have bad performance if there's a lot of thread?
    thank you for your experience return. If you have no idea just tell me how much thread you can see on your managed server in Production.

    up, up...
    we have always the same probleme in production: 50 stuck thread on each JVM since 15 days....
    the manages serveurs are in warning but don't seem to be disturb cause the work manager add more threads dynamicaly.
    Anyone have idea if this situation is a probleme for response time on other request ?
    reboot managed solve this situation but i would like to understand the consequence of this situation.
    thanks a lot for your experience.

  • How to find number of records in a cube and ODS....

    Hi,
    How do we find total number of records in a cube and ODS?
    Is there any Tcode for this ?
    From the content it is difficult to get the number of records, if it is more in number.
    Thanks,
    Jeetu

    Hello ,
              Please check the following thread,
    Number of records in a infocube
    hope it helps,
    assign points if helpful.

  • Copy variable from one thread to another

    My program requires user to input a java file which contains the run() method.
    In the input file, user can declare variables and use those variables inside the run method. User also need to enter the number of threads to be spawned.
    The problem is how can I construct some method like "copy" which can copy the variable from one thread to another in my program? I can't do that since I don't know the name of the variables that the user inputted.
    I've tried this:
    class helloworld extends thread{
    void run(){
    String a="hello";
    String b="world";
    copy(0,1,a,b)
    class myProgram {
    Class c = Class.forName(fileName);         // file name of user's file     
    Thread t[] = new Thread[p];             // p is number of threads
         for (int i=0; i<p; i++){             // create threads      
                   t[i] = (Thread) c.newInstance();  
                   t.start();
    public void copy(int sourThread, int destThread, String s1, String s2){
    t[sourThread].s1=t[destThread].s2
    But it doesn't work. It said "cannot resolve symbol s1 and s2".
    please help. urgent. Thanks a lot in advance.

    You need to seriously reconsider what you're allowing the user to do. The short answer to your problem is to use a shared, synchronized associative array.
    However, since the user can specify any number of threads, you will have to resolve deadlocks, and the fact that you're asking this question suggests you will have problems doing so until you have read up on threads and shared variables in more detail. (I don't mean to be dismissive. Deadlocks and shared variables have to be customized to the application, i.e., you have to figure out just when each thread will need access to the variable, what kind of access, and when.)
    In the meantime, take a step back and take a look at the big picture.
    From what you've said, I would guess a common example of your application is that I want to be able to read file "foo.dat", uppercase each letter in the file, and write it out to "fooXXX.dat" where XXX reflects the thread number. And specify any number of threads I want.
    Threads would not be the best way to accomplish this. Do this serially.
    Alternatively, I could interpret your problem as in you need to create a main() function that's capable of reading someone else's dot-class file, clone the object and start it. In which case, why do you want to share variables? If the user did his job correctly, then his file will already contain shared variables (or copy them as appropriate). All you have to do is clone the object via the new keyword, then call start() in it.
    You cannot share something when you don't know what you're sharing.
    The third option is that you're doing this as an academic exercise (i.e., homework). Granted, yes, your professor may ask you to do things illogically just to prove they can be done. Unfortunately, we're not supposed to help you in that case. People who read this forum generally try to find logical and efficient ways of doing things.

  • Smtp_in and IMAP, number connexion never decrease

    I have apply cumulativ patch 10.1.2.4 on my mail server. since that server SMTP_IN and IMAP blocks once the maximum number of connection reached. I tested the LD_ASSUME_KERNEL and the umilit - S 512
    but the number of connection of never falls. in the log of the SMTP_In mode traces. the number of thread increases by 1 with each new message. but does not decrease.

    Hi,
    And is it suposed to decrease? I think the thread number always increases but the older threads are being terminated when no longer used. So the real "alive" number is always constant and the number you are seeing is just a sequencial numeration since the bounce of the smtp process.
    Just my opinion.
    Luis

  • How to terminate a java thread from c++ code?

    Hi,
    I made a screensaver which loads a jvm, forks a thread running a java class, wait until user's action(i.e. mouse move/click keyboard input), then terminate the java thread.
    However, I met a problem, How to terminate a running java thread from c++ code?
    Here is my code, but it does not work: (even after the terminate is called, jvm throws an error)
    JNIEnv* env;
    JavaVM* jvm;
    HANDLE hThread; //handle for the startThread
    unsigned __stdcall startThread(void *arg)
         jclass cls;
         jmethodID mainId;
         jint          res;
         int threadNum = (int)arg;
         res = jvm->AttachCurrentThread((void**)&env, NULL);
    cls = env->FindClass( MAIN_CLASS);
         mainId = env->GetStaticMethodID(cls, "main", "([Ljava/lang/String;)V");
         // setup the parameters to pass to main()
         jstring str;
         jobjectArray args;
         int i=0;
         args = env->NewObjectArray(1, env->FindClass("java/lang/String"), 0); //only one input parameters
         str = env->NewStringUTF("localhost");
         env->SetObjectArrayElement(args, 0, str);
         env->CallStaticVoidMethod(cls, mainId, args); // call main()      
         if (env->ExceptionOccurred()) {
                   env->ExceptionDescribe();
         return TRUE;
    Here is the main method:
    First create the jvm and load the thread. then tries to terminate the thread, but failed here
    switch (msg)
    { case WM_CREATE:
              JavaVMOption options[NUMBEROFOPTIONS];
              JavaVMInitArgs vmargs;     
              jint rc;
              vmargs.version = JNI_VERSION_1_4; /* version 1.4 */
              vmargs.options = options;
              vmargs.nOptions = NUMBEROFOPTIONS;
              vmargs.ignoreUnrecognized = JNI_FALSE;          
              rc=JNI_CreateJavaVM( &jvm, (void **)&env, &vmargs ); /* create JVM */
              /* We pass the thread number as the argument to the invoked thread */
              unsigned int threadId = -1;
              // to initialize a thread-safe C runtime library
              hThread = (HANDLE)_beginthreadex(NULL, 0, &startThread, NULL, 0, &threadId );
    } break;
    case (WM_DESTROY):
              CloseHandle( hThread );
              jvm->DestroyJavaVM(); /* kill JVM */
              Debug("Destroy Java Virtual Machine\n");
    }break;
    Note, after the thread "startThread" runs, it has an infinite loop and will not terminate, until the user clicks to terminate.(I didn't call jvm->DetachCurrentThread();_endthreadex(0); in the "startThread" because the java thread will not terminate by itself)
    Thus, the only way to terminate the thread is to call closehandle(hthread) in the main thread, which may cause jvm to throw an error.
    Do you know how to terminate a java thread safely???
    Thanks a lot

    Assuming that your java thread is in a loop of some kind. Such as
    int i=1; /* I tried using a boolean, I just could not get my C++ env, to change this value. So i decided to use an int */
    run {
    while(i)
    isdfjsdfj
    void seti()
    i=0
    So, B/4, i call destroyVM in my C++ code, i call this seti(). so the loop terminates, therefore my thread finishes executing and ends.
    Hope this helps
    tola.

Maybe you are looking for