Skip to content
Snippets Groups Projects
Commit ad968cd7 authored by David Hrbáč's avatar David Hrbáč
Browse files

Corrections of code highliting

parent 797a929a
No related branches found
No related tags found
5 merge requests!368Update prace.md to document the change from qprace to qprod as the default...,!367Update prace.md to document the change from qprace to qprod as the default...,!366Update prace.md to document the change from qprace to qprod as the default...,!323extended-acls-storage-section,!117Resolve "Ukázky z konzoly nemají být bash"
Pipeline #
......@@ -21,9 +21,9 @@ $ ls -la .ssh/
## Access Privileges on .ssh Folder
* .ssh directory: 700 (drwx------)
* Authorized_keys, known_hosts and public key (.pub file): 644 (-rw-r--r--)
* Private key (id_rsa/id_rsa.ppk): 600 (-rw-------)
* .ssh directory: `700 (drwx------)`
* Authorized_keys, known_hosts and public key (.pub file): `644 (-rw-r--r--)`
* Private key (id_rsa/id_rsa.ppk): `600 (-rw-------)`
```console
$ cd /home/username/
......@@ -40,7 +40,7 @@ $ chmod 600 .ssh/id_rsa.ppk
!!! note
The path to a private key is usually /home/username/.ssh/
Private key file in "id_rsa" or `*.ppk` format is used to authenticate with the servers. Private key is present locally on local side and used for example in SSH agent Pageant (for Windows users). The private key should always be kept in a safe place.
Private key file in `id_rsa` or `*.ppk` format is used to authenticate with the servers. Private key is present locally on local side and used for example in SSH agent Pageant (for Windows users). The private key should always be kept in a safe place.
An example of private key format:
......@@ -76,7 +76,7 @@ An example of private key format:
## Public Key
Public key file in "\*.pub" format is used to verify a digital signature. Public key is present on the remote side and allows access to the owner of the matching private key.
Public key file in `*.pub` format is used to verify a digital signature. Public key is present on the remote side and allows access to the owner of the matching private key.
An example of public key format:
......@@ -107,4 +107,4 @@ In this example, we add an additional public key, stored in file additional_key.
## How to Remove Your Own Key
Removing your key from authorized_keys can be done simply by deleting the corresponding public key which can be identified by a comment at the end of line (eg. _username@organization.example.com_).
Removing your key from authorized_keys can be done simply by deleting the corresponding public key which can be identified by a comment at the end of line (eg. `username@organization.example.com`).
......@@ -99,7 +99,7 @@ Using sshfs, the users Salomon home directory will be mounted on your local comp
Learn more on ssh, scp and sshfs by reading the manpages
```bash
```console
$ man ssh
$ man scp
$ man sshfs
......
......@@ -10,7 +10,7 @@ Available modules
$ ml av phono3py
```
```bash
```console
$ ml phono3py
```
......
......@@ -29,25 +29,25 @@ For information about the usage of Intel Compilers and other Intel products, ple
The Portland Group Cluster Development Kit (PGI CDK) is available.
```bash
$ module load PGI
$ pgcc -v
$ pgc++ -v
$ pgf77 -v
$ pgf90 -v
$ pgf95 -v
$ pghpf -v
```console
$ module load PGI
$ pgcc -v
$ pgc++ -v
$ pgf77 -v
$ pgf90 -v
$ pgf95 -v
$ pghpf -v
```
The PGI CDK also incudes tools for debugging and profiling.
PGDBG OpenMP/MPI debugger and PGPROF OpenMP/MPI profiler are available
```bash
$ module load PGI
$ module load Java
$ pgdbg &
$ pgprof &
```console
$ module load PGI
$ module load Java
$ pgdbg &
$ pgprof &
```
For more information, see the [PGI page](http://www.pgroup.com/products/pgicdk.htm).
......@@ -58,21 +58,21 @@ For compatibility reasons there are still available the original (old 4.4.7-11)
It is strongly recommended to use the up to date version which comes with the module GCC:
```bash
$ module load GCC
$ gcc -v
$ g++ -v
$ gfortran -v
```console
$ module load GCC
$ gcc -v
$ g++ -v
$ gfortran -v
```
With the module loaded two environment variables are predefined. One for maximum optimizations on the cluster's architecture, and the other for debugging purposes:
```bash
$ echo $OPTFLAGS
-O3 -march=native
```console
$ echo $OPTFLAGS
-O3 -march=native
$ echo $DEBUGFLAGS
-O0 -g
$ echo $DEBUGFLAGS
-O0 -g
```
For more information about the possibilities of the compilers, please see the man pages.
......@@ -88,41 +88,41 @@ UPC is supported by two compiler/runtime implementations:
To use the GNU UPC compiler and run the compiled binaries use the module gupc
```bash
$ module add gupc
$ gupc -v
$ g++ -v
```console
$ module add gupc
$ gupc -v
$ g++ -v
```
Simple program to test the compiler
```bash
$ cat count.upc
/* hello.upc - a simple UPC example */
#include <upc.h>
#include <stdio.h>
int main() {
if (MYTHREAD == 0) {
printf("Welcome to GNU UPC!!!n");
}
upc_barrier;
printf(" - Hello from thread %in", MYTHREAD);
return 0;
}
```upc
$ cat count.upc
/* hello.upc - a simple UPC example */
#include <upc.h>
#include <stdio.h>
int main() {
if (MYTHREAD == 0) {
printf("Welcome to GNU UPC!!!n");
}
upc_barrier;
printf(" - Hello from thread %in", MYTHREAD);
return 0;
}
```
To compile the example use
```bash
$ gupc -o count.upc.x count.upc
```console
$ gupc -o count.upc.x count.upc
```
To run the example with 5 threads issue
```bash
$ ./count.upc.x -fupc-threads-5
```console
$ ./count.upc.x -fupc-threads-5
```
For more information see the man pages.
......@@ -131,9 +131,9 @@ For more information see the man pages.
To use the Berkley UPC compiler and runtime environment to run the binaries use the module bupc
```bash
$ module add BerkeleyUPC/2.16.2-gompi-2015b
$ upcc -version
```console
$ module add BerkeleyUPC/2.16.2-gompi-2015b
$ upcc -version
```
As default UPC network the "smp" is used. This is very quick and easy way for testing/debugging, but limited to one node only.
......@@ -145,41 +145,41 @@ For production runs, it is recommended to use the native InfiniBand implementati
Example UPC code:
```bash
$ cat hello.upc
/* hello.upc - a simple UPC example */
#include <upc.h>
#include <stdio.h>
int main() {
if (MYTHREAD == 0) {
printf("Welcome to Berkeley UPC!!!n");
}
upc_barrier;
printf(" - Hello from thread %in", MYTHREAD);
return 0;
}
```upc
$ cat hello.upc
/* hello.upc - a simple UPC example */
#include <upc.h>
#include <stdio.h>
int main() {
if (MYTHREAD == 0) {
printf("Welcome to Berkeley UPC!!!n");
}
upc_barrier;
printf(" - Hello from thread %in", MYTHREAD);
return 0;
}
```
To compile the example with the "ibv" UPC network use
```bash
$ upcc -network=ibv -o hello.upc.x hello.upc
```console
$ upcc -network=ibv -o hello.upc.x hello.upc
```
To run the example with 5 threads issue
```bash
$ upcrun -n 5 ./hello.upc.x
```console
$ upcrun -n 5 ./hello.upc.x
```
To run the example on two compute nodes using all 48 cores, with 48 threads, issue
```bash
$ qsub -I -q qprod -A PROJECT_ID -l select=2:ncpus=24
$ module add bupc
$ upcrun -n 48 ./hello.upc.x
```console
$ qsub -I -q qprod -A PROJECT_ID -l select=2:ncpus=24
$ module add bupc
$ upcrun -n 48 ./hello.upc.x
```
For more information see the man pages.
......
......@@ -154,7 +154,7 @@ export OFFLOAD_REPORT=3
A very basic example of code that employs offload programming technique is shown in the next listing. Please note that this code is sequential and utilizes only single core of the accelerator.
```console
```cpp
$ cat source-offload.cpp
#include <iostream>
......@@ -190,7 +190,7 @@ $ ./bin-offload
One way of paralelization a code for Xeon Phi is using OpenMP directives. The following example shows code for parallel vector addition.
```console
```cpp
$ cat ./vect-add
#include <stdio.h>
......@@ -317,7 +317,7 @@ $ ml intel
The code can be copied to a file and compiled without any necessary modification.
```console
```cpp
$ vim sgemm-ao-short.c
#include <stdio.h>
......@@ -816,7 +816,7 @@ $ mpirun -genv LD_LIBRARY_PATH $MIC_LD_LIBRARY_PATH -host mic0 -n 4 ~/mpi-test-m
or using mpirun
```bash
```console
$ mpirun -genv LD_LIBRARY_PATH $MIC_LD_LIBRARY_PATH -host mic0 -n 4 ~/mpi-test-mic
```
......@@ -899,7 +899,7 @@ $ mpirun -genv LD_LIBRARY_PATH \
In this case four MPI processes are executed on accelerator cn204-mic and six processes are executed on accelerator cn205-mic0. The sample output (sorted after execution) is:
```bash
```console
Hello world from process 0 of 10 on host r25u25n710-mic0
Hello world from process 1 of 10 on host r25u25n710-mic0
Hello world from process 2 of 10 on host r25u25n710-mic0
......
......@@ -45,25 +45,25 @@ To run R in batch mode, write an R script, then write a bash jobscript and execu
Example jobscript:
```bash
#!/bin/bash
#!/bin/bash
# change to local scratch directory
cd /lscratch/$PBS_JOBID || exit
# change to local scratch directory
cd /lscratch/$PBS_JOBID || exit
# copy input file to scratch
cp $PBS_O_WORKDIR/rscript.R .
# copy input file to scratch
cp $PBS_O_WORKDIR/rscript.R .
# load R module
module load R
# load R module
module load R
# execute the calculation
R CMD BATCH rscript.R routput.out
# execute the calculation
R CMD BATCH rscript.R routput.out
# copy output file to home
cp routput.out $PBS_O_WORKDIR/.
# copy output file to home
cp routput.out $PBS_O_WORKDIR/.
#exit
exit
#exit
exit
```
This script may be submitted directly to the PBS workload manager via the qsub command. The inputs are in rscript.R file, outputs in routput.out file. See the single node jobscript example in the [Job execution section](../../job-submission-and-execution/).
......@@ -79,16 +79,16 @@ The package parallel provides support for parallel computation, including by for
The package is activated this way:
```console
$ R
> library(parallel)
$ R
> library(parallel)
```
More information and examples may be obtained directly by reading the documentation available in R
```console
> ?parallel
> library(help = "parallel")
> vignette("parallel")
> ?parallel
> library(help = "parallel")
> vignette("parallel")
```
Download the package [parallell](package-parallel-vignette.pdf) vignette.
......@@ -103,41 +103,41 @@ The forking is the most simple to use. Forking family of functions provide paral
Forking example:
```cpp
library(parallel)
library(parallel)
#integrand function
f <- function(i,h) {
x <- h*(i-0.5)
return (4/(1 + x*x))
}
#integrand function
f <- function(i,h) {
x <- h*(i-0.5)
return (4/(1 + x*x))
}
#initialize
size <- detectCores()
#initialize
size <- detectCores()
while (TRUE)
{
#read number of intervals
cat("Enter the number of intervals: (0 quits) ")
fp<-file("stdin"); n<-scan(fp,nmax=1); close(fp)
while (TRUE)
{
#read number of intervals
cat("Enter the number of intervals: (0 quits) ")
fp<-file("stdin"); n<-scan(fp,nmax=1); close(fp)
if(n<=0) break
if(n<=0) break
#run the calculation
n <- max(n,size)
h <- 1.0/n
#run the calculation
n <- max(n,size)
h <- 1.0/n
i <- seq(1,n);
pi3 <- h*sum(simplify2array(mclapply(i,f,h,mc.cores=size)));
i <- seq(1,n);
pi3 <- h*sum(simplify2array(mclapply(i,f,h,mc.cores=size)));
#print results
cat(sprintf("Value of PI %16.14f, diff= %16.14fn",pi3,pi3-pi))
}
#print results
cat(sprintf("Value of PI %16.14f, diff= %16.14fn",pi3,pi3-pi))
}
```
The above example is the classic parallel example for calculating the number π. Note the **detectCores()** and **mclapply()** functions. Execute the example as:
```bash
$ R --slave --no-save --no-restore -f pi3p.R
```console
$ R --slave --no-save --no-restore -f pi3p.R
```
Every evaluation of the integrad function runs in parallel on different process.
......@@ -300,51 +300,51 @@ Execution is identical to other dynamic Rmpi programs.
mpi.apply Rmpi example:
```cpp
#integrand function
f <- function(i,h) {
x <- h*(i-0.5)
return (4/(1 + x*x))
}
#the worker function
workerpi <- function(rank,size,n)
{
#run the calculation
n <- max(n,size)
h <- 1.0/n
i <- seq(rank,n,size);
mypi <- h*sum(sapply(i,f,h));
return(mypi)
}
#main
library(Rmpi)
cat("Enter the number of slaves: ")
fp<-file("stdin"); ns<-scan(fp,nmax=1); close(fp)
mpi.spawn.Rslaves(nslaves=ns)
mpi.bcast.Robj2slave(f)
mpi.bcast.Robj2slave(workerpi)
while (TRUE)
{
#read number of intervals
cat("Enter the number of intervals: (0 quits) ")
fp<-file("stdin"); n<-scan(fp,nmax=1); close(fp)
if(n<=0) break
#run workerpi
i=seq(1,2*ns)
pi3=sum(mpi.parSapply(i,workerpi,2*ns,n))
#print results
cat(sprintf("Value of PI %16.14f, diff= %16.14fn",pi3,pi3-pi))
}
mpi.quit()
#integrand function
f <- function(i,h) {
x <- h*(i-0.5)
return (4/(1 + x*x))
}
#the worker function
workerpi <- function(rank,size,n)
{
#run the calculation
n <- max(n,size)
h <- 1.0/n
i <- seq(rank,n,size);
mypi <- h*sum(sapply(i,f,h));
return(mypi)
}
#main
library(Rmpi)
cat("Enter the number of slaves: ")
fp<-file("stdin"); ns<-scan(fp,nmax=1); close(fp)
mpi.spawn.Rslaves(nslaves=ns)
mpi.bcast.Robj2slave(f)
mpi.bcast.Robj2slave(workerpi)
while (TRUE)
{
#read number of intervals
cat("Enter the number of intervals: (0 quits) ")
fp<-file("stdin"); n<-scan(fp,nmax=1); close(fp)
if(n<=0) break
#run workerpi
i=seq(1,2*ns)
pi3=sum(mpi.parSapply(i,workerpi,2*ns,n))
#print results
cat(sprintf("Value of PI %16.14f, diff= %16.14fn",pi3,pi3-pi))
}
mpi.quit()
```
The above is the mpi.apply MPI example for calculating the number π. Only the slave processes carry out the calculation. Note the **mpi.parSapply()**, function call. The package parallel [example](r/#package-parallel) [above](r/#package-parallel) may be trivially adapted (for much better performance) to this structure using the mclapply() in place of mpi.parSapply().
......@@ -366,30 +366,30 @@ The R parallel jobs are executed via the PBS queue system exactly as any other p
Example jobscript for [static Rmpi](r/#static-rmpi) parallel R execution, running 1 process per core:
```bash
#!/bin/bash
#PBS -q qprod
#PBS -N Rjob
#PBS -l select=100:ncpus=24:mpiprocs=24:ompthreads=1
#!/bin/bash
#PBS -q qprod
#PBS -N Rjob
#PBS -l select=100:ncpus=24:mpiprocs=24:ompthreads=1
# change to scratch directory
SCRDIR=/scratch/work/user/$USER/myjob
cd $SCRDIR || exit
# change to scratch directory
SCRDIR=/scratch/work/user/$USER/myjob
cd $SCRDIR || exit
# copy input file to scratch
cp $PBS_O_WORKDIR/rscript.R .
# copy input file to scratch
cp $PBS_O_WORKDIR/rscript.R .
# load R and openmpi module
module load R
module load OpenMPI
# load R and openmpi module
module load R
module load OpenMPI
# execute the calculation
mpiexec -bycore -bind-to-core R --slave --no-save --no-restore -f rscript.R
# execute the calculation
mpiexec -bycore -bind-to-core R --slave --no-save --no-restore -f rscript.R
# copy output file to home
cp routput.out $PBS_O_WORKDIR/.
# copy output file to home
cp routput.out $PBS_O_WORKDIR/.
#exit
exit
#exit
exit
```
For more information about jobscripts and MPI execution refer to the [Job submission](../../job-submission-and-execution/) and general [MPI](../mpi/mpi/) sections.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment