Skip to content

Commit

Permalink
Merge pull request #180 from AdaptiveParticles/joel_tmp
Browse files Browse the repository at this point in the history
Joel tmp
  • Loading branch information
joeljonsson authored Oct 16, 2023
2 parents 10ab24a + d220171 commit 003270b
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 30 deletions.
9 changes: 6 additions & 3 deletions src/data_structures/APR/APR.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class APR {
friend class APRConverterBatch;
friend class APRBenchHelper;

protected:
public:

// initialize tree RandomAccess
void initialize_tree_random_sparse();
Expand Down Expand Up @@ -60,8 +60,6 @@ class APR {

APRParameters parameters; // this is here to keep a record of what parameters were used, to then be written if needed.

public:

#ifdef APR_USE_CUDA


Expand All @@ -86,6 +84,10 @@ class APR {
* @param with_tree include the tree access
*/
void init_cuda(bool with_tree=true) {
gpuAccess.genInfo = &aprInfo;
gpuTreeAccess.genInfo = &treeInfo;
linearAccess.genInfo = &aprInfo;
linearAccessTree.genInfo = &treeInfo;
auto apr_helper = gpuAPRHelper();
if(with_tree) {
auto tree_helper = gpuTreeHelper();
Expand Down Expand Up @@ -190,6 +192,7 @@ class APR {
tree_initialized = apr2copy.tree_initialized;
apr_initialized = apr2copy.apr_initialized;
name = apr2copy.name;
parameters = apr2copy.parameters;

//old data structures
apr_access = apr2copy.apr_access;
Expand Down
4 changes: 1 addition & 3 deletions src/data_structures/APR/access/GPUAccess.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ class GPUAccessHelper {
gpuAccess->init_y_vec(linearAccess->y_vec);
gpuAccess->init_level_xz_vec(linearAccess->level_xz_vec);
gpuAccess->init_xz_end_vec(linearAccess->xz_end_vec);
gpuAccess->genInfo = linearAccess->genInfo;
gpuAccess->copy2Device();
gpuAccess->initialized = true;
}
Expand All @@ -78,7 +77,6 @@ class GPUAccessHelper {
gpuAccess->init_y_vec(linearAccess->y_vec);
gpuAccess->init_level_xz_vec(linearAccess->level_xz_vec);
gpuAccess->init_xz_end_vec(linearAccess->xz_end_vec);
gpuAccess->genInfo = linearAccess->genInfo;
gpuAccess->copy2Device(total_number_particles(tree_access.level_max()), tree_access.gpuAccess);
gpuAccess->initialized = true;
}
Expand All @@ -88,7 +86,7 @@ class GPUAccessHelper {
gpuAccess->copy2Host();
}

uint64_t total_number_particles() { return gpuAccess->total_number_particles(); }
uint64_t total_number_particles() { return gpuAccess->genInfo->total_number_particles; }

uint64_t total_number_particles(const int level) {
uint64_t index = linearAccess->level_xz_vec[level] + linearAccess->x_num(level) - 1 + (linearAccess->z_num(level)-1)*linearAccess->x_num(level);
Expand Down
3 changes: 2 additions & 1 deletion src/io/APRWriter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,8 @@ class APRWriter {
break;
case Operation::WRITE:

fileId = hdf5_create_file_blosc(aFileName);
// fileId = hdf5_create_file_blosc(aFileName);
fileId = H5Fcreate(aFileName.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);

if (fileId == -1) {
std::cerr << "Could not create file [" << aFileName << "]" << std::endl;
Expand Down
4 changes: 3 additions & 1 deletion src/numerics/APRDownsampleGPU.cu
Original file line number Diff line number Diff line change
Expand Up @@ -900,6 +900,7 @@ template<int blockSize_z, int blockSize_x>
void compute_ne_rows_tree_cuda(GPUAccessHelper& tree_access, VectorData<int>& ne_count, ScopedCudaMemHandler<int*, JUST_ALLOC>& ne_rows_gpu) {

ne_count.resize(tree_access.level_max() + 3);
ne_count[0] = 0;

int z_blocks_max = (tree_access.z_num(tree_access.level_max()) + blockSize_z - 1) / blockSize_z;
int num_levels = tree_access.level_max() - tree_access.level_min() + 1;
Expand Down Expand Up @@ -973,12 +974,13 @@ void compute_ne_rows_tree_cuda(GPUAccessHelper& tree_access, VectorData<int>& ne
ne_rows_gpu.get());
}

error_check(cudaFree(block_sums_device) )
error_check(cudaFree(block_sums_device))
}


void compute_ne_rows_tree(GPUAccessHelper& tree_access, VectorData<int>& ne_counter, VectorData<int>& ne_rows) {
ne_counter.resize(tree_access.level_max() + 3);
ne_counter[0] = 0;

int z = 0;
int x = 0;
Expand Down
29 changes: 15 additions & 14 deletions src/numerics/miscCuda.cu
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ __global__ void fill_ne_rows_cuda(const uint64_t* level_xz_vec,
}



template<int blockSize_z, int blockSize_x>
void compute_ne_rows_cuda(GPUAccessHelper& access, VectorData<int>& ne_count, ScopedCudaMemHandler<int*, JUST_ALLOC>& ne_rows_gpu, int blockSize) {

Expand Down Expand Up @@ -264,12 +265,12 @@ void compute_ne_rows_cuda(GPUAccessHelper& access, VectorData<int>& ne_count, Sc
count_ne_rows_cuda<blockSize_z, blockSize_x>
<< < grid_dim, block_dim >> >
(access.get_level_xz_vec_ptr(),
access.get_xz_end_vec_ptr(),
access.z_num(level),
access.x_num(level),
level,
blockSize,
block_sums_device + offset);
access.get_xz_end_vec_ptr(),
access.z_num(level),
access.x_num(level),
level,
blockSize,
block_sums_device + offset);
offset += z_blocks_max;
}

Expand Down Expand Up @@ -305,14 +306,14 @@ void compute_ne_rows_cuda(GPUAccessHelper& access, VectorData<int>& ne_count, Sc

fill_ne_rows_cuda<<< grid_dim, block_dim >>>
(access.get_level_xz_vec_ptr(),
access.get_xz_end_vec_ptr(),
access.z_num(level),
access.x_num(level),
level,
blockSize,
ne_sz,
ne_count[level],
ne_rows_gpu.get());
access.get_xz_end_vec_ptr(),
access.z_num(level),
access.x_num(level),
level,
blockSize,
ne_sz,
ne_count[level],
ne_rows_gpu.get());
}

error_check( cudaFree(block_sums_device) )
Expand Down
2 changes: 1 addition & 1 deletion vcpkg
Submodule vcpkg updated 6351 files
24 changes: 17 additions & 7 deletions vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,20 @@
"name": "libapr",
"version-string": "0.0.1",
"dependencies": [
"blosc",
"hdf5",
"szip",
"gtest",
"tiff"
]
}
{
"name": "blosc"
},
{
"name": "hdf5",
"version>=": "1.8.20"
},
{
"name": "szip"
},
{
"name": "tiff",
"version>=": "4.0"
}
],
"builtin-baseline": "486a4640db740f5994e492eb60748111dfc48de7"
}

0 comments on commit 003270b

Please sign in to comment.