MAJ terminée. Nous sommes passés en version 14.6.2 . Pour consulter les "releases notes" associées c'est ici :

https://about.gitlab.com/releases/2022/01/11/security-release-gitlab-14-6-2-released/
https://about.gitlab.com/releases/2022/01/04/gitlab-14-6-1-released/

Commit b2c72a49 authored by berenger-bramas's avatar berenger-bramas
Browse files

Time counter FTic added.

This is a cross os time counter to evaluate performance.
(Also every openmp time counting has been removed and replaced by ftic)

git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/scalfmm/scalfmm/trunk@9 2616d619-271b-44dc-8df4-d4a8f33a7222
parent 824f70fd
#ifndef FTIC_HPP
#define FTIC_HPP
#if defined(_WIN32) || defined(ming)
#define WINDOWS
#include <windows.h>
#else
#define POSIX
#include <sys/time.h>
#endif
#include <time.h>
/** @author Berenger Bramas (berenger.bramas@inria.fr)
* This class is a easy to use time counter
* With it you can very easyli estimate elapsed
* time between two moments
* <code>
* FTic counter;<br>
* counter.tic();<br>
* //...<br>
* counter.tac();<br>
* counter.elapsed(); //> time in s<br>
* </code>
*/
class FTic {
private:
double start; //< start time (tic)
double end; //<stop time (tac)
public:
/** Constructor */
FTic() : start(0.0), end(0.0) {
}
/** Tic : start <= current time */
void tic(){
this->start = FTic::GetTime();
}
/** Tac : end <= current time */
void tac(){
this->end = FTic::GetTime();
}
/** Return end - start
* @return the time elapsed between tic & tac in second */
double elapsed() const{
return this->end - this->start;
}
/** Global get time
* @return a global time
* GetTickCount on windows
* gettimeofday on linux
*/
static double GetTime(){
#ifdef WINDOWS
return static_cast<double>(GetTickCount())/1000.0;
#else
timeval t;
gettimeofday(&t, NULL);
return (t.tv_sec) + (t.tv_usec/1000000.0);
#endif
}
};
#endif
......@@ -5,8 +5,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <omp.h>
#include "../Sources/Containers/FOctree.hpp"
#include "../Sources/Containers/FList.hpp"
......@@ -19,8 +17,10 @@
#include "../Sources/Core/FFMMAlgorithm.hpp"
#include "../Sources/Core/FSimpleKernels.hpp"
#include "../Sources/Utils/FTic.hpp"
// We use openmp to count time (portable and easy to manage)
// Compile by : g++ testFMMAlgorithm.cpp ../Sources/Utils/FDebug.cpp ../Sources/Utils/FAssertable.cpp -lgomp -fopenmp -O2 -o testFMMAlgorithm.exe
// Compile by : g++ testFMMAlgorithm.cpp ../Sources/Utils/FDebug.cpp ../Sources/Utils/FAssertable.cpp -O2 -o testFMMAlgorithm.exe
/** This program show an example of use of
* the fmm basic algo
......@@ -145,43 +145,44 @@ public:
int main(int , char ** ){
const int NbLevels = 10;//10;
const int NbSubLevels = 3;//3
const long NbPart = 2000000;//2E6;
const long NbPart = 200000;//2E6;
MyTestParticule* particules = new MyTestParticule[NbPart];
FTic counter;
srand ( 1 ); // volontary set seed to constant
// -----------------------------------------------------
std::cout << "Creating " << NbPart << " particules ..." << std::endl;
const double CreatingStartTime = omp_get_wtime();
counter.tic();
for(long idxPart = 0 ; idxPart < NbPart ; ++idxPart){
new (&particules[idxPart]) MyTestParticule(double(rand())/RAND_MAX,double(rand())/RAND_MAX,double(rand())/RAND_MAX);
}
const double CreatingEndTime = omp_get_wtime();
std::cout << "Done " << "(" << (CreatingEndTime-CreatingStartTime) << "s)." << std::endl;
counter.tac();
std::cout << "Done " << "(" << counter.elapsed() << "s)." << std::endl;
// -----------------------------------------------------
FOctree<MyTestParticule, MyTestCell, NbLevels, NbSubLevels> tree(1.0,F3DPosition(0.5,0.5,0.5));
// -----------------------------------------------------
std::cout << "Inserting particules ..." << std::endl;
const double InsertingStartTime = omp_get_wtime();
counter.tic();
for(long idxPart = 0 ; idxPart < NbPart ; ++idxPart){
tree.insert(&particules[idxPart]);
}
const double InsertingEndTime = omp_get_wtime();
std::cout << "Done " << "(" << (InsertingEndTime-InsertingStartTime) << "s)." << std::endl;
counter.tac();
std::cout << "Done " << "(" << counter.elapsed() << "s)." << std::endl;
// -----------------------------------------------------
std::cout << "Working on particules ..." << std::endl;
const double WorkingStartTime = omp_get_wtime();
counter.tic();
MyTestKernels<MyTestParticule, MyTestCell> kernels;
FFMMAlgorithm<MyTestParticule, MyTestCell, NbLevels, NbSubLevels> algo(&tree,&kernels);
algo.execute();
const double WorkingEndTime = omp_get_wtime();
std::cout << "Done " << "(" << (WorkingEndTime-WorkingStartTime) << "s)." << std::endl;
counter.tac();
std::cout << "Done " << "(" << counter.elapsed() << "s)." << std::endl;
// -----------------------------------------------------
......@@ -216,13 +217,13 @@ int main(int , char ** ){
// -----------------------------------------------------
std::cout << "Deleting particules ..." << std::endl;
const double DeletingStartTime = omp_get_wtime();
counter.tic();
for(long idxPart = 0 ; idxPart < NbPart ; ++idxPart){
particules[idxPart].~MyTestParticule();
}
delete [] particules;
const double DeletingEndTime = omp_get_wtime();
std::cout << "Done " << "(" << (DeletingEndTime-DeletingStartTime) << "s)." << std::endl;
counter.tac();
std::cout << "Done " << "(" << counter.elapsed() << "s)." << std::endl;
// -----------------------------------------------------
return 0;
......
......@@ -6,7 +6,7 @@
#include <stdlib.h>
#include <time.h>
#include <omp.h>
#include "../Sources/Utils/FTic.hpp"
#include "../Sources/Containers/FOctree.hpp"
#include "../Sources/Containers/FList.hpp"
......@@ -19,7 +19,7 @@
#include "../Sources/Files/FBasicLoader.hpp"
// Compile by : g++ testLoader.cpp ../Sources/Utils/FAssertable.cpp -O2 -lgomp -fopenmp -o testLoader.exe
// Compile by : g++ testLoader.cpp ../Sources/Utils/FAssertable.cpp -O2 -o testLoader.exe
/**
......@@ -36,6 +36,7 @@ int main(int , char ** ){
FList<FBasicParticule*> particules;
// Use testLoaderCreate.exe to create this file
const char* const filename = "testLoader.basic.temp";
FTic counter;
// open basic particules loader
FBasicLoader<FBasicParticule> loader(filename);
......@@ -49,24 +50,24 @@ int main(int , char ** ){
// -----------------------------------------------------
std::cout << "Inserting " << loader.getNumberOfParticules() << " particules ..." << std::endl;
const double InsertingStartTime = omp_get_wtime();
counter.tic();
for(int idx = 0 ; idx < loader.getNumberOfParticules() ; ++idx){
FBasicParticule* const part = new FBasicParticule();
particules.pushFront(part);
loader.fillParticule(part);
tree.insert(part);
}
const double InsertingEndTime = omp_get_wtime();
std::cout << "Done " << "(" << (InsertingEndTime-InsertingStartTime) << ")." << std::endl;
counter.tac();
std::cout << "Done " << "(" << counter.elapsed() << ")." << std::endl;
// -----------------------------------------------------
std::cout << "Deleting particules ..." << std::endl;
const double DeletingStartTime = omp_get_wtime();
counter.tic();
while(particules.getSize()){
delete particules.popFront();
}
const double DeletingEndTime = omp_get_wtime();
std::cout << "Done " << "(" << (DeletingEndTime-DeletingStartTime) << ")." << std::endl;
counter.tac();
std::cout << "Done " << "(" << counter.elapsed() << ")." << std::endl;
// -----------------------------------------------------
return 0;
......
......@@ -6,7 +6,7 @@
#include <stdlib.h>
#include <time.h>
#include <omp.h>
#include "../Sources/Utils/FTic.hpp"
#include "../Sources/Containers/FOctree.hpp"
#include "../Sources/Containers/FList.hpp"
......@@ -19,7 +19,7 @@
#include "../Sources/Files/FFMALoader.hpp"
// Compile by : g++ testLoaderFMA.cpp ../Sources/Utils/FAssertable.cpp -O2 -lgomp -fopenmp -o testLoaderFMA.exe
// Compile by : g++ testLoaderFMA.cpp ../Sources/Utils/FAssertable.cpp -O2 -o testLoaderFMA.exe
/**
......@@ -36,6 +36,7 @@ int main(int , char ** ){
FList<FBasicParticule*> particules;
// Use testLoaderCreate.exe to create this file
const char* const filename = "testLoaderFMA.fma";
FTic counter;
// open basic particules loader
FFMALoader<FBasicParticule> loader(filename);
......@@ -49,24 +50,24 @@ int main(int , char ** ){
// -----------------------------------------------------
std::cout << "Inserting " << loader.getNumberOfParticules() << " particules ..." << std::endl;
const double InsertingStartTime = omp_get_wtime();
counter.tic();
for(int idx = 0 ; idx < loader.getNumberOfParticules() ; ++idx){
FBasicParticule* const part = new FBasicParticule();
particules.pushFront(part);
loader.fillParticule(part);
tree.insert(part);
}
const double InsertingEndTime = omp_get_wtime();
std::cout << "Done " << "(" << (InsertingEndTime-InsertingStartTime) << ")." << std::endl;
counter.tac();
std::cout << "Done " << "(" << counter.elapsed() << ")." << std::endl;
// -----------------------------------------------------
std::cout << "Deleting particules ..." << std::endl;
const double DeletingStartTime = omp_get_wtime();
counter.tic();
while(particules.getSize()){
delete particules.popFront();
}
const double DeletingEndTime = omp_get_wtime();
std::cout << "Done " << "(" << (DeletingEndTime-DeletingStartTime) << ")." << std::endl;
counter.tac();
std::cout << "Done " << "(" << counter.elapsed() << ")." << std::endl;
// -----------------------------------------------------
return 0;
......
......@@ -6,7 +6,7 @@
#include <stdlib.h>
#include <time.h>
#include <omp.h>
#include "../Sources/Utils/FTic.hpp"
#include "../Sources/Containers/FOctree.hpp"
#include "../Sources/Containers/FList.hpp"
......@@ -18,7 +18,7 @@
#include "../Sources/Core/FAbstractCell.hpp"
// We use openmp to count time (portable and easy to manage)
// Compile by : g++ testOctree.cpp ../Sources/Utils/FAssertable.cpp -O2 -lgomp -fopenmp -o testOctree.exe
// Compile by : g++ testOctree.cpp ../Sources/Utils/FAssertable.cpp -O2 -o testOctree.exe
/**
* In this file we show how to use octree
......@@ -59,18 +59,19 @@ public:
int main(int , char ** ){
const long NbPart = 2000000;
FList<TestParticule*> particules;
FTic counter;
srand ( time(NULL) );
// -----------------------------------------------------
std::cout << "Creating " << NbPart << " particules ..." << std::endl;
const double CreatingStartTime = omp_get_wtime();
counter.tic();
for(long idxPart = 0 ; idxPart < NbPart ; ++idxPart){
particules.pushFront(new TestParticule(F3DPosition(double(rand())/RAND_MAX,double(rand())/RAND_MAX,double(rand())/RAND_MAX)));
}
const double CreatingEndTime = omp_get_wtime();
std::cout << "Done " << "(" << (CreatingEndTime-CreatingStartTime) << ")." << std::endl;
counter.tac();
std::cout << "Done " << "(" << counter.elapsed() << ")." << std::endl;
// -----------------------------------------------------
FOctree<TestParticule, TestCell, 10, 3> tree(1.0,F3DPosition(0.5,0.5,0.5));
......@@ -78,23 +79,23 @@ int main(int , char ** ){
// -----------------------------------------------------
std::cout << "Inserting particules ..." << std::endl;
const double InsertingStartTime = omp_get_wtime();
counter.tic();
while( iter.isValide() ){
tree.insert(iter.value());
iter.progress();
}
const double InsertingEndTime = omp_get_wtime();
std::cout << "Done " << "(" << (InsertingEndTime-InsertingStartTime) << ")." << std::endl;
counter.tac();
std::cout << "Done " << "(" << counter.elapsed() << ")." << std::endl;
// -----------------------------------------------------
// -----------------------------------------------------
std::cout << "Deleting particules ..." << std::endl;
const double DeletingStartTime = omp_get_wtime();
counter.tic();
while(particules.getSize()){
delete particules.popFront();
}
const double DeletingEndTime = omp_get_wtime();
std::cout << "Done " << "(" << (DeletingEndTime-DeletingStartTime) << ")." << std::endl;
counter.tac();
std::cout << "Done " << "(" << counter.elapsed() << ")." << std::endl;
// -----------------------------------------------------
......
......@@ -6,7 +6,7 @@
#include <stdlib.h>
#include <time.h>
#include <omp.h>
#include "../Sources/Utils/FTic.hpp"
#include "../Sources/Containers/FOctree.hpp"
#include "../Sources/Containers/FList.hpp"
......@@ -18,7 +18,7 @@
#include "../Sources/Core/FAbstractCell.hpp"
// We use openmp to count time (portable and easy to manage)
// Compile by : g++ testOctreeIter.cpp ../Sources/Utils/FAssertable.cpp -lgomp -fopenmp -O2 -o testOctreeIter.exe
// Compile by : g++ testOctreeIter.cpp ../Sources/Utils/FAssertable.cpp -O2 -o testOctreeIter.exe
/**
* In this file we show how to use octree with iteration
......@@ -87,17 +87,18 @@ int main(int , char ** ){
const int NbSubLevels = 3;
const long NbPart = 2E6;
FList<TestParticule*> particules;
FTic counter;
srand ( 1 ); // volontary set seed to constant
// -----------------------------------------------------
std::cout << "Creating " << NbPart << " particules ..." << std::endl;
const double CreatingStartTime = omp_get_wtime();
counter.tic();
for(long idxPart = 0 ; idxPart < NbPart ; ++idxPart){
particules.pushFront(new TestParticule(F3DPosition(double(rand())/RAND_MAX,double(rand())/RAND_MAX,double(rand())/RAND_MAX)));
}
const double CreatingEndTime = omp_get_wtime();
std::cout << "Done " << "(" << (CreatingEndTime-CreatingStartTime) << "s)." << std::endl;
counter.tac();
std::cout << "Done " << "(" << counter.elapsed() << "s)." << std::endl;
// -----------------------------------------------------
FOctree<TestParticule, TestCell, NbLevels, NbSubLevels> tree(1.0,F3DPosition(0.5,0.5,0.5));
......@@ -105,17 +106,17 @@ int main(int , char ** ){
// -----------------------------------------------------
std::cout << "Inserting particules ..." << std::endl;
const double InsertingStartTime = omp_get_wtime();
counter.tic();
while( iter.isValide() ){
tree.insert(iter.value());
iter.progress();
}
const double InsertingEndTime = omp_get_wtime();
std::cout << "Done " << "(" << (InsertingEndTime-InsertingStartTime) << "s)." << std::endl;
counter.tac();
std::cout << "Done " << "(" << counter.elapsed() << "s)." << std::endl;
// -----------------------------------------------------
std::cout << "Itering on particules ..." << std::endl;
const double InteringStartTime = omp_get_wtime();
counter.tic();
FOctree<TestParticule, TestCell, NbLevels, NbSubLevels>::Iterator octreeIterator(&tree);
octreeIterator.gotoBottomLeft();
......@@ -129,17 +130,17 @@ int main(int , char ** ){
octreeIterator.gotoLeft();
std::cout << "Next level (" << counter << ")...\n";
}
const double IteringEndTime = omp_get_wtime();
std::cout << "Done " << "(" << (IteringEndTime-InteringStartTime) << "s)." << std::endl;
counter.tac();
std::cout << "Done " << "(" << counter.elapsed() << "s)." << std::endl;
// -----------------------------------------------------
std::cout << "Deleting particules ..." << std::endl;
const double DeletingStartTime = omp_get_wtime();
counter.tic();
while(particules.getSize()){
delete particules.popFront();
}
const double DeletingEndTime = omp_get_wtime();
std::cout << "Done " << "(" << (DeletingEndTime-DeletingStartTime) << "s)." << std::endl;
counter.tac();
std::cout << "Done " << "(" << counter.elapsed() << "s)." << std::endl;
// -----------------------------------------------------
return 0;
......
#include <iostream>
#include "../Sources/Utils/FTic.hpp"
#include <stdlib.h>
#include <unistd.h>
/**
* Here we show an example of using FTic
* g++ testTic.cpp -o testTic.exe
*/
int main(){
FTic counter;
counter.tic();
usleep(1500000);
//Sleep(1500); //on windows
counter.tac();
std::cout << counter.elapsed() << " (s)\n";
return 0;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment