本文整理汇总了C++中MPI_Type_size函数的典型用法代码示例。如果您正苦于以下问题:C++ MPI_Type_size函数的具体用法?C++ MPI_Type_size怎么用?C++ MPI_Type_size使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MPI_Type_size函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: ARMCII_Buf_acc_scale
/** Prepare a set of buffers for use with an accumulate operation. The
* returned set of buffers is guaranteed to be in private space and scaled.
* Copies will be made if needed, the result should be completed by finish.
*
* @param[in] buf Original set of buffers.
* @param[in] count Number of entries in the buffer list.
* @param[in] size The size of the buffers (all are of the same size).
* @param[in] datatype The type of the buffer.
* @param[in] scale Scaling constant to apply to each buffer.
* @return Pointer to the new buffer or buf
*/
void ARMCII_Buf_acc_scale(void *buf_in, void *buf_out, int size, int datatype, void *scale) {
int j, nelem;
int type_size = -1;
MPI_Datatype type;
switch (datatype) {
case ARMCI_ACC_INT:
MPI_Type_size(MPI_INT, &type_size);
type = MPI_INT;
nelem= size/type_size;
{
int *src_i = (int*) buf_in;
int *scl_i = (int*) buf_out;
const int s = *((int*) scale);
for (j = 0; j < nelem; j++)
scl_i[j] = src_i[j]*s;
}
break;
case ARMCI_ACC_LNG:
MPI_Type_size(MPI_LONG, &type_size);
type = MPI_LONG;
nelem= size/type_size;
{
long *src_l = (long*) buf_in;
long *scl_l = (long*) buf_out;
const long s = *((long*) scale);
for (j = 0; j < nelem; j++)
scl_l[j] = src_l[j]*s;
}
break;
case ARMCI_ACC_FLT:
MPI_Type_size(MPI_FLOAT, &type_size);
type = MPI_FLOAT;
nelem= size/type_size;
{
float *src_f = (float*) buf_in;
float *scl_f = (float*) buf_out;
const float s = *((float*) scale);
for (j = 0; j < nelem; j++)
scl_f[j] = src_f[j]*s;
}
break;
case ARMCI_ACC_DBL:
MPI_Type_size(MPI_DOUBLE, &type_size);
type = MPI_DOUBLE;
nelem= size/type_size;
{
double *src_d = (double*) buf_in;
double *scl_d = (double*) buf_out;
const double s = *((double*) scale);
for (j = 0; j < nelem; j++)
scl_d[j] = src_d[j]*s;
}
break;
case ARMCI_ACC_CPL:
MPI_Type_size(MPI_FLOAT, &type_size);
type = MPI_FLOAT;
nelem= size/type_size;
{
float *src_fc = (float*) buf_in;
float *scl_fc = (float*) buf_out;
const float s_r = ((float*)scale)[0];
const float s_c = ((float*)scale)[1];
for (j = 0; j < nelem; j += 2) {
// Complex multiplication: (a + bi)*(c + di)
const float src_fc_j = src_fc[j];
const float src_fc_j_1 = src_fc[j+1];
/*
scl_fc[j] = src_fc[j]*s_r - src_fc[j+1]*s_c;
scl_fc[j+1] = src_fc[j+1]*s_r + src_fc[j]*s_c;
*/
scl_fc[j] = src_fc_j*s_r - src_fc_j_1*s_c;
scl_fc[j+1] = src_fc_j_1*s_r + src_fc_j*s_c;
}
}
//.........这里部分代码省略.........
开发者ID:abhinavvishnu,项目名称:matex,代码行数:101,代码来源:buffer.c
示例2: blockindexed_contig_test
/* blockindexed_contig_test()
*
* Tests behavior with a blockindexed that can be converted to a
* contig easily. This is specifically for coverage.
*
* Returns the number of errors encountered.
*/
int blockindexed_contig_test(void)
{
int buf[4] = { 7, -1, -2, -3 };
int err, errs = 0;
int i, count = 1;
int disp = 0;
MPI_Datatype newtype;
int size, int_size;
MPI_Aint extent;
err = MPI_Type_create_indexed_block(count, 1, &disp, MPI_INT, &newtype);
if (err != MPI_SUCCESS) {
if (verbose) {
fprintf(stderr, "error creating struct type in blockindexed_contig_test()\n");
}
errs++;
}
MPI_Type_size(MPI_INT, &int_size);
err = MPI_Type_size(newtype, &size);
if (err != MPI_SUCCESS) {
if (verbose) {
fprintf(stderr, "error obtaining type size in blockindexed_contig_test()\n");
}
errs++;
}
if (size != int_size) {
if (verbose) {
fprintf(stderr, "error: size != int_size in blockindexed_contig_test()\n");
}
errs++;
}
err = MPI_Type_extent(newtype, &extent);
if (err != MPI_SUCCESS) {
if (verbose) {
fprintf(stderr, "error obtaining type extent in blockindexed_contig_test()\n");
}
errs++;
}
if (extent != int_size) {
if (verbose) {
fprintf(stderr, "error: extent != int_size in blockindexed_contig_test()\n");
}
errs++;
}
MPI_Type_commit(&newtype);
err = pack_and_unpack((char *) buf, 1, newtype, 4 * sizeof(int));
if (err != 0) {
if (verbose) {
fprintf(stderr, "error packing/unpacking in blockindexed_contig_test()\n");
}
errs += err;
}
for (i = 0; i < 4; i++) {
int goodval;
switch (i) {
case 0:
goodval = 7;
break;
default:
goodval = 0; /* pack_and_unpack() zeros before unpack */
break;
}
if (buf[i] != goodval) {
errs++;
if (verbose)
fprintf(stderr, "buf[%d] = %d; should be %d\n", i, buf[i], goodval);
}
}
MPI_Type_free(&newtype);
return errs;
}
开发者ID:ParaStation,项目名称:psmpi2,代码行数:91,代码来源:blockindexed_misc.c
示例3: main
int main(int argc, char *argv[])
{
int i, j, nerrors=0, total_errors=0;
int rank, size;
int bpos;
MPI_Datatype darray;
MPI_Status status;
MPI_File mpi_fh;
/* Define array distribution
A 2x2 block size works with ROMIO, a 3x3 block size breaks it. */
int distrib[2] = { MPI_DISTRIBUTE_CYCLIC, MPI_DISTRIBUTE_CYCLIC };
int bsize[2] = { NBLOCK, NBLOCK };
int gsize[2] = { NSIDE, NSIDE };
int psize[2] = { NPROC, NPROC };
double data[NSIDE*NSIDE];
double *ldata, *pdata;
int tsize, nelem;
MPI_File dfile;
MPI_Init(&argc, &argv);
MPI_Comm_size(MPI_COMM_WORLD, &size);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
/* Set up type */
CHECK(MPI_Type_create_darray(size, rank, 2, gsize, distrib,
bsize, psize, MPI_ORDER_FORTRAN, MPI_DOUBLE, &darray));
CHECK(MPI_Type_commit(&darray));
CHECK(MPI_Type_size(darray, &tsize));
nelem = tsize / sizeof(double);
for(i = 0; i < (NSIDE*NSIDE); i++) data[i] = i;
if (rank == 0) {
CHECK(MPI_File_open(MPI_COMM_SELF, argv[1],
MPI_MODE_CREATE|MPI_MODE_WRONLY, MPI_INFO_NULL, &dfile));
CHECK(MPI_File_write(dfile, data, NSIDE*NSIDE, MPI_DOUBLE, &status));
CHECK(MPI_File_close(&dfile));
}
MPI_Barrier(MPI_COMM_WORLD);
/* Allocate buffer */
ldata = (double *)malloc(tsize);
pdata = (double *)malloc(tsize);
/* Use Pack to pull out array */
bpos = 0;
CHECK(MPI_Pack(data, 1, darray, pdata, tsize, &bpos, MPI_COMM_WORLD));
MPI_Barrier(MPI_COMM_WORLD);
/* Read in array from file. */
CHECK(MPI_File_open(MPI_COMM_WORLD, argv[1], MPI_MODE_RDONLY, MPI_INFO_NULL, &mpi_fh));
CHECK(MPI_File_set_view(mpi_fh, 0, MPI_DOUBLE, darray, "native", MPI_INFO_NULL));
CHECK(MPI_File_read_all(mpi_fh, ldata, nelem, MPI_DOUBLE, &status));
CHECK(MPI_File_close(&mpi_fh));
for(i = 0; i < size; i++) {
#ifdef VERBOSE
MPI_Barrier(MPI_COMM_WORLD);
if(rank == i) {
printf("=== Rank %i === (%i elements) \nPacked: ", rank, nelem);
for(j = 0; j < nelem; j++) {
printf("%4.1f ", pdata[j]);
fflush(stdout);
}
printf("\nRead: ");
for(j = 0; j < nelem; j++) {
printf("%4.1f ", ldata[j]);
fflush(stdout);
}
printf("\n\n");
fflush(stdout);
}
#endif
if(rank == i) {
for (j=0; j< nelem; j++) {
if (pdata[j] != ldata[j]) {
fprintf(stderr, "rank %d at index %d: packbuf %4.1f filebuf %4.1f\n",
rank, j, pdata[j], ldata[j]);
nerrors++;
}
}
}
}
MPI_Allreduce(&nerrors, &total_errors, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
if (rank == 0 && total_errors == 0)
printf(" No Errors\n");
free(ldata);
free(pdata);
MPI_Type_free(&darray);
MPI_Finalize();
//.........这里部分代码省略.........
开发者ID:Niharikareddy,项目名称:mpich,代码行数:101,代码来源:darray_read.c
示例4: ADIOI_NFS_WriteStrided
void ADIOI_NFS_WriteStrided(ADIO_File fd, void *buf, int count,
MPI_Datatype datatype, int file_ptr_type,
ADIO_Offset offset, ADIO_Status *status, int
*error_code)
{
/* offset is in units of etype relative to the filetype. */
ADIOI_Flatlist_node *flat_buf, *flat_file;
int i, j, k, err=-1, bwr_size, fwr_size=0, st_index=0;
int bufsize, num, size, sum, n_etypes_in_filetype, size_in_filetype;
int n_filetypes, etype_in_filetype;
ADIO_Offset abs_off_in_filetype=0;
int filetype_size, etype_size, buftype_size, req_len;
MPI_Aint filetype_extent, buftype_extent;
int buf_count, buftype_is_contig, filetype_is_contig;
ADIO_Offset userbuf_off;
ADIO_Offset off, req_off, disp, end_offset, writebuf_off, start_off;
char *writebuf, *value;
int flag, st_fwr_size, st_n_filetypes, writebuf_len, write_sz;
int new_bwr_size, new_fwr_size, err_flag=0, info_flag, max_bufsize;
#ifndef PRINT_ERR_MSG
static char myname[] = "ADIOI_NFS_WRITESTRIDED";
#endif
ADIOI_Datatype_iscontig(datatype, &buftype_is_contig);
ADIOI_Datatype_iscontig(fd->filetype, &filetype_is_contig);
MPI_Type_size(fd->filetype, &filetype_size);
MPI_Type_extent(fd->filetype, &filetype_extent);
MPI_Type_size(datatype, &buftype_size);
MPI_Type_extent(datatype, &buftype_extent);
etype_size = fd->etype_size;
bufsize = buftype_size * count;
/* get max_bufsize from the info object. */
value = (char *) ADIOI_Malloc((MPI_MAX_INFO_VAL+1)*sizeof(char));
MPI_Info_get(fd->info, "ind_wr_buffer_size", MPI_MAX_INFO_VAL, value,
&info_flag);
max_bufsize = atoi(value);
ADIOI_Free(value);
if (!buftype_is_contig && filetype_is_contig) {
/* noncontiguous in memory, contiguous in file. */
ADIOI_Flatten_datatype(datatype);
flat_buf = ADIOI_Flatlist;
while (flat_buf->type != datatype) flat_buf = flat_buf->next;
off = (file_ptr_type == ADIO_INDIVIDUAL) ? fd->fp_ind :
fd->disp + etype_size * offset;
start_off = off;
end_offset = off + bufsize - 1;
writebuf_off = off;
writebuf = (char *) ADIOI_Malloc(max_bufsize);
writebuf_len = (int) (ADIOI_MIN(max_bufsize,end_offset-writebuf_off+1));
/* if atomicity is true, lock the region to be accessed */
if (fd->atomicity)
ADIOI_WRITE_LOCK(fd, start_off, SEEK_SET, end_offset-start_off+1);
for (j=0; j<count; j++)
for (i=0; i<flat_buf->count; i++) {
userbuf_off = j*buftype_extent + flat_buf->indices[i];
req_off = off;
req_len = flat_buf->blocklens[i];
ADIOI_BUFFERED_WRITE_WITHOUT_READ
off += flat_buf->blocklens[i];
}
/* write the buffer out finally */
lseek(fd->fd_sys, writebuf_off, SEEK_SET);
if (!(fd->atomicity)) ADIOI_WRITE_LOCK(fd, writebuf_off, SEEK_SET, writebuf_len);
err = write(fd->fd_sys, writebuf, writebuf_len);
if (!(fd->atomicity)) ADIOI_UNLOCK(fd, writebuf_off, SEEK_SET, writebuf_len);
if (err == -1) err_flag = 1;
if (fd->atomicity)
ADIOI_UNLOCK(fd, start_off, SEEK_SET, end_offset-start_off+1);
ADIOI_Free(writebuf); /* malloced in the buffered_write macro */
if (file_ptr_type == ADIO_INDIVIDUAL) fd->fp_ind = off;
#ifdef PRINT_ERR_MSG
*error_code = (err_flag) ? MPI_ERR_UNKNOWN : MPI_SUCCESS;
#else
if (err_flag) {
*error_code = MPIR_Err_setmsg(MPI_ERR_IO, MPIR_ADIO_ERROR,
myname, "I/O Error", "%s", strerror(errno));
ADIOI_Error(fd, *error_code, myname);
}
else *error_code = MPI_SUCCESS;
#endif
}
else { /* noncontiguous in file */
//.........这里部分代码省略.........
开发者ID:carsten-clauss,项目名称:MP-MPICH,代码行数:101,代码来源:ad_nfs_write.c
示例5: blockindexed_vector_test
/* blockindexed_vector_test()
*
* Tests behavior with a blockindexed of some vector types;
* this shouldn't be easily convertable into anything else.
*
* Returns the number of errors encountered.
*/
int blockindexed_vector_test(void)
{
#define NELT (18)
int buf[NELT] = { -1, -1, -1,
1, -2, 2,
-3, -3, -3,
-4, -4, -4,
3, -5, 4,
5, -6, 6
};
int expected[NELT] = {
0, 0, 0,
1, 0, 2,
0, 0, 0,
0, 0, 0,
3, 0, 4,
5, 0, 6
};
int err, errs = 0;
int i, count = 3;
int disp[] = { 1, 4, 5 };
MPI_Datatype vectype, newtype;
int size, int_size;
/* create a vector type of 2 ints, skipping one in between */
err = MPI_Type_vector(2, 1, 2, MPI_INT, &vectype);
if (err != MPI_SUCCESS) {
if (verbose) {
fprintf(stderr, "error creating vector type in blockindexed_contig_test()\n");
}
errs++;
}
err = MPI_Type_create_indexed_block(count, 1, disp, vectype, &newtype);
if (err != MPI_SUCCESS) {
if (verbose) {
fprintf(stderr, "error creating blockindexed type in blockindexed_contig_test()\n");
}
errs++;
}
MPI_Type_size(MPI_INT, &int_size);
err = MPI_Type_size(newtype, &size);
if (err != MPI_SUCCESS) {
if (verbose) {
fprintf(stderr, "error obtaining type size in blockindexed_contig_test()\n");
}
errs++;
}
if (size != 6 * int_size) {
if (verbose) {
fprintf(stderr, "error: size != 6 * int_size in blockindexed_contig_test()\n");
}
errs++;
}
MPI_Type_commit(&newtype);
err = pack_and_unpack((char *) buf, 1, newtype, NELT * sizeof(int));
if (err != 0) {
if (verbose) {
fprintf(stderr, "error packing/unpacking in blockindexed_vector_test()\n");
}
errs += err;
}
for (i = 0; i < NELT; i++) {
if (buf[i] != expected[i]) {
errs++;
if (verbose)
fprintf(stderr, "buf[%d] = %d; should be %d\n", i, buf[i], expected[i]);
}
}
MPI_Type_free(&vectype);
MPI_Type_free(&newtype);
return errs;
}
开发者ID:ParaStation,项目名称:psmpi2,代码行数:89,代码来源:blockindexed_misc.c
示例6: ADIOI_Get_eof_offset
void ADIOI_Get_eof_offset(ADIO_File fd, ADIO_Offset *eof_offset)
{
unsigned filetype_size;
int error_code, filetype_is_contig, etype_size;
ADIO_Offset fsize, disp, sum=0, size_in_file, n_filetypes, rem;
int flag, i;
ADIO_Fcntl_t *fcntl_struct;
MPI_Aint filetype_extent;
ADIOI_Flatlist_node *flat_file;
/* find the eof in bytes */
fcntl_struct = (ADIO_Fcntl_t *) ADIOI_Malloc(sizeof(ADIO_Fcntl_t));
ADIO_Fcntl(fd, ADIO_FCNTL_GET_FSIZE, fcntl_struct, &error_code);
fsize = fcntl_struct->fsize;
ADIOI_Free(fcntl_struct);
/* Find the offset in etype units corresponding to eof.
The eof could lie in a hole in the current view, or in the
middle of an etype. In that case the offset will be the offset
corresponding to the start of the next etype in the current view.*/
ADIOI_Datatype_iscontig(fd->filetype, &filetype_is_contig);
etype_size = fd->etype_size;
if (filetype_is_contig)
*eof_offset = (fsize - fd->disp + etype_size - 1)/etype_size;
/* ceiling division in case fsize is not a multiple of etype_size;*/
else {
/* filetype already flattened in ADIO_Open */
flat_file = ADIOI_Flatlist;
while (flat_file->type != fd->filetype)
flat_file = flat_file->next;
MPI_Type_size(fd->filetype, (int*)&filetype_size);
MPI_Type_extent(fd->filetype, &filetype_extent);
disp = fd->disp;
n_filetypes = -1;
flag = 0;
while (!flag) {
sum = 0;
n_filetypes++;
for (i=0; i<flat_file->count; i++) {
sum += flat_file->blocklens[i];
if (disp + flat_file->indices[i] +
n_filetypes* ADIOI_AINT_CAST_TO_OFFSET filetype_extent +
flat_file->blocklens[i] >= fsize) {
if (disp + flat_file->indices[i] +
n_filetypes * ADIOI_AINT_CAST_TO_OFFSET filetype_extent >= fsize)
sum -= flat_file->blocklens[i];
else {
rem = (disp + flat_file->indices[i] +
n_filetypes* ADIOI_AINT_CAST_TO_OFFSET filetype_extent
+ flat_file->blocklens[i] - fsize);
sum -= rem;
}
flag = 1;
break;
}
}
}
size_in_file = n_filetypes*(ADIO_Offset)filetype_size + sum;
*eof_offset = (size_in_file+etype_size-1)/etype_size; /* ceiling division */
}
}
开发者ID:315234,项目名称:OpenFOAM-2.2.x-OSX,代码行数:65,代码来源:eof_offset.c
示例7: IMB_igatherv
void IMB_igatherv(struct comm_info* c_info,
int size,
struct iter_schedule* ITERATIONS,
MODES RUN_MODE,
double* time)
/*
MPI-NBC benchmark kernel
Benchmarks MPI_Igatherv
Input variables:
-c_info (type struct comm_info*)
Collection of all base data for MPI;
see [1] for more information
-size (type int)
Basic message size in bytes
-ITERATIONS (type struct iter_schedule *)
Repetition scheduling
-RUN_MODE (type MODES)
(only MPI-2 case: see [1])
Output variables:
-time (type double*)
Timing result per sample
*/
{
int i = 0;
Type_Size s_size,
r_size;
int s_num = 0,
r_num = 0;
MPI_Request request;
MPI_Status status;
double t_pure = 0.,
t_comp = 0.,
t_ovrlp = 0.;
#ifdef CHECK
defect=0.;
#endif
ierr = 0;
/* GET SIZE OF DATA TYPE */
MPI_Type_size(c_info->s_data_type, &s_size);
MPI_Type_size(c_info->r_data_type, &r_size);
if ((s_size!=0) && (r_size!=0)) {
s_num = size / s_size;
r_num = size / r_size;
}
if(c_info->rank != -1) {
/* GET PURE TIME. DISPLACEMENT AND RECEIVE COUNT WILL BE INITIALIZED HERE */
IMB_igatherv_pure(c_info, size, ITERATIONS, RUN_MODE, &t_pure);
/* INITIALIZATION CALL */
IMB_cpu_exploit(t_pure, 1);
for(i=0; i<N_BARR; i++) {
MPI_Barrier(c_info->communicator);
}
t_ovrlp = MPI_Wtime();
for(i=0; i < ITERATIONS->n_sample; i++)
{
ierr = MPI_Igatherv((char*)c_info->s_buffer + i % ITERATIONS->s_cache_iter * ITERATIONS->s_offs,
s_num,
c_info->s_data_type,
(char*)c_info->r_buffer + i % ITERATIONS->r_cache_iter * ITERATIONS->r_offs,
c_info->reccnt,
c_info->rdispl,
c_info->r_data_type,
i % c_info->num_procs, // root = round robin
c_info->communicator,
&request);
MPI_ERRHAND(ierr);
t_comp -= MPI_Wtime();
IMB_cpu_exploit(t_pure, 0);
t_comp += MPI_Wtime();
MPI_Wait(&request, &status);
#ifdef CHECK
if (c_info->rank == i % c_info->num_procs) {
CHK_DIFF("Igatherv", c_info,
(char*)c_info->r_buffer + i % ITERATIONS->r_cache_iter * ITERATIONS->r_offs,
0, 0, ((size_t)c_info->num_procs * (size_t)size),
1, put, 0, ITERATIONS->n_sample, i, -2, &defect);
}
#endif // CHECK
//.........这里部分代码省略.........
开发者ID:jedwards4b,项目名称:IMB,代码行数:101,代码来源:IMB_gatherv.c
示例8: ompi_coll_libnbc_ialltoall
/* simple linear MPI_Ialltoall the (simple) algorithm just sends to all nodes */
int ompi_coll_libnbc_ialltoall(void* sendbuf, int sendcount, MPI_Datatype sendtype, void* recvbuf, int recvcount,
MPI_Datatype recvtype, struct ompi_communicator_t *comm, ompi_request_t ** request,
struct mca_coll_base_module_2_1_0_t *module)
{
int rank, p, res, a2asize, sndsize, datasize;
NBC_Schedule *schedule;
MPI_Aint rcvext, sndext;
#ifdef NBC_CACHE_SCHEDULE
NBC_Alltoall_args *args, *found, search;
#endif
char *rbuf, *sbuf, inplace;
enum {NBC_A2A_LINEAR, NBC_A2A_PAIRWISE, NBC_A2A_DISS} alg;
NBC_Handle *handle;
ompi_coll_libnbc_request_t **coll_req = (ompi_coll_libnbc_request_t**) request;
ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module;
NBC_IN_PLACE(sendbuf, recvbuf, inplace);
res = NBC_Init_handle(comm, coll_req, libnbc_module);
if(res != NBC_OK) { printf("Error in NBC_Init_handle(%i)\n", res); return res; }
handle = (*coll_req);
res = MPI_Comm_rank(comm, &rank);
if (MPI_SUCCESS != res) { printf("MPI Error in MPI_Comm_rank() (%i)\n", res); return res; }
res = MPI_Comm_size(comm, &p);
if (MPI_SUCCESS != res) { printf("MPI Error in MPI_Comm_size() (%i)\n", res); return res; }
res = MPI_Type_extent(sendtype, &sndext);
if (MPI_SUCCESS != res) { printf("MPI Error in MPI_Type_extent() (%i)\n", res); return res; }
res = MPI_Type_extent(recvtype, &rcvext);
if (MPI_SUCCESS != res) { printf("MPI Error in MPI_Type_extent() (%i)\n", res); return res; }
res = MPI_Type_size(sendtype, &sndsize);
if (MPI_SUCCESS != res) { printf("MPI Error in MPI_Type_size() (%i)\n", res); return res; }
/* algorithm selection */
a2asize = sndsize*sendcount*p;
/* this number is optimized for TCP on odin.cs.indiana.edu */
if((p <= 8) && ((a2asize < 1<<17) || (sndsize*sendcount < 1<<12))) {
/* just send as fast as we can if we have less than 8 peers, if the
* total communicated size is smaller than 1<<17 *and* if we don't
* have eager messages (msgsize < 1<<13) */
alg = NBC_A2A_LINEAR;
} else if(a2asize < (1<<12)*p) {
/*alg = NBC_A2A_DISS;*/
alg = NBC_A2A_LINEAR;
} else
alg = NBC_A2A_LINEAR; /*NBC_A2A_PAIRWISE;*/
if(!inplace) {
/* copy my data to receive buffer */
rbuf = ((char *)recvbuf) + (rank*recvcount*rcvext);
sbuf = ((char *)sendbuf) + (rank*sendcount*sndext);
res = NBC_Copy(sbuf, sendcount, sendtype, rbuf, recvcount, recvtype, comm);
if (NBC_OK != res) { printf("Error in NBC_Copy() (%i)\n", res); return res; }
}
/* allocate temp buffer if we need one */
if(alg == NBC_A2A_DISS) {
/* only A2A_DISS needs buffers */
if(NBC_Type_intrinsic(sendtype)) {
datasize = sndext*sendcount;
} else {
res = MPI_Pack_size(sendcount, sendtype, comm, &datasize);
if (MPI_SUCCESS != res) { printf("MPI Error in MPI_Pack_size() (%i)\n", res); return res; }
}
/* allocate temporary buffers */
if(p % 2 == 0) {
handle->tmpbuf=malloc(datasize*p*2);
} else {
/* we cannot divide p by two, so alloc more to be safe ... */
handle->tmpbuf=malloc(datasize*(p/2+1)*2*2);
}
/* phase 1 - rotate n data blocks upwards into the tmpbuffer */
#if OPAL_CUDA_SUPPORT
if(NBC_Type_intrinsic(sendtype) && !(opal_cuda_check_bufs((char *)sendbuf, (char *)recvbuf))) {
#else
if(NBC_Type_intrinsic(sendtype)) {
#endif /* OPAL_CUDA_SUPPORT */
/* contiguous - just copy (1st copy) */
memcpy(handle->tmpbuf, (char*)sendbuf+datasize*rank, datasize*(p-rank));
if(rank != 0) memcpy((char*)handle->tmpbuf+datasize*(p-rank), sendbuf, datasize*(rank));
} else {
int pos=0;
/* non-contiguous - pack */
res = MPI_Pack((char*)sendbuf+rank*sendcount*sndext, (p-rank)*sendcount, sendtype, handle->tmpbuf, (p-rank)*datasize, &pos, comm);
if (MPI_SUCCESS != res) { printf("MPI Error in MPI_Pack() (%i)\n", res); return res; }
if(rank != 0) {
pos = 0;
MPI_Pack(sendbuf, rank*sendcount, sendtype, (char*)handle->tmpbuf+datasize*(p-rank), rank*datasize, &pos, comm);
if (MPI_SUCCESS != res) { printf("MPI Error in MPI_Pack() (%i)\n", res); return res; }
}
}
} else {
handle->tmpbuf=NULL;
}
#ifdef NBC_CACHE_SCHEDULE
/* search schedule in communicator specific tree */
search.sendbuf=sendbuf;
//.........这里部分代码省略.........
开发者ID:XuanWang1982,项目名称:ompi,代码行数:101,代码来源:nbc_ialltoall.c
示例9: ADIOI_PIOFS_WriteContig
void ADIOI_PIOFS_WriteContig(ADIO_File fd, void *buf, int count,
MPI_Datatype datatype, int file_ptr_type,
ADIO_Offset offset, ADIO_Status *status, int *error_code)
{
int err=-1, datatype_size, len;
#ifndef PRINT_ERR_MSG
static char myname[] = "ADIOI_PIOFS_WRITECONTIG";
#endif
MPI_Type_size(datatype, &datatype_size);
len = datatype_size * count;
if (file_ptr_type == ADIO_EXPLICIT_OFFSET) {
if (fd->fp_sys_posn != offset) {
#ifdef PROFILE
MPE_Log_event(11, 0, "start seek");
#endif
llseek(fd->fd_sys, offset, SEEK_SET);
#ifdef PROFILE
MPE_Log_event(12, 0, "end seek");
#endif
}
#ifdef PROFILE
MPE_Log_event(5, 0, "start write");
#endif
err = write(fd->fd_sys, buf, len);
#ifdef PROFILE
MPE_Log_event(6, 0, "end write");
#endif
fd->fp_sys_posn = offset + err;
/* individual file pointer not updated */
}
else { /* write from curr. location of ind. file pointer */
if (fd->fp_sys_posn != fd->fp_ind) {
#ifdef PROFILE
MPE_Log_event(11, 0, "start seek");
#endif
llseek(fd->fd_sys, fd->fp_ind, SEEK_SET);
#ifdef PROFILE
MPE_Log_event(12, 0, "end seek");
#endif
}
#ifdef PROFILE
MPE_Log_event(5, 0, "start write");
#endif
err = write(fd->fd_sys, buf, len);
#ifdef PROFILE
MPE_Log_event(6, 0, "end write");
#endif
fd->fp_ind += err;
fd->fp_sys_posn = fd->fp_ind;
}
#ifdef HAVE_STATUS_SET_BYTES
if (err != -1) MPIR_Status_set_bytes(status, datatype, err);
#endif
if (err == -1) {
#ifdef MPICH2
*error_code = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_IO, "**io",
"**io %s", strerror(errno));
#elif defined(PRINT_ERR_MSG)
*error_code = MPI_ERR_UNKNOWN;
#else
*error_code = MPIR_Err_setmsg(MPI_ERR_IO, MPIR_ADIO_ERROR,
myname, "I/O Error", "%s", strerror(errno));
ADIOI_Error(fd, *error_code, myname);
#endif
}
else *error_code = MPI_SUCCESS;
}
开发者ID:aosm,项目名称:openmpi,代码行数:71,代码来源:io_romio_ad_piofs_write.c
示例10: PLA_API_Poll_request
int PLA_API_Poll_request ( )
/*--------------------------------------------------------------------------
Purpose : Poll to see if messages have come in
----------------------------------------------------------------------------*/
{
int
msgtype,
m, n, lda,
obj_index, source,
align_row, align_col,
typesize,
local_ldim,
temp;
PLA_Obj
obj_source = NULL;
void
*local_buf;
MPI_Datatype
datatype;
if ( PLA_API_Accept_recv_request_buffer( ) ){
/* New recv put_buffer has come in */
while ( !PLA_API_End_of_recv_request_buffer ( ) ){
/* Process next message */
PLA_API_read_data_from_request_buffer( sizeof( int ),
( char * ) &msgtype );
switch ( msgtype ){
case PLA_API_TYPE_PUT:
PLA_Abort( "API illegal type", __LINE__, __FILE__ );
case PLA_API_TYPE_SYNC:
request_sync_counter ++;
break;
case PLA_API_TYPE_GET:
PLA_API_read_data_from_request_buffer( sizeof( int ), ( char * ) &m );
PLA_API_read_data_from_request_buffer( sizeof( int ), ( char * ) &n );
PLA_API_read_data_from_request_buffer( sizeof( int ),
( char * ) &obj_index );
PLA_API_read_data_from_request_buffer( sizeof( int ),
( char * ) &align_row );
PLA_API_read_data_from_request_buffer( sizeof( int ),
( char * ) &align_col );
PLA_API_read_data_from_request_buffer( sizeof( void * ),
( char * ) &local_buf );
PLA_API_read_data_from_request_buffer( sizeof( int ),
( char * ) &lda );
PLA_API_read_data_from_request_buffer( sizeof( int ),
( char * ) &source );
/* Take view into appropriate object */
PLA_Obj_view( open_objects_list[ obj_index ],
m, n, align_row, align_col, &obj_source );
/* Create room to send current message */
PLA_Obj_datatype( obj_source, &datatype );
MPI_Type_size( datatype, &typesize );
PLA_API_put_buffer_make_room( 5 * sizeof( int ) +
sizeof( void * ) +
m * n * typesize, source );
/* Enter put destination information in the buffer */
temp = PLA_API_TYPE_GET;
PLA_API_add_data_to_put_buffer( sizeof( int ), ( char * ) &temp,
source );
/* PLA_API_add_data_to_put_buffer( sizeof( int ), ( char * ) &datatype,
source ); */
PLA_API_add_data_to_put_buffer( sizeof( int ), ( char * ) &obj_index,
source );
PLA_API_add_data_to_put_buffer( sizeof( int ), ( char * ) &m,
source );
PLA_API_add_data_to_put_buffer( sizeof( int ), ( char * ) &n,
source );
PLA_API_add_data_to_put_buffer( sizeof( void * ),
( char * ) &local_buf, source );
PLA_API_add_data_to_put_buffer( sizeof( int ), ( char * ) &lda,
source );
/* Add the contents of the object to the buffer */
PLA_API_add_contents_from_obj_to_put_buffer( obj_source, source );
break;
default:
PLA_Abort( "API illegal type", __LINE__, __FILE__ );
}
}
}
PLA_Obj_free( &obj_source );
return PLA_SUCCESS;
}
开发者ID:OpenCMISS-Dependencies,项目名称:plapack,代码行数:99,代码来源:PLA_API_util.c
示例11: ADIOI_GEN_ReadStrided_naive
void ADIOI_GEN_ReadStrided_naive(ADIO_File fd, void *buf, int count,
MPI_Datatype buftype, int file_ptr_type,
ADIO_Offset offset, ADIO_Status *status, int
*error_code)
{
/* offset is in units of etype relative to the filetype. */
ADIOI_Flatlist_node *flat_buf, *flat_file;
int brd_size, frd_size=0, b_index;
int bufsize, size, sum, n_etypes_in_filetype, size_in_filetype;
int n_filetypes, etype_in_filetype;
ADIO_Offset abs_off_in_filetype=0;
int filetype_size, etype_size, buftype_size, req_len;
MPI_Aint filetype_extent, buftype_extent;
int buf_count, buftype_is_contig, filetype_is_contig;
ADIO_Offset userbuf_off;
ADIO_Offset off, req_off, disp, end_offset=0, start_off;
ADIO_Status status1;
*error_code = MPI_SUCCESS; /* changed below if error */
ADIOI_Datatype_iscontig(buftype, &buftype_is_contig);
ADIOI_Datatype_iscontig(fd->filetype, &filetype_is_contig);
MPI_Type_size(fd->filetype, &filetype_size);
if ( ! filetype_size ) {
*error_code = MPI_SUCCESS;
return;
}
MPI_Type_extent(fd->filetype, &filetype_extent);
MPI_Type_size(buftype, &buftype_size);
MPI_Type_extent(buftype, &buftype_extent);
etype_size = fd->etype_size;
bufsize = buftype_size * count;
/* contiguous in buftype and filetype is handled elsewhere */
if (!buftype_is_contig && filetype_is_contig) {
int b_count;
/* noncontiguous in memory, contiguous in file. */
ADIOI_Flatten_datatype(buftype);
flat_buf = ADIOI_Flatlist;
while (flat_buf->type != buftype) flat_buf = flat_buf->next;
off = (file_ptr_type == ADIO_INDIVIDUAL) ? fd->fp_ind :
fd->disp + etype_size * offset;
start_off = off;
end_offset = off + bufsize - 1;
/* if atomicity is true, lock (exclusive) the region to be accessed */
if ((fd->atomicity) && (fd->file_system != ADIO_PIOFS) &&
(fd->file_system != ADIO_PVFS))
{
ADIOI_WRITE_LOCK(fd, start_off, SEEK_SET, end_offset-start_off+1);
}
/* for each region in the buffer, grab the data and put it in
* place
*/
for (b_count=0; b_count < count; b_count++) {
for (b_index=0; b_index < flat_buf->count; b_index++) {
userbuf_off = b_count*buftype_extent +
flat_buf->indices[b_index];
req_off = off;
req_len = flat_buf->blocklens[b_index];
ADIO_ReadContig(fd,
(char *) buf + userbuf_off,
req_len,
MPI_BYTE,
ADIO_EXPLICIT_OFFSET,
req_off,
&status1,
error_code);
if (*error_code != MPI_SUCCESS) return;
/* off is (potentially) used to save the final offset later */
off += flat_buf->blocklens[b_index];
}
}
if ((fd->atomicity) && (fd->file_system != ADIO_PIOFS) &&
(fd->file_system != ADIO_PVFS))
{
ADIOI_UNLOCK(fd, start_off, SEEK_SET, end_offset-start_off+1);
}
if (file_ptr_type == ADIO_INDIVIDUAL) fd->fp_ind = off;
}
else { /* noncontiguous in file */
int f_index, st_frd_size, st_index = 0, st_n_filetypes;
int flag;
/* First we're going to calculate a set of values for use in all
//.........这里部分代码省略.........
开发者ID:hpc,项目名称:mvapich-cce,代码行数:101,代码来源:ad_read_str_naive.c
示例12: PLA_API_add_matrix_from_recv_buffer_to_local
int PLA_API_add_matrix_from_recv_buffer_to_local(
MPI_Datatype datatype, int m, int n,
void *local_buf, int lda )
{
int i, j, typesize, cur_length;
/* align */
cur_length = recv_put_buffer_done;
cur_length = ( ( cur_length % SIZE_OF_UNIT ) == 0 ?
cur_length : ( cur_length / SIZE_OF_UNIT + 1 ) * SIZE_OF_UNIT );
recv_put_buffer_done = cur_length;
MPI_Type_size( datatype, &typesize );
if ( datatype == MPI_DOUBLE ) {
double *buf_local, *buf_recv, *tempp_local, *tempp_recv;
buf_local = (double *) local_buf;
buf_recv = ( double * ) ( ( char * ) recv_put_buffer + recv_put_buffer_done );
for ( j=0; j<n; j++ ){
tempp_local = buf_local + j*lda;
tempp_recv = buf_recv + j*m;
for ( i=0; i<m; i++ )
*tempp_local++ += *tempp_recv++;
}
recv_put_buffer_done += m * n * typesize;
}
else if ( datatype == MPI_FLOAT ) {
float *buf_local, *buf_recv, *tempp_local, *tempp_recv;
buf_local = (float *) local_buf;
buf_recv = ( float * ) ( ( char * ) recv_put_buffer + recv_put_buffer_done );
for ( j=0; j<n; j++ ){
tempp_local = buf_local + j*lda;
tempp_recv = buf_recv + j*m;
for ( i=0; i<m; i++ )
*tempp_local++ += *tempp_recv++;
}
recv_put_buffer_done += m * n * typesize;
}
else if ( datatype == MPI_DOUBLE_COMPLEX ) {
double *buf_local, *buf_recv, *tempp_local, *tempp_recv;
buf_local = (double *) local_buf;
buf_recv = ( double * ) ( ( char * ) recv_put_buffer + recv_put_buffer_done );
for ( j=0; j<n; j++ ){
tempp_local = buf_local + j*lda*2;
tempp_recv = buf_recv + j*m*2;
for ( i=0; i<2*m; i++ )
*tempp_local++ += *tempp_recv++;
}
recv_put_buffer_done += m * n * typesize;
}
else if ( datatype == MPI_COMPLEX ) {
float *buf_local, *buf_recv, *tempp_local, *tempp_recv;
buf_local = (float *) local_buf;
buf_recv = ( float * ) ( ( char * ) recv_put_buffer + recv_put_buffer_done );
for ( j=0; j<n; j++ ){
tempp_local = buf_local + j*lda*2;
tempp_recv = buf_recv + j*m*2;
for ( i=0; i<2*m; i++ )
*tempp_local++ += *tempp_recv++;
}
recv_put_buffer_done += m * n * typesize;
}
else {
PLA_Abort( "datatype not yet implemented", __LINE__, __FILE__ );
}
}
开发者ID:OpenCMISS-Dependencies,项目名称:plapack,代码行数:78,代码来源:PLA_API_util.c
示例13: IMB_bcast
void IMB_bcast(struct comm_info* c_info, int size, struct iter_schedule* ITERATIONS,
MODES RUN_MODE, double* time)
/*
MPI-1 benchmark kernel
Benchmarks MPI_Bcast
Input variables:
-c_info (type struct comm_info*)
Collection of all base data for MPI;
see [1] for more information
-size (type int)
Basic message size in bytes
-ITERATIONS (type struct iter_schedule *)
Repetition scheduling
-RUN_MODE (type MODES)
(only MPI-2 case: see [1])
Output variables:
-time (type double*)
Timing result per sample
*/
{
double t1, t2;
int i,i1;
Type_Size s_size;
int s_num;
void* bc_buf;
#ifdef CHECK
defect=0.;
#endif
ierr = 0;
/* GET SIZE OF DATA TYPE */
MPI_Type_size(c_info->s_data_type,&s_size);
if (s_size!=0) s_num=size/s_size;
if(c_info->rank!=-1)
{
i1=0;
for(i=0; i<N_BARR; i++) MPI_Barrier(c_info->communicator);
t1 = MPI_Wtime();
for(i=0;i< ITERATIONS->n_sample;i++)
{
/* Provide that s_buffer is not overwritten */
bc_buf = (i1 == c_info->rank) ? c_info->s_buffer : c_info->r_buffer;
ierr= MPI_Bcast((char*)bc_buf+i%ITERATIONS->s_cache_iter*ITERATIONS->s_offs,
s_num,c_info->s_data_type,
i1,c_info->communicator);
MPI_ERRHAND(ierr);
CHK_DIFF("Bcast", c_info,
(char*)bc_buf + i % ITERATIONS->s_cache_iter * ITERATIONS->s_offs,
0, size, size, 1, put, 0, ITERATIONS->n_sample, i, i1, &defect);
/* CHANGE THE ROOT NODE */
i1=(++i1)%c_info->num_procs;
}
t2 = MPI_Wtime();
*time=(t2 - t1)/(ITERATIONS->n_sample);
}
else
{
*time = 0.;
}
}
开发者ID:Cai900205,项目名称:test,代码行数:82,代码来源:IMB_bcast.c
示例14: IMB_ibcast_pure
void IMB_ibcast_pure(struct comm_info* c_info,
int size,
struct iter_schedule* ITERATIONS,
MODES RUN_MODE,
double* time)
/*
MPI-NBC benchmark kernel
Benchmarks MPI_Ibcast
Input variables:
-c_info (type struct comm_info*)
Collection of all base data for MPI;
see [1] for more information
-size (type int)
Basic message size in bytes
-ITERATIONS (type struct iter_schedule *)
Repetition scheduling
-RUN_MODE (type MODES)
(only MPI-2 case: see [1])
Output variables:
-time (type double*)
Timing result per sample
*/
{
int i = 0,
root = 0;
Type_Size s_size;
int s_num = 0;
void* bc_buf = NULL;
MPI_Request request;
MPI_Status status;
double t_pure = 0.;
#ifdef CHECK
defect = 0.;
#endif
ierr = 0;
/* GET SIZE OF DATA TYPE */
MPI_Type_size(c_info->s_data_type, &s_size);
if (s_size != 0) {
s_num = size / s_size;
}
if(c_info->rank != -1) {
root = 0;
for (i = 0; i < N_BARR; i++) {
MPI_Barrier(c_info->communicator);
}
t_pure = MPI_Wtime();
for(i = 0; i < ITERATIONS->n_sample; i++)
{
bc_buf = (root == c_info->rank)
? c_info->s_buffer
: c_info->r_buffer;
ierr = MPI_Ibcast((char*)bc_buf + i % ITERATIONS->s_cache_iter * ITERATIONS->s_offs,
s_num,
c_info->s_data_type,
root,
c_info->communicator,
&request);
MPI_ERRHAND(ierr);
MPI_Wait(&request, &status);
CHK_DIFF("Ibcast_pure", c_info,
(char*)bc_buf + i % ITERATIONS->s_cache_iter * ITERATIONS->s_offs,
0, size, size, 1, put, 0, ITERATIONS->n_sample, i, root, &defect);
root = (++root) % c_info->num_procs;
}
t_pure = (MPI_Wtime() - t_pure) / ITERATIONS->n_sample;
}
time[0] = t_pure;
}
开发者ID:Cai900205,项目名称:test,代码行数:89,代码来源:IMB_bcast.c
示例15: ADIOI_NFS_WriteStrided
void ADIOI_NFS_WriteStrided(ADIO_File fd, const void *buf, int count,
MPI_Datatype datatype, int file_ptr_type,
ADIO_Offset offset, ADIO_Status *status, int
*error_code)
{
/* offset is in units of etype relative to the filetype. */
ADIOI_Flatlist_node *flat_buf, *flat_file;
int i, j, k, err=-1, bwr_size, fwr_size=0, st_index=0;
int bufsize, num, size, sum, n_etypes_in_filetype, size_in_filetype;
int n_filetypes, etype_in_filetype;
ADIO_Offset abs_off_in_filetype=0;
int filetype_size, etype_size, buftype_size, req_len;
MPI_Aint filetype_extent, buftype_extent;
int buf_count, buftype_is_contig, filetype_is_contig;
ADIO_Offset userbuf_off;
ADIO_Offset off, req_off, disp, end_offset=0, writebuf_off, start_off;
char *writebuf, *value;
int st_fwr_size, st_n_filetypes, writebuf_len, write_sz;
int new_bwr_size, new_fwr_size, err_flag=0, info_flag, max_bufsize;
static char myname[] = "ADIOI_NFS_WRITESTRIDED";
ADIOI_Datatype_iscontig(datatype, &buftype_is_contig);
ADIOI_Datatype_iscontig(fd->filetype, &filetype_is_contig);
MPI_Type_size(fd->filetype, &filetype_size);
if ( ! filetype_size ) {
#ifdef HAVE_STATUS_SET_BYTES
MPIR_Status_set_bytes(status, datatype, 0);
#endif
*error_code = MPI_SUCCESS;
return;
}
MPI_Type_extent(fd->filetype, &filetype_extent);
MPI_Type_size(datatype, &buftype_size);
MPI_Type_extent(datatype, &buftype_extent);
etype_size = fd->etype_size;
bufsize = buftype_size * count;
/* get max_bufsize from the info object. */
value = (char *) ADIOI_Malloc((MPI_MAX_INFO_VAL+1)*sizeof(char));
ADIOI_Info_get(fd->info, "ind_wr_buffer_size", MPI_MAX_INFO_VAL, value,
&info_flag);
max_bufsize = atoi(value);
ADIOI_Free(value);
if (!buftype_is_contig && filetype_is_contig) {
/* noncontiguous in memory, contiguous in file. */
ADIOI_Flatten_datatype(datatype);
flat_buf = ADIOI_Flatlist;
while (flat_buf->type != datatype) flat_buf = flat_buf->next;
off = (file_ptr_type == ADIO_INDIVIDUAL) ? fd->fp_ind :
fd->disp + etype_size * offset;
start_off = off;
end_offset = off + bufsize - 1;
writebuf_off = off;
writebuf = (char *) ADIOI_Malloc(max_bufsize);
writebuf_len = (int) (ADIOI_MIN(max_bufsize,end_offset-writebuf_off+1));
/* if atomicity is true, lock the region to be accessed */
if (fd->atomicity)
ADIOI_WRITE_LOCK(fd, start_off, SEEK_SET, end_offset-start_off+1);
for (j=0; j<count; j++)
for (i=0; i<flat_buf->count; i++) {
userbuf_off = j*buftype_extent + flat_buf->indices[i];
req_off = off;
req_len = flat_buf->
|
请发表评论