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

📄 dt_create_struct.c

📁 MPI stands for the Message Passing Interface. Written by the MPI Forum (a large committee comprising
💻 C
字号:
/* -*- Mode: C; c-basic-offset:4 ; -*- *//* * Copyright (c) 2004-2006 The Trustees of Indiana University and Indiana *                         University Research and Technology *                         Corporation.  All rights reserved. * Copyright (c) 2004-2006 The University of Tennessee and The University *                         of Tennessee Research Foundation.  All rights *                         reserved. * Copyright (c) 2004-2006 High Performance Computing Center Stuttgart, *                         University of Stuttgart.  All rights reserved. * Copyright (c) 2004-2006 The Regents of the University of California. *                         All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow * * $HEADER$ */#include "ompi_config.h"#include "ompi/datatype/datatype.h"int32_t ompi_ddt_create_struct( int count, const int* pBlockLength, const MPI_Aint* pDisp,                                ompi_datatype_t* const * pTypes, ompi_datatype_t** newType ){    int i;    ptrdiff_t disp = 0, endto, lastExtent, lastDisp;    int lastBlock;    ompi_datatype_t *pdt, *lastType;    if( 0 == count ) {        *newType = ompi_ddt_create( 0 );        ompi_ddt_add( *newType, &ompi_mpi_datatype_null, 0, 0, 0);        return OMPI_SUCCESS;    }    /* if we compute the total number of elements before we can     * avoid increasing the size of the desc array often.     */    lastType = (ompi_datatype_t*)pTypes[0];    lastBlock = pBlockLength[0];    lastExtent = lastType->ub - lastType->lb;    lastDisp = pDisp[0];    endto = pDisp[0] + lastExtent * lastBlock;    for( i = 1; i < count; i++ ) {        if( (pTypes[i] == lastType) && (pDisp[i] == endto) ) {            lastBlock += pBlockLength[i];            endto = lastDisp + lastBlock * lastExtent;        } else {            disp += lastType->desc.used;            if( lastBlock > 1 ) disp += 2;            lastType = (ompi_datatype_t*)pTypes[i];            lastExtent = lastType->ub - lastType->lb;            lastBlock = pBlockLength[i];            lastDisp = pDisp[i];            endto = lastDisp + lastExtent * lastBlock;        }    }    disp += lastType->desc.used;    if( lastBlock != 1 ) disp += 2;    lastType = (ompi_datatype_t*)pTypes[0];    lastBlock = pBlockLength[0];    lastExtent = lastType->ub - lastType->lb;    lastDisp = pDisp[0];    endto = pDisp[0] + lastExtent * lastBlock;    pdt = ompi_ddt_create( (int32_t)disp );    /* Do again the same loop but now add the elements */    for( i = 1; i < count; i++ ) {        if( (pTypes[i] == lastType) && (pDisp[i] == endto) ) {            lastBlock += pBlockLength[i];            endto = lastDisp + lastBlock * lastExtent;        } else {            ompi_ddt_add( pdt, lastType, lastBlock, lastDisp, lastExtent );            lastType = (ompi_datatype_t*)pTypes[i];            lastExtent = lastType->ub - lastType->lb;            lastBlock = pBlockLength[i];            lastDisp = pDisp[i];            endto = lastDisp + lastExtent * lastBlock;        }    }    ompi_ddt_add( pdt, lastType, lastBlock, lastDisp, lastExtent );    *newType = pdt;    return OMPI_SUCCESS;}

⌨️ 快捷键说明

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