You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mahout.apache.org by hc...@apache.org on 2026/03/17 03:52:49 UTC
(mahout) branch main updated: Hoist loop-invariant norm computation in iqp_encode_batch_kernel_naive (#1198)
This is an automated email from the ASF dual-hosted git repository.
hcr pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/mahout.git
The following commit(s) were added to refs/heads/main by this push:
new 54fcd13dc Hoist loop-invariant norm computation in iqp_encode_batch_kernel_naive (#1198)
54fcd13dc is described below
commit 54fcd13dcb8c3cffd69fe7df1ee64c41286b5e5b
Author: wdskuki <ds...@gmail.com>
AuthorDate: Tue Mar 17 11:52:44 2026 +0800
Hoist loop-invariant norm computation in iqp_encode_batch_kernel_naive (#1198)
---
qdp/qdp-kernels/src/iqp.cu | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/qdp/qdp-kernels/src/iqp.cu b/qdp/qdp-kernels/src/iqp.cu
index 2316c1252..a8a14c505 100644
--- a/qdp/qdp-kernels/src/iqp.cu
+++ b/qdp/qdp-kernels/src/iqp.cu
@@ -251,6 +251,8 @@ __global__ void iqp_encode_batch_kernel_naive(
const size_t total_elements = num_samples * state_len;
const size_t stride = gridDim.x * blockDim.x;
const size_t state_mask = state_len - 1;
+ // Normalize by 1/2^n (state_len = 2^n) - hoisted outside the loop
+ const double norm = 1.0 / (double)state_len;
for (size_t global_idx = blockIdx.x * blockDim.x + threadIdx.x;
global_idx < total_elements;
@@ -261,7 +263,6 @@ __global__ void iqp_encode_batch_kernel_naive(
cuDoubleComplex amp = compute_amplitude_naive(data, z, state_len, num_qubits, enable_zz);
- double norm = 1.0 / (double)state_len;
state_batch[global_idx] = make_cuDoubleComplex(cuCreal(amp) * norm, cuCimag(amp) * norm);
}
}