MPI 2 Language Bindings

MPI 2 ´Â MPI 1ÀÌ C¿Í Fortran¿¡ ´ëÇØ¼­¸¸ Á¦°øÇÏ´ø °ÍÀ» C++, Fortran 90¿¡ ±îÁö ±× Áö¿øÀ» È®´ëÇÏ¿´´Ù.

C++

Overview

MPI 1 ¿¡¼­´Â C++¿¡ ´ëÇÑ bindingÀ» Á¦°øÇÏÁö ¾Ê¾ÒÁö¸¸, MPIÀÚü°¡ objectÀÇ °üÁ¡¿¡¼­ ±â¼úµÇ¾úÀ¸¹Ç·Î MPI-2¿¡¼­ÀÇ C++Áö¿ø¿¡ ÀÖ¾î ¾î·Á¿î Á¡Àº ¾ø´Ù. ¸î¸î °æ¿ì¿¡ ÀÖ¾î MPI-2°¡ MPI-1ÀÇ C¿¡¼­ ¾²¿´´ø À̸§°ú ´Ù¸¥ Á¡ÀÌ ÀÖÁö´Â ÇÏÁö¸¸, ±âÁ¸ÀÇ MPI-1°ú ¹èÄ¡µÇ´Â »çÇ×Àº ¾ø´Ù.

C++¿¡ ´ëÇÑ binding criteria

1. C++ ¾ð¾î¿¡ ´ëÇÑ interface´Â MPI object¿¡ ±â¹ÝÇÑ class¿¡ ÀÇÇØ (lightweight functional interface)±¸¼ºµÈ´Ù.

2. Semantics¿¡ À־ C++¿¡ bindingµÈ MPI°¡ ±âÁ¸ MPI¿Í ¹èÄ¡µÇ´Â »çÇ×Àº ¾ø´Ù.

3. È®À强À» À§ÇØ MPI ÇÔ¼ö´Â MPI Ŭ·¡½ºÀÇ ¸â¹ö ÇÔ¼öÀÌ´Ù.

MPI¸¦ À§ÇÑ C++Ŭ·¡½º

MPI¸¦ À§ÇÑ ¸ðµç Ŭ·¡½º, »ó¼ö, ÇÔ¼ö´Â MPI_ prefix´ë½Å MPI namespace¸¦ ÀÌ¿ëÇÏ¿© MPI:: prefix·Î ³ªÅ¸³»¾î Áø´Ù.

À̶§ MPIŬ·¡½º´Â non-instantiableÀ̱⠶§¹®¿¡ ¸ðµç »ý¼ºÀÚ´Â private·Î ±¸¼ºµÇ¾îÁ® ÀÖ´Ù.

MPI-1À» À§ÇÑ MPI-2ÀÇ namespace

namespace MPI {

class Comm {...};

class Intracomm : public Comm {...};

class Graphcomm : public Intracomm {...};

class Cartcomm : public Intracomm {...};

class Intercomm : public Comm {...};

class Datatype {...};

class Errhandler {...};

class Exception {...};

class Group {...};

class Op {...};

class Request {...};

class Prequest : public Request {...};

class Status {...};

};

MPI-2ÀÇ namespace

namespace MPI {

class File {...};

class Grequest : public Request {...};

class Info {...};

class Win {...};

};

derived class°¡ ÀûÀº °ü°è·Î virtual inheritance´Â »ç¿ëµÇÁö ¾Ê¾Ò´Ù.

Class Member Functions for MPI

¿ÏÀüÇÑ ÇüÅÂÀÇ C++¿¡ bindingµÈ MPI´Â C++¸¦ À§ÇØ ÇÊ¿äÇÑ constructor, destructorµî°ú °¢Á¾ operator¿¡ ´ëÇØ ±¸ÇöÀÌ µÇ¾úÀÖÀ¸¸ç ¶ÇÇÑ »ó¼Ó°ü°è¸¦ ÀÌ¿ëÇÒ ¼öµµ ÀÖ´Ù.

Example»ó¼ÓµÈ MPI Ŭ·¡½ºÀÇ ¿¹

class foo_comm : public MPI::Intracomm {

public:

void Send(void* buf, int count, const MPI::Datatype& type, int dest, int tag) const

{

// Class library functionality

MPI::Intracomm::Send(buf, count, type, dest, tag);

// More class library functionality

}

};

¡¡

Semantics

