From 9d5a03e43c666052700149018f585b60b85f10af Mon Sep 17 00:00:00 2001 From: Berenger Bramas Date: Tue, 13 Sep 2016 10:07:35 +0200 Subject: [PATCH] Update M2L --- Src/GroupTree/Core/FGroupOfCells.hpp | 8 +++-- .../FGroupTaskStarpuImplicitAlgorithm.hpp | 32 ++++++++++--------- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/Src/GroupTree/Core/FGroupOfCells.hpp b/Src/GroupTree/Core/FGroupOfCells.hpp index 865842bd..8c78abfd 100644 --- a/Src/GroupTree/Core/FGroupOfCells.hpp +++ b/Src/GroupTree/Core/FGroupOfCells.hpp @@ -406,23 +406,27 @@ public: size_t extractGetSizeSymbUp(const std::vector& cellsToExtract) const { - return cellsToExtract.size() * sizeof(SymboleCellClass) * sizeof(PoleCellClass); + return cellsToExtract.size() * (sizeof(SymboleCellClass) + sizeof(PoleCellClass)); } void extractDataUp(const std::vector& cellsToExtract, unsigned char* outputBuffer, const size_t outputBufferSize) const { + FAssertLF(outputBuffer || outputBufferSize == 0); size_t idxValue = 0; for(size_t idxEx = 0 ; idxEx < cellsToExtract.size() ; ++idxEx){ const int idCell = cellsToExtract[idxEx]; + FAssertLF(idCell < blockHeader->numberOfCellsInBlock); memcpy(&outputBuffer[idxValue], &blockCells[idCell], sizeof(SymboleCellClass)); idxValue += sizeof(SymboleCellClass); + FAssertLF(idxValue <= outputBufferSize); memcpy(&outputBuffer[idxValue], &cellMultipoles[idCell], sizeof(PoleCellClass)); idxValue += sizeof(PoleCellClass); + FAssertLF(idxValue <= outputBufferSize); } FAssertLF(idxValue == outputBufferSize); } @@ -445,7 +449,7 @@ public: } size_t extractGetSizeSymbDown(const std::vector& cellsToExtract) const { - return cellsToExtract.size() * sizeof(SymboleCellClass) * sizeof(LocalCellClass); + return cellsToExtract.size() * (sizeof(SymboleCellClass) + sizeof(LocalCellClass)); } void extractDataDown(const std::vector& cellsToExtract, diff --git a/Src/GroupTree/Core/FGroupTaskStarpuImplicitAlgorithm.hpp b/Src/GroupTree/Core/FGroupTaskStarpuImplicitAlgorithm.hpp index b6e53dfd..17e5e8e8 100644 --- a/Src/GroupTree/Core/FGroupTaskStarpuImplicitAlgorithm.hpp +++ b/Src/GroupTree/Core/FGroupTaskStarpuImplicitAlgorithm.hpp @@ -852,9 +852,10 @@ protected: cell_extract_up.where |= STARPU_CPU; memset(&cell_insert_up, 0, sizeof(cell_insert_up)); - cell_extract_up.nbuffers = 3; + cell_insert_up.nbuffers = 3; cell_insert_up.modes[0] = STARPU_R; cell_insert_up.modes[1] = STARPU_RW; + cell_insert_up.modes[2] = STARPU_RW; cell_insert_up.name = "cell_insert_up"; cell_insert_up.cpu_funcs[0] = ThisClass::InsertCellUp; cell_insert_up.where |= STARPU_CPU; @@ -889,29 +890,29 @@ protected: static void InsertCellUp(void *buffers[], void *cl_arg){ CellContainerClass currentCells((unsigned char*)STARPU_VECTOR_GET_PTR(buffers[1]), STARPU_VECTOR_GET_NX(buffers[1]), - nullptr, - (unsigned char*)STARPU_VECTOR_GET_PTR(buffers[2])); - unsigned char* inBuffer = (unsigned char*)STARPU_VECTOR_GET_PTR(buffers[0]); - size_t size = STARPU_VECTOR_GET_NX(buffers[0]); + (unsigned char*)STARPU_VECTOR_GET_PTR(buffers[2]), + nullptr); CellExtractedHandles* interactionBufferPtr; starpu_codelet_unpack_args(cl_arg, &interactionBufferPtr); - currentCells.restoreDataUp(interactionBufferPtr->cellsToExtract, inBuffer, size); + currentCells.restoreDataUp(interactionBufferPtr->cellsToExtract, + (unsigned char*)STARPU_VECTOR_GET_PTR(buffers[0]), + STARPU_VECTOR_GET_NX(buffers[0])); } static void ExtractCellUp(void *buffers[], void *cl_arg){ CellContainerClass currentCells((unsigned char*)STARPU_VECTOR_GET_PTR(buffers[0]), STARPU_VECTOR_GET_NX(buffers[0]), - nullptr, - (unsigned char*)STARPU_VECTOR_GET_PTR(buffers[1])); - unsigned char* inBuffer = (unsigned char*)STARPU_VECTOR_GET_PTR(buffers[2]); - size_t size = STARPU_VECTOR_GET_NX(buffers[2]); + (unsigned char*)STARPU_VECTOR_GET_PTR(buffers[1]), + nullptr); CellExtractedHandles* interactionBufferPtr; starpu_codelet_unpack_args(cl_arg, &interactionBufferPtr); - currentCells.extractDataUp(interactionBufferPtr->cellsToExtract, inBuffer, size); + currentCells.extractDataUp(interactionBufferPtr->cellsToExtract, + (unsigned char*)STARPU_VECTOR_GET_PTR(buffers[2]), + STARPU_VECTOR_GET_NX(buffers[2])); } void initCodeletMpi(){ @@ -1549,8 +1550,9 @@ protected: } interactionBuffer.size = tree->getCellGroup(idxLevel,interactionid)->extractGetSizeSymbUp(interactionBuffer.cellsToExtract); // I allocate only if I will use it to extract - if(starpu_mpi_data_get_rank(cellHandles[idxLevel][interactionid].symb)){ + if(starpu_mpi_data_get_rank(cellHandles[idxLevel][interactionid].symb) == mpi_rank){ interactionBuffer.data.reset(new unsigned char[interactionBuffer.size]); + FAssertLF(interactionBuffer.data); } else{ interactionBuffer.data.reset(nullptr); @@ -1655,7 +1657,7 @@ protected: } interactionBuffer.size = tree->getCellGroup(idxLevel,idxGroup)->extractGetSizeSymbUp(interactionBuffer.cellsToExtract); // I allocate only if I will use it to extract - if(starpu_mpi_data_get_rank(cellHandles[idxLevel][idxGroup].symb)){ + if(starpu_mpi_data_get_rank(cellHandles[idxLevel][idxGroup].symb) == mpi_rank){ interactionBuffer.data.reset(new unsigned char[interactionBuffer.size]); } else{ @@ -1725,8 +1727,8 @@ protected: #endif STARPU_R, cellHandles[idxLevel][interactionid].symb, (STARPU_RW | STARPU_COMMUTE_IF_SUPPORTED), cellHandles[idxLevel][interactionid].down, - STARPU_RW, duplicateB.symb, - STARPU_RW, duplicateB.other, + STARPU_R, duplicateB.symb, + STARPU_R, duplicateB.other, #ifdef STARPU_USE_TASK_NAME #ifndef SCALFMM_SIMGRID_TASKNAMEPARAMS STARPU_NAME, m2lOuterTaskNames[idxLevel].get(), -- GitLab