Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Idea about the missing API af_get_raw_ptr

オープン
#25 コメント 5 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
25/100
issue の種類
機能追加
明瞭さ
説明が足りない
活発さ
停滞
技術スタック
csharp
領域
api

調査の方向性

この 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 はありません

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

arrayfire/arrayfire-dotnet のほかの issue

arrayfire/arrayfire-dotnet の issue をすべて見る

似ている issue

C# の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。