{"id":714,"date":"2016-02-12T14:52:06","date_gmt":"2016-02-12T14:52:06","guid":{"rendered":"http:\/\/coolt.ch\/notizen\/?p=714"},"modified":"2016-02-12T14:52:06","modified_gmt":"2016-02-12T14:52:06","slug":"cuda-paralleles-programmieren","status":"publish","type":"post","link":"https:\/\/coolt.ch\/notizen\/cuda-paralleles-programmieren\/","title":{"rendered":"CUDA paralleles Programmieren"},"content":{"rendered":"<p><strong>N-mal Funktion parallel ausf\u00fchren<\/strong><\/p>\n<pre class=\"lang:sh decode:true\">__global__ void add( int *a, int *b, int *c){\r\n.      *c = *a + *b;\r\n}\r\n\r\n\/\/ Funktion add() wird 1-mal ausgef\u00fchrt\r\nadd&lt;&lt;&lt; <strong>1<\/strong>, 1 &gt;&gt;&gt;( dev_a, dev_b, dev_c );\r\n\r\n\/\/ Funktion add() wird N-mal ausgef\u00fchrt\r\nadd&lt;&lt;&lt; <strong>N<\/strong>, 1 &gt;&gt;&gt;( dev_a, dev_b, dev_c );<\/pre>\n<p>Die <strong>Variablen<\/strong> werden dadurch <strong>zu Arrays<\/strong>.<br \/>\na -&gt; a[<strong>N<\/strong>]\u00a0\u00a0\u00a0\u00a0\u00a0 ,\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 b -&gt; b[<strong>N]<\/strong>,\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 c -&gt; c[<strong>N<\/strong>]<\/p>\n<p><strong><br \/>\nZugreifen auf die parallelen Prozesse<\/strong><br \/>\nJeder parallele Prozess l\u00e4uft im Kernel in einem anderen Block. Jeder Block hat seine Id\u00a0\u00a0<span class=\"lang:sh decode:true crayon-inline\">blockIdx.x<\/span>\u00a0 .<br \/>\na[1], b[1], c[1] laufen im Block 1.<\/p>\n<pre class=\"lang:sh decode:true\">c[0] = a[0] + b[0]<\/pre>\n<pre class=\"lang:sh decode:true\">__global__ void add( int *a, int *b, int *c ) {\r\n.      c[blockIdx.x] = a[blockIdx.x] + b[blockIdx.x];\r\n}<\/pre>\n<p>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>N-mal Funktion parallel ausf\u00fchren __global__ void add( int *a, int *b, int *c){ . *c = *a + *b; } \/\/ Funktion add() wird 1-mal ausgef\u00fchrt add&lt;&lt;&lt; 1, 1 &gt;&gt;&gt;( dev_a, dev_b, dev_c ); \/\/ Funktion add() wird N-mal ausgef\u00fchrt add&lt;&lt;&lt; N, 1 &gt;&gt;&gt;( dev_a, dev_b, dev_c ); Die Variablen werden dadurch zu Arrays. a &hellip; <a href=\"https:\/\/coolt.ch\/notizen\/cuda-paralleles-programmieren\/\" class=\"more-link\"><span class=\"screen-reader-text\">CUDA paralleles Programmieren<\/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\/714"}],"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=714"}],"version-history":[{"count":1,"href":"https:\/\/coolt.ch\/notizen\/wp-json\/wp\/v2\/posts\/714\/revisions"}],"predecessor-version":[{"id":1333,"href":"https:\/\/coolt.ch\/notizen\/wp-json\/wp\/v2\/posts\/714\/revisions\/1333"}],"wp:attachment":[{"href":"https:\/\/coolt.ch\/notizen\/wp-json\/wp\/v2\/media?parent=714"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/coolt.ch\/notizen\/wp-json\/wp\/v2\/categories?post=714"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/coolt.ch\/notizen\/wp-json\/wp\/v2\/tags?post=714"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}