<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	
	xmlns:georss="http://www.georss.org/georss"
	xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
	>

<channel>
	<title>3GB boot switch Archives - CenterSpace</title>
	<atom:link href="https://www.centerspace.net/tag/3gb-boot-switch/feed" rel="self" type="application/rss+xml" />
	<link>https://www.centerspace.net/tag/3gb-boot-switch</link>
	<description>.NET numerical class libraries</description>
	<lastBuildDate>Wed, 08 Jun 2016 17:04:13 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.1.1</generator>
<site xmlns="com-wordpress:feed-additions:1">104092929</site>	<item>
		<title>Large matrices and vectors</title>
		<link>https://www.centerspace.net/large-matrices-and-vectors</link>
					<comments>https://www.centerspace.net/large-matrices-and-vectors#comments</comments>
		
		<dc:creator><![CDATA[Trevor Misfeldt]]></dc:creator>
		<pubDate>Fri, 27 Jul 2012 10:00:33 +0000</pubDate>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[NMath]]></category>
		<category><![CDATA[3GB boot switch]]></category>
		<category><![CDATA[gcAllowVeryLargeObjects]]></category>
		<category><![CDATA[Large matrices .NET]]></category>
		<category><![CDATA[large matricies]]></category>
		<category><![CDATA[massive matricies]]></category>
		<category><![CDATA[massive vectors]]></category>
		<guid isPermaLink="false">http://www.centerspace.net/blog/?p=221</guid>

					<description><![CDATA[<p>Customers frequently ask us the size of the largest matrix they can instantiate. With recent developments at Microsoft the maximum object size now significantly depends on your OS (x86 or x64) and the version of .NET your application is referencing. With .NET 4.5 huge matrices can be created that far exceed the current 2GByte limit. [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://www.centerspace.net/large-matrices-and-vectors">Large matrices and vectors</a> appeared first on <a rel="nofollow" href="https://www.centerspace.net">CenterSpace</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Customers frequently ask us the size of the largest matrix they can instantiate.  With recent developments at Microsoft the maximum object size now significantly depends on your OS (x86 or x64) and the version of .NET your application is referencing.  With .NET 4.5 huge matrices can be created that far exceed the current 2GByte limit.</p>
<h2> Pre .NET 4.5 </h2>
<p>Until 2012 all Microsoft 32-bit .NET processes were limited to 1.2GB of memory. Theoretically a matrix could take up most of that space. Let&#8217;s suppose it&#8217;s feasible in our application to have a 1 GB matrix. That matrix would contain 134,217,728 doubles or 268,435,456 floats &#8212; for example, a 11,585 x 11,585 square <code>DoubleMatrix</code> or a 16,384 x 16,384 square <code>FloatMatrix</code>.  </p>
<p>There is a workaround in 32-bit .NET to increase the process memory to 2.4GB.</p>
<ol>
<li>Add the /3GB switch to boot.ini.
<li> After building the application, run the linker as follows:
</ol>
<pre lang="c">
link -edit -LARGEADDRESSAWARE application.exe
</pre>
<p>Increasingly, our customers are switching to 64-bit computing in part to get around these memory limitations. Although a 64-bit .NET process&#8217;s memory is only limited by the available RAM, the .NET runtime nevertheless limits any one object to 2GB. For that reason, our matrices are limited to a theoretical maximum of 402,653,184 doubles or 805,306,368 floats &#8212;for example, a 20,066 x 20,066 square DoubleMatrix or a 28,377 x 28,377 square <code>FloatMatrix</code>.</p>
<p>The good news is that this <b>memory limit has <i>finally</i> been lifted with the release of .NET 4.5</b>.  A big thanks to the Microsoft GC .NET team!  As they well know many developers have been requesting this change.</p>
<h2> .NET 4.5 </h2>
<p>With the .NET 4.5 release developers can now create objects that exceed the 2 GB per object limit <i>only in x64 environments</i>.  In order create these large objects the application must enable the element <code>gcAllowVeryLargeObjects</code> in the run-time schema.  This run-time schema controls the behavior of the .NET garbage collection system.</p>
<pre lang="c" >
&lt;configuration&gt;
  &lt;runtime>
    &lt;gcAllowVeryLargeObjects enabled="true" /&gt;
  &lt;/runtime&gt;
&lt;/configuration&gt;
</pre>
<p>These very large objects are subject to the following reasonable restrictions</p>
<ol>
<li>The maximum number of elements in an array is UInt32.MaxValue.
<li>The maximum index in any single dimension is 2,147,483,591 (0x7FFFFFC7) for byte arrays and arrays of single-byte structures, and 2,146,435,071 (0X7FEFFFFF) for other types.
<li>The maximum size for strings and other non-array objects is unchanged.
</ol>
<p>The brief Microsoft documentation note can be found <a href="https://msdn.microsoft.com/en-us/library/hh285054(v=vs.110).aspx">here</a>.</p>
<h2> What does this mean for NMath? </h2>
<p>First NMath has not yet been released with .NET 4.5 (as of July 2012) so all of the following will hold in the future under such a release.  All current releases are still subject to the limits outlined above.  So looking to the near future, underlying all NMath vectors and matrices is a contiguous 1-D array.  This means that for matrices the number of elements must be less than 2,146,435,071.  The same holds for vectors.  The following table summarizes the maximum size of various NMath objects under .NET 4.5 on a x64 OS with <code>gcAllowVeryLargeObjects</code> enabled.</p>
<pre class="code">
<table>
<tr><th> Class object</th>           <th> Maximum size - elements </th>           <th> Memory size - bytes </th> </tr> 
<tr><td> <code> FloatVector </code> </td> <td>  2,146,435,071 </td>       <td> 7.996 GBytes </td> </tr>
<tr><td> <code> DoubleVector </code> </td> <td>  2,146,435,071 </td>       <td> 15.992 GBytes </td> </tr>
<tr><td> <code> FloatMatrix </code> </td> <td>  2,146,435,071 </td>       <td> 7.996 GBytes </td> </tr>
<tr><td> <code> DoubleMatrix</code> </td> <td>  2,146,435,071 </td>       <td> 15.992 GBytes </td> </tr>
</table></pre>
<p>The <code>Complex</code> versions of these classes would have the same maximum number of elements but occupy twice the memory.  This also means that we will soon be able to allocate a square matrix with a maximum size of <code>[ 46329 x 46329 ]</code>.</p>
<p>&#8211; Trevor &#038; Paul</p>
<h2>NMath 5.3</h2>
<p>We have confirmed that the currently shipping version of NMath (version 5.3) can handle very large objects if you use <code>gcAllowVeryLargeObjects</code> and you are targeting .NET 4.5. We have created DoubleMatrix objects as large as 30,000 x 30,000 in this way. That&#8217;s a 6.7GB object.</p>
<p>&#8211; Trevor</p>
<h2>Large Matrices in a Web Environment</h2>
<p>It was reported to CenterSpace that the configuration change did not work in web environments. We confirmed this to be true. The good news is that there&#8217;s a workaround developed by Microsoft. A Microsoft developer says:</p>
<p>Essentially, the reason it can&#8217;t be done at the application-level Web.config is that this particular setting can only be set per-process and only when the CLR is initializing.  Since the CLR is already initialized by the time we start reading your Web.config, it&#8217;s too late to do anything about it at that time.  Using CLRConfigFile should work around this by allowing you to specify an intermediate configuration file that the CLR can use for initialization.  Then once the CLR is up, ASP.NET will read your Web.config and run your application as normal.</p>
<p>More info here: <a href="http://weblogs.asp.net/owscott/setting-an-aspnet-config-file-per-application-pool" title="Web workaround">here</a></p>
<p>We have verified that this works.</p>
<p>&#8211; Trevor</p>
<p>The post <a rel="nofollow" href="https://www.centerspace.net/large-matrices-and-vectors">Large matrices and vectors</a> appeared first on <a rel="nofollow" href="https://www.centerspace.net">CenterSpace</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.centerspace.net/large-matrices-and-vectors/feed</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">221</post-id>	</item>
	</channel>
</rss>
