Skip to content

Commit

Permalink
Backup commit
Browse files Browse the repository at this point in the history
  • Loading branch information
nicehashdev committed Oct 18, 2015
1 parent e7bcccd commit 46ef7de
Show file tree
Hide file tree
Showing 19 changed files with 986 additions and 150 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,4 @@ cpuid/cpuid.vcxproj.user
*.obj
*.pdb
*.idb
NiceHashMiner.sdf
16 changes: 10 additions & 6 deletions NiceHashMiner.sln
Original file line number Diff line number Diff line change
Expand Up @@ -10,41 +10,45 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NiceHashMiner", "NiceHashMi
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cpuid", "cpuid\cpuid.vcxproj", "{23C94F99-F466-4CBE-90B7-71B450DD7BF1}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "setcpuaff", "setcpuaff\setcpuaff.vcxproj", "{CC9B70AB-897D-4AE9-8785-33CEB199E2E6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|Mixed Platforms = Debug|Mixed Platforms
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
Release|Any CPU = Release|Any CPU
Release|Mixed Platforms = Release|Mixed Platforms
Release|Win32 = Release|Win32
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A70B0AEE-15C4-49E1-9DC9-B936A1EBC2B5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A70B0AEE-15C4-49E1-9DC9-B936A1EBC2B5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A70B0AEE-15C4-49E1-9DC9-B936A1EBC2B5}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{A70B0AEE-15C4-49E1-9DC9-B936A1EBC2B5}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{A70B0AEE-15C4-49E1-9DC9-B936A1EBC2B5}.Debug|Win32.ActiveCfg = Debug|Any CPU
{A70B0AEE-15C4-49E1-9DC9-B936A1EBC2B5}.Debug|x64.ActiveCfg = Debug|Any CPU
{A70B0AEE-15C4-49E1-9DC9-B936A1EBC2B5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A70B0AEE-15C4-49E1-9DC9-B936A1EBC2B5}.Release|Any CPU.Build.0 = Release|Any CPU
{A70B0AEE-15C4-49E1-9DC9-B936A1EBC2B5}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{A70B0AEE-15C4-49E1-9DC9-B936A1EBC2B5}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{A70B0AEE-15C4-49E1-9DC9-B936A1EBC2B5}.Release|Win32.ActiveCfg = Release|Any CPU
{A70B0AEE-15C4-49E1-9DC9-B936A1EBC2B5}.Release|x64.ActiveCfg = Release|Any CPU
{23C94F99-F466-4CBE-90B7-71B450DD7BF1}.Debug|Any CPU.ActiveCfg = Debug|Win32
{23C94F99-F466-4CBE-90B7-71B450DD7BF1}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
{23C94F99-F466-4CBE-90B7-71B450DD7BF1}.Debug|Mixed Platforms.Build.0 = Debug|Win32
{23C94F99-F466-4CBE-90B7-71B450DD7BF1}.Debug|Win32.ActiveCfg = Debug|Win32
{23C94F99-F466-4CBE-90B7-71B450DD7BF1}.Debug|x64.ActiveCfg = Debug|Win32
{23C94F99-F466-4CBE-90B7-71B450DD7BF1}.Release|Any CPU.ActiveCfg = Release|Win32
{23C94F99-F466-4CBE-90B7-71B450DD7BF1}.Release|Mixed Platforms.ActiveCfg = Release|Win32
{23C94F99-F466-4CBE-90B7-71B450DD7BF1}.Release|Mixed Platforms.Build.0 = Release|Win32
{23C94F99-F466-4CBE-90B7-71B450DD7BF1}.Release|Win32.ActiveCfg = Release|Win32
{23C94F99-F466-4CBE-90B7-71B450DD7BF1}.Release|Win32.Build.0 = Release|Win32
{23C94F99-F466-4CBE-90B7-71B450DD7BF1}.Release|x64.ActiveCfg = Release|Win32
{CC9B70AB-897D-4AE9-8785-33CEB199E2E6}.Debug|Any CPU.ActiveCfg = Debug|x64
{CC9B70AB-897D-4AE9-8785-33CEB199E2E6}.Debug|Mixed Platforms.ActiveCfg = Debug|x64
{CC9B70AB-897D-4AE9-8785-33CEB199E2E6}.Debug|Mixed Platforms.Build.0 = Debug|x64
{CC9B70AB-897D-4AE9-8785-33CEB199E2E6}.Debug|Win32.ActiveCfg = Debug|x64
{CC9B70AB-897D-4AE9-8785-33CEB199E2E6}.Release|Any CPU.ActiveCfg = Release|x64
{CC9B70AB-897D-4AE9-8785-33CEB199E2E6}.Release|Mixed Platforms.ActiveCfg = Release|x64
{CC9B70AB-897D-4AE9-8785-33CEB199E2E6}.Release|Mixed Platforms.Build.0 = Release|x64
{CC9B70AB-897D-4AE9-8785-33CEB199E2E6}.Release|Win32.ActiveCfg = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
35 changes: 0 additions & 35 deletions NiceHashMiner/Algorithm.cs

This file was deleted.

60 changes: 53 additions & 7 deletions NiceHashMiner/CPUID.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,70 @@
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.Diagnostics;

namespace NiceHashMiner
{
class CPUID
{
[DllImport("cpuid.dll")]
public static extern string GetCPUName();
[DllImport("cpuid.dll", CallingConvention = CallingConvention.Cdecl)]
private static extern IntPtr _GetCPUName();

[DllImport("cpuid.dll")]
public static extern string GetCPUVendor();
[DllImport("cpuid.dll", CallingConvention = CallingConvention.Cdecl)]
private static extern IntPtr _GetCPUVendor();

[DllImport("cpuid.dll")]
[DllImport("cpuid.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern int SupportsSSE2();

[DllImport("cpuid.dll")]
[DllImport("cpuid.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern int SupportsAVX();

[DllImport("cpuid.dll")]
[DllImport("cpuid.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern int SupportsAVX2();

[DllImport("cpuid.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern int GetPhysicalProcessorCount();

public static string GetCPUName()
{
IntPtr a = _GetCPUName();
return Marshal.PtrToStringAnsi(a);
}

public static string GetCPUVendor()
{
IntPtr a = _GetCPUVendor();
return Marshal.PtrToStringAnsi(a);
}

public static int GetVirtualCoresCount()
{
int coreCount = 0;

foreach (var item in new System.Management.ManagementObjectSearcher("Select * from Win32_ComputerSystem").Get())
{
coreCount += int.Parse(item["NumberOfLogicalProcessors"].ToString());
}

return coreCount;
}

public static ulong CreateAffinityMask(int index, int percpu)
{
ulong mask = 0;
ulong one = 0x0000000000000001;
for (int i = index * percpu; i < (index + 1) * percpu; i++)
mask = mask | (one << i);
return mask;
}

public static void AdjustAffinity(int pid, ulong mask)
{
Process ProcessHandle = new Process();
ProcessHandle.StartInfo.FileName = "setcpuaff.exe";
ProcessHandle.StartInfo.Arguments = pid.ToString() + " " + mask.ToString();
ProcessHandle.StartInfo.CreateNoWindow = true;
ProcessHandle.Start();
}
}
}
23 changes: 14 additions & 9 deletions NiceHashMiner/Form1.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 46ef7de

Please sign in to comment.