use std::vector for val_pointers

This commit is contained in:
Arne Morten Kvarving 2021-11-11 12:23:16 +01:00
parent 2b0508af8b
commit 4a1fb0b86a
3 changed files with 4 additions and 8 deletions

View File

@ -62,10 +62,6 @@ WellContributions::~WellContributions()
}
#endif
if(num_std_wells > 0){
delete[] val_pointers;
}
#if HAVE_OPENCL
if(opencl_gpu){
if(num_ms_wells > 0){
@ -181,7 +177,7 @@ void WellContributions::addMatrix([[maybe_unused]] MatrixType type, [[maybe_unus
if (num_std_wells_so_far == num_std_wells - 1) {
val_pointers[num_std_wells] = num_blocks;
events.resize(1);
queue->enqueueWriteBuffer(*d_val_pointers_ocl, CL_FALSE, 0, sizeof(unsigned int) * (num_std_wells + 1), val_pointers, nullptr, &events[0]);
queue->enqueueWriteBuffer(*d_val_pointers_ocl, CL_FALSE, 0, sizeof(unsigned int) * (num_std_wells + 1), val_pointers.data(), nullptr, &events[0]);
events[0].wait();
events.clear();
}
@ -227,7 +223,7 @@ void WellContributions::addNumBlocks(unsigned int numBlocks)
void WellContributions::alloc()
{
if (num_std_wells > 0) {
val_pointers = new unsigned int[num_std_wells + 1];
val_pointers.resize(num_std_wells+1);
#if HAVE_CUDA
if(cuda_gpu){

View File

@ -210,7 +210,7 @@ void WellContributions::addMatrixGpu(MatrixType type, int *colIndices, double *v
val_pointers[num_std_wells_so_far] = num_blocks_so_far;
if (num_std_wells_so_far == num_std_wells - 1) {
val_pointers[num_std_wells] = num_blocks;
cudaMemcpy(d_val_pointers, val_pointers, sizeof(unsigned int) * (num_std_wells + 1), cudaMemcpyHostToDevice);
cudaMemcpy(d_val_pointers, val_pointers.data(), sizeof(unsigned int) * (num_std_wells + 1), cudaMemcpyHostToDevice);
}
break;
default:

View File

@ -86,7 +86,7 @@ private:
unsigned int num_ms_wells = 0; // number of MultisegmentWells in this object, must equal multisegments.size()
unsigned int num_blocks_so_far = 0; // keep track of where next data is written
unsigned int num_std_wells_so_far = 0; // keep track of where next data is written
unsigned int *val_pointers = nullptr; // val_pointers[wellID] == index of first block for this well in Ccols and Bcols
std::vector<unsigned int> val_pointers; // val_pointers[wellID] == index of first block for this well in Ccols and Bcols
double *h_x = nullptr;
double *h_y = nullptr;