<?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/"
	>

<channel>
	<title>Blog of developer Mikkel Ovesen</title>
	<atom:link href="http://blog.ovesens.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.ovesens.net</link>
	<description>My thoughts, stuff I need to remember or things I just want to share with the world</description>
	<lastBuildDate>Thu, 19 Jan 2012 11:55:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>My attempts at installing Umbraco via NuGet</title>
		<link>http://blog.ovesens.net/2011/11/my-attempts-at-installing-umbraco-via-nuget/</link>
		<comments>http://blog.ovesens.net/2011/11/my-attempts-at-installing-umbraco-via-nuget/#comments</comments>
		<pubDate>Mon, 14 Nov 2011 13:19:20 +0000</pubDate>
		<dc:creator>Mikkel Ovesen</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[nuget]]></category>
		<category><![CDATA[umbraco]]></category>
		<category><![CDATA[visual studio]]></category>
		<category><![CDATA[vs]]></category>
		<category><![CDATA[vs2010]]></category>

		<guid isPermaLink="false">http://blog.ovesens.net/?p=461</guid>
		<description><![CDATA[I often use Umbraco as a CMS for my web projects, and NuGet for referencing other libraries. This made me wonder whether Umbraco could be deployed via Nuget. The short answer is, it is possible, but it does not work &#8230; <a href="http://blog.ovesens.net/2011/11/my-attempts-at-installing-umbraco-via-nuget/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I often use <a href="http://umbraco.com/">Umbraco</a> as a CMS for my web projects, and NuGet for referencing other libraries. This made me wonder whether Umbraco could be deployed via Nuget. The short answer is, it is possible, but it does not work very well. Here is my experience.</p>
<p>I started to read the <a href="http://docs.nuget.org/">NuGet docs</a> to figure out what a NuGet package actually is.</p>
<h2>NuGet package</h2>
<p>A NuGet package is a file that makes it easy to add, remove, and update libraries and tools in Visual Studio projects that use the .NET Framework. A NuGet package is comprised by these three things:</p>
<ul>
<li><strong>tools</strong> &#8211; The tools folder of a package is for powershell scripts and programs accessible from the Package Manager Console. After the folder is copied to the target project, it is added to the `$env:Path (PATH) environment variable.</li>
<li><strong>lib</strong> &#8211; Assemblies (.dll files) in the lib folder are added as assembly references when the package is installed.</li>
<li><strong>content</strong> &#8211; Files in the content folder are copied to the root of your application when the package is installed.</li>
</ul>
<div><em><span style="font-size: small;"><span class="Apple-style-span" style="line-height: 24px;">The above is from the <a href="http://docs.nuget.org/docs/creating-packages/creating-and-publishing-a-package">NuGet docs</a>.</span></span></em></div>
<p>The documentation also indicate that NuGet was not designed for a project like Umbraco with so many files and such a complex web.config file. But I wanted to try and see how and if it was actually possible.</p>
<h2>The strategy</h2>
<p>The Umbraco project consists of libraries/assemblies and content, so it should be rather easy to create the NuGet package.</p>
<p>The first step was to download Umbraco 4.7.1 and go through the required assemblies and web.config. Initially I located assemblies that could already be found on NuGet and added these dependencies to the NuGet package. It later showed, that there would be versioning problems which I was not able to fix.</p>
<p>So instead of using dependencies to other NuGet packages as NuGet was actually intended, I  just added all the assemblies released with Umbraco 4.7.1.</p>
<h2>Assemblies</h2>
<p>The assemblies that gave me the most trouble was ClientDependency and ICharpCode.SharpZipLib.</p>
<p>ClientDependency was actually already in the NuGet feed, but the configuration transformation made from that NuGet package combined with the web.config transformation from the Umbraco package, yilded an invalid web.config file.  ClientDependency was therefor provided as an assembly directly from the Umbraco package and not as an external dependency.</p>
<p>The assembly ICSharpCode.SharpZipLib was also found in the NuGet feed, but Umbraco 4.7.1 required a specific version (0.85.5.452) that NuGet could not provide, and this assembly was as such also added as a part of the Umbraco package.</p>
<h2>Web.config</h2>
<p>The web.config configuration file for Umbraco is long and rather complex, and that makes merging of multiple web.config files difficult. The configuration transformation features in NuGet are limited, so you should expect problems when adding the Umbraco package to an existing website. The best results I achieved was when the package was added to an empty website or web application.</p>
<p>But even though a web.config file is almost empty, you should still prepare for some clean up.</p>
<h2>Content</h2>
<p>The <a href="http://umbraco.codeplex.com/releases/view/73692">Umbraco 4.7.1 binary release</a> containes more than 1500 files. NuGet was not designed for this number of files and does not handle it very well. A complete package installation can take up to 5-10 min. depending on you machine and SSD/HDD configuration.</p>
<h2>Example</h2>
<p>The following describes the steps I used to run the Umbraco NuGet package against a web application project and the problems that arose.</p>
<p>1. Open Visual Studio 2010 and create an empty C# web application project</p>
<p>2. Open the NuGet Package Manager Console</p>
<p>3. Write:</p>
<pre>Install-Package "Umbraco" -Source "c:\[NuGetPackageFolder]"</pre>
<p><em>NuGetPackageFolder: Replace with the path to the folder containing the Umbraco.4.7.1.nupkg file. <strong>Important do not give the full path to the file, just the folder</strong></em></p>
<p>4. Hit [ENTER] and wait for NuGet to do its work</p>
<p>5. Wait for the following two messages:</p>
<pre>Successfully installed 'Umbraco 4.7.1'.
Successfully added 'Umbraco 4.7.1' to WebApplication1.</pre>
<p>6. Compile and receive an error from web.config. (Multiple System.Web -&gt; Compilation sections are present)</p>
<p>7. Remove the first and compile and run again</p>
<pre class="brush: xml;">&lt;compilation debug="true" targetFramework="4.0" /&gt;</pre>
<p>8. At this point everything worked and I was able to follow the usual Umbraco installation steps <img src='http://blog.ovesens.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<h2>Conclusion</h2>
<p>Umbraco is a fantastic CMS and NuGet is very cool, but together is not a good idea.</p>
<p>My goal was to find a way for installing Umbraco to a web project via NuGet, and that is not impossible, but I would not recommend it. I find it a lot easier to simply download the Umbraco released ZIP, and then extract and drag all files to my web application project. So that is what I will do <img src='http://blog.ovesens.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>But if you still wants the Umbraco NuGet file, you can download it <a href="/wp-content\uploads/2011/11/Umbraco.4.7.1.nupkg.zip">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ovesens.net/2011/11/my-attempts-at-installing-umbraco-via-nuget/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MacBook Pro BootCamp/Windows keyboard schema</title>
		<link>http://blog.ovesens.net/2011/11/macbook-pro-bootcampwindows-keyboard-schema/</link>
		<comments>http://blog.ovesens.net/2011/11/macbook-pro-bootcampwindows-keyboard-schema/#comments</comments>
		<pubDate>Wed, 09 Nov 2011 20:37:16 +0000</pubDate>
		<dc:creator>Mikkel Ovesen</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[bootcamp]]></category>
		<category><![CDATA[macbook]]></category>
		<category><![CDATA[resharper]]></category>
		<category><![CDATA[shortcut]]></category>
		<category><![CDATA[visual studio]]></category>
		<category><![CDATA[vs2010]]></category>

		<guid isPermaLink="false">http://blog.ovesens.net/?p=370</guid>
		<description><![CDATA[Visual Studio 2010 + Resharper Key Description FN+ALT+[Right arrow] Go to sub types FN+ALT+[Left arrow] Go to super types ALT+SHIFT+F12 Find usages of variable CTRL+SHIFT+F11 Go to type of variable CTRL+SHIFT+R Refactor this CTRL+SHIFT+T Go to file CTRL+T Go to &#8230; <a href="http://blog.ovesens.net/2011/11/macbook-pro-bootcampwindows-keyboard-schema/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<h2>Visual Studio 2010 + Resharper</h2>
<table>
<thead>
<tr>
<th>Key</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>FN+ALT+[Right arrow]</td>
<td>Go to sub types</td>
</tr>
<tr>
<td>FN+ALT+[Left arrow]</td>
<td>Go to super types</td>
</tr>
<tr>
<td>ALT+SHIFT+F12</td>
<td>Find usages of variable</td>
</tr>
<tr>
<td>CTRL+SHIFT+F11</td>
<td>Go to type of variable</td>
</tr>
<tr>
<td>CTRL+SHIFT+R</td>
<td>Refactor this</td>
</tr>
<tr>
<td>CTRL+SHIFT+T</td>
<td>Go to file</td>
</tr>
<tr>
<td>CTRL+T</td>
<td>Go to type</td>
</tr>
<tr>
<td>FN+ALT+[ENTER]</td>
<td>Generate</td>
</tr>
</tbody>
</table>
]]></content:encoded>
			<wfw:commentRss>http://blog.ovesens.net/2011/11/macbook-pro-bootcampwindows-keyboard-schema/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>NHibernate query optimising with HQL expression IN</title>
		<link>http://blog.ovesens.net/2011/11/nhibernate-query-optimising-with-hql-expression-in/</link>
		<comments>http://blog.ovesens.net/2011/11/nhibernate-query-optimising-with-hql-expression-in/#comments</comments>
		<pubDate>Wed, 09 Nov 2011 20:28:42 +0000</pubDate>
		<dc:creator>Mikkel Ovesen</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Personal]]></category>
		<category><![CDATA[nhibernate]]></category>

		<guid isPermaLink="false">http://blog.ovesens.net/?p=430</guid>
		<description><![CDATA[A note for me to remember. I have been doing some optimisation of queries done by NHibernate HQL. To optimise I have rewritten some of them to use the HQL IN expression. Point: important to check the collection parameter, if &#8230; <a href="http://blog.ovesens.net/2011/11/nhibernate-query-optimising-with-hql-expression-in/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>A note for me to remember.</p>
<p>I have been doing some optimisation of queries done by NHibernate HQL. To optimise I have rewritten some of them to use the HQL IN expression.</p>
<p>Point: important to check the collection parameter, if NULL or Empty, NHibernate criteria will fail.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ovesens.net/2011/11/nhibernate-query-optimising-with-hql-expression-in/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using OpenCover and NUnit with MSBuild</title>
		<link>http://blog.ovesens.net/2011/11/using-opencover-and-nunit-with-msbuild/</link>
		<comments>http://blog.ovesens.net/2011/11/using-opencover-and-nunit-with-msbuild/#comments</comments>
		<pubDate>Thu, 03 Nov 2011 08:23:07 +0000</pubDate>
		<dc:creator>Mikkel Ovesen</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[msbuild]]></category>
		<category><![CDATA[nunit]]></category>
		<category><![CDATA[open cover]]></category>
		<category><![CDATA[unit test]]></category>

		<guid isPermaLink="false">http://blog.ovesens.net/?p=442</guid>
		<description><![CDATA[I am working on a project that has a large code base with a lot of logic. For this project I am trying to adopt a more TDD oriented development approach. This includes unit- and integration testing, as well as code &#8230; <a href="http://blog.ovesens.net/2011/11/using-opencover-and-nunit-with-msbuild/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I am working on a project that has a large code base with a lot of logic. For this project I am trying to adopt a more TDD oriented development approach. This includes unit- and integration testing, as well as code coverage, and yes I do know that a high coverage percentage is not the same as good tests, but on the other hand, a low coverage indicates that more tests need to be written.</p>
<p>We are currently using NUnit.2.5.10.11092 and the code coverage tools I was able to find was <a href="http://www.ncover.com">NCover</a>, <a href="http://sourceforge.net/projects/partcover/">PartCover</a> and <a href="https://github.com/sawilde/opencover">OpenCover</a>. NCover is no longer free, and from what I can read it seems like OpenCover is the better choice compared to PartCover.</p>
<p>This <a href="http://www.palmmedia.de/Blog/2011/6/21/code-coverage-testing-with-opencover-and-partcover">blog post</a> describes well some of the differences and features of PartCover vs. OpenCover.</p>
<h2>MSBuild</h2>
<p>This is the MSBuild configuration file that we are currently using to run unit test and code coverage.</p>
<pre class="brush: xml;">&lt;Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0"&gt;

  &lt;!-- Application Configurations --&gt;
  &lt;PropertyGroup&gt;
    &lt;NUnit-ToolPath&gt;..\packages\NUnit.2.5.10.11092\tools\&lt;/NUnit-ToolPath&gt;
    &lt;OpenCover-ToolPath&gt;..\packages\OpenCover.1.0.719\&lt;/OpenCover-ToolPath&gt;
    &lt;ReportGenerator-ToolPath&gt;..\packages\ReportGenerator.1.2.1.0\&lt;/ReportGenerator-ToolPath&gt;
    &lt;MSBuildCommunityTasksPath&gt;$(MSBuildProjectDirectory)\..\Libs\msbuild\&lt;/MSBuildCommunityTasksPath&gt;

    &lt;!-- Add paths to assemblies to test --&gt;
    &lt;TestAssemblies&gt;..\Tests\Core.Tests\bin\Debug\Core.Tests.dll ..\Tests\Model.Tests\bin\Debug\Model.Tests.dll&lt;/TestAssemblies&gt;

  &lt;/PropertyGroup&gt;

  &lt;ItemGroup&gt;
    &lt;AllProjects Include="..\Tests\**\*.csproj" /&gt;
  &lt;/ItemGroup&gt;

  &lt;Target Name="Clean"&gt;
    &lt;MSBuild Projects="@(AllProjects)" Targets="Clean" /&gt;
  &lt;/Target&gt;

  &lt;Target Name="Compile"&gt;
    &lt;MSBuild Projects="@(AllProjects)" Targets="Build" Properties="WarningLevel=1" /&gt;
  &lt;/Target&gt;

  &lt;Target Name="Test" DependsOnTargets="Clean;Compile"&gt;
    &lt;!-- /domain=single is not support by the NUnit msbuild task, and it is required for OpenCover coverage test --&gt;
    &lt;Exec Command="$(NUnit-ToolPath)nunit-console-x86.exe $(TestAssembliesPath) /nologo /noshadow /domain=single /output=test-results.xml" /&gt;
  &lt;/Target&gt;

  &lt;Target Name="Coverage" DependsOnTargets="Clean;Compile"&gt;

    &lt;!-- /domain=single is not support by the NUnit msbuild task, and it is required for OpenCover coverage test --&gt;
    &lt;Exec Command="$(OpenCover-ToolPath)OpenCover.Console.exe -register:user -target:"$(NUnit-ToolPath)nunit-console-x86.exe" -targetargs:"/noshadow $(TestAssembliesPath) /domain:single" -filter:"+[Model]* +[Core]* +[Datalayer]*" -output:coverage.xml" /&gt;
    &lt;Delete Files=".\coveragereport" /&gt;
    &lt;Exec Command="$(ReportGenerator-ToolPath)ReportGenerator.exe coverage.xml "coveragereport" html" /&gt;
    &lt;Exec Command="$(ReportGenerator-ToolPath)ReportGenerator.exe coverage.xml "coveragereport" xmlsummary" /&gt;
    &lt;Delete Files="coverage.xml" /&gt;
  &lt;/Target&gt;

  &lt;Target Name="Build" DependsOnTargets="Clean;Compile;Test;" /&gt;

&lt;/Project&gt;</pre>
<p>Running the different targets from command prompt is easy, just type &#8220;msbuild [MSBUILD CONFIG FILE].xml /t:[TARGET]&#8221;</p>
<p>[MSBUILD CONFIG FILE] should be the name of the file above, [TARGET] can be any of the following Clean, Compile, Test and Coverage.</p>
<p>The Coverage target generates a fine HTML report as well as a XML summary.</p>
<p>Please note that I have not used the NUnit task from MSBuild community as the /domain=single is important, and as it is currently not supported by that task.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ovesens.net/2011/11/using-opencover-and-nunit-with-msbuild/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Visual Studio 2010 Package load errors</title>
		<link>http://blog.ovesens.net/2011/10/visual-studio-2010-package-load-errors/</link>
		<comments>http://blog.ovesens.net/2011/10/visual-studio-2010-package-load-errors/#comments</comments>
		<pubDate>Thu, 20 Oct 2011 07:11:35 +0000</pubDate>
		<dc:creator>Mikkel Ovesen</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[visual studio]]></category>
		<category><![CDATA[vs2010]]></category>

		<guid isPermaLink="false">http://blog.ovesens.net/?p=439</guid>
		<description><![CDATA[My Windows 7 installation on my laptop broke down, and I then had to completely reinstall Windows 7, Visual Studio etc. Besides it being a long and tedious process it seemed to go fine. But I started to get the &#8230; <a href="http://blog.ovesens.net/2011/10/visual-studio-2010-package-load-errors/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>My Windows 7 installation on my laptop broke down, and I then had to completely reinstall Windows 7, Visual Studio etc.</p>
<p>Besides it being a long and tedious process it seemed to go fine. But I started to get the following error messages when Visual Studio 2010 was launched:</p>
<blockquote><p>The &#8216;RadLangSvc.Package, RadLangSvc.VS, Version = 10.0.0.0, Culture = neutral, PublicKeyToken = 89845dcd8080cc91&#8242; failed to load</p></blockquote>
<blockquote><p>VSTS for Database Professionals Sql Server Data-tier Application did not load</p></blockquote>
<p>and some other VSTS packages that was unable to load.</p>
<p>I followed the steps described <a href="http://techsolutions-at-desk.blogspot.com/2011/04/radlangsvcvs-version-10000-culture.html">here</a>, and it worked <img src='http://blog.ovesens.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> . The steps are also described below:</p>
<ol>
<li>Close all running instances of Visual Studio 2010</li>
<li>Install the following MSI packages from the installation CD of VS2010, in the folder  \WCU\DAC</li>
<li>DACProjectSystemSetup_enu.msi</li>
<li>TSqlLanguageService_enu.msi</li>
<li>DACFramework_enu.msi</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://blog.ovesens.net/2011/10/visual-studio-2010-package-load-errors/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Cuda v3.2 template project using C++</title>
		<link>http://blog.ovesens.net/2011/05/cuda-v3-2-template-project-using-cpp/</link>
		<comments>http://blog.ovesens.net/2011/05/cuda-v3-2-template-project-using-cpp/#comments</comments>
		<pubDate>Wed, 18 May 2011 16:59:27 +0000</pubDate>
		<dc:creator>Mikkel Ovesen</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[cuda]]></category>
		<category><![CDATA[gpgpu]]></category>
		<category><![CDATA[gpu]]></category>
		<category><![CDATA[visual studio]]></category>
		<category><![CDATA[vs2008]]></category>

		<guid isPermaLink="false">http://blog.ovesens.net/?p=388</guid>
		<description><![CDATA[Important The tutorial is missing some compilation, linker, library settings steps. However you can download the template project, it works and has everything setup. Introduction Download template project source Download executable I am a developer who has been developing software &#8230; <a href="http://blog.ovesens.net/2011/05/cuda-v3-2-template-project-using-cpp/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<h2>Important</h2>
<p>The tutorial is missing some compilation, linker, library settings steps. However you can download the template project, it works and has everything setup.</p>
<h1>Introduction</h1>
<ul>
<li><a href="/wp-content/uploads/2011/05/CudaTemplate_Cuda_3.2.zip">Download template project source</a></li>
<li><a href="/wp-content/uploads/2011/05/CudaTemplate_exe_Cuda_3.2.zip">Download executable</a></li>
</ul>
<h2><span style="font-size: 16px; color: #444444; line-height: 24px;">I am a developer who has been developing software using .NET and C# for several years. I have never used C or C++, and it has never been required.</span></h2>
<p>I like to investigate new technologies, mainly because I am curious, but also because it could make my daily development work easier or smarter.</p>
<p>Recently my focus has been directed towards GPGPU on the Nvidia Cuda platform.</p>
<p>The programming language for Cuda is called &#8220;Cuda C&#8221;. The name implies that knowledge of C indeed is required for using GPGPU on the Cuda platform.</p>
<p>I discovered that there exist .NET bindings to the Cuda platform and drivers. However, I find their usage complicated and insufficient, and further more kernel development will still have to done in Cuda C.</p>
<p>These fact made me realise that I would have to learn a bit of C and C++ to use Cuda as it was actually intended by Nvidia. Nvidia provides many samples and suggest that a Cuda development environment on Windows could use Visual Studio and Nvidia Parallel NSight for debugging, profiling etc.</p>
<p>As my knowledge of C and C++ development was severely limited, so was the setting up and configuration of Visual Studio 2008 for Cuda C development.</p>
<p>I have read &#8220;Cuda by example&#8230;&#8221; (<a href="http://developer.nvidia.com/object/cuda-by-example.html">http://developer.nvidia.com/object/cuda-by-example.html</a>), &#8220;Programming Massively Parallel Processors&#8230;&#8221; (<a href="http://www.nvidia.com/object/io_1264656303008.html">http://www.nvidia.com/object/io_1264656303008.html</a>) and &#8220;C Programming Language, 2. edition&#8221; (<a href="http://www.pearsonhighered.com/educator/product/C-Programming-Language/9780131103627.page">http://www.pearsonhighered.com/educator/product/C-Programming-Language/9780131103627.page</a>). These books have given me the foundation to start developing using Cuda C and GPGPU.</p>
<p>Setting up Visual Studio 2008 and making the compiler work required some work, but here is what I did.</p>
<h2>1. Download and install driver and toolkit</h2>
<p>Download Cuda toolkit and the developer driver and install. A restart is probably required. (<a href="http://developer.nvidia.com/object/gpucomputing.html">http://developer.nvidia.com/object/gpucomputing.html</a>)</p>
<h2>2. Start Visual Studio 2008, and create a new project of type Win32 Console Application</h2>
<p>Give the project and solution a name (here called Cuda_Template).</p>
<p><a href="http://blog.ovesens.net/wp-content/uploads/2011/05/CudaTemplate_2_create_project..png"><img class="alignnone size-full wp-image-389" title="Step 2 - Create solution and project" src="http://blog.ovesens.net/wp-content/uploads/2011/05/CudaTemplate_2_create_project..png" alt="" width="804" height="572" /></a></p>
<h2>3. Click Next</h2>
<p><a href="http://blog.ovesens.net/wp-content/uploads/2011/05/CudaTemplate_3_click_next.png"><img class="alignnone size-full wp-image-398" title="Step 3 - Click next" src="http://blog.ovesens.net/wp-content/uploads/2011/05/CudaTemplate_3_click_next.png" alt="" width="625" height="530" /></a></p>
<h2>4. Select Console application and check the empty project, then click Finish</h2>
<p><a href="http://blog.ovesens.net/wp-content/uploads/2011/05/CudaTemplate_4_project_settings.png"><img class="alignnone size-full wp-image-399" title="Step 4 - Project settings" src="http://blog.ovesens.net/wp-content/uploads/2011/05/CudaTemplate_4_project_settings.png" alt="" width="625" height="530" /></a></p>
<h2>5. Add new item called main.cpp of type C++ File</h2>
<p><a href="http://blog.ovesens.net/wp-content/uploads/2011/05/CudaTemplate_5_create_cpp_file.png"><img class="alignnone size-full wp-image-400" title="Step 5 - Create C++ file" src="http://blog.ovesens.net/wp-content/uploads/2011/05/CudaTemplate_5_create_cpp_file.png" alt="" width="804" height="514" /></a></p>
<h2>6. Add the following code the file</h2>
<pre class="brush: cpp;">#include &lt;stdio.h&gt; 

int main() {

    printf("Hello world...\n);
    return 0;

}</pre>
<h2>7. Build and try to run the exe file. The output should be</h2>
<p><a href="http://blog.ovesens.net/wp-content/uploads/2011/05/CudaTemplate_7_exe_output.png"><img class="alignnone size-full wp-image-404" title="Step 7 - Hello world output" src="http://blog.ovesens.net/wp-content/uploads/2011/05/CudaTemplate_7_exe_output.png" alt="" width="709" height="359" /></a></p>
<h2>8. Select Project -&gt; Custom Build Rules&#8230;</h2>
<p><a href="http://blog.ovesens.net/wp-content/uploads/2011/05/CudaTemplate_8_custom_build_rules.png"><img class="alignnone size-full wp-image-405" title="Step 8 - Custom build rules" src="http://blog.ovesens.net/wp-content/uploads/2011/05/CudaTemplate_8_custom_build_rules.png" alt="" width="1280" height="760" /></a></p>
<h2>9. Select Cuda Runtime API build rule (v3.2)</h2>
<p><a href="http://blog.ovesens.net/wp-content/uploads/2011/05/CudaTemplate_9_cuda_build_rules.png"><img class="alignnone size-full wp-image-406" title="Step 9 - Cuda build rule" src="http://blog.ovesens.net/wp-content/uploads/2011/05/CudaTemplate_9_cuda_build_rules.png" alt="" width="676" height="433" /></a></p>
<h2>10. Add a new file called kernel.cu</h2>
<p><a href="http://blog.ovesens.net/wp-content/uploads/2011/05/CudaTemplate_10_create_kernel.png"><img class="alignnone size-full wp-image-407" title="Step 10 - Create kernel" src="http://blog.ovesens.net/wp-content/uploads/2011/05/CudaTemplate_10_create_kernel.png" alt="" width="804" height="514" /></a></p>
<h2>11. Add the following to the file kernel.cu</h2>
<pre class="brush: c;">/* power: raise base to n-th power; n &gt;= 0 */
__device__ int devicePower(int base, int n) {

    int p = 1;

    for (int i = 1; i &lt;= n; ++i) {
        p = p * base;
    }

    return p;
}

__global__ void power( int *base, int *n, int *output, int threadMax ) {

    int tid = threadIdx.x + blockIdx.x * blockDim.x;

    if (tid &lt; threadMax) {
        output[tid] = devicePower(base[tid], n[tid]);
    }

}</pre>
<h2>12. Right click the newly created file and select properties</h2>
<p><a href="http://blog.ovesens.net/wp-content/uploads/2011/05/CudaTemplate_12_kernel_properties.png"><img class="alignnone size-full wp-image-414" title="Step 12 - Kernel properties" src="http://blog.ovesens.net/wp-content/uploads/2011/05/CudaTemplate_12_kernel_properties.png" alt="" width="1280" height="760" /></a></p>
<h2>13. Set the &#8220;Exclude From Build&#8221; and make sure that the project still builds</h2>
<p><a href="http://blog.ovesens.net/wp-content/uploads/2011/05/CudaTemplate_13_kernel_exclude_from_build.png"><img class="alignnone size-full wp-image-415" title="Step 13 - Exclude kernel from build" src="http://blog.ovesens.net/wp-content/uploads/2011/05/CudaTemplate_13_kernel_exclude_from_build.png" alt="" width="759" height="531" /></a></p>
<h2>14. Create a new file called call_kernel.cu</h2>
<p><a href="http://blog.ovesens.net/wp-content/uploads/2011/05/CudaTemplate_14_create_kernel_call_file..png"><img class="alignnone size-full wp-image-416" title="Step 14 - Create C++ kernel calling file" src="http://blog.ovesens.net/wp-content/uploads/2011/05/CudaTemplate_14_create_kernel_call_file..png" alt="" width="804" height="514" /></a></p>
<h2>15. Add the following to the file call_kernel.cu</h2>
<pre class="brush: c">#include &lt;cuda_runtime_api.h&gt;
#include "main.h"

// includes, kernels
#include &lt;kernel.cu&gt;

void call_kernel_power(int *base, int *n, int *output, int elementCount) {

    int *dev_base, *dev_n, *dev_output;
    int gridX = (elementCount+ThreadsPerBlock-1)/ThreadsPerBlock;

    cudaMalloc( (void**)&amp;dev_base, elementCount * sizeof(int) );
    cudaMalloc( (void**)&amp;dev_n, elementCount * sizeof(int) );
    cudaMalloc( (void**)&amp;dev_output, elementCount * sizeof(int) );

    cudaMemcpy( dev_base, base, elementCount * sizeof(int), cudaMemcpyHostToDevice);
    cudaMemcpy( dev_n, n, elementCount * sizeof(int), cudaMemcpyHostToDevice);

    power&lt;&lt;&lt;gridX,ThreadsPerBlock&gt;&gt;&gt;(dev_base, dev_n, dev_output, elementCount);

    cudaMemcpy( output, dev_output, elementCount * sizeof(int), cudaMemcpyDeviceToHost);

    cudaFree( dev_base );
    cudaFree( dev_n );
    cudaFree( dev_output );
}</pre>
<h2>16. Create a new header file called main.h</h2>
<p><a href="http://blog.ovesens.net/wp-content/uploads/2011/05/CudaTemplate_16_create_main_header.png"><img class="alignnone size-full wp-image-419" title="Step 16 - Create header main.h file" src="http://blog.ovesens.net/wp-content/uploads/2011/05/CudaTemplate_16_create_main_header.png" alt="" width="804" height="514" /></a></p>
<h2>17. Add the following content to the file</h2>
<pre class="brush: cpp">#define ThreadsPerBlock 128

#include &lt;stdio.h&gt;

void call_kernel_power(int *base, int *n, int *output, int elementCount);</pre>
<h2>18. Update the main.cpp file with the following:</h2>
<pre class="brush: cpp">#include "main.h"

#define N   80000

int main() {

    printf("Power Cuda kernel test from C++\n");
    printf("Testing %d elements\n", N);

    int base[N], n[N], output[N];

    for(int i = 0; i &lt; N; i++) {
          base[i] = 2;
          n[i] = i+1;
          output[i] = 0;
      }

    call_kernel_power(base, n, output, N);

    for(int i = 0; i &lt; N &amp;&amp; i &lt; 15; i++) {

          printf("%d^%d = %d\n", base[i], n[i], output[i]);

      }

      printf("Done\n");

    return 0;
}</pre>
<h2>19. That should be it&#8230;</h2>
<p>You now have a template that you can work from. When you build the file and run it, I get this output:</p>
<p><a href="http://blog.ovesens.net/wp-content/uploads/2011/05/CudaTemplate_19_exe_output.png"><img class="alignnone size-full wp-image-417" title="Step 19 - Output" src="http://blog.ovesens.net/wp-content/uploads/2011/05/CudaTemplate_19_exe_output.png" alt="" width="661" height="487" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ovesens.net/2011/05/cuda-v3-2-template-project-using-cpp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mercurial graph</title>
		<link>http://blog.ovesens.net/2011/05/mercurial-graph/</link>
		<comments>http://blog.ovesens.net/2011/05/mercurial-graph/#comments</comments>
		<pubDate>Wed, 18 May 2011 16:22:41 +0000</pubDate>
		<dc:creator>Mikkel Ovesen</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Fun]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[graph]]></category>
		<category><![CDATA[hg]]></category>
		<category><![CDATA[mercurial]]></category>

		<guid isPermaLink="false">http://blog.ovesens.net/?p=382</guid>
		<description><![CDATA[This is a screenshot of the Mercurial graph, of a project that I am currently is working on. It kind of looks like a string instrument you want to play]]></description>
			<content:encoded><![CDATA[<p>This is a screenshot of the Mercurial graph, of a project that I am currently is working on.</p>
<p>It kind of looks like a string instrument you want to play <img src='http://blog.ovesens.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><a href="http://blog.ovesens.net/wp-content/uploads/2011/05/mercurial-graph.png"><img class="alignnone size-full wp-image-383" title="Mercurial graph" src="http://blog.ovesens.net/wp-content/uploads/2011/05/mercurial-graph.png" alt="" width="439" height="1007" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ovesens.net/2011/05/mercurial-graph/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>NHibernate dirty problem, weird updates in NHprof</title>
		<link>http://blog.ovesens.net/2011/03/nhibernate-dirty-problem-weird-updates-in-nhprof/</link>
		<comments>http://blog.ovesens.net/2011/03/nhibernate-dirty-problem-weird-updates-in-nhprof/#comments</comments>
		<pubDate>Fri, 04 Mar 2011 11:01:40 +0000</pubDate>
		<dc:creator>Mikkel Ovesen</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[debug]]></category>
		<category><![CDATA[nh]]></category>
		<category><![CDATA[nh3]]></category>
		<category><![CDATA[nhibernate]]></category>
		<category><![CDATA[orm]]></category>

		<guid isPermaLink="false">http://blog.ovesens.net/?p=352</guid>
		<description><![CDATA[Upgrading to NH3 from NH2.1.2 We have recently update to NHibernate 3 in one of our projects. While testing I was suddenly seeing some weird UPDATE statements in NHprof. It seemed like the NHibernate IsDirty detection had changed. After some &#8230; <a href="http://blog.ovesens.net/2011/03/nhibernate-dirty-problem-weird-updates-in-nhprof/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<h2>Upgrading to NH3 from NH2.1.2</h2>
<p>We have recently update to NHibernate 3 in one of our projects. While testing I was suddenly seeing some weird UPDATE statements in NHprof.</p>
<p>It seemed like the NHibernate IsDirty detection had changed.</p>
<p>After some digging it turned out that our mapping files (made in FluentNhibernate) actually contained some minor errors when compared to the DB schema. Minor errors like value typed properties not being nullable when the ClassMap said it should be.</p>
<h2>Debugging of NHibernate projects</h2>
<p>I found that inserting the following into the classmaps made debugging a lot easier:</p>
<pre class="brush: csharp;">DynamicUpdate();</pre>
<p>Now only the properties that are Dirty (according to NHibernate) are used in the SQL UPDATE statement. Here are the description from NHibernate docs:</p>
<ul>
<li><strong><tt>dynamic-update</tt></strong> (optional, defaults to <tt>false</tt>): Specifies that <tt>UPDATE</tt> SQL should be generated at runtime and contain only those columns whose values have changed.</li>
<li><strong><tt>dynamic-insert</tt></strong>: (optional, defaults to <tt>false</tt>): Specifies that <tt>INSERT</tt> SQL should be generated at runtime and contain only the columns whose values are not null.</li>
</ul>
<p>That led me directly to the property in the mapping files that had errors in it, and I could easily fix it.</p>
<h2>Conclusion</h2>
<p>So, in our case, it wasn&#8217;t really the NHibernate dirty detection that changed, NHibernate 3 is just not as fault tolerant, than that of NH2. So the upgrade made us discover some errors that should be corrected.</p>
<p>As such, this is a good thing, but it would have been nicer if NH2 had made us aware of these errors in the first place.</p>
<p>But hey, better late than never <img src='http://blog.ovesens.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ovesens.net/2011/03/nhibernate-dirty-problem-weird-updates-in-nhprof/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Mercurial repository locked on network share and is never released</title>
		<link>http://blog.ovesens.net/2011/03/mercurial-repository-locked-on-network-share-and-is-never-released/</link>
		<comments>http://blog.ovesens.net/2011/03/mercurial-repository-locked-on-network-share-and-is-never-released/#comments</comments>
		<pubDate>Thu, 03 Mar 2011 14:19:08 +0000</pubDate>
		<dc:creator>Mikkel Ovesen</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[hg]]></category>
		<category><![CDATA[mercurial]]></category>

		<guid isPermaLink="false">http://blog.ovesens.net/?p=346</guid>
		<description><![CDATA[I have experienced this when the connection is dropped in the middle of a HG command being executed. The solution is to run the following command on the machine hosting the repository. Fire the command in the directory hosting the &#8230; <a href="http://blog.ovesens.net/2011/03/mercurial-repository-locked-on-network-share-and-is-never-released/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I have experienced this when the connection is dropped in the middle of a HG command being executed.</p>
<p>The solution is to run the following command on the machine hosting the repository. Fire the command in the directory hosting the problematic/locked .hg folder. (It is not really a requirement to execute the command on the hosting machine, but it will make it a lot quicker than over the network)</p>
<pre>hg recover</pre>
<p>That is it.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ovesens.net/2011/03/mercurial-repository-locked-on-network-share-and-is-never-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>NHibernate CompositeId and GetHashCode SELECT N+1 problem</title>
		<link>http://blog.ovesens.net/2011/02/nhibernate-compositeid-and-gethashcode-select-n1-problem/</link>
		<comments>http://blog.ovesens.net/2011/02/nhibernate-compositeid-and-gethashcode-select-n1-problem/#comments</comments>
		<pubDate>Mon, 28 Feb 2011 20:34:59 +0000</pubDate>
		<dc:creator>Mikkel Ovesen</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[fix]]></category>
		<category><![CDATA[nh]]></category>
		<category><![CDATA[nhibernate]]></category>
		<category><![CDATA[orm]]></category>

		<guid isPermaLink="false">http://blog.ovesens.net/?p=337</guid>
		<description><![CDATA[I was looking in my NHProf log and got a lot of SELECT request. To many and I thought I was having a SELECT N+1 problem. Using the &#8220;Stack Trace&#8221; in NHprof I identified a call being made to GetHashCode() &#8230; <a href="http://blog.ovesens.net/2011/02/nhibernate-compositeid-and-gethashcode-select-n1-problem/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I was looking in my NHProf log and got a lot of SELECT request. To many and I thought I was having a SELECT N+1 problem.</p>
<p>Using the &#8220;Stack Trace&#8221; in NHprof I identified a call being made to GetHashCode() of the class (<em>MyClass</em>) holding the composite id. <em>MyClass</em> looked like this:</p>
<pre class="brush: csharp;">public class MyClass
{
    public virtual Key1Class Key1 { get; set; }
    public virtual Key2Class Key2 { get; set; }

    /*
     * Other virtual properties
     * ...
     */

    public override int GetHashCode()
    {
        unchecked
        {
            return ((Key1 != null ? Key1.GetHashCode() : 0) * 397) ^ (Key2 != null ? Key2.GetHashCode() : 0);
        }
    }
}</pre>
<p>Note that Key1 and Key2 are both references, and please take a closer look at the GetHashCode method.</p>
<h2>The problem</h2>
<p>The problem I was facing&#8230; NHibernate called the GetHashCode() of <em>MyClass</em> when doing the query. And the call to <em>MyClass</em>&#8216;s GetHashCode method subsequentily called GetHashCode() of both the Key1 and Key2 classes.</p>
<p>Key1 and Key2 were loaded as proxies and hence a call to something else than theirs Id resulted in a select being fired.</p>
<h2>The solution</h2>
<p>The solution was to rewrite the GetHashCode method to this:</p>
<pre class="brush: csharp;">public override int GetHashCode()
{
    unchecked
    {
        return ((Key1 != null ? Key1.Id : 0) * 397) ^ (Key2 != null ? Key2.Id : 0);
    }
}</pre>
<p>Note that both Id&#8217;s of KeyClass1 and KeyClass2 are integers.</p>
<p>Now a call to <em>MyClass</em> GetHashCode does not result in individual SELECT statements being fired, even though the Keys area lazy loaded.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ovesens.net/2011/02/nhibernate-compositeid-and-gethashcode-select-n1-problem/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

