diff --git a/branches/ParadisEO-GPU/tutoriel/PPP_GPU/application/moGPUConfig.h b/branches/ParadisEO-GPU/tutoriel/PPP_GPU/application/moGPUConfig.h new file mode 100644 index 000000000..55aa676d7 --- /dev/null +++ b/branches/ParadisEO-GPU/tutoriel/PPP_GPU/application/moGPUConfig.h @@ -0,0 +1,56 @@ +/* + + 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 + */ + +#ifndef __moGPUConfig_H +#define __moGPUConfig_H + +#define BLOCK_SIZE 8 +#ifndef NB_POS +#define NB_POS 3 +#endif +#ifndef SIZE +#define SIZE 73 + +#define Nd 73 +#define Md 73 +#define ca 30 +#define cb 1 + +#endif +#endif + + + + + diff --git a/branches/ParadisEO-GPU/tutoriel/PPP_GPU/application/testSimpleTS_PPP.cu b/branches/ParadisEO-GPU/tutoriel/PPP_GPU/application/testSimpleTS_PPP.cu index 141cf3fdd..ff991a6f0 100644 --- a/branches/ParadisEO-GPU/tutoriel/PPP_GPU/application/testSimpleTS_PPP.cu +++ b/branches/ParadisEO-GPU/tutoriel/PPP_GPU/application/testSimpleTS_PPP.cu @@ -32,12 +32,7 @@ Contact: paradiseo-help@lists.gforge.inria.fr */ -//Init the number of threads per block -#define BLOCK_SIZE 256 -#define Nd 101 -#define Md 117 -#define ca 30 -#define cb 1 +#include "moGPUConfig.h" #include #include #include @@ -51,8 +46,8 @@ __device__ int * dev_h; #include // Fitness function #include -// Cuda Fitness function -#include +// GPU Fitness function +#include #include //Specific data to PPP problem #include @@ -61,9 +56,11 @@ __device__ int * dev_h; // PPP neighbor #include //To compute execution time -#include -//Kswap neighborhood -#include +#include +//Utils to compute size Mapping of x-change position +#include +//x-Change neighborhood +#include // The Solution and neighbor comparator #include #include @@ -80,7 +77,7 @@ __device__ int * dev_h; typedef PPPSolution solution; typedef PPPNeighbor Neighbor; -typedef moCudaKflipNeighborhood Neighborhood; +typedef moGPUXChangeNeighborhoodByModif Neighborhood; int main(int argc, char **argv) @@ -103,10 +100,11 @@ int main(int argc, char **argv) parser.processParam( seedParam ); unsigned seed = seedParam.value(); - // Swap number - eoValueParam KSwapParam(0, "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(); // Iteration number eoValueParam nbIterationParam(1, "nbIteration", "TS Iteration number", 'I'); @@ -149,8 +147,8 @@ 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); - +// rng.reseed(seed); +srand(0); /* ========================================================= * * Initilisation of QAP data @@ -158,6 +156,7 @@ int main(int argc, char **argv) * ========================================================= */ PPPData _data; +_data.load(); /* ========================================================= * @@ -166,8 +165,8 @@ int main(int argc, char **argv) * ========================================================= */ solution sol(Nd); - _data.cudaObject.memCopyGlobalVariable(dev_a,_data.a_d); - _data.cudaObject.memCopyGlobalVariable(dev_h,_data.H_d); + _data.GPUObject.memCopyGlobalVariable(dev_a,_data.a_d); + _data.GPUObject.memCopyGlobalVariable(dev_h,_data.H_d); /*========================================================= * @@ -176,9 +175,9 @@ int main(int argc, char **argv) * ========================================================= */ PPPEval eval(_data); - unsigned long int sizeMap=sizeMapping(Nd,KSwap); + unsigned long int sizeMap=sizeMapping(Nd,NB_POS); PPPIncrEval incr_eval; - moCudaKswapEval > cueval(sizeMap,incr_eval); + moGPUMappingEvalByModif > cueval(sizeMap,incr_eval); /* ========================================================= * @@ -195,7 +194,7 @@ int main(int argc, char **argv) * * ========================================================= */ - Neighborhood neighborhood(Nd,KSwap,cueval); + Neighborhood neighborhood(sizeMap,NB_POS,cueval); /* ========================================================= * @@ -211,7 +210,7 @@ int main(int argc, char **argv) * * ========================================================= */ - sizeTabuList=(Nd*(Nd-1))/2; + sizeTabuList=sizeMap; duration=sizeTabuList/8; // tabu list moIndexedVectorTabuList tl(sizeTabuList,duration); @@ -245,8 +244,8 @@ int main(int argc, char **argv) std::cout << "initial: " << sol<< std::endl; // Create timer for timing CUDA calculation - cudaFuncSetCacheConfig(kernelPermutation >, cudaFuncCachePreferL1); - moCudaTimer timer; + /*cudaFuncSetCacheConfig(moGPUMappingKernelEvalByModif >, cudaFuncCachePreferL1);*/ + moGPUTimer timer; timer.start(); tabuSearch(sol); std::cout << "final: " << sol << std::endl; @@ -255,8 +254,8 @@ int main(int argc, char **argv) timer.deleteTimer(); - _data.cudaObject.free(dev_a); - _data.cudaObject.free(dev_h); + _data.GPUObject.free(dev_a); + _data.GPUObject.free(dev_h); return 0; }