Commit 13278d73 authored by COULAUD Olivier's avatar COULAUD Olivier

Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot/scalfmm/scalfmm

# By bramas (7) and piacibel (4)
# Via bramas
* 'master' of git+ssh://scm.gforge.inria.fr//gitroot/scalfmm/scalfmm:
  Add a name to critical section (even if they should not be called at the same time but to ensure that they cannot interfere with some others)
  Add critical when creating kernel for each thread to ensure that the thread are in a protected environment
  minor fix on that test
  Add operation to the vector to ensure that object without default constructor can be user with it
  Both version (user defined kernel and interpolation kernel) provides same features
  oops missmatch in the deleter for the smart ptr
  Remove some warnings and add the patch for the omp to starpu auto version
  Remove some warnings and add the patch for the omp to starpu auto version
  remove some conversion warnings
  Forgot 1 modifocation
  Update in API in order to remove memory leaks (changes added to FChebInterpolator too.)
parents 0569d1fc f01521a6
......@@ -101,9 +101,6 @@ typedef void* scalfmm_handle;
/**
* @brief This function initialize scalfmm datas.
* @param TreeHeight Height of the octree.
* @param BoxWidth Width of the entire simulation box.
* @param BoxCenter Coordinate of the center of the box (ie array)
* @param KernelType kernel to be used
* @return scalfmm_handle (ie void *). This handle will be given to
* every other scalfmm functions.
......@@ -111,15 +108,58 @@ typedef void* scalfmm_handle;
* Every data will be stored in order to crete later through a builder
* what is needed for the simulation
*/
scalfmm_handle scalfmm_init(int TreeHeight,double BoxWidth,double* BoxCenter, scalfmm_kernel_type KernelType);
scalfmm_handle scalfmm_init( scalfmm_kernel_type KernelType);
/////////////////////////////////////////////////////////////////////
////////////////// Tree Part //////////////
/////////////////////////////////////////////////////////////////////
//In order to initate the tree for user defined cell and kernel, we
//define here the call_backs to deal with cells
/**
* @brief Function to init the cells (should be given by the user when
* calling Scalfmm_init_cell)
* @param level level of the cell.
* @param morton_index morton index of the cell to be allocated.
* @param tree_position int[3] position inside the tree (number of boxes in
* each direction)
* @param spatial_position double[3] center of the cell
*/
typedef void* (*Callback_init_cell)(int level, long long morton_index, int* tree_position, double* spatial_position);
/**
* Function to destroy what have bee initialized by the user (should
* be give in Scalfmm_dealloc_handle)
*/
typedef void (*Callback_free_cell)(void*);
/**
* @brief Structure containing user's call_backs in order to
* initialize/free the cell's user data.
*/
typedef struct User_Scalfmm_Cell_Descriptor{
Callback_free_cell user_free_cell;
Callback_init_cell user_init_cell;
}Scalfmm_Cell_Descriptor;
/**
* @brief This function build the tree. If scalfmm_init has been
* called with a user defined kernel, then user_cell_descriptor need
* to be provided
*
* @param TreeHeight Height of the octree.
* @param BoxWidth Width of the entire simulation box.
* @param BoxCenter Coordinate of the center of the box (ie array)
*/
void scalfmm_build_tree(scalfmm_handle handle,int TreeHeight,double BoxWidth,double* BoxCenter,Scalfmm_Cell_Descriptor user_cell_descriptor);
/**
* @brief This function insert an array of position into the octree
* @param Handle scalfmm_handle provided by scalfmm_init.
......@@ -414,30 +454,14 @@ void scalfmm_user_kernel_config(scalfmm_handle Handle, Scalfmm_Kernel_Descriptor
//To fill gestion des cellules utilisateurs
/**
* @brief Function to init the cells (should be given by the user when
* calling Scalfmm_init_cell)
* @param level level of the cell.
* @param morton_index morton index of the cell to be allocated.
* @param tree_position int[3] position inside the tree (number of boxes in
* each direction)
* @param spatial_position double[3] center of the cell
*/
typedef void* (*Callback_init_cell)(int level, long long morton_index, int* tree_position, double* spatial_position);
/**
* Function to destroy what have bee initialized by the user (should
* be give in Scalfmm_dealloc_handle)
*/
typedef void (*Callback_free_cell)(void*);
void scalfmm_init_cell(scalfmm_handle Handle, Callback_init_cell user_cell_initializer);
void scalfmm_free_cell(scalfmm_handle Handle, Callback_free_cell user_cell_deallocator);
/* void scalfmm_init_cell(scalfmm_handle Handle, Callback_init_cell user_cell_initializer); */
/* void scalfmm_free_cell(scalfmm_handle Handle, Callback_free_cell user_cell_deallocator); */
/* /\** */
/* *@param Struct defining how scalfmm will handle user's cell data. */
/* *\/ */
/* void scalfmm_user_cell_config(scalfmm_handle Handle, Scalfmm_Cell_Descriptor user_cell_descriptor); */
///////////////// Common kernel part : /////////////////
......@@ -465,7 +489,7 @@ void scalfmm_execute_fmm(scalfmm_handle Handle);
* The last param cellDestroyer is meaningless in case the user uses
* one of the provided kernel. (i.e. Chebyshev, Lagrange)
*/
void Scalfmm_dealloc_handle(scalfmm_handle handle, Callback_free_cell cellDestroyer);
void scalfmm_dealloc_handle(scalfmm_handle handle, Callback_free_cell cellDestroyer);
#endif
......@@ -24,9 +24,10 @@
#include "FScalFMMEngine.hpp"
#include "Kernels/Interpolation/FInterpMatrixKernel.hpp"
#include "Kernels/P2P/FP2PLeafInterface.hpp"
//#include "Kernels/P2P/FP2PLeafInterface.hpp"
#include "Arranger/FOctreeArranger.hpp"
#include "Arranger/FArrangerPeriodic.hpp"
#include "Arranger/FBasicParticleContainerIndexedMover.hpp"
#include "Core/FFmmAlgorithmThread.hpp"
#include "Core/FFmmAlgorithm.hpp"
......@@ -45,12 +46,14 @@ class FInterEngine : public FScalFMMEngine{
private:
//Typedef on the octree class, in order to clarify following code
typedef FOctree<InterCell,ContainerClass,LeafClass> OctreeClass;
typedef FP2PLeafInterface<OctreeClass> LeafInterface;
//typedef FP2PLeafInterface<OctreeClass> LeafInterface;
//Typedef on Octree Arranger, in order to clarify following code
typedef FOctreeArranger<OctreeClass,ContainerClass,LeafInterface> ArrangerClass;
typedef FArrangerPeriodic<OctreeClass,ContainerClass,LeafInterface> ArrangerClassPeriodic;
typedef FBasicParticleContainerIndexedMover<OctreeClass, ContainerClass> MoverClass;
typedef FOctreeArranger<OctreeClass, ContainerClass, MoverClass> ArrangerClass;
typedef FArrangerPeriodic<OctreeClass, ContainerClass, MoverClass> ArrangerClassPeriodic;
//Pointer to the kernel to be executed
InterKernel * kernel;
MatrixKernelClass * matrix;
......@@ -67,19 +70,26 @@ public:
* @param BoxCenter double[3] coordinate of the center of the
* simulation box
*/
FInterEngine(int TreeHeight, double BoxWidth , double * BoxCenter,scalfmm_kernel_type KernelType) :
FInterEngine(scalfmm_kernel_type KernelType) :
kernel(nullptr), matrix(nullptr), octree(nullptr),arranger(nullptr){
kernelType = KernelType;
}
void build_tree(int TreeHeight, double BoxWidth , double * BoxCenter,User_Scalfmm_Cell_Descriptor notUsedHere){
octree = new OctreeClass(TreeHeight,FMath::Min(3,TreeHeight-1),BoxWidth,FPoint(BoxCenter));
this->matrix = new MatrixKernelClass();
this->kernel = new InterKernel(TreeHeight,BoxWidth,FPoint(BoxCenter),matrix);
kernelType = KernelType;
arranger = nullptr;
}
//TODO free kernel too
~FInterEngine(){
free(octree);
free(kernel);
delete matrix;
delete octree;
delete kernel;
if(arranger){
delete arranger;
}
}
//Inserting array of position
......@@ -528,7 +538,6 @@ public:
void execute_fmm(){
//typedef FOctree<InterCell,ContainerClass,LeafClass> OctreeClass;
switch(Algorithm){
case 0:
{
......@@ -557,7 +566,9 @@ public:
}
}
void intern_dealloc_handle(Callback_free_cell unUsed){
//this->~FInterEngine();
}
};
......
......@@ -51,11 +51,16 @@ protected:
scalfmm_kernel_type kernelType;
scalfmm_algorithm Algorithm;
FVector<bool> progress;
FVector<bool>* progress;
int nbPart;
public:
FScalFMMEngine() : Algorithm(multi_thread), progress(), nbPart(0){
FScalFMMEngine() : Algorithm(multi_thread), progress(nullptr), nbPart(0){
progress = new FVector<bool>();
}
virtual ~FScalFMMEngine() {
delete progress;
}
//First function displayed there are common function for every
......@@ -75,6 +80,10 @@ public:
//by specific Engine
//Function about the tree
virtual void build_tree(int TreeHeight,double BoxWidth,double* BoxCenter,Scalfmm_Cell_Descriptor user_cell_descriptor){
FAssertLF(0,"Nothing has been done yet, exiting");
}
virtual void tree_insert_particles( int NbPositions, double * arrayX, double * arrayY, double * arrayZ){
FAssertLF(0,"No tree instancied, exiting ...\n");
}
......@@ -196,15 +205,11 @@ public:
FAssertLF(0,"No user kernel defined, exiting ...\n");
}
virtual void init_cell(Callback_init_cell user_cell_initializer){
FAssertLF(0,"No user kernel defined, exiting ...\n");
}
virtual void free_cell(Callback_free_cell user_cell_initializer){
FAssertLF(0,"No user kernel defined, exiting ...\n");
virtual void execute_fmm(){
FAssertLF(0,"No kernel set, cannot execute anything, exiting ...\n");
}
virtual void execute_fmm(){
virtual void intern_dealloc_handle(Callback_free_cell userDeallocator){
FAssertLF(0,"No kernel set, cannot execute anything, exiting ...\n");
}
......@@ -225,7 +230,9 @@ struct ScalFmmCoreHandle {
extern "C" void scalfmm_build_tree(scalfmm_handle Handle,int TreeHeight,double BoxWidth,double* BoxCenter,Scalfmm_Cell_Descriptor user_cell_descriptor){
((ScalFmmCoreHandle *) Handle)->engine->build_tree(TreeHeight,BoxWidth, BoxCenter, user_cell_descriptor);
}
extern "C" void scalfmm_tree_insert_particles(scalfmm_handle Handle, int NbPositions, double * arrayX, double * arrayY, double * arrayZ){
((ScalFmmCoreHandle *) Handle)->engine->tree_insert_particles(NbPositions, arrayX, arrayY, arrayZ);
......@@ -378,12 +385,8 @@ extern "C" void scalfmm_execute_fmm(scalfmm_handle Handle){
((ScalFmmCoreHandle * ) Handle)->engine->execute_fmm();
}
extern "C" void scalfmm_init_cell(scalfmm_handle Handle, Callback_init_cell user_cell_initializer){
((ScalFmmCoreHandle * ) Handle)->engine->init_cell(user_cell_initializer);
}
extern "C" void scalfmm_free_cell(scalfmm_handle Handle, Callback_free_cell user_cell_deallocator){
((ScalFmmCoreHandle * ) Handle)->engine->free_cell(user_cell_deallocator);
extern "C" void scalfmm_user_kernel_config(scalfmm_handle Handle, Scalfmm_Kernel_Descriptor userKernel, void * userDatas){
((ScalFmmCoreHandle * ) Handle)->engine->user_kernel_config(userKernel,userDatas);
}
......
#ifndef CALL_HPP
#define CALL_HPP
/** It should be compiled with C export */
extern "C" {
#include "CScalfmmApi.h"
......@@ -10,13 +6,12 @@ extern "C" {
#include "FInterEngine.hpp"
#include "FUserKernelEngine.hpp"
extern "C" scalfmm_handle scalfmm_init(int TreeHeight,double BoxWidth,double* BoxCenter, scalfmm_kernel_type KernelType){
extern "C" scalfmm_handle scalfmm_init(/*int TreeHeight,double BoxWidth,double* BoxCenter, */scalfmm_kernel_type KernelType){
ScalFmmCoreHandle * handle = new ScalFmmCoreHandle();
switch(KernelType){
case 0:
//handle->engine = new FUserKernelEngine(...);
std::cout<< "User Kernel type unsupported yet" << std::endl;
handle->engine = new FUserKernelEngine(/*TreeHeight, BoxWidth, BoxCenter, */KernelType);
break;
case 1:
......@@ -27,7 +22,7 @@ extern "C" scalfmm_handle scalfmm_init(int TreeHeight,double BoxWidth,double* Bo
typedef FInterpMatrixKernelR MatrixKernelClass;
typedef FChebSymKernel<ChebCell,ContainerClass,MatrixKernelClass,7> ChebKernel;
handle->engine = new FInterEngine<ChebCell,ChebKernel>(TreeHeight,BoxWidth,BoxCenter, KernelType);
handle->engine = new FInterEngine<ChebCell,ChebKernel>(/*TreeHeight,BoxWidth,BoxCenter, */KernelType);
break;
case 2:
//TODO typedefs
......@@ -37,7 +32,7 @@ extern "C" scalfmm_handle scalfmm_init(int TreeHeight,double BoxWidth,double* Bo
typedef FInterpMatrixKernelR MatrixKernelClass;
typedef FUnifKernel<UnifCell,ContainerClass,MatrixKernelClass,7> UnifKernel;
handle->engine = new FInterEngine<UnifCell,UnifKernel>(TreeHeight,BoxWidth,BoxCenter,KernelType);
handle->engine = new FInterEngine<UnifCell,UnifKernel>(/*TreeHeight,BoxWidth,BoxCenter, */KernelType);
break;
default:
......@@ -48,5 +43,8 @@ extern "C" scalfmm_handle scalfmm_init(int TreeHeight,double BoxWidth,double* Bo
return handle;
}
#endif
extern "C" void scalfmm_dealloc_handle(scalfmm_handle handle, Callback_free_cell userDeallocator){
((ScalFmmCoreHandle *) handle)->engine->intern_dealloc_handle(userDeallocator);
delete ((ScalFmmCoreHandle *) handle)->engine ;
delete (ScalFmmCoreHandle *) handle;
}
This diff is collapsed.
......@@ -23,12 +23,17 @@ int main(int argc, char ** av){
scalfmm_kernel_type myChoice = chebyshev;
//Octree configuration
int TreeHeight = 5;
int TreeHeight = 7;
double boxWidth = 2.0;
double boxCenter[3] = {0.0,0.0,0.0};
//Init our lib
scalfmm_handle handle = scalfmm_init(TreeHeight,boxWidth,boxCenter,myChoice); //The tree is built
scalfmm_handle handle = scalfmm_init(/* TreeHeight,boxWidth,boxCenter, */myChoice); //The tree is built
struct User_Scalfmm_Cell_Descriptor user_descr;
user_descr.user_init_cell = NULL;
user_descr.user_free_cell = NULL;
scalfmm_build_tree(handle,TreeHeight,boxWidth,boxCenter,user_descr);
scalfmm_algorithm_config(handle,periodic);
//Creation of an array of particles
int nb_of_parts = 2;
......@@ -56,7 +61,7 @@ int main(int argc, char ** av){
//Computation Part
int nb_iteration = 100;
int nb_iteration = 3;//atoi(av[1]);
int curr_iteration = 0;
//Array to store the output
......@@ -112,13 +117,16 @@ int main(int argc, char ** av){
curr_iteration++;
}
//End of Computation, useer get the position after a hundreds of iterations
//Free memory
free(positionsXYZ);
free(array_of_charge);
free(array_of_forces);
free(array_of_pot);
free(array_of_displacement);
//End of Computation, useer get the position after some iterations
scalfmm_dealloc_handle(handle,NULL);
return 0;
}
......@@ -25,7 +25,7 @@
#include "../Src/CScalfmmApi.h"
// Uncomment the next line to avoid the print in the kernel and verbosity
// #define NOT_TOO_MUCH_VERBOSE
#define NOT_TOO_MUCH_VERBOSE
#ifdef NOT_TOO_MUCH_VERBOSE
#define VerbosePrint(X...)
#else
......@@ -233,13 +233,19 @@ int main(int argc, char ** argv){
}
// Init the handle
scalfmm_handle handle = scalfmm_init(treeHeight, boxWidth, boxCenter,user_defined_kernel);
scalfmm_handle handle = scalfmm_init(user_defined_kernel);
//Build our own call backs
struct User_Scalfmm_Cell_Descriptor cellDescriptor;
cellDescriptor.user_init_cell = my_Callback_init_cell;
cellDescriptor.user_free_cell = my_Callback_free_cell;
// Init tree and cell
printf("Building the tree and Initizalizing the cells:\n");
scalfmm_build_tree(handle,treeHeight, boxWidth, boxCenter, cellDescriptor);
// Insert particles
printf("Inserting particles...\n");
Scalfmm_insert_array_of_particles(handle, nbParticles, particleIndexes, particleXYZ);
// Init cell
printf("Initizalizing the cells:\n");
Scalfmm_init_cell(handle, my_Callback_init_cell);
scalfmm_tree_insert_particles_xyz(handle, nbParticles, particleXYZ);
// Init our callback struct
struct User_Scalfmm_Kernel_Descriptor kernel;
......@@ -255,9 +261,34 @@ int main(int argc, char ** argv){
struct MyData my_data;
memset(&my_data, 0, sizeof(struct MyData));
my_data.insertedPositions = particleXYZ;
//Set my datas before calling fmm (this will set as well the kernel)
scalfmm_user_kernel_config(handle,kernel,&my_data);
//loop to multiples runs of the fmm
int nb_ite = 1;
int curr_ite = 0;
//array to store positions
double new_positions[nbParticles*3];
memset(new_positions,0,3*nbParticles*sizeof(double));
while(curr_ite < nb_ite){
// Execute the FMM
scalfmm_execute_fmm(handle/*, kernel, &my_data*/);
scalfmm_get_positions_xyz(handle,nbParticles,new_positions);
//Computation on those positions
//Here it's a random
int id;
for(id = 0 ; id < nbParticles ; ++id){
new_positions[id*3 ] = (random()/(double)(RAND_MAX))*boxWidth - boxWidth/2 + boxCenter[0];
new_positions[id*3+1] = (random()/(double)(RAND_MAX))*boxWidth - boxWidth/2 + boxCenter[1];
new_positions[id*3+2] = (random()/(double)(RAND_MAX))*boxWidth - boxWidth/2 + boxCenter[2];
}
printf("Positions changed \n");
// Execute the FMM
Scalfmm_execute_kernel(handle, kernel, &my_data);
scalfmm_set_positions_xyz(handle,nbParticles,new_positions);
scalfmm_update_tree(handle);
curr_ite++;
}
// Print the results store in our callback
printf("There was %d P2M\n", my_data.countP2M);
......@@ -269,7 +300,7 @@ int main(int argc, char ** argv){
printf("There was %d P2P\n", my_data.countP2P);
// Dealloc the handle
Scalfmm_dealloc_handle(handle,my_Callback_free_cell);
scalfmm_dealloc_handle(handle,my_Callback_free_cell);
return 0;
}
......@@ -111,8 +111,12 @@ else()
# NOT INTEL
if(NOT ${ScalFMM_USE_MPI})
SET(ScaLFMM_CXX_FLAGS "${ScaLFMM_CXX_FLAGS} -Wzero-as-null-pointer-constant")
else()
SET(ScaLFMM_CXX_FLAGS "${ScaLFMM_CXX_FLAGS} -Wno-literal-suffix")
else()
include(CheckCCompilerFlag)
check_c_compiler_flag(-Wno-literal-suffix HAS_NO_LITERAL_SUFFIX_FLAG)
if(HAS_NO_LITERAL_SUFFIX_FLAG)
SET(ScaLFMM_CXX_FLAGS "${ScaLFMM_CXX_FLAGS} -Wno-literal-suffix")
endif()
endif()
SET(AVX_FLAGS "-mtune=native -march=native")
IF (APPLE)
......@@ -326,6 +330,11 @@ ENDIF(ScalFMM_USE_AVX AND ScalFMM_USE_SSE)
# Use native MIC compilation #
##################################################################
if( ScalFMM_USE_MIC_NATIVE )
include(CheckCCompilerFlag)
check_c_compiler_flag(-mmic HAS_MMIC_FLAG)
IF(NOT HAS_MMIC_FLAG)
MESSAGE(FATAL_ERROR "MIC NOT SUPPORTED ; Set ScalFMM_USE_MIC_NATIVE to OFF")
ENDIF()
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmic")
else()
# SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -xhost")
......
......@@ -118,7 +118,7 @@ int main(int argc, char* argv[])
#ifdef _OPENMP
omp_set_num_threads(NbThreads);
#else
std::cout << "\n>> Sequential version.\n" << std::
std::cout << "\n>> Sequential version.\n" << std::endl;
#endif
std::cout << "Parameters "<< std::endl
......
......@@ -37,7 +37,7 @@ class FMpiBufferWriter : public FAbstractBufferWriter {
/** Test and exit if not enought space */
void expandIfNeeded(const size_t requestedSpace) {
if( arrayCapacity < int(currentIndex + requestedSpace) ){
arrayCapacity = int((currentIndex + requestedSpace + 1) * 1.5);
arrayCapacity = int(double(currentIndex + requestedSpace + 1) * 1.5);
char* arrayTmp = new char[arrayCapacity];
memcpy(arrayTmp, array.get(), sizeof(char)*currentIndex);
array.reset(arrayTmp);
......
......@@ -145,13 +145,14 @@ public:
}
/** Resize the vector (and change the capacity if needed) */
void resize(const int newSize){
template <typename... Args>
void resize(const int newSize, Args... args){
if(index < newSize){
if(capacity < newSize){
setCapacity(int(newSize*1.5));
}
while(index != newSize){
new((void*)&array[index]) ObjectType();
new((void*)&array[index]) ObjectType(args...);
}
}
else{
......@@ -215,6 +216,19 @@ public:
new((void*)&array[index++]) ObjectType(inValue);
}
/**
* To Create a new object
*/
template <typename... Args>
void pushNew(Args... args){
// if needed, increase the vector
if( index == capacity ){
setCapacity(int((capacity+1) * 1.5));
}
// add the new element
new((void*)&array[index++]) ObjectType(args...);
}
/**
* Add one value multiple time
* @param inValue the new value
......
......@@ -66,7 +66,10 @@ public:
this->kernels = new KernelClass*[MaxThreads];
#pragma omp parallel for schedule(static)
for(int idxThread = 0 ; idxThread < MaxThreads ; ++idxThread){
this->kernels[idxThread] = new KernelClass(*inKernels);
#pragma omp critical (InitFFmmAlgorithmSectionTask)
{
this->kernels[idxThread] = new KernelClass(*inKernels);
}
}
FLOG(FLog::Controller << "FFmmAlgorithmSectionTask (Max Thread " << omp_get_max_threads() << ")\n");
......
......@@ -66,7 +66,10 @@ public:
this->kernels = new KernelClass*[MaxThreads];
#pragma omp parallel for schedule(static)
for(int idxThread = 0 ; idxThread < MaxThreads ; ++idxThread){
this->kernels[idxThread] = new KernelClass(*inKernels);
#pragma omp critical (InitFFmmAlgorithmTask)
{
this->kernels[idxThread] = new KernelClass(*inKernels);
}
}
FLOG(FLog::Controller << "FFmmAlgorithmTask (Max Thread " << omp_get_max_threads() << ")\n");
......
......@@ -74,7 +74,10 @@ public:
this->kernels = new KernelClass*[MaxThreads];
#pragma omp parallel for schedule(static)
for(int idxThread = 0 ; idxThread < MaxThreads ; ++idxThread){
this->kernels[idxThread] = new KernelClass(*inKernels);
#pragma omp critical (InitFFmmAlgorithmThread)
{
this->kernels[idxThread] = new KernelClass(*inKernels);
}
}
FLOG(FLog::Controller << "FFmmAlgorithmThread (Max Thread " << omp_get_max_threads() << ")\n");
......
......@@ -143,7 +143,10 @@ public:
this->kernels = new KernelClass*[MaxThreads];
#pragma omp parallel for schedule(static)
for(int idxThread = 0 ; idxThread < MaxThreads ; ++idxThread){
this->kernels[idxThread] = new KernelClass(*inKernels);
#pragma omp critical (InitFFmmAlgorithmThreadProc)
{
this->kernels[idxThread] = new KernelClass(*inKernels);
}
}
FLOG(FLog::Controller << "FFmmAlgorithmThreadProc\n");
......@@ -674,7 +677,7 @@ private:
for(int idxProc = 0 ; idxProc < nbProcess ; ++idxProc){
const long long int toSendAtProcAtLevel = indexToSend[idxLevel * nbProcess + idxProc];
if(toSendAtProcAtLevel != 0){
sendBuffer[idxLevel * nbProcess + idxProc] = new FMpiBufferWriter(comm.getComm(),toSendAtProcAtLevel);
sendBuffer[idxLevel * nbProcess + idxProc] = new FMpiBufferWriter(comm.getComm(),int(toSendAtProcAtLevel));
sendBuffer[idxLevel * nbProcess + idxProc]->write(int(toSend[idxLevel * nbProcess + idxProc].getSize()));
......@@ -693,7 +696,7 @@ private:
const long long int toReceiveFromProcAtLevel = globalReceiveMap[(idxProc * nbProcess * OctreeHeight) + idxLevel * nbProcess + idProcess];
if(toReceiveFromProcAtLevel){
recvBuffer[idxLevel * nbProcess + idxProc] = new FMpiBufferReader(comm.getComm(),toReceiveFromProcAtLevel);
recvBuffer[idxLevel * nbProcess + idxProc] = new FMpiBufferReader(comm.getComm(),int(toReceiveFromProcAtLevel));
FMpi::MpiAssert( MPI_Irecv(recvBuffer[idxLevel * nbProcess + idxProc]->data(),
recvBuffer[idxLevel * nbProcess + idxProc]->getCapacity(), MPI_PACKED,idxProc,
......
......@@ -115,7 +115,10 @@ public:
this->kernels = new KernelClass*[MaxThreads];
#pragma omp parallel for schedule(static)
for(int idxThread = 0 ; idxThread < MaxThreads ; ++idxThread){
this->kernels[idxThread] = new KernelClass(*inKernels);
#pragma omp critical (InitFFmmAlgorithmThreadProcPeriodic)
{
this->kernels[idxThread] = new KernelClass(*inKernels);
}
}
}
......
......@@ -70,7 +70,10 @@ public:
this->kernels = new KernelClass*[MaxThreads];
#pragma omp parallel for schedule(static)
for(int idxThread = 0 ; idxThread < MaxThreads ; ++idxThread){
this->kernels[idxThread] = new KernelClass(*inKernels);
#pragma omp critical (InitFFmmAlgorithmThreadTsm)
{
this->kernels[idxThread] = new KernelClass(*inKernels);
}
}
FLOG(FLog::Controller << "FFmmAlgorithmThreadTsm\n");
......
This diff is collapsed.
......@@ -22,6 +22,16 @@ enum FSmartPointerType{
FSmartPointerMemory
};
template <FSmartPointerType MemoryType, class ClassType>
inline typename std::enable_if<(MemoryType == FSmartArrayMemory), void>::type FSmartDeletePointer(ClassType* ptr){
delete[] ptr;
}
template <FSmartPointerType MemoryType, class ClassType>
inline typename std::enable_if<(MemoryType == FSmartPointerMemory), void>::type FSmartDeletePointer(ClassType* ptr){
delete ptr;
}
/** This class is a basic smart pointer class
* Use as FSmartPointer<int> array = new int[5];
* FSmartPointer<int, PointerMemory> pt = new int;
......@@ -87,8 +97,7 @@ public:
if(counter){
(*counter) -= 1;
if( (*counter) == 0 ){
if(MemoryType == FSmartArrayMemory) delete[] pointer;
else if(MemoryType == FSmartPointerMemory) delete pointer;
FSmartDeletePointer<MemoryType>(pointer);
delete counter;
}
pointer = nullptr;
......
......@@ -26,6 +26,14 @@
#include <smmintrin.h> // SSE4
#endif
#ifndef _mm_set_pd1
// Looks like clang's emmintrin.h doesn't have this alternate name.
// But _mm_set1_pd is an equivalent to _mm_set_pd1.
#define _mm_set_pd1 _mm_set1_pd
#endif
#ifdef __SSEPE_INTEL_COMPILER