{"action":"created","issue":{"url":"https://api.github.com/repos/myurtoglu/cudaforengineers/issues/1","repository_url":"https://api.github.com/repos/myurtoglu/cudaforengineers","labels_url":"https://api.github.com/repos/myurtoglu/cudaforengineers/issues/1/labels{/name}","comments_url":"https://api.github.com/repos/myurtoglu/cudaforengineers/issues/1/comments","events_url":"https://api.github.com/repos/myurtoglu/cudaforengineers/issues/1/events","html_url":"https://github.com/myurtoglu/cudaforengineers/issues/1","id":134180128,"number":1,"title":"dd_1d_shared code question","user":{"login":"yoshi95","id":1912743,"avatar_url":"https://avatars.githubusercontent.com/u/1912743?v=3","gravatar_id":"","url":"https://api.github.com/users/yoshi95","html_url":"https://github.com/yoshi95","followers_url":"https://api.github.com/users/yoshi95/followers","following_url":"https://api.github.com/users/yoshi95/following{/other_user}","gists_url":"https://api.github.com/users/yoshi95/gists{/gist_id}","starred_url":"https://api.github.com/users/yoshi95/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yoshi95/subscriptions","organizations_url":"https://api.github.com/users/yoshi95/orgs","repos_url":"https://api.github.com/users/yoshi95/repos","events_url":"https://api.github.com/users/yoshi95/events{/privacy}","received_events_url":"https://api.github.com/users/yoshi95/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-02-17T05:08:33Z","updated_at":"2016-02-17T19:48:00Z","closed_at":"2016-02-17T19:48:00Z","body":"@myurtoglu\r\n\r\nhi, wondering why the following works\r\nin this line (https://github.com/myurtoglu/cudaforengineers/blob/master/dd_1d_shared/kernel.cu#L18)\r\n`s_in[s_idx - RAD] = d_in[i - RAD];`\r\nfor the 1st thread `threadIdx.x = i = 0`, `i-RAD = -1` and should run into errors for `d_in[i-RAD]` right?"},"comment":{"url":"https://api.github.com/repos/myurtoglu/cudaforengineers/issues/comments/185373220","html_url":"https://github.com/myurtoglu/cudaforengineers/issues/1#issuecomment-185373220","issue_url":"https://api.github.com/repos/myurtoglu/cudaforengineers/issues/1","id":185373220,"user":{"login":"myurtoglu","id":4368431,"avatar_url":"https://avatars.githubusercontent.com/u/4368431?v=3","gravatar_id":"","url":"https://api.github.com/users/myurtoglu","html_url":"https://github.com/myurtoglu","followers_url":"https://api.github.com/users/myurtoglu/followers","following_url":"https://api.github.com/users/myurtoglu/following{/other_user}","gists_url":"https://api.github.com/users/myurtoglu/gists{/gist_id}","starred_url":"https://api.github.com/users/myurtoglu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/myurtoglu/subscriptions","organizations_url":"https://api.github.com/users/myurtoglu/orgs","repos_url":"https://api.github.com/users/myurtoglu/repos","events_url":"https://api.github.com/users/myurtoglu/events{/privacy}","received_events_url":"https://api.github.com/users/myurtoglu/received_events","type":"User","site_admin":false},"created_at":"2016-02-17T19:47:59Z","updated_at":"2016-02-17T19:47:59Z","body":"Hi @yoshi95, except the first block, the first thread reads still some meaningful and important value since `threadIdx.x = 0` does not necessarily mean `i = 0`. However, for the first block, first thread case, it is indeed `-1`. Since there is no bounds checking in C/C++, `d_in[-1]` results in reading of some garbage value. This is not a big deal, since that only affects `result_parallel[0]`, and `result_parallel[0]` is not taken into account [here](https://github.com/myurtoglu/cudaforengineers/blob/master/dd_1d_shared/main.cpp#L22-L25). The reasoning behind this is; there should be some boundary condition actually prescribed (i.e. Dirichlet Boundary conditions) and we haven't specified it, so we don't worry about it."}}