コード例 #1
0
ファイル: LineSliceFields.hpp プロジェクト: AK9527lq/picongpu
        void getLineSliceFields()
        {
            typedef typename MappingDesc::SuperCellSize SuperCellSize;

            const float3_X tmpFloat3(float3_X(float_X(0.0), float_X(0.0), float_X(0.0)));
            sliceDataField->getDeviceBuffer().setValue(tmpFloat3);
            dim3 block(SuperCellSize::toRT().toDim3());

            const SubGrid<simDim>& subGrid = Environment<simDim>::get().SubGrid();
            // global cell id offset (without guardings!)
            // returns the global id offset of the "first" border cell on a GPU
            const DataSpace<simDim> globalCellIdOffset(subGrid.getLocalDomain().offset);

            // global number of cells for whole simulation: local cells on GPU * GPUs
            // (assumed same size on each gpu :-/  -> todo: provide interface!)
            //! \todo create a function for: global number of cells for whole simulation
            //!
            const DataSpace<simDim> localNrOfCells(subGrid.getLocalDomain().size);
            const DataSpace<simDim> globalNrOfCells (subGrid.getGlobalDomain().size);


            __picKernelArea(kernelLineSliceFields, *cellDescription, AREA)
                    (block)
                    (fieldE->getDeviceDataBox(),
                    fieldB->getDeviceDataBox(),
                    sliceDataField->getDeviceBuffer().getBasePointer(),
                    globalCellIdOffset,
                    globalNrOfCells
                    );
            sliceDataField->deviceToHost();
            //return sliceDataField->getHostBuffer().getDataBox()[0];
        }
コード例 #2
0
ファイル: Visualisation.hpp プロジェクト: CodeLemon/picongpu
    void createImage(uint32_t currentStep, VirtualWindow window)
    {
        DataConnector &dc = DataConnector::getInstance();
        // Data does not need to be synchronized as visualization is
        // done at the device.
        FieldB *fieldB = &(dc.getData<FieldB > (FieldB::getName(), true));
        FieldE* fieldE = &(dc.getData<FieldE > (FieldE::getName(), true));
        FieldJ* fieldJ = &(dc.getData<FieldJ > (FieldJ::getName(), true));
        ParticlesType* particles = &(dc.getData<ParticlesType > (particleTag, true));

        PMACC_AUTO(simBox, SubGrid<simDim>::getInstance().getSimulationBox());
        uint32_t globalOffset = 0;
#if(SIMDIM==DIM3)
        globalOffset = SubGrid<simDim>::getInstance().getSimulationBox().getGlobalOffset()[sliceDim];
#endif
        
        typedef MappingDesc::SuperCellSize SuperCellSize;
        assert(cellDescription != NULL);
        //create image fields
        __picKernelArea((kernelPaintFields), *cellDescription, CORE + BORDER)
            (SuperCellSize::getDataSpace())
            (fieldE->getDeviceDataBox(),
             fieldB->getDeviceDataBox(),
             fieldJ->getDeviceDataBox(),
             img->getDeviceBuffer().getDataBox(),
             transpose,
             sliceOffset,
             globalOffset, sliceDim
             );

        // find maximum for img.x()/y and z and return it as float3_X
        int elements = img->getGridLayout().getDataSpace().productOfComponents();

        //Add one dimension access to 2d DataBox
        typedef DataBoxDim1Access<typename GridBuffer<float3_X, DIM2 >::DataBoxType> D1Box;
        D1Box d1access(img->getDeviceBuffer().getDataBox(), img->getGridLayout().getDataSpace());

#if (EM_FIELD_SCALE_CHANNEL1 == -1 || EM_FIELD_SCALE_CHANNEL2 == -1 || EM_FIELD_SCALE_CHANNEL3 == -1)
        //reduce with functor max
        float3_X max = reduce(nvidia::functors::Max(),
                              d1access,
                              elements);
        //reduce with functor min
        //float3_X min = reduce(nvidia::functors::Min(),
        //                    d1access,
        //                    elements);
#if (EM_FIELD_SCALE_CHANNEL1 != -1 )
        max.x() = float_X(1.0);
#endif
#if (EM_FIELD_SCALE_CHANNEL2 != -1 )
        max.y() = float_X(1.0);
#endif
#if (EM_FIELD_SCALE_CHANNEL3 != -1 )
        max.z() = float_X(1.0);
#endif

        //We don't know the superCellSize at compile time 
        // (because of the runtime dimension selection in any analyser), 
        // thus we must use a one dimension kernel and no mapper
        __cudaKernel(vis_kernels::divideAnyCell)(ceil((double) elements / 256), 256)(d1access, elements, max);
#endif

        // convert channels to RGB
        __cudaKernel(vis_kernels::channelsToRGB)(ceil((double) elements / 256), 256)(d1access, elements);

        // add density color channel
        DataSpace<simDim> blockSize(MappingDesc::SuperCellSize::getDataSpace());
        DataSpace<DIM2> blockSize2D(blockSize[transpose.x()], blockSize[transpose.y()]);

        //create image particles
        __picKernelArea((kernelPaintParticles3D), *cellDescription, CORE + BORDER)
            (SuperCellSize::getDataSpace(), blockSize2D.productOfComponents() * sizeof (int))
            (particles->getDeviceParticlesBox(),
             img->getDeviceBuffer().getDataBox(),
             transpose,
             sliceOffset,
             globalOffset, sliceDim
             );

        // send the RGB image back to host
        img->deviceToHost();


        header.update(*cellDescription, window, transpose, currentStep);


        __getTransactionEvent().waitForFinished(); //wait for copy picture

        DataSpace<DIM2> size = img->getGridLayout().getDataSpace();

        PMACC_AUTO(hostBox, img->getHostBuffer().getDataBox());

        if (picongpu::white_box_per_GPU)
        {
            hostBox[0 ][0 ] = float3_X(1.0, 1.0, 1.0);
            hostBox[size.y() - 1 ][0 ] = float3_X(1.0, 1.0, 1.0);
            hostBox[0 ][size.x() - 1] = float3_X(1.0, 1.0, 1.0);
            hostBox[size.y() - 1 ][size.x() - 1] = float3_X(1.0, 1.0, 1.0);
        }
        PMACC_AUTO(resultBox, gather(hostBox, header));
        if (isMaster)
        {
            output(resultBox.shift(header.window.offset), header.window.size, header);
        }

    }