From 692f4a20e6481e4cf3b635e08defbf42906149d8 Mon Sep 17 00:00:00 2001 From: boufaras Date: Tue, 8 Feb 2011 17:12:20 +0000 Subject: [PATCH] git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@2128 331e1502-861f-0410-8da2-ba01fb791d7f --- ParadisEO-GPU/src/problems/data/QAPData.h | 27 ++++++++++++----------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/ParadisEO-GPU/src/problems/data/QAPData.h b/ParadisEO-GPU/src/problems/data/QAPData.h index d9f51819d..34abbfc76 100644 --- a/ParadisEO-GPU/src/problems/data/QAPData.h +++ b/ParadisEO-GPU/src/problems/data/QAPData.h @@ -40,7 +40,7 @@ template class QAPData: public moCudaSpecificData { - public: +public: using moCudaSpecificData::sizeData; using moCudaSpecificData::cudaObject; @@ -130,33 +130,34 @@ class QAPData: public moCudaSpecificData { void load(char* _fileName) { - FILE *f; - unsigned int i,j; - int r; + fstream file(_fileName, ios::in); + if (!file) { - f = fopen(_fileName, "r"); - if (f != NULL) - r=fscanf(f, "%d", &(*this).sizeData); - else - printf("Le Fichier est vide\n"); + string str = "QAPData: Could not open file [" + (string) _fileName + + "]."; + throw runtime_error(str); + } + unsigned i, j; + file >> sizeData; a_h = new ElemType[sizeData * sizeData]; b_h = new ElemType[sizeData * sizeData]; for (i = 0; i < sizeData; i++) for (j = 0; j < sizeData; j++) - r=fscanf(f, "%d", &a_h[i * sizeData + j]); - + file >> a_h[i * sizeData + j]; for (i = 0; i < sizeData; i++) for (j = 0; j < sizeData; j++) - fscanf(f, "%d", &b_h[i * sizeData + j]); + file >> b_h[i * sizeData + j]; //Allocate and copy QAP data from CPU memory to GPU global memory cudaObject.memCopy(a_d, a_h, sizeData * sizeData); cudaObject.memCopy(b_d, b_h, sizeData * sizeData); } - public: +public: +public: + public: ElemType* a_h;