Sunstudio on Linux using OpenMP

I am new to use SunStudio.
Rightnow, I want to use openmp to parallel my code.
To do that, I begin from simple example.
PROGRAM calculate
USE omp_lib
INTEGER :: i, max_number
DOUBLE PRECISION :: step, x, value, sum
DOUBLE PRECISION :: num_steps = 1000000000
REAL(8) :: start_time, end_time, run_time, timearray1(2), timearray2(2)
INTEGER :: j
DOUBLE PRECISION :: y, value2 = 0.0
INTEGER :: id, nthrds, nthreads
sum = 0.0
step = 1.0/num_steps;
start_time = dtime(timearray1)
DO  i = 1, int(num_steps), 1
    x = (i - 0.5)*step;
    sum = sum + 4.0/(1.0 + x*x)
END DO
value = step*sum
end_time = dtime(timearray1)
run_time = end_time - start_time
write(*,*) 'run_time is ', end_time, 'seconds'
write(*,*) 'calcuated value is ', value
WRite(*,*) '-------------------------------'
write(*,*) '**      Parallel Test      **'
write(*,*) '-------------------------------'
max_number = OMP_GET_MAX_THREADS()
write(*,*) 'Max Threads = ', max_number
CALL OMP_SET_NUM_THREADS(4)
sum = 0.0
start_time = dtime(timearray2)
!$OMP PARALLEL PRIVATE(id,sum)
id = OMP_get_thread_num()
     DO j = id + 1, int(num_steps), 4
         y = (j - 0.5)*step
         sum = sum + 4.0/(1.0 + y*y)
     END DO
!$OMP CRITICAL
     value2 = value2 + sum*step
     write(*,*) "My thread is", ID, "value2 is", value2
!$OMP END CRITICAL
!$OMP END PARALLEL
end_time = dtime(timearray2)
run_time = end_time - start_time
write(*,*) value2, end_time
END PROGRAMCompilation proceed with no errors or warnings. I used 'f95 test.f90 -xopenmp -O3 -fast'
But the result is strange, it is
run_time is 10.717370986938477 seconds
calcuated value is 3.1415926525857966
** Parallel Test **
Max Threads = 4
My thread is 1 value2 is 0.7853981633965759
My thread is 0 value2 is 1.57079632680205
My thread is 3 value2 is 2.3561944891987165
My thread is 2 value2 is 3.1415926525868203
3.1415926525868203 11.203296661376953
looks like not parallel at all, I test the same code by GCC, it did parallel.
Anybody can help me out? thank you

Thank you very much, Peter,
I try your code, the output is strange, the time is wired
'3.1415926525874704 -188950.34375 '
I am using RedHat Enterperise Linux 5.
The purpose here is I want to see how much performance can be improved by openmp, the similar problem coding up by C and compiled by gcc gave
'using 1000000000 steps to calculate Pi
num_threads = 1
pi is 3.141593 in 7.146756 seconds 1 threds
num_threads = 2
pi is 3.141593 in 4.289904 seconds 2 threds
num_threads = 3
pi is 3.141593 in 2.787567 seconds 3 threds
num_threads = 4
pi is 3.141593 in 1.698492 seconds 4 threds
Thanks again
Edited by: frankqi on Feb 11, 2009 12:21 PM

