Пример #1
0
        public View <TDataType, TExecutionSpace> MakeViewFromPointer <TDataType>(ulong n0,
                                                                                 ulong n1 = ulong.MaxValue,
                                                                                 ulong n2 = ulong.MaxValue,
                                                                                 ulong n3 = ulong.MaxValue,
                                                                                 ulong n4 = ulong.MaxValue,
                                                                                 ulong n5 = ulong.MaxValue,
                                                                                 ulong n6 = ulong.MaxValue,
                                                                                 ulong n7 = ulong.MaxValue)
            where TDataType : struct
        {
            int dataTypeSize = Unsafe.SizeOf <TDataType>();

            DataTypeKind dataType = DataType <TDataType> .GetKind();

            nint viewPtr = KokkosLibrary.IpcMakeViewFromPointer(executionSpaceType, dataType, Pointer, n0, n1, n2, n3, n4, n5, n6, n7);

            ushort rank = (ushort)KokkosLibrary.CalculateRank(n0, n1, n2, n3, n4, n5, n6, n7);

            NdArray ndArray = View <TDataType, TExecutionSpace> .RcpConvert(viewPtr, rank);

            ulong size = KokkosLibrary.CalculateSize(ndArray[0].Dim, ndArray[1].Dim, ndArray[2].Dim, ndArray[3].Dim, ndArray[4].Dim, ndArray[5].Dim, ndArray[6].Dim, ndArray[7].Dim);

            View <TDataType, TExecutionSpace> view = new View <TDataType, TExecutionSpace>(new NativePointer(viewPtr, (ulong)dataTypeSize * size), ndArray);

            return(view);
        }