<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[einfaches OpenMP-Beispiel]]></title><description><![CDATA[<p>Ich wollte mir mal OpenMP anschauen und habe einfach mal ein kleines Beispiel kopiert:</p>
<pre><code>#include &lt;iostream&gt;
#include &lt;omp.h&gt;

int main(int argc, const char **argv)
{
    #pragma omp parallel
    {
        int nloops = 0;

        #pragma omp for 
        for (int i=0; i&lt;1000000; ++i)
        {
            ++nloops;
        }

        int thread_id = omp_get_thread_num();

        std::cout &lt;&lt; &quot;Thread &quot; &lt;&lt; thread_id &lt;&lt; &quot; performed &quot;
                  &lt;&lt; nloops &lt;&lt; &quot; iterations of the loop.\n&quot;;
    }

    return 0;
}
</code></pre>
<p>Mein Output:</p>
<blockquote>
<p>Thread Thread Thread Thread 910 performed 833336Thread performed 83333 iterations of the loop.<br />
Thread 0 performed 83334 iterations of the loop.<br />
Thread 3 performed 83334 iterations of the loop.<br />
iterations of the loop.<br />
performed 83333 iterations of the loop.<br />
Thread 2 performed 83334 iterations of the loop.<br />
Thread 4 performed 83333 iterations of the loop.<br />
11 performed 83333 iterations of the loop.<br />
7 performed 83333 iterations of the loop.<br />
Thread 1 performed 83334 iterations of the loop.<br />
Thread 8 performed 83333 iterations of the loop.<br />
Thread 5 performed 83333 iterations of the loop.</p>
</blockquote>
<p>Ich verstehe nicht so ganz, warum das nicht funktioniert.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/330572/einfaches-openmp-beispiel</link><generator>RSS for Node</generator><lastBuildDate>Fri, 03 Jul 2026 01:17:58 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/330572.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 16 Jan 2015 19:07:54 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to einfaches OpenMP-Beispiel on Fri, 16 Jan 2015 19:07:54 GMT]]></title><description><![CDATA[<p>Ich wollte mir mal OpenMP anschauen und habe einfach mal ein kleines Beispiel kopiert:</p>
<pre><code>#include &lt;iostream&gt;
#include &lt;omp.h&gt;

int main(int argc, const char **argv)
{
    #pragma omp parallel
    {
        int nloops = 0;

        #pragma omp for 
        for (int i=0; i&lt;1000000; ++i)
        {
            ++nloops;
        }

        int thread_id = omp_get_thread_num();

        std::cout &lt;&lt; &quot;Thread &quot; &lt;&lt; thread_id &lt;&lt; &quot; performed &quot;
                  &lt;&lt; nloops &lt;&lt; &quot; iterations of the loop.\n&quot;;
    }

    return 0;
}
</code></pre>
<p>Mein Output:</p>
<blockquote>
<p>Thread Thread Thread Thread 910 performed 833336Thread performed 83333 iterations of the loop.<br />
Thread 0 performed 83334 iterations of the loop.<br />
Thread 3 performed 83334 iterations of the loop.<br />
iterations of the loop.<br />
performed 83333 iterations of the loop.<br />
Thread 2 performed 83334 iterations of the loop.<br />
Thread 4 performed 83333 iterations of the loop.<br />
11 performed 83333 iterations of the loop.<br />
7 performed 83333 iterations of the loop.<br />
Thread 1 performed 83334 iterations of the loop.<br />
Thread 8 performed 83333 iterations of the loop.<br />
Thread 5 performed 83333 iterations of the loop.</p>
</blockquote>
<p>Ich verstehe nicht so ganz, warum das nicht funktioniert.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2437927</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2437927</guid><dc:creator><![CDATA[SLx64]]></dc:creator><pubDate>Fri, 16 Jan 2015 19:07:54 GMT</pubDate></item><item><title><![CDATA[Reply to einfaches OpenMP-Beispiel on Fri, 16 Jan 2015 20:07:10 GMT]]></title><description><![CDATA[<p>Deine Ausgabe ist nicht threadsafe, die Threads interrupten sich gegenseitig und schreiben dann selber etwas. Du brauchst eine Mutex.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2437932</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2437932</guid><dc:creator><![CDATA[Nathan]]></dc:creator><pubDate>Fri, 16 Jan 2015 20:07:10 GMT</pubDate></item><item><title><![CDATA[Reply to einfaches OpenMP-Beispiel on Fri, 16 Jan 2015 20:14:29 GMT]]></title><description><![CDATA[<p>SLx64 schrieb:</p>
<blockquote>
<p>Ich wollte mir mal OpenMP anschauen</p>
</blockquote>
<p>OpenMP ist nicht mehr zeitgemäss. Nimm lieber TBB oder so.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2437934</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2437934</guid><dc:creator><![CDATA[omgomp]]></dc:creator><pubDate>Fri, 16 Jan 2015 20:14:29 GMT</pubDate></item><item><title><![CDATA[Reply to einfaches OpenMP-Beispiel on Sat, 17 Jan 2015 15:34:09 GMT]]></title><description><![CDATA[<p>Ah okay danke! <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2438048</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2438048</guid><dc:creator><![CDATA[SLx64]]></dc:creator><pubDate>Sat, 17 Jan 2015 15:34:09 GMT</pubDate></item></channel></rss>