-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(gpu): Implements a classical PBS variant that uses thread block …
…cluster and distributed shared memory
- Loading branch information
1 parent
05527c9
commit 20e11ea
Showing
12 changed files
with
1,101 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 28 additions & 24 deletions
52
backends/tfhe-cuda-backend/cuda/src/pbs/programmable_bootstrap.cu
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,44 @@ | ||
#include "programmable_bootstrap.cuh" | ||
|
||
|
||
template <> __device__ int get_this_block_rank(grid_group &group, bool support_dsm) { | ||
template <> | ||
__device__ int get_this_block_rank(grid_group &group, bool support_dsm) { | ||
return blockIdx.y; | ||
} | ||
|
||
template <> __device__ int get_this_block_rank(cluster_group &cluster, bool support_dsm) { | ||
template <> | ||
__device__ double2 * | ||
get_join_buffer_element(int level_id, int glwe_id, grid_group &group, | ||
double2 *global_memory_buffer, uint32_t polynomial_size, | ||
uint32_t glwe_dimension, bool support_dsm) { | ||
double2 *buffer_slice = | ||
global_memory_buffer + | ||
(glwe_id + level_id * (glwe_dimension + 1)) * polynomial_size / 2; | ||
return buffer_slice; | ||
} | ||
|
||
#if CUDA_ARCH >= 900 | ||
template <> | ||
__device__ int get_this_block_rank(cluster_group &cluster, bool support_dsm) { | ||
if (support_dsm) | ||
return cluster.block_rank(); | ||
else | ||
return blockIdx.y; | ||
} | ||
|
||
template<> __device__ double2 *get_join_buffer_element(int i, grid_group &group, | ||
bool support_dsm, | ||
double2 *global_memory_buffer, uint32_t | ||
polynomial_size) { | ||
double2 *buffer_slice = global_memory_buffer + i * polynomial_size / 2; | ||
return buffer_slice; | ||
} | ||
|
||
template<> __device__ double2 *get_join_buffer_element(int i, cluster_group &cluster, | ||
bool support_dsm, | ||
double2 *global_memory_buffer, uint32_t | ||
polynomial_size) { | ||
#if CUDA_ARCH < 900 | ||
double2 *buffer_slice = | ||
global_memory_buffer + blockIdx.y * polynomial_size / 2; | ||
#else | ||
template <> | ||
__device__ double2 * | ||
get_join_buffer_element(int level_id, int glwe_id, cluster_group &cluster, | ||
double2 *global_memory_buffer, uint32_t polynomial_size, | ||
uint32_t glwe_dimension, bool support_dsm) { | ||
double2 *buffer_slice; | ||
if (support_dsm) { | ||
extern __shared__ double2 smem[]; | ||
buffer_slice = cluster.map_shared_rank(smem, i); | ||
buffer_slice = cluster.map_shared_rank( | ||
smem, glwe_id + level_id * (glwe_dimension + 1)); | ||
} else { | ||
buffer_slice = global_memory_buffer + i * polynomial_size / 2; | ||
buffer_slice = | ||
global_memory_buffer + | ||
(glwe_id + level_id * (glwe_dimension + 1)) * polynomial_size / 2; | ||
} | ||
#endif | ||
return buffer_slice; | ||
} | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.