forked from preda/gpuowl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Task.h
51 lines (38 loc) · 1.2 KB
/
Task.h
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
// gpuOwL, a GPU OpenCL Lucas-Lehmer primality checker.
// Copyright (C) 2017-2018 Mihai Preda.
#pragma once
#include "Args.h"
#include "common.h"
#include <string>
#include <cstdio>
#include <atomic>
class Args;
class Result;
class Background;
struct Task {
enum Kind {PRP, VERIFY};
Kind kind;
u32 exponent;
string AID; // Assignment ID
string line; // the verbatim worktodo line, used in deleteTask().
u32 B1 = 0;
u32 B2 = 0;
u32 bitLo = 0;
u32 wantsPm1 = 0; // An indication of how much P-1 is desired before PRP
string verifyPath; // For Verify
void adjustBounds(Args& args);
void execute(const Args& args);
void writeResultPRP(const Args&, bool isPrime, u64 res64, u32 fftSize, u32 nErrors, const fs::path& proofPath) const;
void writeResultPM1(const Args&, const std::string& factor, u32 fftSize) const;
string kindStr() const { return "PRP"; }
operator string() const {
string prefix;
char buf[256];
if (B1 || B2) {
snprintf(buf, sizeof(buf), "B1=%u,B2=%u;", B1, B2);
prefix = buf;
}
snprintf(buf, sizeof(buf), "%s=%s,1,2,%u,-1,%u,%u", kindStr().c_str(), AID.empty() ? "N/A" : AID.c_str(), exponent, bitLo, wantsPm1);
return buf;
}
};