Idea about the missing API af_get_raw_ptr
まだ誰も着手していません。
評価
調査の方向性
この issue では、リポジトリのファイルやテストが指定されていません。まず、示されている C# の相互運用宣言と ArrayFire af_get_raw_ptr API の契約を確認し、そのうえで、サポートされる所有権とライフタイムの要件を判断してください。完了条件は、.NET 向けの raw-pointer または zero-copy アクセス設計について合意し、公開されたメモリが複製なしで有効なまま維持されることを検証することです。
索引モデルが issue の本文から書いたものです。
説明
Hello Arrayfire team!,
I was curious about the implemented APIs for dotnet so far and noticed that there is one is missing (or commented out) : "af_get_raw_ptr".
When using arrayfire you just always get the "unmanaged" C++ af array object as an IntrPtr without any possibility to use this object in other .NET APIs (except arrayfire). In my opinion it would be awesome if .NET would have the underlying array as dotnet object but without duplicating it in memory (this means the raw pointer as .NET array or Span or sth in this way).
If arrayfire-dotnet could do this - you could interact with many other librarties but do not duplicate the memory (as long as on CPU backend I guess).
For this the API af_get_raw_ptr is important. I did some ... try outs and played around with it. I was able to create an arrayfire array, got the raw pointer and created a span object from it. Just want to share with you and ask what you think about. unfortunately until now I did not test if there is really not a duplicate in memory and it was for a very small array so far... plus a lot of unsafe sections
public static class af
{
[DllImport("afcpu.dll", ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
public static extern int af_create_array(out IntPtr array_arr, [In] float[] data, uint ndims, [In] long[] dim_dims, int type);
[DllImport("afcpu.dll")]
public unsafe static extern int af_get_raw_ptr(void** ptr, IntPtr arr);
}
class Program
{
static unsafe void Main(string[] args)
{
float[] dotnetArray = {101,2,3,4,5};
float puffer_1 = 5;
IntPtr af_Ptr = new IntPtr();
void* puffer_2=(void*) &puffer_1;
void** raw_ptr = & puffer_2;
int error = af.af_create_array(out af_Ptr, dotnetArray, 1,new long[] {5},0 );
error = af.af_get_raw_ptr(raw_ptr,af_Ptr);
puffer_2 = *raw_ptr;
var dotnetSpan = new Span<float>((float*)puffer_2, 5);
}
}
- 主要言語
- C#
- スター
- 76
- フォーク
- 19
- PR マージ指標
- 30日以内にマージされた PR はありません
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
arrayfire/arrayfire-dotnet のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 25/100
-
Error in ar_topk オープン
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
-
af_index_t オープンquestion
難易度 5/5 1週間以上 初心者へのやさしさ 20/100
arrayfire/arrayfire-dotnet#31 · コメント 3 件 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
arrayfire/arrayfire-dotnet#29 · コメント 3 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 42/100
arrayfire/arrayfire-dotnet#27 · コメント 1 件 ·
arrayfire/arrayfire-dotnet の issue をすべて見る
似ている issue
-
Documentation
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
cake-build/cake#5024 ·
-
Frontend status/draft TechnicalDebt
難易度 2/5 1〜2日 初心者へのやさしさ 75/100
Altinn/altinn-auth#4143 ·
-
.NET Flaky Test Testing Tests
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
getsentry/sentry-dotnet#5617 · コメント 1 件 ·
-
:watch: Not Triaged dotnet-fsharp/svc
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
-
Client customer-reported needs-team-attention question Service Attention WebPubSub
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
Azure/azure-sdk-for-net#63292 · コメント 3 件 · リアクション 1 件 ·