viiccwen opened a new pull request, #941: URL: https://github.com/apache/mahout/pull/941
### Purpose of PR <!-- Describe what this PR does. --> The `l2_norm_batch_kernel` uses vectorized `double2` loads (16-byte alignment required) to compute L2 norms for batched samples. However, when `sample_len` is odd, the base offset `base = sample_idx * sample_len` may be odd, causing `input_batch + base` to be misaligned (offset by 8 bytes instead of 16 bytes). Added alignment handling logic to ensure vectorized loads always start from properly aligned addresses: 1. **Alignment check**: Check if `base` is even (16-byte aligned for `double2`) 2. **Peel first element**: If misaligned, handle the first element separately using a single `double` load 3. **Vectorized loads**: Start vectorized `double2` loads from the second element (`base + 1`), which is guaranteed to be 16-byte aligned 4. **Index separation**: Strictly separate "aligned sub-array index" from "original sample index" to avoid confusion and bugs ### Related Issues or PRs closes #940 ### Changes Made <!-- Please mark one with an "x" --> - [x] Bug fix - [ ] New feature - [ ] Refactoring - [ ] Documentation - [x] Test - [ ] CI/CD pipeline - [ ] Other ### Breaking Changes <!-- Does this PR introduce a breaking change? --> - [ ] Yes - [x] No ### Checklist <!-- Please mark each item with an "x" when complete --> <!-- If not all items are complete, please open this as a **Draft PR**. Once all requirements are met, mark as ready for review. --> - [ ] Added or updated unit tests for all changes - [ ] Added or updated documentation for all changes - [ ] Successfully built and ran all unit tests or manual tests locally - [ ] PR title follows "MAHOUT-XXX: Brief Description" format (if related to an issue) - [ ] Code follows ASF guidelines -- 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]
