├── src ├── _build │ ├── run_miner_win.bat │ ├── run_miner_win_API.bat │ ├── run_miner_linux.sh │ ├── run_miner_linux_API.sh │ ├── build_win.bat │ ├── build_linux.sh │ ├── build_win_with_API.bat │ └── build_linux_with_API.sh ├── OpenCL-dotnet │ ├── .gitignore │ ├── .vscode │ │ ├── settings.json │ │ ├── tasks.json │ │ └── launch.json │ ├── OpenCl.DotNetCore.Interop │ │ ├── Memory │ │ │ ├── BufferCreateType.cs │ │ │ ├── PipeInformation.cs │ │ │ ├── ImageFormat.cs │ │ │ ├── MemoryObjectType.cs │ │ │ ├── MemoryObjectInformation.cs │ │ │ ├── ImageInformation.cs │ │ │ ├── ChannelType.cs │ │ │ ├── MemoryFlag.cs │ │ │ └── ChannelOrder.cs │ │ ├── Samplers │ │ │ ├── FilterMode.cs │ │ │ ├── AddressingMode.cs │ │ │ └── SamplerInformation.cs │ │ ├── Devices │ │ │ ├── DeviceExecutionCapabilities.cs │ │ │ ├── DeviceMemoryCacheType.cs │ │ │ ├── DeviceLocalMemoryType.cs │ │ │ ├── DevicePartitionProperty.cs │ │ │ ├── DeviceSvmCapability.cs │ │ │ ├── DeviceType.cs │ │ │ ├── DeviceFloatingPointConfiguration.cs │ │ │ └── DeviceAffinityDomain.cs │ │ ├── EnqueuedCommands │ │ │ ├── CommandExecutionStatus.cs │ │ │ ├── MemoryMigrationFlag.cs │ │ │ └── MapFlag.cs │ │ ├── Programs │ │ │ ├── ProgramBuildInformation.cs │ │ │ └── ProgramInformation.cs │ │ ├── Contexts │ │ │ └── ContextInformation.cs │ │ ├── Kernels │ │ │ ├── KernelExecutionInformation.cs │ │ │ ├── KernelArgumentInformation.cs │ │ │ ├── KernelSubGroupInformation.cs │ │ │ ├── KernelInformation.cs │ │ │ └── KernelWorkGroupInformation.cs │ │ ├── OpenCl.DotNetCore.Interop.csproj │ │ ├── CommandQueues │ │ │ ├── CommandQueueInformation.cs │ │ │ └── CommandQueueProperty.cs │ │ ├── Events │ │ │ └── EventInformation.cs │ │ ├── Profiling │ │ │ ├── ProfilingInformation.cs │ │ │ └── ProfilingNativeApi.cs │ │ ├── IntroducedInOpenClAttribute.cs │ │ ├── Platforms │ │ │ ├── PlatformInformation.cs │ │ │ └── PlatformsNativeApi.cs │ │ ├── SvmAllocations │ │ │ ├── SvmAllocationsNativeApi.cs │ │ │ └── SvmMemoryFlag.cs │ │ └── Extensions │ │ │ └── ExtensionsNativeApi.cs │ ├── OpenCl.DotNetCore │ │ ├── Platforms │ │ │ ├── Profile.cs │ │ │ └── Version.cs │ │ ├── Memory │ │ │ ├── Pipe.cs │ │ │ ├── Image.cs │ │ │ ├── MemoryBuffer.cs │ │ │ ├── MemoryFlag.cs │ │ │ └── MemoryObject.cs │ │ ├── Events │ │ │ └── UserEvent.cs │ │ ├── CommandQueues │ │ │ └── CommandExecutionStatus.cs │ │ ├── OpenCl.DotNetCore.csproj │ │ ├── Devices │ │ │ └── DeviceType.cs │ │ ├── Programs │ │ │ └── Program.cs │ │ ├── OpenClException.cs │ │ └── InteropConverter.cs │ ├── OpenCl.DotNetCore.Tests │ │ └── OpenCl.DotNetCore.Tests.csproj │ ├── LICENSE │ └── README.md ├── CudaSolver │ ├── build.bat │ ├── Logger.cs │ ├── CudaSolver.csproj │ └── Properties │ │ ├── Resources.Designer.cs │ │ └── Resources.resx ├── GrinProMInerAPI │ ├── appsettings.json │ ├── appsettings.Development.json │ ├── Startup.cs │ ├── Controllers │ │ ├── ConfigController.cs │ │ ├── WorkersController.cs │ │ ├── HomeController.cs │ │ ├── ConnectionController.cs │ │ └── StatusController.cs │ ├── GrinGoldMinerAPI.csproj │ ├── _README.txt │ ├── Models │ │ └── Status.cs │ └── Views │ │ └── Home.cshtml ├── Cudacka │ ├── Microsoft.VCToolsVersion.14.11.props │ ├── Cudacka.sln │ └── Cudacka.vcxproj ├── Master │ ├── Stats.cs │ ├── Master.csproj │ ├── Config.cs │ ├── XMLTools.cs │ ├── Program.cs │ └── config.xml ├── SharedSerialization │ ├── SharedSerialization.csproj │ ├── DirComm.cs │ ├── Blake2B-Simple.cs │ └── Blake2B-Inline.cs ├── GrinGoldMiner3 │ └── GrinGoldMiner3.csproj └── OclSolver │ └── OclSolver.csproj ├── README.md └── help.md /src/_build/run_miner_win.bat: -------------------------------------------------------------------------------- 1 | cd bin 2 | GrinGoldMiner3.exe 3 | 4 | -------------------------------------------------------------------------------- /src/_build/run_miner_win_API.bat: -------------------------------------------------------------------------------- 1 | cd bin 2 | GrinGoldMinerAPI.exe 3 | -------------------------------------------------------------------------------- /src/_build/run_miner_linux.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | cd bin 4 | ./GrinGoldMiner3 5 | -------------------------------------------------------------------------------- /src/OpenCL-dotnet/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Ignores the .NET Core build output 3 | bin/ 4 | obj/ -------------------------------------------------------------------------------- /src/_build/run_miner_linux_API.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | cd bin 4 | ./GrinGoldMinerAPI 5 | -------------------------------------------------------------------------------- /src/CudaSolver/build.bat: -------------------------------------------------------------------------------- 1 | dotnet publish -r win10-x64 /p:PublishSingleFile=true -c Release 2 | pause -------------------------------------------------------------------------------- /src/GrinProMInerAPI/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Warning" 5 | } 6 | }, 7 | "AllowedHosts": "*" 8 | } 9 | -------------------------------------------------------------------------------- /src/GrinProMInerAPI/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Warning", 5 | "System": "Warning", 6 | "Microsoft": "Warning" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/OpenCL-dotnet/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.exclude": { 3 | "**/.git": true, 4 | "**/.svn": true, 5 | "**/.hg": true, 6 | "**/.DS_Store": true, 7 | "**/bin": true, 8 | "**/obj": true 9 | } 10 | } -------------------------------------------------------------------------------- /src/Cudacka/Microsoft.VCToolsVersion.14.11.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 14.11.25503 5 | 6 | 7 | -------------------------------------------------------------------------------- /src/OpenCL-dotnet/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.1.0", 3 | "command": "dotnet", 4 | "isShellCommand": true, 5 | "args": [], 6 | "tasks": [ 7 | { 8 | "taskName": "build", 9 | "args": [ 10 | "${workspaceRoot}/OpenCl.DotNetCore.Tests/project.json" 11 | ], 12 | "isBuildCommand": true, 13 | "problemMatcher": "$msCompile" 14 | } 15 | ] 16 | } -------------------------------------------------------------------------------- /src/_build/build_win.bat: -------------------------------------------------------------------------------- 1 | md bin 2 | cd .. 3 | cd GrinGoldMiner3 4 | dotnet publish -c Release -r win-x64 --self-contained --framework netcoreapp2.2 --output ..\_build\bin 5 | cd .. 6 | cd CudaSolver 7 | dotnet publish -c Release -r win-x64 --self-contained --framework netcoreapp2.2 --output ..\_build\bin 8 | cd .. 9 | cd OclSolver 10 | dotnet publish -c Release -r win-x64 --self-contained --framework netcoreapp2.2 --output ..\_build\bin 11 | 12 | pause 13 | -------------------------------------------------------------------------------- /src/_build/build_linux.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | mkdir bin 4 | cd .. 5 | cd GrinGoldMiner3 6 | dotnet publish -c Release -r linux-x64 --self-contained --framework netcoreapp2.2 --output ../_build/bin 7 | cd .. 8 | cd CudaSolver 9 | dotnet publish -c Release -r linux-x64 --self-contained --framework netcoreapp2.2 --output ../_build/bin 10 | cd .. 11 | cd OclSolver 12 | dotnet publish -c Release -r linux-x64 --self-contained --framework netcoreapp2.2 --output ../_build/bin 13 | 14 | -------------------------------------------------------------------------------- /src/_build/build_win_with_API.bat: -------------------------------------------------------------------------------- 1 | md bin 2 | cd .. 3 | cd GrinProMInerAPI 4 | dotnet publish -c Release -r win-x64 --self-contained --framework netcoreapp2.2 --output ..\_build\bin 5 | cd .. 6 | cd CudaSolver 7 | dotnet publish -c Release -r win-x64 --self-contained --framework netcoreapp2.2 --output ..\_build\bin 8 | cd .. 9 | cd OclSolver 10 | dotnet publish -c Release -r win-x64 --self-contained --framework netcoreapp2.2 --output ..\_build\bin 11 | 12 | pause 13 | -------------------------------------------------------------------------------- /src/OpenCL-dotnet/OpenCl.DotNetCore.Interop/Memory/BufferCreateType.cs: -------------------------------------------------------------------------------- 1 | 2 | namespace OpenCl.DotNetCore.Interop.Memory 3 | { 4 | /// 5 | /// Represents an enumeration for the buffer creation type. 6 | /// 7 | public enum BufferCreateType : uint 8 | { 9 | 10 | /// 11 | /// Creates a buffer object that represents a specific region in the buffer. 12 | /// 13 | Region = 0x1220 14 | } 15 | } -------------------------------------------------------------------------------- /src/_build/build_linux_with_API.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | mkdir bin 4 | cd .. 5 | cd GrinProMInerAPI 6 | dotnet publish -c Release -r linux-x64 --self-contained --framework netcoreapp2.2 --output ../_build/bin 7 | cd .. 8 | cd CudaSolver 9 | dotnet publish -c Release -r linux-x64 --self-contained --framework netcoreapp2.2 --output ../_build/bin 10 | cd .. 11 | cd OclSolver 12 | dotnet publish -c Release -r linux-x64 --self-contained --framework netcoreapp2.2 --output ../_build/bin 13 | -------------------------------------------------------------------------------- /src/Master/Stats.cs: -------------------------------------------------------------------------------- 1 | // Grin Gold Miner https://github.com/urza/GrinGoldMiner 2 | // Copyright (c) 2018 Lukas Kubicek - urza 3 | // Copyright (c) 2018 Jiri Vadura - photon 4 | 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Text; 8 | 9 | namespace Mozkomor.GrinGoldMiner 10 | { 11 | public class Stats 12 | { 13 | public int graphs = 0; 14 | public int edgesets = 0; 15 | public int solutions = 0; 16 | public int mined = 0; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/SharedSerialization/SharedSerialization.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | 2.7.9717 6 | 7 | 8 | 9 | x64 10 | 11 | 12 | 13 | x64 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/OpenCL-dotnet/OpenCl.DotNetCore.Interop/Samplers/FilterMode.cs: -------------------------------------------------------------------------------- 1 | 2 | namespace OpenCl.DotNetCore.Interop.Samplers 3 | { 4 | /// 5 | /// Represents an enumeration for the different filter modes that can be used for samplers. 6 | /// 7 | public enum FilterMode : uint 8 | { 9 | /// 10 | /// The filter mode is nearest. 11 | /// 12 | Nearest = 0x1140, 13 | 14 | /// 15 | /// The filter mode is linear. 16 | /// 17 | Linear = 0x1141 18 | } 19 | } -------------------------------------------------------------------------------- /src/OpenCL-dotnet/OpenCl.DotNetCore/Platforms/Profile.cs: -------------------------------------------------------------------------------- 1 | 2 | namespace OpenCl.DotNetCore.Platforms 3 | { 4 | /// 5 | /// Represents an enumeration for the different profiles that can be supported by OpenCL platforms. 6 | /// 7 | public enum Profile 8 | { 9 | /// 10 | /// The full OpenCL specification is supported. 11 | /// 12 | Full, 13 | 14 | /// 15 | /// A subset of the OpenCL specification for embedded devices is supported. 16 | /// 17 | Embedded 18 | } 19 | } -------------------------------------------------------------------------------- /src/OpenCL-dotnet/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "name": "Launch OpenCL.NET Tests", 6 | "type": "coreclr", 7 | "request": "launch", 8 | "preLaunchTask": "build", 9 | "program": "${workspaceRoot}/OpenCl.DotNetCore.Tests/bin/Debug/netcoreapp1.1/OpenCl.DotNetCore.Tests.dll", 10 | "args": [], 11 | "cwd": "${workspaceRoot}", 12 | "externalConsole": false, 13 | "stopAtEntry": false, 14 | "internalConsoleOptions": "openOnSessionStart" 15 | } 16 | ] 17 | } -------------------------------------------------------------------------------- /src/OpenCL-dotnet/OpenCl.DotNetCore/Memory/Pipe.cs: -------------------------------------------------------------------------------- 1 | 2 | #region Using Directives 3 | 4 | using System; 5 | 6 | #endregion 7 | 8 | namespace OpenCl.DotNetCore.Memory 9 | { 10 | /// 11 | /// Represents an OpenCL pipe. 12 | /// 13 | public class Pipe : MemoryObject 14 | { 15 | #region Constructors 16 | 17 | /// 18 | /// Initializes a new instance. 19 | /// 20 | /// The handle to the OpenCL pipe. 21 | public Pipe(IntPtr handle) 22 | : base(handle) 23 | { 24 | } 25 | 26 | #endregion 27 | } 28 | } -------------------------------------------------------------------------------- /src/OpenCL-dotnet/OpenCl.DotNetCore/Memory/Image.cs: -------------------------------------------------------------------------------- 1 | 2 | #region Using Directives 3 | 4 | using System; 5 | 6 | #endregion 7 | 8 | namespace OpenCl.DotNetCore.Memory 9 | { 10 | /// 11 | /// Represents an OpenCL image. 12 | /// 13 | public class Image : MemoryObject 14 | { 15 | #region Constructors 16 | 17 | /// 18 | /// Initializes a new instance. 19 | /// 20 | /// The handle to the OpenCL image. 21 | public Image(IntPtr handle) 22 | : base(handle) 23 | { 24 | } 25 | 26 | #endregion 27 | } 28 | } -------------------------------------------------------------------------------- /src/OpenCL-dotnet/OpenCl.DotNetCore/Memory/MemoryBuffer.cs: -------------------------------------------------------------------------------- 1 | 2 | #region Using Directives 3 | 4 | using System; 5 | 6 | #endregion 7 | 8 | namespace OpenCl.DotNetCore.Memory 9 | { 10 | /// 11 | /// Represents an OpenCL memory buffer. 12 | /// 13 | public class MemoryBuffer : MemoryObject 14 | { 15 | #region Constructors 16 | 17 | /// 18 | /// Initializes a new instance. 19 | /// 20 | /// The handle to the OpenCL memory buffer. 21 | public MemoryBuffer(IntPtr handle) 22 | : base(handle) 23 | { 24 | } 25 | 26 | #endregion 27 | } 28 | } -------------------------------------------------------------------------------- /src/OpenCL-dotnet/OpenCl.DotNetCore.Interop/Devices/DeviceExecutionCapabilities.cs: -------------------------------------------------------------------------------- 1 | 2 | #region Using Directives 3 | 4 | using System; 5 | 6 | #endregion 7 | 8 | namespace OpenCl.DotNetCore.Interop.Devices 9 | { 10 | /// 11 | /// Represents an enumeration for the different execution capabilities of devices. 12 | /// 13 | [Flags] 14 | public enum DeviceExecutionCapabilities : ulong 15 | { 16 | /// 17 | /// The OpenCL device can execute OpenCL kernels. 18 | /// 19 | Kernel = 1 << 0, 20 | 21 | /// 22 | /// The OpenCL device can execute native kernels. 23 | /// 24 | NativeKernel = 1 << 1 25 | } 26 | } -------------------------------------------------------------------------------- /src/OpenCL-dotnet/OpenCl.DotNetCore.Interop/Memory/PipeInformation.cs: -------------------------------------------------------------------------------- 1 | 2 | namespace OpenCl.DotNetCore.Interop.Memory 3 | { 4 | /// 5 | /// Represents an enumeration for the different types of information that can be queried from an pipe object. 6 | /// 7 | public enum PipeInformation : uint 8 | { 9 | /// 10 | /// Retrieves the pipe packet size specified when pipe is created with . 11 | /// 12 | PacketSize = 0x1120, 13 | 14 | /// 15 | /// Retrieves the maximum number of packets specified when pipe is created with . 16 | /// 17 | MaximumNumberOfPackets = 0x1121 18 | } 19 | } -------------------------------------------------------------------------------- /src/OpenCL-dotnet/OpenCl.DotNetCore.Interop/Devices/DeviceMemoryCacheType.cs: -------------------------------------------------------------------------------- 1 | 2 | namespace OpenCl.DotNetCore.Interop.Devices 3 | { 4 | /// 5 | /// Represents an enumeration for the different types of device memory caches. 6 | /// 7 | public enum DeviceMemoryCacheType : uint 8 | { 9 | /// 10 | /// No device memory cache is available. 11 | /// 12 | None = 0x0, 13 | 14 | /// 15 | /// The device memory cache is read-only. 16 | /// 17 | ReadOnlyCache = 0x1, 18 | 19 | /// 20 | /// The device memory cache is readable and writable. 21 | /// 22 | ReadWriteCache = 0x2 23 | } 24 | } -------------------------------------------------------------------------------- /src/OpenCL-dotnet/OpenCl.DotNetCore.Interop/Devices/DeviceLocalMemoryType.cs: -------------------------------------------------------------------------------- 1 | 2 | namespace OpenCl.DotNetCore.Interop.Devices 3 | { 4 | /// 5 | /// Represents an enumeration for the different type of local device memory. 6 | /// 7 | public enum DeviceLocalMemoryType : uint 8 | { 9 | /// 10 | /// Custom devices may have no local memory support. 11 | /// 12 | None = 0x0, 13 | 14 | /// 15 | /// Dedicated local memory storage such as SRAM. 16 | /// 17 | Local = 0x1, 18 | 19 | /// 20 | /// No dedicated local memory storage is available, but rather global memory is used. 21 | /// 22 | Global = 0x2 23 | } 24 | } -------------------------------------------------------------------------------- /src/OpenCL-dotnet/OpenCl.DotNetCore/Events/UserEvent.cs: -------------------------------------------------------------------------------- 1 | 2 | #region Using Directives 3 | 4 | using System; 5 | 6 | #endregion 7 | 8 | namespace OpenCl.DotNetCore.Events 9 | { 10 | /// 11 | /// Represents an OpenCL event, which has been created by the user and is not bound to a command enqueued on the command queue. 12 | /// 13 | public class UserEvent : AwaitableEvent 14 | { 15 | #region Constructors 16 | 17 | /// 18 | /// Initializes a new instance. 19 | /// 20 | /// The handle to the OpenCL event. 21 | public UserEvent(IntPtr handle) 22 | : base(handle) 23 | { 24 | } 25 | 26 | #endregion 27 | } 28 | } -------------------------------------------------------------------------------- /src/Master/Master.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Library 5 | netstandard2.0 6 | 7 | 8 | 9 | 10 | 11 | x64 12 | 13 | 14 | 15 | x64 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/OpenCL-dotnet/OpenCl.DotNetCore.Interop/EnqueuedCommands/CommandExecutionStatus.cs: -------------------------------------------------------------------------------- 1 | 2 | namespace OpenCl.DotNetCore.Interop.EnqueuedCommands 3 | { 4 | /// 5 | /// Represents an enumeration for the status of the execution of a command. 6 | /// 7 | public enum CommandExecutionStatus : int 8 | { 9 | /// 10 | /// The command has completed. 11 | /// 12 | Complete = 0x0, 13 | 14 | /// 15 | /// The device is currently executing this command. 16 | /// 17 | Running = 0x1, 18 | 19 | /// 20 | /// The enqueued command has been submitted by the host to the device associated with the command-queue. 21 | /// 22 | Submitted = 0x2, 23 | 24 | /// 25 | /// The command has been enqueued in the command-queue. 26 | /// 27 | Queued = 0x3 28 | } 29 | } -------------------------------------------------------------------------------- /src/OpenCL-dotnet/OpenCl.DotNetCore.Interop/Samplers/AddressingMode.cs: -------------------------------------------------------------------------------- 1 | 2 | namespace OpenCl.DotNetCore.Interop.Samplers 3 | { 4 | /// 5 | /// Represents an enumeration for the different addressing modes that can be used for samplers. 6 | /// 7 | public enum AddressingMode : uint 8 | { 9 | /// 10 | /// No addressing mode. 11 | /// 12 | None = 0x1130, 13 | 14 | /// 15 | /// Clamps the image to the edge. 16 | /// 17 | ClampToEdge = 0x1131, 18 | 19 | /// 20 | /// Clamps the image. 21 | /// 22 | Clamp = 0x1132, 23 | 24 | /// 25 | /// Repeats the image. 26 | /// 27 | Repeat = 0x1133, 28 | 29 | /// 30 | /// Repeats the image mirrored. 31 | /// 32 | MirroredRepeat = 0x1134 33 | } 34 | } -------------------------------------------------------------------------------- /src/GrinGoldMiner3/GrinGoldMiner3.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.2 6 | 7 | 8 | 9 | x64 10 | 11 | 12 | 13 | x64 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /src/OpenCL-dotnet/OpenCl.DotNetCore.Interop/Devices/DevicePartitionProperty.cs: -------------------------------------------------------------------------------- 1 | 2 | namespace OpenCl.DotNetCore.Interop.Devices 3 | { 4 | /// 5 | /// Represents an enumeration for the different device partition properties. 6 | /// 7 | public enum DevicePartitionProperty : uint 8 | { 9 | /// 10 | /// Partitions the device equally among sub-devices. 11 | /// 12 | PartitionEqually = 0x1086, 13 | 14 | /// 15 | /// Partitions the device among sub-devices by counts. 16 | /// 17 | PartitionByCounts = 0x1087, 18 | 19 | /// 20 | /// Marks the end of the list. 21 | /// 22 | PartitionByCountsListEnd = 0x0, 23 | 24 | /// 25 | /// Partitions the device among sub-devices along a cache line. 26 | /// 27 | PartitionByAffinityDomain = 0x1088 28 | } 29 | } -------------------------------------------------------------------------------- /src/OpenCL-dotnet/OpenCl.DotNetCore.Interop/EnqueuedCommands/MemoryMigrationFlag.cs: -------------------------------------------------------------------------------- 1 | 2 | #region Using Directives 3 | 4 | using System; 5 | 6 | #endregion 7 | 8 | namespace OpenCl.DotNetCore.Interop.EnqueuedCommands 9 | { 10 | /// 11 | /// Represents an enumeration for the different flags, that can be used when migrating memory. 12 | /// 13 | [Flags] 14 | public enum MemoryMigrationFlag : ulong 15 | { 16 | /// 17 | /// This flag indicates that the specified set of memory objects are to be migrated to the host, regardless of the target command-queue. 18 | /// 19 | Host = 1 << 0, 20 | 21 | /// 22 | /// This flag indicates that the contents of the set of memory objects are undefined after migration. The specified set of memory objects are migrated to the device associated with the command queue without incurring the overhead of 23 | /// migrating their contents. 24 | /// 25 | ContentUndefined = 1 << 1 26 | } 27 | } -------------------------------------------------------------------------------- /src/OpenCL-dotnet/OpenCl.DotNetCore.Interop/Memory/ImageFormat.cs: -------------------------------------------------------------------------------- 1 | 2 | #region Using Directives 3 | 4 | using System.Runtime.InteropServices; 5 | 6 | #endregion 7 | 8 | namespace OpenCl.DotNetCore.Interop.Memory 9 | { 10 | /// 11 | /// Represents the image format descriptor structure. 12 | /// 13 | [StructLayout(LayoutKind.Sequential)] 14 | public struct ImageFormat 15 | { 16 | #region Public Properties 17 | 18 | /// 19 | /// Contains a value that specifies the number of channels and the channel layout i.e. the memory layout in which channels are stored in the image. 20 | /// 21 | public ChannelOrder ChannelOrder; 22 | 23 | /// 24 | /// Contains a value that describes the size of the channel data type. The number of bits per element determined by the and must be a power of two. 25 | /// 26 | public ChannelType ChannelDataType; 27 | 28 | #endregion 29 | } 30 | } -------------------------------------------------------------------------------- /src/OpenCL-dotnet/OpenCl.DotNetCore/CommandQueues/CommandExecutionStatus.cs: -------------------------------------------------------------------------------- 1 | 2 | namespace OpenCl.DotNetCore.CommandQueues 3 | { 4 | /// 5 | /// Represents an enumeration for the status of the execution of a command. 6 | /// 7 | public enum CommandExecutionStatus : int 8 | { 9 | /// 10 | /// The command could not be executed successfully. 11 | /// 12 | Error = -0x1, 13 | 14 | /// 15 | /// The command has completed. 16 | /// 17 | Complete = 0x0, 18 | 19 | /// 20 | /// The device is currently executing this command. 21 | /// 22 | Running = 0x1, 23 | 24 | /// 25 | /// The enqueued command has been submitted by the host to the device associated with the command-queue. 26 | /// 27 | Submitted = 0x2, 28 | 29 | /// 30 | /// The command has been enqueued in the command-queue. 31 | /// 32 | Queued = 0x3 33 | } 34 | } -------------------------------------------------------------------------------- /src/OpenCL-dotnet/OpenCl.DotNetCore.Tests/OpenCl.DotNetCore.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | This is a test program for the .NET Core wrapper for OpenCL 2.1. 5 | Copyright © 2016 David Neumann 6 | OpenCL.NET Core Test 7 | 0.1.0-alpha1 8 | David Neumann 9 | netcoreapp2.0 10 | portable 11 | OpenCl.DotNetCore.Tests 12 | Exe 13 | OpenCl.DotNetCore.Tests 14 | $(PackageTargetFallback);dnxcore50 15 | 1.1.1 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/OpenCL-dotnet/OpenCl.DotNetCore.Interop/Programs/ProgramBuildInformation.cs: -------------------------------------------------------------------------------- 1 | 2 | namespace OpenCl.DotNetCore.Interop.Programs 3 | { 4 | /// 5 | /// Represents an enumeration for the different types of information that can be queried from a program build. 6 | /// 7 | public enum ProgramBuildInformation : uint 8 | { 9 | /// 10 | /// The build, compile, or link status. 11 | /// 12 | Status = 0x1181, 13 | 14 | /// 15 | /// The build, compile, or link options. 16 | /// 17 | Options = 0x1182, 18 | 19 | /// 20 | /// The build, compile, or link log. 21 | /// 22 | Log = 0x1183, 23 | 24 | /// 25 | /// The program binary type for the device. 26 | /// 27 | BinaryType = 0x1184, 28 | 29 | /// 30 | /// The total amount of storage, in bytes, used by program variables in the global address space. 31 | /// 32 | GlobalVariableTotalSize = 0x1185 33 | } 34 | } -------------------------------------------------------------------------------- /src/OpenCL-dotnet/OpenCl.DotNetCore.Interop/Contexts/ContextInformation.cs: -------------------------------------------------------------------------------- 1 | 2 | namespace OpenCl.DotNetCore.Interop 3 | { 4 | /// 5 | /// Represents an enumeration for the different types of information that can be queried from a context. 6 | /// 7 | public enum ContextInformation : uint 8 | { 9 | /// 10 | /// The context reference count. The reference count returned should be considered immediately stale. It is unsuitable for general use in applications. This feature is provided for identifying memory leaks. 11 | /// 12 | ReferenceCount = 0x1080, 13 | 14 | /// 15 | /// The list of devices in the context. 16 | /// 17 | Devices = 0x1081, 18 | 19 | /// 20 | /// The properties argument specified in or . 21 | /// 22 | Properties = 0x1082, 23 | 24 | /// 25 | /// The number of devices in context. 26 | /// 27 | NumberOfDevices = 0x1083 28 | } 29 | } -------------------------------------------------------------------------------- /src/CudaSolver/Logger.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using SharedSerialization; 5 | 6 | namespace CudaSolver 7 | { 8 | internal static class Logger 9 | { 10 | public static volatile bool CopyToConsole = false; 11 | 12 | public static void Log(LogLevel level, string message, Exception e = null) 13 | { 14 | try 15 | { 16 | if (level != LogLevel.Debug && CopyToConsole) 17 | { 18 | Console.WriteLine(string.Format("{0}:\t {1}, {2}, {3}", DateTime.Now, level.ToString(), message, e != null ? e.Message : "")); 19 | } 20 | lock (Comms.logsOut) 21 | { 22 | Comms.logsOut.Enqueue(new LogMessage() { level = level, ex = e, message = message, time = DateTime.Now }); 23 | } 24 | Comms.SetEvent(); 25 | } 26 | catch 27 | { 28 | // log to file 29 | } 30 | } 31 | 32 | 33 | } 34 | 35 | 36 | 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/OpenCL-dotnet/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 David Neumann 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /src/Cudacka/Cudacka.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.28307.271 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Cudacka", "Cudacka.vcxproj", "{B87AA420-FC97-4320-9584-BD1E3863AA79}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Release|x64 = Release|x64 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {B87AA420-FC97-4320-9584-BD1E3863AA79}.Debug|x64.ActiveCfg = Debug|x64 15 | {B87AA420-FC97-4320-9584-BD1E3863AA79}.Debug|x64.Build.0 = Debug|x64 16 | {B87AA420-FC97-4320-9584-BD1E3863AA79}.Release|x64.ActiveCfg = Release|x64 17 | {B87AA420-FC97-4320-9584-BD1E3863AA79}.Release|x64.Build.0 = Release|x64 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {8F9B07F2-181E-4DEE-B2BB-A83EBDC66B56} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /src/OpenCL-dotnet/OpenCl.DotNetCore.Interop/Kernels/KernelExecutionInformation.cs: -------------------------------------------------------------------------------- 1 | 2 | namespace OpenCl.DotNetCore.Interop.Kernels 3 | { 4 | /// 5 | /// Represents an enumeration for the different types of information that can be set for the kernel execution. 6 | /// 7 | public enum KernelExecutionInformation : uint 8 | { 9 | /// 10 | /// SVM pointers used by a kernel which are not passed as arguments to kernel. These addresses may be defined in SVM buffer(s) that are passed as arguments to kernel. These non-argument SVM pointers must be specified using 11 | /// for coarse-grain and fine-grain buffer SVM allocations but not for fine-grain system SVM allocations. 12 | /// 13 | SvmPointers = 0x11B6, 14 | 15 | /// 16 | /// This flag indicates whether the kernel uses pointers that are fine grain system SVM allocations. These fine grain system SVM pointers may be passed as arguments or defined in SVM buffers that are passed as arguments to the kernel. 17 | /// 18 | SvmFineGrainSystem = 0x11B7 19 | } 20 | } -------------------------------------------------------------------------------- /src/OpenCL-dotnet/OpenCl.DotNetCore.Interop/Memory/MemoryObjectType.cs: -------------------------------------------------------------------------------- 1 | 2 | namespace OpenCl.DotNetCore.Interop.Memory 3 | { 4 | /// 5 | /// 6 | /// 7 | public enum MemoryObjectType : uint 8 | { 9 | /// 10 | /// The memory object is a buffer. 11 | /// 12 | Buffer = 0x10F0, 13 | 14 | /// 15 | /// The memory object is a 2D image. 16 | /// 17 | Image2D = 0x10F1, 18 | 19 | /// 20 | /// The memory object is a 3D image. 21 | /// 22 | Image3D = 0x10F2, 23 | 24 | /// 25 | /// The memory object is a 2D image array. 26 | /// 27 | Image2DArray = 0x10F3, 28 | 29 | /// 30 | /// The memory object is a 1D image. 31 | /// 32 | Image1D = 0x10F4, 33 | 34 | /// 35 | /// The memory object is a 1D image array. 36 | /// 37 | Image1DArray = 0x10F5, 38 | 39 | /// 40 | /// The memory object is a 1D image buffer. 41 | /// 42 | Image1DBuffer = 0x10F6, 43 | 44 | /// 45 | /// The memory object is a pipe. 46 | /// 47 | Pipe = 0x10F7 48 | } 49 | } -------------------------------------------------------------------------------- /src/OpenCL-dotnet/OpenCl.DotNetCore.Interop/OpenCl.DotNetCore.Interop.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | The interop wrapper for OpenCL .NET Core. 5 | Copyright © 2016 David Neumann 6 | OpenCL.NET Core Interop 7 | 0.1.0-alpha1 8 | David Neumann 9 | netstandard2.0 10 | portable 11 | OpenCl.DotNetCore.Interop 12 | OpenCl.DotNetCore.Interop 13 | 1.6.1 14 | 15 | 16 | 17 | true 18 | x64 19 | 20 | 21 | 22 | true 23 | x64 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /src/GrinProMInerAPI/Startup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Builder; 6 | using Microsoft.AspNetCore.Hosting; 7 | using Microsoft.AspNetCore.Mvc; 8 | using Microsoft.Extensions.Configuration; 9 | using Microsoft.Extensions.DependencyInjection; 10 | using Microsoft.Extensions.Logging; 11 | using Microsoft.Extensions.Options; 12 | 13 | namespace GrinProMInerAPI 14 | { 15 | public class Startup 16 | { 17 | public Startup(IConfiguration configuration) 18 | { 19 | Configuration = configuration; 20 | } 21 | 22 | public IConfiguration Configuration { get; } 23 | 24 | // This method gets called by the runtime. Use this method to add services to the container. 25 | public void ConfigureServices(IServiceCollection services) 26 | { 27 | services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); 28 | } 29 | 30 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 31 | public void Configure(IApplicationBuilder app, IHostingEnvironment env) 32 | { 33 | if (env.IsDevelopment()) 34 | { 35 | app.UseDeveloperExceptionPage(); 36 | } 37 | 38 | app.UseMvc(); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/GrinProMInerAPI/Controllers/ConfigController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Http; 6 | using Microsoft.AspNetCore.Mvc; 7 | using Mozkomor.GrinGoldMiner; 8 | 9 | namespace GrinProMiner.Controllers 10 | { 11 | [Route("api/[controller]")] 12 | [ApiController] 13 | public class ConfigController : ControllerBase 14 | { 15 | [HttpGet] 16 | public ActionResult Get() 17 | { 18 | return GrinProMInerAPI.Program.config; 19 | } 20 | 21 | [HttpPost] 22 | public ActionResult Post(Config config) 23 | { 24 | var path = GrinProMInerAPI.Program.WriteConfigToDisk(config); 25 | return Ok($"config saved in {path}, will be activated next time miner is started"); 26 | 27 | ///TODO Re-Init Workers and connections / how to reinit workers? 28 | //GrinProMInerAPI.Program.ChangeRemoteTerminate = true; //will change remote dashboard ping - what if it wasnt running in the first run? then there is no loop active 29 | //Task.Delay(1000).Wait(); 30 | //ConnectionManager.CloseAll(); 31 | //Task.Delay(1000).Wait(); 32 | //Logger.SetLogOptions(config.LogOptions); 33 | //WorkerManager.Init(config); 34 | //ConnectionManager.Init(config); 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /src/OpenCL-dotnet/OpenCl.DotNetCore.Interop/Kernels/KernelArgumentInformation.cs: -------------------------------------------------------------------------------- 1 | 2 | namespace OpenCl.DotNetCore.Interop.Kernels 3 | { 4 | /// 5 | /// Represents an enumeration for the different types of information that can be queried from an OpenCL kernel parameter. 6 | /// 7 | public enum KernelArgumentInformation : uint 8 | { 9 | /// 10 | /// The address qualifier specified for the argument. 11 | /// 12 | AddressQualifier = 0x1196, 13 | 14 | /// 15 | /// The access qualifier specified for the argument. 16 | /// 17 | AccessQualifier = 0x1197, 18 | 19 | /// 20 | /// The type name specified for the argument. The type name returned will be the argument type name as it was declared with any whitespace removed. If argument type name is an unsigned scalar type (i.e. unsigned char, unsigned short, 21 | /// unsigned int, unsigned long), uchar, ushort, uint and ulong will be returned. The argument type name returned does not include any type qualifiers. 22 | /// 23 | TypeName = 0x1198, 24 | 25 | /// 26 | /// The type qualifier specified for the argument. 27 | /// 28 | TypeQualifier = 0x1199, 29 | 30 | /// 31 | /// The name specified for the argument. 32 | /// 33 | Name = 0x119A 34 | } 35 | } -------------------------------------------------------------------------------- /src/OpenCL-dotnet/OpenCl.DotNetCore/OpenCl.DotNetCore.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | This is a .NET Core wrapper for OpenCL 2.1. 5 | Copyright © 2016 David Neumann 6 | OpenCL.NET Core 7 | 0.1.0-alpha1 8 | David Neumann 9 | netstandard2.0 10 | OpenCl.DotNetCore 11 | OpenCl.DotNetCore 12 | 1.6.1 13 | 14 | 15 | 16 | true 17 | x64 18 | 19 | 20 | 21 | true 22 | x64 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /src/OpenCL-dotnet/OpenCl.DotNetCore.Interop/CommandQueues/CommandQueueInformation.cs: -------------------------------------------------------------------------------- 1 | 2 | namespace OpenCl.DotNetCore.Interop 3 | { 4 | /// 5 | /// Represents an enumeration for the different types of information that can be queried from a command queue. 6 | /// 7 | public enum CommandQueueInformation : uint 8 | { 9 | /// 10 | /// The context specified when the command-queue is created. 11 | /// 12 | Context = 0x1090, 13 | 14 | /// 15 | /// The device specified when the command-queue is created. 16 | /// 17 | Device = 0x1091, 18 | 19 | /// 20 | /// The reference count should be considered immediately stale. It is unsuitable for general use in applications. This feature is provided for identifying memory leaks. 21 | /// 22 | ReferenceCount = 0x1092, 23 | 24 | /// 25 | /// The currently specified properties for the command-queue. 26 | /// 27 | Properties = 0x1093, 28 | 29 | /// 30 | /// The currently specified size for the device command-queue. This query is only supported for device command queues. 31 | /// 32 | Size = 0x1094, 33 | 34 | /// 35 | /// The current default command queue for the underlying device. 36 | /// 37 | DeviceDefault = 0x1095 38 | } 39 | } -------------------------------------------------------------------------------- /src/SharedSerialization/DirComm.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SharedSerialization 6 | { 7 | [SerializableAttribute] 8 | public class MinerInfo 9 | { 10 | public string MinerName { get; set; } 11 | public string MinerUniqueName => MinerName; 12 | public List Workers { get; set; } 13 | } 14 | 15 | [SerializableAttribute] 16 | public class WorkerInfo 17 | { 18 | public string GPUStatus { get; set; } 19 | public float GraphsPerSecond { get; set; } 20 | public uint TotalSols { get; set; } 21 | public double Fidelity { get; set; } 22 | //public LogMessage LastLog { get; set; } 23 | public int ID { get; set; } 24 | public DateTime Time { get; set; } 25 | public GPUOption GPUOption { get; set; } 26 | public DateTime lastSolution { get; set; } 27 | public int Errors { get; set; } 28 | public string GPUName { get; set; } 29 | public LogMessage LastLog = new LogMessage() { message = "-", time = DateTime.MinValue }; 30 | public LogMessage LastDebugLog; 31 | public LogMessage LastErrLog = null; 32 | } 33 | 34 | [SerializableAttribute] 35 | public enum GPUStatus : int 36 | { 37 | STARTING, 38 | DISABLED, 39 | ONLINE, 40 | OFFLINE, 41 | ERROR, 42 | OOM 43 | } 44 | 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/GrinProMInerAPI/GrinGoldMinerAPI.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp2.2 5 | InProcess 6 | 7 | Exe 8 | 9 | 10 | 11 | 12 | x64 13 | 14 | 15 | 16 | x64 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | Always 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /src/OpenCL-dotnet/OpenCl.DotNetCore.Interop/Devices/DeviceSvmCapability.cs: -------------------------------------------------------------------------------- 1 | 2 | #region Using Directives 3 | 4 | using System; 5 | 6 | #endregion 7 | 8 | namespace OpenCl.DotNetCore.Interop.Devices 9 | { 10 | /// 11 | /// Represents an enumration for the different SVM capabilities a device may have. 12 | /// 13 | [Flags] 14 | public enum DeviceSvmCapabilities : ulong 15 | { 16 | /// 17 | /// Support for coarse-grain buffer sharing using . Memory consistency is guaranteed at synchronization points and the host must use calls to and 18 | /// . 19 | /// 20 | CoarseGrainBuffer = 1 << 0, 21 | 22 | /// 23 | /// Support for fine-grain buffer sharing using . Memory consistency is guaranteed at synchronization points without need for and . 24 | /// 25 | FineGrainBuffer = 1 << 1, 26 | 27 | /// 28 | /// Support for sharing the host’s entire virtual memory including memory allocated using malloc. Memory consistency is guaranteed at synchronization points. 29 | /// 30 | FineGrainSystem = 1 << 2, 31 | 32 | /// 33 | /// Support for the OpenCL 2.0 atomic operations that provide memory consistency across the host and all OpenCL devices supporting fine-grain SVM allocations. 34 | /// 35 | Atomics = 1 << 3 36 | } 37 | } -------------------------------------------------------------------------------- /src/OpenCL-dotnet/OpenCl.DotNetCore.Interop/Events/EventInformation.cs: -------------------------------------------------------------------------------- 1 | 2 | namespace OpenCl.DotNetCore.Interop.Events 3 | { 4 | /// 5 | /// Represents an enumeration that identifies the event information that can be queried from an event. 6 | /// 7 | public enum EventInformation : uint 8 | { 9 | /// 10 | /// The command-queue associated with the event. For user event objects, a null value is returned. If the cl_khr_gl_sharing extension is enabled, the command queue of a linked event null, because the event is not associated 11 | /// with any OpenCL command queue. If the cl_khr_egl_event extension is enabled, the CL_EVENT_COMMAND_QUEUE of a linked event is null, because the event is not associated with any OpenCL command queue. 12 | /// 13 | CommandQueue = 0x11D0, 14 | 15 | /// 16 | /// The command associated with the event. 17 | /// 18 | CommandType = 0x11D1, 19 | 20 | /// 21 | /// The event reference count. The reference count returned should be considered immediately stale. It is unsuitable for general use in applications. This feature is provided for identifying memory leaks. 22 | /// 23 | ReferenceCount = 0x11D2, 24 | 25 | /// 26 | /// The execution status of the command identified by the event. 27 | /// 28 | CommandExecutionStatus = 0x11D3, 29 | 30 | /// 31 | /// The context associated with the event. 32 | /// 33 | Context = 0x11D4 34 | } 35 | } -------------------------------------------------------------------------------- /src/OpenCL-dotnet/OpenCl.DotNetCore/Devices/DeviceType.cs: -------------------------------------------------------------------------------- 1 | 2 | #region Using Directives 3 | 4 | using System; 5 | 6 | #endregion 7 | 8 | namespace OpenCl.DotNetCore.Devices 9 | { 10 | /// 11 | /// Represents the different device types that can be supported by an OpenCL platform. 12 | /// 13 | [Flags] 14 | public enum DeviceType : ulong 15 | { 16 | /// 17 | /// The default OpenCL device in the system. The default device cannot be a DeviceType.Custom device. 18 | /// 19 | Default = 1 << 0, 20 | 21 | /// 22 | /// An OpenCL device that is the host processor. The host processor runs the OpenCL implementations and is a single or multi-core CPU. 23 | /// 24 | Cpu = 1 << 1, 25 | 26 | /// 27 | /// An OpenCL device that is a GPU. By this we mean that the device can also be used to accelerate a 3D API such as OpenGL or DirectX. 28 | /// 29 | Gpu = 1 << 2, 30 | 31 | /// 32 | /// Dedicated OpenCL accelerators (for example the IBM CELL Blade). These devices communicate with the host processor using a peripheral interconnect such as PCIe. 33 | /// 34 | Accelerator = 1 << 3, 35 | 36 | /// 37 | /// Dedicated accelerators that do not support programs written in OpenCL C. 38 | /// 39 | Custom = 1 << 4, 40 | 41 | /// 42 | /// All OpenCL devices available in the system except DeviceType.Custom devices. 43 | /// 44 | All = 0xFFFFFFFF 45 | } 46 | } -------------------------------------------------------------------------------- /src/OpenCL-dotnet/OpenCl.DotNetCore.Interop/Devices/DeviceType.cs: -------------------------------------------------------------------------------- 1 | 2 | #region Using Directives 3 | 4 | using System; 5 | 6 | #endregion 7 | 8 | namespace OpenCl.DotNetCore.Interop.Devices 9 | { 10 | /// 11 | /// Represents the different device types that can be supported by an OpenCL platform. 12 | /// 13 | [Flags] 14 | public enum DeviceType : ulong 15 | { 16 | /// 17 | /// The default OpenCL device in the system. The default device cannot be a DeviceType.Custom device. 18 | /// 19 | Default = 1 << 0, 20 | 21 | /// 22 | /// An OpenCL device that is the host processor. The host processor runs the OpenCL implementations and is a single or multi-core CPU. 23 | /// 24 | Cpu = 1 << 1, 25 | 26 | /// 27 | /// An OpenCL device that is a GPU. By this we mean that the device can also be used to accelerate a 3D API such as OpenGL or DirectX. 28 | /// 29 | Gpu = 1 << 2, 30 | 31 | /// 32 | /// Dedicated OpenCL accelerators (for example the IBM CELL Blade). These devices communicate with the host processor using a peripheral interconnect such as PCIe. 33 | /// 34 | Accelerator = 1 << 3, 35 | 36 | /// 37 | /// Dedicated accelerators that do not support programs written in OpenCL C. 38 | /// 39 | Custom = 1 << 4, 40 | 41 | /// 42 | /// All OpenCL devices available in the system except DeviceType.Custom devices. 43 | /// 44 | All = 0xFFFFFFFF 45 | } 46 | } -------------------------------------------------------------------------------- /src/OpenCL-dotnet/OpenCl.DotNetCore.Interop/Profiling/ProfilingInformation.cs: -------------------------------------------------------------------------------- 1 | 2 | namespace OpenCl.DotNetCore.Interop 3 | { 4 | /// 5 | /// Represents an enumeration for the different types of information that can be queried for profiling purposes. 6 | /// 7 | public enum ProfilingInformation : uint 8 | { 9 | /// 10 | /// A 64-bit value that describes the current device time counter in nanoseconds when the command identified by the event is enqueued in a command-queue by the host. 11 | /// 12 | CommandQueued = 0x1280, 13 | 14 | /// 15 | /// A 64-bit value that describes the current device time counter in nanoseconds when the command identified by the event that has been enqueued is submitted by the host to the device associated with the command-queue. 16 | /// 17 | CommandSubmit = 0x1281, 18 | 19 | /// 20 | /// A 64-bit value that describes the current device time counter in nanoseconds when the command identified by the event starts execution on the device. 21 | /// 22 | CommandStart = 0x1282, 23 | 24 | /// 25 | /// A 64-bit value that describes the current device time counter in nanoseconds when the command identified by the event has finished execution on the device. 26 | /// 27 | CommandEnd = 0x1283, 28 | 29 | /// 30 | /// A 64-bit value that describes the current device time counter in nanoseconds when the command identified by the event and any child commands enqueued by this command on the device have finished execution. 31 | /// 32 | CommandComplete = 0x1284 33 | } 34 | } -------------------------------------------------------------------------------- /src/OpenCL-dotnet/OpenCl.DotNetCore.Interop/Samplers/SamplerInformation.cs: -------------------------------------------------------------------------------- 1 | 2 | namespace OpenCl.DotNetCore.Interop.Samplers 3 | { 4 | /// 5 | /// Represents an enumeration for the different types of information that can be queried from a sampler object. 6 | /// 7 | public enum SamplerInformation : uint 8 | { 9 | /// 10 | /// Retrieves the sampler reference count. The reference count returned should be considered immediately stale. It is unsuitable for general use in applications. This feature is provided for identifying memory leaks. 11 | /// 12 | ReferenceCount = 0x1150, 13 | 14 | /// 15 | /// Retrieves the context specified when the sampler is created. 16 | /// 17 | Context = 0x1151, 18 | 19 | /// 20 | /// Retrieves the normalized coordinates value associated with the sampler. 21 | /// 22 | NormalizedCoordinates = 0x1152, 23 | 24 | /// 25 | /// Retrieves the addressing mode value associated with the sampler. 26 | /// 27 | AddressingMode = 0x1153, 28 | 29 | /// 30 | /// Retrieves the filter mode value associated with the sampler. 31 | /// 32 | FilterMode = 0x1154, 33 | 34 | /// 35 | /// Retrievess the MIP filter mode. 36 | /// 37 | MipFilterMode = 0x1155, 38 | 39 | /// 40 | /// Retrieves the LOD minimum. 41 | /// 42 | LodMinimum = 0x1156, 43 | 44 | /// 45 | /// Retrieves the LOD maximum. 46 | /// 47 | LodMaximum = 0x1157 48 | } 49 | } -------------------------------------------------------------------------------- /src/OpenCL-dotnet/OpenCl.DotNetCore.Interop/Devices/DeviceFloatingPointConfiguration.cs: -------------------------------------------------------------------------------- 1 | 2 | #region Using Directives 3 | 4 | using System; 5 | 6 | #endregion 7 | 8 | namespace OpenCl.DotNetCore.Interop.Devices 9 | { 10 | /// 11 | /// Represents an enumeration for the different floating point configurations of devices. 12 | /// 13 | [Flags] 14 | public enum DeviceFloatingPointConfiguration : ulong 15 | { 16 | /// 17 | /// Denorms are supported. 18 | /// 19 | Denorm = 1 << 0, 20 | 21 | /// 22 | /// Inifinity (INF) and Not-a-Number's (NaNs) are supported. 23 | /// 24 | InfinityAndNotANumber = 1 << 1, 25 | 26 | /// 27 | /// Round to nearest even rounding mode is supported. 28 | /// 29 | RoundToNearest = 1 << 2, 30 | 31 | /// 32 | /// Round to zero rounding mode supported. 33 | /// 34 | RoundToZero = 1 << 3, 35 | 36 | /// 37 | /// Round to +ve and -ve infinity rounding modes supported. 38 | /// 39 | RoundToInfinity = 1 << 4, 40 | 41 | /// 42 | /// IEEE754-2008 fused multiply-add is supported. 43 | /// 44 | FusedMultiplyAdd = 1 << 5, 45 | 46 | /// 47 | /// Basic floating-point operations (such as addition, subtraction, multiplication) are implemented in software. 48 | /// 49 | SoftwareFloat = 1 << 6, 50 | 51 | /// 52 | /// Divide and sqrt are correctly rounded as defined by the IEEE754 specification. 53 | /// 54 | CorrectlyRoundedDivideSquareRoot = 1 << 7 55 | } 56 | } -------------------------------------------------------------------------------- /src/OpenCL-dotnet/OpenCl.DotNetCore.Interop/IntroducedInOpenClAttribute.cs: -------------------------------------------------------------------------------- 1 | 2 | #region Using Directives 3 | 4 | using System; 5 | 6 | #endregion 7 | 8 | namespace OpenCl.DotNetCore.Interop 9 | { 10 | /// 11 | /// Represents a custom attribute, which can be used to mark an element of the public API with the OpenCL version that is was introduced in. 12 | /// 13 | [AttributeUsage(AttributeTargets.Enum | AttributeTargets.Field | AttributeTargets.Method | AttributeTargets.Struct, Inherited = true, AllowMultiple = false)] 14 | public class IntroducedInOpenClAttribute : Attribute 15 | { 16 | #region Constructors 17 | 18 | /// 19 | /// Initializes a new instance. 20 | /// 21 | /// The major version of OpenCL in which the marked element of the public API was introduced. 22 | /// The minor version of OpenCL in which the marked element of the public API was introduced. 23 | public IntroducedInOpenClAttribute(int majorVersion, int minorVersion) 24 | { 25 | this.MajorVersion = majorVersion; 26 | this.MinorVersion = minorVersion; 27 | } 28 | 29 | #endregion 30 | 31 | #region Public Properties 32 | 33 | /// 34 | /// Gets or sets the major version of OpenCL in which the marked element of the public API was introduced. 35 | /// 36 | public int MajorVersion { get; private set; } 37 | 38 | /// 39 | /// Gets or sets the minor version of OpenCL in which the marked element of the public API was introduced. 40 | /// 41 | public int MinorVersion { get; private set; } 42 | 43 | #endregion 44 | } 45 | } -------------------------------------------------------------------------------- /src/OpenCL-dotnet/OpenCl.DotNetCore.Interop/Devices/DeviceAffinityDomain.cs: -------------------------------------------------------------------------------- 1 | 2 | #region Using Directives 3 | 4 | using System; 5 | 6 | #endregion 7 | 8 | namespace OpenCl.DotNetCore.Interop.Devices 9 | { 10 | /// 11 | /// Represents an enumeration for the different affinity domains devices may have. 12 | /// 13 | [Flags] 14 | public enum DeviceAffinityDomain : ulong 15 | { 16 | /// 17 | /// Split the device into sub-devices comprised of compute units that share a NUMA node. 18 | /// 19 | Numa = 1 << 0, 20 | 21 | /// 22 | /// Split the device into sub-devices comprised of compute units that share a level 4 data cache. 23 | /// 24 | Level4Cache = 1 << 1, 25 | 26 | /// 27 | /// Split the device into sub-devices comprised of compute units that share a level 3 data cache. 28 | /// 29 | Level3Cache = 1 << 2, 30 | 31 | /// 32 | /// Split the device into sub-devices comprised of compute units that share a level 2 data cache. 33 | /// 34 | Level2Cache = 1 << 3, 35 | 36 | /// 37 | /// Split the device into sub-devices comprised of compute units that share a level 1 data cache. 38 | /// 39 | Level1Cache = 1 << 4, 40 | 41 | /// 42 | /// Split the device along the next partitionable affinity domain. The implementation shall find the first level along which the device or sub-device may be further subdivided in the order NUMA, L4, L3, L2, L1, and partition the 43 | /// device into sub-devices comprised of compute units that share memory subsystems at this level. 44 | /// 45 | NextPartitionable = 1 << 5 46 | } 47 | } -------------------------------------------------------------------------------- /src/CudaSolver/CudaSolver.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.2 6 | 7 | 8 | 9 | x64 10 | true 11 | 12 | 13 | 14 | x64 15 | true 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | Never 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | True 41 | True 42 | Resources.resx 43 | 44 | 45 | 46 | 47 | 48 | ResXFileCodeGenerator 49 | Resources.Designer.cs 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /src/OclSolver/OclSolver.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.2 6 | 7 | 8 | 9 | x64 10 | true 11 | 12 | 13 | 14 | true 15 | x64 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | Always 37 | 38 | 39 | Always 40 | 41 | 42 | Always 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /src/GrinProMInerAPI/_README.txt: -------------------------------------------------------------------------------- 1 | GGM3 2 | ----------------------------------- 3 | 4 | Make sure you have latest drivers. PTX JIT failure on nvidia is an indication that drivers don't have Cuda10 support. 5 | Check with nvidia-smi. 6 | 7 | Miner can accept some command line arguments like api-port=5777 or configpath=/path/to/ 8 | All possible arguments are documented at: https://gist.github.com/urza/331bf94b78a3c1bf04a1f8104f6b41cb 9 | 10 | First run will generate config.xml and ask for stratum connections and try to auto-detect GPU devices. 11 | If you want to run directly without waiting for user input you have 2 options: 12 | 1. Make sure config.xml exists in directory of miner executable 13 | - see manual_config.xml for example and modify your values 14 | - you can also read config from other location with ./GrinProMiner configpath=/absolute/path/to/directory 15 | (path must be absolute, must exist and must contain config.xml) 16 | 2. You can use command-line arguments (but you will lose some options, config.xml is preferred option): 17 | ./GrinProMiner ignore-config=true stratum-address=eu-west-stratum.grinmint.com stratum-port=4416 stratum-tls=true stratum-login=logina@example.com nvidia=0 amd=0:0 18 | (this will ignore config.xml and will start mining on grinmint pool with 2 GPUs - one Nvidia (Device ID 0) and one AMD (platform 0, Device ID 0)) 19 | 20 | API: 21 | Miner has JSON API: 22 | http://localhost:5777/api 23 | API can be used to get status of the miner, information about GPUs, Connections, Config. 24 | API can also change current stratum connection and config options. 25 | API DOCS: https://grinpro.io/api.html 26 | 27 | LOGS: 28 | Logs are saved to logs/ directory 29 | You can set your logging preferences (or disable logging) in config.xml 30 | 31 | 32 | Optimize CPU usage: 33 | 34 | Change value in config.xml 35 | 0 36 | 37 | 0 - automatic CPU load balancer 38 | 10 - minimal CPU usage, less GPS 39 | 100 - maximum CPU usage, more GPS 40 | 41 | numbers between 0 .. 100+ are possible -------------------------------------------------------------------------------- /src/OpenCL-dotnet/OpenCl.DotNetCore.Interop/CommandQueues/CommandQueueProperty.cs: -------------------------------------------------------------------------------- 1 | 2 | #region Using Directives 3 | 4 | using System; 5 | 6 | #endregion 7 | 8 | namespace OpenCl.DotNetCore.Interop.CommandQueues 9 | { 10 | /// 11 | /// Represents an enumeration for the command queue properties. 12 | /// 13 | [Flags] 14 | public enum CommandQueueProperty : ulong 15 | { 16 | /// 17 | /// Determines whether the commands queued in the command-queue are executed in-order or out-of-order. If set, the commands in the command-queue are executed out-of-order. Otherwise, commands are executed in-order. 18 | /// 19 | OutOfOrderExecutionModeEnable = 1 << 0, 20 | 21 | /// 22 | /// Enables or disables profiling of commands in the command-queue. If set, the profiling of commands is enabled. Otherwise profiling of commands is disabled. 23 | /// 24 | ProfilingEnable = 1 << 1, 25 | 26 | /// 27 | /// Indicates that the command-queue is a device queue. If CommandQueueProperty.OnDevice is set, CommandQueuePropertyOutOfOrderExecutionModeEnable must also be set. Only out-of-order device queues are supported. 28 | /// 29 | OnDevice = 1 << 2, 30 | 31 | /// 32 | /// Indicates that this is the default device queue. This can only be used with CommandQueueProperty.OnDevice. The application must create the default device queue if any kernels containing calls to 33 | /// are enqueued. There can only be one default device queue for each device within a context. with CommandQueueInformation.Properties set to 34 | /// CommandQueueProperty.OnDevice | CommandQueueProperty.OnDeviceDefault will return the default device queue that has already been created and increment its retain count by 1. 35 | /// 36 | OnDeviceDefault = 1 << 3 37 | } 38 | } -------------------------------------------------------------------------------- /src/OpenCL-dotnet/OpenCl.DotNetCore.Interop/EnqueuedCommands/MapFlag.cs: -------------------------------------------------------------------------------- 1 | 2 | #region Using Directives 3 | 4 | using System; 5 | 6 | #endregion 7 | 8 | namespace OpenCl.DotNetCore.Interop.EnqueuedCommands 9 | { 10 | /// 11 | /// Represents an enumeration for the different flags, that can be used when mapping device memory to host memory. 12 | /// 13 | [Flags] 14 | public enum MapFlag : ulong 15 | { 16 | /// 17 | /// This flag specifies that the region being mapped in the memory object is being mapped for reading. The pointer returned by and is guaranteed to contain the latest bits in the 18 | /// region being mapped when the or command has completed. 19 | /// 20 | Read = 1 << 0, 21 | 22 | /// 23 | /// This flag specifies that the region being mapped in the memory object is being mapped for writing. The pointer returned by and is guaranteed to contain the latest bits in the 24 | /// region being mapped when the or command has completed. 25 | /// 26 | Write = 1 << 1, 27 | 28 | /// 29 | /// This flag specifies that the region being mapped in the memory object is being mapped for writing. The contents of the region being mapped are to be discarded. This is typically the case when the region being mapped is overwritten by 30 | /// the host. This flag allows the implementation to no longer guarantee that the pointer returned by or contains the latest bits in the region being mapped which can be a 31 | /// significant performance enhancement. MapFlag.Read or MapFlag.Write and MapFlag.WriteInvalidateRegion are mutually exclusive. 32 | /// 33 | WriteInvalidateRegion = 1 << 2 34 | } 35 | } -------------------------------------------------------------------------------- /src/GrinProMInerAPI/Controllers/WorkersController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Http; 6 | using Microsoft.AspNetCore.Mvc; 7 | using Mozkomor.GrinGoldMiner; 8 | using SharedSerialization; 9 | 10 | namespace GrinProMiner.Controllers 11 | { 12 | [Route("api/[controller]")] 13 | [ApiController] 14 | public class WorkersController : ControllerBase 15 | { 16 | [HttpGet] 17 | public ActionResult> Get() 18 | { 19 | List workers = new List(); 20 | foreach (var worker in WorkerManager.GetWorkersInfo()) 21 | { 22 | //WorkerInfo wi = new WorkerInfo(); 23 | //wi.GPUOption = worker.gpu; 24 | //wi.GPUStatus = worker.GetStatus().ToString(); 25 | //wi.GraphsPerSecond = worker.currentGPS; 26 | //wi.ID = worker.ID; 27 | //wi.LastLog = null; 28 | //wi.Time = DateTime.Now; 29 | //wi.TotalSols = worker.totalSols; 30 | //wi.lastSolution = worker.lastSolTime; 31 | //wi.Errors = worker.errors; 32 | workers.Add(worker); 33 | } 34 | return workers; 35 | } 36 | 37 | [HttpGet("{id}")] 38 | public ActionResult Get(int id) 39 | { 40 | var worker = WorkerManager.GetWorkersInfo().Where(x => x.ID == id).FirstOrDefault(); 41 | 42 | if (worker == null) 43 | return StatusCode(404, $"No worker with id {id} found"); 44 | 45 | //WorkerInfo wi = new WorkerInfo(); 46 | //wi.GPUOption = worker.gpu; 47 | //wi.GPUStatus =worker.GetStatus().ToString(); 48 | //wi.GraphsPerSecond = worker.currentGPS; 49 | //wi.ID = worker.ID; 50 | //wi.LastLog = null; 51 | //wi.Time = DateTime.Now; 52 | //wi.TotalSols = worker.totalSols; 53 | //wi.lastSolution = worker.lastSolTime; 54 | //wi.Errors = worker.errors; 55 | 56 | return worker; 57 | } 58 | } 59 | } -------------------------------------------------------------------------------- /src/GrinProMInerAPI/Models/Status.cs: -------------------------------------------------------------------------------- 1 | using SharedSerialization; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | 7 | namespace GrinProMiner.Models 8 | { 9 | public class Status 10 | { 11 | public StratumConnectionInfo ActiveConnection { get; set; } 12 | public string LastJob { get; set; } //seconds 13 | public string LastShare { get; set; } //seconds 14 | public ShareStats Shares { get; set; } 15 | public List Workers { get; set; } 16 | } 17 | 18 | public class SimpleStatus 19 | { 20 | public string ConnectionAddress { get; set; } 21 | public string ConnectionStatus { get; set; } 22 | public string LastJob { get; set; } //seconds 23 | public string LastShare { get; set; } //seconds 24 | public ShareStats Shares { get; set; } 25 | public List Workers { get; set; } 26 | } 27 | 28 | public class SimpleWorkerInfo 29 | { 30 | public int ID { get; set; } 31 | public string Platform { get; set; } 32 | public string GPUName { get; set; } 33 | public string Status { get; set; } 34 | public float GraphsPerSecond { get; set; } 35 | public uint TotalSols { get; set; } 36 | public float Fidelity { get; set; } 37 | public string LastSolution { get; set; } 38 | } 39 | 40 | public class StratumConnectionInfo 41 | { 42 | public string Address { get; set; } 43 | public string Port { get; set; } 44 | public string Status { get; set; } 45 | public string Login { get; set; } 46 | public string Password { get; set; } 47 | public string LastCommunication { get; set; } 48 | public string LastJob { get; set; } 49 | } 50 | 51 | public class ShareStats 52 | { 53 | public uint Found { get; set; } 54 | public uint Submitted { get; set; } 55 | public uint Accepted { get; set; } 56 | public uint TooLate { get; set; } 57 | public uint FailedToValidate { get; set; } 58 | } 59 | 60 | public class ShareInfo 61 | { 62 | public string Reason { get; set; } 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /src/SharedSerialization/Blake2B-Simple.cs: -------------------------------------------------------------------------------- 1 | /* BLAKE2 reference source code package - C# implementation 2 | 3 | Written in 2012 by Samuel Neves 4 | Written in 2012 by Christian Winnerlein 5 | Written in 2016 by Uli Riehm 6 | 7 | To the extent possible under law, the author(s) have dedicated all copyright 8 | and related and neighboring rights to this software to the public domain 9 | worldwide. This software is distributed without any warranty. 10 | 11 | You should have received a copy of the CC0 Public Domain Dedication along with 12 | this software. If not, see . 13 | */ 14 | 15 | using System; 16 | 17 | namespace Crypto 18 | { 19 | #if SIMPLE 20 | public partial class Blake2B 21 | { 22 | private ulong[] v = new ulong[16]; 23 | 24 | private static ulong RotateRight(ulong value, int nBits) 25 | { 26 | return (value >> nBits) | (value << (64 - nBits)); 27 | } 28 | 29 | private void G(int a, int b, int c, int d, int r, int i) 30 | { 31 | int p = (r << 4) + i; 32 | int p0 = Sigma[p]; 33 | int p1 = Sigma[p + 1]; 34 | 35 | v[a] += v[b] + material[p0]; 36 | v[d] = RotateRight(v[d] ^ v[a], 32); 37 | v[c] += v[d]; 38 | v[b] = RotateRight(v[b] ^ v[c], 24); 39 | v[a] += v[b] + material[p1]; 40 | v[d] = RotateRight(v[d] ^ v[a], 16); 41 | v[c] += v[d]; 42 | v[b] = RotateRight(v[b] ^ v[c], 63); 43 | } 44 | 45 | partial void Compress() 46 | { 47 | v[0] = state[0]; 48 | v[1] = state[1]; 49 | v[2] = state[2]; 50 | v[3] = state[3]; 51 | v[4] = state[4]; 52 | v[5] = state[5]; 53 | v[6] = state[6]; 54 | v[7] = state[7]; 55 | 56 | v[8] = IV0; 57 | v[9] = IV1; 58 | v[10] = IV2; 59 | v[11] = IV3; 60 | v[12] = IV4 ^ counter0; 61 | v[13] = IV5 ^ counter1; 62 | v[14] = IV6 ^ f0; 63 | v[15] = IV7 ^ f1; 64 | 65 | for (int r = 0; r < NumberOfRounds; ++r) 66 | { 67 | G(0, 4, 8, 12, r, 0); 68 | G(1, 5, 9, 13, r, 2); 69 | G(2, 6, 10, 14, r, 4); 70 | G(3, 7, 11, 15, r, 6); 71 | G(3, 4, 9, 14, r, 14); 72 | G(2, 7, 8, 13, r, 12); 73 | G(0, 5, 10, 15, r, 8); 74 | G(1, 6, 11, 12, r, 10); 75 | } 76 | 77 | for (int i = 0; i < 8; ++i) 78 | state[i] ^= v[i] ^ v[i + 8]; 79 | } 80 | } 81 | #endif 82 | } 83 | -------------------------------------------------------------------------------- /src/OpenCL-dotnet/OpenCl.DotNetCore.Interop/Platforms/PlatformInformation.cs: -------------------------------------------------------------------------------- 1 | 2 | namespace OpenCl.DotNetCore.Interop.Platforms 3 | { 4 | /// 5 | /// Represents an enumeration for the different types of information that can be queried from an OpenCl platform. 6 | /// 7 | public enum PlatformInformation : uint 8 | { 9 | /// 10 | /// OpenCL profile string. Returns the profile name supported by the implementation. The profile name returned can be one of the following strings: FULL_PROFILE - if the implementation supports the OpenCL specification (functionality 11 | /// defined as part of the core specification and does not require any extensions to be supported). EMBEDDED_PROFILE - if the implementation supports the OpenCL embedded profile. The embedded profile is defined to be a subset for each 12 | /// version of OpenCL. 13 | /// 14 | Profile = 0x0900, 15 | 16 | /// 17 | /// OpenCL version string. Returns the OpenCL version supported by the implementation. This version string has the following format: "OpenCL[space][major_version.minor_version][space][platform-specific information]. 18 | /// 19 | Version = 0x0901, 20 | 21 | /// 22 | /// Platform name string. 23 | /// 24 | Name = 0x0902, 25 | 26 | /// 27 | /// Platform vendor string. 28 | /// 29 | Vendor = 0x0903, 30 | 31 | /// 32 | /// Returns a space-separated list of extension names (the extension names themselves do not contain any spaces) supported by the platform. Extensions defined here must be supported by all devices associated with this platform. 33 | /// 34 | Extensions = 0x0904, 35 | 36 | /// 37 | /// Returns the resolution of the host timer in nanoseconds as used by . 38 | /// 39 | PlatformHostTimerResolution = 0x0905, 40 | 41 | /// 42 | /// If the cl_khr_icd extension is enabled, the function name suffix used to identify extension functions to be directed to this platform by the ICD Loader. 43 | /// 44 | PlatformIcdSuffix = 0x0920 45 | } 46 | } -------------------------------------------------------------------------------- /src/OpenCL-dotnet/OpenCl.DotNetCore.Interop/Kernels/KernelSubGroupInformation.cs: -------------------------------------------------------------------------------- 1 | 2 | namespace OpenCl.DotNetCore.Interop.Kernels 3 | { 4 | /// 5 | /// Represents an enumeration for the different types of information that can be queried from an OpenCL kernel sub group. 6 | /// 7 | public enum KernelSubGroupInformation : uint 8 | { 9 | /// 10 | /// Returns the maximum sub-group size for the kernel. All subgroups must be the same size, while the last sub-group in any work-group (i.e. the sub-group with the maximum index) could be the same or smaller size. The input value must 11 | /// be an array of values corresponding to the local work size parameter of the intended dispatch. The number of dimensions in the ND-range will be inferred from the value specified for input value size. 12 | /// 13 | MaximumSubGroupSizeForNDRange = 0x2033, 14 | 15 | /// 16 | /// Returns the number of sub-groups that will be present in each work-group for a given local work size. All workgroups, apart from the last work-group in each dimension in the presence of non-uniform work-group sizes, will have the 17 | /// same number of subgroups. The input value must be an array of values corresponding to the local work size parameter of the intended dispatch. The number of dimensions in the ND-range will be inferred from the 18 | /// value specified for input value size. 19 | /// 20 | SubGroupCountForNDRange = 0x2034, 21 | 22 | /// 23 | /// Returns the local size that will generate the requested number of sub-groups for the kernel. The output array must be an array of values corresponding to the local size parameter. Any returned work-group will 24 | /// have one dimension. Other dimensions inferred from the value specified for parameter value size will be filled with the value 1. The returned value will produce an exact number of sub-groups and result in no partial groups for an 25 | /// executing kernel except in the case where the last work-group in a dimension has a size different from that of the other groups. If no work-group size can accommodate the requested number of sub-groups, 0 will be returned in each 26 | /// element of the return array. 27 | /// 28 | LocalSizeForSubGroupCount = 0x11B8 29 | } 30 | } -------------------------------------------------------------------------------- /src/OpenCL-dotnet/OpenCl.DotNetCore.Interop/Memory/MemoryObjectInformation.cs: -------------------------------------------------------------------------------- 1 | 2 | namespace OpenCl.DotNetCore.Interop.Memory 3 | { 4 | /// 5 | /// Represents an enumeration for the different types of information that can be queried from an memory object. 6 | /// 7 | public enum MemoryObjectInformation : uint 8 | { 9 | /// 10 | /// The type of the memory object. 11 | /// 12 | Type = 0x1100, 13 | 14 | /// 15 | /// The flags argument value specified when the memory object was created. 16 | /// 17 | Flags = 0x1101, 18 | 19 | /// 20 | /// The actual size of the data store associated with memory object in bytes. 21 | /// 22 | Size = 0x1102, 23 | 24 | /// 25 | /// The host pointer argument value specified when memory object is created. 26 | /// 27 | HostPointer = 0x1103, 28 | 29 | /// 30 | /// The map count. The map count returned should be considered immediately stale. It is unsuitable for general use in applications. This feature is provided for debugging. 31 | /// 32 | MapCount = 0x1104, 33 | 34 | /// 35 | /// The reference count. The reference count returned should be considered immediately stale. It is unsuitable for general use in applications. This feature is provided for identifying memory leaks. 36 | /// 37 | ReferenceCount = 0x1105, 38 | 39 | /// 40 | /// The context specified when the memory object was created. 41 | /// 42 | Context = 0x1106, 43 | 44 | /// 45 | /// The memory object from which the memory object was created. 46 | /// 47 | AssociatedMemoryObject = 0x1107, 48 | 49 | /// 50 | /// The offset if memory object is a sub-buffer object created using . 51 | /// 52 | Offset = 0x1108, 53 | 54 | /// 55 | /// true if the memory object is a buffer object that was created with MemoryFlag.UseHostPointer or is a subbuffer object of a buffer object that was created with MemoryFlag.UseHostPointer and the 56 | /// host pointer specified when the buffer object was created is a SVM pointer. Otherwise false. 57 | /// 58 | UsesSvmPointer = 0x1109 59 | } 60 | } -------------------------------------------------------------------------------- /src/OpenCL-dotnet/OpenCl.DotNetCore.Interop/Memory/ImageInformation.cs: -------------------------------------------------------------------------------- 1 | 2 | namespace OpenCl.DotNetCore.Interop.Memory 3 | { 4 | /// 5 | /// Represents an enumeration for the different types of information that can be queried from an image object. 6 | /// 7 | public enum ImageInformation : uint 8 | { 9 | /// 10 | /// Return image format descriptor specified when image is created with . 11 | /// 12 | Format = 0x1110, 13 | 14 | /// 15 | /// Return size of each element of the image memory object given by image in bytes. An element is made up of n channels. The value of n is given in image format descriptor. 16 | /// 17 | ElementSize = 0x1111, 18 | 19 | /// 20 | /// Return calculated row pitch in bytes of a row of elements of the image object given by image. 21 | /// 22 | RowPitch = 0x1112, 23 | 24 | /// 25 | /// Return calculated slice pitch in bytes of a 2D slice for the 3D image object or size of each image in a 1D or 2D image array given by image. For a 1D image, 1D image buffer and 2D image object return 0. 26 | /// 27 | SlicePitch = 0x1113, 28 | 29 | /// 30 | /// Return width of image in pixels. 31 | /// 32 | Width = 0x1114, 33 | 34 | /// 35 | /// Return height of image in pixels. For a 1D image, 1D image buffer and 1D image array object, height = 0. 36 | /// 37 | Height = 0x1115, 38 | 39 | /// 40 | /// Return depth of the image in pixels. For a 1D image, 1D image buffer, 2D image or 1D and 2D image array object, depth = 0. 41 | /// 42 | Depth = 0x1116, 43 | 44 | /// 45 | /// Return number of images in the image array. If image is not an image array, 0 is returned. 46 | /// 47 | ArraySize = 0x1117, 48 | 49 | /// 50 | /// Return buffer object associated with the image. 51 | /// 52 | Buffer = 0x1118, 53 | 54 | /// 55 | /// Return num_mip_levels associated with the image. 56 | /// 57 | NumberOfMipLevels = 0x1119, 58 | 59 | /// 60 | /// Return num_samples associated with the image. 61 | /// 62 | NumberOfSamples = 0x111A 63 | } 64 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # [DISCONTINUED - Does NOT work on current Grin chain!] 2 | # GGM - open-source Grin GPU miner 3 | 4 | _The miner is no longer being udpated to work with hard-forked PoW changes!_ 5 | 6 | Thanks to all miners who supported our software. We can no longer provide competitive open-source Grin miner to the community. 7 | 8 | We recommend grin-miner (open source, nvidia, linux) or lolminer (closed source, amd, windows/linux). 9 | 10 | ----- 11 | 12 | Miner supports all AMD and NVIDIA 6GB+ cards for both Linux and Winows (MacOS untested). Up to 60% faster compared to GGM2. 13 | 14 | GGM releases collect 1% fee for the Grin Development Fund and 1% fee for further miner development. 15 | 16 | ## How to build 17 | 18 | Miner is written entirely in C# using new open-source .NET implementation called Dotnet Core. 19 | 20 | Instal dotnet core 2.2 SDK (Linux/Windows/Mac) from https://dotnet.microsoft.com/download 21 | 22 | Clone the repository and go to _build forder. 23 | 24 | Run `build_win.bat` (Windows) or `build_linux.sh` (Linux). Alternatively, run `build_[OS]_API.bat` to build a miner with remote API support. 25 | API version can be used with our dashboard project to manage multiple rigs. 26 | 27 | Run `run_miner_win.bat` or `run_miner_linux.sh` to start the miner. 28 | 29 | *If you wish to build CUDA .ptx intermediate code yourself, install CUDA SDK with compatible compiler and compile the project in Cudacka folder. 30 | Pre-generated PTX file is already included in the repository so there is no need to pre-compile it yourself.* 31 | 32 | ## How to run binary releases 33 | 34 | Both Winows and Linux builds are self-contained and come with all needed dotnet core libraries, there is no need to install any additional SW. 35 | 36 | ## Configuration 37 | 38 | GPUs should be auto-detected on first launch. Once `config.xml` is created you can edit is to access hidden options: 39 | 40 | ### Define log level 41 | 42 | ```xml 43 | INFO 44 | DEBUG 45 | ``` 46 | 47 | If you want to see all the details that are happening in the background, change the configration as above. Possible log level options are DEBUG, INFO, WARNING, ERROR. 48 | 49 | ### Change CPU load 50 | 51 | Locate this line in the config 52 | 53 | ```xml 54 | 55 | 0 56 | 57 | ``` 58 | 59 | If you wish to reduce CPU load use small numbers (1..10), if you have a powerful multi-core CPU then you can try higher values like 50..100. Value 0 mean auto-balancer. Automatic setting may not work optimally with either very weak CPUs and/or many fast GPUs on the PC (8 and more Vegas for example). 60 | -------------------------------------------------------------------------------- /help.md: -------------------------------------------------------------------------------- 1 | 2 | # GGM Features in CLI and Config 3 | 4 | 5 | ### Switch between static TUI (text user interface) and rolling console 6 | 7 | by pressing key "L" (lowercase and uppercase both should work) 8 | 9 | ### TUI not refreshing? 10 | Try pressing enter in the console window, on Windows the console can be sometimes "paused" by clicking in it 11 | 12 | ### Load config from different location: 13 | 14 | Linux: ./GrinGoldMinerCLI configpath=/absolute/path/to/directory 15 | Windows: GrinGoldMinerCLI.exe configpath=C:\absolute\path\to\directory 16 | path must be absolute and must exists, config will be created or loaded in this location 17 | 18 | ### Start withou TUI (rolling console only) 19 | 20 | Linux: ./GrinGoldMinerCLI mode=rolling 21 | Windows: GrinGoldMinerCLI.exe mode=rolling 22 | 23 | 24 | ### Define backup pool in case the primary pool is down: 25 | In your config.xml fill the SecondaryConnection details to another pool with your real account, for example: 26 | ``` 27 | 28 | eu-west-stratum.grinmint.com 29 | 4416 30 | true 31 | your@email.com/rig1 32 | password 33 | 34 | 35 | eu.stratum.grin-pool.org 36 | 3416 37 | false 38 | yourloginhere 39 | 40 | 41 | ``` 42 | ### Password in config 43 | Some pools require password every time, some pools only when you join for the first time and then can be blank, other pools require that you first create account on their web, yet other pools don't require password at all and treat this field differently. Always be sure you understand the pool's policy with "password" field. If you are deleting content of password tag from config.xml (because your pool does not require it) be sure you have it stored somewhere else safely. 44 | 45 | ### Define what you see in console or what gets logged into files 46 | Can be set in config.xml in 47 | ``` 48 | INFO 49 | INFO 50 | ``` 51 | Accepted values are DEBUG, INFO, WARNING, ERROR. 52 | DEBUG will slow down your mining and fill your disk really quickly. 53 | 54 | ### Offload some work from CPU to GPU 55 | 56 | 0 57 | 58 | value is integer between 5 and 90 59 | Experimental for Rigs with more cards and really slow CPUs. 60 | 61 | ### Sample config.xml with comments 62 | [commented config.xml](/src/Master/config.xml) 63 | 64 | 65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /src/OpenCL-dotnet/OpenCl.DotNetCore/Programs/Program.cs: -------------------------------------------------------------------------------- 1 | 2 | #region Using Directives 3 | 4 | using System; 5 | using OpenCl.DotNetCore.Interop; 6 | using OpenCl.DotNetCore.Interop.Kernels; 7 | using OpenCl.DotNetCore.Interop.Programs; 8 | using OpenCl.DotNetCore.Kernels; 9 | 10 | #endregion 11 | 12 | namespace OpenCl.DotNetCore.Programs 13 | { 14 | /// 15 | /// Represents an OpenCL program. 16 | /// 17 | public class Program : HandleBase 18 | { 19 | #region Constructors 20 | 21 | /// 22 | /// Initializes a new instance. 23 | /// 24 | /// The handle to the OpenCL program. 25 | internal Program(IntPtr handle) 26 | : base(handle) 27 | { 28 | } 29 | 30 | #endregion 31 | 32 | #region Public Methods 33 | 34 | /// 35 | /// Creates a kernel with the specified name from the program. 36 | /// 37 | /// The name of the kernel that is defined in the program. 38 | /// If the kernel could not be created, then an is thrown. 39 | /// Returns the created kernel. 40 | public Kernel CreateKernel(string kernelName) 41 | { 42 | // Allocates enough memory for the return value and retrieves it 43 | Result result; 44 | IntPtr kernelPointer = KernelsNativeApi.CreateKernel(this.Handle, kernelName, out result); 45 | if (result != Result.Success) 46 | throw new OpenClException("The kernel could not be created.", result); 47 | 48 | // Creates a new kernel object from the kernel pointer and returns it 49 | return new Kernel(kernelPointer); 50 | } 51 | 52 | #endregion 53 | 54 | #region IDisposable Implementation 55 | 56 | /// 57 | /// Disposes of the resources that have been acquired by the program. 58 | /// 59 | /// Determines whether managed object or managed and unmanaged resources should be disposed of. 60 | protected override void Dispose(bool disposing) 61 | { 62 | // Checks if the program has already been disposed of, if not, then the program is disposed of 63 | if (!this.IsDisposed) 64 | ProgramsNativeApi.ReleaseProgram(this.Handle); 65 | 66 | // Makes sure that the base class can execute its dispose logic 67 | base.Dispose(disposing); 68 | } 69 | 70 | #endregion 71 | } 72 | } -------------------------------------------------------------------------------- /src/OpenCL-dotnet/OpenCl.DotNetCore.Interop/Kernels/KernelInformation.cs: -------------------------------------------------------------------------------- 1 | 2 | namespace OpenCl.DotNetCore.Interop.Kernels 3 | { 4 | /// 5 | /// Represents an enumeration for the different types of information that can be queried from an OpenCL kernel. 6 | /// 7 | public enum KernelInformation : uint 8 | { 9 | /// 10 | /// The kernel function name. 11 | /// 12 | FunctionName = 0x1190, 13 | 14 | /// 15 | /// The number of arguments to kernel. 16 | /// 17 | NumberOfArguments = 0x1191, 18 | 19 | /// 20 | /// The kernel reference count. The reference count returned should be considered immediately stale. It is unsuitable for general use in applications. This feature is provided for identifying memory leaks. 21 | /// 22 | ReferenceCount = 0x1192, 23 | 24 | /// 25 | /// The context associated with kernel. 26 | /// 27 | Context = 0x1193, 28 | 29 | /// 30 | /// The program object associated with kernel. 31 | /// 32 | Program = 0x1194, 33 | 34 | /// 35 | /// Attributes specified using the __attribute__ qualifier with the kernel function declaration in the program source. These attributes include those on the __attribute__ page and other attributes supported by an implementation. 36 | /// Attributes are returned as they were declared inside __attribute__((...)), with any surrounding whitespace and embedded newlines removed. When multiple attributes are present, they are returned as a single, space delimited string. 37 | /// For kernels not created from OpenCL C source and the API call the string returned from this query will be empty. 38 | /// 39 | Attributes = 0x1195, 40 | 41 | /// 42 | /// This provides a mechanism for the application to query the maximum number of sub-groups that may make up each work-group to execute a kernel on a specific device. The OpenCL implementation uses the resource requirements of the 43 | /// kernel (register usage etc.) to determine what this work-group size should be. The returned value may be used to compute a work-group size to enqueue the kernel with to give a round number of sub-groups for an enqueue. 44 | /// 45 | MaxNumberOfSubGroups = 0x11B9, 46 | 47 | /// 48 | /// Returns the number of sub-groups specified in the kernel source or IL. If the sub-group count is not specified then 0 is returned. 49 | /// 50 | CompileNumberOfSubGroups = 0x11BA 51 | } 52 | } -------------------------------------------------------------------------------- /src/OpenCL-dotnet/OpenCl.DotNetCore/OpenClException.cs: -------------------------------------------------------------------------------- 1 | 2 | #region Using Directives 3 | 4 | using System; 5 | using OpenCl.DotNetCore.Interop; 6 | 7 | #endregion 8 | 9 | namespace OpenCl.DotNetCore 10 | { 11 | /// 12 | /// Represents an exception, which is thrown when there is an OpenCL error. 13 | /// 14 | public class OpenClException : Exception 15 | { 16 | #region Constructors 17 | 18 | /// 19 | /// Initializes a new instance. 20 | /// 21 | public OpenClException() { } 22 | 23 | /// 24 | /// Initializes a new instance. 25 | /// 26 | /// The error code that was returned by OpenCL. 27 | public OpenClException(Result result) 28 | { 29 | this.Result = result; 30 | } 31 | 32 | /// 33 | /// Initializes a new instance. 34 | /// 35 | /// An error message. 36 | public OpenClException(string message) 37 | : base(message) { } 38 | 39 | /// 40 | /// Initializes a new instance. 41 | /// 42 | /// An error message. 43 | /// The error code that was returned by OpenCL. 44 | public OpenClException(string message, Result result) 45 | : base($"{message} Error code: {result}.") 46 | { 47 | this.Result = result; 48 | } 49 | 50 | /// 51 | /// Initializes a new instance. 52 | /// 53 | /// An error message. 54 | /// The inner exception, which is the root cause for this exception. 55 | public OpenClException(string message, Exception inner) 56 | : base(message, inner) { } 57 | 58 | /// 59 | /// Initializes a new instance. 60 | /// 61 | /// An error message. 62 | /// The inner exception, which is the root cause for this exception. 63 | /// The error code that was returned by OpenCL. 64 | public OpenClException(string message, Exception inner, Result result) 65 | : base($"{message} Error code: {result}.", inner) 66 | { 67 | this.Result = result; 68 | } 69 | 70 | #endregion 71 | 72 | #region Public Properties 73 | 74 | /// 75 | /// Gets the error code that was returned by OpenCL. 76 | /// 77 | public Result Result { get; private set; } 78 | 79 | #endregion 80 | } 81 | } -------------------------------------------------------------------------------- /src/Master/Config.cs: -------------------------------------------------------------------------------- 1 | // Grin Gold Miner https://github.com/urza/GrinGoldMiner 2 | // Copyright (c) 2018 Lukas Kubicek - urza 3 | // Copyright (c) 2018 Jiri Vadura - photon 4 | 5 | using SharedSerialization; 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Text; 9 | 10 | namespace Mozkomor.GrinGoldMiner 11 | { 12 | public class Config 13 | { 14 | public Connection PrimaryConnection { get; set; } 15 | public Connection SecondaryConnection { get; set; } 16 | public int ReconnectToPrimary { get; set; } 17 | public DashboardOptions RemoteDashboard { get; set; } 18 | public LogOptions LogOptions { get; set; } 19 | public int CPUOffloadValue { get; set; } 20 | public List GPUOptions { get; set; } 21 | 22 | 23 | public static Config GetDefaultConfig() 24 | { 25 | var c1 = new Connection() { ConnectionAddress = "us-east.stratum.grinmint.com", ConnectionPort = 13416, Login = "satoshi@nakamoto.com/rig21", Password = "myverystrongpassword", Ssl =false }; 26 | var c2 = new Connection() { ConnectionAddress = "backup_pooladdress", ConnectionPort = 13416, Login = "login", Password = "password", Ssl = false }; 27 | var logOptions = new LogOptions() {ConsoleMinimumLogLevel = LogLevel.INFO, FileMinimumLogLevel = LogLevel.WARNING, KeepDays=1, DisableLogging = false }; 28 | var remoteDashboard = new DashboardOptions() { DashboardAddress = "", RigName = "", SendInterval=60 }; 29 | List gpuOptions = new List() { new GPUOption() { DeviceID = 0, Enabled = true, GPUType = WorkerType.NVIDIA, PlatformID = 0 } }; 30 | return new Config() { PrimaryConnection = c1, 31 | SecondaryConnection = c2, 32 | ReconnectToPrimary = 0, 33 | RemoteDashboard = remoteDashboard, 34 | CPUOffloadValue = 0, 35 | GPUOptions = gpuOptions, 36 | LogOptions = logOptions }; 37 | } 38 | } 39 | 40 | public class DashboardOptions 41 | { 42 | public string DashboardAddress { get; set; } 43 | //public string DashboardPort { get; set; } 44 | public string RigName { get; set; } 45 | 46 | /// 47 | /// How often (in seconds) should miner push status info to remote dashboard 48 | /// If 0 then miner doesnt push, instead dashboard needs to pull (based on user interaction (refreshing page)) 49 | /// 50 | public int SendInterval { get; set; } 51 | } 52 | 53 | public class Connection 54 | { 55 | public string ConnectionAddress { get; set; } 56 | public int ConnectionPort { get; set; } 57 | public bool Ssl { get; set; } 58 | public string Login { get; set; } 59 | public string Password { get; set; } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/CudaSolver/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace CudaSolver.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("CudaSolver.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Overrides the current thread's CurrentUICulture property for all 51 | /// resource lookups using this strongly typed resource class. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/OpenCL-dotnet/OpenCl.DotNetCore/Platforms/Version.cs: -------------------------------------------------------------------------------- 1 | 2 | #region Using Directives 3 | 4 | using System; 5 | using System.Text.RegularExpressions; 6 | 7 | #endregion 8 | 9 | namespace OpenCl.DotNetCore.Platforms 10 | { 11 | /// 12 | /// Represents the version of an OpenCL platform. 13 | /// 14 | public class Version 15 | { 16 | #region Constructors 17 | 18 | /// 19 | /// Initializes a new instance. 20 | /// 21 | /// Gets the original version string returned by the OpenCL platform, which is in the format"OpenCL[space][major_version.minor_version][space][platform-specific information]". 22 | /// If the version string could not be parsed, then an is thrown. 23 | public Version(string versionString) 24 | { 25 | // Saves the version string for later reference 26 | this.VersionString = versionString; 27 | 28 | // Creates a new regular expression, which is used to parse the version string 29 | Regex versionStringRegularExpression = new Regex("^OpenCL (?[0-9]+)\\.(?[0-9]+) (?.*)$"); 30 | 31 | // Parses the version string and checks if it matched successfully, if not, then an ArgumentException is thrown 32 | Match match = versionStringRegularExpression.Match(this.VersionString); 33 | if (!match.Success) 34 | throw new ArgumentException($"The version string \"{this.VersionString}\" is not a valid OpenCL platform version string."); 35 | 36 | // Saves the version information 37 | this.MajorVersion = Convert.ToInt32(match.Groups["MajorVersion"].Value); 38 | this.MinorVersion = Convert.ToInt32(match.Groups["MinorVersion"].Value); 39 | this.PlatformSpecificInformation = match.Groups["PlatformSpecificInformation"].Value; 40 | } 41 | 42 | #endregion 43 | 44 | #region Public Properties 45 | 46 | /// 47 | /// Gets the original version string returned by the OpenCL platform, which is in the format "OpenCL[space][major_version.minor_version][space][platform-specific information]". 48 | /// 49 | public string VersionString { get; private set; } 50 | 51 | /// 52 | /// Gets the major version of OpenCL that is supported by the OpenCL platform. 53 | /// 54 | public int MajorVersion { get; private set; } 55 | 56 | /// 57 | /// Gets the minor version of OpenCL that is supported by the OpenCL platform. 58 | /// 59 | public int MinorVersion { get; private set; } 60 | 61 | /// 62 | /// Gets the version information specific to the OpenCL platform. 63 | /// 64 | public string PlatformSpecificInformation { get; private set; } 65 | 66 | #endregion 67 | } 68 | } -------------------------------------------------------------------------------- /src/OpenCL-dotnet/OpenCl.DotNetCore.Interop/Profiling/ProfilingNativeApi.cs: -------------------------------------------------------------------------------- 1 | 2 | #region Using Directives 3 | 4 | using System; 5 | using System.Runtime.InteropServices; 6 | 7 | #endregion 8 | 9 | namespace OpenCl.DotNetCore.Interop.Profiling 10 | { 11 | /// 12 | /// Represents a wrapper for the native methods of the OpenCL Profiling API. 13 | /// 14 | public static class ProfilingNativeApi 15 | { 16 | #region Public Static Methods 17 | 18 | /// 19 | /// Returns profiling information for the command associated with if profiling is enabled. 20 | /// 21 | /// Specifies the OpenCL event being queried. 22 | /// An enumeration constant that specifies the information to query. 23 | /// A pointer to memory where the appropriate result being queried is returned. If is null, it is ignored. 24 | /// Specifies the size in bytes of memory pointed to by . 25 | /// Returns the actual size in bytes of data being queried by . If is null, it is ignored. 26 | /// 27 | /// Returns Result.Success if the function executed successfully, or one of the errors below: 28 | /// 29 | /// Result.ProfilingInformationNotAvailable if the CommandQueueProperty.ProfilingEnable flag is not set for the command-queue, if the execution status of the command identified by event is not complete or if 30 | /// refers to the command or is a user event object. 31 | /// 32 | /// Result.InvalidEvent if is not a valid event. 33 | /// 34 | /// Result.InvalidValue if is not one of the supported values or if size in bytes specified by is less than the size of the return type 35 | /// is not a null value. 36 | /// 37 | /// Result.OutOfResources if there is a failure to allocate resources required by the OpenCL implementation on the device. 38 | /// 39 | /// Result.OutOfHostMemory if there is a failure to allocate resources required by the OpenCL implementation on the host. 40 | /// 41 | [IntroducedInOpenCl(1, 0)] 42 | [DllImport("OpenCL", EntryPoint = "clGetEventProfilingInfo")] 43 | public static extern Result GetEventProfilingInformation( 44 | [In] IntPtr eventHandle, 45 | [In] [MarshalAs(UnmanagedType.U4)] ProfilingInformation parameterName, 46 | [In] UIntPtr parameterValueSize, 47 | [Out] byte[] parameterValue, 48 | [Out] out UIntPtr parameterValueSizeReturned 49 | ); 50 | 51 | #endregion 52 | } 53 | } -------------------------------------------------------------------------------- /src/Master/XMLTools.cs: -------------------------------------------------------------------------------- 1 | // Grin Gold Miner https://github.com/urza/GrinGoldMiner 2 | // Copyright (c) 2018 Lukas Kubicek - urza 3 | // Copyright (c) 2018 Jiri Vadura - photon 4 | 5 | using System; 6 | using System.Collections.Generic; 7 | using System.IO; 8 | using System.Text; 9 | using System.Xml.Serialization; 10 | 11 | namespace Mozkomor.GrinGoldMiner 12 | { 13 | public static class XmlTools 14 | { 15 | public static string ToXmlString(this T input) 16 | { 17 | using (var writer = new StringWriter()) 18 | { 19 | input.ToXml(writer); 20 | return writer.ToString(); 21 | } 22 | } 23 | public static void ToXml(this T objectToSerialize, Stream stream) 24 | { 25 | new XmlSerializer(typeof(T)).Serialize(stream, objectToSerialize); 26 | } 27 | 28 | public static void ToXml(this T objectToSerialize, StringWriter writer) 29 | { 30 | new XmlSerializer(typeof(T)).Serialize(writer, objectToSerialize); 31 | } 32 | } 33 | 34 | public class Serialization 35 | { 36 | public static bool Serialize(T input, string outputFile) 37 | { 38 | try 39 | { 40 | // Serialization 41 | XmlSerializer s = new XmlSerializer(typeof(T)); 42 | using (TextWriter w = new StreamWriter(outputFile)) 43 | { 44 | s.Serialize(w, input); 45 | } 46 | 47 | return true; 48 | } 49 | catch (Exception Ex) 50 | { 51 | Logger.Log(Ex); 52 | return false; 53 | } 54 | } 55 | 56 | public static T DeSerialize(string inputFile) 57 | { 58 | //try 59 | //{ 60 | // Deserialization 61 | XmlSerializer s = new XmlSerializer(typeof(T)); 62 | T newClass; 63 | using (TextReader r = new StreamReader(inputFile)) 64 | { 65 | newClass = (T)s.Deserialize(r); 66 | } 67 | 68 | return newClass; 69 | //} 70 | //catch (Exception Ex) 71 | //{ 72 | // Logger.Log(Ex); 73 | // return default(T); 74 | //} 75 | } 76 | 77 | public static T DeSerializeString(string inputContent) 78 | { 79 | //try 80 | //{ 81 | // Deserialization 82 | XmlSerializer s = new XmlSerializer(typeof(T)); 83 | T newClass; 84 | using (TextReader r = new StringReader(inputContent)) 85 | { 86 | newClass = (T)s.Deserialize(r); 87 | } 88 | 89 | return newClass; 90 | //} 91 | //catch (Exception Ex) 92 | //{ 93 | // Logger.Log(Ex); 94 | // return default(T); 95 | //} 96 | } 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /src/GrinProMInerAPI/Views/Home.cshtml: -------------------------------------------------------------------------------- 1 | @model GrinProMiner.Models.SimpleStatus 2 | @{ 3 | Layout = null; 4 | } 5 | 6 | 7 | 8 | 9 | 10 | 11 | GrinPro.io 12 | 13 | 62 | 63 | 64 |

GrinPro.io Miner

65 | Connection: @Model.ConnectionAddress
66 | Status: @Model.ConnectionStatus
67 | Last Job: @Model.LastJob
68 | Last Share: @Model.LastShare
69 |
70 |
71 | Shares
72 | Found: @Model.Shares.Found
73 | Submitted: @Model.Shares.Submitted
74 | Accepted: @Model.Shares.Accepted
75 | TooLate: @Model.Shares.TooLate
76 | Invalid: @Model.Shares.FailedToValidate
77 |
78 |
79 | Workers 80 |
81 | @foreach (var worker in Model.Workers) 82 | { 83 | ID: @worker.ID
84 | STATUS: @worker.Status
85 | GPS: @worker.GraphsPerSecond
86 | TotalSols: @worker.TotalSols
87 | } 88 | 89 |
90 |
91 |
92 | Access JSON API at: /api
93 | API can be used to get status of the miner, information about GPUs, Connections, Config.
94 | API can also SET current stratum connection and config options.
95 | API DOCS: https://grinpro.io/api.html 96 |
97 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /src/GrinProMInerAPI/Controllers/HomeController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using GrinProMiner.Models; 6 | using Microsoft.AspNetCore.Http; 7 | using Microsoft.AspNetCore.Mvc; 8 | using Mozkomor.GrinGoldMiner; 9 | 10 | namespace GrinProMiner.Controllers 11 | { 12 | [Route("")] 13 | [Controller] 14 | public class HomeController : Controller 15 | { 16 | [Route("api")] 17 | public string Get() 18 | { 19 | return "You can use GET METHODS: /api/status, /api/workers, /api/workers/{id}, /api/connections, /api/connections/active /api/config and POST METHODS: /api/connections/active, /api/config. API DOCS: https://grinpro.io/api.html"; 20 | } 21 | 22 | [Route("")] 23 | public IActionResult GetHome() 24 | { 25 | var lastJob = WorkerManager.lastJob.ToString("yyyy-MM-ddTHH:mm:ssK"); 26 | 27 | var conn = ConnectionManager.GetCurrConn(); 28 | 29 | if (conn == null) 30 | return StatusCode(404, "No Straturm Connection active."); 31 | 32 | 33 | var lastSHare = conn.lastShare; 34 | var totalShares = conn.totalShares; 35 | var accepted = conn.sharesAccepted; 36 | var rejected = conn.sharesRejected; 37 | var tooLate = conn.sharesTooLate; 38 | ///TODO do WorkerManagera dat SolutionsFound (kolik dohromady ze vsech karet) a 39 | /// SolutionsSubmitted (to bude az co projde pres diff) 40 | 41 | SimpleStatus status = new SimpleStatus(); 42 | 43 | status.LastShare = lastSHare.ToString("yyyy-MM-ddTHH:mm:ssK"); 44 | status.LastJob = lastJob; 45 | 46 | List workers = new List(); 47 | foreach (var worker in WorkerManager.GetWorkersInfo()) 48 | { 49 | SimpleWorkerInfo wi = new SimpleWorkerInfo(); 50 | 51 | wi.Status = worker.GPUStatus; 52 | wi.GraphsPerSecond = worker.GraphsPerSecond; 53 | wi.ID = worker.ID; 54 | wi.TotalSols = worker.TotalSols; 55 | wi.LastSolution = worker.lastSolution.ToString("yyyy-MM-ddTHH:mm:ssK"); 56 | wi.Fidelity = (float)worker.Fidelity; 57 | workers.Add(wi); 58 | } 59 | status.Workers = workers; 60 | 61 | if (ConnectionManager.IsInFee()) 62 | { 63 | status.ConnectionAddress = $"FEE (GrinPro collects 1% as fee for the Grin Development Fund and 1% for further miner development.)"; 64 | status.ConnectionStatus = conn.IsConnected == true ? "Connected" : "Disconnectd"; 65 | } 66 | else 67 | { 68 | status.ConnectionAddress = $"{conn.ip}:{conn.port}"; 69 | status.ConnectionStatus = conn.IsConnected == true ? "Connected" : "Disconnectd"; 70 | } 71 | 72 | ShareStats ss = new ShareStats(); 73 | ss.Accepted = accepted; 74 | ss.FailedToValidate = rejected; 75 | ss.Found = (uint)workers.Sum(w => w.TotalSols); 76 | ss.Submitted = totalShares; 77 | ss.TooLate = tooLate; 78 | 79 | status.Shares = ss; 80 | 81 | 82 | return View("Views/Home.cshtml",status); 83 | } 84 | } 85 | } -------------------------------------------------------------------------------- /src/OpenCL-dotnet/OpenCl.DotNetCore.Interop/Kernels/KernelWorkGroupInformation.cs: -------------------------------------------------------------------------------- 1 | 2 | namespace OpenCl.DotNetCore.Interop.Kernels 3 | { 4 | /// 5 | /// Represents an enumeration for the different types of information that can be queried from an OpenCL kernel work group. 6 | /// 7 | public enum KernelWorkGroupInformation : uint 8 | { 9 | /// 10 | /// This provides a mechanism for the application to query the maximum work-group size that can be used to execute the kernel on a specific device. The OpenCL implementation uses the resource requirements of the kernel (register usage 11 | /// etc.) to determine what this work-group size should be. As a result and unlike DeviceInformation.MaximumWorkGoupSize this value may vary from one kernel to another as well as one device to another. 12 | /// KernelWorkGroupInformation.WorkGroupSize will be less than or equal to DeviceInformation.MaximumWorkGoupSize for a given kernel object. 13 | /// 14 | WorkGroupSize = 0x11B0, 15 | 16 | /// 17 | /// Returns the work-group size specified in the kernel source or IL. If the work-group size is not specified in the kernel source or IL, (0, 0, 0) is returned. 18 | /// 19 | CompileWorkGroupSize = 0x11B1, 20 | 21 | /// 22 | /// Returns the amount of local memory in bytes being used by a kernel. This includes local memory that may be needed by an implementation to execute the kernel, variables declared inside the kernel with the __local address 23 | /// qualifier and local memory to be allocated for arguments to the kernel declared as pointers with the __local address qualifier and whose size is specified with . If the local memory size, for 24 | /// any pointer argument to the kernel declared with the __local address qualifier, is not specified, its size is assumed to be 0. 25 | /// 26 | LocalMemorySize = 0x11B2, 27 | 28 | /// 29 | /// Returns the preferred multiple of workgroup size for launch. This is a performance hint. Specifying a workgroup size that is not a multiple of the value returned by this query as the value of the local work size argument to 30 | /// will not fail to enqueue the kernel for execution unless the work-group size specified is larger than the device maximum. 31 | /// 32 | PreferredWorkGroupSizeMultiple = 0x11B3, 33 | 34 | /// 35 | /// Returns the minimum amount of private memory, in bytes, used by each work-item in the kernel. This value may include any private memory needed by an implementation to execute the kernel, including that used by the language built-ins 36 | /// and variable declared inside the kernel with the __private qualifier. 37 | /// 38 | PrivateMemorySize = 0x11B4, 39 | 40 | /// 41 | /// This provides a mechanism for the application to query the maximum global size that can be used to execute a kernel (i.e. argument to ) on a custom device given by 42 | /// device or a built-in kernel on an OpenCL device. If the device is not a custom device or the kernel is not a built-in kernel, returns the error Result.InvalidValue. 43 | /// 44 | GlobalWorkSize = 0x11B5 45 | } 46 | } -------------------------------------------------------------------------------- /src/OpenCL-dotnet/OpenCl.DotNetCore.Interop/Memory/ChannelType.cs: -------------------------------------------------------------------------------- 1 | 2 | namespace OpenCl.DotNetCore.Interop.Memory 3 | { 4 | /// 5 | /// Represents an enumeration for the different data types that can be used for color channels in an image. 6 | /// 7 | public enum ChannelType : uint 8 | { 9 | /// 10 | /// Each channel component is a normalized signed 8-bit integer value. 11 | /// 12 | NormalizedSignedInteger8 = 0x10D0, 13 | 14 | /// 15 | /// Each channel component is a normalized signed 16-bit integer value. 16 | /// 17 | NormalizedSignedInteger16 = 0x10D1, 18 | 19 | /// 20 | /// Each channel component is a normalized unsigned 8-bit integer value. 21 | /// 22 | NormalizedUnsignedInteger8 = 0x10D2, 23 | 24 | /// 25 | /// Each channel component is a normalized unsigned 16-bit integer value. 26 | /// 27 | NormalizedUnsignedInteger16 = 0x10D3, 28 | 29 | /// 30 | /// Represents a normalized 5-6-5 3-channel RGB image. The channel order must be ChannelOrder.Rgb or ChannelOrder.Rgbx. 31 | /// 32 | NormalizedUnsignedShortFloat565 = 0x10D4, 33 | 34 | /// 35 | /// Represents a normalized x-5-5-5 4-channel xRGB image. The channel order must be ChannelOrder.Rgb or ChannelOrder.Rgbx. 36 | /// 37 | NormalizedUnsignedShortFloat555 = 0x10D5, 38 | 39 | /// 40 | /// Represents a normalized x-10-10-10 4-channel xRGB image. The channel order must be ChannelOrder.Rgb or ChannelOrder.Rgbx. 41 | /// 42 | NormalizedUnsignedInteger101010 = 0x10D6, 43 | 44 | /// 45 | /// Each channel component is an unnormalized signed 8-bit integer value. 46 | /// 47 | SignedInteger8 = 0x10D7, 48 | 49 | /// 50 | /// Each channel component is an unnormalized signed 16-bit integer value. 51 | /// 52 | SignedInteger16 = 0x10D8, 53 | 54 | /// 55 | /// Each channel component is an unnormalized signed 32-bit integer value. 56 | /// 57 | SignedInteger32 = 0x10D9, 58 | 59 | /// 60 | /// Each channel component is an unnormalized unsigned 8-bit integer value. 61 | /// 62 | UnsignedInteger8 = 0x10DA, 63 | 64 | /// 65 | /// Each channel component is an unnormalized unsigned 16-bit integer value. 66 | /// 67 | UnsignedInteger16 = 0x10DB, 68 | 69 | /// 70 | /// Each channel component is an unnormalized unsigned 32-bit integer value. 71 | /// 72 | UnsignedInteger32 = 0x10DC, 73 | 74 | /// 75 | /// Each channel component is a 16-bit half-float value. 76 | /// 77 | HalfFloat = 0x10DD, 78 | 79 | /// 80 | /// Each channel component is a single precision floating-point value. 81 | /// 82 | Float = 0x10DE, 83 | 84 | /// 85 | /// Each channel component is a normalized unsigned 24-bit integer value. 86 | /// 87 | NormalizedUnsignedInteger24 = 0x10DF, 88 | 89 | /// 90 | /// Represents a different version of a normalized x-10-10-10 4-channel xRGB image. The channel order must be ChannelOrder.Rgb or ChannelOrder.Rgbx. 91 | /// 92 | NormalizedUnsignedInteger101010Version2 = 0x10E0 93 | } 94 | } -------------------------------------------------------------------------------- /src/GrinProMInerAPI/Controllers/ConnectionController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using GrinProMiner.Models; 6 | using Microsoft.AspNetCore.Http; 7 | using Microsoft.AspNetCore.Mvc; 8 | using Mozkomor.GrinGoldMiner; 9 | 10 | namespace GrinProMiner.Controllers 11 | { 12 | [Route("api/[controller]")] 13 | [ApiController] 14 | public class ConnectionsController : ControllerBase 15 | { 16 | 17 | [HttpGet("")] 18 | public ActionResult> GetAll() 19 | { 20 | var sc1 = ConnectionManager.GetConnectionById(1); 21 | var c1 = new StratumConnectionInfo() 22 | { 23 | Address = sc1.ip, 24 | Port = sc1.port.ToString(), 25 | Login = sc1.login, 26 | Password = sc1.password, 27 | Status = sc1.IsConnected == true ? "Connected" : "Disconnectd", 28 | LastCommunication = sc1.lastComm.ToString("yyyy-MM-ddTHH:mm:ssK"), 29 | LastJob = sc1.CurrentJob?.timestamp.ToString("yyyy-MM-ddTHH:mm:ssK"), 30 | }; 31 | 32 | var sc2 = ConnectionManager.GetConnectionById(2); 33 | var c2 = new StratumConnectionInfo() 34 | { 35 | Address = sc2.ip, 36 | Port = sc2.port.ToString(), 37 | Login = sc2.login, 38 | Password = sc2.password, 39 | Status = sc2.IsConnected == true ? "Connected" : "Disconnectd", 40 | LastCommunication = sc2.lastComm.ToString("yyyy-MM-ddTHH:mm:ssK"), 41 | LastJob = sc2.CurrentJob?.timestamp.ToString("yyyy-MM-ddTHH:mm:ssK"), 42 | }; 43 | 44 | return new List() { c1, c2 }; 45 | } 46 | 47 | [HttpGet("active")] 48 | public ActionResult GetActive() 49 | { 50 | try 51 | { 52 | var curr = ConnectionManager.GetCurrConn(); 53 | if (curr != null) 54 | { 55 | bool isFee = ConnectionManager.IsInFee(); 56 | var ci = new StratumConnectionInfo() 57 | { 58 | Address = isFee ? "FEE" : curr.ip, 59 | Port = isFee ? "FEE" : curr.port.ToString(), 60 | Login = isFee ? "FEE" : curr.login, 61 | Password = isFee ? "FEE" : 62 | curr.password, 63 | Status = curr.IsConnected == true ? "Connected" : "Disconnectd", 64 | LastCommunication = curr.lastComm.ToString("yyyy-MM-ddTHH:mm:ssK"), 65 | LastJob = curr.CurrentJob?.timestamp.ToString("yyyy-MM-ddTHH:mm:ssK"), 66 | }; 67 | 68 | return ci; 69 | } 70 | else 71 | { 72 | return StatusCode(404, $"No active connection."); 73 | } 74 | 75 | } 76 | catch (Exception ex) 77 | { 78 | return StatusCode(500, $"ERROR while getting active connection. {ex.Message}"); 79 | } 80 | } 81 | 82 | [HttpPost("active")] 83 | public ActionResult SetActive(Mozkomor.GrinGoldMiner.Connection connection) 84 | { 85 | var r = ConnectionManager.SetConnection(connection); 86 | 87 | if (r == "ok") 88 | return Ok("New connection is active. Check by calling /api/connections/active"); 89 | else 90 | return StatusCode(500, r); 91 | } 92 | } 93 | } -------------------------------------------------------------------------------- /src/Master/Program.cs: -------------------------------------------------------------------------------- 1 | // Grin Gold Miner https://github.com/urza/GrinGoldMiner 2 | // Copyright (c) 2018 Lukas Kubicek - urza 3 | // Copyright (c) 2018 Jiri Vadura - photon 4 | 5 | using System; 6 | using System.Collections.Generic; 7 | using System.IO; 8 | using System.Threading.Tasks; 9 | 10 | namespace Mozkomor.GrinGoldMiner 11 | { 12 | 13 | class Program 14 | { 15 | static void Main(string[] args) 16 | { 17 | Console.CancelKeyPress += delegate 18 | { 19 | Console.WriteLine("Ctrl+C - Exitting"); 20 | Close(); 21 | }; 22 | 23 | if (DateTime.Today >= new DateTime(2019,1,14)) 24 | { 25 | Console.WriteLine("!!! This version of GrinGoldMiner is outdated. Please go to https://github.com/mozkomor/GrinGoldMiner/releases and downlaod the latest release."); 26 | Logger.Log(LogLevel.ERROR,"!!! This version of GrinGoldMiner is outdated. Please go to https://github.com/mozkomor/GrinGoldMiner/releases and downlaod the latest release."); 27 | Console.ReadLine(); 28 | Close(); 29 | } 30 | 31 | var dir = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); 32 | var configPath = Path.Combine(dir, "config.xml"); 33 | Config config = new Config(); 34 | if (File.Exists(configPath)) 35 | { 36 | config = Serialization.DeSerialize(configPath); 37 | } 38 | else 39 | { 40 | Console.WriteLine($"ERROR: missing config.xml, created new empty config.xml in directory with miner ({dir}), please set the values in this file"); 41 | Serialization.Serialize(Config.GetDefaultConfig(), configPath); 42 | Console.ReadLine(); 43 | } 44 | 45 | Logger.SetLogOptions(config.LogOptions); 46 | WorkerManager.Init(config); 47 | ConnectionManager.Init(config, "grin29"); 48 | 49 | while (Console.ReadKey().Key != ConsoleKey.Q) 50 | { 51 | } 52 | Close(); 53 | 54 | //string prevprepow = ""; 55 | //while (true) 56 | //{ 57 | 58 | // var job = ConnectionManager.GetJob(); 59 | // if (job != null) 60 | // { 61 | // if (job.pre_pow != prevprepow) 62 | // { 63 | // //ConnectionManager.SubmitSol( 64 | // // new Solution() 65 | // // { 66 | // // jobId = job.job_id, 67 | // // difficulty = job.difficulty, 68 | // // height = job.height, 69 | // // k0 = 111, k1 = 111, k2 = 111, k3 = 111, 70 | // // nonce = 123456, nonces = null, 71 | // // prepow = job.pre_pow, 72 | // // }); 73 | 74 | // prevprepow = job.pre_pow; 75 | // } 76 | // Task.Delay(2500).Wait(); 77 | // } 78 | // else 79 | // { 80 | // Console.Write("."); 81 | // Task.Delay(500).Wait(); 82 | // } 83 | 84 | // //Theta.ConnectionManager.SubmitJob(); 85 | //} 86 | Console.WriteLine(); 87 | 88 | } 89 | 90 | public static void Close() 91 | { 92 | ConnectionManager.CloseAll(); 93 | Environment.Exit(0); 94 | } 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /src/Master/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | POOLADDRESS 7 | 4416 8 | true 9 | userlogin 10 | secretpwd 11 | 12 | 13 | 17 | 18 | POOLADDRESS 19 | 3416 20 | false 21 | userlogin 22 | 23 | 24 | 25 | 29 | 0 30 | 31 | 32 | 33 | 35 | 36 | 37 | 38 | 40 | 0 41 | 42 | 43 | 44 | 45 | false 46 | 47 | ERROR 48 | ERROR 49 | 50 | 2 51 | 52 | 53 | 54 | 55 | 0 56 | 57 | 58 | 59 | 60 | GeForce GTX 1070 61 | NVIDIA 62 | 0 63 | 0 64 | true 65 | 66 | 67 | GeForce GTX 1070 68 | NVIDIA 69 | 1 70 | 0 71 | true 72 | 73 | 74 | P106-100 75 | NVIDIA 76 | 2 77 | 0 78 | true 79 | 80 | 81 | Ellesmere 82 | AMD 83 | 0 84 | 0 85 | true 86 | 87 | 88 | gfx900 89 | AMD 90 | 0 91 | 1 92 | true 93 | 94 | 95 | gfx900 96 | AMD 97 | 1 98 | 1 99 | false 100 | 101 | 102 | -------------------------------------------------------------------------------- /src/OpenCL-dotnet/OpenCl.DotNetCore.Interop/SvmAllocations/SvmAllocationsNativeApi.cs: -------------------------------------------------------------------------------- 1 | 2 | #region Using Directives 3 | 4 | using System; 5 | using System.Runtime.InteropServices; 6 | 7 | #endregion 8 | 9 | namespace OpenCl.DotNetCore.Interop.SvmAllocations 10 | { 11 | /// 12 | /// Represents a wrapper for the native methods of the OpenCL SVM Allocations API. 13 | /// 14 | public static class SvmAllocationsNativeApi 15 | { 16 | #region Public Static Methods 17 | 18 | /// 19 | /// Allocates a shared virtual memory (SVM) buffer that can be shared by the host and all devices in an OpenCL context that support shared virtual memory. 20 | /// 21 | /// A valid OpenCL context used to create the SVM buffer. 22 | /// An enumeration that is used to specify allocation and usage information. 23 | /// The size in bytes of the SVM buffer to be allocated. 24 | /// 25 | /// The minimum alignment in bytes that is required for the newly created buffer’s memory region. It must be a power of two up to the largest data type supported by the OpenCL device. For the full profile, the largest data type is 26 | /// long16. For the embedded profile, it is long16 if the device supports 64-bit integers; otherwise it is int16. If alignment is 0, a default alignment will be used that is equal to the size of largest data type supported by the 27 | /// OpenCL implementation. 28 | /// 29 | /// 30 | /// Returns a valid non-null shared virtual memory address if the SVM buffer is successfully allocated. Otherwise, like malloc, it returns a null pointer value. will fail if: 31 | /// 32 | /// - is not a valid context 33 | /// - does not contain SvmMemoryFlag.SvmFineGrainBuffer but does contain SvmMemoryFlag.SvmAtomics 34 | /// - Values specified in do not follow rules described for supported values 35 | /// - SvmMemoryFlag.SvmFineGrainBuffer or SvmMemoryFlag.SvmAtomics is specified in and these are not supported by at least one device in 36 | /// - The values specified in are not valid 37 | /// - is 0 or greater than the DeviceInformation.MaximumMemoryAllocationSize value for any device in 38 | /// - is not a power of two or the OpenCL implementation cannot support the specified alignment for at least one device in 39 | /// - There was a failure to allocate resources 40 | /// 41 | [IntroducedInOpenCl(2, 0)] 42 | [DllImport("OpenCL", EntryPoint = "clSVMAlloc")] 43 | public static extern IntPtr SvmAllocate( 44 | [In] IntPtr context, 45 | [In] [MarshalAs(UnmanagedType.U8)] SvmMemoryFlag flags, 46 | [In] UIntPtr size, 47 | [In] [MarshalAs(UnmanagedType.U4)] uint alignment 48 | ); 49 | 50 | /// 51 | /// Frees a shared virtual memory buffer allocated using . Note that does not wait for previously enqueued commands that may be using to finish before freeing 52 | /// . It is the responsibility of the application to make sure that enqueued commands that use have finished before freeing . 53 | /// 54 | /// A valid OpenCL context used to create the SVM buffer. 55 | /// Must be the value returned by a call to . If a null pointer is passed in , no action occurs. 56 | [IntroducedInOpenCl(2, 0)] 57 | [DllImport("OpenCL", EntryPoint = "clSVMFree")] 58 | public static extern void SvmFree( 59 | [In] IntPtr context, 60 | [In] IntPtr svmPointer 61 | ); 62 | 63 | #endregion 64 | } 65 | } -------------------------------------------------------------------------------- /src/OpenCL-dotnet/OpenCl.DotNetCore/Memory/MemoryFlag.cs: -------------------------------------------------------------------------------- 1 | 2 | #region Using Directives 3 | 4 | using System; 5 | 6 | #endregion 7 | 8 | namespace OpenCl.DotNetCore.Memory 9 | { 10 | /// 11 | /// Represents the memory flags, that are used to create memory buffers. 12 | /// 13 | [Flags] 14 | public enum MemoryFlag : ulong 15 | { 16 | /// 17 | /// This flag specifies that the memory object will be read and written by a kernel. This is the default. 18 | /// 19 | ReadWrite = 1 << 0, 20 | 21 | /// 22 | /// This flags specifies that the memory object will be written but not read by a kernel. Reading from a buffer or image object created with inside a kernel is undefined. and 23 | /// are mutually exclusive. 24 | /// 25 | WriteOnly = 1 << 1, 26 | 27 | /// 28 | /// This flag specifies that the memory object is a read-only memory object when used inside a kernel. Writing to a buffer or image object created with inside a kernel is undefined. or 29 | /// and are mutually exclusive. 30 | /// 31 | ReadOnly = 1 << 2, 32 | 33 | /// 34 | /// This flag is valid only if a host pointer was specified. If specified, it indicates that the application wants the OpenCL implementation to use memory referenced by the specified host pointer as the storage bits for the memory 35 | /// object. OpenCL implementations are allowed to cache the buffer contents pointed to by the specified host pointer in device memory. This cached copy can be used when kernels are executed on a device. The result of OpenCL commands 36 | /// that operate on multiple buffer objects created with the same host pointer or overlapping host regions is considered to be undefined. Refer to the description of the alignment rules for the specified host pointer for memory 37 | /// objects (buffer and images) created using . 38 | /// 39 | UseHostPointer = 1 << 3, 40 | 41 | /// 42 | /// This flag specifies that the application wants the OpenCL implementation to allocate memory from host accessible memory. and are mutually exclusive. 43 | /// 44 | AllocateHostPointer = 1 << 4, 45 | 46 | /// 47 | /// This flag is valid only if a host pointer was specified. If specified, it indicates that the application wants the OpenCL implementation to allocate memory for the memory object and copy the data from memory referenced by the 48 | /// specified host pointer. and are mutually exclusive. can be used with to initialize the contents of the 49 | /// memory object allocated using host-accessible (e.g. PCIe) memory. 50 | /// 51 | CopyHostPointer = 1 << 5, 52 | 53 | /// 54 | /// This flag specifies that the host will only write to the memory object (using OpenCL APIs that enqueue a write or a map for write). This can be used to optimize write access from the host (e.g. enable write combined allocations 55 | /// for memory objects for devices that communicate with the host over a system bus such as PCIe). 56 | /// 57 | HostWriteOnly = 1 << 7, 58 | 59 | /// 60 | /// This flag specifies that the host will only read the memory object (using OpenCL APIs that enqueue a read or a map for read). and are mutually exclusive. 61 | /// 62 | HostReadOnly = 1 << 8, 63 | 64 | /// 65 | /// This flag specifies that the host will not read or write the memory object. or and are mutually exclusive. 66 | /// 67 | HostNoAccess = 1 << 9, 68 | 69 | /// 70 | /// Can be used to get a list of supported image formats that can be both read from and written to by a kernel. 71 | /// 72 | KernelReadAndWrite = 1 << 12 73 | } 74 | } -------------------------------------------------------------------------------- /src/OpenCL-dotnet/OpenCl.DotNetCore.Interop/Memory/MemoryFlag.cs: -------------------------------------------------------------------------------- 1 | 2 | #region Using Directives 3 | 4 | using System; 5 | 6 | #endregion 7 | 8 | namespace OpenCl.DotNetCore.Interop.Memory 9 | { 10 | /// 11 | /// Represents the memory flags, that are used to create memory buffers. 12 | /// 13 | [Flags] 14 | public enum MemoryFlag : ulong 15 | { 16 | /// 17 | /// This flag specifies that the memory object will be read and written by a kernel. This is the default. 18 | /// 19 | ReadWrite = 1 << 0, 20 | 21 | /// 22 | /// This flags specifies that the memory object will be written but not read by a kernel. Reading from a buffer or image object created with inside a kernel is undefined. and 23 | /// are mutually exclusive. 24 | /// 25 | WriteOnly = 1 << 1, 26 | 27 | /// 28 | /// This flag specifies that the memory object is a read-only memory object when used inside a kernel. Writing to a buffer or image object created with inside a kernel is undefined. or 29 | /// and are mutually exclusive. 30 | /// 31 | ReadOnly = 1 << 2, 32 | 33 | /// 34 | /// This flag is valid only if a host pointer was specified. If specified, it indicates that the application wants the OpenCL implementation to use memory referenced by the specified host pointer as the storage bits for the memory 35 | /// object. OpenCL implementations are allowed to cache the buffer contents pointed to by the specified host pointer in device memory. This cached copy can be used when kernels are executed on a device. The result of OpenCL commands 36 | /// that operate on multiple buffer objects created with the same host pointer or overlapping host regions is considered to be undefined. Refer to the description of the alignment rules for the specified host pointer for memory objects 37 | /// (buffer and images) created using . 38 | /// 39 | UseHostPointer = 1 << 3, 40 | 41 | /// 42 | /// This flag specifies that the application wants the OpenCL implementation to allocate memory from host accessible memory. and are mutually exclusive. 43 | /// 44 | AllocateHostPointer = 1 << 4, 45 | 46 | /// 47 | /// This flag is valid only if a host pointer was specified. If specified, it indicates that the application wants the OpenCL implementation to allocate memory for the memory object and copy the data from memory referenced by the 48 | /// specified host pointer. and are mutually exclusive. can be used with to initialize the contents of the 49 | /// memory object allocated using host-accessible (e.g. PCIe) memory. 50 | /// 51 | CopyHostPointer = 1 << 5, 52 | 53 | /// 54 | /// This flag specifies that the host will only write to the memory object (using OpenCL APIs that enqueue a write or a map for write). This can be used to optimize write access from the host (e.g. enable write combined allocations for 55 | /// memory objects for devices that communicate with the host over a system bus such as PCIe). 56 | /// 57 | HostWriteOnly = 1 << 7, 58 | 59 | /// 60 | /// This flag specifies that the host will only read the memory object (using OpenCL APIs that enqueue a read or a map for read). and are mutually exclusive. 61 | /// 62 | HostReadOnly = 1 << 8, 63 | 64 | /// 65 | /// This flag specifies that the host will not read or write the memory object. or and are mutually exclusive. 66 | /// 67 | HostNoAccess = 1 << 9, 68 | 69 | /// 70 | /// Can be used to get a list of supported image formats that can be both read from and written to by a kernel. 71 | /// 72 | KernelReadAndWrite = 1 << 12 73 | } 74 | } -------------------------------------------------------------------------------- /src/CudaSolver/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | text/microsoft-resx 91 | 92 | 93 | 1.3 94 | 95 | 96 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 97 | 98 | 99 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 100 | 101 | -------------------------------------------------------------------------------- /src/OpenCL-dotnet/OpenCl.DotNetCore.Interop/SvmAllocations/SvmMemoryFlag.cs: -------------------------------------------------------------------------------- 1 | 2 | #region Using Directives 3 | 4 | using System; 5 | 6 | #endregion 7 | 8 | namespace OpenCl.DotNetCore.Interop.SvmAllocations 9 | { 10 | /// 11 | /// Represents the SVM memory flags, that are used to allocate SVMs. 12 | /// 13 | [Flags] 14 | public enum SvmMemoryFlag : ulong 15 | { 16 | /// 17 | /// This flag specifies that the memory object will be read and written by a kernel. This is the default. 18 | /// 19 | ReadWrite = 1 << 0, 20 | 21 | /// 22 | /// This flags specifies that the memory object will be written but not read by a kernel. Reading from a buffer or image object created with inside a kernel is undefined. and 23 | /// are mutually exclusive. 24 | /// 25 | WriteOnly = 1 << 1, 26 | 27 | /// 28 | /// This flag specifies that the memory object is a read-only memory object when used inside a kernel. Writing to a buffer or image object created with inside a kernel is undefined. or 29 | /// and are mutually exclusive. 30 | /// 31 | ReadOnly = 1 << 2, 32 | 33 | /// 34 | /// This flag is valid only if a host pointer was specified. If specified, it indicates that the application wants the OpenCL implementation to use memory referenced by the specified host pointer as the storage bits for the memory 35 | /// object. OpenCL implementations are allowed to cache the buffer contents pointed to by the specified host pointer in device memory. This cached copy can be used when kernels are executed on a device. The result of OpenCL commands 36 | /// that operate on multiple buffer objects created with the same host pointer or overlapping host regions is considered to be undefined. Refer to the description of the alignment rules for the specified host pointer for memory objects 37 | /// (buffer and images) created using . 38 | /// 39 | UseHostPointer = 1 << 3, 40 | 41 | /// 42 | /// This flag specifies that the application wants the OpenCL implementation to allocate memory from host accessible memory. and are mutually exclusive. 43 | /// 44 | AllocateHostPointer = 1 << 4, 45 | 46 | /// 47 | /// This flag is valid only if a host pointer was specified. If specified, it indicates that the application wants the OpenCL implementation to allocate memory for the memory object and copy the data from memory referenced by the 48 | /// specified host pointer. and are mutually exclusive. can be used with to initialize the contents of the 49 | /// memory object allocated using host-accessible (e.g. PCIe) memory. 50 | /// 51 | CopyHostPointer = 1 << 5, 52 | 53 | /// 54 | /// This flag specifies that the host will only write to the memory object (using OpenCL APIs that enqueue a write or a map for write). This can be used to optimize write access from the host (e.g. enable write combined allocations for 55 | /// memory objects for devices that communicate with the host over a system bus such as PCIe). 56 | /// 57 | HostWriteOnly = 1 << 7, 58 | 59 | /// 60 | /// This flag specifies that the host will only read the memory object (using OpenCL APIs that enqueue a read or a map for read). and are mutually exclusive. 61 | /// 62 | HostReadOnly = 1 << 8, 63 | 64 | /// 65 | /// This flag specifies that the host will not read or write the memory object. or and are mutually exclusive. 66 | /// 67 | HostNoAccess = 1 << 9, 68 | 69 | /// 70 | /// This specifies that the application wants the OpenCL implementation to do a fine-grained allocation. 71 | /// 72 | SvmFineGrainBuffer = 1 << 10, 73 | 74 | /// 75 | /// This flag is valid only if MemoryFlag.SvmFineGrainBuffer is specified in flags. It is used to indicate that SVM atomic operations can control visibility of memory accesses in this SVM buffer. 76 | /// 77 | SvmAtomics = 1 << 11, 78 | 79 | /// 80 | /// Can be used to get a list of supported image formats that can be both read from and written to by a kernel. 81 | /// 82 | KernelReadAndWrite = 1 << 12 83 | } 84 | } -------------------------------------------------------------------------------- /src/OpenCL-dotnet/OpenCl.DotNetCore/Memory/MemoryObject.cs: -------------------------------------------------------------------------------- 1 | 2 | #region Using Directives 3 | 4 | using System; 5 | using System.Runtime.InteropServices; 6 | using OpenCl.DotNetCore.Interop; 7 | using OpenCl.DotNetCore.Interop.Memory; 8 | 9 | #endregion 10 | 11 | namespace OpenCl.DotNetCore.Memory 12 | { 13 | /// 14 | /// Represents an OpenCL memory object. 15 | /// 16 | public abstract class MemoryObject : HandleBase 17 | { 18 | #region Constructors 19 | 20 | /// 21 | /// Initializes a new instance. 22 | /// 23 | /// The handle to the OpenCL memory object. 24 | internal MemoryObject(IntPtr handle) 25 | : base(handle) 26 | { 27 | } 28 | 29 | #endregion 30 | 31 | #region Public Properties 32 | 33 | /// 34 | /// Contains the size of the contents of the memory object in bytes. 35 | /// 36 | private Nullable size; 37 | 38 | /// 39 | /// Gets the size of the contents of the memory object in bytes. 40 | /// 41 | public long Size 42 | { 43 | get 44 | { 45 | if (!this.size.HasValue) 46 | { 47 | if (Marshal.SizeOf() == sizeof(long)) 48 | this.size = this.GetMemoryObjectInformation(MemoryObjectInformation.Size); 49 | else 50 | this.size = (long)this.GetMemoryObjectInformation(MemoryObjectInformation.Size); 51 | } 52 | return this.size.Value; 53 | } 54 | } 55 | 56 | /// 57 | /// Contains the flags with which the memory object was created. 58 | /// 59 | private Nullable flags; 60 | 61 | /// 62 | /// Gets the flags with which the memory object was created. 63 | /// 64 | public MemoryFlag Flags 65 | { 66 | get 67 | { 68 | if (!this.flags.HasValue) 69 | this.flags = (MemoryFlag)this.GetMemoryObjectInformation(MemoryObjectInformation.Flags); 70 | return this.flags.Value; 71 | } 72 | } 73 | 74 | #endregion 75 | 76 | #region Private Methods 77 | 78 | /// 79 | /// Retrieves the specified information about the OpenCL memory object. 80 | /// 81 | /// The type of the data that is to be returned. 82 | /// The kind of information that is to be retrieved. 83 | /// If the information could not be retrieved, then an is thrown. 84 | /// Returns the specified information. 85 | private T GetMemoryObjectInformation(MemoryObjectInformation memoryObjectInformation) 86 | { 87 | // Retrieves the size of the return value in bytes, this is used to later get the full information 88 | UIntPtr returnValueSize; 89 | Result result = MemoryNativeApi.GetMemoryObjectInformation(this.Handle, memoryObjectInformation, UIntPtr.Zero, null, out returnValueSize); 90 | if (result != Result.Success) 91 | throw new OpenClException("The memory object information could not be retrieved.", result); 92 | 93 | // Allocates enough memory for the return value and retrieves it 94 | byte[] output = new byte[returnValueSize.ToUInt32()]; 95 | result = MemoryNativeApi.GetMemoryObjectInformation(this.Handle, memoryObjectInformation, new UIntPtr((uint)output.Length), output, out returnValueSize); 96 | if (result != Result.Success) 97 | throw new OpenClException("The memory object information could not be retrieved.", result); 98 | 99 | // Returns the output 100 | return InteropConverter.To(output); 101 | } 102 | 103 | #endregion 104 | 105 | #region IDisposable Implementation 106 | 107 | /// 108 | /// Disposes of the resources that have been acquired by the memory object. 109 | /// 110 | /// Determines whether managed object or managed and unmanaged resources should be disposed of. 111 | protected override void Dispose(bool disposing) 112 | { 113 | // Checks if the memory object has already been disposed of, if not, then the memory object is disposed of 114 | if (!this.IsDisposed) 115 | MemoryNativeApi.ReleaseMemoryObject(this.Handle); 116 | 117 | // Makes sure that the base class can execute its dispose logic 118 | base.Dispose(disposing); 119 | } 120 | 121 | #endregion 122 | } 123 | } -------------------------------------------------------------------------------- /src/OpenCL-dotnet/OpenCl.DotNetCore.Interop/Platforms/PlatformsNativeApi.cs: -------------------------------------------------------------------------------- 1 | 2 | #region Using Directives 3 | 4 | using System; 5 | using System.Runtime.InteropServices; 6 | 7 | #endregion 8 | 9 | namespace OpenCl.DotNetCore.Interop.Platforms 10 | { 11 | /// 12 | /// Represents a wrapper for the native methods of the OpenCL Platforms API. 13 | /// 14 | public static class PlatformsNativeApi 15 | { 16 | #region Public Static Methods 17 | 18 | /// 19 | /// Obtain the list of platforms available. 20 | /// 21 | /// The number of platform entries that can be added to . If is not null, the must be greater than zero. 22 | /// 23 | /// Returns a list of OpenCL platforms found. The platform values returned in can be used to identify a specific OpenCL platform. If argument is null, this argument is ignored. 24 | /// The number of OpenCL platforms returned is the mininum of the value specified by or the number of OpenCL platforms available. 25 | /// 26 | /// Returns the number of OpenCL platforms available. If is null, this argument is ignored. 27 | /// 28 | /// Returns Result.Success if the function is executed successfully. If the cl_khr_icd extension is enabled, returns Result.Success if the function is executed successfully and there are a 29 | /// non zero number of platforms available. Otherwise it returns one of the following errors: 30 | /// 31 | /// Result.InvalidValue if is equal to zero and is not null, or if both and are null. 32 | /// 33 | /// Result.OutOfHostMemory if there is a failure to allocate resources required by the OpenCL implementation on the host. 34 | /// 35 | /// Result.PlatformNotFoundKhr if the cl_khr_icd extension is enabled and no platforms are found. 36 | /// 37 | [IntroducedInOpenCl(1, 0)] 38 | [DllImport("OpenCL", EntryPoint = "clGetPlatformIDs")] 39 | public static extern Result GetPlatformIds( 40 | [In] [MarshalAs(UnmanagedType.U4)] uint numberOfEntries, 41 | [Out] [MarshalAs(UnmanagedType.LPArray)] IntPtr[] platforms, 42 | [Out] [MarshalAs(UnmanagedType.U4)] out uint numberOfPlatforms 43 | ); 44 | 45 | /// 46 | /// Get specific information about the OpenCL platform. 47 | /// 48 | /// The platform ID returned by or can be null. If is null, the behavior is implementation-defined. 49 | /// An enumeration constant that identifies the platform information being queried. 50 | /// Specifies the size in bytes of memory pointed to by . This size in bytes must be greater than or equal to size of return type specified above. 51 | /// A pointer to memory location where appropriate values for a given will be returned. If is null, it is ignored. 52 | /// Returns the actual size in bytes of data being queried by . If is null, it is ignored. 53 | /// 54 | /// Returns Result.Success if the function is executed successfully. Otherwise, it returns the following: (The OpenCL specification does not describe the order of precedence for error codes returned by API calls) 55 | /// 56 | /// Result.InvalidPlatform if platform is not a valid platform. 57 | /// 58 | /// Result.InvalidValue if is not one of the supported values or if size in bytes specified by is less than size of return type and is 59 | /// not a null value. 60 | /// 61 | /// Result.OutOfHostMemory if there is a failure to allocate resources required by the OpenCL implementation on the host. 62 | /// 63 | [IntroducedInOpenCl(1, 0)] 64 | [DllImport("OpenCL", EntryPoint = "clGetPlatformInfo")] 65 | public static extern Result GetPlatformInformation( 66 | [In] IntPtr platform, 67 | [In] [MarshalAs(UnmanagedType.U4)] PlatformInformation parameterName, 68 | [In] UIntPtr parameterValueSize, 69 | [Out] byte[] parameterValue, 70 | [Out] out UIntPtr parameterValueSizeReturned 71 | ); 72 | 73 | #endregion 74 | } 75 | } -------------------------------------------------------------------------------- /src/OpenCL-dotnet/OpenCl.DotNetCore/InteropConverter.cs: -------------------------------------------------------------------------------- 1 | 2 | #region Using Directives 3 | 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Reflection; 8 | using System.Text; 9 | 10 | #endregion 11 | 12 | namespace OpenCl.DotNetCore 13 | { 14 | /// 15 | /// Represents a converter, which is used to convert byte arrays into several different CLR data types. 16 | /// 17 | public static class InteropConverter 18 | { 19 | #region Private Static Fields 20 | 21 | /// 22 | /// Contains a map, which maps a data type to a converter that is able to convert it. 23 | /// 24 | private static Dictionary> converterMap = new Dictionary>(); 25 | 26 | #endregion 27 | 28 | #region Public Static Methods 29 | 30 | /// 31 | /// Converts the specified data to the data type specified as type parameter. 32 | /// 33 | /// The data type into which the data is to be converted. 34 | /// The data that is to be converted. 35 | /// If no fitting convert could be found, then an is thrown. 36 | /// Returns the converted data. 37 | public static T To(byte[] data) 38 | { 39 | if (typeof(T) == typeof(string)) 40 | return (T)(object)ToString(data); 41 | 42 | // Checks if there is a converter for the specified data type 43 | Type targetType = typeof(T); 44 | if (!InteropConverter.converterMap.ContainsKey(targetType)) 45 | { 46 | // Since the converter could not be found, a fitting method is searched, if one is found, then it is added to the converter map, otherwise an exception is thrown 47 | TypeInfo typeInfo = typeof(InteropConverter).GetTypeInfo(); 48 | MethodInfo converterMethodInfo = typeInfo.GetMethods().FirstOrDefault(method => 49 | method.IsStatic && 50 | method.ReturnType == targetType && 51 | method.GetParameters().Count() == 1 && 52 | method.GetParameters().First().ParameterType == typeof(byte[]) && 53 | method.Name == $"To{targetType.Name}"); 54 | if (converterMethodInfo == null) 55 | throw new InvalidOperationException($"No fitting converter could be found for the type {targetType.Name}"); 56 | InteropConverter.converterMap.Add(targetType, dataToConvert => converterMethodInfo.Invoke(null, new object[] { dataToConvert })); 57 | } 58 | 59 | // Gets the fitting converter, converts the value and returns it 60 | Func converter = InteropConverter.converterMap[targetType]; 61 | return (T)converter(data); 62 | } 63 | 64 | 65 | /// 66 | /// Converts a byte array to a 32 bit integer value. 67 | /// 68 | /// The byte array that is to be converted. 69 | /// Returns the converted data. 70 | public static int ToInt32(byte[] data) => BitConverter.ToInt32(data, 0); 71 | 72 | /// 73 | /// Converts a byte array to a 32 bit unsigned integer value. 74 | /// 75 | /// The byte array that is to be converted. 76 | /// Returns the converted data. 77 | public static uint ToUInt32(byte[] data) => BitConverter.ToUInt32(data, 0); 78 | 79 | /// 80 | /// Converts a byte array to a 64 bit integer value. 81 | /// 82 | /// The byte array that is to be converted. 83 | /// Returns the converted data. 84 | public static long ToInt64(byte[] data) => BitConverter.ToInt64(data, 0); 85 | 86 | /// 87 | /// Converts a byte array to a 64 bit unsigned integer value. 88 | /// 89 | /// The byte array that is to be converted. 90 | /// Returns the converted data. 91 | public static ulong ToUInt64(byte[] data) => BitConverter.ToUInt64(data, 0); 92 | 93 | /// 94 | /// Converts a byte array to a string value. 95 | /// 96 | /// The byte array that is to be converted. 97 | /// Returns the converted data. 98 | public static string ToString(byte[] data) 99 | { 100 | // All OpenCL String are ASCII encoded, therefore the byte array is decoded using the ASCII encoder 101 | string result = Encoding.ASCII.GetString(data); 102 | 103 | // All OpenCL strings are null-terminated, therefore the null-terminator must be removed 104 | result = result.Replace("\0", string.Empty); 105 | 106 | // Returns the converted string 107 | return result; 108 | } 109 | 110 | #endregion 111 | } 112 | } -------------------------------------------------------------------------------- /src/OpenCL-dotnet/README.md: -------------------------------------------------------------------------------- 1 | 2 | # OpenCL.NET 3 | 4 | This is an OpenCL wrapper for .NET Core, which implements the .NET Standard Profile and therefore should run cross-platform on Linux, macOS, and Windows, as well as on many different .NET implementations, such as .NET Core, Mono, .NET Framework, 5 | and Xamarin. The project aims at implementing the full OpenCL 2.1 standard on a low-level PInvoke level and create a wrapper, which exposes most of the functionality in a more CLR-style fashion. More abstract wrappers are planned for the future. 6 | This wrapper should help with implementing image manipulation software as well as with machine learning (especially deep learning). Once the components have reached a certain maturity, they will be released to *__NuGet__*. 7 | 8 | ## Installation 9 | 10 | In order to use OpenCL you have to install OpenCL. Under macOS you are in luck, because macOS has been shipping with OpenCL ever since Snow Leopard and you have to do nothing more, to get everything set up. Many standard Windows installations 11 | also alread ship with OpenCL installed. If you have a custom setup, then installing the correct drivers should suffice. Under Linux things are a little more complicated. First of all you have to install the ICD loader. For example under Ubuntu 12 | and Debian based systems you can do it like so: 13 | 14 | ```bash 15 | sudo apt update 16 | sudo apt install ocl-icd-opencl-dev 17 | ``` 18 | 19 | Then you have to install the correct drivers for your platform, e.g. the graphics adapter, and the OpenCL platform of choice. For example for Nvidia you have to install the CUDA framework. 20 | 21 | *__More information on installation and setup will follow soon.__* 22 | 23 | ## Running the Sample 24 | 25 | You can try the test application, that comes with this repository. It just performs a simple multiplication of a matrix with a vector. To build and run the sample application, you can do the following: 26 | 27 | ```bash 28 | git clone https://github.com/lecode-official/opencl-dotnet.git 29 | cd opencl-dotnet 30 | cd OpenCl.DotNetCore 31 | dotnet restore 32 | cd .. 33 | cd OpenCl.DotNetCore.Interop 34 | dotnet restore 35 | cd .. 36 | cd OpenCl.DotNetCore.Tests 37 | dotnet restore 38 | dotnet build 39 | dotnet run 40 | ``` 41 | 42 | ## Troubleshooting 43 | 44 | When your are experiencing a `DllNotFoundException` on macOS, then please make sure that you have the OpenCL framework in your library load path: 45 | 46 | ```bash 47 | export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:/System/Library/Frameworks/OpenCL.framework/OpenCL 48 | dotnet run 49 | ``` 50 | 51 | ## Roadmap 52 | 53 | In the following sections the roadmap to a stable 0.1.0-beta release is mapped out. 54 | 55 | ### General Todos 56 | 57 | - [x] Separate into three projects: Native Core, CLR Wrapper, Test Program 58 | 59 | ### *__OpenCl.DotNetCore.Interop__* Project Todos 60 | 61 | - [x] Rename the arguments of the native methods 62 | - [x] Rename Info to Information 63 | - [x] Put the different APIs of the native wrapper into different classes 64 | - [x] Port the whole API surface area 65 | - [x] Command Queues API 66 | - [x] Contexts API 67 | - [x] Devices API 68 | - [x] Enqueued Commands API 69 | - [x] Events API 70 | - [x] Extensions API 71 | - [x] Kernels API 72 | - [x] Memory API 73 | - [x] Platforms API 74 | - [x] Profiling API 75 | - [x] Programs API 76 | - [x] Samplers API 77 | - [x] SVM Allocations API 78 | - [x] Finish API documentation 79 | - [x] Command Queues API 80 | - [x] Contexts API 81 | - [x] Devices API 82 | - [x] Enqueued Commands API 83 | - [x] Events API 84 | - [x] Extensions API 85 | - [x] Kernels API 86 | - [x] Memory API 87 | - [x] Platforms API 88 | - [x] Profiling API 89 | - [x] Programs API 90 | - [x] Samplers API 91 | - [x] SVM Allocations API 92 | - [x] Mark everything with the Obsolete attribute that have been deprecated in OpenCL 93 | - [x] Mark everything with an attribute that contains the minimum version of OpenCL required 94 | 95 | ### *__OpenCl.DotNetCore__* Project Todos 96 | 97 | - [x] `HandleBase` class, which is the base class for all OpenCL classes that need a handle 98 | - [x] Add compiler log to exception, when program cannot be build 99 | - [x] Add method to compile multiple sources at once 100 | - [x] Add method to compile from file/files 101 | - [x] Add method to compile from Stream/Streams 102 | - [x] Create a class that converts `byte` arrays into CLR types 103 | - [x] Implement the `equals` and the `==` operator, which compares the `Handle` 104 | - [x] Split the different APIs in sub-namespaces 105 | - [x] Make `MemoryObject` abstract and derive `Image`, `Pipe`, and `Buffer` from it 106 | - [x] Add `async` methods for all native methods that have an `event` 107 | - [x] Create an base class for event and then derive a user event from it, which is returned when calling CreateUserEvent (this should be done to ensure, that SetUserEventStatus can only be called on valid user events) 108 | - [ ] Fix compilation and linking problems for Intel platform (maybe only on Windows) 109 | - [ ] Make `WaitEvent` awaitable (maybe even rename it to `AwaitableEvent`) 110 | 111 | ### *__OpenCl.DotNetCore.Tests__* Project Todos 112 | 113 | ![Nothing to do here](http://img4.wikia.nocookie.net/__cb20120208030738/meme/es/images/thumb/8/8a/Nothing-to-do-here.jpg/170px-Nothing-to-do-here.jpg) 114 | -------------------------------------------------------------------------------- /src/OpenCL-dotnet/OpenCl.DotNetCore.Interop/Extensions/ExtensionsNativeApi.cs: -------------------------------------------------------------------------------- 1 | 2 | #region Using Directives 3 | 4 | using System; 5 | using System.Runtime.InteropServices; 6 | 7 | #endregion 8 | 9 | namespace OpenCl.DotNetCore.Interop.Extensions 10 | { 11 | /// 12 | /// Represents a wrapper for the native methods of the OpenCL Extensions API. 13 | /// 14 | public static class ExtensionsNativeApi 15 | { 16 | #region Public Static Methods 17 | 18 | /// 19 | /// Gets the address of the extension function named by for a given . Since there is no way to qualify the query with a device, the function pointer returned must work for all 20 | /// implementations of that extension on different devices for a platform. The behavior of calling a device extension function on a device not supporting that extension is undefined. 21 | /// 22 | /// The platform for which the extension function is to be retrieved. 23 | /// Name of an extension function. 24 | /// 25 | /// Returns a pointer to the extension function named by for a given . The pointer returned should be cast to a function pointer type matching the extension function's definition defined 26 | /// in the appropriate extension specification and header file. A return value of null indicates that the specified function does not exist for the implementation or platform is not a valid platform. A non-null return 27 | /// value for does not guarantee that an extension function is actually supported by the platform. The application must also make a corresponding query using 28 | /// or to determine if an extension is supported by the OpenCL implementation. may not be queried for core 29 | /// (non-extension) functions in OpenCL. For functions that are queryable with , implementations may choose to also export those functions statically from the object libraries 30 | /// implementing those functions. However, portable applications cannot rely on this behavior. Function pointer type definitions must be declared for all extensions that add API entrypoints. These type definitions are a required part of 31 | /// the extension interface, to be provided in an appropriate header (such as cl_ext.h if the extension is an OpenCL extension, or cl_gl_ext.h if the extension is an OpenCL/OpenGL sharing extension). 32 | /// 33 | [IntroducedInOpenCl(1, 2)] 34 | [DllImport("OpenCL", EntryPoint = "clGetExtensionFunctionAddressForPlatform")] 35 | public static extern IntPtr GetExtensionFunctionAddressForPlatform( 36 | [In] IntPtr platform, 37 | [In] [MarshalAs(UnmanagedType.LPStr)] string functionName 38 | ); 39 | 40 | #endregion 41 | 42 | #region Deprecated Public Methods 43 | 44 | /// 45 | /// Returns the address of the extension function named by . 46 | /// 47 | /// Name of an extension function. 48 | /// 49 | /// Returns a pointer to the extension function named by for a given . The pointer returned should be cast to a function pointer type matching the extension function's definition defined 50 | /// in the appropriate extension specification and header file. A return value of null indicates that the specified function does not exist for the implementation or platform is not a valid platform. A non-null return 51 | /// value for does not guarantee that an extension function is actually supported by the platform. The application must also make a corresponding query using 52 | /// or to determine if an extension is supported by the OpenCL implementation. may not be queried for core (non-extension) functions in OpenCL. For functions that are 53 | /// queryable with , implementations may choose to also export those functions statically from the object libraries implementing those functions. However, portable applications cannot rely on this 54 | /// behavior. Function pointer type definitions must be declared for all extensions that add API entrypoints. These type definitions are a required part of the extension interface, to be provided in an appropriate header (such as 55 | /// cl_ext.h if the extension is an OpenCL extension, or cl_gl_ext.h if the extension is an OpenCL/OpenGL sharing extension). 56 | /// 57 | [IntroducedInOpenCl(1, 0)] 58 | [DllImport("OpenCL", EntryPoint = "clGetExtensionFunctionAddress")] 59 | [Obsolete("This is a deprecated OpenCL 1.1 method, please use GetExtensionFunctionAddressForPlatform instead.")] 60 | public static extern IntPtr GetExtensionFunctionAddress( 61 | [In] [MarshalAs(UnmanagedType.LPStr)] string functionName 62 | ); 63 | 64 | #endregion 65 | } 66 | } -------------------------------------------------------------------------------- /src/SharedSerialization/Blake2B-Inline.cs: -------------------------------------------------------------------------------- 1 | /* BLAKE2 reference source code package - C# implementation 2 | 3 | Written in 2012 by Samuel Neves 4 | Written in 2012 by Christian Winnerlein 5 | Written in 2016 by Uli Riehm 6 | 7 | To the extent possible under law, the author(s) have dedicated all copyright 8 | and related and neighboring rights to this software to the public domain 9 | worldwide. This software is distributed without any warranty. 10 | 11 | You should have received a copy of the CC0 Public Domain Dedication along with 12 | this software. If not, see . 13 | */ 14 | 15 | using System; 16 | 17 | namespace Crypto 18 | { 19 | #if INLINE 20 | public partial class Blake2B 21 | { 22 | partial void Compress() 23 | { 24 | ulong v0 = state[0]; 25 | ulong v1 = state[1]; 26 | ulong v2 = state[2]; 27 | ulong v3 = state[3]; 28 | ulong v4 = state[4]; 29 | ulong v5 = state[5]; 30 | ulong v6 = state[6]; 31 | ulong v7 = state[7]; 32 | 33 | ulong v8 = IV0; 34 | ulong v9 = IV1; 35 | ulong v10 = IV2; 36 | ulong v11 = IV3; 37 | ulong v12 = IV4 ^ counter0; 38 | ulong v13 = IV5 ^ counter1; 39 | ulong v14 = IV6 ^ f0; 40 | ulong v15 = IV7 ^ f1; 41 | 42 | for (int r = 0; r < NumberOfRounds; ++r) 43 | { 44 | // G(r,0,v0,v4,v8,v12) 45 | v0 = v0 + v4 + material[Sigma[16 * r + 2 * 0 + 0]]; 46 | v12 ^= v0; 47 | v12 = ((v12 >> 32) | (v12 << (64 - 32))); 48 | v8 = v8 + v12; 49 | v4 ^= v8; 50 | v4 = ((v4 >> 24) | (v4 << (64 - 24))); 51 | v0 = v0 + v4 + material[Sigma[16 * r + 2 * 0 + 1]]; 52 | v12 ^= v0; 53 | v12 = ((v12 >> 16) | (v12 << (64 - 16))); 54 | v8 = v8 + v12; 55 | v4 ^= v8; 56 | v4 = ((v4 >> 63) | (v4 << (64 - 63))); 57 | 58 | // G(r,1,v1,v5,v9,v13) 59 | v1 = v1 + v5 + material[Sigma[16 * r + 2 * 1 + 0]]; 60 | v13 ^= v1; 61 | v13 = ((v13 >> 32) | (v13 << (64 - 32))); 62 | v9 = v9 + v13; 63 | v5 ^= v9; 64 | v5 = ((v5 >> 24) | (v5 << (64 - 24))); 65 | v1 = v1 + v5 + material[Sigma[16 * r + 2 * 1 + 1]]; 66 | v13 ^= v1; 67 | v13 = ((v13 >> 16) | (v13 << (64 - 16))); 68 | v9 = v9 + v13; 69 | v5 ^= v9; 70 | v5 = ((v5 >> 63) | (v5 << (64 - 63))); 71 | 72 | // G(r,2,v2,v6,v10,v14) 73 | v2 = v2 + v6 + material[Sigma[16 * r + 2 * 2 + 0]]; 74 | v14 ^= v2; 75 | v14 = ((v14 >> 32) | (v14 << (64 - 32))); 76 | v10 = v10 + v14; 77 | v6 ^= v10; 78 | v6 = ((v6 >> 24) | (v6 << (64 - 24))); 79 | v2 = v2 + v6 + material[Sigma[16 * r + 2 * 2 + 1]]; 80 | v14 ^= v2; 81 | v14 = ((v14 >> 16) | (v14 << (64 - 16))); 82 | v10 = v10 + v14; 83 | v6 ^= v10; 84 | v6 = ((v6 >> 63) | (v6 << (64 - 63))); 85 | 86 | // G(r,3,v3,v7,v11,v15) 87 | v3 = v3 + v7 + material[Sigma[16 * r + 2 * 3 + 0]]; 88 | v15 ^= v3; 89 | v15 = ((v15 >> 32) | (v15 << (64 - 32))); 90 | v11 = v11 + v15; 91 | v7 ^= v11; 92 | v7 = ((v7 >> 24) | (v7 << (64 - 24))); 93 | v3 = v3 + v7 + material[Sigma[16 * r + 2 * 3 + 1]]; 94 | v15 ^= v3; 95 | v15 = ((v15 >> 16) | (v15 << (64 - 16))); 96 | v11 = v11 + v15; 97 | v7 ^= v11; 98 | v7 = ((v7 >> 63) | (v7 << (64 - 63))); 99 | 100 | // G(r,4,v0,v5,v10,v15) 101 | v0 = v0 + v5 + material[Sigma[16 * r + 2 * 4 + 0]]; 102 | v15 ^= v0; 103 | v15 = ((v15 >> 32) | (v15 << (64 - 32))); 104 | v10 = v10 + v15; 105 | v5 ^= v10; 106 | v5 = ((v5 >> 24) | (v5 << (64 - 24))); 107 | v0 = v0 + v5 + material[Sigma[16 * r + 2 * 4 + 1]]; 108 | v15 ^= v0; 109 | v15 = ((v15 >> 16) | (v15 << (64 - 16))); 110 | v10 = v10 + v15; 111 | v5 ^= v10; 112 | v5 = ((v5 >> 63) | (v5 << (64 - 63))); 113 | 114 | // G(r,5,v1,v6,v11,v12) 115 | v1 = v1 + v6 + material[Sigma[16 * r + 2 * 5 + 0]]; 116 | v12 ^= v1; 117 | v12 = ((v12 >> 32) | (v12 << (64 - 32))); 118 | v11 = v11 + v12; 119 | v6 ^= v11; 120 | v6 = ((v6 >> 24) | (v6 << (64 - 24))); 121 | v1 = v1 + v6 + material[Sigma[16 * r + 2 * 5 + 1]]; 122 | v12 ^= v1; 123 | v12 = ((v12 >> 16) | (v12 << (64 - 16))); 124 | v11 = v11 + v12; 125 | v6 ^= v11; 126 | v6 = ((v6 >> 63) | (v6 << (64 - 63))); 127 | 128 | // G(r,6,v2,v7,v8,v13) 129 | v2 = v2 + v7 + material[Sigma[16 * r + 2 * 6 + 0]]; 130 | v13 ^= v2; 131 | v13 = ((v13 >> 32) | (v13 << (64 - 32))); 132 | v8 = v8 + v13; 133 | v7 ^= v8; 134 | v7 = ((v7 >> 24) | (v7 << (64 - 24))); 135 | v2 = v2 + v7 + material[Sigma[16 * r + 2 * 6 + 1]]; 136 | v13 ^= v2; 137 | v13 = ((v13 >> 16) | (v13 << (64 - 16))); 138 | v8 = v8 + v13; 139 | v7 ^= v8; 140 | v7 = ((v7 >> 63) | (v7 << (64 - 63))); 141 | 142 | // G(r,7,v3,v4,v9,v14) 143 | v3 = v3 + v4 + material[Sigma[16 * r + 2 * 7 + 0]]; 144 | v14 ^= v3; 145 | v14 = ((v14 >> 32) | (v14 << (64 - 32))); 146 | v9 = v9 + v14; 147 | v4 ^= v9; 148 | v4 = ((v4 >> 24) | (v4 << (64 - 24))); 149 | v3 = v3 + v4 + material[Sigma[16 * r + 2 * 7 + 1]]; 150 | v14 ^= v3; 151 | v14 = ((v14 >> 16) | (v14 << (64 - 16))); 152 | v9 = v9 + v14; 153 | v4 ^= v9; 154 | v4 = ((v4 >> 63) | (v4 << (64 - 63))); 155 | } 156 | 157 | state[0] ^= v0 ^ v8; 158 | state[1] ^= v1 ^ v9; 159 | state[2] ^= v2 ^ v10; 160 | state[3] ^= v3 ^ v11; 161 | state[4] ^= v4 ^ v12; 162 | state[5] ^= v5 ^ v13; 163 | state[6] ^= v6 ^ v14; 164 | state[7] ^= v7 ^ v15; 165 | } 166 | } 167 | #endif 168 | } 169 | -------------------------------------------------------------------------------- /src/OpenCL-dotnet/OpenCl.DotNetCore.Interop/Memory/ChannelOrder.cs: -------------------------------------------------------------------------------- 1 | 2 | namespace OpenCl.DotNetCore.Interop.Memory 3 | { 4 | /// 5 | /// Represents an enumeration for the different ways color channels can be ordered in a pixel of an image. 6 | /// 7 | public enum ChannelOrder : uint 8 | { 9 | /// 10 | /// Only a red channel. 11 | /// 12 | R = 0x10B0, 13 | 14 | /// 15 | /// Only an alpha channel. 16 | /// 17 | A = 0x10B1, 18 | 19 | /// 20 | /// Only a red and a green channel. 21 | /// 22 | Rg = 0x10B2, 23 | 24 | /// 25 | /// Only a red and an alpha channel. 26 | /// 27 | Ra = 0x10B3, 28 | 29 | /// 30 | /// Red, green, and blue channel. This channel order can only be used if the channel data type is ChannelType.NormalizedUnsignedShortFloat565, ChannelType.NormalizedUnsignedShortFloat555 or 31 | /// ChannelType.NormalizedUnsignedInteger101010. 32 | /// 33 | Rgb = 0x10B4, 34 | 35 | /// 36 | /// Red, green, blue, and alpha channel. 37 | /// 38 | Rgba = 0x10B5, 39 | 40 | /// 41 | /// Blue, green, red, and alpha channel. This channel order can only be used if the channel data type is ChannelType.NormalizedUnsignedInteger8, ChannelType.NormalizedSignedInteger8, ChannelType.SignedInteger8, or 42 | /// ChannelType.UnsignedInteger8. 43 | /// 44 | Bgra = 0x10B6, 45 | 46 | /// 47 | /// Alpha, red, green, and blue channel. This channel order can only be used if the channel data type is ChannelType.NormalizedUnsignedInteger8, ChannelType.NormalizedSignedInteger8, ChannelType.SignedInteger8, or 48 | /// ChannelType.UnsignedInteger8. 49 | /// 50 | Argb = 0x10B7, 51 | 52 | /// 53 | /// Only one channel for the intensity. This channel order can only be used if the channel data type is ChannelType.NormalizedUnsignedInteger8, ChannelType.NormalizedUnsignedInteger16, 54 | /// ChannelType.NormalizedSignedInteger8, ChannelType.NormalizedSignedInteger16, ChannelType.HalfFloat, or ChannelType.Float. 55 | /// 56 | Intensity = 0x10B8, 57 | 58 | /// 59 | /// Only one channel for the luminance. This channel order can only be used if the channel data type is ChannelType.NormalizedUnsignedInteger8, ChannelType.NormalizedUnsignedInteger16, 60 | /// ChannelType.NormalizedSignedInteger8, ChannelType.NormalizedSignedInteger16, ChannelType.HalfFloat, or ChannelType.Float. 61 | /// 62 | Luminance = 0x10B9, 63 | 64 | /// 65 | /// Only a red channel with some padding. 66 | /// 67 | Rx = 0x10BA, 68 | 69 | /// 70 | /// Red and green channel with some padding. 71 | /// 72 | Rgx = 0x10BB, 73 | 74 | /// 75 | /// Red, green, and blue channel with some padding. This channel order can only be used if the channel data type is ChannelType.NormalizedUnsignedShortFloat565, ChannelType.NormalizedUnsignedShortFloat555 or 76 | /// ChannelType.NormalizedUnsignedInteger101010. 77 | /// 78 | Rgbx = 0x10BC, 79 | 80 | /// 81 | /// Only one channel for depth. This channel order can only be used if the channel data type is ChannelType.NormalizedUnsignedInteger16 or ChannelType.Float. 82 | /// 83 | Depth = 0x10BD, 84 | 85 | /// 86 | /// Only one channel for a depth stencil. This channel order can only be used if the channel data type is ChannelType.NormalizedUnsignedInteger24. 87 | /// 88 | DepthStencil = 0x10BE, 89 | 90 | /// 91 | /// Standard RGB (red, green, and blue channel). This channel order can only be used if the channel data type is ChannelType.NormalizedUnsignedInteger8. 92 | /// 93 | Srgb = 0x10BF, 94 | 95 | /// 96 | /// Standard RGB (red, green, and blue channel) with some padding. This channel order can only be used if the channel data type is ChannelType.NormalizedUnsignedInteger8. 97 | /// 98 | Srgbx = 0x10C0, 99 | 100 | /// 101 | /// Standard RGBA with alpha channel (red, green, blue, and alpha channel). This channel order can only be used if the channel data type is ChannelType.NormalizedUnsignedInteger8. 102 | /// 103 | Srgba = 0x10C1, 104 | 105 | /// 106 | /// Standard BGRA with alpha channel (blue, green, red, and alpha channel). This channel order can only be used if the channel data type is ChannelType.NormalizedUnsignedInteger8. 107 | /// 108 | Sbgra = 0x10C2, 109 | 110 | /// 111 | /// Alpha, blue, green, and red channel. This channel order can only be used if the channel data type is ChannelType.NormalizedUnsignedInteger8, ChannelType.NormalizedSignedInteger8, ChannelType.SignedInteger8, or 112 | /// ChannelType.UnsignedInteger8. 113 | /// 114 | Abgr = 0x10C3 115 | } 116 | } -------------------------------------------------------------------------------- /src/GrinProMInerAPI/Controllers/StatusController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Http; 6 | using Microsoft.AspNetCore.Mvc; 7 | using Mozkomor.GrinGoldMiner; 8 | using GrinProMiner.Models; 9 | using SharedSerialization; 10 | 11 | namespace GrinProMiner.Controllers 12 | { 13 | [Route("api/[controller]")] 14 | [ApiController] 15 | public class StatusController : ControllerBase 16 | { 17 | [Route("all")] 18 | public ActionResult GetAll() 19 | { 20 | var lastJob = WorkerManager.lastJob.ToString(); 21 | 22 | var conn = ConnectionManager.GetCurrConn(); 23 | 24 | if (conn == null) 25 | return StatusCode(404, "No Straturm Connection active."); 26 | 27 | 28 | var lastSHare = conn.lastShare; 29 | var totalShares = conn.totalShares; 30 | var accepted = conn.sharesAccepted; 31 | var rejected = conn.sharesRejected; 32 | var tooLate = conn.sharesTooLate; 33 | ///TODO do WorkerManagera dat SolutionsFound (kolik dohromady ze vsech karet) a 34 | /// SolutionsSubmitted (to bude az co projde pres diff) 35 | 36 | Status status = new Status(); 37 | 38 | status.LastShare = lastSHare.ToString(); 39 | status.LastJob = lastJob; 40 | 41 | 42 | 43 | List workers = new List(); 44 | foreach (var worker in WorkerManager.GetWorkersInfo()) 45 | { 46 | workers.Add(worker); 47 | } 48 | status.Workers = workers; 49 | 50 | var sc1 = conn; 51 | bool isFee = ConnectionManager.IsInFee(); 52 | var c1 = new StratumConnectionInfo() 53 | { 54 | Address = isFee ? "FEE" : sc1.ip, 55 | Port = isFee ? "FEE" : sc1.port.ToString(), 56 | Login = isFee ? "FEE" : sc1.login, 57 | Password = isFee ? "FEE" : sc1.password, 58 | Status = sc1.IsConnected == true ? "Connected" : "Disconnectd", 59 | LastCommunication = sc1.lastComm.ToString(), 60 | LastJob = sc1.CurrentJob?.timestamp.ToString(), 61 | }; 62 | status.ActiveConnection = c1; 63 | 64 | 65 | ShareStats ss = new ShareStats(); 66 | ss.Accepted = accepted; 67 | ss.FailedToValidate = rejected; 68 | ss.Found = (uint)workers.Sum(w => w.TotalSols); 69 | ss.Submitted = totalShares; 70 | ss.TooLate = tooLate; 71 | 72 | status.Shares = ss; 73 | 74 | return status; 75 | } 76 | 77 | [Route("")] 78 | public ActionResult Get() 79 | { 80 | var lastJob = WorkerManager.lastJob.ToString("yyyy-MM-ddTHH:mm:ssK"); 81 | 82 | var conn = ConnectionManager.GetCurrConn(); 83 | 84 | if (conn == null) 85 | return StatusCode(404, "No Straturm Connection active."); 86 | 87 | 88 | var lastSHare = conn.lastShare; 89 | var totalShares = conn.totalShares; 90 | var accepted = conn.sharesAccepted; 91 | var rejected = conn.sharesRejected; 92 | var tooLate = conn.sharesTooLate; 93 | ///TODO do WorkerManagera dat SolutionsFound (kolik dohromady ze vsech karet) a 94 | /// SolutionsSubmitted (to bude az co projde pres diff) 95 | 96 | SimpleStatus status = new SimpleStatus(); 97 | 98 | status.LastShare = lastSHare.ToString("yyyy-MM-ddTHH:mm:ssK"); 99 | status.LastJob = lastJob; 100 | 101 | List workers = new List(); 102 | foreach (var worker in WorkerManager.GetWorkersInfo()) 103 | { 104 | SimpleWorkerInfo wi = new SimpleWorkerInfo(); 105 | 106 | wi.GPUName = worker.GPUName; 107 | wi.Platform = worker.GPUOption.PlatformID.ToString(); 108 | wi.Status = worker.GPUStatus; 109 | wi.GraphsPerSecond = worker.GraphsPerSecond; 110 | wi.ID = worker.ID; 111 | wi.TotalSols = worker.TotalSols; 112 | wi.LastSolution = worker.lastSolution.ToString("yyyy-MM-ddTHH:mm:ssK"); 113 | wi.Fidelity = (float)worker.Fidelity; 114 | workers.Add(wi); 115 | } 116 | status.Workers = workers; 117 | 118 | if (ConnectionManager.IsInFee()) 119 | { 120 | status.ConnectionAddress = $"FEE (GrinPro collects 1% as fee for the Grin Development Fund and 1% for further miner development.)"; 121 | status.ConnectionStatus = conn.IsConnected == true ? "Connected" : "Disconnectd"; 122 | } 123 | else 124 | { 125 | status.ConnectionAddress = $"{conn.ip}:{conn.port}"; 126 | status.ConnectionStatus = conn.IsConnected == true ? "Connected" : "Disconnectd"; 127 | } 128 | 129 | ShareStats ss = new ShareStats(); 130 | ss.Accepted = accepted; 131 | ss.FailedToValidate = rejected; 132 | ss.Found = (uint)workers.Sum(w => w.TotalSols); 133 | ss.Submitted = totalShares; 134 | ss.TooLate = tooLate; 135 | 136 | status.Shares = ss; 137 | 138 | return status; 139 | } 140 | } 141 | } -------------------------------------------------------------------------------- /src/Cudacka/Cudacka.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | x64 7 | 8 | 9 | Release 10 | x64 11 | 12 | 13 | 14 | {B87AA420-FC97-4320-9584-BD1E3863AA79} 15 | Cudacka 16 | 8.1 17 | 18 | 19 | 20 | 21 | Utility 22 | true 23 | MultiByte 24 | v141 25 | 26 | 27 | Utility 28 | false 29 | true 30 | MultiByte 31 | v141 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | true 46 | 47 | 48 | bin 49 | 50 | 51 | 52 | Level3 53 | Disabled 54 | WIN32;WIN64;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 55 | 56 | 57 | true 58 | Console 59 | cudart.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) 60 | 61 | 62 | echo copy "$(CudaToolkitBinDir)\cudart*.dll" "$(OutDir)" 63 | copy "$(CudaToolkitBinDir)\cudart*.dll" "$(OutDir)" 64 | 65 | 66 | 64 67 | ptx 68 | compute_35,sm_35 69 | $(OutDir)%(Filename)\%(Filename)_x64.ptx 70 | 71 | 72 | 73 | 74 | Level3 75 | MaxSpeed 76 | true 77 | true 78 | WIN32;WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 79 | 80 | 81 | true 82 | true 83 | true 84 | Console 85 | cudart.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) 86 | 87 | 88 | echo copy "$(CudaToolkitBinDir)\cudart*.dll" "$(OutDir)" 89 | copy "$(CudaToolkitBinDir)\cudart*.dll" "$(OutDir)" 90 | 91 | 92 | 64 93 | compute_61,sm_61 94 | ptx 95 | $(OutDir)\kernel_x64.ptx 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | -------------------------------------------------------------------------------- /src/OpenCL-dotnet/OpenCl.DotNetCore.Interop/Programs/ProgramInformation.cs: -------------------------------------------------------------------------------- 1 | 2 | namespace OpenCl.DotNetCore.Interop.Programs 3 | { 4 | /// 5 | /// Represents an enumeration for the different types of information that can be queried from a program. 6 | /// 7 | public enum ProgramInformation : uint 8 | { 9 | /// 10 | /// Retrieves the program reference count. The reference count returned should be considered immediately stale. It is unsuitable for general use in applications. This feature is provided for identifying memory leaks. 11 | /// 12 | ReferenceCount = 0x1160, 13 | 14 | /// 15 | /// Retrieves the context specified when the program object is created. 16 | /// 17 | Context = 0x1161, 18 | 19 | /// 20 | /// Retrieves the number of devices associated with program. 21 | /// 22 | NumberOfDevices = 0x1162, 23 | 24 | /// 25 | /// Retrieves the list of devices associated with the program object. This can be the devices associated with on which the program object has been created or can be a subset of devices that are specified when a 26 | /// progam object is created using . 27 | /// 28 | Devices = 0x1163, 29 | 30 | /// 31 | /// Retrieves the program source code specified by . The source string returned is a concatenation of all source strings specified to with a null terminator. The 32 | /// concatenation strips any nulls in the original source strings. 33 | /// 34 | /// If program is created using , , or , a null string or the appropriate program source code is returned depending on 35 | /// whether or not the program source code is stored in the binary. 36 | /// 37 | Source = 0x1164, 38 | 39 | /// 40 | /// Retrieves an array that contains the size in bytes of the program binary (could be an executable binary, compiled binary or library binary) for each device associated with program. The size of the array is the number of devices 41 | /// associated with program. If a binary is not available for a device(s), a size of zero is returned. 42 | /// 43 | /// If program is created using , the implementation may return zero in any entries of the returned array. 44 | /// 45 | BinarySizes = 0x1165, 46 | 47 | /// 48 | /// Retrieves the program binaries (could be an executable binary, compiled binary or library binary) for all devices associated with . For each device in , the binary returned can be the binary 49 | /// specified for the device when program is created with or it can be the executable binary generated by or . If program is created with 50 | /// or , the binary returned is the binary generated by , , or . The bits returned 51 | /// can be an implementation-specific intermediate representation (a.k.a. IR) or device specific executable bits or both. The decision on which information is returned in the binary is up to the OpenCL implementation. 52 | /// 53 | /// points to an array of n pointers allocated by the caller, where n is the number of devices associated with . The buffer sizes needed to allocate the memory that these n pointers 54 | /// refer to can be queried using the ProgramInformation.BinarySizes query as described in this table. 55 | /// 56 | /// Each entry in this array is used by the implementation as the location in memory where to copy the program binary for a specific device, if there is a binary available. To find out which device the program binary in the array 57 | /// refers to, use the ProgramInformation.Devices query to get the list of devices. There is a one-to-one correspondence between the array of n pointers returned by ProgramInformation.BinarySizes and array of devices 58 | /// returned by ProgramInformation.Devices. 59 | /// 60 | /// If an entry value in the array is null, the implementation skips copying the program binary for the specific device identified by the array index. 61 | /// 62 | Binaries = 0x1166, 63 | 64 | /// 65 | /// Retrieves the number of kernels declared in program that can be created with . This information is only available after a successful program executable has been built for at least one device in the list of 66 | /// devices associated with . 67 | /// 68 | NumberOfKernels = 0x1167, 69 | 70 | /// 71 | /// Retrieves a semi-colon separated list of kernel names in that can be created with . This information is only available after a successful program executable has been built for at least 72 | // one device in the list of devices associated with . 73 | /// 74 | KernelNames = 0x1168, 75 | 76 | /// 77 | /// Retrieves the program IL for programs created with . If program is created with , or 78 | /// the memory pointed to by will be unchanged and will be set to 0. 79 | /// 80 | Il = 0x1169 81 | } 82 | } --------------------------------------------------------------------------------