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); }
public static void Initialize(int gpuDeviceId = 0) { KokkosLibrary.Initialize(Environment.ProcessorCount, gpuDeviceId); //AppDomain.CurrentDomain.ProcessExit += View_Dtor; }
public Devices() { Cpus = new List <CpuDevice>((int)KokkosLibrary.GetNumaCount()); OperatingSystem os = Environment.OSVersion; for (int i = 0; i < (int)KokkosLibrary.GetNumaCount(); ++i) { Cpus.Add(new CpuDevice(i, $"{os.Platform:G}", (int)KokkosLibrary.GetCoresPerNuma(), (int)KokkosLibrary.GetCoresPerNuma() * (int)KokkosLibrary.GetThreadsPerCore(), new DeviceArch(RuntimeInformation.ProcessArchitecture == Architecture.X64 ? "x64" : "x86"))); } Gpus = new List <GpuDevice>((int)KokkosLibrary.GetDeviceCount()); uint gpuId = 0; foreach (PhysicalGPU physicalGpu in PhysicalGPU.GetPhysicalGPUs()) { uint gpuVersion = KokkosLibrary.GetComputeCapability(gpuId); Gpus.Add(new CudaGpuDevice((int)gpuId, "Cuda", physicalGpu.ArchitectInformation.NumberOfCores, physicalGpu.ArchitectInformation.NumberOfCores, new DeviceArch(GetCudaDeviceName(gpuVersion), (int)gpuVersion), physicalGpu.UsageInformation)); ++gpuId; } }
private static void RrcTexasDataAdapter_Dtor(object?sender, EventArgs e) { if (KokkosLibrary.IsInitialized() || _initialized) { KokkosLibrary.FinalizeAll(); } }
public static void Initialize(int numCpuThreads, int gpuDeviceId) { KokkosLibrary.Initialize(numCpuThreads <= 0 ? Environment.ProcessorCount : numCpuThreads, gpuDeviceId); //AppDomain.CurrentDomain.ProcessExit += View_Dtor; }
public InterprocessMemory(string label) { nint ptr = KokkosLibrary.IpcOpenExisting(executionSpaceType, new NativeString <Serial>(label)); ulong size = KokkosLibrary.IpcGetSize(executionSpaceType, ptr); Pointer = new NativePointer(ptr, size); }
private void ReleaseUnmanagedResources() { if (_isOwner) { KokkosLibrary.Free(executionSpace, ((NativeStruct *)Instance)->Data); } }
public void Dispose() { KokkosLibrary.IpcClose(executionSpaceType, Pointer.Data); KokkosLibrary.IpcDestory(executionSpaceType, Pointer.Data); Pointer?.Dispose(); GC.SuppressFinalize(this); }
public static bool IsRunning() { if (KokkosLibrary.IsLoaded) { return(KokkosLibrary.IsInitialized()); } return(false); }
public static ScopeGuard Get(int gpuDeviceId) { if (!_initialized) { KokkosLibrary.Initialize(Environment.ProcessorCount, gpuDeviceId); _initialized = true; } return(new ScopeGuard()); }
public static ScopeGuard Get(InitArguments arguments) { if (!_initialized) { KokkosLibrary.Initialize(arguments); _initialized = true; } return(new ScopeGuard()); }
public static View <double, TExecutionSpace> NearestNeighbor(View <double, TExecutionSpace> latlongdegrees) { nint result = KokkosLibrary.NearestNeighborDouble(latlongdegrees.Pointer, executionSpace); NdArray ndArray = View <double, TExecutionSpace> .RcpConvert(result, 1); View <double, TExecutionSpace> neighbors = new View <double, TExecutionSpace>(new NativePointer(result, sizeof(double) * latlongdegrees.Extent(0)), ndArray); return(neighbors); }
public static ScopeGuard Get(int numCpuThreads, int gpuDeviceId) { if (!_initialized) { KokkosLibrary.Initialize(numCpuThreads, gpuDeviceId); _initialized = true; } return(new ScopeGuard()); }
public static View <double, TExecutionSpace> Shepard2d(View <double, TExecutionSpace> xd, View <double, TExecutionSpace> zd, double p, View <double, TExecutionSpace> xi) { nint result = KokkosLibrary.Shepard2dDouble(xd.Pointer, zd.Pointer, p, xi.Pointer, executionSpace); NdArray ndArray = View <double, TExecutionSpace> .RcpConvert(result, 1); View <double, TExecutionSpace> zi = new View <double, TExecutionSpace>(new NativePointer(result, sizeof(double) * xi.Size()), ndArray); return(zi); }
public static View <long, TExecutionSpace> GetCountLineEndings(string filename) { if (!File.Exists(filename)) { throw new FileNotFoundException(); } char[] chars = File.ReadAllText(filename).ToCharArray(); long n = chars.LongLength; nint result = 0; View <char, TExecutionSpace> stringView = new View <char, TExecutionSpace>("stringView", n); for (long i = 0; i < n; ++i) { stringView[i] = chars[i]; } switch (executionSpace) { case ExecutionSpaceKind.Serial: { result = KokkosLibrary.CountLineEndingsSerial(stringView.Pointer); break; } case ExecutionSpaceKind.OpenMP: { result = KokkosLibrary.CountLineEndingsOpenMP(stringView.Pointer); break; } case ExecutionSpaceKind.Cuda: { result = KokkosLibrary.CountLineEndingsCuda(stringView.Pointer); break; } } NdArray ndArray = View <long, TExecutionSpace> .RcpConvert(result, 1); View <long, TExecutionSpace> lineEndings = new View <long, TExecutionSpace>(new NativePointer(result, sizeof(long) * n), ndArray); return(lineEndings); }
public NativeArray(int size) { _pointer = NativePointer.Allocate(sizeof(NativeStruct), executionSpace); ((NativeStruct *)Instance)->Length = size; ((NativeStruct *)Instance)->Data = KokkosLibrary.Allocate(executionSpace, (ulong)(size * elementSize)); _isOwner = true; data_pointer = (T *)((NativeStruct *)Instance)->Data; }
public NativeArray(T[] array) { _pointer = NativePointer.Allocate(sizeof(NativeStruct), executionSpace); _isOwner = true; ((NativeStruct *)Instance)->Length = array.Length; ((NativeStruct *)Instance)->Data = KokkosLibrary.Allocate(executionSpace, (ulong)(array.Length * elementSize)); data_pointer = (T *)((NativeStruct *)Instance)->Data; if (data_pointer != null) { for (int i = 0; i < array.Length; i++) { data_pointer[i] = array[i]; } } }
public static void Initialize(InitArguments arguments) { KokkosLibrary.Initialize(arguments); //AppDomain.CurrentDomain.ProcessExit += View_Dtor; }
public InterprocessMemory(nint memoryPtr, ulong size, string label) { Pointer = new NativePointer(KokkosLibrary.IpcCreateFrom(executionSpaceType, memoryPtr, size, new NativeString <Serial>(label)), size); }
public static void Print() { KokkosLibrary.PrintConfiguration(true); }
public nint GetMemoryPointer() { return(KokkosLibrary.IpcGetMemoryPointer(executionSpaceType, Pointer.Data)); }
public nint GetDeviceHandle() { return(KokkosLibrary.IpcGetDeviceHandle(executionSpaceType, Pointer.Data)); }
public ulong GetSize() { return(KokkosLibrary.IpcGetSize(executionSpaceType, Pointer.Data)); }
public static void Shutdown() { KokkosLibrary.@Finalize(); }