⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 allreduce.cc

📁 MPICH是MPI的重要研究,提供了一系列的接口函数,为并行计算的实现提供了编程环境.
💻 CC
字号:
// Copyright 1997-2000, University of Notre Dame.// Authors: Jeremy G. Siek, Jeffery M. Squyres, Michael P. McNally, and//          Andrew Lumsdaine// // This file is part of the Notre Dame C++ bindings for MPI.// // You should have received a copy of the License Agreement for the Notre// Dame C++ bindings for MPI along with the software; see the file// LICENSE.  If not, contact Office of Research, University of Notre// Dame, Notre Dame, IN 46556.// // Permission to modify the code and to distribute modified code is// granted, provided the text of this NOTICE is retained, a notice that// the code was modified is included with the above COPYRIGHT NOTICE and// with the COPYRIGHT NOTICE in the LICENSE file, and that the LICENSE// file is distributed with the modified code.// // LICENSOR MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED.// By way of example, but not limitation, Licensor MAKES NO// REPRESENTATIONS OR WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY// PARTICULAR PURPOSE OR THAT THE USE OF THE LICENSED SOFTWARE COMPONENTS// OR DOCUMENTATION WILL NOT INFRINGE ANY PATENTS, COPYRIGHTS, TRADEMARKS// OR OTHER RIGHTS.// // Additional copyrights may follow./**************************************************************************** MESSAGE PASSING INTERFACE TEST CASE SUITE Copyright IBM Corp. 1995 IBM Corp. hereby grants a non-exclusive license to use, copy, modify, and distribute this software for any purpose and without fee provided that the above copyright notice and the following paragraphs appear in all copies. IBM Corp. makes no representation that the test cases comprising this suite are correct or are an accurate representation of any standard. In no event shall IBM be liable to any party for direct, indirect, special incidental, or consequential damage arising out of the use of this software even if IBM Corp. has been advised of the possibility of such damage. IBM CORP. SPECIFICALLY DISCLAIMS ANY WARRANTIES INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS AND IBM CORP. HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.**************************************************************************** These test cases reflect an interpretation of the MPI Standard.  They are are, in most cases, unit tests of specific MPI behaviors.  If a user of any test case from this set believes that the MPI Standard requires behavior different than that implied by the test case we would appreciate feedback. Comments may be sent to:    Richard Treumann    treumann@kgn.ibm.com*****************************************************************************/#include "mpi2c++_test.h"#define MAXLEN 1000void allreduce(){  char msg[150];  int ccin[MAXLEN];  int ccout[MAXLEN];  int i;  int in[MAXLEN];  int j;  int k;  int out[MAXLEN];    Testing("Allreduce");  for ( j = 1; j <= MAXLEN; j *= 10) {    for ( i = 0; i < j; i++) {      out[i] = i;      ccout[i] = i;    }        MPI::COMM_WORLD.Allreduce(out,in,j,MPI::INT,MPI::SUM);    MPI_Allreduce(ccout,ccin,j,MPI_INT,MPI_SUM,MPI_COMM_WORLD);        for ( k = 0; k < j; k++)      if (in[k] != ccin[k]) {	sprintf(msg,"NODE %d - 1) Bad answer %d at index %d of %d (should be %d)",		my_rank, in[k], k + i * j, j * comm_size, ccin[k]);	Fail(msg);      }  }  Pass(); // Allreduce}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -