Monday, 25 February 2013

JOMP: Sample Program, Setting ClassPath

Read More about JOMP from website of EPCC

Step1: Download "jomp1.0b.jar" File from Here

Step2: Put it into your directory for example "/home/nishant/JOMP"

Step3: To install JOMP , we just need to add it into CLASSPATH

           For this,
         
           goto your home folder.
           For example user is nishant. so go to nishant's home folder
           type "cd" only to go into user's home folder.
           now we need to edit ".bashrc" file of user.
           Here "." before file indicate that file is hidden (Linux Concepts :) )
         
           now add classpath in .bashrc file by adding following line,

           export CLASSPATH=$CLASSPATH:/home/nishant/JOMP/jomp1.0b.jar

          here my downloaded file is in /home/nishant/JOMP folder. you have to write your own location of downloaded file.


Step4: create a file and write the hello world code as given below. store file with extension .jomp

=============================================

import jomp.runtime.*;
public class Hello {
public static void main (String argv[]) throws Exception
{
int threadID;
//omp parallel private(threadID)
{
threadID = OMP.getThreadNum();
System.out.println("Hello from " + threadID);
}
}
}
=============================================
as class name is Hello ==>store file as===> HELLO.jomp



Step5: Compile the jomp directives first with following command


[nishant@ckpcet JOMP]$ java   jomp.compiler.Jomp   Hello

remember,just give file name without extension


Step6: Compile java file javac

[nishant@ckpcet JOMP]$javac Hello.java


Step7: Execute java file

[nishant@ckpcet JOMP]$ java -Djomp.threads=n Hello

set the no of threads with value of n.



Congratulation for First JOMP application


3 comments:

  1. hello
    i did the same exact steps but is still geting this error when tring to excute
    java jomp.compiler.Jomp Hello
    ***************
    Exception in thread "main" java.lang.NoClassDefFoundError: jomp/compiler/Jomp
    Caused by: java.lang.ClassNotFoundException: jomp.compiler.Jomp
    at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
    Could not find the main class: jomp.compiler.Jomp. Program will exit.

    ReplyDelete
  2. I don't know it should work.
    make check list.
    1)you have properly set classpath in ".bashrc"
    2)you have given extension as ".jomp" not ".java".
    still problem?
    join my at FB for more conversation
    https://www.facebook.com/nishantgandhi99

    ReplyDelete
  3. it works now
    thanks
    i will add you in facebook

    ReplyDelete