-
Notifications
You must be signed in to change notification settings - Fork 15
/
test128cpu.cu
50 lines (36 loc) · 988 Bytes
/
test128cpu.cu
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
#include <stdint.h>
#include <iostream>
#include <omp.h>
#include "cuda_uint128.h"
uint128_t calc(char * argv);
int main(int argc, char ** argv)
{
uint128_t x = (uint128_t) 1 << 120;
if(argc == 2)
x = string_to_u128((std::string)argv[1]);
#pragma omp parallel for
for(uint64_t v = 2; v < 1u << 30; v++){
uint64_t r;
uint128_t y = uint128_t::div128to128(x, v, &r);
uint128_t z = mul128(y, v) + r;
if(z != x) std::cout << z << std::endl;
}
// std::cout << _isqrt(x) << std::endl;
// std::cout << _icbrt(x) << std::endl;
// std::cout << _iqrt(x) << std::endl;
return 0;
}
uint128_t calc(char * argv) // for getting values bigger than the 32 bits that system() will return;
{
uint128_t value;
size_t len = 0;
char * line = NULL;
FILE * in;
char cmd[256];
sprintf(cmd, "calc %s | awk {'print $1'}", argv);
in = popen(cmd, "r");
getline(&line, &len, in);
std::string s = line;
value = string_to_u128(s);
return value;
}