Skip to content

Commit

Permalink
update examples with new vec ops (#388)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChickenLover authored Feb 21, 2024
1 parent f975598 commit 965bf75
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
12 changes: 6 additions & 6 deletions examples/c++/multiply/example.cu
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@

using namespace curve_config;

// select scalar or point field
//typedef scalar_t T;
typedef point_field_t T;
typedef scalar_t T;

int vector_mult(T* vec_b, T* vec_a, T* vec_result, size_t n_elments, device_context::DeviceContext ctx)
{
const bool is_on_device = true;
const bool is_montgomery = false;
cudaError_t err = vec_ops::Mul<T,T>(vec_a, vec_b, n_elments, is_on_device, is_montgomery, ctx, vec_result);
vec_ops::VecOpsConfig<scalar_t> config = vec_ops::DefaultVecOpsConfig<scalar_t>();
config.is_a_on_device = true;
config.is_b_on_device = true;
config.is_result_on_device = true;
cudaError_t err = vec_ops::Mul<T>(vec_a, vec_b, n_elments, config, vec_result);
if (err != cudaSuccess) {
std::cerr << "Failed to multiply vectors - " << cudaGetErrorString(err) << std::endl;
return 0;
Expand Down
10 changes: 9 additions & 1 deletion examples/c++/polynomial_multiplication/example.cu
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,16 @@ int main(int argc, char** argv)

// (4) multiply A,B
CHK_IF_RETURN(cudaMallocAsync(&MulGpu, sizeof(test_data) * NTT_SIZE, ntt_config.ctx.stream));
vec_ops::VecOpsConfig<test_data> config {
ntt_config.ctx,
true, // is_a_on_device
true, // is_b_on_device
true, // is_result_on_device
false, // is_montgomery
false // is_async
};
CHK_IF_RETURN(
vec_ops::Mul(GpuA, GpuB, NTT_SIZE, true /*=is_on_device*/, false /*=is_montgomery*/, ntt_config.ctx, MulGpu));
vec_ops::Mul(GpuA, GpuB, NTT_SIZE, config, MulGpu));

// (5) INTT (in place)
ntt_config.are_inputs_on_device = true;
Expand Down

0 comments on commit 965bf75

Please sign in to comment.