Commit a3d9f303 authored by David Hrbáč's avatar David Hrbáč
Browse files

Test source tabs

parent b0e015e3
......@@ -6,7 +6,177 @@ Sample MPI applications provided both as a trivial primer to MPI as well as simp
There are two MPI examples, each using one of six different MPI interfaces:
**Hello world**
###Hello world
```c tab="C"
/*
* Copyright (c) 2004-2006 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2006 Cisco Systems, Inc. All rights reserved.
*
* Sample MPI "hello world" application in C
*/
#include <stdio.h>
#include "mpi.h"
int main(int argc, char* argv[])
{
int rank, size, len;
char version[MPI_MAX_LIBRARY_VERSION_STRING];
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size);
MPI_Get_library_version(version, &len);
printf("Hello, world, I am %d of %d, (%s, %d)\n",
rank, size, version, len);
MPI_Finalize();
return 0;
}
```
```c++ tab="C++"
//
// Copyright (c) 2004-2006 The Trustees of Indiana University and Indiana
// University Research and Technology
// Corporation. All rights reserved.
// Copyright (c) 2006 Cisco Systems, Inc. All rights reserved.
//
// Sample MPI "hello world" application in C++
//
// NOTE: The MPI C++ bindings were deprecated in MPI-2.2 and removed
// from the standard in MPI-3. Open MPI still provides C++ MPI
// bindings, but they are no longer built by default (and may be
// removed in a future version of Open MPI). You must
// --enable-mpi-cxx when configuring Open MPI to enable the MPI C++
// bindings.
//
#include "mpi.h"
#include <iostream>
int main(int argc, char **argv)
{
int rank, size, len;
char version[MPI_MAX_LIBRARY_VERSION_STRING];
MPI::Init();
rank = MPI::COMM_WORLD.Get_rank();
size = MPI::COMM_WORLD.Get_size();
MPI_Get_library_version(version, &len);
std::cout << "Hello, world! I am " << rank << " of " << size
<< "(" << version << ", " << len << ")" << std::endl;
MPI::Finalize();
return 0;
}
```
```fortran tab="F mpi.h"
C
C Copyright (c) 2004-2006 The Trustees of Indiana University and Indiana
C University Research and Technology
C Corporation. All rights reserved.
C Copyright (c) 2006-2015 Cisco Systems, Inc. All rights reserved.
C $COPYRIGHT$
C
C Sample MPI "hello world" application using the Fortran mpif.h
C bindings.
C
program main
implicit none
include 'mpif.h'
integer ierr, rank, size, len
character(len=MPI_MAX_LIBRARY_VERSION_STRING) version
call MPI_INIT(ierr)
call MPI_COMM_RANK(MPI_COMM_WORLD, rank, ierr)
call MPI_COMM_SIZE(MPI_COMM_WORLD, size, ierr)
call MPI_GET_LIBRARY_VERSION(version, len, ierr)
write(*, '("Hello, world, I am ", i2, " of ", i2, ": ", a)')
& rank, size, version
call MPI_FINALIZE(ierr)
end
```
```fortran tab="F use mpi"
!
! Copyright (c) 2004-2006 The Trustees of Indiana University and Indiana
! University Research and Technology
! Corporation. All rights reserved.
! Copyright (c) 2004-2005 The Regents of the University of California.
! All rights reserved.
! Copyright (c) 2006-2015 Cisco Systems, Inc. All rights reserved.
! $COPYRIGHT$
!
! Sample MPI "hello world" application using the Fortran mpi module
! bindings.
!
program main
use mpi
implicit none
integer :: ierr, rank, size, len
character(len=MPI_MAX_LIBRARY_VERSION_STRING) :: version
call MPI_INIT(ierr)
call MPI_COMM_RANK(MPI_COMM_WORLD, rank, ierr)
call MPI_COMM_SIZE(MPI_COMM_WORLD, size, ierr)
call MPI_GET_LIBRARY_VERSION(version, len, ierr)
write(*, '("Hello, world, I am ", i2, " of ", i2, ": ", a)') &
rank, size, version
call MPI_FINALIZE(ierr)
end
```
```java tab="Java"
/*
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
* Author of revised version: Franklyn Pinedo
*
* Adapted from Source Code in C of Tutorial/User's Guide for MPI by
* Peter Pacheco.
*/
/*
* Copyright (c) 2011 Cisco Systems, Inc. All rights reserved.
*
*/
import mpi.*;
class Hello {
static public void main(String[] args) throws MPIException {
MPI.Init(args);
int myrank = MPI.COMM_WORLD.getRank();
int size = MPI.COMM_WORLD.getSize() ;
System.out.println("Hello world from rank " + myrank + " of " + size);
MPI.Finalize();
}
}
```
* C: [hello_c.c](../../src/ompi/hello_c.c)
* C++: [hello_cxx.cc](../../src/ompi/hello_cxx.cc)
......@@ -17,7 +187,7 @@ There are two MPI examples, each using one of six different MPI interfaces:
* C shmem.h: [hello_oshmem_c.c](../../src/ompi/hello_oshmem_c.c)
* Fortran shmem.fh: [hello_oshmemfh.f90](../../src/ompi/hello_oshmemfh.f90)
**Send a trivial message around in a ring**
###Send a trivial message around in a ring
* C: [ring_c.c](../../src/ompi/ring_c.c)
* C++: [ring_cxx.cc](../../src/ompi/ring_cxx.cc)
......@@ -30,7 +200,7 @@ There are two MPI examples, each using one of six different MPI interfaces:
Additionally, there's one further example application, but this one only uses the MPI C bindings:
**Test the connectivity between all processes**
###Test the connectivity between all pross
* C: [connectivity_c.c](../../src/ompi/connectivity_c.c)
......
......@@ -224,6 +224,7 @@ markdown_extensions:
slugify: !!python/name:pymdownx.slugs.uslugify
- pymdownx.snippets:
base_path: docs.it4i/snippets
- pymdownx.superfences
google_analytics:
- 'UA-90498826-1'
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment