Advertisement
jadenquinn

aceinthehole

Jan 26th, 2021
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 64.90 KB | None | 0 0
  1. Microsoft Windows [Version 10.0.19042.631]
  2. (c) 2020 Microsoft Corporation. All rights reserved.
  3.  
  4. C:\Users\Jaden>cd /downloads/JCLMiner
  5. The system cannot find the path specified.
  6.  
  7. C:\Users\Jaden>cd \Downloads\JCLMiner\bin
  8. The system cannot find the path specified.
  9.  
  10. C:\Users\Jaden>cd Downloads\JCLMiner\bin
  11.  
  12. C:\Users\Jaden\Downloads\JCLMiner\bin>JCLminer
  13. usage: JCLMiner -h [address]
  14. -h,--host <arg> The address to send rewards to.
  15. -l,--list-devices Show a list of compatible devices and their
  16. signatures.
  17. -p,--profile Profile each device to find the optimal work range.
  18. -b,--best-device Mine on whichever device is deemed 'best.' Default
  19. option.
  20. -a,--all-devices Mine on all compatible hardware devices.
  21. -d,--devices <arg> Specifies what work size to use for given device
  22. types. Run a profile with -p to get best setting.
  23. -?,--help Show usage.
  24.  
  25. C:\Users\Jaden\Downloads\JCLMiner\bin>JCLMiner -p
  26. Starting system profiler...
  27. Profiling device Intel(R) HD Graphics 6000
  28. Test #1 > 438.78 KH/s
  29. Test #2 > Exception in thread "Thread-1" com.nativelibs4java.opencl.CLException$InvalidMemObject: InvalidMemObject (kernel name = krist_miner_basic, num args = 6, arg index = 0, source = <<<
  30. // This file contains code for hashing and mining on OpenCL hardware
  31.  
  32. typedef uchar byte;
  33.  
  34. // macro so i can change it later
  35. #define mult_add(a,b,c) (a * b + c)
  36.  
  37. // right rotate macro
  38. #define RR(X, Y) rotate((uint)X, -((uint)Y))
  39.  
  40. // optimized padding macro
  41. // takes a character array and integer
  42. // character array is used as both input and output
  43. // character array should be 64 items long regardless of content
  44. // actual input present in character array should not exceed 55 items
  45. // second argument should be the length of the input content
  46. // example usage:
  47. // char data[64];
  48. // data[0] = 'h';
  49. // data[1] = 'e';
  50. // data[2] = 'l';
  51. // data[3] = 'l';
  52. // data[4] = 'o';
  53. // PAD(data, 5);
  54. // // data array now contains 'hello' padded
  55. #define PAD(X, Y) X[63] = Y * 8; X[62] = Y >> 5; X[Y] = 0x80;
  56.  
  57. // SHA256 macros
  58. #define CH(x,y,z) bitselect(z,y,x)
  59. #define MAJ(x,y,z) bitselect(x,y,z^x)
  60. #define EP0(x) (RR(x,2) ^ RR(x,13) ^ RR(x,22))
  61. #define EP1(x) (RR(x,6) ^ RR(x,11) ^ RR(x,25))
  62. #define SIG0(x) (RR(x,7) ^ RR(x,18) ^ ((x) >> 3))
  63. #define SIG1(x) (RR(x,17) ^ RR(x,19) ^ ((x) >> 10))
  64.  
  65. __constant uint K[64] = {
  66. 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
  67. 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
  68. 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
  69. 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
  70. 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
  71. 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
  72. 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
  73. 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2};
  74.  
  75. // SHA256 digest function - optimization pending
  76. // takes a byte array of size 64 with 55 or fewer items, and writes
  77. // hash to 32 item byte array.
  78. // make sure to pass the input size as the second argument.
  79. // example usage:
  80. // char data[64];
  81. // char hash[32];
  82. // data[0] = 'h';
  83. // data[1] = 'e';
  84. // data[2] = 'l';
  85. // data[3] = 'l';
  86. // data[4] = 'o';
  87. // digest(data, 5, hash);
  88. // // hash array now contains hash of 'hello'
  89.  
  90. void digest(byte* data, uint inputLen, byte* hash) {
  91. /* init vars */
  92. uint h0, h1, h2, h3, h4, h5, h6, h7;
  93. uint a, b, c, d, e, f, g, h, i, j, l, t1, t2, m[64] = {0};
  94. PAD(data, inputLen);
  95. /* init hash state */
  96. h0 = 0x6a09e667;
  97. h1 = 0xbb67ae85;
  98. h2 = 0x3c6ef372;
  99. h3 = 0xa54ff53a;
  100. h4 = 0x510e527f;
  101. h5 = 0x9b05688c;
  102. h6 = 0x1f83d9ab;
  103. h7 = 0x5be0cd19;
  104. /* transform */
  105. #pragma unroll
  106. for (i = 0; i < 16; i++)
  107. m[i] = (data[mult_add(i,4,0)] << 24) | (data[mult_add(i,4,1)] << 16) | (data[mult_add(i,4,2)] << 8) | (data[mult_add(i,4,3)]);
  108. #pragma unroll
  109. for (i = 16; i < 64; ++i)
  110. m[i] = SIG1(m[i - 2]) + m[i - 7] + SIG0(m[i - 15]) + m[i - 16];
  111. a = h0;
  112. b = h1;
  113. c = h2;
  114. d = h3;
  115. e = h4;
  116. f = h5;
  117. g = h6;
  118. h = h7;
  119. #pragma unroll
  120. for (i = 0; i < 64; ++i) {
  121. t1 = h + EP1(e) + CH(e,f,g) + K[i] + m[i];
  122. t2 = EP0(a) + MAJ(a,b,c);
  123. h = g;
  124. g = f;
  125. f = e;
  126. e = d + t1;
  127. d = c;
  128. c = b;
  129. b = a;
  130. a = t1 + t2;
  131. }
  132. h0 += a;
  133. h1 += b;
  134. // only first 2 hash values needed.
  135. h2 += c;
  136. h3 += d;
  137. h4 += e;
  138. h5 += f;
  139. h6 += g;
  140. h7 += h;
  141. /* finish */
  142. #pragma unroll
  143. for (i = 0; i < 4; ++i) {
  144. l = mult_add(i, -8, 24);
  145. hash[i] = (h0 >> l) & 0x000000ff;
  146. hash[i + 4] = (h1 >> l) & 0x000000ff;
  147. // only the first 6 bytes are needed.
  148. hash[i + 8] = (h2 >> l) & 0x000000ff;
  149. hash[i + 12] = (h3 >> l) & 0x000000ff;
  150. hash[i + 16] = (h4 >> l) & 0x000000ff;
  151. hash[i + 20] = (h5 >> l) & 0x000000ff;
  152. hash[i + 24] = (h6 >> l) & 0x000000ff;
  153. hash[i + 28] = (h7 >> l) & 0x000000ff;
  154. }
  155. }
  156. long hashToLong(byte* hash) {
  157. return hash[5] + (hash[4] << 8) + (hash[3] << 16) + ((long)hash[2] << 24) + ((long) hash[1] << 32) + ((long) hash[0] << 40);
  158. }
  159.  
  160. // converts one long into 12 hex characters
  161. void longToHex(long in, byte* hex, int offset) {
  162. #pragma unroll
  163. for (int i = offset; i < 34; i++) {
  164. hex[i] = (in >> ((i - offset) * 5) & 31) + 48;
  165. }
  166. }
  167.  
  168. __kernel void krist_miner_basic(
  169. __global const byte* address, // 10 chars
  170. __global const byte* block, // 12 chars
  171. __global const byte* prefix, // 2 chars
  172. const long base, // convert to 10 chars
  173. const long work,
  174. __global byte* output) {
  175. int id = get_global_id(0);
  176. long nonce = id + base;
  177. byte input[64];
  178. byte hashed[32];
  179. #pragma unroll
  180. for (int i = 0; i < 10; i++) {
  181. input[i] = address[i];
  182. }
  183. #pragma unroll
  184. for (int i = 10; i < 22; i++) {
  185. input[i] = block[i - 10];
  186. }
  187. #pragma unroll
  188. for (int i = 22; i < 24; i++) {
  189. input[i] = prefix[i-22];
  190. }
  191. #pragma unroll
  192. for (int i = 24; i < 34; i++) {
  193. input[i] = ((nonce >> ((i - 24) * 5)) & 31) + 48;
  194. }
  195. digest(input, 34, hashed);
  196. long score = hashToLong(hashed);
  197. if (score < work) {
  198. #pragma unroll
  199. for (int i = 0; i < 10; i++) {
  200. output[i] = address[i];
  201. }
  202. #pragma unroll
  203. for (int i = 10; i < 22; i++) {
  204. output[i] = block[i - 10];
  205. }
  206. #pragma unroll
  207. for (int i = 22; i < 24; i++) {
  208. output[i] = prefix[i-22];
  209. }
  210. #pragma unroll
  211. for (int i = 24; i < 34; i++) {
  212. output[i] = ((nonce >> ((i - 24) * 5)) & 31) + 48;
  213. }
  214. }
  215. }
  216.  
  217. >>> ) (make sure to log all errors with environment variable CL_LOG_ERRORS=stdout)
  218. at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  219. at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
  220. at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
  221. at java.lang.reflect.Constructor.newInstance(Unknown Source)
  222. at java.lang.Class.newInstance(Unknown Source)
  223. at com.nativelibs4java.opencl.CLException.error(CLException.java:302)
  224. at com.nativelibs4java.opencl.CLKernel.setKernelArg(CLKernel.java:273)
  225. at com.nativelibs4java.opencl.CLKernel.setArg(CLKernel.java:406)
  226. at com.nativelibs4java.opencl.CLKernel.setObjectArg(CLKernel.java:201)
  227. at com.nativelibs4java.opencl.CLKernel.setArgs(CLKernel.java:191)
  228. at me.apemanzilla.jclminer.miners.GPUMiner.run(GPUMiner.java:142)
  229. at java.lang.Thread.run(Unknown Source)
  230. 578.87 KH/s
  231. Test #3 > 1.19 MH/s
  232. Test #4 > 2.04 MH/s
  233. Test #5 > Exception in thread "Thread-4" com.nativelibs4java.opencl.CLException$InvalidMemObject: InvalidMemObject (kernel name = krist_miner_basic, num args = 6, arg index = 2, source = <<<
  234. // This file contains code for hashing and mining on OpenCL hardware
  235.  
  236. typedef uchar byte;
  237.  
  238. // macro so i can change it later
  239. #define mult_add(a,b,c) (a * b + c)
  240.  
  241. // right rotate macro
  242. #define RR(X, Y) rotate((uint)X, -((uint)Y))
  243.  
  244. // optimized padding macro
  245. // takes a character array and integer
  246. // character array is used as both input and output
  247. // character array should be 64 items long regardless of content
  248. // actual input present in character array should not exceed 55 items
  249. // second argument should be the length of the input content
  250. // example usage:
  251. // char data[64];
  252. // data[0] = 'h';
  253. // data[1] = 'e';
  254. // data[2] = 'l';
  255. // data[3] = 'l';
  256. // data[4] = 'o';
  257. // PAD(data, 5);
  258. // // data array now contains 'hello' padded
  259. #define PAD(X, Y) X[63] = Y * 8; X[62] = Y >> 5; X[Y] = 0x80;
  260.  
  261. // SHA256 macros
  262. #define CH(x,y,z) bitselect(z,y,x)
  263. #define MAJ(x,y,z) bitselect(x,y,z^x)
  264. #define EP0(x) (RR(x,2) ^ RR(x,13) ^ RR(x,22))
  265. #define EP1(x) (RR(x,6) ^ RR(x,11) ^ RR(x,25))
  266. #define SIG0(x) (RR(x,7) ^ RR(x,18) ^ ((x) >> 3))
  267. #define SIG1(x) (RR(x,17) ^ RR(x,19) ^ ((x) >> 10))
  268.  
  269. __constant uint K[64] = {
  270. 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
  271. 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
  272. 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
  273. 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
  274. 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
  275. 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
  276. 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
  277. 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2};
  278.  
  279. // SHA256 digest function - optimization pending
  280. // takes a byte array of size 64 with 55 or fewer items, and writes
  281. // hash to 32 item byte array.
  282. // make sure to pass the input size as the second argument.
  283. // example usage:
  284. // char data[64];
  285. // char hash[32];
  286. // data[0] = 'h';
  287. // data[1] = 'e';
  288. // data[2] = 'l';
  289. // data[3] = 'l';
  290. // data[4] = 'o';
  291. // digest(data, 5, hash);
  292. // // hash array now contains hash of 'hello'
  293.  
  294. void digest(byte* data, uint inputLen, byte* hash) {
  295. /* init vars */
  296. uint h0, h1, h2, h3, h4, h5, h6, h7;
  297. uint a, b, c, d, e, f, g, h, i, j, l, t1, t2, m[64] = {0};
  298. PAD(data, inputLen);
  299. /* init hash state */
  300. h0 = 0x6a09e667;
  301. h1 = 0xbb67ae85;
  302. h2 = 0x3c6ef372;
  303. h3 = 0xa54ff53a;
  304. h4 = 0x510e527f;
  305. h5 = 0x9b05688c;
  306. h6 = 0x1f83d9ab;
  307. h7 = 0x5be0cd19;
  308. /* transform */
  309. #pragma unroll
  310. for (i = 0; i < 16; i++)
  311. m[i] = (data[mult_add(i,4,0)] << 24) | (data[mult_add(i,4,1)] << 16) | (data[mult_add(i,4,2)] << 8) | (data[mult_add(i,4,3)]);
  312. #pragma unroll
  313. for (i = 16; i < 64; ++i)
  314. m[i] = SIG1(m[i - 2]) + m[i - 7] + SIG0(m[i - 15]) + m[i - 16];
  315. a = h0;
  316. b = h1;
  317. c = h2;
  318. d = h3;
  319. e = h4;
  320. f = h5;
  321. g = h6;
  322. h = h7;
  323. #pragma unroll
  324. for (i = 0; i < 64; ++i) {
  325. t1 = h + EP1(e) + CH(e,f,g) + K[i] + m[i];
  326. t2 = EP0(a) + MAJ(a,b,c);
  327. h = g;
  328. g = f;
  329. f = e;
  330. e = d + t1;
  331. d = c;
  332. c = b;
  333. b = a;
  334. a = t1 + t2;
  335. }
  336. h0 += a;
  337. h1 += b;
  338. // only first 2 hash values needed.
  339. h2 += c;
  340. h3 += d;
  341. h4 += e;
  342. h5 += f;
  343. h6 += g;
  344. h7 += h;
  345. /* finish */
  346. #pragma unroll
  347. for (i = 0; i < 4; ++i) {
  348. l = mult_add(i, -8, 24);
  349. hash[i] = (h0 >> l) & 0x000000ff;
  350. hash[i + 4] = (h1 >> l) & 0x000000ff;
  351. // only the first 6 bytes are needed.
  352. hash[i + 8] = (h2 >> l) & 0x000000ff;
  353. hash[i + 12] = (h3 >> l) & 0x000000ff;
  354. hash[i + 16] = (h4 >> l) & 0x000000ff;
  355. hash[i + 20] = (h5 >> l) & 0x000000ff;
  356. hash[i + 24] = (h6 >> l) & 0x000000ff;
  357. hash[i + 28] = (h7 >> l) & 0x000000ff;
  358. }
  359. }
  360. long hashToLong(byte* hash) {
  361. return hash[5] + (hash[4] << 8) + (hash[3] << 16) + ((long)hash[2] << 24) + ((long) hash[1] << 32) + ((long) hash[0] << 40);
  362. }
  363.  
  364. // converts one long into 12 hex characters
  365. void longToHex(long in, byte* hex, int offset) {
  366. #pragma unroll
  367. for (int i = offset; i < 34; i++) {
  368. hex[i] = (in >> ((i - offset) * 5) & 31) + 48;
  369. }
  370. }
  371.  
  372. __kernel void krist_miner_basic(
  373. __global const byte* address, // 10 chars
  374. __global const byte* block, // 12 chars
  375. __global const byte* prefix, // 2 chars
  376. const long base, // convert to 10 chars
  377. const long work,
  378. __global byte* output) {
  379. int id = get_global_id(0);
  380. long nonce = id + base;
  381. byte input[64];
  382. byte hashed[32];
  383. #pragma unroll
  384. for (int i = 0; i < 10; i++) {
  385. input[i] = address[i];
  386. }
  387. #pragma unroll
  388. for (int i = 10; i < 22; i++) {
  389. input[i] = block[i - 10];
  390. }
  391. #pragma unroll
  392. for (int i = 22; i < 24; i++) {
  393. input[i] = prefix[i-22];
  394. }
  395. #pragma unroll
  396. for (int i = 24; i < 34; i++) {
  397. input[i] = ((nonce >> ((i - 24) * 5)) & 31) + 48;
  398. }
  399. digest(input, 34, hashed);
  400. long score = hashToLong(hashed);
  401. if (score < work) {
  402. #pragma unroll
  403. for (int i = 0; i < 10; i++) {
  404. output[i] = address[i];
  405. }
  406. #pragma unroll
  407. for (int i = 10; i < 22; i++) {
  408. output[i] = block[i - 10];
  409. }
  410. #pragma unroll
  411. for (int i = 22; i < 24; i++) {
  412. output[i] = prefix[i-22];
  413. }
  414. #pragma unroll
  415. for (int i = 24; i < 34; i++) {
  416. output[i] = ((nonce >> ((i - 24) * 5)) & 31) + 48;
  417. }
  418. }
  419. }
  420.  
  421. >>> ) (make sure to log all errors with environment variable CL_LOG_ERRORS=stdout)
  422. at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  423. at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
  424. at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
  425. at java.lang.reflect.Constructor.newInstance(Unknown Source)
  426. at java.lang.Class.newInstance(Unknown Source)
  427. at com.nativelibs4java.opencl.CLException.error(CLException.java:302)
  428. at com.nativelibs4java.opencl.CLKernel.setKernelArg(CLKernel.java:273)
  429. at com.nativelibs4java.opencl.CLKernel.setArg(CLKernel.java:406)
  430. at com.nativelibs4java.opencl.CLKernel.setObjectArg(CLKernel.java:201)
  431. at com.nativelibs4java.opencl.CLKernel.setArgs(CLKernel.java:191)
  432. at me.apemanzilla.jclminer.miners.GPUMiner.run(GPUMiner.java:142)
  433. at java.lang.Thread.run(Unknown Source)
  434. 3.74 MH/s
  435. Test #6 > 5.93 MH/s
  436. Test #7 > Exception in thread "Thread-6" com.nativelibs4java.opencl.CLException$InvalidMemObject: InvalidMemObject (kernel name = krist_miner_basic, num args = 6, arg index = 2, source = <<<
  437. // This file contains code for hashing and mining on OpenCL hardware
  438.  
  439. typedef uchar byte;
  440.  
  441. // macro so i can change it later
  442. #define mult_add(a,b,c) (a * b + c)
  443.  
  444. // right rotate macro
  445. #define RR(X, Y) rotate((uint)X, -((uint)Y))
  446.  
  447. // optimized padding macro
  448. // takes a character array and integer
  449. // character array is used as both input and output
  450. // character array should be 64 items long regardless of content
  451. // actual input present in character array should not exceed 55 items
  452. // second argument should be the length of the input content
  453. // example usage:
  454. // char data[64];
  455. // data[0] = 'h';
  456. // data[1] = 'e';
  457. // data[2] = 'l';
  458. // data[3] = 'l';
  459. // data[4] = 'o';
  460. // PAD(data, 5);
  461. // // data array now contains 'hello' padded
  462. #define PAD(X, Y) X[63] = Y * 8; X[62] = Y >> 5; X[Y] = 0x80;
  463.  
  464. // SHA256 macros
  465. #define CH(x,y,z) bitselect(z,y,x)
  466. #define MAJ(x,y,z) bitselect(x,y,z^x)
  467. #define EP0(x) (RR(x,2) ^ RR(x,13) ^ RR(x,22))
  468. #define EP1(x) (RR(x,6) ^ RR(x,11) ^ RR(x,25))
  469. #define SIG0(x) (RR(x,7) ^ RR(x,18) ^ ((x) >> 3))
  470. #define SIG1(x) (RR(x,17) ^ RR(x,19) ^ ((x) >> 10))
  471.  
  472. __constant uint K[64] = {
  473. 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
  474. 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
  475. 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
  476. 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
  477. 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
  478. 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
  479. 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
  480. 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2};
  481.  
  482. // SHA256 digest function - optimization pending
  483. // takes a byte array of size 64 with 55 or fewer items, and writes
  484. // hash to 32 item byte array.
  485. // make sure to pass the input size as the second argument.
  486. // example usage:
  487. // char data[64];
  488. // char hash[32];
  489. // data[0] = 'h';
  490. // data[1] = 'e';
  491. // data[2] = 'l';
  492. // data[3] = 'l';
  493. // data[4] = 'o';
  494. // digest(data, 5, hash);
  495. // // hash array now contains hash of 'hello'
  496.  
  497. void digest(byte* data, uint inputLen, byte* hash) {
  498. /* init vars */
  499. uint h0, h1, h2, h3, h4, h5, h6, h7;
  500. uint a, b, c, d, e, f, g, h, i, j, l, t1, t2, m[64] = {0};
  501. PAD(data, inputLen);
  502. /* init hash state */
  503. h0 = 0x6a09e667;
  504. h1 = 0xbb67ae85;
  505. h2 = 0x3c6ef372;
  506. h3 = 0xa54ff53a;
  507. h4 = 0x510e527f;
  508. h5 = 0x9b05688c;
  509. h6 = 0x1f83d9ab;
  510. h7 = 0x5be0cd19;
  511. /* transform */
  512. #pragma unroll
  513. for (i = 0; i < 16; i++)
  514. m[i] = (data[mult_add(i,4,0)] << 24) | (data[mult_add(i,4,1)] << 16) | (data[mult_add(i,4,2)] << 8) | (data[mult_add(i,4,3)]);
  515. #pragma unroll
  516. for (i = 16; i < 64; ++i)
  517. m[i] = SIG1(m[i - 2]) + m[i - 7] + SIG0(m[i - 15]) + m[i - 16];
  518. a = h0;
  519. b = h1;
  520. c = h2;
  521. d = h3;
  522. e = h4;
  523. f = h5;
  524. g = h6;
  525. h = h7;
  526. #pragma unroll
  527. for (i = 0; i < 64; ++i) {
  528. t1 = h + EP1(e) + CH(e,f,g) + K[i] + m[i];
  529. t2 = EP0(a) + MAJ(a,b,c);
  530. h = g;
  531. g = f;
  532. f = e;
  533. e = d + t1;
  534. d = c;
  535. c = b;
  536. b = a;
  537. a = t1 + t2;
  538. }
  539. h0 += a;
  540. h1 += b;
  541. // only first 2 hash values needed.
  542. h2 += c;
  543. h3 += d;
  544. h4 += e;
  545. h5 += f;
  546. h6 += g;
  547. h7 += h;
  548. /* finish */
  549. #pragma unroll
  550. for (i = 0; i < 4; ++i) {
  551. l = mult_add(i, -8, 24);
  552. hash[i] = (h0 >> l) & 0x000000ff;
  553. hash[i + 4] = (h1 >> l) & 0x000000ff;
  554. // only the first 6 bytes are needed.
  555. hash[i + 8] = (h2 >> l) & 0x000000ff;
  556. hash[i + 12] = (h3 >> l) & 0x000000ff;
  557. hash[i + 16] = (h4 >> l) & 0x000000ff;
  558. hash[i + 20] = (h5 >> l) & 0x000000ff;
  559. hash[i + 24] = (h6 >> l) & 0x000000ff;
  560. hash[i + 28] = (h7 >> l) & 0x000000ff;
  561. }
  562. }
  563. long hashToLong(byte* hash) {
  564. return hash[5] + (hash[4] << 8) + (hash[3] << 16) + ((long)hash[2] << 24) + ((long) hash[1] << 32) + ((long) hash[0] << 40);
  565. }
  566.  
  567. // converts one long into 12 hex characters
  568. void longToHex(long in, byte* hex, int offset) {
  569. #pragma unroll
  570. for (int i = offset; i < 34; i++) {
  571. hex[i] = (in >> ((i - offset) * 5) & 31) + 48;
  572. }
  573. }
  574.  
  575. __kernel void krist_miner_basic(
  576. __global const byte* address, // 10 chars
  577. __global const byte* block, // 12 chars
  578. __global const byte* prefix, // 2 chars
  579. const long base, // convert to 10 chars
  580. const long work,
  581. __global byte* output) {
  582. int id = get_global_id(0);
  583. long nonce = id + base;
  584. byte input[64];
  585. byte hashed[32];
  586. #pragma unroll
  587. for (int i = 0; i < 10; i++) {
  588. input[i] = address[i];
  589. }
  590. #pragma unroll
  591. for (int i = 10; i < 22; i++) {
  592. input[i] = block[i - 10];
  593. }
  594. #pragma unroll
  595. for (int i = 22; i < 24; i++) {
  596. input[i] = prefix[i-22];
  597. }
  598. #pragma unroll
  599. for (int i = 24; i < 34; i++) {
  600. input[i] = ((nonce >> ((i - 24) * 5)) & 31) + 48;
  601. }
  602. digest(input, 34, hashed);
  603. long score = hashToLong(hashed);
  604. if (score < work) {
  605. #pragma unroll
  606. for (int i = 0; i < 10; i++) {
  607. output[i] = address[i];
  608. }
  609. #pragma unroll
  610. for (int i = 10; i < 22; i++) {
  611. output[i] = block[i - 10];
  612. }
  613. #pragma unroll
  614. for (int i = 22; i < 24; i++) {
  615. output[i] = prefix[i-22];
  616. }
  617. #pragma unroll
  618. for (int i = 24; i < 34; i++) {
  619. output[i] = ((nonce >> ((i - 24) * 5)) & 31) + 48;
  620. }
  621. }
  622. }
  623.  
  624. >>> ) (make sure to log all errors with environment variable CL_LOG_ERRORS=stdout)
  625. at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  626. at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
  627. at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
  628. at java.lang.reflect.Constructor.newInstance(Unknown Source)
  629. at java.lang.Class.newInstance(Unknown Source)
  630. at com.nativelibs4java.opencl.CLException.error(CLException.java:302)
  631. at com.nativelibs4java.opencl.CLKernel.setKernelArg(CLKernel.java:273)
  632. at com.nativelibs4java.opencl.CLKernel.setArg(CLKernel.java:406)
  633. at com.nativelibs4java.opencl.CLKernel.setObjectArg(CLKernel.java:201)
  634. at com.nativelibs4java.opencl.CLKernel.setArgs(CLKernel.java:191)
  635. at me.apemanzilla.jclminer.miners.GPUMiner.run(GPUMiner.java:142)
  636. at java.lang.Thread.run(Unknown Source)
  637. 8.50 MH/s
  638. Test #8 > 10.69 MH/s
  639. Test #9 > Exception in thread "Thread-9" com.nativelibs4java.opencl.CLException$InvalidMemObject: InvalidMemObject (kernel name = krist_miner_basic, num args = 6, arg index = 2, source = <<<
  640. // This file contains code for hashing and mining on OpenCL hardware
  641.  
  642. typedef uchar byte;
  643.  
  644. // macro so i can change it later
  645. #define mult_add(a,b,c) (a * b + c)
  646.  
  647. // right rotate macro
  648. #define RR(X, Y) rotate((uint)X, -((uint)Y))
  649.  
  650. // optimized padding macro
  651. // takes a character array and integer
  652. // character array is used as both input and output
  653. // character array should be 64 items long regardless of content
  654. // actual input present in character array should not exceed 55 items
  655. // second argument should be the length of the input content
  656. // example usage:
  657. // char data[64];
  658. // data[0] = 'h';
  659. // data[1] = 'e';
  660. // data[2] = 'l';
  661. // data[3] = 'l';
  662. // data[4] = 'o';
  663. // PAD(data, 5);
  664. // // data array now contains 'hello' padded
  665. #define PAD(X, Y) X[63] = Y * 8; X[62] = Y >> 5; X[Y] = 0x80;
  666.  
  667. // SHA256 macros
  668. #define CH(x,y,z) bitselect(z,y,x)
  669. #define MAJ(x,y,z) bitselect(x,y,z^x)
  670. #define EP0(x) (RR(x,2) ^ RR(x,13) ^ RR(x,22))
  671. #define EP1(x) (RR(x,6) ^ RR(x,11) ^ RR(x,25))
  672. #define SIG0(x) (RR(x,7) ^ RR(x,18) ^ ((x) >> 3))
  673. #define SIG1(x) (RR(x,17) ^ RR(x,19) ^ ((x) >> 10))
  674.  
  675. __constant uint K[64] = {
  676. 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
  677. 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
  678. 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
  679. 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
  680. 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
  681. 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
  682. 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
  683. 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2};
  684.  
  685. // SHA256 digest function - optimization pending
  686. // takes a byte array of size 64 with 55 or fewer items, and writes
  687. // hash to 32 item byte array.
  688. // make sure to pass the input size as the second argument.
  689. // example usage:
  690. // char data[64];
  691. // char hash[32];
  692. // data[0] = 'h';
  693. // data[1] = 'e';
  694. // data[2] = 'l';
  695. // data[3] = 'l';
  696. // data[4] = 'o';
  697. // digest(data, 5, hash);
  698. // // hash array now contains hash of 'hello'
  699.  
  700. void digest(byte* data, uint inputLen, byte* hash) {
  701. /* init vars */
  702. uint h0, h1, h2, h3, h4, h5, h6, h7;
  703. uint a, b, c, d, e, f, g, h, i, j, l, t1, t2, m[64] = {0};
  704. PAD(data, inputLen);
  705. /* init hash state */
  706. h0 = 0x6a09e667;
  707. h1 = 0xbb67ae85;
  708. h2 = 0x3c6ef372;
  709. h3 = 0xa54ff53a;
  710. h4 = 0x510e527f;
  711. h5 = 0x9b05688c;
  712. h6 = 0x1f83d9ab;
  713. h7 = 0x5be0cd19;
  714. /* transform */
  715. #pragma unroll
  716. for (i = 0; i < 16; i++)
  717. m[i] = (data[mult_add(i,4,0)] << 24) | (data[mult_add(i,4,1)] << 16) | (data[mult_add(i,4,2)] << 8) | (data[mult_add(i,4,3)]);
  718. #pragma unroll
  719. for (i = 16; i < 64; ++i)
  720. m[i] = SIG1(m[i - 2]) + m[i - 7] + SIG0(m[i - 15]) + m[i - 16];
  721. a = h0;
  722. b = h1;
  723. c = h2;
  724. d = h3;
  725. e = h4;
  726. f = h5;
  727. g = h6;
  728. h = h7;
  729. #pragma unroll
  730. for (i = 0; i < 64; ++i) {
  731. t1 = h + EP1(e) + CH(e,f,g) + K[i] + m[i];
  732. t2 = EP0(a) + MAJ(a,b,c);
  733. h = g;
  734. g = f;
  735. f = e;
  736. e = d + t1;
  737. d = c;
  738. c = b;
  739. b = a;
  740. a = t1 + t2;
  741. }
  742. h0 += a;
  743. h1 += b;
  744. // only first 2 hash values needed.
  745. h2 += c;
  746. h3 += d;
  747. h4 += e;
  748. h5 += f;
  749. h6 += g;
  750. h7 += h;
  751. /* finish */
  752. #pragma unroll
  753. for (i = 0; i < 4; ++i) {
  754. l = mult_add(i, -8, 24);
  755. hash[i] = (h0 >> l) & 0x000000ff;
  756. hash[i + 4] = (h1 >> l) & 0x000000ff;
  757. // only the first 6 bytes are needed.
  758. hash[i + 8] = (h2 >> l) & 0x000000ff;
  759. hash[i + 12] = (h3 >> l) & 0x000000ff;
  760. hash[i + 16] = (h4 >> l) & 0x000000ff;
  761. hash[i + 20] = (h5 >> l) & 0x000000ff;
  762. hash[i + 24] = (h6 >> l) & 0x000000ff;
  763. hash[i + 28] = (h7 >> l) & 0x000000ff;
  764. }
  765. }
  766. long hashToLong(byte* hash) {
  767. return hash[5] + (hash[4] << 8) + (hash[3] << 16) + ((long)hash[2] << 24) + ((long) hash[1] << 32) + ((long) hash[0] << 40);
  768. }
  769.  
  770. // converts one long into 12 hex characters
  771. void longToHex(long in, byte* hex, int offset) {
  772. #pragma unroll
  773. for (int i = offset; i < 34; i++) {
  774. hex[i] = (in >> ((i - offset) * 5) & 31) + 48;
  775. }
  776. }
  777.  
  778. __kernel void krist_miner_basic(
  779. __global const byte* address, // 10 chars
  780. __global const byte* block, // 12 chars
  781. __global const byte* prefix, // 2 chars
  782. const long base, // convert to 10 chars
  783. const long work,
  784. __global byte* output) {
  785. int id = get_global_id(0);
  786. long nonce = id + base;
  787. byte input[64];
  788. byte hashed[32];
  789. #pragma unroll
  790. for (int i = 0; i < 10; i++) {
  791. input[i] = address[i];
  792. }
  793. #pragma unroll
  794. for (int i = 10; i < 22; i++) {
  795. input[i] = block[i - 10];
  796. }
  797. #pragma unroll
  798. for (int i = 22; i < 24; i++) {
  799. input[i] = prefix[i-22];
  800. }
  801. #pragma unroll
  802. for (int i = 24; i < 34; i++) {
  803. input[i] = ((nonce >> ((i - 24) * 5)) & 31) + 48;
  804. }
  805. digest(input, 34, hashed);
  806. long score = hashToLong(hashed);
  807. if (score < work) {
  808. #pragma unroll
  809. for (int i = 0; i < 10; i++) {
  810. output[i] = address[i];
  811. }
  812. #pragma unroll
  813. for (int i = 10; i < 22; i++) {
  814. output[i] = block[i - 10];
  815. }
  816. #pragma unroll
  817. for (int i = 22; i < 24; i++) {
  818. output[i] = prefix[i-22];
  819. }
  820. #pragma unroll
  821. for (int i = 24; i < 34; i++) {
  822. output[i] = ((nonce >> ((i - 24) * 5)) & 31) + 48;
  823. }
  824. }
  825. }
  826.  
  827. >>> ) (make sure to log all errors with environment variable CL_LOG_ERRORS=stdout)
  828. at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  829. at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
  830. at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
  831. at java.lang.reflect.Constructor.newInstance(Unknown Source)
  832. at java.lang.Class.newInstance(Unknown Source)
  833. at com.nativelibs4java.opencl.CLException.error(CLException.java:302)
  834. at com.nativelibs4java.opencl.CLKernel.setKernelArg(CLKernel.java:273)
  835. at com.nativelibs4java.opencl.CLKernel.setArg(CLKernel.java:406)
  836. at com.nativelibs4java.opencl.CLKernel.setObjectArg(CLKernel.java:201)
  837. at com.nativelibs4java.opencl.CLKernel.setArgs(CLKernel.java:191)
  838. at me.apemanzilla.jclminer.miners.GPUMiner.run(GPUMiner.java:142)
  839. at java.lang.Thread.run(Unknown Source)
  840. 10.74 MH/s
  841. Test #10 > Exception in thread "Thread-10" com.nativelibs4java.opencl.CLException$InvalidMemObject: InvalidMemObject (kernel name = krist_miner_basic, num args = 6, arg index = 2, source = <<<
  842. // This file contains code for hashing and mining on OpenCL hardware
  843.  
  844. typedef uchar byte;
  845.  
  846. // macro so i can change it later
  847. #define mult_add(a,b,c) (a * b + c)
  848.  
  849. // right rotate macro
  850. #define RR(X, Y) rotate((uint)X, -((uint)Y))
  851.  
  852. // optimized padding macro
  853. // takes a character array and integer
  854. // character array is used as both input and output
  855. // character array should be 64 items long regardless of content
  856. // actual input present in character array should not exceed 55 items
  857. // second argument should be the length of the input content
  858. // example usage:
  859. // char data[64];
  860. // data[0] = 'h';
  861. // data[1] = 'e';
  862. // data[2] = 'l';
  863. // data[3] = 'l';
  864. // data[4] = 'o';
  865. // PAD(data, 5);
  866. // // data array now contains 'hello' padded
  867. #define PAD(X, Y) X[63] = Y * 8; X[62] = Y >> 5; X[Y] = 0x80;
  868.  
  869. // SHA256 macros
  870. #define CH(x,y,z) bitselect(z,y,x)
  871. #define MAJ(x,y,z) bitselect(x,y,z^x)
  872. #define EP0(x) (RR(x,2) ^ RR(x,13) ^ RR(x,22))
  873. #define EP1(x) (RR(x,6) ^ RR(x,11) ^ RR(x,25))
  874. #define SIG0(x) (RR(x,7) ^ RR(x,18) ^ ((x) >> 3))
  875. #define SIG1(x) (RR(x,17) ^ RR(x,19) ^ ((x) >> 10))
  876.  
  877. __constant uint K[64] = {
  878. 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
  879. 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
  880. 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
  881. 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
  882. 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
  883. 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
  884. 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
  885. 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2};
  886.  
  887. // SHA256 digest function - optimization pending
  888. // takes a byte array of size 64 with 55 or fewer items, and writes
  889. // hash to 32 item byte array.
  890. // make sure to pass the input size as the second argument.
  891. // example usage:
  892. // char data[64];
  893. // char hash[32];
  894. // data[0] = 'h';
  895. // data[1] = 'e';
  896. // data[2] = 'l';
  897. // data[3] = 'l';
  898. // data[4] = 'o';
  899. // digest(data, 5, hash);
  900. // // hash array now contains hash of 'hello'
  901.  
  902. void digest(byte* data, uint inputLen, byte* hash) {
  903. /* init vars */
  904. uint h0, h1, h2, h3, h4, h5, h6, h7;
  905. uint a, b, c, d, e, f, g, h, i, j, l, t1, t2, m[64] = {0};
  906. PAD(data, inputLen);
  907. /* init hash state */
  908. h0 = 0x6a09e667;
  909. h1 = 0xbb67ae85;
  910. h2 = 0x3c6ef372;
  911. h3 = 0xa54ff53a;
  912. h4 = 0x510e527f;
  913. h5 = 0x9b05688c;
  914. h6 = 0x1f83d9ab;
  915. h7 = 0x5be0cd19;
  916. /* transform */
  917. #pragma unroll
  918. for (i = 0; i < 16; i++)
  919. m[i] = (data[mult_add(i,4,0)] << 24) | (data[mult_add(i,4,1)] << 16) | (data[mult_add(i,4,2)] << 8) | (data[mult_add(i,4,3)]);
  920. #pragma unroll
  921. for (i = 16; i < 64; ++i)
  922. m[i] = SIG1(m[i - 2]) + m[i - 7] + SIG0(m[i - 15]) + m[i - 16];
  923. a = h0;
  924. b = h1;
  925. c = h2;
  926. d = h3;
  927. e = h4;
  928. f = h5;
  929. g = h6;
  930. h = h7;
  931. #pragma unroll
  932. for (i = 0; i < 64; ++i) {
  933. t1 = h + EP1(e) + CH(e,f,g) + K[i] + m[i];
  934. t2 = EP0(a) + MAJ(a,b,c);
  935. h = g;
  936. g = f;
  937. f = e;
  938. e = d + t1;
  939. d = c;
  940. c = b;
  941. b = a;
  942. a = t1 + t2;
  943. }
  944. h0 += a;
  945. h1 += b;
  946. // only first 2 hash values needed.
  947. h2 += c;
  948. h3 += d;
  949. h4 += e;
  950. h5 += f;
  951. h6 += g;
  952. h7 += h;
  953. /* finish */
  954. #pragma unroll
  955. for (i = 0; i < 4; ++i) {
  956. l = mult_add(i, -8, 24);
  957. hash[i] = (h0 >> l) & 0x000000ff;
  958. hash[i + 4] = (h1 >> l) & 0x000000ff;
  959. // only the first 6 bytes are needed.
  960. hash[i + 8] = (h2 >> l) & 0x000000ff;
  961. hash[i + 12] = (h3 >> l) & 0x000000ff;
  962. hash[i + 16] = (h4 >> l) & 0x000000ff;
  963. hash[i + 20] = (h5 >> l) & 0x000000ff;
  964. hash[i + 24] = (h6 >> l) & 0x000000ff;
  965. hash[i + 28] = (h7 >> l) & 0x000000ff;
  966. }
  967. }
  968. long hashToLong(byte* hash) {
  969. return hash[5] + (hash[4] << 8) + (hash[3] << 16) + ((long)hash[2] << 24) + ((long) hash[1] << 32) + ((long) hash[0] << 40);
  970. }
  971.  
  972. // converts one long into 12 hex characters
  973. void longToHex(long in, byte* hex, int offset) {
  974. #pragma unroll
  975. for (int i = offset; i < 34; i++) {
  976. hex[i] = (in >> ((i - offset) * 5) & 31) + 48;
  977. }
  978. }
  979.  
  980. __kernel void krist_miner_basic(
  981. __global const byte* address, // 10 chars
  982. __global const byte* block, // 12 chars
  983. __global const byte* prefix, // 2 chars
  984. const long base, // convert to 10 chars
  985. const long work,
  986. __global byte* output) {
  987. int id = get_global_id(0);
  988. long nonce = id + base;
  989. byte input[64];
  990. byte hashed[32];
  991. #pragma unroll
  992. for (int i = 0; i < 10; i++) {
  993. input[i] = address[i];
  994. }
  995. #pragma unroll
  996. for (int i = 10; i < 22; i++) {
  997. input[i] = block[i - 10];
  998. }
  999. #pragma unroll
  1000. for (int i = 22; i < 24; i++) {
  1001. input[i] = prefix[i-22];
  1002. }
  1003. #pragma unroll
  1004. for (int i = 24; i < 34; i++) {
  1005. input[i] = ((nonce >> ((i - 24) * 5)) & 31) + 48;
  1006. }
  1007. digest(input, 34, hashed);
  1008. long score = hashToLong(hashed);
  1009. if (score < work) {
  1010. #pragma unroll
  1011. for (int i = 0; i < 10; i++) {
  1012. output[i] = address[i];
  1013. }
  1014. #pragma unroll
  1015. for (int i = 10; i < 22; i++) {
  1016. output[i] = block[i - 10];
  1017. }
  1018. #pragma unroll
  1019. for (int i = 22; i < 24; i++) {
  1020. output[i] = prefix[i-22];
  1021. }
  1022. #pragma unroll
  1023. for (int i = 24; i < 34; i++) {
  1024. output[i] = ((nonce >> ((i - 24) * 5)) & 31) + 48;
  1025. }
  1026. }
  1027. }
  1028.  
  1029. >>> ) (make sure to log all errors with environment variable CL_LOG_ERRORS=stdout)
  1030. at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  1031. at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
  1032. at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
  1033. at java.lang.reflect.Constructor.newInstance(Unknown Source)
  1034. at java.lang.Class.newInstance(Unknown Source)
  1035. at com.nativelibs4java.opencl.CLException.error(CLException.java:302)
  1036. at com.nativelibs4java.opencl.CLKernel.setKernelArg(CLKernel.java:273)
  1037. at com.nativelibs4java.opencl.CLKernel.setArg(CLKernel.java:406)
  1038. at com.nativelibs4java.opencl.CLKernel.setObjectArg(CLKernel.java:201)
  1039. at com.nativelibs4java.opencl.CLKernel.setArgs(CLKernel.java:191)
  1040. at me.apemanzilla.jclminer.miners.GPUMiner.run(GPUMiner.java:142)
  1041. at java.lang.Thread.run(Unknown Source)
  1042. 10.92 MH/s
  1043. Test #11 > Exception in thread "Thread-8" com.nativelibs4java.opencl.CLException$InvalidMemObject: InvalidMemObject (kernel name = krist_miner_basic, num args = 6, arg index = 1, source = <<<
  1044. // This file contains code for hashing and mining on OpenCL hardware
  1045.  
  1046. typedef uchar byte;
  1047.  
  1048. // macro so i can change it later
  1049. #define mult_add(a,b,c) (a * b + c)
  1050.  
  1051. // right rotate macro
  1052. #define RR(X, Y) rotate((uint)X, -((uint)Y))
  1053.  
  1054. // optimized padding macro
  1055. // takes a character array and integer
  1056. // character array is used as both input and output
  1057. // character array should be 64 items long regardless of content
  1058. // actual input present in character array should not exceed 55 items
  1059. // second argument should be the length of the input content
  1060. // example usage:
  1061. // char data[64];
  1062. // data[0] = 'h';
  1063. // data[1] = 'e';
  1064. // data[2] = 'l';
  1065. // data[3] = 'l';
  1066. // data[4] = 'o';
  1067. // PAD(data, 5);
  1068. // // data array now contains 'hello' padded
  1069. #define PAD(X, Y) X[63] = Y * 8; X[62] = Y >> 5; X[Y] = 0x80;
  1070.  
  1071. // SHA256 macros
  1072. #define CH(x,y,z) bitselect(z,y,x)
  1073. #define MAJ(x,y,z) bitselect(x,y,z^x)
  1074. #define EP0(x) (RR(x,2) ^ RR(x,13) ^ RR(x,22))
  1075. #define EP1(x) (RR(x,6) ^ RR(x,11) ^ RR(x,25))
  1076. #define SIG0(x) (RR(x,7) ^ RR(x,18) ^ ((x) >> 3))
  1077. #define SIG1(x) (RR(x,17) ^ RR(x,19) ^ ((x) >> 10))
  1078.  
  1079. __constant uint K[64] = {
  1080. 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
  1081. 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
  1082. 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
  1083. 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
  1084. 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
  1085. 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
  1086. 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
  1087. 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2};
  1088.  
  1089. // SHA256 digest function - optimization pending
  1090. // takes a byte array of size 64 with 55 or fewer items, and writes
  1091. // hash to 32 item byte array.
  1092. // make sure to pass the input size as the second argument.
  1093. // example usage:
  1094. // char data[64];
  1095. // char hash[32];
  1096. // data[0] = 'h';
  1097. // data[1] = 'e';
  1098. // data[2] = 'l';
  1099. // data[3] = 'l';
  1100. // data[4] = 'o';
  1101. // digest(data, 5, hash);
  1102. // // hash array now contains hash of 'hello'
  1103.  
  1104. void digest(byte* data, uint inputLen, byte* hash) {
  1105. /* init vars */
  1106. uint h0, h1, h2, h3, h4, h5, h6, h7;
  1107. uint a, b, c, d, e, f, g, h, i, j, l, t1, t2, m[64] = {0};
  1108. PAD(data, inputLen);
  1109. /* init hash state */
  1110. h0 = 0x6a09e667;
  1111. h1 = 0xbb67ae85;
  1112. h2 = 0x3c6ef372;
  1113. h3 = 0xa54ff53a;
  1114. h4 = 0x510e527f;
  1115. h5 = 0x9b05688c;
  1116. h6 = 0x1f83d9ab;
  1117. h7 = 0x5be0cd19;
  1118. /* transform */
  1119. #pragma unroll
  1120. for (i = 0; i < 16; i++)
  1121. m[i] = (data[mult_add(i,4,0)] << 24) | (data[mult_add(i,4,1)] << 16) | (data[mult_add(i,4,2)] << 8) | (data[mult_add(i,4,3)]);
  1122. #pragma unroll
  1123. for (i = 16; i < 64; ++i)
  1124. m[i] = SIG1(m[i - 2]) + m[i - 7] + SIG0(m[i - 15]) + m[i - 16];
  1125. a = h0;
  1126. b = h1;
  1127. c = h2;
  1128. d = h3;
  1129. e = h4;
  1130. f = h5;
  1131. g = h6;
  1132. h = h7;
  1133. #pragma unroll
  1134. for (i = 0; i < 64; ++i) {
  1135. t1 = h + EP1(e) + CH(e,f,g) + K[i] + m[i];
  1136. t2 = EP0(a) + MAJ(a,b,c);
  1137. h = g;
  1138. g = f;
  1139. f = e;
  1140. e = d + t1;
  1141. d = c;
  1142. c = b;
  1143. b = a;
  1144. a = t1 + t2;
  1145. }
  1146. h0 += a;
  1147. h1 += b;
  1148. // only first 2 hash values needed.
  1149. h2 += c;
  1150. h3 += d;
  1151. h4 += e;
  1152. h5 += f;
  1153. h6 += g;
  1154. h7 += h;
  1155. /* finish */
  1156. #pragma unroll
  1157. for (i = 0; i < 4; ++i) {
  1158. l = mult_add(i, -8, 24);
  1159. hash[i] = (h0 >> l) & 0x000000ff;
  1160. hash[i + 4] = (h1 >> l) & 0x000000ff;
  1161. // only the first 6 bytes are needed.
  1162. hash[i + 8] = (h2 >> l) & 0x000000ff;
  1163. hash[i + 12] = (h3 >> l) & 0x000000ff;
  1164. hash[i + 16] = (h4 >> l) & 0x000000ff;
  1165. hash[i + 20] = (h5 >> l) & 0x000000ff;
  1166. hash[i + 24] = (h6 >> l) & 0x000000ff;
  1167. hash[i + 28] = (h7 >> l) & 0x000000ff;
  1168. }
  1169. }
  1170. long hashToLong(byte* hash) {
  1171. return hash[5] + (hash[4] << 8) + (hash[3] << 16) + ((long)hash[2] << 24) + ((long) hash[1] << 32) + ((long) hash[0] << 40);
  1172. }
  1173.  
  1174. // converts one long into 12 hex characters
  1175. void longToHex(long in, byte* hex, int offset) {
  1176. #pragma unroll
  1177. for (int i = offset; i < 34; i++) {
  1178. hex[i] = (in >> ((i - offset) * 5) & 31) + 48;
  1179. }
  1180. }
  1181.  
  1182. __kernel void krist_miner_basic(
  1183. __global const byte* address, // 10 chars
  1184. __global const byte* block, // 12 chars
  1185. __global const byte* prefix, // 2 chars
  1186. const long base, // convert to 10 chars
  1187. const long work,
  1188. __global byte* output) {
  1189. int id = get_global_id(0);
  1190. long nonce = id + base;
  1191. byte input[64];
  1192. byte hashed[32];
  1193. #pragma unroll
  1194. for (int i = 0; i < 10; i++) {
  1195. input[i] = address[i];
  1196. }
  1197. #pragma unroll
  1198. for (int i = 10; i < 22; i++) {
  1199. input[i] = block[i - 10];
  1200. }
  1201. #pragma unroll
  1202. for (int i = 22; i < 24; i++) {
  1203. input[i] = prefix[i-22];
  1204. }
  1205. #pragma unroll
  1206. for (int i = 24; i < 34; i++) {
  1207. input[i] = ((nonce >> ((i - 24) * 5)) & 31) + 48;
  1208. }
  1209. digest(input, 34, hashed);
  1210. long score = hashToLong(hashed);
  1211. if (score < work) {
  1212. #pragma unroll
  1213. for (int i = 0; i < 10; i++) {
  1214. output[i] = address[i];
  1215. }
  1216. #pragma unroll
  1217. for (int i = 10; i < 22; i++) {
  1218. output[i] = block[i - 10];
  1219. }
  1220. #pragma unroll
  1221. for (int i = 22; i < 24; i++) {
  1222. output[i] = prefix[i-22];
  1223. }
  1224. #pragma unroll
  1225. for (int i = 24; i < 34; i++) {
  1226. output[i] = ((nonce >> ((i - 24) * 5)) & 31) + 48;
  1227. }
  1228. }
  1229. }
  1230.  
  1231. >>> ) (make sure to log all errors with environment variable CL_LOG_ERRORS=stdout)
  1232. at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  1233. at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
  1234. at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
  1235. at java.lang.reflect.Constructor.newInstance(Unknown Source)
  1236. at java.lang.Class.newInstance(Unknown Source)
  1237. at com.nativelibs4java.opencl.CLException.error(CLException.java:302)
  1238. at com.nativelibs4java.opencl.CLKernel.setKernelArg(CLKernel.java:273)
  1239. at com.nativelibs4java.opencl.CLKernel.setArg(CLKernel.java:406)
  1240. at com.nativelibs4java.opencl.CLKernel.setObjectArg(CLKernel.java:201)
  1241. at com.nativelibs4java.opencl.CLKernel.setArgs(CLKernel.java:191)
  1242. at me.apemanzilla.jclminer.miners.GPUMiner.run(GPUMiner.java:142)
  1243. at java.lang.Thread.run(Unknown Source)
  1244. 12.90 MH/s
  1245. Test #12 > 13.16 MH/s
  1246. Test #13 > Exception in thread "Thread-13" com.nativelibs4java.opencl.CLException$InvalidMemObject: InvalidMemObject (kernel name = krist_miner_basic, num args = 6, arg index = 2, source = <<<
  1247. // This file contains code for hashing and mining on OpenCL hardware
  1248.  
  1249. typedef uchar byte;
  1250.  
  1251. // macro so i can change it later
  1252. #define mult_add(a,b,c) (a * b + c)
  1253.  
  1254. // right rotate macro
  1255. #define RR(X, Y) rotate((uint)X, -((uint)Y))
  1256.  
  1257. // optimized padding macro
  1258. // takes a character array and integer
  1259. // character array is used as both input and output
  1260. // character array should be 64 items long regardless of content
  1261. // actual input present in character array should not exceed 55 items
  1262. // second argument should be the length of the input content
  1263. // example usage:
  1264. // char data[64];
  1265. // data[0] = 'h';
  1266. // data[1] = 'e';
  1267. // data[2] = 'l';
  1268. // data[3] = 'l';
  1269. // data[4] = 'o';
  1270. // PAD(data, 5);
  1271. // // data array now contains 'hello' padded
  1272. #define PAD(X, Y) X[63] = Y * 8; X[62] = Y >> 5; X[Y] = 0x80;
  1273.  
  1274. // SHA256 macros
  1275. #define CH(x,y,z) bitselect(z,y,x)
  1276. #define MAJ(x,y,z) bitselect(x,y,z^x)
  1277. #define EP0(x) (RR(x,2) ^ RR(x,13) ^ RR(x,22))
  1278. #define EP1(x) (RR(x,6) ^ RR(x,11) ^ RR(x,25))
  1279. #define SIG0(x) (RR(x,7) ^ RR(x,18) ^ ((x) >> 3))
  1280. #define SIG1(x) (RR(x,17) ^ RR(x,19) ^ ((x) >> 10))
  1281.  
  1282. __constant uint K[64] = {
  1283. 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
  1284. 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
  1285. 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
  1286. 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
  1287. 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
  1288. 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
  1289. 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
  1290. 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2};
  1291.  
  1292. // SHA256 digest function - optimization pending
  1293. // takes a byte array of size 64 with 55 or fewer items, and writes
  1294. // hash to 32 item byte array.
  1295. // make sure to pass the input size as the second argument.
  1296. // example usage:
  1297. // char data[64];
  1298. // char hash[32];
  1299. // data[0] = 'h';
  1300. // data[1] = 'e';
  1301. // data[2] = 'l';
  1302. // data[3] = 'l';
  1303. // data[4] = 'o';
  1304. // digest(data, 5, hash);
  1305. // // hash array now contains hash of 'hello'
  1306.  
  1307. void digest(byte* data, uint inputLen, byte* hash) {
  1308. /* init vars */
  1309. uint h0, h1, h2, h3, h4, h5, h6, h7;
  1310. uint a, b, c, d, e, f, g, h, i, j, l, t1, t2, m[64] = {0};
  1311. PAD(data, inputLen);
  1312. /* init hash state */
  1313. h0 = 0x6a09e667;
  1314. h1 = 0xbb67ae85;
  1315. h2 = 0x3c6ef372;
  1316. h3 = 0xa54ff53a;
  1317. h4 = 0x510e527f;
  1318. h5 = 0x9b05688c;
  1319. h6 = 0x1f83d9ab;
  1320. h7 = 0x5be0cd19;
  1321. /* transform */
  1322. #pragma unroll
  1323. for (i = 0; i < 16; i++)
  1324. m[i] = (data[mult_add(i,4,0)] << 24) | (data[mult_add(i,4,1)] << 16) | (data[mult_add(i,4,2)] << 8) | (data[mult_add(i,4,3)]);
  1325. #pragma unroll
  1326. for (i = 16; i < 64; ++i)
  1327. m[i] = SIG1(m[i - 2]) + m[i - 7] + SIG0(m[i - 15]) + m[i - 16];
  1328. a = h0;
  1329. b = h1;
  1330. c = h2;
  1331. d = h3;
  1332. e = h4;
  1333. f = h5;
  1334. g = h6;
  1335. h = h7;
  1336. #pragma unroll
  1337. for (i = 0; i < 64; ++i) {
  1338. t1 = h + EP1(e) + CH(e,f,g) + K[i] + m[i];
  1339. t2 = EP0(a) + MAJ(a,b,c);
  1340. h = g;
  1341. g = f;
  1342. f = e;
  1343. e = d + t1;
  1344. d = c;
  1345. c = b;
  1346. b = a;
  1347. a = t1 + t2;
  1348. }
  1349. h0 += a;
  1350. h1 += b;
  1351. // only first 2 hash values needed.
  1352. h2 += c;
  1353. h3 += d;
  1354. h4 += e;
  1355. h5 += f;
  1356. h6 += g;
  1357. h7 += h;
  1358. /* finish */
  1359. #pragma unroll
  1360. for (i = 0; i < 4; ++i) {
  1361. l = mult_add(i, -8, 24);
  1362. hash[i] = (h0 >> l) & 0x000000ff;
  1363. hash[i + 4] = (h1 >> l) & 0x000000ff;
  1364. // only the first 6 bytes are needed.
  1365. hash[i + 8] = (h2 >> l) & 0x000000ff;
  1366. hash[i + 12] = (h3 >> l) & 0x000000ff;
  1367. hash[i + 16] = (h4 >> l) & 0x000000ff;
  1368. hash[i + 20] = (h5 >> l) & 0x000000ff;
  1369. hash[i + 24] = (h6 >> l) & 0x000000ff;
  1370. hash[i + 28] = (h7 >> l) & 0x000000ff;
  1371. }
  1372. }
  1373. long hashToLong(byte* hash) {
  1374. return hash[5] + (hash[4] << 8) + (hash[3] << 16) + ((long)hash[2] << 24) + ((long) hash[1] << 32) + ((long) hash[0] << 40);
  1375. }
  1376.  
  1377. // converts one long into 12 hex characters
  1378. void longToHex(long in, byte* hex, int offset) {
  1379. #pragma unroll
  1380. for (int i = offset; i < 34; i++) {
  1381. hex[i] = (in >> ((i - offset) * 5) & 31) + 48;
  1382. }
  1383. }
  1384.  
  1385. __kernel void krist_miner_basic(
  1386. __global const byte* address, // 10 chars
  1387. __global const byte* block, // 12 chars
  1388. __global const byte* prefix, // 2 chars
  1389. const long base, // convert to 10 chars
  1390. const long work,
  1391. __global byte* output) {
  1392. int id = get_global_id(0);
  1393. long nonce = id + base;
  1394. byte input[64];
  1395. byte hashed[32];
  1396. #pragma unroll
  1397. for (int i = 0; i < 10; i++) {
  1398. input[i] = address[i];
  1399. }
  1400. #pragma unroll
  1401. for (int i = 10; i < 22; i++) {
  1402. input[i] = block[i - 10];
  1403. }
  1404. #pragma unroll
  1405. for (int i = 22; i < 24; i++) {
  1406. input[i] = prefix[i-22];
  1407. }
  1408. #pragma unroll
  1409. for (int i = 24; i < 34; i++) {
  1410. input[i] = ((nonce >> ((i - 24) * 5)) & 31) + 48;
  1411. }
  1412. digest(input, 34, hashed);
  1413. long score = hashToLong(hashed);
  1414. if (score < work) {
  1415. #pragma unroll
  1416. for (int i = 0; i < 10; i++) {
  1417. output[i] = address[i];
  1418. }
  1419. #pragma unroll
  1420. for (int i = 10; i < 22; i++) {
  1421. output[i] = block[i - 10];
  1422. }
  1423. #pragma unroll
  1424. for (int i = 22; i < 24; i++) {
  1425. output[i] = prefix[i-22];
  1426. }
  1427. #pragma unroll
  1428. for (int i = 24; i < 34; i++) {
  1429. output[i] = ((nonce >> ((i - 24) * 5)) & 31) + 48;
  1430. }
  1431. }
  1432. }
  1433.  
  1434. >>> ) (make sure to log all errors with environment variable CL_LOG_ERRORS=stdout)
  1435. at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  1436. at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
  1437. at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
  1438. at java.lang.reflect.Constructor.newInstance(Unknown Source)
  1439. at java.lang.Class.newInstance(Unknown Source)
  1440. at com.nativelibs4java.opencl.CLException.error(CLException.java:302)
  1441. at com.nativelibs4java.opencl.CLKernel.setKernelArg(CLKernel.java:273)
  1442. at com.nativelibs4java.opencl.CLKernel.setArg(CLKernel.java:406)
  1443. at com.nativelibs4java.opencl.CLKernel.setObjectArg(CLKernel.java:201)
  1444. at com.nativelibs4java.opencl.CLKernel.setArgs(CLKernel.java:191)
  1445. at me.apemanzilla.jclminer.miners.GPUMiner.run(GPUMiner.java:142)
  1446. at java.lang.Thread.run(Unknown Source)
  1447. 13.21 MH/s
  1448. Test #14 > 13.11 MH/s
  1449. Performance decrease - stopping tests.
  1450. Profiling complete! Use the following launch arguments for optimal performance:
  1451. -a -d 513176346:1048576;
  1452.  
  1453. C:\Users\Jaden\Downloads\JCLMiner\bin>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement