@@ -140,19 +140,25 @@ void CSysMatrix<ScalarType>::Initialize(unsigned long npoint, unsigned long npoi
140140 ptr = MemoryAllocation::aligned_alloc<ScalarType, true >(64 , num * sizeof (ScalarType));
141141 };
142142
143- allocAndInit (matrix, nnz * nVar * nEqn);
144143
145- auto GPUAllocAndInit = [](ScalarType*& ptr, unsigned long num) {
146- ptr = GPUMemoryAllocation::gpu_alloc<ScalarType, true >(num * sizeof (ScalarType));
147- };
144+ if (config->GetCUDA ())
145+ {
146+ /* --- Allocate GPU data. ---*/
147+ allocAndInit (matrix, nnz * nVar * nEqn);
148148
149- auto GPUAllocAndCopy = [](const unsigned long *& ptr, const unsigned long *& src_ptr , unsigned long num) {
150- ptr = GPUMemoryAllocation::gpu_alloc_cpy< const unsigned long >(src_ptr, num * sizeof (const unsigned long ));
151- };
149+ auto GPUAllocAndInit = [](ScalarType *& ptr, unsigned long num) {
150+ ptr = GPUMemoryAllocation::gpu_alloc<ScalarType, true >( num * sizeof (ScalarType ));
151+ };
152152
153- GPUAllocAndInit (d_matrix, nnz * nVar * nEqn);
154- GPUAllocAndCopy (d_row_ptr, row_ptr, (nPointDomain + 1.0 ));
155- GPUAllocAndCopy (d_col_ind, col_ind, nnz);
153+ auto GPUAllocAndCopy = [](const unsigned long *& ptr, const unsigned long *& src_ptr, unsigned long num) {
154+ ptr = GPUMemoryAllocation::gpu_alloc_cpy<const unsigned long >(src_ptr, num * sizeof (const unsigned long ));
155+ };
156+
157+ GPUAllocAndInit (d_matrix, nnz * nVar * nEqn);
158+ GPUAllocAndCopy (d_row_ptr, row_ptr, (nPointDomain + 1.0 ));
159+ GPUAllocAndCopy (d_col_ind, col_ind, nnz);
160+ }
161+
156162
157163 if (needTranspPtr) col_ptr = geometry->GetTransposeSparsePatternMap (type).data ();
158164
0 commit comments