Beispiel #1
0
    void operator()(T_Dim){

        typedef uint8_t Data;
        typedef size_t Extents;

        std::vector<size_t> nElementsPerDim = getElementsPerDim<T_Dim>();
        
        for(unsigned i = 0; i < nElementsPerDim.size(); ++i){
            ::PMacc::DataSpace<T_Dim::value> const dataSpace = ::PMacc::DataSpace<T_Dim::value>::create(nElementsPerDim[i]);
            ::PMacc::HostBuffer<Data, T_Dim::value>* hostBufferIntern = new ::PMacc::HostBufferIntern<Data, T_Dim::value>(dataSpace);
            ::PMacc::DeviceBuffer<Data, T_Dim::value>* deviceBufferIntern = new ::PMacc::DeviceBufferIntern<Data, T_Dim::value>(dataSpace);

            hostBufferIntern->reset();

            for(size_t i = 0; i < static_cast<size_t>(dataSpace.productOfComponents()); ++i){
                hostBufferIntern->getPointer()[i] = static_cast<Data>(i);
            }

            deviceBufferIntern->copyFrom(*hostBufferIntern);
            hostBufferIntern->reset();
            hostBufferIntern->copyFrom(*deviceBufferIntern);

            for(size_t i = 0; i < static_cast<size_t>(dataSpace.productOfComponents()); ++i){
                BOOST_CHECK_EQUAL(hostBufferIntern->getPointer()[i], static_cast<Data>(i));
            }

            delete hostBufferIntern;
            delete deviceBufferIntern;

        }

    }
Beispiel #2
0
    void update(CellDesc & cellDesc,
                picongpu::Window vWindow,
                Size2D transpose,
                uint32_t currentStep,
                float* cellSizeArr = NULL,
                const PMacc::DataSpace<CellDesc::Dim> gpus = PMacc::DataSpace<CellDesc::Dim > ())
    {
        using namespace PMacc;
        using namespace picongpu;

        enum
        {
            Dim = CellDesc::Dim
        };

        const DataSpace<Dim> localSize(cellDesc.getGridLayout().getDataSpaceWithoutGuarding());
        const DataSpace<DIM2> localSize2D(localSize[transpose.x()], localSize[transpose.y()]);

        /*update only if nuber of gpus are set, else use old value*/
        if (gpus.productOfComponents() != 0)
            sim.nodes = DataSpace<DIM2 > (gpus[transpose.x()], gpus[transpose.y()]);

        PMACC_AUTO(simBox, Environment<simDim>::get().SubGrid().getSimulationBox());

        const DataSpace<Dim> globalSize(simBox.getGlobalSize());
        sim.size.x() = globalSize[transpose.x()];
        sim.size.y() = globalSize[transpose.y()];

        node.maxSize = DataSpace<DIM2 > (localSize[transpose.x()], localSize[transpose.y()]);

        const DataSpace<Dim> windowSize = vWindow.globalDimensions.size;
        window.size = DataSpace<DIM2 > (windowSize[transpose.x()], windowSize[transpose.y()]);

        if (cellSizeArr != NULL)
        {
            float scale[2];
            scale[0] = cellSizeArr[transpose.x()];
            scale[1] = cellSizeArr[transpose.y()];
            sim.cellSizeArr[0] = cellSizeArr[transpose.x()];
            sim.cellSizeArr[1] = cellSizeArr[transpose.y()];

            const float scale0to1 = scale[0] / scale[1];

            if (scale0to1 > 1.0f)
            {
                sim.setScale(scale0to1, 1.f);
            }
            else if (scale0to1 < 1.0f)
            {
                sim.setScale(1.f, 1.0f / scale0to1);
            }
            else
            {
                sim.setScale(1.f, 1.f);
            }
        }

        const DataSpace<Dim> offsetToSimNull(simBox.getGlobalOffset());
        const DataSpace<Dim> windowOffsetToSimNull(vWindow.globalDimensions.offset);
        const DataSpace<Dim> localOffset(vWindow.localDimensions.offset);

        const DataSpace<DIM2> localOffset2D(localOffset[transpose.x()], localOffset[transpose.y()]);
        node.localOffset = localOffset2D;

        DataSpace<Dim> offsetToWindow(offsetToSimNull - windowOffsetToSimNull);

        const DataSpace<DIM2> offsetToWindow2D(offsetToWindow[transpose.x()], offsetToWindow[transpose.y()]);
        node.offsetToWindow = offsetToWindow2D;

        const DataSpace<DIM2> offsetToSimNull2D(offsetToSimNull[transpose.x()], offsetToSimNull[transpose.y()]);
        node.offset = offsetToSimNull2D;

        const DataSpace<DIM2> windowOffsetToSimNull2D(windowOffsetToSimNull[transpose.x()], windowOffsetToSimNull[transpose.y()]);
        window.offset = windowOffsetToSimNull2D;

        const DataSpace<Dim> currentLocalSize(vWindow.localDimensions.size);
        const DataSpace<DIM2> currentLocalSize2D(currentLocalSize[transpose.x()], currentLocalSize[transpose.y()]);
        node.size = currentLocalSize2D;

        sim.step = currentStep;

        /*add sliding windo informations to header*/
        const uint32_t numSlides = MovingWindow::getInstance().getSlideCounter(currentStep);
        sim.simOffsetToNull = DataSpace<DIM2 > ();
        if (transpose.x() == 1)
            sim.simOffsetToNull.x() = node.maxSize.x() * numSlides;
        else if (transpose.y() == 1)
            sim.simOffsetToNull.y() = node.maxSize.y() * numSlides;

    }
Beispiel #3
0
 HDINLINE RefValueType operator()(const PMacc::DataSpace<DIM1> &idx = PMacc::DataSpace<DIM1>())
 {
     const PMacc::DataSpace<Dim> real_idx(DataSpaceOperations<Dim>::map(originalSize, idx.x()));
     return Base::operator()(real_idx);
 }
 HDINLINE RefValueType operator()(const PMacc::DataSpace<DIM1> &idx = PMacc::DataSpace<DIM1>())
 {
     const PMacc::DataSpace<DIM3> real_idx(DataSpaceOperations<DIM3>::map(originalSize, idx.x()));
     return (Base::operator[](real_idx.z()))[real_idx.y()][real_idx.x()];
 }