Hi, Everyone
Test function in this main.cpp file
The file is running with CPU.
How can I run it with the GPU?
/*
* This file is part of the BSGS distribution (https://github.com/JeanLucPons/Kangaroo).
* Copyright (c) 2020 Jean Luc PONS.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#include
#include "Kangaroo.h"
#include "Timer.h"
#include "SECPK1/SECP256k1.h"
#include "GPU/GPUEngine.h"
#include
#include
#include
#include
#include
#include
using namespace std;
#define CHECKARG(opt,n) if(a>=argc-1) {::printf(opt " missing argument #%d\n",n);exit(0);} else {a++;}
int getInt(string name, char* v) {
int r;
try {
r = std::stoi(string(v));
}
catch (std::invalid_argument&) {
printf("Invalid %s argument, number expected\n", name.c_str());
exit(-1);
}
return r;
}
double getDouble(string name, char* v) {
double r;
try {
r = std::stod(string(v));
}
catch (std::invalid_argument&) {
printf("Invalid %s argument, number expected\n", name.c_str());
exit(-1);
}
return r;
}
// ------------------------------------------------------------------------------------------
void getInts(string name, vector& tokens, const string& text, char sep) {
size_t start = 0, end = 0;
tokens.clear();
int item;
try {
while ((end = text.find(sep, start)) != string::npos) {
item = std::stoi(text.substr(start, end - start));
tokens.push_back(item);
start = end + 1;
}
item = std::stoi(text.substr(start));
tokens.push_back(item);
}
catch (std::invalid_argument&) {
printf("Invalid %s argument, number expected\n", name.c_str());
exit(-1);
}
}
// ------------------------------------------------------------------------------------------
// Default params
static int dp = -1;
static int nbCPUThread;
static string configFile = "";
static bool checkFlag = false;
static bool gpuEnable = false;
static vector gpuId = { 0 };
static vector gridSize;
static string workFile = "";
static string checkWorkFile = "";
static string iWorkFile = "";
static uint32_t savePeriod = 60;
static bool saveKangaroo = false;
static bool saveKangarooByServer = false;
static string merge1 = "";
static string merge2 = "";
static string mergeDest = "";
static string mergeDir = "";
static string infoFile = "";
static double maxStep = 0.0;
static int wtimeout = 3000;
static int ntimeout = 3000;
static int port = 17403;
static bool serverMode = false;
static string serverIP = "";
static string outputFile = "";
static bool splitWorkFile = false;
//Mamu
Secp256K1 secp256k1;
int nbGPUThread;
uint64_t totalRW;
uint64_t counters[256];
int CPU_GRP_SIZE = 1024;
void TestFunc(string ScalarInput)
{
Int i;
char* c = const_cast(ScalarInput.c_str()); //*****************************************************************************************************
i.SetBase10(c);
while (true)
{
i.AddOne();
Point aa = secp256k1.ComputePublicKey(&i);
string PointaX = aa.x.GetBase10();
string PointaY = aa.y.GetBase10();
Int s(secp256k1.order);
s.Sub(&i);
Point bb = secp256k1.ComputePublicKey(&s);
string PointbX = bb.x.GetBase10();
string PointbY = bb.y.GetBase10();
string num1 = i.GetBase10();
string num2 = s.GetBase10();
string Result1 = num1 + " = " + PointaX + " : " + PointaY + "\n";
string Result2 = num2 + " = " + PointbX + " : " + PointbY + "\n";
cout << Result1 << "\n";
cout << Result2 << "\n";
}
}
void main()
{
secp256k1.Init();
cout << "Working..." << "\n";
string ScalarInput;
printf("\n\tStart Number : ");
cin >> ScalarInput;
TestFunc(ScalarInput);
}