diff --git a/branches/ParadisEO-GPU/tutoriel/QAP/CMakeLists.txt b/branches/ParadisEO-GPU/tutoriel/QAP/CMakeLists.txt index b721de36c..8cdf70b0f 100644 --- a/branches/ParadisEO-GPU/tutoriel/QAP/CMakeLists.txt +++ b/branches/ParadisEO-GPU/tutoriel/QAP/CMakeLists.txt @@ -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(CutestSimpleTS_GPU testSimpleTS.cu) +#CUDA_ADD_EXECUTABLE(CutestSimpleTS_GPU testSimpleTS.cu) 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}) diff --git a/branches/ParadisEO-GPU/tutoriel/QAP/testSimpleHC.cu b/branches/ParadisEO-GPU/tutoriel/QAP/testSimpleHC.cu index 0e78aed08..10926c33e 100644 --- a/branches/ParadisEO-GPU/tutoriel/QAP/testSimpleHC.cu +++ b/branches/ParadisEO-GPU/tutoriel/QAP/testSimpleHC.cu @@ -32,13 +32,15 @@ Contact: paradiseo-help@lists.gforge.inria.fr */ -//Init the number of threads per block -#define BLOCK_SIZE 256 + #include #include #include using namespace std; +//Include GPU Config File +#include "moGPUConfig.h" + __device__ int * dev_a; __device__ int * dev_b; @@ -48,18 +50,20 @@ __device__ int * dev_b; // Fitness function #include // Cuda Fitness function -#include +#include #include //Specific data to QAP problem #include // QAP solution -#include -// One Max neighbor -#include +#include +// Swap neighbor +#include //To compute execution time -#include -// One Max ordered neighborhood -#include +#include +//Utils to compute size Mapping of x-change position +#include +// Use an ordered neighborhood without mapping, with local copy of solution +#include // The Solution and neighbor comparator #include #include @@ -71,12 +75,11 @@ __device__ int * dev_b; #include // The simple HC algorithm explorer #include -#include -typedef moCudaIntVector solution; -typedef moKswapNeighbor Neighbor; -typedef moCudaKswapNeighborhood Neighborhood; +typedef moGPUPermutationVector solution; +typedef moGPUXSwapNeighbor Neighbor; +typedef moGPUXChangeNeighborhoodByCpy Neighborhood; int main(int argc, char **argv) @@ -103,14 +106,14 @@ int main(int argc, char **argv) unsigned seed = seedParam.value(); // description of genotype - eoValueParam vecSizeParam(6, "vecSize", "Genotype size", 'V'); + eoValueParam vecSizeParam(20, "vecSize", "Genotype size", 'V'); parser.processParam( vecSizeParam, "Representation" ); unsigned vecSize = vecSizeParam.value(); - // Swap number - eoValueParam KSwapParam(1, "KSwap", "swap number", 'N'); - parser.processParam(KSwapParam, "KSwap" ); - unsigned KSwap = KSwapParam.value(); + //Number of position to change + eoValueParam nbPosParam(1, "nbPos", "X Change", 'N'); + parser.processParam( nbPosParam, "Exchange" ); + unsigned nbPos = nbPosParam.value(); // the name of the "status" file where all actual parameter values will be saved 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, // you'll aways get the same result, NOT a random run rng.reseed(seed); - srand(time(NULL)); /* ========================================================= * @@ -148,13 +150,13 @@ int main(int argc, char **argv) vecSize=_data.sizeData; /* ========================================================= * - * Initilisation of the solution + * Initilisation of the solution and specific data * * ========================================================= */ solution sol(vecSize); - _data.cudaObject.memCopyGlobalVariable(dev_a,_data.a_d); - _data.cudaObject.memCopyGlobalVariable(dev_b,_data.b_d); + _data.GPUObject.memCopyGlobalVariable(dev_a,_data.a_d); + _data.GPUObject.memCopyGlobalVariable(dev_b,_data.b_d); /* ========================================================= * @@ -162,9 +164,9 @@ int main(int argc, char **argv) * * ========================================================= */ QAPEval eval(_data); - unsigned long int sizeMap=sizeMapping(vecSize,KSwap); + unsigned long int sizeMap=sizeMapping(vecSize,NB_POS); QAPIncrEval incr_eval; - moCudaKswapEval > cueval(sizeMap,incr_eval); + moGPUMappingEvalByCpy > 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; // Create timer for timing CUDA calculation - moCudaTimer timer; + moGPUTimer timer; timer.start(); localSearch(sol); std::cout << "final: " << sol << std::endl; timer.stop(); - printf("CUDA execution time = %f ms\n",timer.getTime()); + printf("Execution time = %f ms\n",timer.getTime()); timer.deleteTimer(); - _data.cudaObject.free(dev_a); - _data.cudaObject.free(dev_b); + _data.GPUObject.free(dev_a); + _data.GPUObject.free(dev_b); return 0; -} \ No newline at end of file +}