Skip to content

GregEakin/HighPerformance

Repository files navigation

High Performance C# Multithreaded Programming

This is a C# implemenmtation of the Takk<T> to generate dataflow graphs. It was inspired by Thomas Christopher's book High Performance Java Computing: Multithreaded and Networked Programming.

From the book:

High Performance Java Computing: Multithreaded and Networked Programming

Christopher, Thomas W., and George Thiruvathukal. High Performance Java Computing: Multithreaded and Networked Programming. Hemel Hempstead: Prentice Hall, 2000. Print.

Features:

  • Tasks
  • Dataflows

Links:

Sample code

Here's a two-operand task that evaluates the sum of the array, when the Result is called. The value is only calculated once, and only on demand. If the Result is never called, the result memory is not allocated and sum operation never occurs. Look here, at line 32, for an example of how it's used.

public class BinAddFloatArrayLazy
{
    private readonly Lazy<float[]> _left;
    private readonly Lazy<float[]> _right;

    public BinAddFloatArrayLazy(Lazy<float[]> left, Lazy<float[]> right)
    {
        _left = left;
        _right = right;
        Result = new Lazy<float[]>(Run);
    }

    public Lazy<float[]> Result { get; }

    private float[] Run()
    {
        var left = _left.Value;
        var right = _right.Value;
        var sum = new float[left.Length];
        for (var i = 0; i < left.Length; i++)
            sum[i] = left[i] + right[i];
        return sum;
    }
}

Author

🔥 Greg Eakin

Releases

No releases published

Packages

No packages published

Languages