Similar Messages

  • Open a PDF file in linux using java

    Hi..
    How can I open a PDF file in linux using java.
    I am able to open PDF in windows and mac using this code
    in Windows
    Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + path_of_PDF);
    in mac
    Runtime.getRuntime().exec("open " + path_of_PDF);
    But nothing is working with linux.
    Please help
    Thanks

    One thread is enough:
    http://forum.java.sun.com/thread.jspa?threadID=5267458

  • Open PDF file in linux using java

    Hi..
    How can I open a PDF file in linux using java.
    I am able to open PDF in windows and mac using this code
    in Windows
    Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + path_of_PDF);
    in mac
    Runtime.getRuntime().exec("open " + path_of_PDF);
    But nothing is working with linux.
    Please help
    Thanks

    appi wrote:
    Hi.. I found the JDIC binary files. There are different binaries for all the plateform. Is there any solution which is independent of plateform.Yes, and we already told you: Use JDK6, which has those libraries built into the standard class library.
    How can I use these binaries in my existing project. does it work, If I place them at same place where other .class files are kept.Read the documentation of the JDIC project. I'm sure they answer this question in their FAQ.

  • Linux using boot camp is it possible why people choose VMware or parallels?

    Hi everyone,
    Has anyone installed Linux using boot camp ? I'm asking this because i want to install the latest version of oracle database 11g and i need to install Linux or Windows to run the server.
    There is no version of Oracle 11g for macosx atm.
    Why people choose VMware and Parallels instead of using boot camp?
    Please give some feedback.
    Greatfully,
    Nuno

    UrbanJenkie wrote:
    Hi everyone,
    Hi Nuno and welcome to Discussions,
    Has anyone installed Linux using boot camp ? I'm asking this because i want to install the latest version of oracle database 11g and i need to install Linux or Windows to run the server.
    Quite a lot of people are running Linux on their Intel-Macs (I am not one of them...).
    Here's a how-to for Ubuntu https://help.ubuntu.com/community/Intel_iMac
    There is no version of Oracle 11g for macosx atm.
    Time to complain(send a feedback to Oracle
    Why people choose VMware and Parallels instead of using boot camp?
    VMWare and Parallels have the advantage over BootCamp, that you can use them while still being in OSX, so that you can run Windows/Linux alongside OSX.
    With BootCamp you have to restart your Mac each time you want to switch to/from Windows/Linux.
    Please give some feedback.
    Hope it helps
    Greatfully,
    Nuno
    Regards
    Stefan

  • Want to use credit card with firefox but do not see a lock with firefox 5 on linux using priceline

    want to use credit card with firefox but do not see a lock with firefox 5 on linux using priceline

    Type '''about:preferences#applications'''<enter> in the address bar.
    Now follow the picture.

  • Oracle 10g installation on linux using virtual box.

    Hi,
    Iam trying to install oracle 10g on enterprise linux using virtual box.I downloaded oracle 10g for linux and while running the installer,Iam getting this error
    Exception in thread "main" java.lang.UnsatisfiedLinkError: /tmp/OraInstall2010-04-16_07-29-46AM/jre/1.4.2/lib/i386/libawt.so: libXp.so.6: cannot open shared object file: No such file or directory
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary0(Unknown Source)
    at java.lang.ClassLoader.loadLibrary(Unknown Source)
    at java.lang.Runtime.loadLibrary0(Unknown Source)
    at java.lang.System.loadLibrary(Unknown Source)
    at sun.security.action.LoadLibraryAction.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.awt.NativeLibLoader.loadLibraries(Unknown Source)
    at sun.awt.DebugHelper.<clinit>(Unknown Source)
    at java.awt.Component.<clinit>(Unknown Source)
    Please help me to solve this

    user9362721 wrote:
    Hi,
    Iam trying to install oracle 10g on enterprise linux using virtual box.I downloaded oracle 10g for linux and while running the installer,Iam getting this error
    Exception in thread "main" java.lang.UnsatisfiedLinkError: /tmp/OraInstall2010-04-16_07-29-46AM/jre/1.4.2/lib/i386/libawt.so: libXp.so.6: cannot open shared object file: No such file or directoryHi.
    This question was answered in this forum yesterday. And the day before. And the day before that. And ... (Or at least it feels like we get this every day, and sometimes several times a day.)
    Search for 'xhost'

  • Where can I find the right doc for SunStudio For Linux ?

    I can find the docs for SunStudio here, http://docs.sun.com/app/docs/doc/819-5265/6n7c29ck9?a=view
    but it seems that it doesn't right on linux platform.
    #include <stdio.h>
    int main(void)
    #if defined(sun)
            printf("sun defined \n");
    #else
            printf("sun undefined \n");
    #endif
    #if defined(unix)
            printf("unix defined \n");
    #else
            printf("unix undefined \n");
    #endif
    #if defined(sparc)
            printf("sparc defined \n");
    #else
            printf("sparc undefined \n");
    #endif
    #if defined(i386)
            printf("i386 defined \n");
    #else
            printf("i386 undefined \n");
    #endif
    #if defined(__sun)
            printf("__sun defined \n");
    #else
            printf("__sun undefined \n");
    #endif
    #if defined(__unix)
            printf("__unix defined \n");
    #else
            printf("__unix undefined \n");
    #endif
    #if defined(__SUNPRO_C)
            printf("__SUNPRO_C defined \n");
    #else
            printf("__SUNPRO_C undefined \n");
    #endif
    #if defined(__sparc)
            printf("__sparc defined \n");
    #else
            printf("__sparc undefined \n");
    #endif
    #if defined(__i386)
            printf("__i386 defined \n");
    #else
            printf("__i386 undefined \n");
    #endif
    #if defined(__SVR4)
            printf("__SVR4 defined \n");
    #else
            printf("__SVR4 undefined \n");
    #endif
            return 0;
    }[luoyi@qpd06 test]$ suncc -o test test.c
    [luoyi@qpd06 test]$ ./test
    sun undefined
    unix defined
    sparc undefined
    i386 undefined
    __sun undefined
    __unix defined
    __SUNPRO_C defined
    __sparc undefined
    __i386 undefined
    __SVR4 undefined
    where can I found the correct docs for SunStudio For Linux ?

    You can refer to cc man pages. Here is about predefinitions:
    Predefinitions:unix
    sparc (SPARC)
    i386 (x86)
    sun
    The above are not predefined in -Xc mode.
    These predefinitions are valid in all modes:
    __BUILTIN_VA_ARG_INCR
    __SUNPRO_C=0x590
    __SVR4(SPARC)
    __SunOS(Solaris)
    __SunOS_OSN.N(Solaris)
    __amd64(x86 with-m64)
    __gnu__linux(linux)
    __i386(x86)
    __linux(linux)
    __linux__(linux)
    __sparc(SPARC)
    __sparcv9(with-m64)
    __sun(Solaris)
    __unix
    __�uname -s�_�uname -r�
    __x86_64(x86)
    linux(x86,linux)
    The following is predefined in -Xa and -Xt modes only:
    __RESTRICT
    The compiler also predefines the object-like macro
    __PRAGMA_REDEFINE_EXTNAME,
    to indicate the pragma will be recognized.
    ...

  • RAC with Oracle Linux (Using firewire drive)

    Guys
    Did anyone install RAC (10g or 11g) using Oracle Linux using firewire drive? Does Oracle linux support firewire technology?
    Please share your experience.
    Regards
    PJ

    Start here
    Installing Oracle Database 11g Release 1 on Enterprise Linux 5 (32- and 64-bit)
    http://www.oracle.com/technology/pub/articles/smiley-11gr1-install.html#kernel
    My installation:
    [root@linux3 OCFS2]# uname -a
    Linux linux3 2.6.18-8.el5 #1 SMP Tue Jun 5 23:11:13 EDT 2007 i686 i686 i386 GNU/Linux
    OCFS2
    -rw-r--r-- 1 root root 274826 May 2 17:22 ocfs2-2.6.18-8.el5-1.2.8-2.el5.i686.rpm
    -rw-r--r-- 1 root root 9123303 May 2 17:23 ocfs2-2.6.18-8.el5-debuginfo-1.2.8-2.el5.i686.rpm
    -rw-r--r-- 1 root root 1144294 May 2 17:27 ocfs2-tools-1.2.7-1.el5.i386.rpm
    Others rpms needed in my case after installation
    -rw-r--r-- 1 root root 39297 Jun 7 2007 rsh-server-0.17-37.el5.i386.rpm
    -rw-r--r-- 1 root root 126577 Jun 7 2007 xinetd-2.3.14-10.el5.i386.rpm
    lsmod
    parport 37513 2 lp,parport_pc
    snd_page_alloc 13641 2 snd_intel8x0,snd_pcm
    serio_raw 10693 0
    ohci1394 32964 1
    ieee1394 83252 2 sbp2,ohci1394 <-
    ohci is part of kernel modules !
    ./modules/2.6.18-8.el5/updates/drivers/ieee1394/sbp2.ko
    ext3 123081 1
    jbd 56553 2 ocfs2,ext3
    ehci_hcd 32845 0
    When the driver was loaded succesful looks similar to this, please verify other configuration like serialize_io
    [root@linux3 sysconfig]# dmesg | grep 1394
    ieee1394: no version for "struct_module" found: kernel tainted.
    ohci1394: fw-host0: OHCI-1394 1.1 (PCI): IRQ=[201] MMIO=[ea125000-ea1257ff] Max Packet=[2048] IR/IT contexts=[4/8]
    ieee1394: The root node is not cycle master capable; selecting a new root node and resetting...
    ieee1394: Node added: ID:BUS[0-00:1023] GUID[0030e002e04546d5]
    ieee1394: Host added: ID:BUS[0-01:1023] GUID[001106664001995a]
    ieee1394: sbp2: Driver forced to serialize I/O (serialize_io=1)
    ieee1394: sbp2: Try serialize_io=0 for better performance
    scsi0 : SBP-2 IEEE-1394
    ieee1394: sbp2: Logged into SBP-2 device
    ieee1394: Node 0-00:1023: Max speed [S400] - Max payload [2048]
    and here we are!
    [root@linux3 etc]# fdisk -l
    Disk /dev/hda: 40.0 GB, 40020664320 bytes
    255 heads, 63 sectors/track, 4865 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Device Boot Start End Blocks Id System
    /dev/hda1 1 1824 14651248+ 83 Linux
    /dev/hda2 * 1959 4699 22017082+ 83 Linux
    /dev/hda3 4700 4865 1333395 82 Linux swap / Solaris
    /dev/hda4 1825 1958 1076355 82 Linux swap / Solaris
    Partition table entries are not in disk order
    Disk /dev/sda: 82.3 GB, 82348277760 bytes <= Firewire Disk
    255 heads, 63 sectors/track, 10011 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Device Boot Start End Blocks Id System
    /dev/sda1 1 5000 40162468+ 83 Linux
    /dev/sda2 5001 6217 9775552+ 83 Linux
    /dev/sda3 6218 7434 9775552+ 83 Linux
    /dev/sda4 7435 10011 20699752+ 83 Linux
    Please let me know if you need more information.
    J

  • URGENT Creating database in Linux using RMAN dump of windows

    Hi Everyone,
    I'm having a problem in creating a database in Oracle Enterprise Linux using a database dump of Windows platform.
    I Have the following-
    -->RMAN Backup (for windows database)
    -->Archive log files.
    Using these i've to create the same database (clone) in linux.
    But when i'm try to do this ,everything goes fine except the datafile structures remain same as in windows( like C:\oracle\datafiles\system.dbf instead of /home/oracle/datafiles/system.dbf)
    And also i'm not able to restore the full database.
    Please suggest me the way to accomplish the task.
    Edited by: user8915599 on Jan 11, 2010 10:13 PM

    Hello
    You posted in the wrong forum, you'd better use one of the database forums : http://forums.oracle.com/forums/category.jspa?categoryID=18
    Anaway, regarding your datafile name strucyture you should look after db_file_name_convert in RMAN documentation. As for your other question, please be more precise (which version, what happens, etc).
    But again, post in the right forum and you'll get a ton of answers

  • How connect the oracle/Linux using ODBC

    I want to connect the Oracle which install on Linux using Odbc, so my win98 machine can connect with the oracle.
    But I don't know how to do ? May I install some Odbc driver in the Linux machine? and install odbc driver in my win98 machine?
    my email: [email protected]

    You may use this way:
    1. Start on the server (Linux) Net*8 listener (lsnrctl start)
    2. Install on the client (win98) Net*8 and configure it (Net8 Easy Configuration)
    3. Install on the client (win98) ODBC drivers for ORACLE (by ORACLE or others) and configure it

  • Directory Creation in Unix/Linux  using sysop group.

    Hi All,
    Directory Creation in Linux using sysop group.
    I want to create a directory using sysop group but it default create using root:root
    I have other user called test:test using test:test sysop group i want create directory
    In java using test:test sysop group how to create directory.
    Is it possible i have checked the File API. I did't find any information.
    Please any one help me.
    Thanks
    Venu J

    I find it worrying that you are able to create a root:root file since this implies that you are running your Java program as user root.

  • Migrating database from windows to linux using dbca templates

    Hi every one,
    Is it possible to migrate Oracle10g database from Windows to Linux by using DBCA templates?????????????
    If yes please guide me, as i tried it and am getting error while creating database on linux using DBCA templates of Windows server.
    Warm regards,
    Veeresh.S
    (Oracle DBA)

    With DBCA you can create a new database, delete a database, create ASM, and manage templates.
    There's no option of migrating a database from one platform to the other. If you want to migrate your database from Windows to Linux you have 2 ways of doing it:
    1 using IMP/EXP Export you db on windows and Import it on Linux.
    2 Use across platform transportable tablespace if you db is already on 10g.
    Regards,
    Tony

  • Oracle 11gr2 Software Installation on Linux Using Shell Script

    Hi,
    I have requirement to install Oracle Software on Linux Using shell script, with out any manual entries.
    Thanks,
    loganathan

    Srini_Chavali wrote:
    Pl identify exact version of database and OS.
    Ed - not sure where you looked :-) but response files can certainly be used for an automated installation (which is what I think OP is referring to)
    http://docs.oracle.com/cd/E11882_01/install.112/e24321/app_nonint.htm#BABFEECI
    HTH
    Srini
    You are right.  I must be losing it.  My failure rate lately has been abnormally high.  I don't remember exactly how I searched before .. I thought I opened the Installation Guide an searched for 'silent' in "this document only" -- but all I came up with was references to dbca and emca ... nothing for OUI itself.  Now that I go back and do the same search, there it is.

  • Migrate Oracle 11g database from Windows To Linux using RMAN hot / cold  backup ?

    Hi Friends,
    Is it possible to Migrate Oracle 11g database from Windows To Linux using RMAN hot / cold  backup ? ( as i would like to perform Point In Time recovery)
    (or) The only way is to use RMAN convert as mentioned here  - Transporting Data Across Platforms
    (or) Is there any other method (except exp/imp and data pump)
    Regards,
    DB

    HI
    his post describes the procedure required to migrate a database from Windows to Linux using the RMAN Convert Database command.
    Both Windows and Linux platforms have the same endian format, which makes possible to transfer the whole database, making the migration process very straightforward and simple.
    To migrate between platforms that have a different endian format, Cross Platform Transportable Tablespaces (XTTS) needs to be used instead.
    List of Steps Needed to Complete the Migration
    The migration process is simple, but as it has several steps it is convenient to be familiar with them before running it.
    1. Check platform compatibility between source and target OS
    2. Start the database in read only mode
    3. Check database readiness for transport from Windows to Linux using DBMS_TDB.CHECK_DB
    4. Check if there are any external objects
    5. Execute the Rman Convert database command
    6. Copy converted datafiles, generated Transport Script and Parameter File to Linux
    7. Edit the init.ora for the new database
    8. Edit the Transport Script and Parameter File changing the windows paths to Linux Paths
    9. Execute the Transport Script
    10.Change the Database ID
    11.Check database integrity
    Thank you

  • SunStudio on Linux: C functions are not in std:: namespace

    Hi,
    i'm using SunStudio 12 compilers on a Debian Etch x86 host and have some compilation problems.
    The compilers complains that C functions are not in std:: but only in the global namespace.
    I thought the standard was that they are in both namespaces.
    I suspect the issue may be related to system headers since the problem never occured with Sarge nor Solaris.
    Anyone as some hint to solve this problem ?
    I there a "clean" workaround ?
    Thanks,
    Aurelien

    Let me clarify Paul's comments.
    If you include a C-style header like <stdio.h>, you should get names in both namespace std and in the global namespace.
    That is, the following program should compile with Sun C++: #include <stdio.h>
    int main()
        std::printf("Hello ");
        printf("world!\n");
    }If you include the C++ versions of the C headers, like <cstdio>, using Sun C++ you get names only in namespace std -- except on Linux.
    The g++ compiler, particularly on Linux, does not follow the same rules. The <stdio.h> header puts names only in the global namespace, and <cstdio> puts names in both namespaces. To allow compilation of programs on Linux that compile with g++, Sun C++ tends to follow g++ rules where they are looser than what the C++ Standard says. (For some definition of "looser".)
    The most portable approach is to use the <xxx.h> C-style headers, and do not qualify the names from the headers with "std::".
    That is, the following program should compile everywhere: #include <stdio.h>
    int main()
        printf("Hello ");
        printf("world!\n");
    }

Maybe you are looking for