Skip to content
Snippets Groups Projects
Commit d4621f54 authored by Debolskiy Andrey's avatar Debolskiy Andrey :bicyclist_tone5:
Browse files

Initial commit

initial v1.1 which was obtained from MVS ivm account with gitignore added
parents
No related branches found
No related tags found
No related merge requests found
Pipeline #
#This is a gitignore file for parlib
#object files
*.o
#linked libraries
*.a
#copied manual and headers
man/
include/
.SUFFIXES: .c .o .a
AR = ar crl
RANLIB = ranlib
INSTALLDIR = /gpfs/NETHOME/ivm6/CM/ParLib.v1.1
#INSTALLDIR = $(HOME)
default: all
all: setvars libparlib.a libparlibf.a
#
# For INM's HP-cluster
#
CC = mpicc
LIBS = -lmpich
# LIBPATH = -L/opt/mpich-gm/lib
# INCPATH = -I/opt/mpich-gm/include
DEFINES = -DFORTRANUNDERSCORE
setvars:
libparlib.a: bexchange.o transpose.o
$(AR) $@ $?
$(RANLIB) $@
libparlibf.a: parlibf.o bexchangef.o transposef.o
$(AR) $@ $?
$(RANLIB) $@
.c.o:
$(CC) $(INCPATH) -c $(DEFINES) $<
clean:
rm -f *.o *.a
rebuild: clean all
install: libparlib.a libparlibf.a
@if !(test -d $(INSTALLDIR)) ; then \
echo Creating directory $(INSTALLDIR)...; \
mkdir $(INSTALLDIR) ; \
fi
@if !(test -d $(INSTALLDIR)/lib) ; then \
echo Creating directory $(INSTALLDIR)/lib...; \
mkdir $(INSTALLDIR)/lib ; \
fi
cp $? $(INSTALLDIR)/lib
@if !(test -d $(INSTALLDIR)/include) ; then \
echo Creating directory $(INSTALLDIR)/include...; \
mkdir $(INSTALLDIR)/include ; \
fi
cp -r parlib.h parlibf.h $(INSTALLDIR)/include
@if !(test -d $(INSTALLDIR)/man) ; then \
echo Creating directory $(INSTALLDIR)/man...; \
mkdir $(INSTALLDIR)/man ; \
fi
@if !(test -d $(INSTALLDIR)/man/man3) ; then \
echo Creating directory $(INSTALLDIR)/man/man3...; \
mkdir $(INSTALLDIR)/man/man3 ; \
fi
cp -r man/* $(INSTALLDIR)/man/man3
ln -s $(INSTALLDIR)/man/man3/P_BExchange_init.3 \
$(INSTALLDIR)/man/man3/P_BExchange_start.3
ln -s $(INSTALLDIR)/man/man3/P_BExchange_init.3 \
$(INSTALLDIR)/man/man3/P_BExchange_end.3
ln -s $(INSTALLDIR)/man/man3/P_BExchange_init.3 \
$(INSTALLDIR)/man/man3/P_BExchange_free.3
ln -s $(INSTALLDIR)/man/man3/P_Transpose_init.3 \
$(INSTALLDIR)/man/man3/P_Transpose_start.3
ln -s $(INSTALLDIR)/man/man3/P_Transpose_init.3 \
$(INSTALLDIR)/man/man3/P_Transpose_end.3
ln -s $(INSTALLDIR)/man/man3/P_Transpose_init.3 \
$(INSTALLDIR)/man/man3/P_Transpose_free.3
parlibf.o: parlib.h
bexchange.o: parlib.h
bexchangef.o: parlib.h
transpose.o: parlib.h
transposef.o: parlib.h
INM ParLib v1.0
-------------------------------------------------------------------------------
author: Val Gloukhov
Institute of Numerical Mathematics of the Russian Academy
of Sciences
(gluhoff@inm.ras.ru)
latest update: 11/30/2001
-------------------------------------------------------------------------------
INM ParLib is a high level library facilitating the coding of finite
difference and spectral approximation weather and climate prediction
models on distributed memory parallel computers.
#include "parlib.h"
/*
* Error codes:
* 0 - success
* 1 - nonpositive number of dimensions
* 2 - wrong communicated dimension
* 3 - negative boundary width
* 4 - nonpositive dimension
* 5 - boundary width exceeds the array block length
*/
int P_BExchange_init ( ndims, stride, blklen, bdim, overlap, datatype,
comm, period, bexchange )
int ndims, *stride, *blklen, bdim, overlap[2], period;
MPI_Datatype datatype;
MPI_Comm comm;
BExchange *bexchange;
{
int nproc, iproc, direct, idim, sendproc[2], recvproc[2];
int count, strd, sbind[2], rbind[2], send[2], recv[2];
MPI_Aint fsize;
MPI_Datatype oldtype, btype[2];
MPI_Request sreq[2], rreq[2];
/*
* Check input parameters
*/
if ( ndims < 1 ) {return 1;}
if ( bdim < 1 || bdim > ndims ) {return 2;}
if ( overlap[0] == 0 && overlap[1] == 0 ) {return 0;} /* success */
for ( idim = 0; idim < ndims; idim++ ) {
if ( stride[idim] <= 0 ) {return 4;}
}
for ( direct = 0; direct < 2; direct++ ) {
if ( overlap[direct] < 0 ) {return 3;}
if ( overlap[direct] > blklen[bdim-1] ) {return 5;}
}
/*
* Define the number of processors in the group and the rank
*/
MPI_Comm_size ( comm, &nproc );
if ( nproc == 0 ) {return 0;} /* success */
MPI_Comm_rank ( comm, &iproc );
if ( iproc == MPI_UNDEFINED ) {return 0;} /* the process does not belong to the group */
sendproc[0] = ( iproc == 0 ? nproc-1 : iproc-1 );
recvproc[0] = ( iproc == nproc-1 ? 0 : iproc+1 );
sendproc[1] = recvproc[0];
recvproc[1] = sendproc[0];
send[0] = iproc > 0 || period;
recv[0] = iproc < nproc-1 || period;
send[1] = recv[0];
recv[1] = send[0];
MPI_Type_extent ( datatype, &fsize );
/*
* Define data types for the boundaries
*/
for ( direct = 0; direct < 2; direct++ ) {
if ( overlap[direct] > 0 ) {
oldtype = datatype;
strd = 1;
for ( idim = 0; idim < ndims; idim++ ) {
if ( idim+1 == bdim ) {
count = overlap[direct];
} else {
count = blklen[idim];
}
MPI_Type_hvector ( count, 1, strd * fsize, oldtype,
&btype[direct] );
if ( idim > 0 ) {
MPI_Type_free ( &oldtype );
}
oldtype = btype[direct];
strd = strd * stride[idim];
}
MPI_Type_commit ( &btype[direct] );
}
}
/*
* Determine the begining of boundaries
*/
strd = 1;
for ( idim = 0; idim < bdim - 1; idim++ ) {
strd = strd * stride[idim];
}
sbind[0] = 0;
rbind[0] = blklen[bdim-1]*strd;
sbind[1] = (blklen[bdim-1]-overlap[1])*strd;
rbind[1] = -overlap[1]*strd;
for ( direct = 0; direct < 2; direct++ ) {
bexchange->overlap[direct] = overlap[direct];
bexchange->send[direct] = send[direct];
bexchange->recv[direct] = recv[direct];
bexchange->btype[direct] = btype[direct];
bexchange->sendproc[direct] = sendproc[direct];
bexchange->recvproc[direct] = recvproc[direct];
bexchange->sbind[direct] = sbind[direct];
bexchange->rbind[direct] = rbind[direct];
}
bexchange->comm = comm;
bexchange->fsize = fsize;
return 0;
}
int P_BExchange_start ( a, bexchange )
void *a;
BExchange *bexchange;
{
int direct, overlap[2], send[2], recv[2], btype[2];
int sendproc[2], recvproc[2], sbind[2], rbind[2];
MPI_Comm comm;
MPI_Request sreq[2], rreq[2];
MPI_Aint fsize;
char *ach = (char *) a;
for ( direct = 0; direct < 2; direct++ ) {
overlap[direct] = bexchange->overlap[direct];
send[direct] = bexchange->send[direct];
recv[direct] = bexchange->recv[direct];
btype[direct] = bexchange->btype[direct];
sendproc[direct] = bexchange->sendproc[direct];
recvproc[direct] = bexchange->recvproc[direct];
sbind[direct] = bexchange->sbind[direct];
rbind[direct] = bexchange->rbind[direct];
}
comm = bexchange->comm;
fsize = bexchange->fsize;
for ( direct = 0; direct < 2; direct++ ) {
if ( overlap[direct] > 0 ) {
if ( send[direct] ) {
MPI_Isend ( ach+sbind[direct]*fsize, 1, btype[direct],
sendproc[direct], 0, comm, &sreq[direct] );
}
if ( recv[direct] ) {
MPI_Irecv ( ach+rbind[direct]*fsize, 1, btype[direct],
recvproc[direct], 0, comm, &rreq[direct] );
}
}
}
for ( direct = 0; direct < 2; direct++ ) {
bexchange->sreq[direct]=sreq[direct];
bexchange->rreq[direct]=rreq[direct];
}
return 0;
}
int P_BExchange_end ( bexchange )
BExchange *bexchange;
{
MPI_Status status;
int direct, overlap[2], send[2], recv[2];
MPI_Request sreq[2], rreq[2];
for ( direct = 0; direct < 2; direct++ ) {
overlap[direct] = bexchange->overlap[direct];
send[direct] = bexchange->send[direct];
recv[direct] = bexchange->recv[direct];
sreq[direct] = bexchange->sreq[direct];
rreq[direct] = bexchange->rreq[direct];
}
for ( direct = 0; direct < 2; direct++ ) {
if ( overlap[direct] > 0 ) {
if ( send[direct] ) {
MPI_Wait ( &sreq[direct], &status );
}
if ( recv[direct] ) {
MPI_Wait ( &rreq[direct], &status );
}
}
}
return 0;
}
int P_BExchange_free ( bexchange )
BExchange *bexchange;
{
int direct, overlap[2];
MPI_Datatype btype[2];
for ( direct = 0; direct < 2; direct++ ) {
overlap[direct] = bexchange->overlap[direct];
btype[direct] = bexchange->btype[direct];
}
for ( direct = 0; direct < 2; direct++ ) {
if ( overlap[direct] > 0 ) {
MPI_Type_free ( &btype[direct] );
}
}
return 0;
}
int P_BExchange ( a, ndims, stride, blklen, bdim, overlap, datatype,
comm, period )
void *a;
MPI_Datatype datatype;
int ndims, *stride, *blklen, bdim, overlap[2];
int period;
MPI_Comm comm;
{
BExchange bexchange;
int ierr;
if ( ierr = P_BExchange_init ( ndims, stride, blklen, bdim, overlap,
datatype, comm, period, &bexchange ) != 0 ) { return ierr; }
P_BExchange_start ( a, &bexchange );
P_BExchange_end ( &bexchange );
P_BExchange_free ( &bexchange );
return 0;
}
#include <stdlib.h>
#include "parlib.h"
#ifdef FORTRANUNDERSCORE
void p_bexchange_init_ ( ndims, stride, blklen, bdim, overlap, datatype,
comm, period, bexchange, ierr )
#elif defined(FORTRANDOUBLEUNDERSCORE)
void p_bexchange_init__ ( ndims, stride, blklen, bdim, overlap, datatype,
comm, period, bexchange, ierr )
#else
void p_bexchange_init ( ndims, stride, blklen, bdim, overlap, datatype,
comm, period, bexchange, ierr )
#endif
MPI_Fint *datatype, *ndims, *stride, *blklen, *bdim, *overlap,
*period, *ierr, *comm;
BExchange **bexchange;
{
*bexchange = (BExchange *) malloc ( sizeof (BExchange) );
*ierr = P_BExchange_init ( (int)*ndims, (int *)stride, (int *)blklen,
(int)*bdim, (int *)overlap, MPI_Type_f2c(*datatype),
MPI_Comm_f2c(*comm), (int)*period, *bexchange );
}
#ifdef FORTRANUNDERSCORE
void p_bexchange_start_ ( a, bexchange, ierr )
#elif defined(FORTRANDOUBLEUNDERSCORE)
void p_bexchange_start__ ( a, bexchange, ierr )
#else
void p_bexchange_start ( a, bexchange, ierr )
#endif
void *a;
BExchange **bexchange;
MPI_Fint *ierr;
{
*ierr = P_BExchange_start ( a, *bexchange );
}
#ifdef FORTRANUNDERSCORE
void p_bexchange_end_ ( bexchange, ierr )
#elif defined(FORTRANDOUBLEUNDERSCORE)
void p_bexchange_end__ ( bexchange, ierr )
#else
void p_bexchange_end ( bexchange, ierr )
#endif
BExchange **bexchange;
MPI_Fint *ierr;
{
*ierr = P_BExchange_end ( *bexchange );
}
#ifdef FORTRANUNDERSCORE
void p_bexchange_free_ ( bexchange, ierr )
#elif defined(FORTRANDOUBLEUNDERSCORE)
void p_bexchange_free__ ( bexchange, ierr )
#else
void p_bexchange_free ( bexchange, ierr )
#endif
BExchange **bexchange;
MPI_Fint *ierr;
{
P_BExchange_free ( *bexchange );
free ( *bexchange );
}
#ifdef FORTRANUNDERSCORE
void p_bexchange_ ( a, ndims, stride, blklen, bdim, overlap, datatype,
comm, period, ierr )
#elif defined(FORTRANDOUBLEUNDERSCORE)
void p_bexchange__ ( a, ndims, stride, blklen, bdim, overlap, datatype,
comm, period, ierr )
#else
void p_bexchange ( a, ndims, stride, blklen, bdim, overlap, datatype,
comm, period, ierr )
#endif
void *a;
int *ndims, *stride, *blklen, *bdim, *overlap, *period, *ierr;
MPI_Datatype *datatype;
MPI_Comm *comm;
{
*ierr = P_BExchange ( a, (int)*ndims, (int *)stride, (int *)blklen,
(int)*bdim, (int *)overlap, MPI_Type_f2c(*datatype),
MPI_Comm_f2c(*comm), (int)*period );
}
\relax
\catcode`"\active
\select@language{russian}
\@writefile{toc}{\select@language{russian}}
\@writefile{lof}{\select@language{russian}}
\@writefile{lot}{\select@language{russian}}
\citation{T126}
\citation{AGCM}
\citation{Ilghiz}
\citation{Swarztrauber}
\citation{Barros}
\@writefile{toc}{\contentsline {section}{\numberline {1}\IeC {\CYRV }\IeC {\cyrv }\IeC {\cyre }\IeC {\cyrd }\IeC {\cyre }\IeC {\cyrn }\IeC {\cyri }\IeC {\cyre }}{1}}
\@writefile{toc}{\contentsline {section}{\numberline {2}\IeC {\CYRI }\IeC {\cyrs }\IeC {\cyrp }\IeC {\cyro }\IeC {\cyrl }\IeC {\cyrsftsn }\IeC {\cyrz }\IeC {\cyro }\IeC {\cyrv }\IeC {\cyra }\IeC {\cyrn }\IeC {\cyri }\IeC {\cyre } \IeC {\cyrb }\IeC {\cyri }\IeC {\cyrb }\IeC {\cyrl }\IeC {\cyri }\IeC {\cyro }\IeC {\cyrt }\IeC {\cyre }\IeC {\cyrk }\IeC {\cyri }}{1}}
\@writefile{toc}{\contentsline {subsection}{\numberline {2.1}\IeC {\CYRK }\IeC {\cyro }\IeC {\cyrm }\IeC {\cyrp }\IeC {\cyri }\IeC {\cyrl }\IeC {\cyrya }\IeC {\cyrc }\IeC {\cyri }\IeC {\cyrya } \IeC {\cyri } \IeC {\cyrl }\IeC {\cyri }\IeC {\cyrn }\IeC {\cyrk }\IeC {\cyro }\IeC {\cyrv }\IeC {\cyrk }\IeC {\cyra } \IeC {\cyrp }\IeC {\cyrr }\IeC {\cyro }\IeC {\cyrg }\IeC {\cyrr }\IeC {\cyra }\IeC {\cyrm }\IeC {\cyrm }}{2}}
\@writefile{toc}{\contentsline {subsection}{\numberline {2.2}\IeC {\CYRV }\IeC {\cyrery }\IeC {\cyrz }\IeC {\cyro }\IeC {\cyrv } \IeC {\cyrb }\IeC {\cyri }\IeC {\cyrb }\IeC {\cyrl }\IeC {\cyri }\IeC {\cyro }\IeC {\cyrt }\IeC {\cyre }\IeC {\cyrch }\IeC {\cyrn }\IeC {\cyrery }\IeC {\cyrh } \IeC {\cyrp }\IeC {\cyrr }\IeC {\cyro }\IeC {\cyrc }\IeC {\cyre }\IeC {\cyrd }\IeC {\cyru }\IeC {\cyrr }}{2}}
\@writefile{toc}{\contentsline {subsubsection}{\numberline {2.2.1}\IeC {\CYRO }\IeC {\cyrb }\IeC {\cyrm }\IeC {\cyre }\IeC {\cyrn } \IeC {\cyrg }\IeC {\cyrr }\IeC {\cyra }\IeC {\cyrn }\IeC {\cyri }\IeC {\cyrch }\IeC {\cyrn }\IeC {\cyrery }\IeC {\cyrm }\IeC {\cyri } \IeC {\cyrz }\IeC {\cyrn }\IeC {\cyra }\IeC {\cyrch }\IeC {\cyre }\IeC {\cyrn }\IeC {\cyri }\IeC {\cyrya }\IeC {\cyrm }\IeC {\cyri }}{2}}
\@writefile{toc}{\contentsline {subsubsection}{\numberline {2.2.2}\IeC {\CYRT }\IeC {\cyrr }\IeC {\cyra }\IeC {\cyrn }\IeC {\cyrs }\IeC {\cyrp }\IeC {\cyro }\IeC {\cyrn }\IeC {\cyri }\IeC {\cyrr }\IeC {\cyro }\IeC {\cyrv }\IeC {\cyra }\IeC {\cyrn }\IeC {\cyri }\IeC {\cyre }}{3}}
\bibcite{T126}{1}
\bibcite{AGCM}{2}
\bibcite{Ilghiz}{3}
\bibcite{Swarztrauber}{4}
\bibcite{Barros}{5}
\bibcite{Rodriguez}{6}
\bibcite{Henderson}{7}
File added
This is TeX, Version 3.14159 (Web2C 7.3.1) (format=latex 2001.1.2) 2 NOV 2001 14:34
**manual.tex
(manual.tex
LaTeX2e <1999/12/01> patch level 1
Babel <v3.6Z> and hyphenation patterns for american, russian, nohyphenation, lo
aded.
(/usr/share/texmf/tex/latex/base/article.cls
Document Class: article 1999/09/10 v1.4a Standard LaTeX document class
(/usr/share/texmf/tex/latex/base/size12.clo
File: size12.clo 1999/09/10 v1.4a Standard LaTeX file (size option)
)
\c@part=\count79
\c@section=\count80
\c@subsection=\count81
\c@subsubsection=\count82
\c@paragraph=\count83
\c@subparagraph=\count84
\c@figure=\count85
\c@table=\count86
\abovecaptionskip=\skip41
\belowcaptionskip=\skip42
\bibindent=\dimen102
)
(/usr/share/texmf/tex/latex/base/inputenc.sty
Package: inputenc 1999/09/17 v0.992 Input encoding file
(/usr/share/texmf/tex/latex/cyrillic/koi8-r.def
File: koi8-r.def 1999/11/16 v1.0d Input encoding file
))
(/usr/share/texmf/tex/generic/babel/babel.sty
Package: babel 1999/09/09 v3.6Z The Babel package
(/usr/share/texmf/tex/generic/babel/russianb.ldf
Language: russianb 1999/08/27 v1.1l Russian support from the babel system
(/usr/share/texmf/tex/generic/babel/babel.def
File: babel.def 1999/09/09 v3.6Z Babel common definitions
\babel@savecnt=\count87
\U@D=\dimen103
)
(/usr/share/texmf/tex/latex/cyrillic/t2aenc.def
File: t2aenc.def 1999/11/29 v1.0c Cyrillic encoding definition file
)
LaTeX Info: Redefining \latintext on input line 142.
LaTeX Info: Redefining \textlatin on input line 147.
Package babel Info: Making " an active character on input line 210.
)) (manual.aux
LaTeX Font Info: Try loading font information for T2A+cmr on input line 3.
(/usr/share/texmf/tex/latex/cyrillic/t2acmr.fd
File: t2acmr.fd 1999/01/07 v1.0 Computer Modern Cyrillic font definitions
))
\openout1 = `manual.aux'.
LaTeX Font Info: Checking defaults for OML/cmm/m/it on input line 5.
LaTeX Font Info: ... okay on input line 5.
LaTeX Font Info: Checking defaults for T1/cmr/m/n on input line 5.
LaTeX Font Info: ... okay on input line 5.
LaTeX Font Info: Checking defaults for OT1/cmr/m/n on input line 5.
LaTeX Font Info: ... okay on input line 5.
LaTeX Font Info: Checking defaults for OMS/cmsy/m/n on input line 5.
LaTeX Font Info: ... okay on input line 5.
LaTeX Font Info: Checking defaults for OMX/cmex/m/n on input line 5.
LaTeX Font Info: ... okay on input line 5.
LaTeX Font Info: Checking defaults for U/cmr/m/n on input line 5.
LaTeX Font Info: ... okay on input line 5.
LaTeX Font Info: Checking defaults for T2A/cmr/m/n on input line 5.
LaTeX Font Info: ... okay on input line 5.
[1
]
Overfull \hbox (0.26997pt too wide) in paragraph at lines 38--39
[]\T2A/cmr/m/n/12 ----, - --
- -
[]
LaTeX Font Info: Try loading font information for T2A+cmtt on input line 45.
(/usr/share/texmf/tex/latex/cyrillic/t2acmtt.fd
File: t2acmtt.fd 1999/01/07 v1.0 Computer Modern Cyrillic font definitions
)
Overfull \hbox (1.98051pt too wide) in paragraph at lines 44--46
\T2A/cmr/m/n/12 --- --- - - \T2A/cmtt/m/n/12 -I
\T2A/cmr/m/it/12 __--\T2A/cmtt/m/n/12 /include\T2A/cmr/m/n/12 ,
[]
[1]
LaTeX Font Info: External font `cmex10' loaded for size
(Font) <12> on input line 60.
LaTeX Font Info: External font `cmex10' loaded for size
(Font) <8> on input line 60.
LaTeX Font Info: External font `cmex10' loaded for size
(Font) <6> on input line 60.
Overfull \hbox (1.32059pt too wide) in paragraph at lines 75--82
\T2A/cmr/m/n/12 -, -- - -- \T2A/cmtt/m/n/12 MPI_REA
L \T2A/cmr/m/n/12 \T2A/cmtt/m/n/12 MPI_DOUBLE_PRECISION\T2A/cmr/m/n/12 .
[]
[2] [3] [4] [5] [6] (manual.aux) )
Here is how much of TeX's memory you used:
975 strings out of 20896
10539 string characters out of 197516
59080 words of memory out of 350001
3925 multiletter control sequences out of 10000+15000
12345 words of font info for 33 fonts, out of 400000 for 1000
24 hyphenation exceptions out of 1000
24i,8n,24p,457b,303s stack positions out of 1500i,100n,500p,50000b,4000s
Output written on manual.dvi (7 pages, 19380 bytes).
This diff is collapsed.
% LaTeX document
\documentclass[a4paper,12pt]{article}
\usepackage[koi8-r]{inputenc}
\usepackage[russian]{babel}
\begin{document}
\begin{titlepage}
\begin{center}
\Huge{\textbf{
\\
\\
INM~ParLib ( 1.0)}}
\vspace{0.1\textheight}
\Large{~.~.} \\
\vspace{0.2\textheight}
\Large{ ~ \\
, \today}
\end{center}
\end{titlepage}
\section{}
INM ParLib, ~\cite{T126} ~\cite{AGCM} .
, , , .
.
.
.
, , .
, , .
, .
~\cite{Ilghiz}, \cite{Swarztrauber} , ~\cite{Barros}.
, , ( , ).
\section{ }
, , .
\subsection{ }
MPI , MPI.
, {\tt -I{\it \_\_\-\-}/include}, ~-- {\tt -L{\it \_\_}/lib -lparlib}, a {\tt -lparlibf}.
\subsection{ }
\begin{verbatim}
INCLUDE 'parlibf.h'
\end{verbatim}
,
\begin{verbatim}
#include 'parlib.h'
\end{verbatim}
.
\subsubsection{ }
$\cal A$ .
().
, .
\begin{verbatim}
DIMENSION A(STRIDE(1), ..., STRIDE(NDIMS))
\end{verbatim}
{\tt NDIMS}~-- , {\tt STRIDE}~-- .
, {\tt BDIM}~-- , $\cal A$ , , .
\\{\tt P\_BExchange} :
\begin{verbatim}
CALL P_BEXCAHNGE (ARR, NDIMS, STRIDE, BLKLEN, BDIM,
1 OVERLAP, DATATYPE, COMM, PERIOD, IERROR)
\end{verbatim}
{\tt ARR}~-- {\tt A}; {\tt BLKLEN}~-- {\tt A}, , , {\tt ARR(1:BLKLEN(1), ..., 1:BLKLEN(NDIMS))}.
{\tt OVERLAP}, {\tt OVERLAP(1)} {\tt BDIM}, ~-- {\tt OVERLAP(2)}.
{\tt PERIOD} .
, .
MPI {\tt COMM}, {\tt A} MPI {\tt DATATYPE}.
, {\tt MPI\_REAL} {\tt MPI\_DOUBLE\_PRECISION}.
% ,
.
:
\begin{verbatim}
CALL P_BEXCAHNGE_INIT (NDIMS, STRIDE, BLKLEN, BDIM,
1 OVERLAP, DATATYPE, COMM, PERIO, BEXCHANGE, IERROR)
CALL P_BEXCAHNGE_START (ARR, BEXCHANGE, IERROR)
CALL P_BEXCAHNGE_END (BEXCHANGE, IERROR)
CALL P_BEXCAHNGE_FREE (BEXCHANGE, IERROR)
\end{verbatim}
, , , {\tt BEXCHANGE}, , , , , , .
, {\tt P\_BExcahnge\_start} {\tt P\_BExchange\_end} , .
\subsubsection{}
, $\cal A$ {\tt DIM\_SOURCE} {\tt LBLKS\_SOURCE(IPROC)}, {\tt IPROC}~-- , {\tt DIM\_DEST} .
$\cal A$ , {\tt LBLKS\_DEST(IPROC)} {\tt DIM\_DEST} {\tt DIM\_SOURCE}.
{\tt ARR\_SOURCE}~-- $\cal A$ , {\tt ARR\_DEST}~-- , :
\begin{verbatim}
CALL P_TRANSPOSE (NDIMS, ARR_SOURCE, DIM_SOURCE,
1 LBLKS_SOURCE, ARR_DEST, DIM_DEST, LBLKS_DEST,
2 STRIDE, BLKLEN, OVERLAP, DATATYPE, COMM, PERIOD,
3 DIAG, IERROR)
\end{verbatim}
{\tt NDIMS}~-- $\cal A$, {\tt DATATYPE}~-- MPI, , {\tt COMM}~-- MPI, .
, $\cal A$ , .
, , {\tt DIAG} {\tt .FALSE.} .
$\cal A$ {\tt A\_SOURCE}, ~-- {\tt A\_DEST}.
\begin{verbatim}
DIMENSION A_SOURCE(DIM_SOURCE(1), ..., DIM_SOURCE(NDIMS))
DIMENSION A_DEST(DIM_DEST(1), ..., DIM_DEST(NDIMS))
\end{verbatim}
{\tt DIM\_SOURCE} :
$$
\texttt{DIM\_SOURSE(IDIM)}=\left\{
\begin{array}{l}
\texttt{BLKLEN(DIM\_SOURCE)} \textrm{, } \texttt{IDIM=DIM\_SOURCE}\\
\texttt{STRIDE(IDIM)} \textrm{, }
\end{array}\right.
$$
{\tt DIM\_DEST}:
$$
\texttt{DIM\_DEST(IDIM)}=\left\{
\begin{array}{l}
\texttt{BLKLEN(DIM\_DEST)} \textrm{, } \texttt{IDIM=DIM\_DEST}\\
\texttt{STRIDE(IDIM)} \textrm{, }
\end{array}\right.
$$
{\tt A\_SOURCE} {\tt A\_DEST} , :
\begin{verbatim}
ARR_SOURCE(1:BLK_SOURCE(1), ..., 1:BLK_SOURCE(NDIMS)
ARR_DEST(1:BLK_DEST(1), ..., 1:BLK_DEST(NDIMS)
\end{verbatim}
:
$$
\texttt{BLK\_SOURCE(IDIM)}=\left\{
\begin{array}{l}
\texttt{LBLKS\_SOURCE(IPROC)} \textrm{, } \texttt{IDIM=DIM\_SOURCE} \\
\sum\texttt{LBLKS\_DEST} \textrm{, } \texttt{IDIM=DIM\_DEST} \\
\texttt{BLKLEN(IDIM)} \textrm{, }
\end{array}\right.
$$
$$
\texttt{BLK\_DEST(IDIM)}=\left\{
\begin{array}{l}
\texttt{LBLKS\_DEST(IPROC)} \textrm{, } \texttt{IDIM=DIM\_DEST} \\
\sum\texttt{LBLKS\_SOURE} \textrm{, } \texttt{IDIM=DIM\_SOURCE} \\
\texttt{BLKLEN(IDIM)} \textrm{, }
\end{array}\right.
$$
:
\begin{verbatim}
CALL P_TRANSPOSE_INIT (NDIMS, DIM_SOURCE, LBLKS_SOURCE,
1 DIM_DEST, LBLKS_DEST, STRIDE, BLKLEN, OVERLAP, DATATYPE,
2 COMM, PERIOD, DIAG, TRANSP, IERROR)
CALL P_TRANSPOSE_START (ARR_SOURCE, ARR_DEST, TRANSP,
1 IERROR)
CALL P_TRANSPOSE_END (TRANSP, IERROR)
CALL P_TRANSPOSE_FREE (TRANSP, IERROR)
\end{verbatim}
{\tt TRANSP}~-- .
\begin{thebibliography}{}
\bibitem{T126} ~.~. T126 . Optimization of Finite Element Approximations, Splines and Wavelets (OFEA'2001). Abstracts of International conference (June~25--29, 2001, St.-Petersburg, Russia), 2001, 184~p.
\bibitem{AGCM} .~A.~Tolstykh, V.~N.~Gloukhov. Implementation of global atmospheric models on parallel computers. {\it .} ~, .
\bibitem{Ilghiz} ~.~. . . , , 1999.
\bibitem{Swarztrauber} P.~N.~Swarztrauber, S.~W.~Hammond. A comparison of optimal FFTs on torus and hypercube multicomputers. {\it Parallel computing},~27 (2001), pp.~847--859.
\bibitem{Barros} Barros,~S.~R.~M., Kauranne,~T. On the parallelization of global spectral weather models. {\it Parallel Computing},~20 (1994), pp.~1335--1356.
\bibitem{Rodriguez} B.~Rodriguez, L.~Hart, T.~Henderson. Performance and portability in parallel computing: a weather forecasr view. {\it High Performance Computing in the Geosciences}, 1995, Kluwer Academic Publishers, Netherlands, pp.~1--23.
\bibitem{Henderson} T.~Henderson, D.~Shaffer, M.~Govett, L.~Hart. SMS User's Guide. Advanced Computing Branch, Aviation Division, NOAA Forecast system laboratory, Boulder, 2001.
\end{thebibliography}
\end{document}
#ifndef _MPI_INCLUDE
#include <mpi.h>
#endif
typedef struct BExchange {
int overlap[2], send[2], recv[2], btype[2];
int sendproc[2], recvproc[2], sbind[2], rbind[2];
MPI_Comm comm;
MPI_Request sreq[2], rreq[2];
MPI_Aint fsize;
} BExchange;
typedef struct Transposition {
MPI_Datatype *stype, *rtype;
int *sbeg, *rbeg;
MPI_Comm comm;
int nproc, iproc;
MPI_Request *sreq, *rreq;
MPI_Aint fsize;
} Transposition;
int P_BExchange_init ( int, int*, int*, int, int*, MPI_Datatype,
MPI_Comm, int, BExchange* );
int P_BExchange_start ( void*, BExchange* );
int P_BExchange_end ( BExchange* );
int P_BExchange_free ( BExchange* );
int P_BExchange ( void*, int, int*, int*, int, int*, MPI_Datatype,
MPI_Comm, int );
int P_Transpose_init ( int , int, int*, int, int*, int*, int*, int*,
MPI_Datatype, MPI_Comm, int, Transposition* );
int P_Transpose_start ( void*, void*, Transposition* );
int P_Transpose_end ( Transposition* );
int P_Transpose_free ( Transposition* );
int P_Transpose ( int, void*, int, int*, void*, int, int*, int*, int*,
int*, MPI_Datatype, MPI_Comm, int );
#include "parlib.h"
// Additionall calls to make this version 1.1 compliant with version 2.1
// -------------------------------------------------------------------------- //
#ifdef FORTRANUNDERSCORE
void parlib_init_()
#elif defined(FORTRANDOUBLEUNDERSCORE)
void parlib_init__()
#else
void parlib_init()
#endif
{
}
#ifdef FORTRANUNDERSCORE
void parlib_deinit_()
#elif defined(FORTRANDOUBLEUNDERSCORE)
void parlib_deinit__()
#else
void parlib_deinit()
#endif
{
}
// -------------------------------------------------------------------------- //
INTEGER HANDLE_SIZE
PARAMETER (HANDLE_SIZE = 2)
#include <stdlib.h>
#include "parlib.h"
int P_Transpose_init ( ndims, dim_source, lblks_source, dim_dest,
lblks_dest, stride, blklen, overlap, datatype, comm, period,
transp )
int ndims, dim_source, *lblks_source, dim_dest, *lblks_dest, *stride;
int *blklen, *overlap;
MPI_Datatype datatype;
MPI_Comm comm;
int period;
Transposition *transp;
{
int idim, nproc, iproc, ip, strd, count;
int wblka, wblkb, begb;
int ifsta, ifstb, idir, suma, sumb;
MPI_Aint fsize;
MPI_Datatype oldtype, *stype, *rtype;
int *sbeg, *rbeg;
/*
* Check input parameters
*/
if ( ndims < 2) { return 1; }
if ( dim_source < 1 || dim_source > ndims ) { return 2; }
if ( dim_dest < 1 || dim_dest > ndims ) { return 3; }
if ( dim_source == dim_dest ) { return 4; }
for ( idim = 0; idim < ndims; idim++ ) {
if ( stride[idim] <= 0) { return 5; }
}
for (idir = 0; idir < 2; idir++ ) {
if ( overlap[idir] < 0 ) { return 6; }
}
/*
* Define the number of processors in the group and the rank
*/
MPI_Comm_size ( comm, &nproc );
if ( nproc == 0 ) { return 0; }
MPI_Comm_rank ( comm, &iproc );
if ( iproc == MPI_UNDEFINED ) { return 0; }
suma = sumb = 0;
for ( ip = 0; ip < nproc; ip++ ) {
suma += lblks_source[ip];
sumb += lblks_dest[ip];
if ( lblks_source[ip] <= 0 ) { return 14; }
if ( lblks_dest[ip] <= 0 ) { return 15; }
}
if ( lblks_source[iproc] > blklen[dim_source-1] ) { return 8; }
if ( lblks_dest[iproc] > blklen[dim_dest-1] ) { return 9; }
if ( suma > stride[dim_source-1] ) { return 10; }
if ( sumb > stride[dim_dest-1] ) { return 11; }
for ( idim = 0; idim < ndims; idim++ ) {
if ( idim != dim_source-1 && idim != dim_dest-1 ) {
if ( blklen[idim] > stride[idim] ) { return 7; }
}
}
if ( overlap[0] > lblks_dest[0] ) { return 12; }
if ( overlap[1] > lblks_dest[nproc-1] ) { return 13; }
MPI_Type_extent ( datatype, &fsize );
/*
* Allocate memory
*/
stype = transp->stype =
(MPI_Datatype *) malloc ( sizeof(MPI_Datatype)*nproc );
rtype = transp->rtype =
(MPI_Datatype *) malloc ( sizeof(MPI_Datatype)*nproc );
sbeg = transp->sbeg = (int *) malloc ( sizeof(int)*nproc );
rbeg = transp->rbeg = (int *) malloc ( sizeof(int)*nproc );
/*
* Define data types for the blocks and the beginings of the blocks
*/
ifsta = ifstb = 1;
for ( ip = 0; ip < nproc; ip++ ) {
wblka = lblks_source[iproc];
wblkb = lblks_dest[ip];
if ( ip > 0 || period ) wblkb += overlap[0];
if ( ip < nproc-1 || period ) wblkb += overlap[1];
oldtype = datatype;
strd = 1;
for ( idim = 0; idim < ndims; idim++ ) {
if ( idim == dim_source-1 ) {
count = wblka;
} else if ( idim == dim_dest-1 ) {
count = wblkb;
} else {
count = blklen[idim];
}
MPI_Type_hvector ( count, 1, strd*fsize, oldtype, stype+ip );
if ( idim > 0 ) { MPI_Type_free ( &oldtype ); }
oldtype = stype[ip];
if ( idim == dim_source-1 ) {
strd *= blklen[idim];
} else {
strd *= stride[idim];
}
}
MPI_Type_commit ( stype+ip );
wblka = lblks_source[ip];
wblkb = lblks_dest[iproc];
if ( iproc > 0 || period ) wblkb += overlap[0];
if ( iproc < nproc-1 || period ) wblkb += overlap[1];
oldtype = datatype;
strd = 1;
for ( idim = 0; idim < ndims; idim++ ) {
if ( idim == dim_source-1 ) {
count = wblka;
} else if ( idim == dim_dest-1 ) {
count = wblkb;
} else {
count = blklen[idim];
}
MPI_Type_hvector ( count, 1, strd*fsize, oldtype, rtype+ip );
if ( idim > 0 ) { MPI_Type_free ( &oldtype ); }
oldtype = rtype[ip];
if ( idim == dim_dest-1 ) {
strd *= blklen[idim];
} else {
strd *= stride[idim];
}
}
MPI_Type_commit ( rtype+ip );
begb = ifstb;
if ( ip > 0 || period ) begb -= overlap[0];
strd = 1;
for ( idim = 0; idim < dim_dest-1; idim++ ) {
if ( idim == dim_source-1 ) {
strd *= blklen[idim];
} else {
strd *= stride[idim];
}
}
sbeg[ip] = strd*(begb-1);
rbeg[ip] = 0;
if ( iproc > 0 || period ) rbeg[ip] -= overlap[0]*strd;
strd = 1;
for ( idim = 0; idim < dim_source-1; idim++ ) {
if ( idim == dim_dest-1 ) {
strd *= blklen[idim];
} else {
strd *= stride[idim];
}
}
rbeg[ip] += strd*(ifsta-1);
ifsta += lblks_source[ip];
ifstb += lblks_dest[ip];
}
transp->nproc = nproc;
transp->iproc = iproc;
transp->comm = comm;
transp->fsize = fsize;
return 0;
}
int P_Transpose_start ( arr_source, arr_dest, transp )
void *arr_source, *arr_dest;
Transposition *transp;
{
char *arr_source_ch = (char *) arr_source;
char *arr_dest_ch = (char *) arr_dest;
int nproc = transp->nproc;
int iproc = transp->iproc;
MPI_Aint fsize = transp->fsize;
int *sbeg = transp->sbeg;
int *rbeg = transp->rbeg;
MPI_Datatype *stype = transp->stype;
MPI_Datatype *rtype = transp->rtype;
MPI_Comm comm = transp->comm;
MPI_Request *sreq, *rreq;
int ip;
char *src, *dest;
if ( nproc == 0 ) { return 0; }
if ( iproc == MPI_UNDEFINED ) { return 0; }
/*
* Allocate memory
*/
sreq = transp->sreq =
(MPI_Request *) malloc ( sizeof(MPI_Request)*nproc );
rreq = transp->rreq =
(MPI_Request *) malloc ( sizeof(MPI_Request)*nproc );
/*
* Start the communication
*/
for ( ip = 0; ip < nproc; ip++ ) {
dest = arr_dest_ch+rbeg[ip]*fsize;
src = arr_source_ch+sbeg[ip]*fsize;
if ( dest == src && iproc == ip ) {
rreq[ip] = sreq[ip] = MPI_REQUEST_NULL;
} else {
MPI_Irecv ( dest, 1, rtype[ip], ip, 0, comm, rreq+ip );
MPI_Isend ( src, 1, stype[ip], ip, 0, comm, sreq+ip );
}
}
return 0;
}
int P_Transpose_end ( transp )
Transposition *transp;
{
int nproc = transp->nproc;
int iproc = transp->iproc;
MPI_Request *sreq = transp->sreq;
MPI_Request *rreq = transp->rreq;
int ip;
MPI_Status status;
if ( nproc == 0 ) { return 0; }
if ( iproc == MPI_UNDEFINED ) { return 0; }
for ( ip = 0; ip < nproc; ip++ ) {
MPI_Wait ( rreq+ip, &status );
MPI_Wait ( sreq+ip, &status );
}
return 0;
}
int P_Transpose_free ( transp )
Transposition *transp;
{
int nproc = transp->nproc;
int iproc = transp->iproc;
int *sbeg = transp->sbeg;
int *rbeg = transp->rbeg;
MPI_Datatype *stype = transp->stype;
MPI_Datatype *rtype = transp->rtype;
MPI_Request *sreq = transp->sreq;
MPI_Request *rreq = transp->rreq;
int ip;
if ( nproc == 0 ) { return 0; }
if ( iproc == MPI_UNDEFINED ) { return 0; }
for ( ip = 0; ip < nproc; ip++ ) {
MPI_Type_free ( rtype+ip );
MPI_Type_free ( stype+ip );
}
free ( stype );
free ( rtype );
free ( sbeg );
free ( rbeg );
free ( sreq );
free ( rreq );
return 0;
}
int P_Transpose ( ndims, arr_source, dim_source, lblks_source, arr_dest,
dim_dest, lblks_dest, stride, blklen, overlap, datatype, comm,
period )
void *arr_source, *arr_dest;
int ndims, dim_source, *lblks_source, dim_dest, *lblks_dest, *stride;
int *blklen, *overlap;
MPI_Datatype datatype;
MPI_Comm comm;
int period;
{
Transposition transp;
int ierr;
if ( ierr = P_Transpose_init ( ndims, dim_source, lblks_source,
dim_dest, lblks_dest, stride, blklen, overlap, datatype, comm,
period, &transp ) != 0 )
{
return ierr;
}
P_Transpose_start ( arr_source, arr_dest, &transp );
P_Transpose_end ( &transp );
P_Transpose_free ( &transp );
return 0;
}
#include <stdlib.h>
#include "parlib.h"
#ifdef FORTRANUNDERSCORE
void p_transpose_init_ ( ndims, dim_source, lblks_source, dim_dest,
lblks_dest, stride, blklen, overlap, datatype, comm, period,
transp, ierr )
#elif defined(FORTRANDOUBLEUNDERSCORE)
void p_transpose_init__ ( ndims, dim_source, lblks_source, dim_dest,
lblks_dest, stride, blklen, overlap, datatype, comm, period,
transp, ierr )
#else
void p_transpose_init ( ndims, dim_source, lblks_source, dim_dest,
lblks_dest, stride, blklen, overlap, datatype, comm, period,
transp, ierr )
#endif
MPI_Fint *ndims, *dim_source, *lblks_source, *dim_dest, *lblks_dest;
MPI_Fint *stride, *blklen, *overlap, *datatype, *comm, *period;
MPI_Fint **transp, *ierr;
{
*transp = (MPI_Fint *) malloc ( sizeof(Transposition) );
*ierr = P_Transpose_init ( *ndims, *dim_source, lblks_source,
*dim_dest, lblks_dest, stride, blklen, overlap,
MPI_Type_f2c(*datatype), MPI_Comm_f2c(*comm), *period,
(Transposition *) *transp );
}
#ifdef FORTRANUNDERSCORE
void p_transpose_start_ ( arr_source, arr_dest, transp, ierr )
#elif defined(FORTRANDOUBLEUNDERSCORE)
void p_transpose_start__ ( arr_source, arr_dest, transp, ierr )
#else
void p_transpose_start ( arr_source, arr_dest, transp, ierr )
#endif
void *arr_source, *arr_dest;
MPI_Fint **transp, *ierr;
{
*ierr = P_Transpose_start ( arr_source, arr_dest,
(Transposition *) *transp );
}
#ifdef FORTRANUNDERSCORE
void p_transpose_end_ ( transp, ierr )
#elif defined(FORTRANDOUBLEUNDERSCORE)
void p_transpose_end__ ( transp, ierr )
#else
void p_transpose_end ( transp, ierr )
#endif
MPI_Fint **transp, *ierr;
{
*ierr = P_Transpose_end ( (Transposition *) *transp );
}
#ifdef FORTRANUNDERSCORE
void p_transpose_free_ ( transp, ierr )
#elif defined(FORTRANDOUBLEUNDERSCORE)
void p_transpose_free__ ( transp, ierr )
#else
void p_transpose_free ( transp, ierr )
#endif
MPI_Fint **transp, *ierr;
{
*ierr = P_Transpose_free ( (Transposition *) *transp );
free ( *transp );
}
#ifdef FORTRANUNDERSCORE
void p_transpose_ ( ndims, arr_source, dim_source, lblks_source, arr_dest,
dim_dest, lblks_dest, stride, blklen, overlap, datatype, comm,
period, ierr )
#elif defined(FORTRANDOUBLEUNDERSCORE)
void p_transpose__ ( ndims, arr_source, dim_source, lblks_source, arr_dest,
dim_dest, lblks_dest, stride, blklen, overlap, datatype, comm,
period, ierr )
#else
void p_transpose ( ndims, arr_source, dim_source, lblks_source, arr_dest,
dim_dest, lblks_dest, stride, blklen, overlap, datatype, comm,
period, ierr )
#endif
void *arr_source, *arr_dest;
MPI_Fint *ndims, *dim_source, *lblks_source, *dim_dest, *lblks_dest;
MPI_Fint *stride, *blklen, *overlap, *datatype, *comm, *period;
MPI_Fint *ierr;
{
*ierr = P_Transpose ( *ndims, arr_source, *dim_source, lblks_source,
arr_dest, *dim_dest, lblks_dest, stride, blklen, overlap,
MPI_Type_f2c(*datatype), MPI_Comm_f2c(*comm), *period );
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment