{"id":230,"date":"2010-12-15T11:34:47","date_gmt":"2010-12-15T10:34:47","guid":{"rendered":"http:\/\/numbercrunch.de\/blog\/?p=230"},"modified":"2023-01-18T23:42:51","modified_gmt":"2023-01-18T22:42:51","slug":"new-trng-release-4","status":"publish","type":"post","link":"https:\/\/www.numbercrunch.de\/blog\/2010\/12\/new-trng-release-4\/","title":{"rendered":"New TRNG release"},"content":{"rendered":"<p style=\"text-align: justify;\">A new version of <a href=\"http:\/\/trng.berlios.de\">TRNG<\/a> (Tina\u2019s Random Number Generator Library) has been released. TRNG may be utilized in sequential as well as in parallel Monte Carlo simulations. It does not depend on a specific parallelization technique, e.g., POSIX threads, MPI or others. As an outstanding new feature of the latest TRNG release 4.11 it also supports <a href=\"http:\/\/www.nvidia.com\/cuda\">CUDA<\/a>. See <a href=\"http:\/\/trng.berlios.de\/trng.pdf\">TRNG documentation<\/a> for details. If you need a modern C++ random number generator library for sequential or parallel Monte Carlo then check out <a href=\"http:\/\/developer.berlios.de\/project\/showfiles.php?group_id=9049\">TRNG 4.11<\/a>.<\/p>\n<p style=\"text-align: justify;\">The following piece of C++ code exemplifies how to use TRNG in a CUDA program. See <a href=\"http:\/\/trng.berlios.de\/trng.pdf\">TRNG documentation<\/a> for details.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"cpp\">#include &lt;cstdlib&gt;\n#include &lt;iostream&gt;\n#include &lt;trng\/yarn5s.hpp&gt;\n#include &lt;trng\/uniform01_dist.hpp&gt;\n\n__global__\nvoid parallel_pi(long samples, long *in, trng::yarn5s r) {\n  long rank=threadIdx.x;\n  long size=blockDim.x;\n  r.jump(2*(rank*samples\/size));      \/\/ jump ahead\n  trng::uniform01_dist&lt;float&gt; u;      \/\/ random number distribution\n  in[rank]=0;                         \/\/ local number of points in circle\n  for (long i=rank*samples\/size; i&lt;(rank+1)*samples\/size; ++i) {\n    float x=u(r), y=u(r);             \/\/ choose random x- and y-coordinates\n    if (x*x+y*y&lt;=1)                   \/\/ is point in circle?\n      ++in[rank];                     \/\/ increase thread-local counter\n  }\n}\n\nint main(int argc, char *argv[]) {\n  const long samples=1000000l;             \/\/ total number of points in square\n  const int size=128;                      \/\/ number of threads\n  long *in_device;\n  cudaMalloc(&amp;in_device, size*sizeof(*in_device));\n  trng::yarn5s r;\n  \/\/ start parallel Monte Carlo\n  parallel_pi&lt;&lt;&lt;1, size&gt;&gt;&gt;(samples, in_device, r);\n  \/\/ gather results\n  long *in=new long[size];\n  cudaMemcpy(in, in_device, size*sizeof(*in), cudaMemcpyDeviceToHost);\n  long sum=0;\n  for (int rank=0; rank&lt;size; ++rank) \n    sum+=in[rank];\n  \/\/ print result\n  std::cout &lt;&lt; \"pi = \" &lt;&lt; 4.0*sum\/samples &lt;&lt; std::endl;\n  return EXIT_SUCCESS;\n}\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>A new version of TRNG (Tina\u2019s Random Number Generator Library) has been released. TRNG may be utilized in sequential as well as in parallel Monte Carlo simulations. It does not depend on a specific parallelization technique, e.g., POSIX threads, MPI or others. As an outstanding new feature of the latest TRNG release 4.11 it also&hellip; <a href=\"https:\/\/www.numbercrunch.de\/blog\/2010\/12\/new-trng-release-4\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">New TRNG release<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13,5,6],"tags":[],"class_list":["post-230","post","type-post","status-publish","format-standard","hentry","category-gpu-computing","category-software","category-trng"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>New TRNG release - Number Crunch<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.numbercrunch.de\/blog\/2010\/12\/new-trng-release-4\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"New TRNG release - Number Crunch\" \/>\n<meta property=\"og:description\" content=\"A new version of TRNG (Tina\u2019s Random Number Generator Library) has been released. TRNG may be utilized in sequential as well as in parallel Monte Carlo simulations. It does not depend on a specific parallelization technique, e.g., POSIX threads, MPI or others. As an outstanding new feature of the latest TRNG release 4.11 it also&hellip; Continue reading New TRNG release\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.numbercrunch.de\/blog\/2010\/12\/new-trng-release-4\/\" \/>\n<meta property=\"og:site_name\" content=\"Number Crunch\" \/>\n<meta property=\"article:published_time\" content=\"2010-12-15T10:34:47+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-01-18T22:42:51+00:00\" \/>\n<meta name=\"author\" content=\"Heiko Bauke\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Heiko Bauke\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.numbercrunch.de\/blog\/2010\/12\/new-trng-release-4\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.numbercrunch.de\/blog\/2010\/12\/new-trng-release-4\/\"},\"author\":{\"name\":\"Heiko Bauke\",\"@id\":\"https:\/\/www.numbercrunch.de\/blog\/#\/schema\/person\/e73eab65b1721dd0c3d408edb887e413\"},\"headline\":\"New TRNG release\",\"datePublished\":\"2010-12-15T10:34:47+00:00\",\"dateModified\":\"2023-01-18T22:42:51+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.numbercrunch.de\/blog\/2010\/12\/new-trng-release-4\/\"},\"wordCount\":106,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.numbercrunch.de\/blog\/#\/schema\/person\/e73eab65b1721dd0c3d408edb887e413\"},\"articleSection\":[\"GPU computing\",\"Software\",\"TRNG\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.numbercrunch.de\/blog\/2010\/12\/new-trng-release-4\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.numbercrunch.de\/blog\/2010\/12\/new-trng-release-4\/\",\"url\":\"https:\/\/www.numbercrunch.de\/blog\/2010\/12\/new-trng-release-4\/\",\"name\":\"New TRNG release - Number Crunch\",\"isPartOf\":{\"@id\":\"https:\/\/www.numbercrunch.de\/blog\/#website\"},\"datePublished\":\"2010-12-15T10:34:47+00:00\",\"dateModified\":\"2023-01-18T22:42:51+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.numbercrunch.de\/blog\/2010\/12\/new-trng-release-4\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.numbercrunch.de\/blog\/2010\/12\/new-trng-release-4\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.numbercrunch.de\/blog\/2010\/12\/new-trng-release-4\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.numbercrunch.de\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"New TRNG release\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.numbercrunch.de\/blog\/#website\",\"url\":\"https:\/\/www.numbercrunch.de\/blog\/\",\"name\":\"Number Crunch\",\"description\":\"A computational science blog.\",\"publisher\":{\"@id\":\"https:\/\/www.numbercrunch.de\/blog\/#\/schema\/person\/e73eab65b1721dd0c3d408edb887e413\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.numbercrunch.de\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/www.numbercrunch.de\/blog\/#\/schema\/person\/e73eab65b1721dd0c3d408edb887e413\",\"name\":\"Heiko Bauke\",\"logo\":{\"@id\":\"https:\/\/www.numbercrunch.de\/blog\/#\/schema\/person\/image\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"New TRNG release - Number Crunch","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.numbercrunch.de\/blog\/2010\/12\/new-trng-release-4\/","og_locale":"en_US","og_type":"article","og_title":"New TRNG release - Number Crunch","og_description":"A new version of TRNG (Tina\u2019s Random Number Generator Library) has been released. TRNG may be utilized in sequential as well as in parallel Monte Carlo simulations. It does not depend on a specific parallelization technique, e.g., POSIX threads, MPI or others. As an outstanding new feature of the latest TRNG release 4.11 it also&hellip; Continue reading New TRNG release","og_url":"https:\/\/www.numbercrunch.de\/blog\/2010\/12\/new-trng-release-4\/","og_site_name":"Number Crunch","article_published_time":"2010-12-15T10:34:47+00:00","article_modified_time":"2023-01-18T22:42:51+00:00","author":"Heiko Bauke","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Heiko Bauke","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.numbercrunch.de\/blog\/2010\/12\/new-trng-release-4\/#article","isPartOf":{"@id":"https:\/\/www.numbercrunch.de\/blog\/2010\/12\/new-trng-release-4\/"},"author":{"name":"Heiko Bauke","@id":"https:\/\/www.numbercrunch.de\/blog\/#\/schema\/person\/e73eab65b1721dd0c3d408edb887e413"},"headline":"New TRNG release","datePublished":"2010-12-15T10:34:47+00:00","dateModified":"2023-01-18T22:42:51+00:00","mainEntityOfPage":{"@id":"https:\/\/www.numbercrunch.de\/blog\/2010\/12\/new-trng-release-4\/"},"wordCount":106,"commentCount":0,"publisher":{"@id":"https:\/\/www.numbercrunch.de\/blog\/#\/schema\/person\/e73eab65b1721dd0c3d408edb887e413"},"articleSection":["GPU computing","Software","TRNG"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.numbercrunch.de\/blog\/2010\/12\/new-trng-release-4\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.numbercrunch.de\/blog\/2010\/12\/new-trng-release-4\/","url":"https:\/\/www.numbercrunch.de\/blog\/2010\/12\/new-trng-release-4\/","name":"New TRNG release - Number Crunch","isPartOf":{"@id":"https:\/\/www.numbercrunch.de\/blog\/#website"},"datePublished":"2010-12-15T10:34:47+00:00","dateModified":"2023-01-18T22:42:51+00:00","breadcrumb":{"@id":"https:\/\/www.numbercrunch.de\/blog\/2010\/12\/new-trng-release-4\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.numbercrunch.de\/blog\/2010\/12\/new-trng-release-4\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.numbercrunch.de\/blog\/2010\/12\/new-trng-release-4\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.numbercrunch.de\/blog\/"},{"@type":"ListItem","position":2,"name":"New TRNG release"}]},{"@type":"WebSite","@id":"https:\/\/www.numbercrunch.de\/blog\/#website","url":"https:\/\/www.numbercrunch.de\/blog\/","name":"Number Crunch","description":"A computational science blog.","publisher":{"@id":"https:\/\/www.numbercrunch.de\/blog\/#\/schema\/person\/e73eab65b1721dd0c3d408edb887e413"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.numbercrunch.de\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/www.numbercrunch.de\/blog\/#\/schema\/person\/e73eab65b1721dd0c3d408edb887e413","name":"Heiko Bauke","logo":{"@id":"https:\/\/www.numbercrunch.de\/blog\/#\/schema\/person\/image\/"}}]}},"_links":{"self":[{"href":"https:\/\/www.numbercrunch.de\/blog\/wp-json\/wp\/v2\/posts\/230"}],"collection":[{"href":"https:\/\/www.numbercrunch.de\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.numbercrunch.de\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.numbercrunch.de\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.numbercrunch.de\/blog\/wp-json\/wp\/v2\/comments?post=230"}],"version-history":[{"count":10,"href":"https:\/\/www.numbercrunch.de\/blog\/wp-json\/wp\/v2\/posts\/230\/revisions"}],"predecessor-version":[{"id":998,"href":"https:\/\/www.numbercrunch.de\/blog\/wp-json\/wp\/v2\/posts\/230\/revisions\/998"}],"wp:attachment":[{"href":"https:\/\/www.numbercrunch.de\/blog\/wp-json\/wp\/v2\/media?parent=230"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.numbercrunch.de\/blog\/wp-json\/wp\/v2\/categories?post=230"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.numbercrunch.de\/blog\/wp-json\/wp\/v2\/tags?post=230"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}