Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Topic profile hdf5 2 #280

Merged
merged 11 commits into from
Mar 17, 2014
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ namespace fieldSolver = fieldSolverYee;
* - gasHomogenous : constant gas density with a certain length
* - gasSphereFlanks : constant sphere droplet with exponential decr envelope
* - gasFreeFormula: use a custom formula (slower)
* - gasFromHdf5: load gas density from HDF5 file
* - gasNone : just stay with a vacuum
*/
namespace gasProfile = gasGaussianCloud;
Expand Down
12 changes: 11 additions & 1 deletion examples/Bunch/include/simulation_defines/param/gasConfig.param
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2013-2014 Axel Huebl, Heiko Burau, Rene Widera
* Copyright 2013-2014 Axel Huebl, Heiko Burau, Rene Widera, Felix Schmitt
*
* This file is part of PIConGPU.
*
Expand Down Expand Up @@ -221,6 +221,16 @@ namespace picongpu
};
}
}

#if (ENABLE_HDF5 == 1)
namespace gasFromHdf5
{
const char *gasHdf5Filename = "gas";
const char *gasHdf5Dataset = "fields/Density_e";
const int32_t gasHdf5Iteration = 0;
const float_X gasDefaultValue = 0.0;
}
#endif

namespace gasNone
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ namespace picongpu
* - gasHomogenous : constant gas density with a certain length
* - gasSphereFlanks : constant sphere droplet with exponential decr envelope
* - gasFreeFormula: use a custom formula (slower)
* - gasFromHdf5: load gas density from HDF5 file
* - gasNone : just stay with a vacuum
*/
namespace gasProfile = gasHomogenous;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2013-2014 Axel Huebl, Heiko Burau, Rene Widera
* Copyright 2013-2014 Axel Huebl, Heiko Burau, Rene Widera, Felix Schmitt
*
* This file is part of PIConGPU.
*
Expand Down Expand Up @@ -221,6 +221,16 @@ namespace picongpu
};
}
}

#if (ENABLE_HDF5 == 1)
namespace gasFromHdf5
{
const char *gasHdf5Filename = "gas";
const char *gasHdf5Dataset = "fields/Density_e";
const int32_t gasHdf5Iteration = 0;
const float_X gasDefaultValue = 0.0;
}
#endif

namespace gasNone
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2013 Axel Huebl, Anton Helm, Rene Widera
* Copyright 2013-2014 Axel Huebl, Anton Helm, Rene Widera, Felix Schmitt
*
* This file is part of PIConGPU.
*
Expand Down Expand Up @@ -58,6 +58,7 @@ namespace fieldSolver = PARAM_FIELDSOLVER;
* - gasHomogenous : constant gas density with a certain length
* - gasSphereFlanks : constant sphere droplet with exponential decr envelope
* - gasFreeFormula: use a custom formula (slower)
* - gasFromHdf5: load gas density from HDF5 file
* - gasNone : just stay with a vacuum
*/
#ifndef PARAM_GASPROFILE
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2013-2014 Axel Huebl, Rene Widera
* Copyright 2013-2014 Axel Huebl, Rene Widera, Felix Schmitt
*
* This file is part of PIConGPU.
*
Expand Down Expand Up @@ -221,6 +221,16 @@ namespace picongpu
};
}
}

#if (ENABLE_HDF5 == 1)
namespace gasFromHdf5
{
const char *gasHdf5Filename = "gas";
const char *gasHdf5Dataset = "fields/Density_e";
const int32_t gasHdf5Iteration = 0;
const float_X gasDefaultValue = 0.0;
}
#endif

