400Ping commented on code in PR #677:
URL: https://github.com/apache/mahout/pull/677#discussion_r2589598226


##########
qdp/qdp-kernels/src/amplitude.cu:
##########
@@ -14,17 +14,27 @@
 #include <cuda_runtime.h>
 #include <cuComplex.h>
 
+__global__ void amplitude_encode_kernel(
+    const double* __restrict__ input,
+    cuDoubleComplex* __restrict__ state,
+    size_t input_len,
+    size_t state_len,
+    double norm
+) {
+    size_t idx = blockIdx.x * blockDim.x + threadIdx.x;
+    if (idx >= state_len) return;
+
+    double real_part = 0.0;
+    if (idx < input_len) {
+        real_part = input[idx] / norm;

Review Comment:
   +1 agree, Also should we explicitly guard against norm <= 0.0 on the host 
side and return cudaErrorInvalidValue instead of relying on undefined 0 / 0 
behavior in the kernel?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to