{"id":1194,"date":"2013-12-10T15:43:56","date_gmt":"2013-12-10T15:43:56","guid":{"rendered":"http:\/\/ri.itservices.manchester.ac.uk\/csf-apps\/?page_id=1194"},"modified":"2017-05-08T12:57:51","modified_gmt":"2017-05-08T12:57:51","slug":"java","status":"publish","type":"page","link":"https:\/\/ri.itservices.manchester.ac.uk\/csf-apps\/software\/applications\/java\/","title":{"rendered":"Java"},"content":{"rendered":"<h2>Overview<\/h2>\n<p>Please read the following information carefully if running java applications on the CSF, whether they be your own code or 3rd-party applications. This is to ensure you use the correct number of threads when running java.<\/p>\n<p>Java Runtime Environment Versions 1.6.0, 1.7.0 and 1.8.0 are installed on the CSF. <\/p>\n<h2>Restrictions on use<\/h2>\n<p>There are no licensing restrictions to running this software. Please note that Java (and the Java compiler) will not run on the login node due to memory restrictions on that node. Please see our <a href=\"\/csf-apps\/software\/applications\/javac\">Java compilation<\/a> notes for more information on compiling Java code.<\/p>\n<h2>Set up procedure<\/h2>\n<p>The default is 1.7.0. It is not strictly necessary to load a modulefile for this version, but you can if you wish:<\/p>\n<pre>\r\nmodule load tools\/java\/1.7.0\r\n<\/pre>\n<p>1.6.0 and 1.8.0 are also available:<\/p>\n<pre>\r\nmodule load tools\/java\/1.6.0\r\nmodule load tools\/java\/1.8.0\r\n<\/pre>\n<h2>Running the application<\/h2>\n<p>Java will not run on the login node and you will receive the following error if you try to run <code>java<\/code> there:<\/p>\n<pre>\r\nError occurred during initialization of VM\r\nCould not reserve enough space for object heap\r\nCould not create the Java virtual machine.\r\n<\/pre>\n<p>Jobs should be submitted to the compute nodes via batch. Note that Java may use several cores for garbage collection unless explicitly instructed not to. See below for how to run serial java code correctly.<\/p>\n<h3>Serial batch job submission<\/h3>\n<p>You must restrict the number of threads used by the java garbage collector otherwise it will attempt to use all of the cores in a node. If you are submitting a serial job then you will be using cores which have not been assigned to your job and will be trampling on other users&#8217; jobs. Please add the following flags to your java command line:<\/p>\n<pre>\r\n-XX:ParallelGCThreads=1 -XX:ParallelCMSThreads=1\r\n<\/pre>\n<p>Java may also try to use more than one core&#8217;s share of the memory in a node. Add the following flag to your java command line to restrict memory usage to 4GB for example (if using a single core on an Intel 64GB compute node). For other nodes, please check the available memory per core and specify that number.<\/p>\n<pre>\r\n-Xmx4G              # 4G tells Java it can use 4 GB of RAM\r\n<\/pre>\n<p>For example, the following jobscript will run a serial java program safely:<\/p>\n<pre>\r\n#!\/bin\/bash\r\n#$ -S \/bin\/bash\r\n#$ -cwd                 # Job runs in current directory - where submitted from\r\n#$ -V                   # Job inherits current environment\r\n\r\njava -XX:ParallelGCThreads=1 -XX:ParallelCMSThreads=1 -Xmx4G my_app_class arg1\r\n\r\n# If you have a .jar file:\r\njava -XX:ParallelGCThreads=1 -XX:ParallelCMSThreads=1 -Xmx4G -jar myapp.jar arg1\r\n<\/pre>\n<p>Submit the jobscript using: <\/p>\n<pre>qsub <em>scriptname<\/em><\/pre>\n<p>where <em>scriptname<\/em> is the name of your jobscript.<\/p>\n<h3>Parallel batch job submission<\/h3>\n<p>If your application uses Java Threads for parallelism then you should submit the job to the <code>smp.pe<\/code> parallel environment and request an appropriate number of cores.<\/p>\n<p>Note that some Java code will use as many threads as possible and there is no way to restrict the number of threads (there is no equivalent of <code>OMP_NUM_THREADS<\/code> in Java). Hence you should submit a 12-core or 16 core parallel job (if running on Intel nodes) as per the examples below. This ensures you will have the entire node to yourself and so do not need to restrict the garbage collection threads or heap size. For example:<\/p>\n<p><strong>12 core job &#8211; westmere compute node<\/strong><\/p>\n<pre>\r\n#!\/bin\/bash\r\n#$ -S \/bin\/bash\r\n#$ -cwd                 # Job runs in current directory - where submitted from\r\n#$ -V                   # Job inherits current environment\r\n#$ -pe smp.pe 12        # Run on all cores on an Intel node\r\n#$ -l westmere          # Run on a westmere Intel node\r\n\r\njava my_parallel_app_class arg1\r\n<\/pre>\n<p><strong>12 core job &#8211; sandybridge compute node<\/strong><\/p>\n<pre>\r\n#!\/bin\/bash\r\n#$ -S \/bin\/bash\r\n#$ -cwd                 # Job runs in current directory - where submitted from\r\n#$ -V                   # Job inherits current environment\r\n#$ -pe smp.pe 12        # Run on all cores on an Intel node\r\n#$ -l sandybridge       # Run on a sandybridge Intel node\r\n\r\njava my_parallel_app_class arg1\r\n<\/pre>\n<p><strong>16 core job &#8211; ivybridge compute node<\/strong><\/p>\n<pre>\r\n#!\/bin\/bash\r\n#$ -S \/bin\/bash\r\n#$ -cwd                 # Job runs in current directory - where submitted from\r\n#$ -V                   # Job inherits current environment\r\n#$ -pe smp.pe 16        # Run on all cores on an Intel node\r\n#$ -l ivybridge         # Run on a sandybridge Intel node\r\n\r\njava my_parallel_app_class arg1\r\n<\/pre>\n<p><strong>12 core job &#8211; highmem compute node<\/strong><\/p>\n<p>This will run on a node that has 8GB per core. It is not possible to request 16 cores. We have a very limited number of this type of node, please do not use this option unless your job genuinely needs a lot of memory.<\/p>\n<pre>\r\n#!\/bin\/bash\r\n#$ -S \/bin\/bash\r\n#$ -cwd                 # Job runs in current directory - where submitted from\r\n#$ -V                   # Job inherits current environment\r\n#$ -pe smp.pe 12        # Run on all cores on an Intel node\r\n#$ -l highmem           # Run on a sandybridge Intel node\r\n\r\njava my_parallel_app_class arg1\r\n<\/pre>\n<p><strong>Which compute node type should I run on?<\/strong><\/p>\n<p>All of the above examples are for all of the possible Intel node types and which of these you use makes very little difference for most java applications. The batch system spreads works as evenly as possible across all the different types of node so no one set of nodes is likely to be busier or quieter than another. Sandybridge or Ivybridge may be slightly faster in terms of run time.<\/p>\n<h2>Further info<\/h2>\n<ul>\n<li><a href=\"\/csf-apps\/software\/applications\/javac\">Javac compiler on the CSF<\/a><\/li>\n<\/ul>\n<h2>Updates<\/h2>\n<p>None.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Overview Please read the following information carefully if running java applications on the CSF, whether they be your own code or 3rd-party applications. This is to ensure you use the correct number of threads when running java. Java Runtime Environment Versions 1.6.0, 1.7.0 and 1.8.0 are installed on the CSF. Restrictions on use There are no licensing restrictions to running this software. Please note that Java (and the Java compiler) will not run on the.. <a href=\"https:\/\/ri.itservices.manchester.ac.uk\/csf-apps\/software\/applications\/java\/\">Read more &raquo;<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"parent":31,"menu_order":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-1194","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf-apps\/wp-json\/wp\/v2\/pages\/1194","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf-apps\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf-apps\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf-apps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf-apps\/wp-json\/wp\/v2\/comments?post=1194"}],"version-history":[{"count":14,"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf-apps\/wp-json\/wp\/v2\/pages\/1194\/revisions"}],"predecessor-version":[{"id":3795,"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf-apps\/wp-json\/wp\/v2\/pages\/1194\/revisions\/3795"}],"up":[{"embeddable":true,"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf-apps\/wp-json\/wp\/v2\/pages\/31"}],"wp:attachment":[{"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf-apps\/wp-json\/wp\/v2\/media?parent=1194"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}