LCOV - code coverage report
Current view: top level - imp - param_manager.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 170 232 73.3 %
Date: 2025-09-16 18:26:42 Functions: 13 17 76.5 %

          Line data    Source code
       1             : #include "../inc/header.h"
       2             : #include "../inc/global_param.h"
       3             : #include "../inc/utils.h"
       4             : 
       5             : 
       6             : /**
       7             :  *  \file param_manager.cu
       8             :  *  \author Guillaume
       9             :  *  \brief Fichier de gestion de param Local Param
      10             :  *  \fn void    FindDescIndex(LocalParam & lp, uint32_t desc_type)
      11             :  *  \brief return index of desc_type in lp.ReadCacheCPU
      12             :  *  \fn void    resetStructCpt(std::vector<types_datas_t> &ReadCacheCPU)
      13             :  *  \brief reset cpt in vector ReadCacheCPU
      14             :  *  \fn int AddDTtoCache(GlobalParam & gp, LocalParam & lp, uint32_t desc_type, uint32_t desc_size)
      15             :  *  \brief add a new desctype to lp.ReadCacheCPU (list of descriptor)
      16             :  *      \fn void LoadDTFolderPath(LocalParam & lp, std::string rootDirectory_aux)
      17             :  *      \return initialise lp.ReadCacheCPU(desc_type).dir the folder where we found file.dat
      18             :  *      \brief need to be optimized for large array !!!!
      19             :  */
      20             : 
      21             : 
      22       11043 : int FindDescIndex(std::vector<types_datas_t>& ReadCacheCPU, uint32_t desc_type){
      23       11031 :         int length = ReadCacheCPU.size();
      24             :         //std::cout<<"Read cache size : "<<length<<std::endl;
      25       11080 :         for(int i = 0; i<length;i++){
      26       11074 :                 if (ReadCacheCPU[i].type==desc_type)
      27          30 :                         return i;
      28             :         }
      29             :         return -1;
      30             : }
      31             : 
      32             : 
      33             : 
      34       88024 : int FindPidsIndex(const std::vector<uint32_t>& ids_vec, uint32_t pids){
      35       88024 :         int length = ids_vec.size();
      36   484044000 :         for(int i = 0; i<length;i++){
      37   484044000 :                 if (ids_vec[i]==pids)
      38       88024 :                         return i;
      39             :         }
      40             :         return -1;
      41             : }
      42             : 
      43           1 : void resetStructCpt(std::vector<types_datas_t> &ReadCacheCPU)
      44             : {
      45           3 :         for (int i = 0; i < ReadCacheCPU.size(); ++i)
      46           2 :                 ReadCacheCPU[i].cpt = 0;
      47           0 : }
      48             : 
      49           6 : void AddDTtoCache(GlobalParam & gp, LocalParam & lp, uint32_t desc_type, uint32_t desc_size)
      50             : {
      51           6 :     uint32_t desc_size_used;
      52           6 :     lp.ReadCacheCPU.resize(gp.nbtype_);
      53           6 :     int tmp_index = FindDescIndex(lp.ReadCacheCPU, desc_type);
      54           6 :     if(tmp_index >=0)
      55             :                 return;
      56           5 :     if (lp.verbose)
      57             :     {
      58           0 :         std::cout<<"Add descriptor type : "<<desc_type<<" of size "<<desc_size<<std::endl;
      59             :     }
      60           5 :         std::cout<<"Add descriptor type : "<<desc_type<<" of size "<<desc_size<<std::endl;
      61           5 :     gp.nbtype_ ++; // ajout d'un type dans le Cache
      62           5 :     lp.ReadCacheCPU.resize(gp.nbtype_);
      63           5 :         lp.ReadCacheCPU[gp.nbtype_-1].type = desc_type;
      64           5 :         lp.ReadCacheCPU[gp.nbtype_-1].size = desc_size;
      65           5 :         lp.ReadCacheCPU[gp.nbtype_-1].nb_data = 0;
      66           5 :         lp.ReadCacheCPU[gp.nbtype_-1].dir = gp.velours_std_ ;
      67           5 :         if (lp.ReadCacheCPU.size() == 0)
      68             :     {
      69           0 :         printf("ERROR &(ReadCacheCPU.size()) is of size empty %ld : \n", (lp.ReadCacheCPU.size()));
      70           0 :         puts("ERROR, ReadCacheCPU not initialized !");
      71             :     }
      72           5 :     int dsctp_index = FindDescIndex(lp.ReadCacheCPU, 0); // recherche le prochaine espace dans le cache non initialisé (=0)
      73             : 
      74             :     // VR 13-4-23 Si on est en type INT et que desc_size n'est pas divisible par 8, on doit compléter avec des 0 // GB : NON
      75             :         //desc_size_used = (uint32_t) ((desc_size / 8) + 1) * 8;
      76             : 
      77             : 
      78           5 :     if (dsctp_index >=0) {
      79           4 :                 lp.ReadCacheCPU[dsctp_index].type = desc_type;
      80           4 :         lp.ReadCacheCPU[dsctp_index].size = desc_size;
      81           4 :         lp.ReadCacheCPU[dsctp_index].size_user_choice = desc_size;
      82           4 :         lp.ReadCacheCPU[dsctp_index].nb_data = 0;
      83           4 :         lp.ReadCacheCPU[dsctp_index].dir = gp.velours_std_ ;
      84             :         }
      85             : }
      86             : 
      87           0 : void AddDynDTtoCache(LocalParam & lp, uint32_t desc_type_pere){
      88             :         
      89           0 :         int new_type;
      90           0 :         uint32_t desc_size;
      91           0 :         if(desc_type_pere >=0){
      92           0 :                 int index_pere = FindDescIndex(lp.ReadCacheCPU, desc_type_pere);
      93           0 :                 if(index_pere == -1){
      94           0 :                         std::cout<<"desc type : "<<desc_type_pere<<" not found in ReadCahe CPU !"<<std::endl;
      95           0 :                         return;
      96             :                 }
      97           0 :                 desc_size = lp.ReadCacheCPU[index_pere].size;
      98             :         }else{
      99             :                 int index_pere = FindDescIndex(lp.ReadCacheCpuDyn, desc_type_pere);
     100             :                 if(index_pere == -1){
     101             :                         std::cout<<"desc type : "<<desc_type_pere<<" not found in ReadCahe CPU !"<<std::endl;
     102             :                         return;
     103             :                 }
     104             :                 desc_size = lp.ReadCacheCpuDyn[index_pere].size;
     105             :         }
     106           0 :         int nb_desc_dyn_before=lp.ReadCacheCpuDyn.size();
     107           0 :         if(nb_desc_dyn_before==0){
     108           0 :                 new_type = -100;
     109             :         }else{
     110           0 :                 new_type=lp.list_dyn_desc_type.back() - 1;
     111             :         }
     112           0 :         std::cout<<"new dyn type : "<<new_type<<std::endl;
     113           0 :         std::cout<<"nb desc in dyn "<<lp.ReadCacheCpuDyn.size()<<std::endl;
     114           0 :         lp.list_dyn_desc_type.push_back(new_type);
     115           0 :         lp.list_pere_desc_dyn.push_back(desc_type_pere);
     116           0 :         lp.ReadCacheCpuDyn.resize(nb_desc_dyn_before+1);
     117           0 :         std::cout<<"nb desc in dyn "<<lp.ReadCacheCpuDyn.size()<<std::endl;
     118           0 :         lp.ReadCacheCpuDyn[nb_desc_dyn_before].type=new_type;
     119           0 :         lp.ReadCacheCpuDyn[nb_desc_dyn_before].size=desc_size;
     120           0 :         lp.ReadCacheCpuDyn[nb_desc_dyn_before].nb_data=0;
     121           0 :         lp.ReadCacheCpuDyn[nb_desc_dyn_before].datas_vec.resize(0);
     122           0 :         lp.ReadCacheCpuDyn[nb_desc_dyn_before].ids_vec.resize(0);
     123           0 :         std::cout<<"nb desc in dyn "<<lp.ReadCacheCpuDyn.size()<<std::endl;
     124             : }
     125             : 
     126           0 : void initDynDTinCache(LocalParam & lp, std::vector<std::vector<uint32_t> > & list_photo_ids_per_cluster, uint32_t desc_type_pere){
     127           0 :         for(int i=0; i<list_photo_ids_per_cluster.size(); i++){
     128           0 :                 AddDynDTtoCache(lp, desc_type_pere);
     129           0 :                 int nb_desc_dyn = lp.ReadCacheCpuDyn.size();
     130             :                 
     131           0 :                 std::cout<<lp.ReadCacheCpuDyn[nb_desc_dyn-1].type<<std::endl;
     132           0 :                 int dim = lp.ReadCacheCpuDyn[nb_desc_dyn-1].size;
     133           0 :                 lp.ReadCacheCpuDyn[nb_desc_dyn-1].nb_data+=list_photo_ids_per_cluster[i].size();
     134           0 :                 for(int j=0; j<list_photo_ids_per_cluster[i].size(); j++){
     135           0 :                         lp.ReadCacheCpuDyn[nb_desc_dyn-1].ids_vec.push_back(list_photo_ids_per_cluster[i][j]);
     136           0 :                         int index = FindPidsIndex(lp.ReadCacheCPU[0].ids_vec, list_photo_ids_per_cluster[i][j]);
     137           0 :                         for(int d=0; d<dim; d++){
     138           0 :                                 lp.ReadCacheCpuDyn[nb_desc_dyn-1].datas_vec.push_back(lp.ReadCacheCPU[0].datas_vec[index*dim+d]);
     139             :                         }
     140             :                 }
     141             :         }
     142           0 : }
     143             : 
     144           2 : void LoadDTFolderPath(LocalParam & lp, std::string rootDirectory_aux,int verbose){
     145           2 :         uint32_t desc_type;
     146          12 :         for (int i = 0; i < lp.ReadCacheCPU.size(); i++)
     147             :         {
     148          10 :                 desc_type = lp.ReadCacheCPU[i].type;
     149          10 :                 if (desc_type != 0){
     150          18 :                         std::string command;
     151           9 :                         command = "mkdir -p ";
     152           9 :                         lp.ReadCacheCPU[i].dir = "";
     153           9 :                         lp.ReadCacheCPU[i].dir += rootDirectory_aux;
     154           9 :                         if (!strstr(rootDirectory_aux.c_str(), "binary")){
     155           9 :                                 lp.ReadCacheCPU[i].dir += "binary";
     156           9 :                                 lp.ReadCacheCPU[i].dir += boost::lexical_cast<std::string>(lp.ReadCacheCPU[i].type);
     157             :                         }
     158           9 :                         lp.ReadCacheCPU[i].dir += "/";
     159           9 :                         command += lp.ReadCacheCPU[i].dir;
     160           9 :                         if (verbose)
     161           0 :                                 printf("%s\n", &(command.at(0)));
     162           9 :                         if(system(&(command.at(0))))
     163             :                                 ;
     164             :                 }
     165             :         }
     166           2 : }
     167             : 
     168           1 : void count_data_by_type(std::vector<types_datas_t>& ReadCacheCPU, uint32_t nb_datas, std::vector<uint32_t> & type_data)
     169             : {
     170           1 :     int32_t tmp;
     171           1 :     int32_t prec;
     172           1 :     tmp = FindDescIndex(ReadCacheCPU, type_data[0]);
     173           1 :     prec = type_data[0];
     174           1 :     if (ReadCacheCPU[tmp].nb_data)
     175             :         return;
     176       11001 :     for (int i = 0; i < nb_datas; ++i)
     177             :     {
     178       11000 :         if (type_data[i] != prec)
     179           0 :             tmp = FindDescIndex(ReadCacheCPU, type_data[i]);
     180       11000 :         if (tmp >= 0 && tmp < GlobalParam::Instance().nbtype_)
     181       11000 :             ReadCacheCPU[tmp].nb_data++;
     182       11000 :         prec = type_data[i];
     183             :     }
     184             : }
     185             : 
     186           1 : void split_ids_datas(std::vector<uint32_t> & ids_data, std::vector<uint32_t> & type_data, std::vector<types_datas_t>& ReadCacheCPU, uint32_t nb_data)
     187             : {
     188           1 :     int32_t tmp;
     189       11001 :     for (int i = 0; i < nb_data; ++i)
     190             :     {
     191       11000 :         tmp = FindDescIndex(ReadCacheCPU, type_data[i]);
     192       11000 :         if (tmp >= 0)
     193             :         {
     194       11000 :                         ReadCacheCPU[tmp].resizeDatas(ReadCacheCPU[tmp].nb_max_data);
     195       11000 :             ReadCacheCPU[tmp].ids_vec[ReadCacheCPU[tmp].cpt++] = ids_data[i];
     196             :         }
     197             :     }
     198           1 : }
     199             : 
     200           1 : int LoadDescriptor(std::vector<types_datas_t>& ReadCacheCPU, int descriptor_type_index, std::vector<uint32_t> & ids_data_vec, std::vector<uint32_t> & ids_index_vec, std::vector<uint32_t> & type_data_vec, int nb_data_in_file_current, int verbose)
     201             : {
     202           1 :         ReadCacheCPU[descriptor_type_index].resizeDatas(ReadCacheCPU[descriptor_type_index].nb_data);
     203           1 :         ReadCacheCPU[descriptor_type_index].nb_max_data = ReadCacheCPU[descriptor_type_index].nb_data;
     204           1 :         if (verbose)
     205           0 :                 std::cout<<"LoadDescriptor "<<ReadCacheCPU[descriptor_type_index].type<<std::endl;
     206           1 :         ReadCacheCPU[descriptor_type_index].resizeDatas(ReadCacheCPU[descriptor_type_index].nb_max_data);
     207           1 :         resetStructCpt(ReadCacheCPU);
     208           1 :         split_ids_datas(ids_data_vec, type_data_vec, ReadCacheCPU, nb_data_in_file_current);
     209           1 :         loadBinary(ids_data_vec, ids_index_vec, type_data_vec, ReadCacheCPU, nb_data_in_file_current, ReadCacheCPU[descriptor_type_index].dir, verbose);
     210           1 :         std::cout<<" data loaded "<<std::endl;
     211          11 :         for(int i=0 ; i<10; i++){
     212             : #ifdef FLOAT_TYPE
     213             :                 std::cout<<ReadCacheCPU[0].datas_vec[i]<<", ";
     214             : #else
     215          10 :                 std::cout<<static_cast<uint16_t>(ReadCacheCPU[0].datas_vec[i])<<", ";
     216             : #endif
     217             :         }
     218           1 :         std::cout<<std::endl;
     219           1 :         return nb_data_in_file_current;
     220             : }
     221             : 
     222          10 : uint32_t loadListIndexFile(std::vector<uint32_t> &  ids_data, std::vector<uint32_t> & ids_index,
     223             :                            std::vector<uint32_t> & type_data, std::string filename_list_index_file_aux, int max_nb_file_loaded_in_index,
     224             :     int & descriptor_type, int verbose)
     225             : {
     226          10 :     if (verbose)
     227           0 :         printf("in loadListIndexFile max_nb_file_loaded_in_index :  %d\n", max_nb_file_loaded_in_index);
     228          10 :     char linebuf[1000];
     229          10 :     int index_id, data_id, data_type;
     230          10 :     uint32_t i = 0;
     231          10 :     FILE * fd = fopen(filename_list_index_file_aux.c_str(), "r");
     232          10 :     if (fd == NULL)
     233             :     {
     234           9 :         printf("%s doesn't exists in loadListIndexFile !\n", filename_list_index_file_aux.c_str());
     235           9 :         return 0;
     236             :     }
     237             : 
     238           1 :     int batch_alloc = 10000;
     239           1 :     ids_data.resize(batch_alloc);
     240           1 :     ids_index.resize(batch_alloc);
     241           1 :     type_data.resize(batch_alloc);
     242       11001 :     while (1)
     243             :     {
     244       11001 :         if (i == max_nb_file_loaded_in_index && max_nb_file_loaded_in_index != 0)
     245             :         {
     246           0 :             printf("Nb maximum data read : %d!\n", max_nb_file_loaded_in_index);
     247             :             break;
     248             :         }
     249       11001 :         if (EOF == fscanf(fd,  "%[^\n]\n",  linebuf))
     250             :           break;
     251             : 
     252       11000 :         sscanf(linebuf, "%d,%d,%d\n", &data_id, &index_id, &data_type);
     253       11000 :         if (descriptor_type == -1)
     254           1 :             descriptor_type = data_type;
     255             : 
     256       11000 :         if (data_type != descriptor_type)
     257             :         {
     258           0 :             i++;
     259           0 :             continue;
     260             :         }
     261             : 
     262       11000 :         if (data_id == -1)
     263             :         {
     264           0 :             printf("data_id is still -1 : %d \n", data_id);
     265             :             break;
     266             :         }
     267             : 
     268       11000 :         if (i % batch_alloc == 0)
     269             :         {
     270           2 :             if (verbose)
     271           0 :                 std::cout << " reallocating : " << (i + batch_alloc) << std::endl;
     272             : 
     273           2 :             ids_data.resize((i + batch_alloc));
     274           2 :             ids_index.resize((i + batch_alloc));
     275           2 :             type_data.resize((i + batch_alloc));
     276             :         }
     277             : 
     278       11000 :         ids_data[i] = data_id;
     279       11000 :         ids_index[i] = index_id;
     280       11000 :         type_data[i] = data_type;
     281             : 
     282       11000 :         bzero(linebuf, 1000);
     283       11000 :         data_id = -1;
     284       11000 :         i++;
     285             :     }
     286           1 :         fclose(fd);
     287           1 :     if (verbose)
     288           0 :         puts("Read data in index\n");
     289             :     return i;
     290             : }
     291             : 
     292             : // remplace setCacheParamDeuxiemeMoitie ?
     293             : 
     294           2 : int LoadDataInCache(GlobalParam & gp, LocalParam & lp, int descriptor_type, int verbose,
     295             :              std::string rootDirectory_aux, int reload, int cleaning)
     296             : {
     297           2 :     if (verbose)
     298             :     {
     299           0 :         std::cout << __FUNCTION__ << std::endl;
     300           0 :         std::cout << "port = " << GlobalParam::Instance().port_<< std::endl;
     301           0 :         std::cout << "Loading data from files and folder !"<< std::endl;
     302             :     }
     303             :     
     304             : 
     305           2 :     clock_t startClock = clock();
     306           2 :     if (!reload)
     307             :     {
     308           2 :         LoadDTFolderPath(lp, rootDirectory_aux, verbose);
     309          12 :         for(int i = 0; i<lp.ReadCacheCPU.size();++i)
     310             :         {
     311          10 :                         gp.WriteCache[i][0].dire = std::string(lp.ReadCacheCPU[i].dir);
     312          10 :                         lp.ReadCacheCPU[i].nb_data = 0;
     313             :                 }
     314             :     }
     315             : 
     316           4 :     std::string completeFileNameStr;
     317           6 :     std::vector<uint32_t> ids_index_vec, ids_data_vec, type_data_vec;
     318             : 
     319           2 :     size_t nb_data_allocated = 0;
     320           2 :     unsigned int nb_data_in_file = 0;
     321             :     // A quoi sert ce max_loading ?? A quoi sert l'option -O qui initialise le lp.load_only_main ?
     322           2 :     int max_loading = (lp.load_only_main == 1 ? lp.load_only_main : lp.ReadCacheCPU.size());
     323          12 :     for (int i = 0; i < lp.ReadCacheCPU.size(); ++i)
     324             :     {
     325          10 :         completeFileNameStr = lp.ReadCacheCPU[i].dir + GlobalParam::Instance().filename_photo_id_list_str_;
     326          10 :         std::cout<<"completefilename : "<<completeFileNameStr<<std::endl;
     327             : 
     328          10 :         int tmp_type = -1;
     329          10 :         uint32_t nb_data_in_file_current = 0;
     330          10 :         if (!lp.empty_server)
     331          30 :             nb_data_in_file_current = loadListIndexFile(ids_data_vec, ids_index_vec, type_data_vec, completeFileNameStr, lp.limit_data, tmp_type, verbose);
     332             : 
     333          10 :         if (lp.descriptor_type == -1 || tmp_type == lp.descriptor_type)
     334             :         {
     335           2 :             resetStructCpt(lp.ReadCacheCPU);
     336           1 :             if (nb_data_in_file_current)
     337             :             {
     338           1 :                 count_data_by_type(lp.ReadCacheCPU, nb_data_in_file_current, type_data_vec);
     339           1 :                 std::cout<<"nb de data dans cache : "<<lp.ReadCacheCPU[i].nb_data<<std::endl;
     340           1 :                 if (lp.ReadCacheCPU.size() == 0)
     341             :                 {
     342           0 :                     printf("error while counting data by types, exiting\n");
     343           0 :                     if(system("wget http://www.fotonower.com/vse_corrupted_data"))
     344             :                         ;
     345           0 :                     return 1;
     346             :                 }
     347           1 :                 if (lp.ReadCacheCPU[i].datas_vec.size() == 0 && lp.ReadCacheCPU[i].type == type_data_vec[0])
     348             :                 {
     349           1 :                                         int DT_index = FindDescIndex(lp.ReadCacheCPU,tmp_type);
     350           1 :                     lp.nb_data_in_file += LoadDescriptor(lp.ReadCacheCPU, DT_index, ids_data_vec, ids_index_vec, type_data_vec, nb_data_in_file_current, verbose);
     351           1 :                     nb_data_allocated += lp.ReadCacheCPU[i].nb_data;
     352             :                 }
     353             :                 else
     354             :                 {
     355           0 :                     if (verbose)
     356          10 :                         printf("data = %u\n", lp.ReadCacheCPU[i].nb_data);
     357             :                 }
     358             :             }
     359             :         }
     360             :     }
     361           2 :     if (verbose)
     362             :     {
     363           0 :         std::cout << " nb_data_allocated : " << nb_data_allocated << std::endl;
     364             :     }
     365             : 
     366           2 :     clock_t endClock = clock();
     367           2 :     printf("Loading %d datas_vec took %lf seconds\n", lp.nb_data_in_file, (endClock - startClock) /(double) CLOCKS_PER_SEC);
     368           2 :     srand((unsigned int) time(NULL));
     369             :     
     370             :     #ifndef ONLY_CPU
     371             :     if (!cleaning)
     372             :     {
     373             :         if (verbose)
     374             :             printf("About to allocate for cuda\n");
     375             :         clock_t startGPU = clock();
     376             :         if (!reload)
     377             :         {
     378             :                         //std::cout << "cudaDeviceMapHost : " << cudaDeviceMapHost << std::endl;
     379             :                         //std::cout << "cudaDeviceMapHost : " << cudaSetDeviceFlags(cudaDeviceMapHost) << std::endl;
     380             :             //testCUDA(cudaSetDeviceFlags(cudaDeviceMapHost));
     381             :         }
     382             :         for (int i = 0; i < GlobalParam::Instance().nbtype_; ++i)
     383             :         {
     384             :             if (!reload)
     385             :             {
     386             :                 if (lp.ReadCacheCPU[i].nb_data && !reload) {
     387             :                     if (verbose)
     388             :                         printf("size_malloc de %d = %lu\n", i, (size_t)lp.ReadCacheCPU[i].nb_data * (size_t)lp.ReadCacheCPU[i].size);
     389             :                     testCUDA(cudaMalloc(&lp.ReadCacheCPU[i].dataGPU, (size_t)lp.ReadCacheCPU[i].nb_data * (size_t)lp.ReadCacheCPU[i].size * sizeof(datag)));
     390             :                     testCUDA(cudaMemcpy(lp.ReadCacheCPU[i].dataGPU, lp.ReadCacheCPU[i].datas_vec.size() ?  &(lp.ReadCacheCPU[i].datas_vec.front()) : NULL, (size_t)lp.ReadCacheCPU[i].nb_data * (size_t)lp.ReadCacheCPU[i].size * sizeof(datag), cudaMemcpyHostToDevice));
     391             :                     //printf("%lu:::%lu:::%lu\n",ReadCacheCPU[i].datas_vec.size(),(size_t)ReadCacheCPU[i].nb_data , (size_t)ReadCacheCPU[i].size);
     392             :                 }
     393             :                 else {
     394             :                     testCUDA(cudaMalloc(&lp.ReadCacheCPU[i].dataGPU, 1 * (size_t)lp.ReadCacheCPU[i].size * sizeof(datag)));
     395             :                 }
     396             :             }else {
     397             :                 if (lp.ReadCacheCPU[i].type == descriptor_type)
     398             :                 {
     399             :                     if (lp.ReadCacheCPU[i].nb_data) {
     400             :                         testCUDA(cudaMalloc(&lp.ReadCacheCPU[i].dataGPU, (size_t)lp.ReadCacheCPU[i].nb_data * (size_t)lp.ReadCacheCPU[i].size * sizeof(datag)));
     401             :                         testCUDA(cudaMemcpy(lp.ReadCacheCPU[i].dataGPU, lp.ReadCacheCPU[i].datas_vec.size() ?  &(lp.ReadCacheCPU[i].datas_vec.front()) : NULL, (size_t)lp.ReadCacheCPU[i].nb_data * (size_t)lp.ReadCacheCPU[i].size * sizeof(datag), cudaMemcpyHostToDevice));
     402             :                     }
     403             :                     else {
     404             :                         testCUDA(cudaMalloc(&lp.ReadCacheCPU[i].dataGPU, 1 * (size_t)lp.ReadCacheCPU[i].size * sizeof(datag)));
     405             :                         return 1;
     406             :                     }
     407             :                 }
     408             :             }
     409             : 
     410             :         }
     411             :         clock_t endClock = clock();
     412             :         printf("Loading in GPU ram took %lf seconds\n", (endClock - startGPU) / (double)CLOCKS_PER_SEC);
     413             :         if (verbose)
     414             :             puts("done cuda loading\n");
     415             : 
     416             : 
     417             : 
     418             :     }
     419             : #endif
     420             : 
     421           2 :     if (verbose)
     422           2 :         printf("After loading data \n");
     423             : 
     424             :     return 0;
     425             : }
     426             : 
     427             : // VR 13-10-16 : on peut déplacer ces fonctions qqpart !
     428             : //-----------------------------------------------------------------------------------
     429     2000000 : toInsert::~toInsert()
     430             : {
     431     2000000 :     if (dire.length() > 0)
     432             :     {
     433           9 :         std::cout << "About to delete dire in ~toInsert which as length : " << dire.length() << std::endl;
     434     2000000 :         std::cout << "About to delete dire in ~toInsert : " << dire << std::endl;
     435             :     }
     436     2000000 : }
     437             : 
     438             : //-----------------------------------------------------------------------------------
     439           0 : int toInsert::commit(int size)
     440             : {
     441           0 :     return 0;
     442             : }
     443             : 
     444             : //-----------------------------------------------------------------------------------
     445          10 : types_datas::types_datas()
     446             : //:ids_vec(0, 0), index_vec(0, 0), datas_vec(0, 0), dataGPU_vec(0, 0)
     447             : {
     448          10 :     resizeDatas(0);
     449          10 : }
     450             : 
     451             : //-----------------------------------------------------------------------------------
     452          38 : types_datas::~types_datas()
     453             : {
     454          16 :     std::cout << __FUNCTION__ << std::endl;
     455          16 : }
     456             : 
     457             : //-----------------------------------------------------------------------------------
     458       11035 : void types_datas::resizeDatas(size_t newsize)
     459             : {
     460             :     // VR TODO weird 26-9-16
     461       11035 :     datas_vec.resize(newsize * size);
     462             : 
     463       11035 :     index_vec.resize(newsize);
     464       11035 :     ids_vec.resize(newsize);
     465       11035 : }
     466             : 
     467             : //-----------------------------------------------------------------------------------
     468             : 

Generated by: LCOV version 1.14