CCTStatusType CCellSet::CalculateOnCell()
{
CCTStatusType Status = CCT_NOERR;
CGridBox TotalGridBox = m_BoundingBox;
Integer TotalCells = TotalGridBox.m_GridSize.x * TotalGridBox.m_GridSize.y * TotalGridBox.m_GridSize.z;
CellInfoAll * a_CellInfoAll = new CellInfoAll[TotalCells];
Integer * ParticleID_New = new Integer[m_ParticleNum];
Scalar3 * ParticlePos_new = new Scalar3[m_ParticleNum];
Scalar * ParticleDen_new = new Scalar[m_ParticleNum];
memset(ParticleDen_new,0,m_ParticleNum * sizeof(Scalar));
Status = CudaSafeCall(cudaMemcpy(ParticleID_New, m_daParticleID,m_ParticleNum * sizeof(Integer), cudaMemcpyDeviceToHost));
CCT_ERROR_CHECK(Status);
Status = CudaSafeCall(cudaMemcpy(ParticlePos_new, m_daParticlePosition,m_ParticleNum * sizeof(Scalar3), cudaMemcpyDeviceToHost));
CCT_ERROR_CHECK(Status);
Status = CudaSafeCall(cudaMemcpy(m_haCellStart,m_dCellStart,TotalCells * sizeof(Integer),cudaMemcpyDeviceToHost));
CCT_ERROR_CHECK(Status);
Status = CudaSafeCall(cudaMemcpy(m_haCellEnd,m_dCellEnd,TotalCells * sizeof(Integer),cudaMemcpyDeviceToHost));
CCT_ERROR_CHECK(Status);
Integer maxCellNumber = 0 ;
for(int i = 0 ; i < TotalCells ; i++)
{
Integer particlesInCell = 0;
if(m_haCellStart[i] != 0xffffffff)
{
int particleIDInCell = 0 ;
a_CellInfoAll[i].m_CellParticleNumber = 0 ;
int cellSize = m_haCellEnd[i] - m_haCellStart[i];
std::cout<<"particleInCell: " << cellSize<<"\n";
for(int j = m_haCellStart[i] ; j < m_haCellEnd[i] ; j++)
{
a_CellInfoAll[i].m_CellParticleNumber++;
a_CellInfoAll[i].m_aCellParticleID[particleIDInCell] = j;
particleIDInCell++;
}
}
else
{
a_CellInfoAll[i].m_CellParticleNumber = 0;
}
}
//Division Starts
Integer GridNum = 2;
for(int GridId = 0 ; GridId < GridNum ; GridId++)
{
//Integer GridId = 1;
//CGridBox TotalGridBox = m_BoundingBox;
Integer3 MyGridSize = m_BoundingBox.m_GridSize;
MyGridSize.x = m_BoundingBox.m_GridSize.x / GridNum;
m_BoundingBox.m_GridSize = MyGridSize;
//Integer TotalCells = TotalGridBox.m_GridSize.x * TotalGridBox.m_GridSize.y * TotalGridBox.m_GridSize.z;
m_GridParams.m_ComputeCellIdStart = TotalCells / GridNum * GridId;
m_GridParams.m_ComputeCellIdEnd = TotalCells / GridNum * (GridId + 1);
Integer BufferCellNum = 1 * TotalGridBox.m_GridSize.y * TotalGridBox.m_GridSize.z;
m_GridParams.m_BufferedCellIdStart = m_GridParams.m_ComputeCellIdStart - BufferCellNum < 0 ? 0 : m_GridParams.m_ComputeCellIdStart - BufferCellNum ;
m_GridParams.m_BufferedCellIdEnd = m_GridParams.m_ComputeCellIdEnd + BufferCellNum > TotalCells ? TotalCells : m_GridParams.m_ComputeCellIdEnd + BufferCellNum;
m_CellNum = m_GridParams.m_BufferedCellIdEnd - m_GridParams.m_BufferedCellIdStart;
m_GridParams.m_LeftGhostCellNum = m_ID > 0 ? BufferCellNum * 2 : 0;
m_GridParams.m_LeftGhostCellEnd = m_GridParams.m_ComputeCellIdStart + m_GridParams.m_LeftGhostCellNum;
m_GridParams.m_RightGhostCellNum = m_ID < GridNum-1 ? BufferCellNum * 2 : 0;
m_GridParams.m_RightGhostCellStart = m_GridParams.m_ComputeCellIdEnd - m_GridParams.m_RightGhostCellNum;
//Devision Ends
//Allocate Device Memory
m_TotalCellsFor1 = m_GridParams.m_BufferedCellIdEnd - m_GridParams.m_BufferedCellIdStart;
//Memory Allocation for Host
m_haCellInfoAll = new CellInfoAll[m_TotalCellsFor1];
//Memory Allocation for Device
Status = CudaSafeCall(cudaMalloc((void**)&m_daCellInfoAll,m_TotalCellsFor1 * sizeof(CellInfoAll)));
CCT_ERROR_CHECK(Status);
//Memory Copy to Host
memcpy(m_haCellInfoAll, a_CellInfoAll /*+ m_GridParams.m_BufferedCellIdStart*/, m_TotalCellsFor1 * sizeof(CellInfoAll));
//Memory Copy to Device
Status = CudaSafeCall(cudaMemcpy(m_daCellInfoAll,m_haCellInfoAll, m_TotalCellsFor1 * sizeof(CellInfoAll), cudaMemcpyHostToDevice));
CCT_ERROR_CHECK(Status);
CCT_ERROR_CHECK(Status);
}
Status = ParticleDeviceToHost();
CCT_ERROR_CHECK(Status);
/*Test Code for Calculation based on Cell Ends*/
return CCT_NOERR;
}
This is the part of a code in which i am trying to copy m_haCellInfoAll value to m_daCellInfoAll. But the value is not copied. Ca you please suggest me the problem