forked from RetiredC/RCKangaroo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRCKangaroo.cpp
676 lines (605 loc) · 16.5 KB
/
RCKangaroo.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
// This file is a part of RCKangaroo software
// (c) 2024, RetiredCoder (RC)
// License: GPLv3, see "LICENSE.TXT" file
// https://github.com/RetiredC
#include <iostream>
#include <vector>
#include "cuda_runtime.h"
#include "cuda.h"
#include "defs.h"
#include "utils.h"
#include "GpuKang.h"
EcJMP EcJumps1[JMP_CNT];
EcJMP EcJumps2[JMP_CNT];
EcJMP EcJumps3[JMP_CNT];
RCGpuKang* GpuKangs[MAX_GPU_CNT];
int GpuCnt;
volatile long ThrCnt;
volatile bool gSolved;
EcInt Int_HalfRange;
EcPoint Pnt_HalfRange;
EcPoint Pnt_NegHalfRange;
EcInt Int_TameOffset;
Ec ec;
CriticalSection csAddPoints;
u8* pPntList;
u8* pPntList2;
volatile int PntIndex;
TFastBase db;
EcPoint gPntToSolve;
EcInt gPrivKey;
volatile u64 TotalOps;
u32 TotalSolved;
u32 gTotalErrors;
u64 PntTotalOps;
bool IsBench;
u32 gDP;
u32 gRange;
EcInt gStart;
bool gStartSet;
EcPoint gPubKey;
u8 gGPUs_Mask[MAX_GPU_CNT];
#pragma pack(push, 1)
struct DBRec
{
u8 x[12];
u8 d[22];
u8 type; //0 - tame, 1 - wild1, 2 - wild2
};
#pragma pack(pop)
void InitGpus()
{
GpuCnt = 0;
int gcnt = 0;
cudaGetDeviceCount(&gcnt);
if (gcnt > MAX_GPU_CNT)
gcnt = MAX_GPU_CNT;
// gcnt = 1; //dbg
if (!gcnt)
return;
int drv, rt;
cudaRuntimeGetVersion(&rt);
cudaDriverGetVersion(&drv);
char drvver[100];
sprintf(drvver, "%d.%d/%d.%d", drv / 1000, (drv % 100) / 10, rt / 1000, (rt % 100) / 10);
printf("CUDA devices: %d, CUDA driver/runtime: %s\r\n", gcnt, drvver);
cudaError_t cudaStatus;
for (int i = 0; i < gcnt; i++)
{
cudaStatus = cudaSetDevice(i);
if (cudaStatus != cudaSuccess)
{
printf("cudaSetDevice for gpu %d failed!\r\n", i);
continue;
}
if (!gGPUs_Mask[i])
continue;
cudaDeviceProp deviceProp;
cudaGetDeviceProperties(&deviceProp, i);
printf("GPU %d: %s, %.2f GB, %d CUs, cap %d.%d, PCI %d, L2 size: %d KB\r\n", i, deviceProp.name, ((float)(deviceProp.totalGlobalMem / (1024 * 1024))) / 1024.0f, deviceProp.multiProcessorCount, deviceProp.major, deviceProp.minor, deviceProp.pciBusID, deviceProp.l2CacheSize / 1024);
if (deviceProp.major < 6)
{
printf("GPU %d - not supported, skip\r\n", i);
continue;
}
cudaSetDeviceFlags(cudaDeviceScheduleBlockingSync);
GpuKangs[GpuCnt] = new RCGpuKang();
GpuKangs[GpuCnt]->CudaIndex = i;
GpuKangs[GpuCnt]->persistingL2CacheMaxSize = deviceProp.persistingL2CacheMaxSize;
GpuKangs[GpuCnt]->mpCnt = deviceProp.multiProcessorCount;
GpuKangs[GpuCnt]->IsOldGpu = deviceProp.l2CacheSize < 16 * 1024 * 1024;
GpuCnt++;
}
printf("Total GPUs for work: %d\r\n", GpuCnt);
}
#ifdef _WIN32
u32 __stdcall kang_thr_proc(void* data)
{
RCGpuKang* Kang = (RCGpuKang*)data;
Kang->Execute();
InterlockedDecrement(&ThrCnt);
return 0;
}
#else
void* kang_thr_proc(void* data)
{
RCGpuKang* Kang = (RCGpuKang*)data;
Kang->Execute();
__sync_fetch_and_sub(&ThrCnt, 1);
return 0;
}
#endif
void AddPointsToList(u32* data, int pnt_cnt, u64 ops_cnt)
{
csAddPoints.Enter();
if (PntIndex + pnt_cnt >= MAX_CNT_LIST)
{
csAddPoints.Leave();
printf("DPs buffer overflow, some points lost, increase DP value!\r\n");
return;
}
memcpy(pPntList + GPU_DP_SIZE * PntIndex, data, pnt_cnt * GPU_DP_SIZE);
PntIndex += pnt_cnt;
PntTotalOps += ops_cnt;
csAddPoints.Leave();
}
bool Collision_SOTA(EcPoint& pnt, EcInt t, int TameType, EcInt w, int WildType, bool IsNeg)
{
if (IsNeg)
t.Neg();
if (TameType == TAME)
{
gPrivKey = t;
gPrivKey.Sub(w);
EcInt sv = gPrivKey;
gPrivKey.Add(Int_HalfRange);
EcPoint P = ec.MultiplyG(gPrivKey);
if (P.IsEqual(pnt))
return true;
gPrivKey = sv;
gPrivKey.Neg();
gPrivKey.Add(Int_HalfRange);
P = ec.MultiplyG(gPrivKey);
return P.IsEqual(pnt);
}
else
{
gPrivKey = t;
gPrivKey.Sub(w);
if (gPrivKey.data[4] >> 63)
gPrivKey.Neg();
gPrivKey.ShiftRight(1);
EcInt sv = gPrivKey;
gPrivKey.Add(Int_HalfRange);
EcPoint P = ec.MultiplyG(gPrivKey);
if (P.IsEqual(pnt))
return true;
gPrivKey = sv;
gPrivKey.Neg();
gPrivKey.Add(Int_HalfRange);
P = ec.MultiplyG(gPrivKey);
return P.IsEqual(pnt);
}
}
void CheckNewPoints()
{
csAddPoints.Enter();
if (!PntIndex)
{
csAddPoints.Leave();
return;
}
int cnt = PntIndex;
memcpy(pPntList2, pPntList, GPU_DP_SIZE * cnt);
PntIndex = 0;
csAddPoints.Leave();
for (int i = 0; i < cnt; i++)
{
DBRec nrec;
u8* p = pPntList2 + i * GPU_DP_SIZE;
memcpy(nrec.x, p, 12);
memcpy(nrec.d, p + 16, 22);
nrec.type = p[40];
DBRec* pref = (DBRec*)db.FindOrAddDataBlock((u8*)&nrec);
if (pref)
{
//in db we dont store first 3 bytes so restore them
DBRec tmp_pref;
memcpy(&tmp_pref, &nrec, 3);
memcpy(((u8*)&tmp_pref) + 3, pref, sizeof(DBRec) - 3);
pref = &tmp_pref;
if (pref->type == nrec.type)
{
if (pref->type == TAME)
continue;
//if it's wild, we can find the key from the same type if distances are different
if (*(u64*)pref->d == *(u64*)nrec.d)
continue;
//else
// ToLog("key found by same wild");
}
EcInt w, t;
int TameType, WildType;
if (pref->type != TAME)
{
memcpy(w.data, pref->d, sizeof(pref->d));
if (pref->d[21] == 0xFF) memset(((u8*)w.data) + 22, 0xFF, 18);
memcpy(t.data, nrec.d, sizeof(nrec.d));
if (nrec.d[21] == 0xFF) memset(((u8*)t.data) + 22, 0xFF, 18);
TameType = nrec.type;
WildType = pref->type;
}
else
{
memcpy(w.data, nrec.d, sizeof(nrec.d));
if (nrec.d[21] == 0xFF) memset(((u8*)w.data) + 22, 0xFF, 18);
memcpy(t.data, pref->d, sizeof(pref->d));
if (pref->d[21] == 0xFF) memset(((u8*)t.data) + 22, 0xFF, 18);
TameType = TAME;
WildType = nrec.type;
}
bool res = Collision_SOTA(gPntToSolve, t, TameType, w, WildType, false) || Collision_SOTA(gPntToSolve, t, TameType, w, WildType, true);
if (!res)
{
bool w12 = ((pref->type == WILD1) && (nrec.type == WILD2)) || ((pref->type == WILD2) && (nrec.type == WILD1));
if (w12) //in rare cases WILD and WILD2 can collide in mirror, in this case there is no way to find K
;// ToLog("W1 and W2 collides in mirror");
else
{
printf("Collision Error\r\n");
gTotalErrors++;
}
continue;
}
gSolved = true;
break;
}
}
}
void ShowStats(u64 tm_start, double exp_ops, double dp_val)
{
#ifdef DEBUG_MODE
for (int i = 0; i <= MD_LEN; i++)
{
u64 val = 0;
for (int j = 0; j < GpuCnt; j++)
{
val += GpuKangs[j]->dbg[i];
}
if (val)
printf("Loop size %d: %llu\r\n", i, val);
}
#endif
int speed = GpuKangs[0]->GetStatsSpeed();
for (int i = 1; i < GpuCnt; i++)
speed += GpuKangs[i]->GetStatsSpeed();
u64 est_dps_cnt = (u64)(exp_ops / dp_val);
u64 exp_sec = 0xFFFFFFFFFFFFFFFFull;
if (speed)
exp_sec = (u64)((exp_ops / 1000000) / speed); //in sec
u64 exp_days = exp_sec / (3600 * 24);
int exp_hours = (int)(exp_sec - exp_days * (3600 * 24)) / 3600;
int exp_min = (int)(exp_sec - exp_days * (3600 * 24) - exp_hours * 3600) / 60;
u64 sec = (GetTickCount64() - tm_start) / 1000;
u64 days = sec / (3600 * 24);
int hours = (int)(sec - days * (3600 * 24)) / 3600;
int min = (int)(sec - days * (3600 * 24) - hours * 3600) / 60;
printf("%sSpeed: %d MKeys/s, Err: %d, DPs: %lluK/%lluK, Time: %llud:%02dh:%02dm, Est: %llud:%02dh:%02dm\r\n", IsBench ? "BENCH: " : "MAIN: ", speed, gTotalErrors, db.GetBlockCnt()/1000, est_dps_cnt/1000, days, hours, min, exp_days, exp_hours, exp_min);
}
bool SolvePoint(EcPoint PntToSolve, int Range, int DP, EcInt* pk_res)
{
if ((Range < 32) || (Range > 180))
{
printf("Unsupported Range value (%d)!\r\n", Range);
return false;
}
if ((DP < 14) || (DP > 60))
{
printf("Unsupported DP value (%d)!\r\n", DP);
return false;
}
printf("\r\nSolving point: Range %d bits, DP %d, start...\r\n", Range, DP);
double ops = 1.15 * pow(2.0, Range / 2);
double dp_val = (double)(1ull << DP);
double ram = (32 + 4 + 4) * ops / dp_val; //+4 for grow allocation and memory fragmentation
ram += sizeof(TListRec) * 256 * 256 * 256; //3byte-prefix table
ram /= (1024 * 1024 * 1024); //GB
printf("SOTA method, estimated ops: 2^%.3f, RAM for DPs: %.3f GB. DP and GPU overheads not included!\r\n", log2(ops), ram);
u64 total_kangs = GpuKangs[0]->CalcKangCnt();
for (int i = 1; i < GpuCnt; i++)
total_kangs += GpuKangs[i]->CalcKangCnt();
double path_single_kang = ops / total_kangs;
double DPs_per_kang = path_single_kang / dp_val;
printf("Estimated DPs per kangaroo: %.3f.%s\r\n", DPs_per_kang, (DPs_per_kang < 5) ? " DP overhead is big, use less DP value if possible!" : "");
PntTotalOps = 0;
PntIndex = 0;
//prepare jumps
EcInt minjump, t;
minjump.Set(1);
minjump.ShiftLeft(Range / 2 + 3);
for (int i = 0; i < JMP_CNT; i++)
{
EcJumps1[i].dist = minjump;
t.RndMax(minjump);
EcJumps1[i].dist.Add(t);
EcJumps1[i].dist.data[0] &= 0xFFFFFFFFFFFFFFFE; //must be even
EcJumps1[i].p = ec.MultiplyG(EcJumps1[i].dist);
}
minjump.Set(1);
minjump.ShiftLeft(Range - 10); //large jumps for L1S2 loops. Must be almost RANGE_BITS
for (int i = 0; i < JMP_CNT; i++)
{
EcJumps2[i].dist = minjump;
t.RndMax(minjump);
EcJumps2[i].dist.Add(t);
EcJumps2[i].dist.data[0] &= 0xFFFFFFFFFFFFFFFE; //must be even
EcJumps2[i].p = ec.MultiplyG(EcJumps2[i].dist);
}
minjump.Set(1);
minjump.ShiftLeft(Range - 10 - 2); //large jumps for loops >2
for (int i = 0; i < JMP_CNT; i++)
{
EcJumps3[i].dist = minjump;
t.RndMax(minjump);
EcJumps3[i].dist.Add(t);
EcJumps3[i].dist.data[0] &= 0xFFFFFFFFFFFFFFFE; //must be even
EcJumps3[i].p = ec.MultiplyG(EcJumps3[i].dist);
}
Int_HalfRange.Set(1);
Int_HalfRange.ShiftLeft(Range - 1);
Pnt_HalfRange = ec.MultiplyG(Int_HalfRange);
Pnt_NegHalfRange = Pnt_HalfRange;
Pnt_NegHalfRange.y.NegModP();
Int_TameOffset.Set(1);
Int_TameOffset.ShiftLeft(Range - 1);
EcInt tt;
tt.Set(1);
tt.ShiftLeft(Range - 5); //half of tame range width
Int_TameOffset.Sub(tt);
gPntToSolve = PntToSolve;
//prepare GPUs
for (int i = 0; i < GpuCnt; i++)
if (!GpuKangs[i]->Prepare(PntToSolve, Range, DP, EcJumps1, EcJumps2, EcJumps3))
{
GpuKangs[i]->Failed = true;
printf("GPU %d Prepare failed\r\n", GpuKangs[i]->CudaIndex);
}
u64 tm0 = GetTickCount64();
printf("GPUs started...\r\n");
#ifdef _WIN32
HANDLE thr_handles[MAX_GPU_CNT];
#else
pthread_t thr_handles[MAX_GPU_CNT];
#endif
u32 ThreadID;
gSolved = false;
ThrCnt = GpuCnt;
for (int i = 0; i < GpuCnt; i++)
{
#ifdef _WIN32
thr_handles[i] = (HANDLE)_beginthreadex(NULL, 0, kang_thr_proc, (void*)GpuKangs[i], 0, &ThreadID);
#else
pthread_create(&thr_handles[i], NULL, kang_thr_proc, (void*)GpuKangs[i]);
#endif
}
u64 tm_stats = GetTickCount64();
while (!gSolved)
{
CheckNewPoints();
Sleep(10);
if (GetTickCount64() - tm_stats > 10 * 1000)
{
ShowStats(tm0, ops, dp_val);
tm_stats = GetTickCount64();
}
}
printf("Stopping work ...\r\n");
for (int i = 0; i < GpuCnt; i++)
GpuKangs[i]->Stop();
while (ThrCnt)
Sleep(10);
for (int i = 0; i < GpuCnt; i++)
{
#ifdef _WIN32
CloseHandle(thr_handles[i]);
#else
pthread_join(thr_handles[i], NULL);
#endif
}
double K = (double)PntTotalOps / pow(2.0, Range / 2);
printf("Point solved, K: %.3f (with DP and GPU overheads)\r\n\r\n", K);
db.Clear();
*pk_res = gPrivKey;
return true;
}
bool ParseCommandLine(int argc, char* argv[])
{
int ci = 1;
while (ci < argc)
{
char* argument = argv[ci];
ci++;
if (strcmp(argument, "-gpu") == 0)
{
if (ci >= argc)
{
printf("error: missed value after -gpu option\r\n");
return false;
}
char* gpus = argv[ci];
ci++;
memset(gGPUs_Mask, 0, sizeof(gGPUs_Mask));
for (int i = 0; i < (int)strlen(gpus); i++)
{
if ((gpus[i] < '0') || (gpus[i] > '9'))
{
printf("error: invalid value for -gpu option\r\n");
return false;
}
gGPUs_Mask[gpus[i] - '0'] = 1;
}
}
else
if (strcmp(argument, "-dp") == 0)
{
int val = atoi(argv[ci]);
ci++;
if ((val < 14) || (val > 60))
{
printf("error: invalid value for -dp option\r\n");
return false;
}
gDP = val;
}
else
if (strcmp(argument, "-range") == 0)
{
int val = atoi(argv[ci]);
ci++;
if ((val < 32) || (val > 170))
{
printf("error: invalid value for -range option\r\n");
return false;
}
gRange = val;
}
else
if (strcmp(argument, "-start") == 0)
{
if (!gStart.SetHexStr(argv[ci]))
{
printf("error: invalid value for -start option\r\n");
return false;
}
ci++;
gStartSet = true;
}
else
if (strcmp(argument, "-pubkey") == 0)
{
if (!gPubKey.SetHexStr(argv[ci]))
{
printf("error: invalid value for -pubkey option\r\n");
return false;
}
ci++;
}
else
{
printf("error: unknown option %s\r\n", argument);
return false;
}
}
if (!gPubKey.x.IsZero())
if (!gStartSet || !gRange || !gDP)
{
printf("error: you must also specify -dp, -range and -start options\r\n");
return false;
}
return true;
}
int main(int argc, char* argv[])
{
#ifdef _DEBUG
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
#endif
printf("********************************************************************************\r\n");
printf("* RCKangaroo v2.0 (c) 2024 RetiredCoder *\r\n");
printf("********************************************************************************\r\n\r\n");
printf("This software is free and open-source: https://github.com/RetiredC\r\n");
printf("It demonstrates fast GPU implementation of SOTA Kangaroo method for solving ECDLP\r\n");
#ifdef _WIN32
printf("Windows version\r\n");
#else
printf("Linux version\r\n");
#endif
#ifdef DEBUG_MODE
printf("DEBUG MODE\r\n\r\n");
#endif
InitEc();
gDP = 0;
gRange = 0;
gStartSet = false;
memset(gGPUs_Mask, 1, sizeof(gGPUs_Mask));
if (!ParseCommandLine(argc, argv))
return 0;
InitGpus();
if (!GpuCnt)
{
printf("No supported GPUs detected, exit\r\n");
return 0;
}
pPntList = (u8*)malloc(MAX_CNT_LIST * GPU_DP_SIZE);
pPntList2 = (u8*)malloc(MAX_CNT_LIST * GPU_DP_SIZE);
TotalOps = 0;
TotalSolved = 0;
gTotalErrors = 0;
//SetRndSeed(0); //dbg
SetRndSeed(GetTickCount64());
IsBench = gPubKey.x.IsZero();
if (!IsBench)
{
printf("\r\nMAIN MODE\r\n\r\n");
EcPoint PntToSolve, PntOfs;
EcInt pk, pk_found;
PntToSolve = gPubKey;
if (!gStart.IsZero())
{
PntOfs = ec.MultiplyG(gStart);
PntOfs.y.NegModP();
PntToSolve = ec.AddPoints(PntToSolve, PntOfs);
}
char sx[100], sy[100];
gPubKey.x.GetHexStr(sx);
gPubKey.y.GetHexStr(sy);
printf("Solving public key\r\nX: %s\r\nY: %s\r\n", sx, sy);
gStart.GetHexStr(sx);
printf("Offset: %s\r\n", sx);
if (!SolvePoint(PntToSolve, gRange, gDP, &pk_found))
{
printf("FATAL ERROR: SolvePoint failed\r\n");
return 0;
}
pk_found.AddModP(gStart);
EcPoint tmp = ec.MultiplyG(pk_found);
if (!tmp.IsEqual(gPubKey))
{
printf("FATAL ERROR: SolvePoint found incorrect key\r\n");
return 0;
}
//happy end
char s[100];
pk_found.GetHexStr(s);
printf("\r\nPRIVATE KEY: %s\r\n\r\n", s);
FILE* fp = fopen("RESULTS.TXT", "a");
if (fp)
{
fprintf(fp, "PRIVATE KEY: %s\n", s);
fclose(fp);
}
else //we cannot save the key, show error and wait forever so the key is displayed
{
printf("WARNING: Cannot save the key to RESULTS.TXT!\r\n");
while (1)
Sleep(100);
}
}
else
{
printf("\r\nBENCHMARK MODE\r\n");
//solve points, show K
while (1)
{
EcInt pk, pk_found;
EcPoint PntToSolve;
if (!gRange)
gRange = 78;
if (!gDP)
gDP = 16;
//generate random pk
pk.RndBits(gRange);
PntToSolve = ec.MultiplyG(pk);
if (!SolvePoint(PntToSolve, gRange, gDP, &pk_found))
{
printf("FATAL ERROR: SolvePoint failed\r\n");
return 0;
}
if (!pk_found.IsEqual(pk))
{
printf("FATAL ERROR: Found key is wrong!\r\n");
return 0;
}
TotalOps += PntTotalOps;
TotalSolved++;
u64 ops_per_pnt = TotalOps / TotalSolved;
double K = (double)ops_per_pnt / pow(2.0, gRange / 2);
printf("Points solved: %d, average K: %.3f (with DP and GPU overheads)\r\n", TotalSolved, K);
//if (TotalSolved >= 100) break; //dbg
}
}
for (int i = 0; i < GpuCnt; i++)
delete GpuKangs[i];
DeInitEc();
free(pPntList2);
free(pPntList);
}