{"id":717,"date":"2016-02-12T14:50:47","date_gmt":"2016-02-12T14:50:47","guid":{"rendered":"http:\/\/coolt.ch\/notizen\/?p=717"},"modified":"2016-02-12T14:50:47","modified_gmt":"2016-02-12T14:50:47","slug":"cuda-threads-and-blocks","status":"publish","type":"post","link":"https:\/\/coolt.ch\/notizen\/cuda-threads-and-blocks\/","title":{"rendered":"CUDA  Threads and Blocks"},"content":{"rendered":"<p><strong>Einfaches Handling in Cuda<\/strong><br \/>\nCuda ist spezialisert auf das parallele Verarbeiten vieler Elemente (Vektoren).<\/p>\n<p><strong>Bsp:<\/strong><br \/>\n8 Blocks (Funktion wird 8 mal ausgef\u00fchrt) mit<br \/>\nVektoren in der Funktion.<br \/>\nJedes Element des Vektors kann per Thread-Index angesprochen werden.<\/p>\n<p><a href=\"http:\/\/coolt.ch\/notizen\/wp-content\/uploads\/2015\/10\/threads_block1.png\"><img loading=\"lazy\" class=\"alignnone size-full wp-image-720\" src=\"http:\/\/coolt.ch\/notizen\/wp-content\/uploads\/2015\/10\/threads_block1.png\" alt=\"threads_block\" width=\"1249\" height=\"300\" srcset=\"https:\/\/coolt.ch\/notizen\/wp-content\/uploads\/2015\/10\/threads_block1.png 1249w, https:\/\/coolt.ch\/notizen\/wp-content\/uploads\/2015\/10\/threads_block1-300x72.png 300w, https:\/\/coolt.ch\/notizen\/wp-content\/uploads\/2015\/10\/threads_block1-1024x246.png 1024w\" sizes=\"(max-width: 1249px) 100vw, 1249px\" \/><\/a><\/p>\n<p><strong>Zugriff auf ein Element<\/strong><br \/>\nDer Index des Elements ist einfach gebildet<\/p>\n<pre class=\"lang:sh decode:true\">int index = (blockIdx.x * Blocktiefe) + threadIdx.x\r\nint index = (blockId2.2 * 8) + threadId5.5\r\nint index = ( 2 * 8 ) + 5 = 21<\/pre>\n<p><a href=\"http:\/\/coolt.ch\/notizen\/wp-content\/uploads\/2015\/10\/index_cuda.png\"><img loading=\"lazy\" class=\"alignnone size-full wp-image-721\" src=\"http:\/\/coolt.ch\/notizen\/wp-content\/uploads\/2015\/10\/index_cuda.png\" alt=\"index_cuda\" width=\"1253\" height=\"132\" srcset=\"https:\/\/coolt.ch\/notizen\/wp-content\/uploads\/2015\/10\/index_cuda.png 1253w, https:\/\/coolt.ch\/notizen\/wp-content\/uploads\/2015\/10\/index_cuda-300x32.png 300w, https:\/\/coolt.ch\/notizen\/wp-content\/uploads\/2015\/10\/index_cuda-1024x108.png 1024w\" sizes=\"(max-width: 1253px) 100vw, 1253px\" \/><\/a><br \/>\n<strong>Elemente aus verschiedenen Threads und Blocks<\/strong><br \/>\nSofern man genau weiss, wie weit die Daten in den einzelnen Threads generiert sind, k\u00f6nnen Indizes unterschiedlicher Nummern verarbeitet werden<\/p>\n<pre class=\"lang:sh decode:true\">__global__ void add( int *a, int *b, int *c ) {\r\n\r\n.      c[index12] = a[index63] + b[index20];\r\n}<\/pre>\n<p>Dazu braucht es jedoch die Synchronisation der Prozesse, die \u00fcber synctrheads() organisiert werden kann.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Einfaches Handling in Cuda Cuda ist spezialisert auf das parallele Verarbeiten vieler Elemente (Vektoren). Bsp: 8 Blocks (Funktion wird 8 mal ausgef\u00fchrt) mit Vektoren in der Funktion. Jedes Element des Vektors kann per Thread-Index angesprochen werden. Zugriff auf ein Element Der Index des Elements ist einfach gebildet int index = (blockIdx.x * Blocktiefe) + threadIdx.x &hellip; <a href=\"https:\/\/coolt.ch\/notizen\/cuda-threads-and-blocks\/\" class=\"more-link\"><span class=\"screen-reader-text\">CUDA  Threads and Blocks<\/span> weiterlesen<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[80],"tags":[],"_links":{"self":[{"href":"https:\/\/coolt.ch\/notizen\/wp-json\/wp\/v2\/posts\/717"}],"collection":[{"href":"https:\/\/coolt.ch\/notizen\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/coolt.ch\/notizen\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/coolt.ch\/notizen\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/coolt.ch\/notizen\/wp-json\/wp\/v2\/comments?post=717"}],"version-history":[{"count":2,"href":"https:\/\/coolt.ch\/notizen\/wp-json\/wp\/v2\/posts\/717\/revisions"}],"predecessor-version":[{"id":1331,"href":"https:\/\/coolt.ch\/notizen\/wp-json\/wp\/v2\/posts\/717\/revisions\/1331"}],"wp:attachment":[{"href":"https:\/\/coolt.ch\/notizen\/wp-json\/wp\/v2\/media?parent=717"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/coolt.ch\/notizen\/wp-json\/wp\/v2\/categories?post=717"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/coolt.ch\/notizen\/wp-json\/wp\/v2\/tags?post=717"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}