📄 allred.c
字号:
out = (unsigned *)malloc( count * sizeof(unsigned) );sol = (unsigned *)malloc( count * sizeof(unsigned) );for (i=0; i<count; i++) { *(in + i) = 0; *(sol + i) = 0; *(out + i) = 0; }MPI_Allreduce( in, out, count, MPI_UNSIGNED, MPI_LOR, comm );for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}}if (fnderr) fprintf( stderr, "(%d) Error for type MPI_UNSIGNED and op MPI_LOR\n", world_rank );free( in );free( out );free( sol );}{unsigned long *in, *out, *sol;int i, fnderr=0;in = (unsigned long *)malloc( count * sizeof(unsigned long) );out = (unsigned long *)malloc( count * sizeof(unsigned long) );sol = (unsigned long *)malloc( count * sizeof(unsigned long) );for (i=0; i<count; i++) { *(in + i) = 0; *(sol + i) = 0; *(out + i) = 0; }MPI_Allreduce( in, out, count, MPI_UNSIGNED_LONG, MPI_LOR, comm );for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}}if (fnderr) fprintf( stderr, "(%d) Error for type MPI_UNSIGNED_LONG and op MPI_LOR\n", world_rank );free( in );free( out );free( sol );}gerr += errcnt;if (errcnt > 0) printf( "Found %d errors on %d for MPI_LOR(0)\n", errcnt, rank );errcnt = 0;/* Test LXOR */if (world_rank == 0 && verbose) printf( "Testing MPI_LXOR...\n" );{int *in, *out, *sol;int i, fnderr=0;in = (int *)malloc( count * sizeof(int) );out = (int *)malloc( count * sizeof(int) );sol = (int *)malloc( count * sizeof(int) );for (i=0; i<count; i++) { *(in + i) = (rank == 1); *(sol + i) = (size > 1); *(out + i) = 0; }MPI_Allreduce( in, out, count, MPI_INT, MPI_LXOR, comm );for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}}if (fnderr) fprintf( stderr, "(%d) Error for type MPI_INT and op MPI_LXOR\n", world_rank );free( in );free( out );free( sol );}{long *in, *out, *sol;int i, fnderr=0;in = (long *)malloc( count * sizeof(long) );out = (long *)malloc( count * sizeof(long) );sol = (long *)malloc( count * sizeof(long) );for (i=0; i<count; i++) { *(in + i) = (rank == 1); *(sol + i) = (size > 1); *(out + i) = 0; }MPI_Allreduce( in, out, count, MPI_LONG, MPI_LXOR, comm );for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}}if (fnderr) fprintf( stderr, "(%d) Error for type MPI_LONG and op MPI_LXOR\n", world_rank );free( in );free( out );free( sol );}{short *in, *out, *sol;int i, fnderr=0;in = (short *)malloc( count * sizeof(short) );out = (short *)malloc( count * sizeof(short) );sol = (short *)malloc( count * sizeof(short) );for (i=0; i<count; i++) { *(in + i) = (rank == 1); *(sol + i) = (size > 1); *(out + i) = 0; }MPI_Allreduce( in, out, count, MPI_SHORT, MPI_LXOR, comm );for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}}if (fnderr) fprintf( stderr, "(%d) Error for type MPI_SHORT and op MPI_LXOR\n", world_rank );free( in );free( out );free( sol );}{unsigned short *in, *out, *sol;int i, fnderr=0;in = (unsigned short *)malloc( count * sizeof(unsigned short) );out = (unsigned short *)malloc( count * sizeof(unsigned short) );sol = (unsigned short *)malloc( count * sizeof(unsigned short) );for (i=0; i<count; i++) { *(in + i) = (rank == 1); *(sol + i) = (size > 1); *(out + i) = 0; }MPI_Allreduce( in, out, count, MPI_UNSIGNED_SHORT, MPI_LXOR, comm );for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}}if (fnderr) fprintf( stderr, "(%d) Error for type MPI_UNSIGNED_SHORT and op MPI_LXOR\n", world_rank );free( in );free( out );free( sol );}{unsigned *in, *out, *sol;int i, fnderr=0;in = (unsigned *)malloc( count * sizeof(unsigned) );out = (unsigned *)malloc( count * sizeof(unsigned) );sol = (unsigned *)malloc( count * sizeof(unsigned) );for (i=0; i<count; i++) { *(in + i) = (rank == 1); *(sol + i) = (size > 1); *(out + i) = 0; }MPI_Allreduce( in, out, count, MPI_UNSIGNED, MPI_LXOR, comm );for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}}if (fnderr) fprintf( stderr, "(%d) Error for type MPI_UNSIGNED and op MPI_LXOR\n", world_rank );free( in );free( out );free( sol );}{unsigned long *in, *out, *sol;int i, fnderr=0;in = (unsigned long *)malloc( count * sizeof(unsigned long) );out = (unsigned long *)malloc( count * sizeof(unsigned long) );sol = (unsigned long *)malloc( count * sizeof(unsigned long) );for (i=0; i<count; i++) { *(in + i) = (rank == 1); *(sol + i) = (size > 1); *(out + i) = 0; }MPI_Allreduce( in, out, count, MPI_UNSIGNED_LONG, MPI_LXOR, comm );for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}}if (fnderr) fprintf( stderr, "(%d) Error for type MPI_UNSIGNED_LONG and op MPI_LXOR\n", world_rank );free( in );free( out );free( sol );}gerr += errcnt;if (errcnt > 0) printf( "Found %d errors on %d for MPI_LXOR(1)\n", errcnt, rank );errcnt = 0;{int *in, *out, *sol;int i, fnderr=0;in = (int *)malloc( count * sizeof(int) );out = (int *)malloc( count * sizeof(int) );sol = (int *)malloc( count * sizeof(int) );for (i=0; i<count; i++) { *(in + i) = 0; *(sol + i) = 0; *(out + i) = 0; }MPI_Allreduce( in, out, count, MPI_INT, MPI_LXOR, comm );for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}}if (fnderr) fprintf( stderr, "(%d) Error for type MPI_INT and op MPI_LXOR\n", world_rank );free( in );free( out );free( sol );}{long *in, *out, *sol;int i, fnderr=0;in = (long *)malloc( count * sizeof(long) );out = (long *)malloc( count * sizeof(long) );sol = (long *)malloc( count * sizeof(long) );for (i=0; i<count; i++) { *(in + i) = 0; *(sol + i) = 0; *(out + i) = 0; }MPI_Allreduce( in, out, count, MPI_LONG, MPI_LXOR, comm );for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}}if (fnderr) fprintf( stderr, "(%d) Error for type MPI_LONG and op MPI_LXOR\n", world_rank );free( in );free( out );free( sol );}{short *in, *out, *sol;int i, fnderr=0;in = (short *)malloc( count * sizeof(short) );out = (short *)malloc( count * sizeof(short) );sol = (short *)malloc( count * sizeof(short) );for (i=0; i<count; i++) { *(in + i) = 0; *(sol + i) = 0; *(out + i) = 0; }MPI_Allreduce( in, out, count, MPI_SHORT, MPI_LXOR, comm );for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}}if (fnderr) fprintf( stderr, "(%d) Error for type MPI_SHORT and op MPI_LXOR\n", world_rank );free( in );free( out );free( sol );}{unsigned short *in, *out, *sol;int i, fnderr=0;in = (unsigned short *)malloc( count * sizeof(unsigned short) );out = (unsigned short *)malloc( count * sizeof(unsigned short) );sol = (unsigned short *)malloc( count * sizeof(unsigned short) );for (i=0; i<count; i++) { *(in + i) = 0; *(sol + i) = 0; *(out + i) = 0; }MPI_Allreduce( in, out, count, MPI_UNSIGNED_SHORT, MPI_LXOR, comm );for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}}if (fnderr) fprintf( stderr, "(%d) Error for type MPI_UNSIGNED_SHORT and op MPI_LXOR\n", world_rank );free( in );free( out );free( sol );}{unsigned *in, *out, *sol;int i, fnderr=0;in = (unsigned *)malloc( count * sizeof(unsigned) );out = (unsigned *)malloc( count * sizeof(unsigned) );sol = (unsigned *)malloc( count * sizeof(unsigned) );for (i=0; i<count; i++) { *(in + i) = 0; *(sol + i) = 0; *(out + i) = 0; }MPI_Allreduce( in, out, count, MPI_UNSIGNED, MPI_LXOR, comm );for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}}if (fnderr) fprintf( stderr, "(%d) Error for type MPI_UNSIGNED and op MPI_LXOR\n", world_rank );free( in );free( out );free( sol );}{unsigned long *in, *out, *sol;int i, fnderr=0;in = (unsigned long *)malloc( count * sizeof(unsigned long) );out = (unsigned long *)malloc( count * sizeof(unsigned long) );sol = (unsigned long *)malloc( count * sizeof(unsigned long) );for (i=0; i<count; i++) { *(in + i) = 0; *(sol + i) = 0; *(out + i) = 0; }MPI_Allreduce( in, out, count, MPI_UNSIGNED_LONG, MPI_LXOR, comm );for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}}if (fnderr) fprintf( stderr, "(%d) Error for type MPI_UNSIGNED_LONG and op MPI_LXOR\n", world_rank );free( in );free( out );free( sol );}gerr += errcnt;if (errcnt > 0) printf( "Found %d errors on %d for MPI_LXOR(0)\n", errcnt, rank );errcnt = 0;{int *in, *out, *sol;int i, fnderr=0;in = (int *)malloc( count * sizeof(int) );out = (int *)malloc( count * sizeof(int) );sol = (int *)malloc( count * sizeof(int) );for (i=0; i<count; i++) { *(in + i) = 1; *(sol + i) = 0; *(out + i) = 0; }MPI_Allreduce( in, out, count, MPI_INT, MPI_LXOR, comm );for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}}if (fnderr) fprintf( stderr, "(%d) Error for type MPI_INT and op MPI_LXOR\n", world_rank );free( in );free( out );free( sol );}{long *in, *out, *sol;int i, fnderr=0;in = (long *)malloc( count * sizeof(long) );out = (long *)malloc( count * sizeof(long) );sol = (long *)malloc( count * sizeof(long) );for (i=0; i<count; i++) { *(in + i) = 1; *(sol + i) = 0; *(out + i) = 0; }MPI_Allreduce( in, out, count, MPI_LONG, MPI_LXOR, comm );for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}}if (fnderr) fprintf( stderr, "(%d) Error for type MPI_LONG and op MPI_LXOR\n", world_rank );free( in );free( out );free( sol );}{short *in, *out, *sol;int i, fnderr=0;in = (short *)malloc( count * sizeof(short) );out = (short *)malloc( count * sizeof(short) );sol = (short *)malloc( count * sizeof(short) );for (i=0; i<count; i++) { *(in + i) = 1; *(sol + i) = 0; *(out + i) = 0; }MPI_Allreduce( in, out, count, MPI_SHORT, MPI_LXOR, comm );for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}}if (fnderr) fprintf( stderr, "(%d) Error for type MPI_SHORT and op MPI_LXOR\n", world_rank );free( in );free( out );free( sol );}{unsigned short *in, *out, *sol;int i, fnderr=0;in = (unsigned short *)malloc( count * sizeof(unsigned short) );out = (unsigned short *)malloc( count * sizeof(unsigned short) );sol = (unsigned short *)malloc( count * sizeof(unsigned short) );for (i=0; i<count; i++) { *(in + i) = 1; *(sol + i) = 0; *(out + i) = 0; }MPI_Allreduce( in, out, count, MPI_UNSIGNED_SHORT, MPI_LXOR, comm );for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}}if (fnderr) fprintf( stderr, "(%d) Error for type MPI_UNSIGNED_SHORT and op MPI_LXOR\n", world_rank );free( in );free( out );free( sol );}{unsigned *in, *out, *sol;int i, fnderr=0;in = (unsigned *)malloc( count * sizeof(unsigned) );out = (unsigned *)malloc( count * sizeof(unsigned) );sol = (unsigned *)malloc( count * sizeof(unsigned) );for (i=0; i<count; i++) { *(in + i) = 1; *(sol + i) = 0; *(out + i) = 0; }MPI_Allreduce( in, out, count, MPI_UNSIGNED, MPI_LXOR, comm );for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}}if (fnderr) fprintf( stderr, "(%d) Error for type MPI_UNSIGNED and op MPI_LXOR\n", world_rank );free( in );free( out );free( sol );}{unsigned long *in, *out, *sol;int i, fnderr=0;in = (unsigned long *)malloc( count * sizeof(unsigned long) );out = (unsigned long *)malloc( count * sizeof(unsigned long) );sol = (unsigned long *)malloc( count * sizeof(unsigned long) );for (i=0; i<count; i++) { *(in + i) = 1; *(sol + i) = 0; *(out + i) = 0; }MPI_Allreduce( in, out, count, MPI_UNSIGNED_LONG, MPI_LXOR, comm );for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}}if (fnderr) fprintf( stderr, "(%d) Error for type MPI_UNSIGNED_LONG and op MPI_LXOR\n", world_rank );free( in );free( out );free( sol );}gerr += errcnt;if (errcnt > 0) printf( "Found %d errors on %d for MPI_LXOR(1-0)\n", errcnt, rank );errcnt = 0;/* Test LAND */if (world_rank == 0 && verbose) printf( "Testing MPI_LAND...\n" );{int *in, *out, *sol;int i, fnderr=0;in = (int *)malloc( count * sizeof(int) );out = (int *)malloc( count * sizeof(int) );sol = (int *)malloc( count * sizeof(int) );for (i=0; i<count; i++) { *(in + i) = (rank & 0x1); *(sol + i) = 0; *(out + i) = 0; }MPI_Allreduce( in, out, count, MPI_INT, MPI_LAND, comm );for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}}if (fnderr) fprintf( stderr, "(%d) Error for type MPI_INT and op MPI_LAND\n", world_rank );free( in );free( out );free( sol );}{long *in, *out, *sol;int i, fnderr=0;in = (long *)malloc( count * sizeof(long) );out = (long *)malloc( count * sizeof(long) );sol = (long *)malloc( count * sizeof(long) );for (i=0; i<count; i++) { *(in + i) = (rank & 0x1); *(sol + i) = 0; *(out + i) = 0; }MPI_Allreduce( in, out, count, MPI_LONG, MPI_LAND, comm );for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}}if (fnderr) fprintf( stderr, "(%d) Error for type MPI_LONG and op MPI_LAND\n", world_rank );free( in );free( out );free( sol );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -