shmem-fortran fix, naming conventions for shmem option, examples
This commit was SVN r29518.
Этот коммит содержится в:
родитель
a4ae1705dd
Коммит
5cc1f3803b
@ -39,28 +39,28 @@ AC_DEFINE_UNQUOTED([OSHMEM_SPEC_COMPAT], [$OSHMEM_SPEC_COMPAT],
|
|||||||
#
|
#
|
||||||
# Do we want to disable OSHMEM parameter checking at run-time?
|
# Do we want to disable OSHMEM parameter checking at run-time?
|
||||||
#
|
#
|
||||||
AC_MSG_CHECKING([if want SHMEM API parameter checking])
|
AC_MSG_CHECKING([if want OSHMEM API parameter checking])
|
||||||
AC_ARG_WITH(shmem-param-check,
|
AC_ARG_WITH(oshmem-param-check,
|
||||||
AC_HELP_STRING([--shmem-param-check(=VALUE)],
|
AC_HELP_STRING([--oshmem-param-check(=VALUE)],
|
||||||
[behavior of SHMEM function parameter checking. Valid values are: always, never. If --with-shmem-param-check is specified with no VALUE argument, it is equivalent to a VALUE of "always"; --without-shmem-param-check is equivalent to "never" (default: always).]))
|
[behavior of OSHMEM API function parameter checking. Valid values are: always, never. If --with-oshmem-param-check is specified with no VALUE argument, it is equivalent to a VALUE of "always"; --without-oshmem-param-check is equivalent to "never" (default: always).]))
|
||||||
shmem_param_check=1
|
shmem_param_check=1
|
||||||
if test "$with_shmem_param_check" = "no" -o \
|
if test "$with_oshmem_param_check" = "no" -o \
|
||||||
"$with_shmem_param_check" = "never"; then
|
"$with_oshmem_param_check" = "never"; then
|
||||||
shmem_param_check=0
|
shmem_param_check=0
|
||||||
AC_MSG_RESULT([never])
|
AC_MSG_RESULT([never])
|
||||||
elif test "$with_shmem_param_check" = "yes" -o \
|
elif test "$with_oshmem_param_check" = "yes" -o \
|
||||||
"$with_shmem_param_check" = "always" -o \
|
"$with_oshmem_param_check" = "always" -o \
|
||||||
-z "$with_shmem_param_check"; then
|
-z "$with_oshmem_param_check"; then
|
||||||
shmem_param_check=1
|
shmem_param_check=1
|
||||||
AC_MSG_RESULT([always])
|
AC_MSG_RESULT([always])
|
||||||
else
|
else
|
||||||
AC_MSG_RESULT([unknown])
|
AC_MSG_RESULT([unknown])
|
||||||
AC_MSG_WARN([*** Unrecognized --with-shmem-param-check value])
|
AC_MSG_WARN([*** Unrecognized --with-oshmem-param-check value])
|
||||||
AC_MSG_WARN([*** See "configure --help" output])
|
AC_MSG_WARN([*** See "configure --help" output])
|
||||||
AC_MSG_WARN([*** Defaulting to "runtime"])
|
AC_MSG_WARN([*** Defaulting to "runtime"])
|
||||||
fi
|
fi
|
||||||
AC_DEFINE_UNQUOTED(OSHMEM_PARAM_CHECK, $shmem_param_check,
|
AC_DEFINE_UNQUOTED(OSHMEM_PARAM_CHECK, $shmem_param_check,
|
||||||
[Whether we want to check SHMEM parameters always or never])
|
[Whether we want to check OSHMEM parameters always or never])
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -85,15 +85,18 @@ AM_CONDITIONAL(OSHMEM_PROFILING, test "$oshmem_profiling_support" = 1)
|
|||||||
AC_ARG_ENABLE(oshmem-fortran,
|
AC_ARG_ENABLE(oshmem-fortran,
|
||||||
AC_HELP_STRING([--enable-oshmem-fortran],
|
AC_HELP_STRING([--enable-oshmem-fortran],
|
||||||
[enable OSHMEM Fortran bindings (default: enabled if Fortran compiler found)]))
|
[enable OSHMEM Fortran bindings (default: enabled if Fortran compiler found)]))
|
||||||
if test "$enable_oshmem_fortran" != "no"; then
|
AS_IF([test $OMPI_WANT_FORTRAN_BINDINGS -eq 1],
|
||||||
|
[if test "$enable_oshmem_fortran" != "no"; then
|
||||||
AC_MSG_RESULT([yes])
|
AC_MSG_RESULT([yes])
|
||||||
OSHMEM_WANT_FORTRAN_BINDINGS=1
|
OSHMEM_WANT_FORTRAN_BINDINGS=1
|
||||||
else
|
else
|
||||||
AC_MSG_RESULT([no])
|
AC_MSG_RESULT([no])
|
||||||
OSHMEM_WANT_FORTRAN_BINDINGS=0
|
OSHMEM_WANT_FORTRAN_BINDINGS=0
|
||||||
fi
|
fi],
|
||||||
|
[AC_MSG_RESULT([no])
|
||||||
|
OSHMEM_WANT_FORTRAN_BINDINGS=0])
|
||||||
|
|
||||||
AC_MSG_CHECKING([if want to build SHMEM fortran bindings])
|
AC_MSG_CHECKING([if want to build OSHMEM fortran bindings])
|
||||||
AM_CONDITIONAL(OSHMEM_WANT_FORTRAN_BINDINGS,
|
AM_CONDITIONAL(OSHMEM_WANT_FORTRAN_BINDINGS,
|
||||||
[test $OSHMEM_WANT_FORTRAN_BINDINGS -eq 1])
|
[test $OSHMEM_WANT_FORTRAN_BINDINGS -eq 1])
|
||||||
AS_IF([test $OSHMEM_WANT_FORTRAN_BINDINGS -eq 1],
|
AS_IF([test $OSHMEM_WANT_FORTRAN_BINDINGS -eq 1],
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
# Copyright (c) 2006-2007 Sun Microsystems, Inc. All rights reserved.
|
# Copyright (c) 2006-2007 Sun Microsystems, Inc. All rights reserved.
|
||||||
# Copyright (c) 2011-2012 Cisco Systems, Inc. All rights reserved.
|
# Copyright (c) 2011-2012 Cisco Systems, Inc. All rights reserved.
|
||||||
# Copyright (c) 2012 Los Alamos National Security, Inc. All rights reserved.
|
# Copyright (c) 2012 Los Alamos National Security, Inc. All rights reserved.
|
||||||
|
# Copyright (c) 2013 Mellanox Technologies, Inc. All rights reserved.
|
||||||
# $COPYRIGHT$
|
# $COPYRIGHT$
|
||||||
#
|
#
|
||||||
# Additional copyrights may follow
|
# Additional copyrights may follow
|
||||||
@ -28,7 +29,9 @@ CXX = mpic++
|
|||||||
CCC = mpic++
|
CCC = mpic++
|
||||||
FC = mpifort
|
FC = mpifort
|
||||||
JAVAC = mpijavac
|
JAVAC = mpijavac
|
||||||
SHMEM = shmemcc
|
SHMEMCC = shmemcc
|
||||||
|
SHMEMFC = shmemfort
|
||||||
|
|
||||||
# Using -g is not necessary, but it is helpful for example programs,
|
# Using -g is not necessary, but it is helpful for example programs,
|
||||||
# especially if users want to examine them with debuggers. Note that
|
# especially if users want to examine them with debuggers. Note that
|
||||||
# gmake requires the CXXFLAGS macro, while other versions of make
|
# gmake requires the CXXFLAGS macro, while other versions of make
|
||||||
@ -48,12 +51,16 @@ EXAMPLES = \
|
|||||||
hello_usempi \
|
hello_usempi \
|
||||||
hello_usempif08 \
|
hello_usempif08 \
|
||||||
hello_shmem \
|
hello_shmem \
|
||||||
|
hello_shmemfh \
|
||||||
Hello.class \
|
Hello.class \
|
||||||
ring_c \
|
ring_c \
|
||||||
ring_cxx \
|
ring_cxx \
|
||||||
ring_mpifh \
|
ring_mpifh \
|
||||||
ring_usempi \
|
ring_usempi \
|
||||||
ring_usempif08 \
|
ring_usempif08 \
|
||||||
|
ring_shmem \
|
||||||
|
ring_shmemfh \
|
||||||
|
ring_shmemf90 \
|
||||||
Ring.class \
|
Ring.class \
|
||||||
connectivity_c
|
connectivity_c
|
||||||
|
|
||||||
@ -78,6 +85,10 @@ all: hello_c ring_c connectivity_c
|
|||||||
fi
|
fi
|
||||||
@ if ompi_info --parsable | grep mca:shmem >/dev/null; then \
|
@ if ompi_info --parsable | grep mca:shmem >/dev/null; then \
|
||||||
$(MAKE) hello_shmem; \
|
$(MAKE) hello_shmem; \
|
||||||
|
$(MAKE) hello_shmemfh; \
|
||||||
|
$(MAKE) ring_shmem; \
|
||||||
|
$(MAKE) ring_shmemfh; \
|
||||||
|
$(MAKE) ring_shmemf90; \
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# The usual "clean" target
|
# The usual "clean" target
|
||||||
@ -107,7 +118,15 @@ Hello.class: Hello.java
|
|||||||
Ring.class: Ring.java
|
Ring.class: Ring.java
|
||||||
$(JAVAC) Ring.java
|
$(JAVAC) Ring.java
|
||||||
|
|
||||||
hello_shmem: hello_shmem.c
|
hello_shmem: hello_shmem_c.c
|
||||||
$(SHMEM) $(CFLAGS) $^ -o $@
|
$(SHMEMCC) $(CFLAGS) $^ -o $@
|
||||||
|
hello_shmemfh: hello_shmemfh.f
|
||||||
|
$(SHMEMFC) $(FCFLAGS) $^ -o $@
|
||||||
|
|
||||||
|
ring_shmem: ring_shmem_c.c
|
||||||
|
$(SHMEMCC) $(CFLAGS) $^ -o $@
|
||||||
|
ring_shmemfh: ring_shmemfh.f
|
||||||
|
$(SHMEMFC) $(FCFLAGS) $^ -o $@
|
||||||
|
ring_shmemf90: ring_shmem.f90
|
||||||
|
$(SHMEMFC) $(FCFLAGS) $^ -o $@
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
# Copyright (c) 2006-2012 Cisco Systems, Inc. All rights reserved.
|
# Copyright (c) 2006-2012 Cisco Systems, Inc. All rights reserved.
|
||||||
# Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved.
|
# Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved.
|
||||||
# Copyright (c) 2012 Los Alamos National Security, Inc. All rights reserved.
|
# Copyright (c) 2012 Los Alamos National Security, Inc. All rights reserved.
|
||||||
|
# Copyright (c) 2013 Mellanox Technologies, Inc. All rights reserved.
|
||||||
# $COPYRIGHT$
|
# $COPYRIGHT$
|
||||||
#
|
#
|
||||||
# Additional copyrights may follow
|
# Additional copyrights may follow
|
||||||
@ -37,11 +38,16 @@ EXTRA_DIST += \
|
|||||||
examples/hello_mpifh.f \
|
examples/hello_mpifh.f \
|
||||||
examples/hello_usempi.f90 \
|
examples/hello_usempi.f90 \
|
||||||
examples/hello_usempif08.f90 \
|
examples/hello_usempif08.f90 \
|
||||||
|
examples/hello_shmem_c.c \
|
||||||
|
examples/hello_shmemfh.f \
|
||||||
examples/ring_c.c \
|
examples/ring_c.c \
|
||||||
examples/ring_cxx.cc \
|
examples/ring_cxx.cc \
|
||||||
examples/ring_mpifh.f \
|
examples/ring_mpifh.f \
|
||||||
examples/ring_usempi.f90 \
|
examples/ring_usempi.f90 \
|
||||||
examples/ring_usempif08.f90 \
|
examples/ring_usempif08.f90 \
|
||||||
|
examples/ring_shmem_c.c \
|
||||||
|
examples/ring_shmemfh.f \
|
||||||
|
examples/ring_shmem.f90 \
|
||||||
examples/connectivity_c.c \
|
examples/connectivity_c.c \
|
||||||
examples/Hello.java \
|
examples/Hello.java \
|
||||||
examples/Ring.java
|
examples/Ring.java
|
||||||
|
@ -4,6 +4,7 @@ Copyright (c) 2004-2006 The Trustees of Indiana University and Indiana
|
|||||||
Copyright (c) 2006-2012 Cisco Systems, Inc. All rights reserved.
|
Copyright (c) 2006-2012 Cisco Systems, Inc. All rights reserved.
|
||||||
Copyright (c) 2007-2009 Sun Microsystems, Inc. All rights reserved.
|
Copyright (c) 2007-2009 Sun Microsystems, Inc. All rights reserved.
|
||||||
Copyright (c) 2010 Oracle and/or its affiliates. All rights reserved.
|
Copyright (c) 2010 Oracle and/or its affiliates. All rights reserved.
|
||||||
|
Copyright (c) 2013 Mellanox Technologies, Inc. All rights reserved.
|
||||||
|
|
||||||
$COPYRIGHT$
|
$COPYRIGHT$
|
||||||
|
|
||||||
@ -20,7 +21,7 @@ Get a free account and login; you can then browse to the list of
|
|||||||
available courses. Look for the ones with "MPI" in the title.
|
available courses. Look for the ones with "MPI" in the title.
|
||||||
|
|
||||||
There are two MPI examples in this directory, each using one of six
|
There are two MPI examples in this directory, each using one of six
|
||||||
different MPI interfaces:
|
different MPI interfaces:
|
||||||
|
|
||||||
- Hello world
|
- Hello world
|
||||||
C: hello_c.c
|
C: hello_c.c
|
||||||
@ -29,7 +30,8 @@ different MPI interfaces:
|
|||||||
Fortran use mpi: hello_usempi.f90
|
Fortran use mpi: hello_usempi.f90
|
||||||
Fortran use mpi_f08: hello_usempif08.f90
|
Fortran use mpi_f08: hello_usempif08.f90
|
||||||
Java: Hello.java
|
Java: Hello.java
|
||||||
OSHMEM: hello_shmem.c
|
C shmem.h: hello_shmem_c.c
|
||||||
|
Fortran shmemfh.f: hello_shmemfh.f
|
||||||
|
|
||||||
- Send a trivial message around in a ring
|
- Send a trivial message around in a ring
|
||||||
C: ring_c.c
|
C: ring_c.c
|
||||||
@ -38,6 +40,9 @@ different MPI interfaces:
|
|||||||
Fortran use mpi: ring_usempi.f90
|
Fortran use mpi: ring_usempi.f90
|
||||||
Fortran use mpi_f08: ring_usempif08.f90
|
Fortran use mpi_f08: ring_usempif08.f90
|
||||||
Java: Ring.java
|
Java: Ring.java
|
||||||
|
C shmem.h: ring_shmem_c.c
|
||||||
|
Fortran shmemfh.f: ring_shmemfh.f
|
||||||
|
F90 shmemfh.f: ring_shmem.f90
|
||||||
|
|
||||||
Additionally, there's one further example application, but this one
|
Additionally, there's one further example application, but this one
|
||||||
only uses the MPI C bindings:
|
only uses the MPI C bindings:
|
||||||
|
@ -1,128 +0,0 @@
|
|||||||
#include "shmem.h"
|
|
||||||
#include "stdio.h"
|
|
||||||
|
|
||||||
#define N 100
|
|
||||||
static int target[N];
|
|
||||||
|
|
||||||
static int source[N];
|
|
||||||
|
|
||||||
#define STATIC_CHECK 1
|
|
||||||
#define DYNAMIC_CHECK 1
|
|
||||||
#define ATOMIC 1
|
|
||||||
#define PEER 1
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
int *source_d,*target_d;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
start_pes(0);
|
|
||||||
|
|
||||||
source_d = shmalloc(sizeof(*source_d)*N);
|
|
||||||
target_d = shmalloc(sizeof(*target_d)*N);
|
|
||||||
|
|
||||||
for (i = 0; i < N; i++)
|
|
||||||
{
|
|
||||||
source_d[i] = source[i] = 1;
|
|
||||||
target[i] = target_d[i] = 9;
|
|
||||||
}
|
|
||||||
|
|
||||||
int peer = PEER;
|
|
||||||
if (_my_pe() == 0)
|
|
||||||
{
|
|
||||||
#if STATIC_CHECK
|
|
||||||
int c, f;
|
|
||||||
int a = c, b = f;
|
|
||||||
#if ATOMIC
|
|
||||||
for (i = 0; i < N; i++)
|
|
||||||
target[i] = shmem_int_g(source + i, peer);
|
|
||||||
#else
|
|
||||||
shmem_int_get(target, source, N, PEER);
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if DYNAMIC_CHECK
|
|
||||||
#if ATOMIC
|
|
||||||
for (i = 0; i < N; i++)
|
|
||||||
{
|
|
||||||
target_d[i] = shmem_int_g(source_d + i, peer);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
shmem_int_get(target_d, source_d, N, PEER);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
if(_my_pe() == 0)
|
|
||||||
{
|
|
||||||
for (i = 0; i < N; i++)
|
|
||||||
{
|
|
||||||
#if DYNAMIC_CHECK
|
|
||||||
if(target_d[i] != 1)
|
|
||||||
{
|
|
||||||
printf("Get dynamic error %d, target + i = %p, target[0] = %d, target[1] = %d\n",i, target_d + i,target_d[0], target_d[1]);
|
|
||||||
fflush(stdout);
|
|
||||||
return 1;
|
|
||||||
#endif
|
|
||||||
#if STATIC_CHECK
|
|
||||||
if (target[i] != 1)
|
|
||||||
{
|
|
||||||
printf("Get static error %d, target + i = %p, target[i] = %d\n",i, target + i,target[i]);
|
|
||||||
fflush(stdout);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*put check*/
|
|
||||||
|
|
||||||
for (i = 0; i < N; i++)
|
|
||||||
{
|
|
||||||
source_d[i] = source[i] = 1;
|
|
||||||
target[i] = target_d[i] = -9;
|
|
||||||
}
|
|
||||||
|
|
||||||
shmem_barrier_all();
|
|
||||||
|
|
||||||
if (_my_pe() == 0)
|
|
||||||
{
|
|
||||||
#if STATIC_CHECK
|
|
||||||
shmem_int_put(target, source, N, PEER);
|
|
||||||
#endif
|
|
||||||
#if DYNAMIC_CHECK
|
|
||||||
shmem_int_put(target_d, source_d, N, PEER);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
shmem_barrier_all();
|
|
||||||
|
|
||||||
if(_my_pe() == PEER)
|
|
||||||
{
|
|
||||||
for (i = 0; i < N; i++)
|
|
||||||
{
|
|
||||||
#if DYNAMIC_CHECK
|
|
||||||
if(target_d[i] != 1)
|
|
||||||
{
|
|
||||||
printf("Put dynamic error\n");
|
|
||||||
fflush(stdout);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#if STATIC_CHECK
|
|
||||||
if (target[i] != 1)
|
|
||||||
{
|
|
||||||
printf("Put static error\n");
|
|
||||||
fflush(stdout);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
printf("All test passed\n");fflush(stdout);
|
|
||||||
shmem_finalize();
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
26
examples/hello_shmem_c.c
Обычный файл
26
examples/hello_shmem_c.c
Обычный файл
@ -0,0 +1,26 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2013 Mellanox Technologies, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
* $COPYRIGHT$
|
||||||
|
*
|
||||||
|
* Additional copyrights may follow
|
||||||
|
*
|
||||||
|
* $HEADER$
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "shmem.h"
|
||||||
|
|
||||||
|
int main(int argc, char* argv[])
|
||||||
|
{
|
||||||
|
int proc, nproc;
|
||||||
|
|
||||||
|
start_pes(0);
|
||||||
|
nproc = _num_pes();
|
||||||
|
proc = _my_pe();
|
||||||
|
|
||||||
|
printf("Hello, world, I am %d of %d\n",
|
||||||
|
proc, nproc);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
19
examples/hello_shmemfh.f
Обычный файл
19
examples/hello_shmemfh.f
Обычный файл
@ -0,0 +1,19 @@
|
|||||||
|
C *
|
||||||
|
C * Copyright (c) 2013 Mellanox Technologies, Inc.
|
||||||
|
C * All rights reserved.
|
||||||
|
C * $COPYRIGHT$
|
||||||
|
C *
|
||||||
|
C * Additional copyrights may follow
|
||||||
|
C *
|
||||||
|
C * $HEADER$
|
||||||
|
C *
|
||||||
|
|
||||||
|
program main
|
||||||
|
integer proc, nproc
|
||||||
|
call START_PES(0)
|
||||||
|
proc = MY_PE()
|
||||||
|
nproc = NUM_PES()
|
||||||
|
|
||||||
|
write(*, '("Hello, world, I am ", i2, " of ", i2)')
|
||||||
|
& proc, nproc
|
||||||
|
end
|
64
examples/ring_shmem.f90
Обычный файл
64
examples/ring_shmem.f90
Обычный файл
@ -0,0 +1,64 @@
|
|||||||
|
!
|
||||||
|
! Copyright (c) 2013 Mellanox Technologies, Inc.
|
||||||
|
! All rights reserved.
|
||||||
|
! $COPYRIGHT$
|
||||||
|
!
|
||||||
|
! Additional copyrights may follow
|
||||||
|
!
|
||||||
|
! $HEADER$
|
||||||
|
!
|
||||||
|
|
||||||
|
program ring_shmem_f90
|
||||||
|
implicit none
|
||||||
|
include 'shmem.fh'
|
||||||
|
|
||||||
|
integer*8, save :: rbuf
|
||||||
|
integer*8 :: message
|
||||||
|
integer :: proc, nproc, next
|
||||||
|
! func definitions
|
||||||
|
integer :: my_pe, num_pes
|
||||||
|
|
||||||
|
rbuf = -1
|
||||||
|
message = 10
|
||||||
|
|
||||||
|
call start_pes(0)
|
||||||
|
proc = my_pe()
|
||||||
|
nproc = num_pes()
|
||||||
|
|
||||||
|
! Calculate the PE number of the next process in the ring. Use the
|
||||||
|
! modulus operator so that the last process "wraps around" to PE 0.
|
||||||
|
|
||||||
|
next = mod((proc + 1), nproc)
|
||||||
|
|
||||||
|
if (proc == 0) then
|
||||||
|
write(*, '("Process 0 sending ", i2, " to", i2, " (", i2, " processes in ring)")') message, next, nproc
|
||||||
|
call shmem_put8(rbuf, message, 1, next)
|
||||||
|
write(*, '("Process 0 sent to ", i2)') next
|
||||||
|
end if
|
||||||
|
|
||||||
|
! Pass the message around the ring. The exit mechanism works as
|
||||||
|
! follows: the message (a positive integer) is passed around the
|
||||||
|
! ring. Each time it passes PE 0, it is decremented. When each
|
||||||
|
! processes receives a message containing a 0 value, it passes the
|
||||||
|
! message on to the next process and then quits. By passing the 0
|
||||||
|
! message first, every process gets the 0 message and can quit
|
||||||
|
! normally.
|
||||||
|
|
||||||
|
do while(message > 0)
|
||||||
|
call shmem_int8_wait_until(rbuf, SHMEM_CMP_EQ, message)
|
||||||
|
|
||||||
|
if (proc == 0) then
|
||||||
|
message = message - 1
|
||||||
|
write(*, '("Process 0 decremented value:", i2)') message
|
||||||
|
else
|
||||||
|
message = rbuf
|
||||||
|
end if
|
||||||
|
|
||||||
|
call shmem_put8(rbuf, message, 1, next)
|
||||||
|
end do
|
||||||
|
|
||||||
|
! All done
|
||||||
|
|
||||||
|
write(*, '("Process", i2," exiting.")') proc
|
||||||
|
|
||||||
|
end program
|
60
examples/ring_shmem_c.c
Обычный файл
60
examples/ring_shmem_c.c
Обычный файл
@ -0,0 +1,60 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2013 Mellanox Technologies, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
* $COPYRIGHT$
|
||||||
|
*
|
||||||
|
* Additional copyrights may follow
|
||||||
|
*
|
||||||
|
* $HEADER$
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <shmem.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int main (int argc, char * argv[])
|
||||||
|
{
|
||||||
|
static int rbuf = -1;
|
||||||
|
int proc, nproc, next, prev;
|
||||||
|
int message = 10;
|
||||||
|
|
||||||
|
start_pes(0);
|
||||||
|
proc = _my_pe();
|
||||||
|
nproc = _num_pes();
|
||||||
|
|
||||||
|
/* Calculate the PE number of the next process in the ring. Use the
|
||||||
|
modulus operator so that the last process "wraps around" to PE 0. */
|
||||||
|
|
||||||
|
next = (proc + 1) % nproc;
|
||||||
|
|
||||||
|
if(proc == 0)
|
||||||
|
{
|
||||||
|
printf("Process 0 puts message %d to %d (%d processes in ring)\n", message, next, nproc);
|
||||||
|
shmem_int_put(&rbuf, &message, 1, next);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Pass the message around the ring. The exit mechanism works as
|
||||||
|
follows: the message (a positive integer) is passed around the
|
||||||
|
ring. Each time it passes PE 0, it is decremented. When each
|
||||||
|
processes receives a message containing a 0 value, it passes the
|
||||||
|
message on to the next process and then quits. By passing the 0
|
||||||
|
message first, every process gets the 0 message and can quit
|
||||||
|
normally. */
|
||||||
|
|
||||||
|
while(message > 0) {
|
||||||
|
shmem_int_wait_until(&rbuf, SHMEM_CMP_EQ, message);
|
||||||
|
if(proc == 0) {
|
||||||
|
--message;
|
||||||
|
printf("Process 0 decremented value: %d\n", message);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
message = rbuf;
|
||||||
|
}
|
||||||
|
shmem_int_put(&rbuf, &message, 1, next);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* All done */
|
||||||
|
|
||||||
|
printf("Process %d exiting\n", proc);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
71
examples/ring_shmemfh.f
Обычный файл
71
examples/ring_shmemfh.f
Обычный файл
@ -0,0 +1,71 @@
|
|||||||
|
C
|
||||||
|
C Copyright (c) 2013 Mellanox Technologies, Inc.
|
||||||
|
C All rights reserved.
|
||||||
|
C $COPYRIGHT$
|
||||||
|
C
|
||||||
|
C Additional copyrights may follow
|
||||||
|
C
|
||||||
|
C $HEADER$
|
||||||
|
C
|
||||||
|
|
||||||
|
program ring_shmem_f77
|
||||||
|
implicit none
|
||||||
|
include 'shmem.fh'
|
||||||
|
|
||||||
|
integer*8 rbuf
|
||||||
|
save rbuf
|
||||||
|
integer*8 message
|
||||||
|
integer proc, nproc, next
|
||||||
|
C func definitions
|
||||||
|
integer my_pe, num_pes
|
||||||
|
|
||||||
|
rbuf = -1
|
||||||
|
message = 10
|
||||||
|
|
||||||
|
call start_pes(0)
|
||||||
|
proc = my_pe()
|
||||||
|
nproc = num_pes()
|
||||||
|
|
||||||
|
C Calculate the PE number of the next process in the ring. Use the
|
||||||
|
C modulus operator so that the last process "wraps around" to PE 0.
|
||||||
|
|
||||||
|
next = mod((proc + 1), nproc)
|
||||||
|
|
||||||
|
if (proc .eq. 0) then
|
||||||
|
write(*, '("Process 0 sending ", i2, " to ", i2,
|
||||||
|
& " (", i2, " processes in ring)")')
|
||||||
|
& message, next, nproc
|
||||||
|
call shmem_put8(rbuf, message, 1, next)
|
||||||
|
write(*, '("Process 0 sent to ", i2)') next
|
||||||
|
end if
|
||||||
|
|
||||||
|
C Pass the message around the ring. The exit mechanism works as
|
||||||
|
C follows: the message (a positive integer) is passed around the
|
||||||
|
C ring. Each time it passes PE 0, it is decremented. When each
|
||||||
|
C processes receives a message containing a 0 value, it passes the
|
||||||
|
C message on to the next process and then quits. By passing the 0
|
||||||
|
C message first, every process gets the 0 message and can quit
|
||||||
|
C normally.
|
||||||
|
|
||||||
|
10 call shmem_int8_wait_until(rbuf, SHMEM_CMP_EQ, message)
|
||||||
|
|
||||||
|
if (proc .eq. 0) then
|
||||||
|
message = message - 1
|
||||||
|
write(*, '("Process 0 decremented value:", i2)') message
|
||||||
|
else
|
||||||
|
message = rbuf
|
||||||
|
end if
|
||||||
|
|
||||||
|
call shmem_put8(rbuf, message, 1, next)
|
||||||
|
|
||||||
|
if (message .gt. 0) then
|
||||||
|
goto 10
|
||||||
|
else
|
||||||
|
goto 20
|
||||||
|
end if
|
||||||
|
|
||||||
|
C All done
|
||||||
|
|
||||||
|
20 write(*, '("Process", i2," exiting.")') proc
|
||||||
|
|
||||||
|
end
|
@ -31,8 +31,8 @@ linker_flags=@OMPI_WRAPPER_EXTRA_LDFLAGS@
|
|||||||
# the MPI API.
|
# the MPI API.
|
||||||
libs=-lshmem -lmpi @OMPI_WRAPPER_EXTRA_LIBS@
|
libs=-lshmem -lmpi @OMPI_WRAPPER_EXTRA_LIBS@
|
||||||
libs_static=-lshmem -lmpi -lopen-rte -lopen-pal @OMPI_WRAPPER_EXTRA_LIBS@
|
libs_static=-lshmem -lmpi -lopen-rte -lopen-pal @OMPI_WRAPPER_EXTRA_LIBS@
|
||||||
dyn_lib_file=libmpi.@OPAL_DYN_LIB_SUFFIX@
|
dyn_lib_file=libshmem.@OPAL_DYN_LIB_SUFFIX@
|
||||||
static_lib_file=libmpi.a
|
static_lib_file=libshmem.a
|
||||||
required_file=
|
required_file=
|
||||||
includedir=${includedir}
|
includedir=${includedir}
|
||||||
libdir=${libdir}
|
libdir=${libdir}
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user