Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnnyFFM committed May 28, 2018
2 parents 100f87d + 7981d30 commit 3c8df01
Show file tree
Hide file tree
Showing 3 changed files with 216 additions and 218 deletions.
89 changes: 45 additions & 44 deletions XPlotter.cpp
Expand Up @@ -49,10 +49,10 @@ BOOL SetPrivilege(void)
tp.PrivilegeCount = 1;
tp.Privileges[0].Luid = luid;
tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;

// Enable the privilege or disable all privileges.

if (!AdjustTokenPrivileges( hToken, FALSE, &tp, sizeof(TOKEN_PRIVILEGES), (PTOKEN_PRIVILEGES)NULL, (PDWORD)NULL))
if (!AdjustTokenPrivileges(hToken, FALSE, &tp, sizeof(TOKEN_PRIVILEGES), (PTOKEN_PRIVILEGES)NULL, (PDWORD)NULL))
{
printLastError("AdjustTokenPrivileges error:");
return FALSE;
Expand All @@ -73,7 +73,7 @@ unsigned long long getFreeSpace(const char* path)
ULARGE_INTEGER lpTotalNumberOfFreeBytes;

GetDiskFreeSpaceExA(path, &lpFreeBytesAvailable, &lpTotalNumberOfBytes, &lpTotalNumberOfFreeBytes);

return lpFreeBytesAvailable.QuadPart;
}

