Test & Update for new version

git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@2678 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
boufaras 2012-01-24 01:35:56 +00:00
commit f2b13bc8ba
18 changed files with 71 additions and 187 deletions

View file

@ -1,6 +1,6 @@
/*
<t-moGPUTimer.cu>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2012
Karima Boufaras, Thé Van LUONG

View file

@ -1,8 +1,8 @@
/*
<moTestClass.h>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2012
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
Karima Boufaras, Thé van Luong
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can use,

View file

@ -1,6 +1,6 @@
/*
<t-moGPUBitNeighbor.cu>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2012
Karima Boufaras, Thé Van LUONG
@ -90,7 +90,7 @@ int main() {
assert(test1.className()=="moGPUBitNeighbor");
std::cout << "[t-moCudaBitNeighbor] => OK" << std::endl;
std::cout << "[t-moGPUBitNeighbor] => OK" << std::endl;
return EXIT_SUCCESS;
}

View file

@ -1,6 +1,6 @@
/*
<t-moGPUBitVector.cu>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2012
Karima Boufaras, Thé Van LUONG
@ -36,7 +36,7 @@
#include <cassert>
#include <iostream>
#include <GPUType/moGPUBitVector.h>
#include <problems/eval/EvalOneMax.h>
#include <problems/eval/moGPUEvalOneMax.h>
#include <eo>
typedef moGPUBitVector<eoMaximizingFitness> Solution;
@ -47,7 +47,7 @@ int main() {
std::cout << "[t-moGPUBitVector] => START" << std::endl;
EvalOneMax<Solution> eval;
moGPUEvalOneMax<Solution> eval;
//test default constructor
Solution _sol;
@ -75,7 +75,7 @@ int main() {
assert(sol.fitness()==sum);
//test size getter
assert(_sol.size()==0);
assert(_sol.size()==5);
assert(sol1.size()==5);
//test size setter

View file

@ -1,6 +1,6 @@
/*
<t-moGPUEvalOneMax.cu>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2012
Karima Boufaras, Thé Van LUONG
@ -47,7 +47,7 @@ int main() {
Solution sol(5);
moGPuEvalOneMax<Solution> eval;
moGPUEvalOneMax<Solution> eval;
int sum=0;
eval(sol);

View file

@ -1,6 +1,6 @@
/*
<t-moGPUIntVector.cu>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2012
Karima Boufaras, Thé Van LUONG
@ -54,10 +54,10 @@ int main() {
Solution sol2(3);
//test copy constructor
sol1.fitness(500);
sol1.fitness(50);
Solution sol(sol1);
assert(sol.size()==5);
assert(sol.fitness()==500);
assert(sol.fitness()==50);
for(int i=0;i<5;i++)
assert(sol[i]==sol1[i]);
@ -82,10 +82,10 @@ int main() {
}
//test assignement operator
sol2.fitness(200);
sol2.fitness(20);
sol1=sol2;
assert(sol1.size()==3);
assert(sol1.fitness()==200);
assert(sol1.fitness()==20);
for(int i=0;i<3;i++)
assert(sol1[i]==sol2[i]);

View file

@ -1,6 +1,6 @@
/*
<t-moGPUMemory.cu>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2012
Karima Boufaras, Thé Van LUONG

View file

@ -1,8 +1,8 @@
/*
<t-moGPUNeighborhoodSizeUtils.cpp>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2012
Boufaras Karima, Thé Van Luong
Karima Boufaras, Thé Van Luong
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can ue,

View file

@ -1,6 +1,6 @@
/*
<t-moGPUObject.cu>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2012
Karima Boufaras, Thé Van LUONG
@ -41,10 +41,14 @@
__device__ int * dev_data;
//kernel to launch to test GPU global variable
__global__ void testKernel(int * _data,unsigned _size){
// The thread identifier within a grid block's
int id = blockIdx.x * blockDim.x + threadIdx.x;
if(id<_size)
_data[id]=2*dev_data[id];
}

View file

@ -1,6 +1,6 @@
/*
<t-OneMaxIncrEval.cu>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2012
Karima Boufaras, Thé Van LUONG
@ -37,9 +37,10 @@
#include <iostream>
#include <neighborhood/moGPUBitNeighbor.h>
#include <GPUType/moGPUBitVector.h>
#include <problems/eval/EvalOneMax.h>
#include <problems/eval/OneMaxIncrEval.h>
#include <problems/eval/moGPUEvalOneMax.h>
#include <problems/eval/moGPUOneMaxIncrEval.h>
#define NB_POS 1
typedef moGPUBitVector<eoMaximizingFitness> Solution;
typedef moGPUBitNeighbor <Solution,eoMaximizingFitness> Neighbor;
@ -47,12 +48,12 @@ typedef moGPUBitNeighbor <Solution,eoMaximizingFitness> Neighbor;
int main() {
std::cout << "[t-OneMaxIncrEval] => START" << std::endl;
std::cout << "[t-moGPUOneMaxIncrEval] => START" << std::endl;
Solution sol(5);
EvalOneMax<Solution> eval;
OneMaxIncrEval<Neighbor> incr_eval;
moGPUEvalOneMax<Solution> eval;
moGPUOneMaxIncrEval<Neighbor> incr_eval;
int sum=0;
int fitness=0;
@ -66,18 +67,17 @@ int main() {
eval(sol);
assert((int)(sol.fitness())==0);
sol[0]=1;
fitness=incr_eval(sol,fitness,0);
sol[0]=1;
eval(sol);
assert((int)(fitness)==1);
assert((int)(sol.fitness())==1);
fitness=incr_eval(sol,fitness,0);
sol[0]=0;
eval(sol);
assert((int)(sol.fitness())==0);
sol[2]=1;
fitness=incr_eval(sol,fitness,2);
assert((int)(fitness)==2);
assert((int)(sol.fitness())==2);
std::cout << "[t-OneMaxIncrEval] => OK" << std::endl;
std::cout << "[t-moGPUOneMaxIncrEval] => OK" << std::endl;
return EXIT_SUCCESS;
}

View file

@ -1,6 +1,6 @@
/*
<t-moGPUPermutationVector.cu>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2012
Karima Boufaras, Thé Van LUONG
@ -54,19 +54,18 @@ int main() {
Solution sol2(3);
//test copy constructor
sol1.fitness(200);
sol1.fitness(20);
Solution sol(sol1);
assert(sol.size()==5);
assert(sol.fitness()==200);
assert(sol.fitness()==20);
for(int i=0;i<5;i++)
assert(sol[i]==sol1[i]);
//test discret vector (create) & getter
//test discret vector create & getter
for(int i=0;i<5;i++)
assert((sol1[i]>=0)||(sol1[i]<5));
//test size getter
assert(_sol.size()==0);
assert(sol1.size()==5);
assert(sol2.size()==3);
@ -78,12 +77,12 @@ int main() {
//test discret vector
for(int i=0;i<3;i++)
assert((sol2[i]>=0)||(sol2[i]<3));
sol2.fitness(300);
sol2.fitness(30);
//test assignement operator
sol1=sol2;
assert(sol1.size()==3);
assert(sol1.fitness()==300);
assert(sol1.fitness()==30);
for(int i=0;i<3;i++)
assert(sol1[i]==sol2[i]);

View file

@ -1,6 +1,6 @@
/*
<t-moGPURealVector.cu>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2012
Karima Boufaras, Thé Van LUONG
@ -55,18 +55,19 @@ int main() {
Solution sol2(3);
//test copy constructor
sol1.fitness(100);
sol1.fitness(10);
Solution sol(sol1);
assert(sol.size()==5);
assert(sol.fitness()==100);
assert(sol.fitness()==10);
for(int i=0;i<5;i++)
assert(sol[i]==sol1[i]);
//test Real vector (create)& getter
float tmp;
for(int i=0;i<5;i++){
tmp=1/sol1[i];
assert(abs(tmp)>0);
int tmp,tmp1;
tmp=(1/(sol1[0]+1))*10;
tmp1=(int)(1/(sol1[0]+));
assert(tmp1>tmp);
}
//test size getter
@ -80,10 +81,10 @@ int main() {
assert(sol[i]==sol1[i]);
//test assignement operator
sol2.fitness(200);
sol2.fitness(20);
sol1=sol2;
assert(sol1.size()==3);
assert(sol1.fitness()==200);
assert(sol1.fitness()==20);
for(int i=0;i<3;i++)
assert(sol1[i]==sol2[i]);

View file

@ -1,6 +1,6 @@
/*
<t-moGPUXBitFlippingNeighbor.cu>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2012
Karima Boufaras, Thé Van LUONG

View file

@ -1,8 +1,8 @@
/*
<t-moGPUXChangeNeighbor.cpp>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
<t-moGPUXChangeNeighbor.cu>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2012
Boufaras Karima, Thé Van Luong
Karima Boufaras, Thé Van Luong
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can ue,

View file

@ -1,6 +1,6 @@
/*
<t-moGPUXChangeNeighborhood.cpp>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
<t-moGPUXChange.cu>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2012
Karima Boufaras, Thé Van LUONG
@ -36,18 +36,18 @@
#include <cassert>
#include <iostream>
#include <eoInt.h>
#include <neighborhood/moGPUXSwapNeighbor.h>
#include <neighborhood/moXGPUChangeNeighborhood.h>
#include <neighborhood/moGPUXSwapN.h>
#include <neighborhood/moGPUXChange.h>
#include <neighborhood/moGPUNeighborhoodSizeUtils.h>
#include <eo>
typedef eoInt<eoMaximizingFitness> Solution;
typedef moXSwapNeighbor<Solution> Neighbor;
typedef moXChangeNeighborhood<Neighbor> Neighborhood;
typedef moGPUXSwapN<Solution> Neighbor;
typedef moGPUXChange<Neighbor> Neighborhood;
int main() {
std::cout << "[t-moGPUXChangeNeighborhood] => START" << std::endl;
std::cout << "[t-moGPUXChange] => START" << std::endl;
//test factorial
assert(factorial(10) == 3628800);
@ -171,7 +171,7 @@ int main() {
delete[] (second);
delete[] (third);
delete[] (forth);
std::cout << "[t-moGPUXChangeNeighborhood] => OK" << std::endl;
std::cout << "[t-moGPUXChange] => OK" << std::endl;
return EXIT_SUCCESS;
}

View file

@ -1,6 +1,6 @@
/*
<t-moGPUXSwapNeighbor.cpp>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
<t-moGPUXSwapNeighbor.cu>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2012
Karima Boufaras, Thé Van LUONG

View file

@ -1,6 +1,6 @@
/*
<t-moGPUXBitFlippingNeighbor.cpp>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
<t-moGPUXBitFlippingN.cu>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2012
Karima Boufaras, Thé Van LUONG
@ -35,7 +35,7 @@
#include <cstdlib>
#include <cassert>
#include <iostream>
#include <neighborhood/moGPUXBitFlippingNeighbor.h>
#include <neighborhood/moGPUXBitFlippingN.h>
#include <eo>
#include <ga/eoBit.h>

View file

@ -1,120 +0,0 @@
/*
<t-moGPUXSwapNeighbor.cpp>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Karima Boufaras, Thé Van LUONG
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can use,
modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
As a counterpart to the access to the source code and rights to copy,
modify and redistribute granted by the license, users are provided only
with a limited warranty and the software's author, the holder of the
economic rights, and the successive licensors have only limited liability.
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#include <cstdlib>
#include <cassert>
#include <iostream>
#include <eoInt.h>
#include <neighborhood/moGPUXSwapNeighbor.h>
#include <eo>
typedef eoInt<eoMaximizingFitness> Solution;
typedef moGPUXSwapNeighbor<Solution> Neighbor;
int main() {
std::cout << "[t-moGPUXSwapNeighbor] => START" << std::endl;
Solution sol1(5);
for (int i = 4; i >=0; i--)
sol1[4-i] = i;
//test constructor
Neighbor neighbor(2);
assert(neighbor.index() == 0);
assert(neighbor.getXChange() == 2);
//test setter of one index
for (unsigned int i = 0; i < neighbor.getXChange(); i++)
neighbor.setIndice(i, i);
//test getter of one index
for (unsigned int i = 0; i < neighbor.getXChange(); i++)
assert(neighbor.getIndice(i) == i);
//test move
neighbor.move(sol1);
assert(sol1[neighbor.getIndice(0)] == 3);
assert(sol1[neighbor.getIndice(1)] == 4);
//test moveBack
neighbor.moveBack(sol1);
assert(sol1[neighbor.getIndice(0)] == 4);
assert(sol1[neighbor.getIndice(1)] == 3);
//test set & get indice
neighbor.setIndice(0, 1);
neighbor.setIndice(1, 2);
assert(neighbor.getIndice(0) == 1);
assert(neighbor.getIndice(1) == 2);
//test move
neighbor.move(sol1);
assert(sol1[neighbor.getIndice(0)] == 2);
assert(sol1[neighbor.getIndice(1)] == 3);
//test move back
neighbor.moveBack(sol1);
assert(sol1[neighbor.getIndice(0)] == 3);
assert(sol1[neighbor.getIndice(1)] == 2);
Neighbor neighbor2(3);
//test setter of one index
neighbor2.setIndice(0, 0);
neighbor2.setIndice(1, 1);
neighbor2.setIndice(2, 2);
//test getter of one index
assert(neighbor2.getIndice(0) == 0);
assert(neighbor2.getIndice(1) == 1);
assert(neighbor2.getIndice(2) == 2);
//test move
neighbor2.move(sol1);
assert(sol1[neighbor2.getIndice(0)] == 3);
assert(sol1[neighbor2.getIndice(1)] == 2);
assert(sol1[neighbor2.getIndice(2)] == 4);
//test moveBack
neighbor2.moveBack(sol1);
assert(sol1[neighbor2.getIndice(0)] == 4);
assert(sol1[neighbor2.getIndice(1)] == 3);
assert(sol1[neighbor2.getIndice(2)] == 2);
std::cout << "[t-moGPUXSwapNeighbor] => OK" << std::endl;
return EXIT_SUCCESS;
}