namespace gasNone
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ namespace fieldSolver = fieldSolverNone;
* - gasHomogenous : constant gas density with a certain length
* - gasSphereFlanks : constant sphere droplet with exponential decr envelope
* - gasFreeFormula: use a custom formula (slower)
* - gasFromHdf5: load gas density from HDF5 file
* - gasNone : just stay with a vacuum
*/
namespace gasProfile = gasNone;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ namespace fieldSolver = fieldSolverYee;
* - gasHomogenous : constant gas density with a certain length
* - gasSphereFlanks : constant sphere droplet with exponential decr envelope
* - gasFreeFormula: use a custom formula (slower)
* - gasFromHdf5: load gas density from HDF5 file
* - gasNone : just stay with a vacuum
*/
namespace gasProfile = gasNone;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ namespace fieldSolver = fieldSolverNone;
* - gasHomogenous : constant gas density with a certain length
* - gasSphereFlanks : constant sphere droplet with exponential decr envelope
* - gasFreeFormula: use a custom formula (slower)
* - gasFromHdf5: load gas density from HDF5 file
* - gasNone : just stay with a vacuum
*/
namespace gasProfile = gasNone;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ namespace fieldSolver = fieldSolverYee;
* - gasHomogenous : constant gas density with a certain length
* - gasSphereFlanks : constant sphere droplet with exponential decr envelope
* - gasFreeFormula: use a custom formula (slower)
* - gasFromHdf5: load gas density from HDF5 file
* - gasNone : just stay with a vacuum
*/
namespace gasProfile = gasHomogenous;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2013 Axel Huebl, Heiko Burau, Rene Widera
* Copyright 2013-2014 Axel Huebl, Heiko Burau, Rene Widera, Felix Schmitt
*
* This file is part of PIConGPU.
*
Expand Down Expand Up @@ -221,6 +221,16 @@ namespace picongpu
};
}
}

#if (ENABLE_HDF5 == 1)
namespace gasFromHdf5
{
const char *gasHdf5Filename = "gas";
const char *gasHdf5Dataset = "fields/Density_e";
const int32_t gasHdf5Iteration = 0;
const float_X gasDefaultValue = 0.0;
}
#endif

namespace gasNone
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ namespace picongpu
* - gasHomogenous : constant gas density with a certain length
* - gasSphereFlanks : constant sphere droplet with exponential decr envelope
* - gasFreeFormula: use a custom formula (slower)
* - gasFromHdf5: load gas density from HDF5 file
* - gasNone : just stay with a vacuum
*/
namespace gasProfile = gasHomogenous;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2013 Axel Huebl, Heiko Burau, Rene Widera
* Copyright 2013-2014 Axel Huebl, Heiko Burau, Rene Widera, Felix Schmitt
*
* This file is part of PIConGPU.
*
Expand Down Expand Up @@ -221,6 +221,16 @@ namespace picongpu
};
}
}

#if (ENABLE_HDF5 == 1)
namespace gasFromHdf5
{
const char *gasHdf5Filename = "gas";
const char *gasHdf5Dataset = "fields/Density_e";
const int32_t gasHdf5Iteration = 0;
const float_X gasDefaultValue = 0.0;
}
#endif

namespace gasNone
{
Expand Down
2 changes: 1 addition & 1 deletion src/libPMacc/include/memory/buffers/DeviceBuffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ namespace PMacc
* @param other the DeviceBuffer to copy from
*/
virtual void copyFrom(DeviceBuffer<TYPE, DIM>& other) = 0;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

? :)

};

} //namespace PMacc
Expand Down
20 changes: 5 additions & 15 deletions src/libPMacc/include/memory/buffers/GridBuffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,24 +173,14 @@ class GridBuffer
*/
virtual ~GridBuffer()
{
for (uint32_t i = 1; i < 27; ++i)
for (uint32_t i = 0; i < 27; ++i)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

huch, has this been a bug @psychocoderHPC ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not realy because 0 means exchange to itself and is always NULL. But better to clean all, we don't know if someone will send data to its own prozess^^ I think nowbody has testet this and the result is undefined. It can be that we must add an assert check that nobody can create exchange 0.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually sending to one self can be quite useful while writing generic algorithms.
and mpi will take care not to put load on the network in that case anyway.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

edited: all right, looks good.

{
if (sendExchanges[i] != NULL)
{
delete sendExchanges[i];
sendExchanges[i] = NULL;
}
if (sendExchanges[i] != NULL)
{
delete receiveExchanges[i];
receiveExchanges[i] = NULL;
}
__delete(sendExchanges[i]);
__delete(receiveExchanges[i]);
}

delete hostBuffer;
hostBuffer = NULL;
delete deviceBuffer;
deviceBuffer = NULL;
__delete(hostBuffer);
__delete(deviceBuffer);
}

/**
Expand Down
6 changes: 4 additions & 2 deletions src/picongpu/include/fields/FieldTmp.tpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#pragma once

#include "types.h"
#include "memory/buffers/GridBuffer.hpp"
#include "mappings/simulation/GridController.hpp"

Expand All @@ -46,7 +47,8 @@ namespace picongpu
using namespace PMacc;

FieldTmp::FieldTmp( MappingDesc cellDescription ) :
SimulationFieldHelper<MappingDesc>( cellDescription )
SimulationFieldHelper<MappingDesc>( cellDescription ),
fieldTmp( NULL )
{
fieldTmp = new GridBuffer<ValueType, simDim > ( cellDescription.getGridLayout( ) );

Expand Down Expand Up @@ -103,7 +105,7 @@ namespace picongpu

FieldTmp::~FieldTmp( )
{
delete fieldTmp;
__delete( fieldTmp );
}

template<uint32_t AREA, class FrameSolver, class ParticlesClass>
Expand Down
4 changes: 2 additions & 2 deletions src/picongpu/include/particles/Particles.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class Particles : public ParticlesBase<T_DataVector,T_MethodsVector, MappingDesc

virtual void reset(uint32_t currentStep);

void init(FieldE &fieldE, FieldB &fieldB, FieldJ &fieldJ);
void init(FieldE &fieldE, FieldB &fieldB, FieldJ &fieldJ, FieldTmp &fieldTmp);

void update(uint32_t currentStep);

Expand All @@ -84,7 +84,7 @@ class Particles : public ParticlesBase<T_DataVector,T_MethodsVector, MappingDesc
FieldE *fieldE;
FieldB *fieldB;
FieldJ *fieldJurrent;

FieldTmp *fieldTmp;

curandState* randState;
};
Expand Down
21 changes: 18 additions & 3 deletions src/picongpu/include/particles/Particles.tpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "fields/FieldB.hpp"
#include "fields/FieldE.hpp"
#include "fields/FieldJ.hpp"
#include "fields/FieldTmp.hpp"

#include "particles/memory/buffers/ParticlesBuffer.hpp"
#include "ParticlesInit.kernel"
Expand All @@ -55,7 +56,8 @@ template< typename T_DataVector, typename T_MethodsVector>
Particles<T_DataVector, T_MethodsVector>::Particles( GridLayout<simDim> gridLayout,
MappingDesc cellDescription,
SimulationDataId datasetID ) :
ParticlesBase<T_DataVector, T_MethodsVector, MappingDesc>( cellDescription ), fieldB( NULL ), fieldE( NULL ), fieldJurrent( NULL ), gridLayout( gridLayout ),
ParticlesBase<T_DataVector, T_MethodsVector, MappingDesc>( cellDescription ),
fieldB( NULL ), fieldE( NULL ), fieldJurrent( NULL ), fieldTmp( NULL ), gridLayout( gridLayout ),
datasetID( datasetID )
{
size_t sizeOfExchanges = 2 * 2 * ( BYTES_EXCHANGE_X + BYTES_EXCHANGE_Y + BYTES_EXCHANGE_Z ) + BYTES_EXCHANGE_X * 2 * 8;
Expand Down Expand Up @@ -125,11 +127,12 @@ void Particles<T_DataVector, T_MethodsVector>::syncToDevice( )
}

template< typename T_DataVector, typename T_MethodsVector>
void Particles<T_DataVector, T_MethodsVector>::init( FieldE &fieldE, FieldB &fieldB, FieldJ &fieldJ )
void Particles<T_DataVector, T_MethodsVector>::init( FieldE &fieldE, FieldB &fieldB, FieldJ &fieldJ, FieldTmp &fieldTmp )
{
this->fieldE = &fieldE;
this->fieldB = &fieldB;
this->fieldJurrent = &fieldJ;
this->fieldTmp = &fieldTmp;

Environment<>::get( ).DataConnector().registerData( *this );
}
Expand Down Expand Up @@ -193,11 +196,23 @@ void Particles<T_DataVector, T_MethodsVector>::initFill( uint32_t currentStep )
if ( gasProfile::GAS_ENABLED )
{
const DataSpace<simDim> globalNrOfCells = simBox.getGlobalSize( );

PMACC_AUTO( &fieldTmpGridBuffer, this->fieldTmp->getGridBuffer() );
FieldTmp::DataBoxType dataBox = fieldTmpGridBuffer.getDeviceBuffer().getDataBox();

if (!gasProfile::gasSetup(fieldTmpGridBuffer, window))
{
log<picLog::SIMULATION_STATE > ("Failed to setup gas profile");
}

__picKernelArea( kernelFillGridWithParticles, this->cellDescription, CORE + BORDER + GUARD )
(block)
( this->particlesBuffer->getDeviceParticleBox( ),
this->particlesBuffer->hasSendExchange( TOP ), gpuCellOffset, seed, globalNrOfCells.y( ) );
this->particlesBuffer->hasSendExchange( TOP ),
gpuCellOffset,
seed,
globalNrOfCells.y( ),
dataBox.shift(this->fieldTmp->getGridLayout().getGuard()));
}

this->fillAllGaps( );
Expand Down
22 changes: 14 additions & 8 deletions src/picongpu/include/particles/ParticlesInit.kernel
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2013-2014 Axel Huebl, Heiko Burau, Rene Widera
* Copyright 2013-2014 Axel Huebl, Heiko Burau, Rene Widera, Felix Schmitt
*
* This file is part of PIConGPU.
*
Expand All @@ -23,6 +23,8 @@
#include "types.h"
#include "simulation_defines.hpp"
#include "particles/Particles.hpp"
#include "memory/boxes/DataBox.hpp"
#include "memory/boxes/PitchedBox.hpp"
#include "dimensions/DataSpaceOperations.hpp"

#include "simulation_defines.hpp"
Expand All @@ -49,20 +51,23 @@ using namespace PMacc;
* @param cellIdx the current cell on this gpu
* @return a float_X which stands for the real number of electrons per volume
*/
template<unsigned int Dim>
DINLINE float_X calcRealDensity(const DataSpace<Dim>& offset, const DataSpace<Dim>& cellIdx)
template<unsigned int Dim, typename FieldBox>
DINLINE float_X calcRealDensity(const DataSpace<Dim>& offset,
const DataSpace<Dim>& localCellIdx, FieldBox fieldTmp)
{
floatD_X physicalCellPosition;
for (uint32_t i = 0; i < simDim; ++i)
physicalCellPosition[i] = (cellIdx[i] + offset[i]) * cellSize[i];
physicalCellPosition[i] = (localCellIdx[i] + offset[i]) * cellSize[i];

const float_X value = gasProfile::calcNormedDensitiy(physicalCellPosition) * GAS_DENSITY;
const float_X value = gasProfile::calcNormedDensity(physicalCellPosition, localCellIdx, fieldTmp) * GAS_DENSITY;
return value;
}

template< typename ParBox, class Mapping>
template< typename ParBox, typename FieldBox, class Mapping>
__global__ void kernelFillGridWithParticles(ParBox pb,
bool isNotTop, DataSpace<simDim> gpuCelloffset, uint32_t seed, uint32_t gNrCellsY,
bool isNotTop, DataSpace<simDim> gpuCelloffset,
uint32_t seed, uint32_t gNrCellsY,
FieldBox fieldTmp,
Mapping mapper)
{
namespace nvrng = nvidia::rng;
Expand Down Expand Up @@ -127,7 +132,8 @@ __global__ void kernelFillGridWithParticles(ParBox pb,


/*multiply density factor to calculated manipulated middle density*/
const float_X realDensity = densityFactor * calcRealDensity(gpuCelloffset, idx - SuperCellSize::getDataSpace());
const float_X realDensity = densityFactor * calcRealDensity(gpuCelloffset,
localCellIdx, fieldTmp);
const float_X realElPerCell = realDensity * CELL_VOLUME;

__shared__ int finished;
Expand Down
Loading