Expand All @@ -93,7 +93,7 @@ void writer_i(const unsigned long long offset, const unsigned long long nonces_t
DWORD dwBytesWritten;
LARGE_INTEGER li;
QueryPerformanceFrequency(&li);

#ifdef __PRINT_WRITER_PERF__
const auto pc_freq = double(li.QuadPart);
LARGE_INTEGER start_time, end_time;
Expand All @@ -105,7 +105,7 @@ void writer_i(const unsigned long long offset, const unsigned long long nonces_t
if (poc2) {
char *buffer = new char[32];


for (size_t scoop = 0; scoop < HASH_CAP / 2; scoop++) {
for (unsigned long t = 0;t < SCOOP_SIZE * nonces_to_write;t += 64) {
memcpy(buffer, &cache_write[scoop][t + 32], 32);
Expand All @@ -130,15 +130,15 @@ void writer_i(const unsigned long long offset, const unsigned long long nonces_t
printLastError(" Failed WriteFile");
exit(-1);
}
written_scoops = scoop+1;
written_scoops = scoop + 1;
}

#ifdef __PRINT_WRITER_PERF__
QueryPerformanceCounter(static_cast<LARGE_INTEGER*>(&end_time));
QueryPerformanceCounter(static_cast<LARGE_INTEGER*>(&end_time));
printf("\n%.3f\n", double(end_time.QuadPart - start_time.QuadPart) / pc_freq);
#endif

write_to_stream(offset+nonces_to_write);
write_to_stream(offset + nonces_to_write);
return;
}

Expand Down Expand Up @@ -198,7 +198,7 @@ bool is_number(const std::string& s)

int drive_info(const std::string &path)
{
std::string drive = path.substr(0, path.find_first_of("/\\")+1);
std::string drive = path.substr(0, path.find_first_of("/\\") + 1);
char NameBuffer[MAX_PATH];
char SysNameBuffer[MAX_PATH];
DWORD VSNumber;
Expand All @@ -223,13 +223,13 @@ int drive_info(const std::string &path)

/*
unsigned long long GCD(unsigned long long a, unsigned long long b) //íàèáîëüøèé îáùèé äåëèòåëü
{
return b ? GCD(b, a%b) : a;
{
return b ? GCD(b, a%b) : a;
}
unsigned long long LCM(unsigned long long a, unsigned long long b) //íàèìåíüøåå îáùåå êðàòíîå
{
return a / GCD(a, b) * b;
return a / GCD(a, b) * b;
}
*/

Expand All @@ -243,7 +243,7 @@ int main(int argc, char* argv[])
unsigned long long nonces_per_thread = 0;
unsigned long long memory = 0;
std::string out_path = "";

std::thread writer;
std::vector<std::thread> workers;
unsigned long long start_timer = 0;
Expand Down Expand Up @@ -271,9 +271,11 @@ int main(int argc, char* argv[])
}

SetConsoleTextAttribute(hConsole, colour::GREEN);
printf("\nXPlotter v1.0 for BURST\n");
printf("\nXPlotter v1.2 for BURST\n");
SetConsoleTextAttribute(hConsole, colour::DARKGREEN);
printf("\t\tprogrammers: Blago, Cerr Janror, DCCT\n\n");
printf("\t\tprogrammers: Blago, Cerr Janror, DCCT\n");
printf("\t\tPOC2 modder: Johnny (5/2018)\n\n");

SetConsoleTextAttribute(hConsole, colour::GRAY);
std::vector<std::string> args(argv, &argv[(size_t)argc]); //copy all parameters to args
for (auto & it : args) //make all parameters to lower case
Expand All @@ -295,21 +297,21 @@ int main(int argc, char* argv[])
poc2 = true;
if (args[i] == "-mem")
{
i++;
memory = strtoull(args[i].substr(0, args[i].find_last_of("0123456789") + 1).c_str(), 0, 10);
switch (args[i][args[i].length() - 1])
{
case 't':
case 'T':
memory *= 1024;
case 'g':
case 'G':
memory *= 1024;
}
i++;
memory = strtoull(args[i].substr(0, args[i].find_last_of("0123456789") + 1).c_str(), 0, 10);
switch (args[i][args[i].length() - 1])
{
case 't':
case 'T':
memory *= 1024;
case 'g':
case 'G':
memory *= 1024;
}
}
}


if (out_path.empty() || (out_path.find(":") == std::string::npos))
{
char Buffer[MAX_PATH];
Expand All @@ -327,7 +329,7 @@ int main(int argc, char* argv[])
printLastError("Can't create directory " + out_path + " for plots");
exit(-1);
}

drive_info(out_path);

DWORD sectorsPerCluster;
Expand All @@ -349,7 +351,7 @@ int main(int argc, char* argv[])

// ajusting nonces
nonces = (nonces / (bytesPerSector / SCOOP_SIZE)) * (bytesPerSector / SCOOP_SIZE);

std::string filename = "";
if (poc2) {
filename = std::to_string(addr) + "_" + std::to_string(startnonce) + "_" + std::to_string(nonces);
Expand Down Expand Up @@ -387,7 +389,7 @@ int main(int argc, char* argv[])
exit(-1);
}


// reserve free space for plot
LARGE_INTEGER liDistanceToMove;
liDistanceToMove.QuadPart = nonces * PLOT_SIZE;
Expand All @@ -401,7 +403,7 @@ int main(int argc, char* argv[])
DeleteFileA((out_path + filename).c_str());
exit(-1);
}

if (granted)
{
if (SetFileValidData(ofile, nonces * PLOT_SIZE) == 0)
Expand All @@ -417,7 +419,7 @@ int main(int argc, char* argv[])

if (memory) nonces_per_thread = memory * 2 / threads;
else nonces_per_thread = 1024; //(bytesPerSector / SCOOP_SIZE) * 1024 / threads;

if (nonces < nonces_per_thread * threads) nonces_per_thread = nonces / threads;

// check free RAM
Expand All @@ -431,8 +433,7 @@ int main(int argc, char* argv[])
printf("Start_nonce: %llu\n", startnonce);
printf("Nonces: %llu\n", nonces);
printf("Nonces per thread: %llu\n", nonces_per_thread);
printf("Nonces per thread: %llu\n", nonces_per_thread);
poc2 ? printf("POC2 Plotting enabled.\n") : printf("POC2 Plotting disabled.\n");
poc2 ? printf("POC2 Plotting enabled.\n") : printf("POC2 Plotting disabled.\n");

printf("Uses %llu Mb of %llu Mb free RAM\n", nonces_per_thread * threads * 2 * PLOT_SIZE / 1024 / 1024, freeRAM / 1024 / 1024);

Expand Down Expand Up @@ -472,7 +473,7 @@ int main(int argc, char* argv[])
leftover = nonces - nonces_done;
if (leftover / (nonces_per_thread*threads) == 0)
{
if (leftover >= threads*(bytesPerSector / SCOOP_SIZE))
if (leftover >= threads * (bytesPerSector / SCOOP_SIZE))
{
nonces_per_thread = leftover / threads;
//ajusting
Expand All @@ -488,20 +489,20 @@ int main(int argc, char* argv[])

for (size_t i = 0; i < threads; i++)
{
#ifdef __AVX2__
#ifdef __AVX2__
std::thread th(std::thread(AVX2::work_i, i, addr, startnonce + nonces_done + i * nonces_per_thread, nonces_per_thread));
#else
#ifdef __AVX__
std::thread th(std::thread(AVX1::work_i, i, addr, startnonce + nonces_done + i * nonces_per_thread, nonces_per_thread));
#else
std::thread th(std::thread(SSE4::work_i, i, addr, startnonce + nonces_done + i * nonces_per_thread, nonces_per_thread));
#endif
#endif
#else
#ifdef __AVX__
std::thread th(std::thread(AVX1::work_i, i, addr, startnonce + nonces_done + i * nonces_per_thread, nonces_per_thread));
#else
std::thread th(std::thread(SSE4::work_i, i, addr, startnonce + nonces_done + i * nonces_per_thread, nonces_per_thread));
#endif
#endif

workers.push_back(move(th));
worker_status.push_back(0);
}
nonces_in_work = threads*nonces_per_thread;
nonces_in_work = threads * nonces_per_thread;
SetConsoleTextAttribute(hConsole, colour::WHITE);
printf("\r[%llu%%] Generating nonces from %llu to %llu\t\t\t\t\t\t\n", (nonces_done * 100) / nonces, startnonce + nonces_done, startnonce + nonces_done + nonces_in_work);
SetConsoleTextAttribute(hConsole, colour::YELLOW);
Expand Down

0 comments on commit 3c8df01

Please sign in to comment.