Skip to content

Commit bfa7edc

Browse files
committed
use precomputeKernelMatrix for trainingFunction.cu
1 parent 893bb25 commit bfa7edc

2 files changed

Lines changed: 3 additions & 36 deletions

File tree

mascot/svmMain.cu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ int main(int argc, char **argv)
4242

4343
printf("CUDA initialized.\n");
4444

45-
if(parser.cross_validation == 1)
45+
if(parser.cross_validation == 0)
4646
{
4747
//perform cross validation
4848
cout << "performing cross-validation" << endl;

mascot/trainingFunction.cu

Lines changed: 2 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -100,45 +100,12 @@ void trainingByGPU(vector<vector<float_point> > &v_v_DocVector, data_info &SData
100100
ops.SetAccessor(&accessor);
101101

102102
//cache part of hessian matrix in memory
103-
struct sysinfo info;
104-
sysinfo(&info);
105-
long nFreeMemInFloat = (info.freeram / sizeof(float_point));
106-
//memory for storing sample data, both original and transposed forms. That's why we use "2" here.
107-
long nMemForSamples = (ops.m_nNumofDim * ops.m_nTotalNumofInstance * 2);
108-
nFreeMemInFloat -= nMemForSamples; //get the number of available memory in the form of number of float
109-
nFreeMemInFloat *= 0.9; //use 80% of the memory for caching
110-
long nNumofHessianRow = (nFreeMemInFloat / nNumofSample);
111-
assert(nFreeMemInFloat > 0);
112-
if (nNumofHessianRow > nNumofSample)
113-
{
114-
//if the available memory is available to store the whole hessian matrix
115-
nNumofHessianRow = nNumofSample;
116-
}
117-
// if(nNumofHessianRow > 21500)nNumofHessianRow = 21500;
118-
// assert(nNumofHessianRow == 21500);
119-
/* long nRAMForRow = RAM_SIZE * 1024;
120-
nRAMForRow *= 1024;
121-
nRAMForRow *= 1024;
122-
nRAMForRow /= sizeof(float_point);
123-
nNumofHessianRow = (nRAMForRow / nNumofSample);
124-
if(nNumofHessianRow > nNumofSample)
125-
nNumofHessianRow = nNumofSample;
126-
*/ cout << nNumofHessianRow << " rows cached in RAM" << endl;
127-
long lSizeofCachedHessia = sizeof(float_point) * nNumofHessianRow * nNumofSample;
128-
checkCudaErrors(cudaMallocHost((void**)&DeviceHessian::m_pfHessianRowsInHostMem,
129-
sizeof(float_point) * nNumofHessianRow * nNumofSample));
130-
memset(DeviceHessian::m_pfHessianRowsInHostMem, 0, lSizeofCachedHessia);
131-
DeviceHessian::m_nNumofCachedHessianRow = nNumofHessianRow;
132-
DeviceHessian::m_pfHessianDiag = new float_point[ops.m_nTotalNumofInstance];
133-
// ops.m_pfHessianDiagTest = new float_point[ops.m_nTotalNumofInstance];
134-
135-
//pre-compute Hessian Matrix and store the result into a file
136103
timeval t1, t2;
137104
float_point elapsedTime;
138105
gettimeofday(&t1, NULL);
139106
gettimeofday(&t1, NULL);
140-
bool bWriteHessian = ops.PrecomputeHessian(strHessianMatrixFileName, strDiagHessianFileName, v_v_DocVector);
141-
ops.ReadDiagFromHessianMatrix();
107+
108+
ops.PrecomputeKernelMatrix(v_v_DocVector, &ops);
142109

143110
gettimeofday(&t2, NULL);
144111
elapsedTime = (t2.tv_sec - t1.tv_sec) * 1000.0;

0 commit comments

Comments
 (0)