C++ binding µÈ MPIÀÇ semantics´Â ±âÁ¸ÀÇ MPIÀÇ semantics¿Í °°´Ù. ´ÜÁö Ʋ¸° Á¡Àº Ç¥Çö»ó¿¡¼­ MPI::<CLASS>ÀÇ ÇüŸ¦ ÀÌ¿ëÇÑ´Ù´Â °Í »ÓÀÌ´Ù. ´ëºÎºÐÀÇ °æ¿ì =Àº copy, ºñ±³´Â ==, !=µîÀÇ operator°¡ overloadingµÇ¾î ÀÖ´Ù.

Data types

data type¿¡ À־ C++¿¡¼­ Á¦°øÇÏ´Â boolÀ» À§ÇØ MPI::BOOL, Complex<xxxx>À» À§ÇØ MPI::COMPLEX, MPI::DOUBLE_COMPLEX, MPI::LONG_DOUBLE_COMPLEXµîÀÌ Ãß°¡µÇ¾î Á³´Ù.

Communicators

±âÁ¸ÀÇ MPI-1°ú Ʋ¸° Á¡Àº MPI-1Àº ¿ÀÁ÷ ÇѰ¡Áö ÇüÅÂÀÇ handleÀÌ ¸ðµç communicator¿¡ Àû¿ëµÇ¾úÁö¸¸, MPI-2¿¡¼­´Â Á÷Á¢ ´Ù¾çÇÑ ÇüÅÂÀÇ communicatorÀ» Á¤ÀÇÇÏ´Â °ÍÀÌ °¡´ÉÇÏ´Ù. ÀÌ¹Ì Á¤ÀÇµÈ °ÍÀ¸·Î´Â MPI::Comm. MPI::Intercomm, MPI::Intracomm, MPI::Cartcomm, MPI::GraphcommµîÀÌ ÀÖ´Ù. ÀÌÁß MPI::CommÀÌ base Ŭ·¡½º°¡ µÈ´Ù.

¿¹¿Üó¸®

C++ÀÇ Exception Handling ÇüÅ·ΠC++ bindingµÈ MPIµµ exception handleÀ» À§ÇÑ ±â´ÉÀ» °¡Áö°í Àִµ¥ MPI::ERRORS_THROW_EXCEPTIONS°¡ ±×°ÍÀÌ´Ù. À̰Ϳ¡ ÀÇÇÑ ¿¡·¯´Â MPI::ExceptionÀ» ¾ß±â½Ã۸ç MPI::SUCCESS¸¦ Á¦¿ÜÇÑ ¸ðµç MPI result code¿¡¼­ ¹ß»ýµÈ´Ù.

È¥ÇÕµÈ ¾ð¾î¿¡¼­ÀÇ ±â´É

C++ bindingµÈ MPI-2´Â C¿ÍÀÇ È¥ÇÕµÈ »ç¿ëÀ» À§ÇØ

MPI::<CLASS>& MPI::<CLASS>::operator=(const MPI_<CLASS>& data)

MPI::<CLASS>(cost MPI_<CLASS>& data)

MPI::<CLASS>::operator MPI<CLASS>() const

µîÀÇ ±â´ÉÀ» °¡Áö°í ÀÖ´Ù.

¡¡

Fortran

MPI-2¿¡¼­ÀÇ Fortran bindingÀº Fortran 90¿¡¼­ ÀÌ·ç¾î Á³´Ù. µû¶ó¼­ Fortran 90ÀÌ Fortran 77°ú °ÅÀÇ À¯»çÇϹǷΠ¸î¸î ¿¹¿Ü¸¦ Á¦¿ÜÇϰí´Â Fortran 77 compiler´Â MPI-2¸¦ compileÇÒ ¼ö ÀÖ´Ù.

2 level Áö¿ø

1. Basic Fortran Support : MPI-1¿¡¼­ÀÇ ¸ðµç »çÇ×°ú, ¾à°£ÀÇ Ãß°¡µÈ ±â´É

2. Extended Fortran Support : Fortran90À» À§ÇØ Æ¯º°È÷ ºÎ°¡µÈ ±â´É

MPI_SIZEOF,

MPI_TYPE_MATCH_SIZE,

MPI_TYPE_CREATE_F90_INTEGER,

MPI_TYPE_CREATE_F90_REAL,

MPI_TYPE_CREATE_F90_COMPLEX

KIND-paramerized type : ¿©·¯ °³ Áß¿¡¼­ ÇÑ °³¸¦ ¼±ÅÃ

Fortran¿¡¼­ Á¦°øÇÏ´Â selected_real_kind, selected_int_kindµîÀ» ÀÌ¿ë.

