Giter Site home page Giter Site logo

lombiq / hastlayer-sdk Goto Github PK

View Code? Open in Web Editor NEW
292.0 16.0 33.0 20.29 MB

Turning .NET software into FPGA hardware for faster execution and lower power usage.

Home Page: https://hastlayer.com

License: BSD 3-Clause "New" or "Revised" License

C# 2.00% Dockerfile 0.01% Shell 0.01% VHDL 97.99% F# 0.01%
fpga lombiq hardware dotnet performance

hastlayer-sdk's Introduction

Hastlayer SDK

Hast.Layer NuGet Build and Test

About

Hastlayer - be the hardware. Hastlayer automatically transforms .NET assemblies into computer chips, improving performance and lowering power consumption for massively parallel applications. For some figures check out the benchmarks.

Hastlayer uses FPGAs (chips that can be "re-wired" on the fly): Simply select the compute-bound part of your .NET program, and Hastlayer seamlessly swaps it out with a generated FPGA implementation. Since .NET Intermediate Language assemblies (but not C#, VisualBasic or other code) are transformed, you can use any .NET language (e.g. C#, VB, F# - sample included, C++, Python, PHP, and JavaScript) in theory.

Hastlayer was also featured on .NET Conf 2017 and many other conferences and meetups. The recorded session covers interesting features of Hastlayer. Check out the FAQ for more information.

This is the PC-side component of Hastlayer, the one that transforms .NET assemblies, programs attached FPGAs, and communicates with said FPGAs.

Note that due to a repository purge the repo history doesn't contain anything from before July 2017 though development has been ongoing more or less actively from 2015.

Created by Lombiq Technologies, an open source .NET web development company working mostly with Orchard CMS, i.e. Orchard 1.x and Orchard Core.

Hastlayer uses ILSpy to process CIL assemblies.

Notes on Hastlayer's documentation

These text files should only serve as a starting point. The samples are the best source of information on how to use Hastlayer. The public API of Hastlayer is also documented inline as code comments. Please check the comments for clarification. The projects also have README files.

Table of contents

Contributing and support

Bug reports, feature requests, comments, questions, code contributions, and love letters are warmly welcome, please do so via GitHub issues and pull requests. Please adhere to our open-source guidelines while doing so.

This project is developed by Lombiq Technologies. Commercial-grade support is available through Lombiq.

hastlayer-sdk's People

Contributors

benedekfarkas avatar ha7ilm avatar katelynkim avatar lombiqbot avatar luko6 avatar piedone avatar sarahelsaig avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hastlayer-sdk's Issues

Ability to construct SimpleMemory without copying

As suggested by @antonfirsov, add an ability to create a SimpleMemory object from existing data (like an image that was read in) in a way that doesn't involve copying to the SimpleMemory.Memory array.

This can be achieved by changing the Memory property to Memory<byte> (see this and this post) for example. Then we can have a SimpleMemory constructor that instantiates an array as before and stores that in the property, and another one that takes a Memory<byte> (or Memory<int> if it's cell-structured) directly. So we'd maintain backwards compatibility, have an option for simple construction, but also enable copy-less usage.

Performance estimation tool (HAST-242)

Have a tool that will tell you how much time a given subprogram will take to execute on given hardware.

Partially we could do this with static analysis by doing a hardware transformation and summing the latencies, plus add memory IO and communication latency. However, since a particular code path can have dynamic properties, like a loop running as long as indicated in a runtime-determined variable, we'd need some kind of code instrumentation (like a profiler) too.

Jira issue

Persistent hardware memory (HAST-247)

The idea is to have memory (SimpleMemory) values persist between hardware entry point calls. The use-case is that you have multiple computations using the same large dataset (like a big image) and you don't want to copy this large input to the hardware every time. So, you'd copy it only once, then let subsequent hardware entry point calls use it. This requires that you only use a single FPGA (otherwise the data set needs to be copied to all connected FPGAs).

We could implement this somehow by marking parts of a SimpleMemory object as persistent: then that wouldn't be sent over to the hardware every time and it wouldn't be overwritten.

Jira issue

2D KPZ sample

Sample for a KPZ implementation: https://arxiv.org/abs/1606.00310

This is useful because the algorithm is parallelizable and compute-bound (though needs quite some memory too) and can be used to compare Hastlayer to a GPU implementation.

Figure out why SIMD multiplications are sometimes wrong

With the default sample that runs 30 multiplications (and other operations) in parallel sometimes some of the results will be wrong.

Waiting not 7 but 30 clock cycles for the multiplications to finish changes which items are wrong but doesn't improve the issue.

Although this affects only division but the "Vivado Design Suite User Guide: Synthesis (UG901)" states that division is "Supported only if the second operand is a power of 2, or both operands are constant".

Maybe the issue has something to do with parallel reads/writes on arrays, but this shouldn't be a problem, see: https://forums.xilinx.com/t5/General-Technical-Discussion/accessing-multiple-elements-in-array-at-the-same-time-vhdl/td-p/551686

C# code listing inside VHDL

Idea: we could add the C# code lines as comments to the VHDL source file, to each state within Hast_IP.vhd. This could potentially improve debugging.

As Hastlayer works from the decompiled IL, it could make use of the IL->C# functions of ILSpy to implement this feature.

Idea by @ha7ilm.

Replace the Sha256Helper static class with a service and provide non-hash implementation (HAST-240)

Testing VHDL correctness during any core development quickly becomes cumbersome, as labels like conditional490fbbe6120ff28cfa73a92f6fc4f384ae723eb9ad8d460306095fada72ff872 change all the time. This is becuase the hash value is derived from a technical name that contains line numbers and the full caller name.

I believe a lookup-based approach (e.g. service class with ConcurrentDictionary) that assigns sequential IDs would be more resistant to inconsequential changes during testing. On the other hand, production could receive a different implementation that actually uses that technical name in a sanitized form, that could be helpful in debugging new code. To achieve this selection, Sha256Helper should be replaced with an IVhdlLabelProvider service with the mentioned two implementations.

Jira issue

logo

Hi.I'm graphic designer. I want to design a logo for the readme. What dou you say?

Support for foreach (HAST-245)

If DecompilerSettings.ForEachStatement is set to false then foreach statements are not recreated. So e.g. in ParallelAlgorithn instead of:

for (int i = 0; i < MaxDegreeOfParallelism; i++)
{
    output += tasks[i].Result;
}

We could write:

foreach (var task in tasks)
{
    output += task.Result;
}

This is then decompiled into something like this (after const substitution):

int i = 0;
while (i< 280) {
	Task<int> task;
	task = array[i];
	output = output + task.Result;
	i = i + 1;
}

The Task<int> variable declaration and the .Result access need special support, otherwise, this is already supported.

Jira issue

Add SIMD remainder (%) operation (HAST-257)

See SimdOperations. What makes this non-trivial is that unlike the four basic arithmetic operations % can't be directly transformed, but is rather a series of division, multiplication, and subtractions. On the flip side, the operation can be easily implemented by chaining the divide, multiple, and subtract operations.

Jira issue

Recursion and parallelization support for custom properties (HAST-256)

Since these are handled the same as methods, they'd need the same support too:

  • Parallelization and recursion support with MemberInvocationInstanceCountConfiguration subclassing like MemberInvocationInstanceCountConfigurationForMethod (direct MemberInvocationInstanceCountConfiguration should work, needs testing).
  • InvocationInstanceCountAdjuster support (this should work, but needs to be tested).

Jira issue

Support class inheritance (HAST-241)

If classes are inherited from then the members of the base classes should be duplicated, just as if they were part of the child class. This is because otherwise the base members could be used from multiple locations at the same time concurrently and with different types for their "this" parameters.

Currently, base method calls aren't handled well either, the "this" parameter is not added for e.g. base.MyMethod().

However, polymorphism still wouldn't be supported (since e.g. variables and arrays need a static type) so this would only be partial support, and non-supported cases need to be handled and let fail gracefully.

Jira issue

Add support for transforming Nullable, ValueTuple (HAST-239)

Currently you are unable to work with nullable structs, for example a method that returns Unum? will throw "The declaration of the type System.Nullable`1[[Lombiq.Arithmetics.Unum]] couldn't be found." error in the TypeConverter. Also null-coalescing operations need to be tested.
Similarly, (int A, int B) Foo() => (1, 1); will throw "The declaration of the type System.ValueTuple`2[[System.Int32],[System.Int32]] couldn't be found.".

Although not a bug, both are commonly used features of modern C# where lack of support will hinder adoption.

Jira issue

Add the ability to store IHardwareRepresentation (HAST-243)

This would make it possible to generate the hardware on one machine and utilize it on another one. So, basically caching the whole hardware representation locally.

Now caching is done on the hardware description level only and you need to be only for the GenerateHardware() call anyway. This would also make it possible to use Hastlayer offline like it is necessary for embedded systems.

Jira issue

Some sentences in README file unclear/difficult to read.

There are a few unclear sentences in the README file due to lack of punctuation and awkward sentence structure.

For instance,

"Since not C#, VisualBasic or other code but .NET Intermediate Language assemblies are transformed in theory any .NET language can be used, including C#, VB, F#, C++, Python, PHP, JavaScript..."

Since not C#, VisualBasic or other code but .NET Intermediate Language assemblies are transformed --> Sentence is awkward as it begins with "not" instead of the subject, which is ".NET Intermediate Language assemblies".

'...assemblies are transformed in theory any .NET language can be used," --> It is unclear to which clause the word "in theory" belongs to due to lack of punctuation. Depending on where the comma is placed, the sentence could mean two different things:
"Since...the assemblies are transformed in theory, any .NET languages can be used."
"Since... the assemblies are transformed, any .NET languages can be used in theory."

At any rate, it is better to remove "in theory" as it gives the impression that the developer is not sure about the range of languages the user can use on his program.

Migrate to .NET Core

Migrate the whole SDK to .NET Core in anticipation of .NET 5. This also means to get rid of Orchard (but potentially use relevant pieces of Orchard Core).

IlSpy libraries need to be updated first, so see: #20.

We'd need to work on substituting the following Orchard features:

  • Automatic dependency injection: registrations for IDependency and its derivatives can potentially be provided in a separate Helpful Libraries package, or register everything by hand into the .NET Core container.
  • Logging
  • Events (there are a few IEventHandler implementations; they can be kept as simple IEnumerable<TEventHandler> dependencies; OrchardCore.Modules.InvokeExtensions can be used to invoke them without surfacing exceptions if necessary to swallow exceptions from events)
  • Virtualized file access with IAppDataFolder (IFileStore can be used with an implementation from the OrchardCore.FileStorage.FileSystem package).
  • ex.IsFatal() (the OrchardCore.Abstractions package contains it)
  • IClock (the implementation is in the OrchardCore package)
  • Caching (IMemoryCache, MemoryCache can be used from Microsoft.Extensions.Caching.Memory)
  • Nunit 2 tests, possibly by migrating to Nunit 3, see: https://davembush.github.io/nunit-2-vs-nunit-3-what-you-need-to-know/ Or use xUnit which Orchard also uses, see this article on a comparison to Nunit: https://dev.to/hatsrumandcode/net-core-2-why-xunit-and-not-nunit-or-mstest--aei Moq can be continued to be used.

Once this is done the note on the usage of Orchard in the Readme should be changed too. Do a search for "Orchard" in the whole solution to check whether everything that refers to Orchard still makes sense.

All packages we use apart from the old IlSpy ones target .NET Standard, so we're good. However, the Catapult libraries are Windows-only, so we need to somehow compartmentalize the Catapult-using parts. Maybe we'll need a separate consumer sample for that too (like Hast.Samples.Consumer).

The class libraries should target .NET Standard, the console apps the latest .NET Core. The KPZ WinForms app needs to be ported over to .NET Core WinForms, see this guide.

For some tips also see this article: https://www.telerik.com/blogs/dotnet-is-dead-long-live-dotnet

Follow-up: #35

JIRA issue

Posit floating point support (HAST-136)

Posit is a floating point number type that's better than the usual IEEE floats but can be easily used as a drop-in replacement still. Let's see this instead of Unum.

See the sources below here: https://github.com/libcg/bfp

Let's create a generally usable .NET library which is transformable with Hastlayer.

Support static fields and properties (HAST-251)

Currently, all methods' variables are like private static fields because the VHDL variables' values are kept between FSM executions. Because such variables are never read before being initialized (this would also be invalid in C#) this is not an issue.

The same mechanism could be used for static fields/properties: every field would have a static setter and getter FSM (like for instance properties) and they'd use the same common signal to store the member's value (which would only be produced once, on first access).

It's a question how this could work with arrays, because their single elements should also be writable. Maybe the easiest way would be to always overwrite the whole array too.

However, arrays and static fields/properties also bring an issue with concurrency: what happens if multiple threads try to access an uninitialized static field? This is not thread-safe in .NET either.

When ConvertConstructorCallIntoInitializer is deactivated, static constructors will appear, and these will contain field initializers (however instance ctors will also appear with a lot of redundant code). This is easier to transform. Such static ctors should be run once after power up (i.e. on the FPGA we need to store that they were run) simultaneously on the first start Task.WhenAll()-style. But what if static fields depend on each other? Maybe a sequential run, but with two passes is better.

Jira issue

Support ref and out parameters

Support passing variables by reference with ref and out method arguments. Would need the same kind of write-back as it happens when arrays and other objects are passed to methods. Some aspects of this are supported because of array passing.

Implement the ability to use bit variables (HAST-235)

For #2 we need to store bit values in an efficient way. We could use bools, which on the FPGA will be represented as bits (which is great), but probably a more explicit approach would be better. Options:

See: http://stackoverflow.com/questions/352089/why-cant-i-define-a-bit-in-c-sharp

Jira issue

Loop unrolling (HAST-114)

Unroll loops with constant parameters, i.e. copy the loop body as many times as the loop would run. Since one loop execution takes one clock cycle in itself if the loop body otherwise wouldn't then we can pack more operations into a single clock cycle.

With constant substitution this is now more widely usable.

This happens in Vivado HLS: https://www.xilinx.com/support/documentation/sw_manuals/xilinx2014_1/ug902-vivado-high-level-synthesis.pdf#page=199

It seems that in Posit32 actually no loops could be automatically unrolled due to the loops expressions not being resolvable statically. However sometimes manual loop unrolling can help.

Also see this article, page 6, "D. Loop Optimizations".

JIRA issue

Make the SDK usable from NuGet (HAST-175)

Instead of having to start with the SDK solution create NuGet packages that you'll then be able to add to your app.

  • Let's use our NuGet-publishing GitHub workflow if possible.
  • Remove the note from WorkingWithHastlayer.
  • Add a NuGetTest solution that runs the verification tests with the NuGet packages.
  • Hardware Frameworks need to be packaged as well, and then used as plain files somehow.
  • Is it better to create a different solution just for NuGet publishing, without a lot of the sample and test projects, or make affected projects <IsPackagable>false</IsPackagable> (publish-nuget can already ignore such projects without erroring out)?
  • Figure out something for Lombiq.Arithmetics and Hast.Vitis.HardwareFramework. These most possibly need their own NuGet publish workflows. Publish them first.
  • Add NuGet-referencing verbiage to Hastlayer.cs:
    • "Did you install the necessary NuGet package for the given device?" for "There is no supported device..."
    • "Did you install the necessary NuGet package for the given device?" for "No suitable hardware implementation..." (device support packages should already depend on the necessary composer packages, hence the same text).
  • Should we package up Hast.Console, perhaps as a .NET Tool? - This doesn't make much sense, no.

Prerequisite: #34

Jira issue

Add support for returning an array field (or its clone) from methods (HAST-258)

As mentioned here:

[...] if you return an array from a method instead of a property it won't work even if the two are functionally equivalent. For example Quire.Segments is an array returning property which is not suggested for performance reasons. But if I replace it with a ulong[] GetSegments() => _segments; method, I will get the The length of the array holder System.Void Lombiq.Arithmetics.Quire::.ctor(System.UInt64[],System.UInt16).Lombiq.Arithmetics.Quire.GetSegments (@this)[82..87) couldn't be statically determined. error. Checking if a method returns a trivial reference could resolve that problem.

We need:

  • ulong[] GetSegments() => _segments.Clone(); : return the clone of an array backing field from a function.
  • IReadOnlyList<ulong> GetSegments() => _segments; : return the backing field directly as an immutable collection.
  • public IReadOnlyList<ulong> Segments => _segments; : do the same from a get-only property.

Jira issue

Optionally inline methods

Inlining methods that are used only once, or are small (measured in e.g. number of expressions, state machine states?): no need for separate state machine in VHDL to cut down on FSM numbers and thus multiplexing logic (uses space and adds latency).

Or optionally inlining all methods for performance.

We could have a VhdlTransformerConfiguration option for that. Or support the [MethodImpl(MethodImplOptions.AggressiveInlining)] attribute (see https://msdn.microsoft.com/en-us/library/system.runtime.compilerservices.methodimploptions(v=vs.110).aspx). However using this doesn't necessarily help on the CPU.

It would be great to use some external tool for this, i.e. provide IL, get inlined IL back, but there seems to be no solution for this. (The JIT compiler is doing the inlining normally, so IL won't be modified.)

This would be very much needed for Unums and Posits, as there are a lot of small methods used everywhere.

Upgrade to v6 ILSpy libraries

See important info:

Also:

  • ICSharpCode.NRefactory was integrated into ICSharpCode.Decompiler and thus the independent ICSharpCode.NRefactory package isn't used any more.
  • ILRange is now part of ILInstruction instead of being an annotation.
  • Not sure what "Instead of Cecil.TypeReference, the decompiler now uses the NRefactory TypeSystem." means for us, but probably we can still get the Cecil type info object as per the former, now deleted, last example on https://github.com/icsharpcode/ILSpy/wiki/Getting-Started-With-ICSharpCode.Decompiler (GetCecil() doesn't exist any more):
var decompiler = new CSharpDecompiler("Demo.ConsoleApp.exe", new DecompilerSettings());
var name = new FullTypeName("Demo.ConsoleApp.Test+NestedClassTest");
ITypeDefinition type = decompiler.TypeSystem.Compilation.FindType(name).GetDefinition();
var module = decompiler.TypeSystem.GetCecil(type).Module

And: https://github.com/icsharpcode/ILSpy/blob/cd2896e3e9989d092419aea92bd8417eb7e2e485/ICSharpCode.Decompiler.PdbProvider.Cecil/MonoCecilDebugInfoProvider.cs

But with v4.0, the underlying decompiler and disassembler engine have been ported to System.Reflection.Metadata, see: https://github.com/icsharpcode/ILSpy/wiki/srm

There is still TypeDeclaration but now there is also an ITypeDefinition which is similar to what was in Mono.Cecil and can be retrieved from various places via GetDefinition(). Then there is IEntity.MetadataToken as well, which is supposed to provide what GetCecil() did.

After this, the workaround for the ILSpy large integer literal bug can be removed, see DecompilationErrorsFixer and WronglyDecompiledCases.

JIRA issue

Support arrays and nulls (HAST-254)

Custom objects can be checked against null and assigned null, but not arrays. Implement support for that.

This could be done by e.g. storing all arrays in a NullableRecord type (but then everywhere it should be changed how arrays are handled).

Jira issue

Support Parallel.For()

So instead of e.g.:

for (int i = 0; i < MaxDegreeOfParallelism; i++)
{
    tasks[i] = Task.Factory.StartNew(
        indexObject =>
        {
            var index = (uint)indexObject;
            ...
        },
        i);
}

We'd write something like:

Parallel.For(0, MaxDegreeOfParallelism, index =>
{
    ...
});

Parallel Eratosthenes’ prime sieve sample (HAST-237)

Memory caching (HAST-249)

Improve memory access latency with some form of caching, similar to how L1 and L2 caches in CPUs work.

Some ideas:

  • In case of larger-than-32b memory channels keep the contents of the DataIn signal. Then if subsequent reads are issued to cells that are under the same physical address then no read should actually happen but another part of the ready DataIn content (which is e.g. 512b) can be used.
  • Speculatively prefetch the next few cells, so if those will be indeed used they'll be already there? What makes this complicated is that if such a prefetch is executing then any manual memory operation needs to wait for it to finish; so it must happen when there won't be any other memory operation for sure.
  • Have async versions of SimpleMemory operations. This way e.g. a memory read can be started ASAP and then awaited only when the result is actually needed. Thus the operation can happen in the background while something else is executing, so no waiting is needed. However, still one such operation would be possible at one time.

This is already done for Vitis.

Jira issue

Refactor to DisplayClass handling not to be a special case (HAST-253)

Currently, DisplayClasses and how they are used are handled as a special case due to them being generated for multi-threaded code. However, now that we have OOP support, we could remove this specialized behavior and instead handle DisplayClasses as any other class.

For this, we'd need to support fields apart from properties as class members too, which is done now.

Jira issue

Optimize the invocation of parallel methods (HAST-246)

When Tasks are started in a loop then there will be an InvocationProxy-like structure in the VHDL (see invocationIndex) where we select the next available instance of the parallelized method (which was created from a lambda expression) to start. This has as many branches as many instances there are. It's not an issue with lower instance counts or simpler initialization logic but once it gets more complex timing errors can happen.

Then there's a corresponding wait state ("Waiting for the state machine invocation of the following method to finish...") that checks all the instances' start and finish signals, which again can get complex.

While both just scale linearly we could optimize to make them simpler somehow. I don't know whether we can do anything really with the wait state, as it's unavoidable for us to check at one point whether all the FSMs finished. But the invocation part could be simpler by pairing invocations similar to invocations between standard methods' FSMs.

Possible approaches:

  • The most promising: Since just a single FSM is started at a given time it would work to push input data to common global registers and have an invocationIndex register as well (but a single signal can't have multiple drivers). If invocationIndex contains the index corresponding to a given FSM then that FSM will start itself. However, this would need significant architectural changes. Alternatively, we could add small pieces of glue logic between the existing parallel FSMs and such global registers (for every FSM there would be some combinatorial logic listening to its corresponding invocationIndex). However, this might not help as all because the current logic is supposed to describe the same too.
  • Possibly related: #14. One solution might be to unroll the Task-creating loops and pair an instance in each unrolled loop body. This, however, would be pretty hard to implement and if the loop body is complex then it'd also greatly increase resource usage.
  • This SO answer mentions using shift registers instead multiplexers. However, at higher levels of parallelism shifting out inputs from a register would take a lot of time for higher FSM indices.

Jira issue

Ability to store objects in SimpleMemory (HAST-250)

As a follow-up to @antonfirsov's idea from here.

Add the ability to store full objects in SimpleMemory, in a Write<T>() style (and similarly for reading). In the background this would de/serialize the object to the byte representation and use the other SimpleMemory operations as usual.

Since object sizes are known at compile-time the store and retrieve logic for an object tree can be substituted in an AST processor (i.e. a Write(index, myObject) substituted with as many Write4Bytes() calls as necessary).

An inconvenience is that such objects would most possibly use more than one memory cell, i.e. the consumer code needs to handle the necessary indexing logic to space out the next object to write to memory for example. This can be made easier if Write<T>() returns an int with the amount of cells used to store the object so you can calculate nextIndex = Write<T>(currentIndex, myObject) + currentIndex.

This brings us to one step distance of masking away SimpleMemory in hardware invocation points and handling standard method arguments behind the scenes but I consider that a low priority (as you'd need SimpleMemory for dynamic memory allocations any way, and it's just a small inconvenience).

Jira issue

Support generics (HAST-252)

Support for generic types, i.e. Generic<T>.

Unlike C++ templates generics in .NET directly exist in IL. How we could handle this is to substitute the type parameters (also a bit like with C++ templates) and basically create a version of the generic class for each type it's used with.

This can happen similarly to how array types are created in VHDL, e.g. we'd create a class named Generic_int and Generic_long from two usages of Generic<T>.

Possibly the best way to implement this would be via an AST processor in the Transformer.

Ideally, there would be a way to get rid of generics in IL and somehow substitute them statically (by the compiler or with some IL tool) but there seems to be no way to do this.

Jira issue

Add the ability to use true random numbers (HAST-236)

Maybe we could substitute RNGCryptoServiceProvider methods (https://msdn.microsoft.com/en-us/library/system.security.cryptography.rngcryptoserviceprovider.aspx) to use a true random number generator implementation on the hardware. Though this would be unexpected and produce different results. So maybe having another API (like the existing PRNGs) and substitute it with a TRNG on the hardware?

For tips see:

Related: #6.

Jira issue

Add support for multidimensional arrays (HAST-255)

Currently only single-dimensional arrays are supported, there is an explicit check for this too in ArrayCreateExpressionTransformer. However Vivado appears to support multi-dimensional arrays (at least for synthesis; further checks are necessary) like below, so we could transform into them:

type singleArray is array (0 to 5) of std_logic_vector(31 downto 0);
type multiArray is array (0 to 3) of singleArray;

type matrix is array (natural range <>, natural range <>, natural range <>) of std_logic_vector(31 downto 0);

Since the support for this can be dependent on tooling probably IDeviceDriver needs to be augmented too to indicate support for multi-dimensional arrays.

Since array.Length is handled now, GetLength() needs to be implemented in a similar manner (see the LENGTH attribute: https://www.csee.umbc.edu/portal/help/VHDL/attribute.html).

Also see: http://stackoverflow.com/questions/30651269/synthesizable-multidimensional-arrays-in-vhdl

Jira issue

Hastlayer-accelerated ImageSharp Orchard Core integration (HAST-192)

Integrate the Hastlayer-accelerated ImageSharp implementation (https://lombiq.atlassian.net/browse/HAST-170) into Orchard Core.

The point is to be able to demonstrate the performance difference between the default (CPU-using) image resizing and the Hastlayer-accelerated one. Thus, the implementation should take over whenever image resizing happens in OC with ImageSharp. We should be able to showcase the performance difference, like the response time of an HTTP request.

Jira issue

Ability to address larger memory space with SimpleMemory (HAST-259)

SimpleMemory currently lets you address 8GB of memory with its int cellIndex (int.MaxValue * 32, since cells are 32b). This is sufficient for now, but we could support addressing more memory.

This can be done by making the size of the Hast_IP CellIndex port configurable in IDeviceManifest, so this can vary between FPGA devices. Though the user code would need to be adapted between platforms too so this is not ideal. Alternatively, we could use a 64b int for addressing in ˙SimpleMemory operations as well as in the Hast_IP ports.

However, the current limitation in .NET Framework is that even with gcAllowVeryLargeObjects enabled the maximum index of a single dimension can still be around int.MaxValue, so we wouldn't be able to use this when running as software. This can be overcome by making SimpleMemory be paged, i.e. use multiple arrays internally (if <2GB these can be even without gcAllowVeryLargeObjects) but have ulong indices in the interface.

After this device drivers for Alveo cards can be updated.

Jira issue

Add the ability to use pseudorandom numbers

Implement a function in the library used by Hast_IP that generates a random 32b unsigned number in the interval given by parameters (i.e. there are two 32b unsigned input parameters). We could transform Random.Next() (which is just pseudorandom) if possible but if not then roll out a custom one (see Hast.Algorithms in the #2 branch for one).

This should be able to work in parallel in multiple instances (is this the case with functions?).

A pseudorandom number generator can be implemented with LFSRs, see e.g.:

The main point would be for the generator not to produce the same sequence during a specific simulation (i.e. the sequence should be long).

Constant value substitution for methods without constant inputs (HAST-234)

Similarly to what happens with constructors in ObjectHoldersToSubstitutedConstructorsMappingVisitor (and ConstantValuesMarkingVisitor and ConstantValuesSubstitutingVisitor) we could have instance-level const substitution for method calls too.

Only pure methods could be used, i.e. those that are static and don't modify any of the input objects (don't assign to their members or to array elements) and their return type is a primitive type.

This would also be used in UnumEnvironment for the UnumHelper calls.

Jira issue

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.