Skip to content

Instantly share code, notes, and snippets.

View redknightlois's full-sized avatar

Federico Andres Lois redknightlois

View GitHub Profile
@redknightlois
redknightlois / MatrixHelper.tt
Last active August 29, 2015 14:02
A real Matrix<T> for int, float and double types.
<#@ template debug="false" hostspecific="false" language="C#" #>
<#@ assembly name="System.Core" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ output extension=".cs" #>
<#
var types = new string[] { "int", "float", "double" };
#>
@redknightlois
redknightlois / cudalearn.cs
Created June 21, 2014 23:35
Comparizon of NumPy, Cudamat and CudaLearn proposed RBM code
public static class GpuRbmExample
{
public static void Main(string[] args)
{
CudaLearnModule.Initialize();
var database = new MnistDatabase();
// Training parameters
public class Blob
{
private readonly int offset = 0;
private Vector<float> _data;
private Vector<float> _diff;
public Vector<float> Data
{
get
{
@redknightlois
redknightlois / gist:dfd16d3dd3f79f50cdc6
Created September 1, 2014 04:47
ArraySegment<T> performance on tight-loops
static float[] data = new float[1000000];
static void Main(string[] args)
{
int offset = 49421;
Stopwatch watch = new Stopwatch();
watch.Start();
float t = 0;
@redknightlois
redknightlois / gist:a9ac805fec178402fa00
Created September 1, 2014 17:42
Roslyn compile source without writing to disk on the same AppDomain.
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
namespace RoslynNuget
{
@redknightlois
redknightlois / Jit_BoolToInt.cs
Created July 29, 2015 01:28
RyuJIT perf regression on bool to int conversions.
using BenchmarkDotNet.Tasks;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace BenchmarkDotNet.Samples
{
[Task(platform: BenchmarkPlatform.X64, jitVersion: BenchmarkJitVersion.LegacyJit)]
[Task(platform: BenchmarkPlatform.X64, jitVersion: BenchmarkJitVersion.RyuJit)]
[Task(platform: BenchmarkPlatform.X64, jitVersion: BenchmarkJitVersion.LegacyJit)]
[Task(platform: BenchmarkPlatform.X64, jitVersion: BenchmarkJitVersion.RyuJit)]
public class Jit_BoolToInt
{
private bool first;
private bool second;
public Jit_BoolToInt()
{
first = true;
@redknightlois
redknightlois / Sparrow.cs
Created July 29, 2015 18:14
Benchmark code for RyuJIT unsafe scenarios
using BenchmarkDotNet;
using BenchmarkDotNet.Tasks;
using Sparrow;
using System;
namespace Sparrow.Tryout
{
[Task(platform: BenchmarkPlatform.X64, jitVersion: BenchmarkJitVersion.LegacyJit)]
[Task(platform: BenchmarkPlatform.X64, jitVersion: BenchmarkJitVersion.RyuJit)]
@redknightlois
redknightlois / Devirtualization.cs
Created September 11, 2015 17:28
Benchmark for devirtualization
using BenchmarkDotNet;
using BenchmarkDotNet.Tasks;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
@redknightlois
redknightlois / Main
Last active October 27, 2015 18:00
RotateBits repro
; Assembly listing for method ConsoleApp1.Program:Main(ref)
; Emitting BLENDED_CODE for X64 CPU with SSE2
; optimized code
; rsp based frame
; partially interruptible
; Final local variable assignments
;
;* V00 arg0 [V00 ] ( 0, 0 ) ref -> zero ref
; V01 tmp0 [V01,T01] ( 2, 4 ) long -> rcx
; V02 tmp1 [V02,T02] ( 2, 4 ) long -> rcx