¼­·Î ÀÌÁúÀûÀÎ machine¿¡¼­ÀÇ ½ÇÇà¿¡ ´ëºñ, ÇüÀÇ ÀÏÄ¡¸¦ À§ÇØ MPI_TYPE_CREATE_F90_xxxx(p, r, newtype) À¸·Î »õ·Î¿î ÇüÅÂÀÇ newtypeÀ» ÁöÁ¤ÇÒ ¼ö ÀÖ´Ù.À̶§ p´Â precision, rÀº exponent range°¡ µÈ´Ù.

Fortran90¿¡ À־ÀÇ ¹®Á¦Á¡

MPIÀÚü°¡ Fortran¿¡ bindingµÇ´Â µ¥´Â ¾à°£ÀÇ ¹®Á¦¸¦ °¡Áö°í ÀÖ¾ú´Âµ¥, Fortran 90¿¡ ¿À¸é¼­ ÀÌ·¯ÇÑ ¹®Á¦°¡ ´õ ½É°¢ÇØ Á³´Ù. ÀÌ·¯ÇÑ °ÍÀº MPIÀÇ »ç¿ë¼ºÀ» À§ÇØ ºÒ°¡ÇÇ ÇÑ °Í ÀÌ´Ù.

Strong Type checkingÀ¸·Î ÀÎÇÑ ¿À·ù

(choice dummy argument, array dummy argument)

integer i(5)

real x(5)

call mpi_send(x, 5, MPI_REAL....)

call mpi_send(i, 5, MPI_INTEGER,....)

mpi_send()¿¡¼­ óÀ½ À§Ä¡ÇÏ´Â argumenetÀÇ ÇüÀÌ ¿©·¯ °¡Áö ÀÏ ¼ö Àִµ¥, À̶§ ¿À·ù°¡ ¹ß»ýÇÒ ¼ö ÀÖÀ½. ? CompileÇÒ ¶§ optionÀ̳ª ´Ù¸¥ Á¶ÀÛÀÌ ÇÊ¿ä.

Data copying¿Í Sequence °ü°è¿¡ ÀÇÇÑ ¿À·ù

Column major¹æ½Ä ÀÌ ¿¬¼ÓµÇ´Â memory¿¡ ´ëÇÑ Á¢±ÙÀ» °í·ÁÇÏ°í ¼³°èµÈ MPI¿Í Àß ¸ÂÁö¸¦ ¾Ê´Â´Ù. A(1:100:2)¿Í °°Àº ÇüÅ¿¡¼­ Non blocking callÀ» ÇÒ °æ¿ì, temporary buffer¸¦ »ý¼ºÇϰí ÀÌ temporal buffer¿¡´Â ¿¬¼ÓÀûÀ¸·Î µé¾î°¡³ª, MPI°¡ Ãß ÈÄ ¾µ ¶§´Â address¸¦ ¹þ¾î ³¯ ¼ö ÀÖ´Ù.

Ưº°ÇÑ »ó¼ö

MPI_BUTTOM, MPI_STATUS_IGNOREµîµî - Ç¥ÁØ¿¡¼­´Â Çã¿ëµÇÁö ¾Ê°í, ¿ÜºÎ¿¡¼­ÀÇ Á¶ÀÛÀÌ ÇÊ¿äÇÏ¸ç ´ë°³ÀÇ °æ¿ì »ó¼ö°¡ ¾Æ´Ñ predefiend static variableÇüŸ¦ ÃëÇϰí ÀÖ´Ù.

Derived type

Fortran 90 ÀÌ Áö¿øÇÏ´Â derived type¿¡ ´ëÇØ choice dummy argument °¡ À̸¦ Áö¿ø ¸øÇÔ.

Register Optimization

MPIÀÇ °¨Ãß¾îÁø µ¿ÀÛ¿¡ ´ëÇØ Fortran compiler°¡ ÇàÇÏ´Â register optimizationÀÌ ¿ªÈ¿°ú¸¦ ³¾ ¼öµµ ÀÖ´Ù. ¾î¶² º¯¼ö°¡ local·Î ¼±¾ðµÇ¾ú´Ù¸é FortranÀÌ À̰ÍÀ» ¿ÜºÎ¿¡¼­´Â ÀÌ¿ëÇÏÁö ¸øÇÏ´Â º¯¼ö·Î Ãë±ÞÇϰí register¿¡¼­¸¸ µ¿ÀÛÇÒ ¼öµµ Àִµ¥, ÀÌ·¯ÇÑ °æ¿ì Non-Blocking callÀ» ¾µ °æ¿ì ¹®Á¦°¡ ÀÖÀ» ¼ö ÀÖ´Ù.