Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/picongpu/include/plugins/PluginController.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@

#if(SIMDIM==DIM3)
#include "plugins/IntensityPlugin.hpp"
#include "plugins/SliceFieldPrinterMulti.hpp"
#endif
#include "plugins/SliceFieldPrinterMulti.hpp"

#include "plugins/output/images/Visualisation.hpp"

Expand Down Expand Up @@ -141,9 +141,7 @@ class PluginController : public ILightweightPlugin

/* define field plugins */
typedef bmpl::vector<
#if(SIMDIM==DIM3)
SliceFieldPrinterMulti<bmpl::_1>
#endif
> UnspecializedFieldPlugins;

typedef bmpl::vector< FieldB, FieldE, FieldJ> AllFields;
Expand Down
4 changes: 2 additions & 2 deletions src/picongpu/include/plugins/SliceFieldPrinter.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2013-2014 Heiko Burau, Rene Widera, Felix Schmitt,
* Copyright 2013-2015 Heiko Burau, Rene Widera, Felix Schmitt,
* Richard Pausch
*
* This file is part of PIConGPU.
Expand Down Expand Up @@ -47,7 +47,7 @@ class SliceFieldPrinter : public ILightweightPlugin
int plane;
float_X slicePoint;
MappingDesc *cellDescription;
container::DeviceBuffer<float3_64, 2>* dBuffer_SI;
container::DeviceBuffer<float3_64, simDim-1>* dBuffer_SI;

void pluginLoad();
void pluginUnload();
Expand Down
41 changes: 26 additions & 15 deletions src/picongpu/include/plugins/SliceFieldPrinter.tpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2013-2014 Heiko Burau, Rene Widera, Felix Schmitt,
* Copyright 2013-2015 Heiko Burau, Rene Widera, Felix Schmitt,
* Richard Pausch
*
* This file is part of PIConGPU.
Expand Down Expand Up @@ -66,10 +66,10 @@ void SliceFieldPrinter<Field>::pluginLoad()
namespace vec = ::PMacc::math;
typedef SuperCellSize BlockDim;

vec::Size_t<3> size = vec::Size_t<3>(this->cellDescription->getGridSuperCells()) * precisionCast<size_t>(BlockDim::toRT())
vec::Size_t<simDim> size = vec::Size_t<simDim>(this->cellDescription->getGridSuperCells()) * precisionCast<size_t>(BlockDim::toRT())
- precisionCast<size_t>(2 * BlockDim::toRT());
this->dBuffer_SI = new container::DeviceBuffer<float3_64, 2>(
size.shrink<2>((this->plane+1)%3));
this->dBuffer_SI = new container::DeviceBuffer<float3_64, simDim-1>(
size.shrink<simDim-1>((this->plane+1)%simDim));
}
else
{
Expand Down Expand Up @@ -126,39 +126,50 @@ void SliceFieldPrinter<Field>::printSlice(const TField& field, int nAxis, float
namespace vec = PMacc::math;
using namespace vec::tools;

PMacc::GridController<3>& con = PMacc::Environment<3>::get().GridController();
vec::Size_t<3> gpuDim = (vec::Size_t<3>)con.getGpuNodes();
vec::Size_t<3> globalGridSize = gpuDim * field.size();
PMacc::GridController<simDim>& con = PMacc::Environment<simDim>::get().GridController();
vec::Size_t<simDim> gpuDim = (vec::Size_t<simDim>)con.getGpuNodes();
vec::Size_t<simDim> globalGridSize = gpuDim * field.size();
int globalPlane = globalGridSize[nAxis] * slicePoint;
int localPlane = globalPlane % field.size()[nAxis];
int gpuPlane = globalPlane / field.size()[nAxis];

vec::Int<3> nVector(vec::Int<3>::create(0));
vec::Int<simDim> nVector(vec::Int<simDim>::create(0));
nVector[nAxis] = 1;

zone::SphericZone<3> gpuGatheringZone(vec::Size_t<3>(gpuDim.x(), gpuDim.y(), gpuDim.z()),
nVector * gpuPlane);
zone::SphericZone<simDim> gpuGatheringZone(gpuDim, nVector * gpuPlane);
gpuGatheringZone.size[nAxis] = 1;

algorithm::mpi::Gather<3> gather(gpuGatheringZone);
algorithm::mpi::Gather<simDim> gather(gpuGatheringZone);
if(!gather.participate()) return;

using namespace lambda;
vec::UInt32<3> twistedVector((nAxis+1)%3, (nAxis+2)%3, nAxis);
#if(SIMDIM==DIM3)
vec::UInt32<3> twistedAxesVec((nAxis+1)%3, (nAxis+2)%3, nAxis);

/* convert data to higher precision and to SI units */
SliceFieldPrinterHelper::ConversionFunctor<Field> cf;
algorithm::kernel::Foreach<vec::CT::UInt32<4,4,1> >()(
dBuffer_SI->zone(), dBuffer_SI->origin(),
cursor::tools::slice(field.originCustomAxes(twistedVector)(0,0,localPlane)),
cursor::tools::slice(field.originCustomAxes(twistedAxesVec)(0,0,localPlane)),
cf );
#endif
#if(SIMDIM==DIM2)
vec::UInt32<2> twistedAxesVec((nAxis+1)%2, nAxis);

/* convert data to higher precision and to SI units */
SliceFieldPrinterHelper::ConversionFunctor<Field> cf;
algorithm::kernel::Foreach<vec::CT::UInt32<16,1,1> >()(
dBuffer_SI->zone(), dBuffer_SI->origin(),
cursor::tools::slice(field.originCustomAxes(twistedAxesVec)(0,localPlane)),
cf );
#endif

/* copy selected plane from device to host */
container::HostBuffer<float3_64, 2> hBuffer(dBuffer_SI->size());
container::HostBuffer<float3_64, simDim-1> hBuffer(dBuffer_SI->size());
hBuffer = *dBuffer_SI;

/* collect data from all nodes/GPUs */
container::HostBuffer<float3_64, 2> globalBuffer(hBuffer.size() * gpuDim.shrink<2>((nAxis+1)%3));
container::HostBuffer<float3_64, simDim-1> globalBuffer(hBuffer.size() * gpuDim.shrink<simDim-1>((nAxis+1)%simDim));
gather(globalBuffer, hBuffer, nAxis);
if(!gather.root()) return;
std::ofstream file(filename.c_str());
Expand Down
4 changes: 2 additions & 2 deletions src/picongpu/include/plugins/SliceFieldPrinterMulti.tpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2013-2014 Heiko Burau, Rene Widera, Felix Schmitt,
* Copyright 2013-2015 Heiko Burau, Rene Widera, Felix Schmitt,
* Richard Pausch
*
* This file is part of PIConGPU.
Expand Down Expand Up @@ -44,7 +44,7 @@ namespace picongpu

template<typename Field>
SliceFieldPrinterMulti<Field>::SliceFieldPrinterMulti()
: name("SliceFieldPrinterMulti: prints a slice of a field"),
: name("SliceFieldPrinter: prints a slice of a field"),
prefix(Field::getName() + std::string("_slice"))
{
Environment<>::get().PluginConnector().registerPlugin(this);
Expand Down