Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
ScalFMM
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
5
Issues
5
List
Boards
Labels
Milestones
Packages
Packages
Container Registry
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
solverstack
ScalFMM
Commits
0dfdbfdf
Commit
0dfdbfdf
authored
Jun 24, 2014
by
BRAMAS Berenger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Debug quicksort mpi and add a unit test
parent
398c5f08
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
1083 additions
and
950 deletions
+1083
-950
Src/Files/FMpiTreeBuilder.hpp
Src/Files/FMpiTreeBuilder.hpp
+316
-316
Src/Utils/FMpi.hpp
Src/Utils/FMpi.hpp
+253
-253
Src/Utils/FQuickSort.hpp
Src/Utils/FQuickSort.hpp
+0
-25
Src/Utils/FQuickSortMpi.hpp
Src/Utils/FQuickSortMpi.hpp
+324
-182
UTests/FUTester.hpp
UTests/FUTester.hpp
+175
-174
UTests/utestMpiQs.cpp
UTests/utestMpiQs.cpp
+15
-0
No files found.
Src/Files/FMpiTreeBuilder.hpp
View file @
0dfdbfdf
This diff is collapsed.
Click to expand it.
Src/Utils/FMpi.hpp
View file @
0dfdbfdf
This diff is collapsed.
Click to expand it.
Src/Utils/FQuickSort.hpp
View file @
0dfdbfdf
...
...
@@ -76,31 +76,6 @@ protected:
return
left
;
}
/* A local iteration of qs */
static
void
QsLocal
(
SortType
array
[],
const
CompareType
&
pivot
,
IndexType
myLeft
,
IndexType
myRight
,
IndexType
&
prefix
,
IndexType
&
sufix
){
IndexType
leftIter
=
myLeft
;
IndexType
rightIter
=
myRight
;
while
(
true
){
while
(
CompareType
(
array
[
leftIter
])
<=
pivot
&&
leftIter
<
rightIter
){
++
leftIter
;
}
while
(
leftIter
<=
rightIter
&&
pivot
<
CompareType
(
array
[
rightIter
])){
--
rightIter
;
}
if
(
rightIter
<
leftIter
)
break
;
Swap
(
array
[
leftIter
],
array
[
rightIter
]);
++
leftIter
;
--
rightIter
;
}
prefix
=
leftIter
-
myLeft
;
sufix
=
myRight
-
myLeft
-
prefix
+
1
;
}
/* The sequential qs */
static
void
QsSequentialStep
(
SortType
array
[],
const
IndexType
left
,
const
IndexType
right
){
...
...
Src/Utils/FQuickSortMpi.hpp
View file @
0dfdbfdf
This diff is collapsed.
Click to expand it.
UTests/FUTester.hpp
View file @
0dfdbfdf
...
...
@@ -16,6 +16,7 @@
#ifndef UTESTER_HPP
#define UTESTER_HPP
#include "ScalFmmConfig.h"
#include <iostream>
#include <list>
...
...
@@ -24,10 +25,10 @@
#define TestClass(X)\
int main(void){\
X Controller;\
return Controller.Run();\
}\
int main(void){\
X Controller;\
return Controller.Run();\
}\
/**
...
...
@@ -44,164 +45,164 @@ int main(void){\
*/
template
<
class
TestClass
>
class
FUTester
{
// Test function pointer
typedef
void
(
TestClass
::*
TestFunc
)(
void
);
/** Test descriptor */
struct
TestFuncDescriptor
{
TestFunc
func
;
//< Test adress
std
::
string
name
;
//< Test name
};
std
::
list
<
TestFuncDescriptor
>
tests
;
//< all tests
int
totalTests
;
//< number of tests
int
currentTest
;
//< current processing test in the run
int
currentStep
;
//< current processing step in the run
int
failedSteps
;
//< number of failed step in the current test
int
failedTests
;
//< number of failed tests
// Test function pointer
typedef
void
(
TestClass
::*
TestFunc
)(
void
);
/** Test descriptor */
struct
TestFuncDescriptor
{
TestFunc
func
;
//< Test adress
std
::
string
name
;
//< Test name
};
std
::
list
<
TestFuncDescriptor
>
tests
;
//< all tests
int
totalTests
;
//< number of tests
int
currentTest
;
//< current processing test in the run
int
currentStep
;
//< current processing step in the run
int
failedSteps
;
//< number of failed step in the current test
int
failedTests
;
//< number of failed tests
protected:
/** Constructor */
FUTester
(){
totalTests
=
0
;
}
/** Callback before processing test */
virtual
void
Before
(){}
/** Callback after processing test */
virtual
void
After
(){}
/** Callback before each unit test */
virtual
void
PreTest
(){}
/** Callback after each unit test */
virtual
void
PostTest
(){}
/**
* This function has to add tests
/** Constructor */
FUTester
(){
totalTests
=
0
;
}
/** Callback before processing test */
virtual
void
Before
(){}
/** Callback after processing test */
virtual
void
After
(){}
/** Callback before each unit test */
virtual
void
PreTest
(){}
/** Callback after each unit test */
virtual
void
PostTest
(){}
/**
* This function has to add tests
* <code> AddTest(&MyTest::TestOne); </code>
*/
virtual
void
SetTests
()
=
0
;
/**
* Add a test without giving a name
* @param inFunc test function address
*/
void
AddTest
(
TestFunc
inFunc
){
char
buff
[
256
];
sprintf
(
buff
,
"Unnamed Test number %d"
,
totalTests
+
1
);
AddTest
(
inFunc
,
buff
);
}
/**
* Add a test with a name
* @param inFunc test function address
* @param inFuncName function name
*/
void
AddTest
(
TestFunc
inFunc
,
const
std
::
string
&
inFuncName
){
++
totalTests
;
TestFuncDescriptor
desc
;
desc
.
func
=
inFunc
;
desc
.
name
=
inFuncName
;
tests
.
push_back
(
desc
);
}
/**
* To print a message manually in the test
* @param value a object that ostream can work on
*/
template
<
class
Output
>
void
Print
(
const
Output
&
value
){
std
::
cout
<<
"--- Output from program : "
<<
value
<<
"
\n
"
;
}
/**
* To test
* @param result the test result
* if result is false test failed
*/
void
uassert
(
const
bool
result
){
++
currentStep
;
if
(
!
result
){
std
::
cout
<<
">> Step "
<<
currentStep
<<
" Failed
\n
"
;
++
failedSteps
;
}
}
/**
* To test equality
* @param v1 value one
* @param v2 value 2
* if v1 is not equal v2 test failed
*/
template
<
class
T
>
void
equal
(
const
T
&
v1
,
const
T
&
v2
){
uassert
(
v1
==
v2
);
}
/**
* To test equality
* @param v1 value one
* @param v2 value 2
* if v1 is equal v2 test failed
*/
template
<
class
T
>
void
different
(
const
T
&
v1
,
const
T
&
v2
){
uassert
(
v1
!=
v2
);
}
*/
virtual
void
SetTests
()
=
0
;
/**
* Add a test without giving a name
* @param inFunc test function address
*/
void
AddTest
(
TestFunc
inFunc
){
char
buff
[
256
];
sprintf
(
buff
,
"Unnamed Test number %d"
,
totalTests
+
1
);
AddTest
(
inFunc
,
buff
);
}
/**
* Add a test with a name
* @param inFunc test function address
* @param inFuncName function name
*/
void
AddTest
(
TestFunc
inFunc
,
const
std
::
string
&
inFuncName
){
++
totalTests
;
TestFuncDescriptor
desc
;
desc
.
func
=
inFunc
;
desc
.
name
=
inFuncName
;
tests
.
push_back
(
desc
);
}
/**
* To print a message manually in the test
* @param value a object that ostream can work on
*/
template
<
class
Output
>
void
Print
(
const
Output
&
value
){
std
::
cout
<<
"--- Output from program : "
<<
value
<<
"
\n
"
;
}
/**
* To test
* @param result the test result
* if result is false test failed
*/
void
uassert
(
const
bool
result
){
++
currentStep
;
if
(
!
result
){
std
::
cout
<<
">> Step "
<<
currentStep
<<
" Failed
\n
"
;
++
failedSteps
;
}
}
/**
* To test equality
* @param v1 value one
* @param v2 value 2
* if v1 is not equal v2 test failed
*/
template
<
class
T
>
void
equal
(
const
T
&
v1
,
const
T
&
v2
){
uassert
(
v1
==
v2
);
}
/**
* To test equality
* @param v1 value one
* @param v2 value 2
* if v1 is equal v2 test failed
*/
template
<
class
T
>
void
different
(
const
T
&
v1
,
const
T
&
v2
){
uassert
(
v1
!=
v2
);
}
public
:
/**
* Processing the test
/**
* Processing the test
* return application exit code (= nb of errors)
*/
int
Run
(){
tests
.
clear
();
// register tests
SetTests
();
TestClass
*
const
toTest
=
static_cast
<
TestClass
*>
(
this
);
currentTest
=
0
;
failedTests
=
0
;
Before
();
// for each tests
const
typename
std
::
list
<
TestFuncDescriptor
>::
const_iterator
end
=
tests
.
end
();
for
(
typename
std
::
list
<
TestFuncDescriptor
>::
iterator
iter
=
tests
.
begin
()
;
iter
!=
end
;
++
iter
){
currentStep
=
0
;
failedSteps
=
0
;
std
::
cout
<<
"[Start] "
<<
(
*
iter
).
name
<<
"
\n
"
;
PreTest
();
TestFunc
ff
=
(
*
iter
).
func
;
(
toTest
->*
ff
)();
PostTest
();
if
(
failedSteps
){
std
::
cout
<<
"[Finished] FAILED ("
<<
failedSteps
<<
"/"
<<
currentStep
<<
" steps failed)
\n
"
;
++
failedTests
;
}
else
{
std
::
cout
<<
"[Finished] PASSED ("
<<
currentStep
<<
" steps)
\n
"
;
}
++
currentTest
;
}
After
();
std
::
cout
<<
"Test is over, "
<<
(
totalTests
-
failedTests
)
<<
" Passed, "
<<
failedTests
<<
" Failed
\n
"
;
return
failedTests
;
}
*/
int
Run
(){
tests
.
clear
();
// register tests
SetTests
();
TestClass
*
const
toTest
=
static_cast
<
TestClass
*>
(
this
);
currentTest
=
0
;
failedTests
=
0
;
Before
();
// for each tests
const
typename
std
::
list
<
TestFuncDescriptor
>::
const_iterator
end
=
tests
.
end
();
for
(
typename
std
::
list
<
TestFuncDescriptor
>::
iterator
iter
=
tests
.
begin
()
;
iter
!=
end
;
++
iter
){
currentStep
=
0
;
failedSteps
=
0
;
std
::
cout
<<
"[Start] "
<<
(
*
iter
).
name
<<
"
\n
"
;
PreTest
();
TestFunc
ff
=
(
*
iter
).
func
;
(
toTest
->*
ff
)();
PostTest
();
if
(
failedSteps
){
std
::
cout
<<
"[Finished] FAILED ("
<<
failedSteps
<<
"/"
<<
currentStep
<<
" steps failed)
\n
"
;
++
failedTests
;
}
else
{
std
::
cout
<<
"[Finished] PASSED ("
<<
currentStep
<<
" steps)
\n
"
;
}
++
currentTest
;
}
After
();
std
::
cout
<<
"Test is over, "
<<
(
totalTests
-
failedTests
)
<<
" Passed, "
<<
failedTests
<<
" Failed
\n
"
;
return
failedTests
;
}
};
...
...
@@ -210,33 +211,33 @@ public :
#include "../Src/Utils/FMpi.hpp"
#define TestClassMpi(X) \
int main(int argc, char** argv){ \
int main(int argc, char** argv){ \
X Controller(argc,argv); \
return Controller.Run(); \
} \
} \
template
<
class
TestClass
>
class
FUTesterMpi
:
public
FUTester
<
TestClass
>
{
protected:
FMpi
app
;
//Constructor with params to initialize FMpi
FUTesterMpi
(
int
argc
,
char
**
argv
)
:
app
(
argc
,
argv
){
}
FMpi
app
;
//Constructor with params to initialize FMpi
FUTesterMpi
(
int
argc
,
char
**
argv
)
:
app
(
argc
,
argv
){
}
/**
/**
* To print a message manually in the test
* @param value a object that ostream can work on
*/
template
<
class
Output
>
void
Print
(
const
Output
&
value
){
if
(
app
.
global
().
processId
()
==
0
){
std
::
cout
<<
"--- Output from program : "
<<
value
<<
"
\n
"
;
template
<
class
Output
>
void
Print
(
const
Output
&
value
){
if
(
app
.
global
().
processId
()
==
0
){
std
::
cout
<<
"--- Output from program : "
<<
value
<<
"
\n
"
;
}
}
}
};
#endif
#endif
UTests/utestMpiQs.cpp
View file @
0dfdbfdf
// ===================================================================================
// Copyright ScalFmm 2011 INRIA, Olivier Coulaud, Bérenger Bramas, Matthias Messner
// olivier.coulaud@inria.fr, berenger.bramas@inria.fr
// This software is a computer program whose purpose is to compute the FMM.
//
// This software is governed by the CeCILL-C and LGPL licenses and
// abiding by the rules of distribution of free software.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public and CeCILL-C Licenses for more details.
// "http://www.cecill.info".
// "http://www.gnu.org/licenses".
// ===================================================================================
#ifndef UTESTMPIQS_HPP
#define UTESTMPIQS_HPP
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment