From e2b45a5b2504f704caa4842c440ffb2760b1816d Mon Sep 17 00:00:00 2001 From: tyduc45 Date: Tue, 28 Jul 2026 13:50:45 +0000 Subject: [PATCH] Fix out-of-bounds TaskListPtr for last pthread worker in UnifiedMemoryStreams Fix: the starting offset for the last thread does not need the remainder term; only taskSize does. --- .../UnifiedMemoryStreams/UnifiedMemoryStreams.cu | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cpp/0_Introduction/UnifiedMemoryStreams/UnifiedMemoryStreams.cu b/cpp/0_Introduction/UnifiedMemoryStreams/UnifiedMemoryStreams.cu index cbede7d60..832124dc8 100644 --- a/cpp/0_Introduction/UnifiedMemoryStreams/UnifiedMemoryStreams.cu +++ b/cpp/0_Introduction/UnifiedMemoryStreams/UnifiedMemoryStreams.cu @@ -299,8 +299,7 @@ int main(int argc, char **argv) else { if (i == nthreads - 1) { InputToThreads[i].taskSize = (TaskList.size() / nthreads) + (TaskList.size() % nthreads); - InputToThreads[i].TaskListPtr = - &TaskList[i * (TaskList.size() / nthreads) + (TaskList.size() % nthreads)]; + InputToThreads[i].TaskListPtr = &TaskList[i * (TaskList.size() / nthreads)]; } else { InputToThreads[i].taskSize = (TaskList.size() / nthreads);