updated
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@2270 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
99e6fc716e
commit
51eb396ade
2 changed files with 34 additions and 32 deletions
|
|
@ -42,9 +42,9 @@ LINK_DIRECTORIES(${PARADISEO_EO_BIN_DIR}/lib ${NVIDIA_LIB_DIR} ${CUDA_LIB_DIR}
|
||||||
######################################################################################
|
######################################################################################
|
||||||
|
|
||||||
CUDA_ADD_EXECUTABLE(CutestSimpleHC_GPU testSimpleHC.cu)
|
CUDA_ADD_EXECUTABLE(CutestSimpleHC_GPU testSimpleHC.cu)
|
||||||
CUDA_ADD_EXECUTABLE(CutestSimpleTS_GPU testSimpleTS.cu)
|
#CUDA_ADD_EXECUTABLE(CutestSimpleTS_GPU testSimpleTS.cu)
|
||||||
|
|
||||||
TARGET_LINK_LIBRARIES(CutestSimpleHC_GPU eoutils ga eo ${cutil})
|
TARGET_LINK_LIBRARIES(CutestSimpleHC_GPU eoutils ga eo ${cutil})
|
||||||
TARGET_LINK_LIBRARIES(CutestSimpleTS_GPU eoutils ga eo ${cutil})
|
#TARGET_LINK_LIBRARIES(CutestSimpleTS_GPU eoutils ga eo ${cutil})
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,13 +32,15 @@
|
||||||
Contact: paradiseo-help@lists.gforge.inria.fr
|
Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//Init the number of threads per block
|
|
||||||
#define BLOCK_SIZE 256
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
//Include GPU Config File
|
||||||
|
#include "moGPUConfig.h"
|
||||||
|
|
||||||
__device__ int * dev_a;
|
__device__ int * dev_a;
|
||||||
__device__ int * dev_b;
|
__device__ int * dev_b;
|
||||||
|
|
||||||
|
|
@ -48,18 +50,20 @@ __device__ int * dev_b;
|
||||||
// Fitness function
|
// Fitness function
|
||||||
#include <problems/eval/QAPEval.h>
|
#include <problems/eval/QAPEval.h>
|
||||||
// Cuda Fitness function
|
// Cuda Fitness function
|
||||||
#include <eval/moCudaKswapEval.h>
|
#include <eval/moGPUMappingEvalByCpy.h>
|
||||||
#include <problems/eval/QAPIncrEval.h>
|
#include <problems/eval/QAPIncrEval.h>
|
||||||
//Specific data to QAP problem
|
//Specific data to QAP problem
|
||||||
#include <problems/data/QAPData.h>
|
#include <problems/data/QAPData.h>
|
||||||
// QAP solution
|
// QAP solution
|
||||||
#include <cudaType/moCudaIntVector.h>
|
#include <GPUType/moGPUPermutationVector.h>
|
||||||
// One Max neighbor
|
// Swap neighbor
|
||||||
#include <neighborhood/moKswapNeighbor.h>
|
#include <neighborhood/moGPUXSwapNeighbor.h>
|
||||||
//To compute execution time
|
//To compute execution time
|
||||||
#include <performance/moCudaTimer.h>
|
#include <performance/moGPUTimer.h>
|
||||||
// One Max ordered neighborhood
|
//Utils to compute size Mapping of x-change position
|
||||||
#include <neighborhood/moCudaKswapNeighborhood.h>
|
#include <neighborhood/moNeighborhoodSizeUtils.h>
|
||||||
|
// Use an ordered neighborhood without mapping, with local copy of solution
|
||||||
|
#include <neighborhood/moGPUXChangeNeighborhoodByCpy.h>
|
||||||
// The Solution and neighbor comparator
|
// The Solution and neighbor comparator
|
||||||
#include <comparator/moNeighborComparator.h>
|
#include <comparator/moNeighborComparator.h>
|
||||||
#include <comparator/moSolNeighborComparator.h>
|
#include <comparator/moSolNeighborComparator.h>
|
||||||
|
|
@ -71,12 +75,11 @@ __device__ int * dev_b;
|
||||||
#include <algo/moSimpleHC.h>
|
#include <algo/moSimpleHC.h>
|
||||||
// The simple HC algorithm explorer
|
// The simple HC algorithm explorer
|
||||||
#include <explorer/moSimpleHCexplorer.h>
|
#include <explorer/moSimpleHCexplorer.h>
|
||||||
#include <time.h>
|
|
||||||
|
|
||||||
|
|
||||||
typedef moCudaIntVector<eoMinimizingFitness> solution;
|
typedef moGPUPermutationVector<eoMinimizingFitness> solution;
|
||||||
typedef moKswapNeighbor<solution> Neighbor;
|
typedef moGPUXSwapNeighbor<eoMinimizingFitness> Neighbor;
|
||||||
typedef moCudaKswapNeighborhood<Neighbor> Neighborhood;
|
typedef moGPUXChangeNeighborhoodByCpy<Neighbor> Neighborhood;
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
|
|
@ -103,14 +106,14 @@ int main(int argc, char **argv)
|
||||||
unsigned seed = seedParam.value();
|
unsigned seed = seedParam.value();
|
||||||
|
|
||||||
// description of genotype
|
// description of genotype
|
||||||
eoValueParam<unsigned int> vecSizeParam(6, "vecSize", "Genotype size", 'V');
|
eoValueParam<unsigned int> vecSizeParam(20, "vecSize", "Genotype size", 'V');
|
||||||
parser.processParam( vecSizeParam, "Representation" );
|
parser.processParam( vecSizeParam, "Representation" );
|
||||||
unsigned vecSize = vecSizeParam.value();
|
unsigned vecSize = vecSizeParam.value();
|
||||||
|
|
||||||
// Swap number
|
//Number of position to change
|
||||||
eoValueParam<unsigned int> KSwapParam(1, "KSwap", "swap number", 'N');
|
eoValueParam<unsigned int> nbPosParam(1, "nbPos", "X Change", 'N');
|
||||||
parser.processParam(KSwapParam, "KSwap" );
|
parser.processParam( nbPosParam, "Exchange" );
|
||||||
unsigned KSwap = KSwapParam.value();
|
unsigned nbPos = nbPosParam.value();
|
||||||
|
|
||||||
// the name of the "status" file where all actual parameter values will be saved
|
// the name of the "status" file where all actual parameter values will be saved
|
||||||
string str_status = parser.ProgramName() + ".status"; // default value
|
string str_status = parser.ProgramName() + ".status"; // default value
|
||||||
|
|
@ -136,7 +139,6 @@ int main(int argc, char **argv)
|
||||||
//reproducible random seed: if you don't change SEED above,
|
//reproducible random seed: if you don't change SEED above,
|
||||||
// you'll aways get the same result, NOT a random run
|
// you'll aways get the same result, NOT a random run
|
||||||
rng.reseed(seed);
|
rng.reseed(seed);
|
||||||
srand(time(NULL));
|
|
||||||
|
|
||||||
/* =========================================================
|
/* =========================================================
|
||||||
*
|
*
|
||||||
|
|
@ -148,13 +150,13 @@ int main(int argc, char **argv)
|
||||||
vecSize=_data.sizeData;
|
vecSize=_data.sizeData;
|
||||||
/* =========================================================
|
/* =========================================================
|
||||||
*
|
*
|
||||||
* Initilisation of the solution
|
* Initilisation of the solution and specific data
|
||||||
*
|
*
|
||||||
* ========================================================= */
|
* ========================================================= */
|
||||||
|
|
||||||
solution sol(vecSize);
|
solution sol(vecSize);
|
||||||
_data.cudaObject.memCopyGlobalVariable(dev_a,_data.a_d);
|
_data.GPUObject.memCopyGlobalVariable(dev_a,_data.a_d);
|
||||||
_data.cudaObject.memCopyGlobalVariable(dev_b,_data.b_d);
|
_data.GPUObject.memCopyGlobalVariable(dev_b,_data.b_d);
|
||||||
|
|
||||||
/* =========================================================
|
/* =========================================================
|
||||||
*
|
*
|
||||||
|
|
@ -162,9 +164,9 @@ int main(int argc, char **argv)
|
||||||
*
|
*
|
||||||
* ========================================================= */
|
* ========================================================= */
|
||||||
QAPEval<solution> eval(_data);
|
QAPEval<solution> eval(_data);
|
||||||
unsigned long int sizeMap=sizeMapping(vecSize,KSwap);
|
unsigned long int sizeMap=sizeMapping(vecSize,NB_POS);
|
||||||
QAPIncrEval<Neighbor> incr_eval;
|
QAPIncrEval<Neighbor> incr_eval;
|
||||||
moCudaKswapEval<Neighbor,QAPIncrEval<Neighbor> > cueval(sizeMap,incr_eval);
|
moGPUMappingEvalByCpy<Neighbor,QAPIncrEval<Neighbor> > cueval(sizeMap,incr_eval);
|
||||||
|
|
||||||
/* =========================================================
|
/* =========================================================
|
||||||
*
|
*
|
||||||
|
|
@ -181,7 +183,7 @@ int main(int argc, char **argv)
|
||||||
*
|
*
|
||||||
* ========================================================= */
|
* ========================================================= */
|
||||||
|
|
||||||
Neighborhood neighborhood(vecSize,KSwap,cueval);
|
Neighborhood neighborhood(sizeMap,NB_POS,cueval);
|
||||||
|
|
||||||
/* =========================================================
|
/* =========================================================
|
||||||
*
|
*
|
||||||
|
|
@ -222,16 +224,16 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
std::cout << "initial: " << sol<< std::endl;
|
std::cout << "initial: " << sol<< std::endl;
|
||||||
// Create timer for timing CUDA calculation
|
// Create timer for timing CUDA calculation
|
||||||
moCudaTimer timer;
|
moGPUTimer timer;
|
||||||
timer.start();
|
timer.start();
|
||||||
localSearch(sol);
|
localSearch(sol);
|
||||||
std::cout << "final: " << sol << std::endl;
|
std::cout << "final: " << sol << std::endl;
|
||||||
timer.stop();
|
timer.stop();
|
||||||
printf("CUDA execution time = %f ms\n",timer.getTime());
|
printf("Execution time = %f ms\n",timer.getTime());
|
||||||
timer.deleteTimer();
|
timer.deleteTimer();
|
||||||
|
|
||||||
_data.cudaObject.free(dev_a);
|
_data.GPUObject.free(dev_a);
|
||||||
_data.cudaObject.free(dev_b);
|
_data.GPUObject.free(dev_b);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue