📄 allred.c
字号:
MPI_Allreduce( in, out, count, MPI_UNSIGNED_LONG, MPI_BOR, 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_BOR\n", rank ); free( in ); free( out ); free( sol );}void g12(void){ unsigned char *in, *out, *sol; int i, fnderr=0; in = (unsigned char *)malloc( count * sizeof(unsigned char) ); out = (unsigned char *)malloc( count * sizeof(unsigned char) ); sol = (unsigned char *)malloc( count * sizeof(unsigned char) ); for (i=0; i<count; i++) { *(in + i) = rank & 0x3; *(sol + i) = (size < 3) ? size - 1 : 0x3; *(out + i) = 0; } MPI_Allreduce( in, out, count, MPI_BYTE, MPI_BOR, comm ); for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} if (fnderr) fprintf( stderr, "(%d) Error for type MPI_BYTE and op MPI_BOR\n", rank ); free( in ); free( out ); free( sol );}void a13(void){ 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 == size-1 ? i : ~0); *(sol + i) = i; *(out + i) = 0; } MPI_Allreduce( in, out, count, MPI_INT, MPI_BAND, 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_BAND\n", rank ); free( in ); free( out ); free( sol );}void b13(void){ 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 == size-1 ? i : ~0); *(sol + i) = i; *(out + i) = 0; } MPI_Allreduce( in, out, count, MPI_LONG, MPI_BAND, 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_BAND\n", rank ); free( in ); free( out ); free( sol );}void c13(void){ 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 == size-1 ? i : ~0); *(sol + i) = i; *(out + i) = 0; } MPI_Allreduce( in, out, count, MPI_SHORT, MPI_BAND, 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_BAND\n", rank ); free( in ); free( out ); free( sol );}void d13(void){ 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 == size-1 ? i : ~0); *(sol + i) = i; *(out + i) = 0; } MPI_Allreduce( in, out, count, MPI_UNSIGNED_SHORT, MPI_BAND, 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_BAND\n", rank ); free( in ); free( out ); free( sol );}void e13(void){ 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 == size-1 ? i : ~0); *(sol + i) = i; *(out + i) = 0; } MPI_Allreduce( in, out, count, MPI_UNSIGNED, MPI_BAND, 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_BAND\n", rank ); free( in ); free( out ); free( sol );}void f13(void){ 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 == size-1 ? i : ~0); *(sol + i) = i; *(out + i) = 0; } MPI_Allreduce( in, out, count, MPI_UNSIGNED_LONG, MPI_BAND, 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_BAND\n", rank ); free( in ); free( out ); free( sol );}void g13(void){ unsigned char *in, *out, *sol; int i, fnderr=0; in = (unsigned char *)malloc( count * sizeof(unsigned char) ); out = (unsigned char *)malloc( count * sizeof(unsigned char) ); sol = (unsigned char *)malloc( count * sizeof(unsigned char) ); for (i=0; i<count; i++) { *(in + i) = (rank == size-1 ? i : ~0); *(sol + i) = i; *(out + i) = 0; } MPI_Allreduce( in, out, count, MPI_BYTE, MPI_BAND, comm ); for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} if (fnderr) fprintf( stderr, "(%d) Error for type MPI_BYTE and op MPI_BAND\n", rank ); free( in ); free( out ); free( sol );}void a14(void){ 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 == size-1 ? i : 0); *(sol + i) = 0; *(out + i) = 0; } MPI_Allreduce( in, out, count, MPI_INT, MPI_BAND, 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_BAND\n", rank ); free( in ); free( out ); free( sol );}void b14(void){ 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 == size-1 ? i : 0); *(sol + i) = 0; *(out + i) = 0; } MPI_Allreduce( in, out, count, MPI_LONG, MPI_BAND, 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_BAND\n", rank ); free( in ); free( out ); free( sol );}void c14(void){ 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 == size-1 ? i : 0); *(sol + i) = 0; *(out + i) = 0; } MPI_Allreduce( in, out, count, MPI_SHORT, MPI_BAND, 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_BAND\n", rank ); free( in ); free( out ); free( sol );}void d14(void){ 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 == size-1 ? i : 0); *(sol + i) = 0; *(out + i) = 0; } MPI_Allreduce( in, out, count, MPI_UNSIGNED_SHORT, MPI_BAND, 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_BAND\n", rank ); free( in ); free( out ); free( sol );}void e14(void){ 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 == size-1 ? i : 0); *(sol + i) = 0; *(out + i) = 0; } MPI_Allreduce( in, out, count, MPI_UNSIGNED, MPI_BAND, 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_BAND\n", rank ); free( in ); free( out ); free( sol );}void f14(void){ 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 == size-1 ? i : 0); *(sol + i) = 0; *(out + i) = 0; } MPI_Allreduce( in, out, count, MPI_UNSIGNED_LONG, MPI_BAND, 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_BAND\n", rank ); free( in ); free( out ); free( sol );}void a15(void){ 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)*0xf0 ; *(sol + i) = (size > 1)*0xf0 ; *(out + i) = 0; } MPI_Allreduce( in, out, count, MPI_INT, MPI_BXOR, 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_BXOR\n", rank ); free( in ); free( out ); free( sol );}void b15(void){ 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)*0xf0 ; *(sol + i) = (size > 1)*0xf0 ; *(out + i) = 0; } MPI_Allreduce( in, out, count, MPI_LONG, MPI_BXOR, 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_BXOR\n", rank ); free( in ); free( out ); free( sol );}void c15(void){ 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)*0xf0 ; *(sol + i) = (size > 1)*0xf0 ; *(out + i) = 0; } MPI_Allreduce( in, out, count, MPI_SHORT, MPI_BXOR, 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_BXOR\n", rank ); free( in ); free( out ); free( sol );}void d15(void){ 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)*0xf0 ; *(sol + i) = (size > 1)*0xf0 ; *(out + i) = 0; } MPI_Allreduce( in, out, count, MPI_UNSIGNED_SHORT, MPI_BXOR, 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_BXOR\n", rank ); free( in ); free( out ); free( sol );}void e15(void){ 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)*0xf0 ; *(sol + i) = (size > 1)*0xf0 ; *(out + i) = 0; } MPI_Allreduce( in, out, count, MPI_UNSIGNED, MPI_BXOR, 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_BXOR\n", rank ); free( in ); free( out ); free( sol );}void f15(void){ 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)*0xf0 ; *(sol + i) = (size > 1)*0xf0 ; *(out + i) = 0; } MPI_Allreduce( in, out, count, MPI_UNSIGNED
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -