示例#1
0
        ExchangeIntern(DeviceBuffer<TYPE, DIM>& source, GridLayout<DIM> memoryLayout, DataSpace<DIM> guardingCells, uint32_t exchange,
                       uint32_t communicationTag, uint32_t area = BORDER, bool sizeOnDevice = false) :
        Exchange<TYPE, DIM>(exchange, communicationTag), deviceDoubleBuffer(NULL)
        {

            assert(!guardingCells.isOneDimensionGreaterThan(memoryLayout.getGuard()));

            DataSpace<DIM> tmp_size = memoryLayout.getDataSpaceWithoutGuarding();
            /*
              DataSpace<DIM> tmp_size = memoryLayout.getDataSpace() - memoryLayout.getGuard() -
                      memoryLayout.getGuard(); delete on each side 2xguard*/

            DataSpace<DIM> exchangeDimensions = exchangeTypeToDim(exchange);

            for (uint32_t dim = 0; dim < DIM; dim++)
            {
                if (DIM > dim && exchangeDimensions[dim] == 1)
                    tmp_size[dim] = guardingCells[dim];
            }

            /*This is only a pointer to other device data
             */
            this->deviceBuffer = new DeviceBufferIntern<TYPE, DIM > (source, tmp_size,
                                                                     exchangeTypeToOffset(exchange, memoryLayout, guardingCells, area),
                                                                     sizeOnDevice);
            if (DIM > DIM1)
            {
                /*create double buffer on gpu for faster memory transfers*/
                this->deviceDoubleBuffer = new DeviceBufferIntern<TYPE, DIM > (tmp_size, false, true);
            }

            this->hostBuffer = new HostBufferIntern<TYPE, DIM > (tmp_size);
        }
示例#2
0
 MessageHeader(Space simSize, GridLayout<DIM2> layout, Space nodeOffset) :
 simSize(simSize),
 nodeOffset(nodeOffset)
 {
     nodeSize = layout.getDataSpace();
     nodePictureSize = layout.getDataSpaceWithoutGuarding();
     nodeGuardCells = layout.getGuard();
 }
示例#3
0
        DataSpace<DIM> exchangeTypeToOffset(uint32_t exchange, GridLayout<DIM> &memoryLayout,
                                            DataSpace<DIM> guardingCells, uint32_t area) const
        {
            DataSpace<DIM> size = memoryLayout.getDataSpace();
            DataSpace<DIM> border = memoryLayout.getGuard();
            Mask mask(exchange);
            DataSpace<DIM> tmp_offset;
            if (DIM >= DIM1)
            {
                if (mask.containsExchangeType(RIGHT))
                {
                    tmp_offset[0] = size[0] - border[0] - guardingCells[0];
                    if (area == GUARD)
                    {
                        tmp_offset[0] += guardingCells[0];
                    }
                    /* std::cout<<"offset="<<tmp_offset[0]<<"border"<<border[0]<<std::endl;*/
                }
                else
                {
                    tmp_offset[0] = border[0];
                    if (area == GUARD && mask.containsExchangeType(LEFT))
                    {
                        tmp_offset[0] -= guardingCells[0];
                    }
                }
            }
            if (DIM >= DIM2)
            {
                if (mask.containsExchangeType(BOTTOM))
                {
                    tmp_offset[1] = size[1] - border[1] - guardingCells[1];
                    if (area == GUARD)
                    {
                        tmp_offset[1] += guardingCells[1];
                    }
                }
                else
                {
                    tmp_offset[1] = border[1];
                    if (area == GUARD && mask.containsExchangeType(TOP))
                    {
                        tmp_offset[1] -= guardingCells[1];
                    }
                }
            }
            if (DIM == DIM3)
            {
                if (mask.containsExchangeType(BACK))
                {
                    tmp_offset[2] = size[2] - border[2] - guardingCells[2];
                    if (area == GUARD)
                    {
                        tmp_offset[2] += guardingCells[2];
                    }
                }
                else /*all other begin from front*/
                {
                    tmp_offset[2] = border[2];
                    if (area == GUARD && mask.containsExchangeType(FRONT))
                    {
                        tmp_offset[2] -= guardingCells[2];
                    }
                }
            }

            return tmp_offset;

        }