kunzmi / managedCuda

ManagedCUDA aims an easy integration of NVidia's CUDA in .net applications written in C#, Visual Basic or any other .net language.
Other
440 stars 79 forks source link

Alignment metadata #45

Closed RobbinMarcus closed 7 years ago

RobbinMarcus commented 7 years ago

Regarding issue #42: this pull request adds an alignment attribute to all vector types that have a defined alignment according to the CUDA C++ definition. This will help to create automated custom structures with correct memory alignment.

kunzmi commented 7 years ago

Hi, I didn't really understand what the purpose of this PR actually is. You want to add some additional alignment info to the structures that is only used if the user actively requests the values? The structures them selves still aren't aligned by your PR if used as is, isn't it? Is this for one very specific use case of yours or do you think this might be of a more general interest?

Especially as you mentioned automated code creation, isn't it simpler to use C# extension methods outside of managedCuda? I don't see how I might use this PR in any of my use cases, why its hard to imagine (for me) how this might help others...

But don't get me wrong, any improvement of managedCuda is welcome, I just don't understand it :) So please elaborate a bit more what you expect from this code being part of managedCuda.

RobbinMarcus commented 7 years ago

As of now, this PR would not improve any of your use cases. I'd like to store the alignment for CUDA vector types as metadata in C#, and I believe it's impossible to add metadata as extension. I imagine this could be useful to others if they want to query the alignment of the vector types as well.

My use case is to create automated C# structures with the same size and alignment as C++. I'm not sure if this is something you would want to add, as my current setup requires multiple projects. Furthermore, it is currently very biased towards x64 structure, and probably compiler dependent. By no means a final product, which is why I didn't want to include it in this PR.

RobbinMarcus commented 7 years ago

I'll work from my fork from now, and re-open the pull request when I figure out a neat solution for this.