Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Microsoft Windows [Version 10.0.19042.631]
- (c) 2020 Microsoft Corporation. All rights reserved.
- C:\Users\Jaden>cd /downloads/JCLMiner
- The system cannot find the path specified.
- C:\Users\Jaden>cd \Downloads\JCLMiner\bin
- The system cannot find the path specified.
- C:\Users\Jaden>cd Downloads\JCLMiner\bin
- C:\Users\Jaden\Downloads\JCLMiner\bin>JCLminer
- usage: JCLMiner -h [address]
- -h,--host <arg> The address to send rewards to.
- -l,--list-devices Show a list of compatible devices and their
- signatures.
- -p,--profile Profile each device to find the optimal work range.
- -b,--best-device Mine on whichever device is deemed 'best.' Default
- option.
- -a,--all-devices Mine on all compatible hardware devices.
- -d,--devices <arg> Specifies what work size to use for given device
- types. Run a profile with -p to get best setting.
- -?,--help Show usage.
- C:\Users\Jaden\Downloads\JCLMiner\bin>JCLMiner -p
- Starting system profiler...
- Profiling device Intel(R) HD Graphics 6000
- Test #1 > 438.78 KH/s
- 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 = <<<
- // This file contains code for hashing and mining on OpenCL hardware
- typedef uchar byte;
- // macro so i can change it later
- #define mult_add(a,b,c) (a * b + c)
- // right rotate macro
- #define RR(X, Y) rotate((uint)X, -((uint)Y))
- // optimized padding macro
- // takes a character array and integer
- // character array is used as both input and output
- // character array should be 64 items long regardless of content
- // actual input present in character array should not exceed 55 items
- // second argument should be the length of the input content
- // example usage:
- // char data[64];
- // data[0] = 'h';
- // data[1] = 'e';
- // data[2] = 'l';
- // data[3] = 'l';
- // data[4] = 'o';
- // PAD(data, 5);
- // // data array now contains 'hello' padded
- #define PAD(X, Y) X[63] = Y * 8; X[62] = Y >> 5; X[Y] = 0x80;
- // SHA256 macros
- #define CH(x,y,z) bitselect(z,y,x)
- #define MAJ(x,y,z) bitselect(x,y,z^x)
- #define EP0(x) (RR(x,2) ^ RR(x,13) ^ RR(x,22))
- #define EP1(x) (RR(x,6) ^ RR(x,11) ^ RR(x,25))
- #define SIG0(x) (RR(x,7) ^ RR(x,18) ^ ((x) >> 3))
- #define SIG1(x) (RR(x,17) ^ RR(x,19) ^ ((x) >> 10))
- __constant uint K[64] = {
- 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
- 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
- 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
- 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
- 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
- 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
- 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
- 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2};
- // SHA256 digest function - optimization pending
- // takes a byte array of size 64 with 55 or fewer items, and writes
- // hash to 32 item byte array.
- // make sure to pass the input size as the second argument.
- // example usage:
- // char data[64];
- // char hash[32];
- // data[0] = 'h';
- // data[1] = 'e';
- // data[2] = 'l';
- // data[3] = 'l';
- // data[4] = 'o';
- // digest(data, 5, hash);
- // // hash array now contains hash of 'hello'
- void digest(byte* data, uint inputLen, byte* hash) {
- /* init vars */
- uint h0, h1, h2, h3, h4, h5, h6, h7;
- uint a, b, c, d, e, f, g, h, i, j, l, t1, t2, m[64] = {0};
- PAD(data, inputLen);
- /* init hash state */
- h0 = 0x6a09e667;
- h1 = 0xbb67ae85;
- h2 = 0x3c6ef372;
- h3 = 0xa54ff53a;
- h4 = 0x510e527f;
- h5 = 0x9b05688c;
- h6 = 0x1f83d9ab;
- h7 = 0x5be0cd19;
- /* transform */
- #pragma unroll
- for (i = 0; i < 16; i++)
- 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)]);
- #pragma unroll
- for (i = 16; i < 64; ++i)
- m[i] = SIG1(m[i - 2]) + m[i - 7] + SIG0(m[i - 15]) + m[i - 16];
- a = h0;
- b = h1;
- c = h2;
- d = h3;
- e = h4;
- f = h5;
- g = h6;
- h = h7;
- #pragma unroll
- for (i = 0; i < 64; ++i) {
- t1 = h + EP1(e) + CH(e,f,g) + K[i] + m[i];
- t2 = EP0(a) + MAJ(a,b,c);
- h = g;
- g = f;
- f = e;
- e = d + t1;
- d = c;
- c = b;
- b = a;
- a = t1 + t2;
- }
- h0 += a;
- h1 += b;
- // only first 2 hash values needed.
- h2 += c;
- h3 += d;
- h4 += e;
- h5 += f;
- h6 += g;
- h7 += h;
- /* finish */
- #pragma unroll
- for (i = 0; i < 4; ++i) {
- l = mult_add(i, -8, 24);
- hash[i] = (h0 >> l) & 0x000000ff;
- hash[i + 4] = (h1 >> l) & 0x000000ff;
- // only the first 6 bytes are needed.
- hash[i + 8] = (h2 >> l) & 0x000000ff;
- hash[i + 12] = (h3 >> l) & 0x000000ff;
- hash[i + 16] = (h4 >> l) & 0x000000ff;
- hash[i + 20] = (h5 >> l) & 0x000000ff;
- hash[i + 24] = (h6 >> l) & 0x000000ff;
- hash[i + 28] = (h7 >> l) & 0x000000ff;
- }
- }
- long hashToLong(byte* hash) {
- return hash[5] + (hash[4] << 8) + (hash[3] << 16) + ((long)hash[2] << 24) + ((long) hash[1] << 32) + ((long) hash[0] << 40);
- }
- // converts one long into 12 hex characters
- void longToHex(long in, byte* hex, int offset) {
- #pragma unroll
- for (int i = offset; i < 34; i++) {
- hex[i] = (in >> ((i - offset) * 5) & 31) + 48;
- }
- }
- __kernel void krist_miner_basic(
- __global const byte* address, // 10 chars
- __global const byte* block, // 12 chars
- __global const byte* prefix, // 2 chars
- const long base, // convert to 10 chars
- const long work,
- __global byte* output) {
- int id = get_global_id(0);
- long nonce = id + base;
- byte input[64];
- byte hashed[32];
- #pragma unroll
- for (int i = 0; i < 10; i++) {
- input[i] = address[i];
- }
- #pragma unroll
- for (int i = 10; i < 22; i++) {
- input[i] = block[i - 10];
- }
- #pragma unroll
- for (int i = 22; i < 24; i++) {
- input[i] = prefix[i-22];
- }
- #pragma unroll
- for (int i = 24; i < 34; i++) {
- input[i] = ((nonce >> ((i - 24) * 5)) & 31) + 48;
- }
- digest(input, 34, hashed);
- long score = hashToLong(hashed);
- if (score < work) {
- #pragma unroll
- for (int i = 0; i < 10; i++) {
- output[i] = address[i];
- }
- #pragma unroll
- for (int i = 10; i < 22; i++) {
- output[i] = block[i - 10];
- }
- #pragma unroll
- for (int i = 22; i < 24; i++) {
- output[i] = prefix[i-22];
- }
- #pragma unroll
- for (int i = 24; i < 34; i++) {
- output[i] = ((nonce >> ((i - 24) * 5)) & 31) + 48;
- }
- }
- }
- >>> ) (make sure to log all errors with environment variable CL_LOG_ERRORS=stdout)
- at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
- at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
- at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
- at java.lang.reflect.Constructor.newInstance(Unknown Source)
- at java.lang.Class.newInstance(Unknown Source)
- at com.nativelibs4java.opencl.CLException.error(CLException.java:302)
- at com.nativelibs4java.opencl.CLKernel.setKernelArg(CLKernel.java:273)
- at com.nativelibs4java.opencl.CLKernel.setArg(CLKernel.java:406)
- at com.nativelibs4java.opencl.CLKernel.setObjectArg(CLKernel.java:201)
- at com.nativelibs4java.opencl.CLKernel.setArgs(CLKernel.java:191)
- at me.apemanzilla.jclminer.miners.GPUMiner.run(GPUMiner.java:142)
- at java.lang.Thread.run(Unknown Source)
- 578.87 KH/s
- Test #3 > 1.19 MH/s
- Test #4 > 2.04 MH/s
- 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 = <<<
- // This file contains code for hashing and mining on OpenCL hardware
- typedef uchar byte;
- // macro so i can change it later
- #define mult_add(a,b,c) (a * b + c)
- // right rotate macro
- #define RR(X, Y) rotate((uint)X, -((uint)Y))
- // optimized padding macro
- // takes a character array and integer
- // character array is used as both input and output
- // character array should be 64 items long regardless of content
- // actual input present in character array should not exceed 55 items
- // second argument should be the length of the input content
- // example usage:
- // char data[64];
- // data[0] = 'h';
- // data[1] = 'e';
- // data[2] = 'l';
- // data[3] = 'l';
- // data[4] = 'o';
- // PAD(data, 5);
- // // data array now contains 'hello' padded
- #define PAD(X, Y) X[63] = Y * 8; X[62] = Y >> 5; X[Y] = 0x80;
- // SHA256 macros
- #define CH(x,y,z) bitselect(z,y,x)
- #define MAJ(x,y,z) bitselect(x,y,z^x)
- #define EP0(x) (RR(x,2) ^ RR(x,13) ^ RR(x,22))
- #define EP1(x) (RR(x,6) ^ RR(x,11) ^ RR(x,25))
- #define SIG0(x) (RR(x,7) ^ RR(x,18) ^ ((x) >> 3))
- #define SIG1(x) (RR(x,17) ^ RR(x,19) ^ ((x) >> 10))
- __constant uint K[64] = {
- 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
- 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
- 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
- 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
- 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
- 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
- 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
- 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2};
- // SHA256 digest function - optimization pending
- // takes a byte array of size 64 with 55 or fewer items, and writes
- // hash to 32 item byte array.
- // make sure to pass the input size as the second argument.
- // example usage:
- // char data[64];
- // char hash[32];
- // data[0] = 'h';
- // data[1] = 'e';
- // data[2] = 'l';
- // data[3] = 'l';
- // data[4] = 'o';
- // digest(data, 5, hash);
- // // hash array now contains hash of 'hello'
- void digest(byte* data, uint inputLen, byte* hash) {
- /* init vars */
- uint h0, h1, h2, h3, h4, h5, h6, h7;
- uint a, b, c, d, e, f, g, h, i, j, l, t1, t2, m[64] = {0};
- PAD(data, inputLen);
- /* init hash state */
- h0 = 0x6a09e667;
- h1 = 0xbb67ae85;
- h2 = 0x3c6ef372;
- h3 = 0xa54ff53a;
- h4 = 0x510e527f;
- h5 = 0x9b05688c;
- h6 = 0x1f83d9ab;
- h7 = 0x5be0cd19;
- /* transform */
- #pragma unroll
- for (i = 0; i < 16; i++)
- 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)]);
- #pragma unroll
- for (i = 16; i < 64; ++i)
- m[i] = SIG1(m[i - 2]) + m[i - 7] + SIG0(m[i - 15]) + m[i - 16];
- a = h0;
- b = h1;
- c = h2;
- d = h3;
- e = h4;
- f = h5;
- g = h6;
- h = h7;
- #pragma unroll
- for (i = 0; i < 64; ++i) {
- t1 = h + EP1(e) + CH(e,f,g) + K[i] + m[i];
- t2 = EP0(a) + MAJ(a,b,c);
- h = g;
- g = f;
- f = e;
- e = d + t1;
- d = c;
- c = b;
- b = a;
- a = t1 + t2;
- }
- h0 += a;
- h1 += b;
- // only first 2 hash values needed.
- h2 += c;
- h3 += d;
- h4 += e;
- h5 += f;
- h6 += g;
- h7 += h;
- /* finish */
- #pragma unroll
- for (i = 0; i < 4; ++i) {
- l = mult_add(i, -8, 24);
- hash[i] = (h0 >> l) & 0x000000ff;
- hash[i + 4] = (h1 >> l) & 0x000000ff;
- // only the first 6 bytes are needed.
- hash[i + 8] = (h2 >> l) & 0x000000ff;
- hash[i + 12] = (h3 >> l) & 0x000000ff;
- hash[i + 16] = (h4 >> l) & 0x000000ff;
- hash[i + 20] = (h5 >> l) & 0x000000ff;
- hash[i + 24] = (h6 >> l) & 0x000000ff;
- hash[i + 28] = (h7 >> l) & 0x000000ff;
- }
- }
- long hashToLong(byte* hash) {
- return hash[5] + (hash[4] << 8) + (hash[3] << 16) + ((long)hash[2] << 24) + ((long) hash[1] << 32) + ((long) hash[0] << 40);
- }
- // converts one long into 12 hex characters
- void longToHex(long in, byte* hex, int offset) {
- #pragma unroll
- for (int i = offset; i < 34; i++) {
- hex[i] = (in >> ((i - offset) * 5) & 31) + 48;
- }
- }
- __kernel void krist_miner_basic(
- __global const byte* address, // 10 chars
- __global const byte* block, // 12 chars
- __global const byte* prefix, // 2 chars
- const long base, // convert to 10 chars
- const long work,
- __global byte* output) {
- int id = get_global_id(0);
- long nonce = id + base;
- byte input[64];
- byte hashed[32];
- #pragma unroll
- for (int i = 0; i < 10; i++) {
- input[i] = address[i];
- }
- #pragma unroll
- for (int i = 10; i < 22; i++) {
- input[i] = block[i - 10];
- }
- #pragma unroll
- for (int i = 22; i < 24; i++) {
- input[i] = prefix[i-22];
- }
- #pragma unroll
- for (int i = 24; i < 34; i++) {
- input[i] = ((nonce >> ((i - 24) * 5)) & 31) + 48;
- }
- digest(input, 34, hashed);
- long score = hashToLong(hashed);
- if (score < work) {
- #pragma unroll
- for (int i = 0; i < 10; i++) {
- output[i] = address[i];
- }
- #pragma unroll
- for (int i = 10; i < 22; i++) {
- output[i] = block[i - 10];
- }
- #pragma unroll
- for (int i = 22; i < 24; i++) {
- output[i] = prefix[i-22];
- }
- #pragma unroll
- for (int i = 24; i < 34; i++) {
- output[i] = ((nonce >> ((i - 24) * 5)) & 31) + 48;
- }
- }
- }
- >>> ) (make sure to log all errors with environment variable CL_LOG_ERRORS=stdout)
- at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
- at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
- at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
- at java.lang.reflect.Constructor.newInstance(Unknown Source)
- at java.lang.Class.newInstance(Unknown Source)
- at com.nativelibs4java.opencl.CLException.error(CLException.java:302)
- at com.nativelibs4java.opencl.CLKernel.setKernelArg(CLKernel.java:273)
- at com.nativelibs4java.opencl.CLKernel.setArg(CLKernel.java:406)
- at com.nativelibs4java.opencl.CLKernel.setObjectArg(CLKernel.java:201)
- at com.nativelibs4java.opencl.CLKernel.setArgs(CLKernel.java:191)
- at me.apemanzilla.jclminer.miners.GPUMiner.run(GPUMiner.java:142)
- at java.lang.Thread.run(Unknown Source)
- 3.74 MH/s
- Test #6 > 5.93 MH/s
- 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 = <<<
- // This file contains code for hashing and mining on OpenCL hardware
- typedef uchar byte;
- // macro so i can change it later
- #define mult_add(a,b,c) (a * b + c)
- // right rotate macro
- #define RR(X, Y) rotate((uint)X, -((uint)Y))
- // optimized padding macro
- // takes a character array and integer
- // character array is used as both input and output
- // character array should be 64 items long regardless of content
- // actual input present in character array should not exceed 55 items
- // second argument should be the length of the input content
- // example usage:
- // char data[64];
- // data[0] = 'h';
- // data[1] = 'e';
- // data[2] = 'l';
- // data[3] = 'l';
- // data[4] = 'o';
- // PAD(data, 5);
- // // data array now contains 'hello' padded
- #define PAD(X, Y) X[63] = Y * 8; X[62] = Y >> 5; X[Y] = 0x80;
- // SHA256 macros
- #define CH(x,y,z) bitselect(z,y,x)
- #define MAJ(x,y,z) bitselect(x,y,z^x)
- #define EP0(x) (RR(x,2) ^ RR(x,13) ^ RR(x,22))
- #define EP1(x) (RR(x,6) ^ RR(x,11) ^ RR(x,25))
- #define SIG0(x) (RR(x,7) ^ RR(x,18) ^ ((x) >> 3))
- #define SIG1(x) (RR(x,17) ^ RR(x,19) ^ ((x) >> 10))
- __constant uint K[64] = {
- 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
- 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
- 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
- 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
- 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
- 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
- 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
- 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2};
- // SHA256 digest function - optimization pending
- // takes a byte array of size 64 with 55 or fewer items, and writes
- // hash to 32 item byte array.
- // make sure to pass the input size as the second argument.
- // example usage:
- // char data[64];
- // char hash[32];
- // data[0] = 'h';
- // data[1] = 'e';
- // data[2] = 'l';
- // data[3] = 'l';
- // data[4] = 'o';
- // digest(data, 5, hash);
- // // hash array now contains hash of 'hello'
- void digest(byte* data, uint inputLen, byte* hash) {
- /* init vars */
- uint h0, h1, h2, h3, h4, h5, h6, h7;
- uint a, b, c, d, e, f, g, h, i, j, l, t1, t2, m[64] = {0};
- PAD(data, inputLen);
- /* init hash state */
- h0 = 0x6a09e667;
- h1 = 0xbb67ae85;
- h2 = 0x3c6ef372;
- h3 = 0xa54ff53a;
- h4 = 0x510e527f;
- h5 = 0x9b05688c;
- h6 = 0x1f83d9ab;
- h7 = 0x5be0cd19;
- /* transform */
- #pragma unroll
- for (i = 0; i < 16; i++)
- 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)]);
- #pragma unroll
- for (i = 16; i < 64; ++i)
- m[i] = SIG1(m[i - 2]) + m[i - 7] + SIG0(m[i - 15]) + m[i - 16];
- a = h0;
- b = h1;
- c = h2;
- d = h3;
- e = h4;
- f = h5;
- g = h6;
- h = h7;
- #pragma unroll
- for (i = 0; i < 64; ++i) {
- t1 = h + EP1(e) + CH(e,f,g) + K[i] + m[i];
- t2 = EP0(a) + MAJ(a,b,c);
- h = g;
- g = f;
- f = e;
- e = d + t1;
- d = c;
- c = b;
- b = a;
- a = t1 + t2;
- }
- h0 += a;
- h1 += b;
- // only first 2 hash values needed.
- h2 += c;
- h3 += d;
- h4 += e;
- h5 += f;
- h6 += g;
- h7 += h;
- /* finish */
- #pragma unroll
- for (i = 0; i < 4; ++i) {
- l = mult_add(i, -8, 24);
- hash[i] = (h0 >> l) & 0x000000ff;
- hash[i + 4] = (h1 >> l) & 0x000000ff;
- // only the first 6 bytes are needed.
- hash[i + 8] = (h2 >> l) & 0x000000ff;
- hash[i + 12] = (h3 >> l) & 0x000000ff;
- hash[i + 16] = (h4 >> l) & 0x000000ff;
- hash[i + 20] = (h5 >> l) & 0x000000ff;
- hash[i + 24] = (h6 >> l) & 0x000000ff;
- hash[i + 28] = (h7 >> l) & 0x000000ff;
- }
- }
- long hashToLong(byte* hash) {
- return hash[5] + (hash[4] << 8) + (hash[3] << 16) + ((long)hash[2] << 24) + ((long) hash[1] << 32) + ((long) hash[0] << 40);
- }
- // converts one long into 12 hex characters
- void longToHex(long in, byte* hex, int offset) {
- #pragma unroll
- for (int i = offset; i < 34; i++) {
- hex[i] = (in >> ((i - offset) * 5) & 31) + 48;
- }
- }
- __kernel void krist_miner_basic(
- __global const byte* address, // 10 chars
- __global const byte* block, // 12 chars
- __global const byte* prefix, // 2 chars
- const long base, // convert to 10 chars
- const long work,
- __global byte* output) {
- int id = get_global_id(0);
- long nonce = id + base;
- byte input[64];
- byte hashed[32];
- #pragma unroll
- for (int i = 0; i < 10; i++) {
- input[i] = address[i];
- }
- #pragma unroll
- for (int i = 10; i < 22; i++) {
- input[i] = block[i - 10];
- }
- #pragma unroll
- for (int i = 22; i < 24; i++) {
- input[i] = prefix[i-22];
- }
- #pragma unroll
- for (int i = 24; i < 34; i++) {
- input[i] = ((nonce >> ((i - 24) * 5)) & 31) + 48;
- }
- digest(input, 34, hashed);
- long score = hashToLong(hashed);
- if (score < work) {
- #pragma unroll
- for (int i = 0; i < 10; i++) {
- output[i] = address[i];
- }
- #pragma unroll
- for (int i = 10; i < 22; i++) {
- output[i] = block[i - 10];
- }
- #pragma unroll
- for (int i = 22; i < 24; i++) {
- output[i] = prefix[i-22];
- }
- #pragma unroll
- for (int i = 24; i < 34; i++) {
- output[i] = ((nonce >> ((i - 24) * 5)) & 31) + 48;
- }
- }
- }
- >>> ) (make sure to log all errors with environment variable CL_LOG_ERRORS=stdout)
- at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
- at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
- at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
- at java.lang.reflect.Constructor.newInstance(Unknown Source)
- at java.lang.Class.newInstance(Unknown Source)
- at com.nativelibs4java.opencl.CLException.error(CLException.java:302)
- at com.nativelibs4java.opencl.CLKernel.setKernelArg(CLKernel.java:273)
- at com.nativelibs4java.opencl.CLKernel.setArg(CLKernel.java:406)
- at com.nativelibs4java.opencl.CLKernel.setObjectArg(CLKernel.java:201)
- at com.nativelibs4java.opencl.CLKernel.setArgs(CLKernel.java:191)
- at me.apemanzilla.jclminer.miners.GPUMiner.run(GPUMiner.java:142)
- at java.lang.Thread.run(Unknown Source)
- 8.50 MH/s
- Test #8 > 10.69 MH/s
- 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 = <<<
- // This file contains code for hashing and mining on OpenCL hardware
- typedef uchar byte;
- // macro so i can change it later
- #define mult_add(a,b,c) (a * b + c)
- // right rotate macro
- #define RR(X, Y) rotate((uint)X, -((uint)Y))
- // optimized padding macro
- // takes a character array and integer
- // character array is used as both input and output
- // character array should be 64 items long regardless of content
- // actual input present in character array should not exceed 55 items
- // second argument should be the length of the input content
- // example usage:
- // char data[64];
- // data[0] = 'h';
- // data[1] = 'e';
- // data[2] = 'l';
- // data[3] = 'l';
- // data[4] = 'o';
- // PAD(data, 5);
- // // data array now contains 'hello' padded
- #define PAD(X, Y) X[63] = Y * 8; X[62] = Y >> 5; X[Y] = 0x80;
- // SHA256 macros
- #define CH(x,y,z) bitselect(z,y,x)
- #define MAJ(x,y,z) bitselect(x,y,z^x)
- #define EP0(x) (RR(x,2) ^ RR(x,13) ^ RR(x,22))
- #define EP1(x) (RR(x,6) ^ RR(x,11) ^ RR(x,25))
- #define SIG0(x) (RR(x,7) ^ RR(x,18) ^ ((x) >> 3))
- #define SIG1(x) (RR(x,17) ^ RR(x,19) ^ ((x) >> 10))
- __constant uint K[64] = {
- 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
- 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
- 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
- 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
- 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
- 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
- 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
- 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2};
- // SHA256 digest function - optimization pending
- // takes a byte array of size 64 with 55 or fewer items, and writes
- // hash to 32 item byte array.
- // make sure to pass the input size as the second argument.
- // example usage:
- // char data[64];
- // char hash[32];
- // data[0] = 'h';
- // data[1] = 'e';
- // data[2] = 'l';
- // data[3] = 'l';
- // data[4] = 'o';
- // digest(data, 5, hash);
- // // hash array now contains hash of 'hello'
- void digest(byte* data, uint inputLen, byte* hash) {
- /* init vars */
- uint h0, h1, h2, h3, h4, h5, h6, h7;
- uint a, b, c, d, e, f, g, h, i, j, l, t1, t2, m[64] = {0};
- PAD(data, inputLen);
- /* init hash state */
- h0 = 0x6a09e667;
- h1 = 0xbb67ae85;
- h2 = 0x3c6ef372;
- h3 = 0xa54ff53a;
- h4 = 0x510e527f;
- h5 = 0x9b05688c;
- h6 = 0x1f83d9ab;
- h7 = 0x5be0cd19;
- /* transform */
- #pragma unroll
- for (i = 0; i < 16; i++)
- 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)]);
- #pragma unroll
- for (i = 16; i < 64; ++i)
- m[i] = SIG1(m[i - 2]) + m[i - 7] + SIG0(m[i - 15]) + m[i - 16];
- a = h0;
- b = h1;
- c = h2;
- d = h3;
- e = h4;
- f = h5;
- g = h6;
- h = h7;
- #pragma unroll
- for (i = 0; i < 64; ++i) {
- t1 = h + EP1(e) + CH(e,f,g) + K[i] + m[i];
- t2 = EP0(a) + MAJ(a,b,c);
- h = g;
- g = f;
- f = e;
- e = d + t1;
- d = c;
- c = b;
- b = a;
- a = t1 + t2;
- }
- h0 += a;
- h1 += b;
- // only first 2 hash values needed.
- h2 += c;
- h3 += d;
- h4 += e;
- h5 += f;
- h6 += g;
- h7 += h;
- /* finish */
- #pragma unroll
- for (i = 0; i < 4; ++i) {
- l = mult_add(i, -8, 24);
- hash[i] = (h0 >> l) & 0x000000ff;
- hash[i + 4] = (h1 >> l) & 0x000000ff;
- // only the first 6 bytes are needed.
- hash[i + 8] = (h2 >> l) & 0x000000ff;
- hash[i + 12] = (h3 >> l) & 0x000000ff;
- hash[i + 16] = (h4 >> l) & 0x000000ff;
- hash[i + 20] = (h5 >> l) & 0x000000ff;
- hash[i + 24] = (h6 >> l) & 0x000000ff;
- hash[i + 28] = (h7 >> l) & 0x000000ff;
- }
- }
- long hashToLong(byte* hash) {
- return hash[5] + (hash[4] << 8) + (hash[3] << 16) + ((long)hash[2] << 24) + ((long) hash[1] << 32) + ((long) hash[0] << 40);
- }
- // converts one long into 12 hex characters
- void longToHex(long in, byte* hex, int offset) {
- #pragma unroll
- for (int i = offset; i < 34; i++) {
- hex[i] = (in >> ((i - offset) * 5) & 31) + 48;
- }
- }
- __kernel void krist_miner_basic(
- __global const byte* address, // 10 chars
- __global const byte* block, // 12 chars
- __global const byte* prefix, // 2 chars
- const long base, // convert to 10 chars
- const long work,
- __global byte* output) {
- int id = get_global_id(0);
- long nonce = id + base;
- byte input[64];
- byte hashed[32];
- #pragma unroll
- for (int i = 0; i < 10; i++) {
- input[i] = address[i];
- }
- #pragma unroll
- for (int i = 10; i < 22; i++) {
- input[i] = block[i - 10];
- }
- #pragma unroll
- for (int i = 22; i < 24; i++) {
- input[i] = prefix[i-22];
- }
- #pragma unroll
- for (int i = 24; i < 34; i++) {
- input[i] = ((nonce >> ((i - 24) * 5)) & 31) + 48;
- }
- digest(input, 34, hashed);
- long score = hashToLong(hashed);
- if (score < work) {
- #pragma unroll
- for (int i = 0; i < 10; i++) {
- output[i] = address[i];
- }
- #pragma unroll
- for (int i = 10; i < 22; i++) {
- output[i] = block[i - 10];
- }
- #pragma unroll
- for (int i = 22; i < 24; i++) {
- output[i] = prefix[i-22];
- }
- #pragma unroll
- for (int i = 24; i < 34; i++) {
- output[i] = ((nonce >> ((i - 24) * 5)) & 31) + 48;
- }
- }
- }
- >>> ) (make sure to log all errors with environment variable CL_LOG_ERRORS=stdout)
- at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
- at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
- at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
- at java.lang.reflect.Constructor.newInstance(Unknown Source)
- at java.lang.Class.newInstance(Unknown Source)
- at com.nativelibs4java.opencl.CLException.error(CLException.java:302)
- at com.nativelibs4java.opencl.CLKernel.setKernelArg(CLKernel.java:273)
- at com.nativelibs4java.opencl.CLKernel.setArg(CLKernel.java:406)
- at com.nativelibs4java.opencl.CLKernel.setObjectArg(CLKernel.java:201)
- at com.nativelibs4java.opencl.CLKernel.setArgs(CLKernel.java:191)
- at me.apemanzilla.jclminer.miners.GPUMiner.run(GPUMiner.java:142)
- at java.lang.Thread.run(Unknown Source)
- 10.74 MH/s
- 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 = <<<
- // This file contains code for hashing and mining on OpenCL hardware
- typedef uchar byte;
- // macro so i can change it later
- #define mult_add(a,b,c) (a * b + c)
- // right rotate macro
- #define RR(X, Y) rotate((uint)X, -((uint)Y))
- // optimized padding macro
- // takes a character array and integer
- // character array is used as both input and output
- // character array should be 64 items long regardless of content
- // actual input present in character array should not exceed 55 items
- // second argument should be the length of the input content
- // example usage:
- // char data[64];
- // data[0] = 'h';
- // data[1] = 'e';
- // data[2] = 'l';
- // data[3] = 'l';
- // data[4] = 'o';
- // PAD(data, 5);
- // // data array now contains 'hello' padded
- #define PAD(X, Y) X[63] = Y * 8; X[62] = Y >> 5; X[Y] = 0x80;
- // SHA256 macros
- #define CH(x,y,z) bitselect(z,y,x)
- #define MAJ(x,y,z) bitselect(x,y,z^x)
- #define EP0(x) (RR(x,2) ^ RR(x,13) ^ RR(x,22))
- #define EP1(x) (RR(x,6) ^ RR(x,11) ^ RR(x,25))
- #define SIG0(x) (RR(x,7) ^ RR(x,18) ^ ((x) >> 3))
- #define SIG1(x) (RR(x,17) ^ RR(x,19) ^ ((x) >> 10))
- __constant uint K[64] = {
- 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
- 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
- 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
- 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
- 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
- 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
- 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
- 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2};
- // SHA256 digest function - optimization pending
- // takes a byte array of size 64 with 55 or fewer items, and writes
- // hash to 32 item byte array.
- // make sure to pass the input size as the second argument.
- // example usage:
- // char data[64];
- // char hash[32];
- // data[0] = 'h';
- // data[1] = 'e';
- // data[2] = 'l';
- // data[3] = 'l';
- // data[4] = 'o';
- // digest(data, 5, hash);
- // // hash array now contains hash of 'hello'
- void digest(byte* data, uint inputLen, byte* hash) {
- /* init vars */
- uint h0, h1, h2, h3, h4, h5, h6, h7;
- uint a, b, c, d, e, f, g, h, i, j, l, t1, t2, m[64] = {0};
- PAD(data, inputLen);
- /* init hash state */
- h0 = 0x6a09e667;
- h1 = 0xbb67ae85;
- h2 = 0x3c6ef372;
- h3 = 0xa54ff53a;
- h4 = 0x510e527f;
- h5 = 0x9b05688c;
- h6 = 0x1f83d9ab;
- h7 = 0x5be0cd19;
- /* transform */
- #pragma unroll
- for (i = 0; i < 16; i++)
- 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)]);
- #pragma unroll
- for (i = 16; i < 64; ++i)
- m[i] = SIG1(m[i - 2]) + m[i - 7] + SIG0(m[i - 15]) + m[i - 16];
- a = h0;
- b = h1;
- c = h2;
- d = h3;
- e = h4;
- f = h5;
- g = h6;
- h = h7;
- #pragma unroll
- for (i = 0; i < 64; ++i) {
- t1 = h + EP1(e) + CH(e,f,g) + K[i] + m[i];
- t2 = EP0(a) + MAJ(a,b,c);
- h = g;
- g = f;
- f = e;
- e = d + t1;
- d = c;
- c = b;
- b = a;
- a = t1 + t2;
- }
- h0 += a;
- h1 += b;
- // only first 2 hash values needed.
- h2 += c;
- h3 += d;
- h4 += e;
- h5 += f;
- h6 += g;
- h7 += h;
- /* finish */
- #pragma unroll
- for (i = 0; i < 4; ++i) {
- l = mult_add(i, -8, 24);
- hash[i] = (h0 >> l) & 0x000000ff;
- hash[i + 4] = (h1 >> l) & 0x000000ff;
- // only the first 6 bytes are needed.
- hash[i + 8] = (h2 >> l) & 0x000000ff;
- hash[i + 12] = (h3 >> l) & 0x000000ff;
- hash[i + 16] = (h4 >> l) & 0x000000ff;
- hash[i + 20] = (h5 >> l) & 0x000000ff;
- hash[i + 24] = (h6 >> l) & 0x000000ff;
- hash[i + 28] = (h7 >> l) & 0x000000ff;
- }
- }
- long hashToLong(byte* hash) {
- return hash[5] + (hash[4] << 8) + (hash[3] << 16) + ((long)hash[2] << 24) + ((long) hash[1] << 32) + ((long) hash[0] << 40);
- }
- // converts one long into 12 hex characters
- void longToHex(long in, byte* hex, int offset) {
- #pragma unroll
- for (int i = offset; i < 34; i++) {
- hex[i] = (in >> ((i - offset) * 5) & 31) + 48;
- }
- }
- __kernel void krist_miner_basic(
- __global const byte* address, // 10 chars
- __global const byte* block, // 12 chars
- __global const byte* prefix, // 2 chars
- const long base, // convert to 10 chars
- const long work,
- __global byte* output) {
- int id = get_global_id(0);
- long nonce = id + base;
- byte input[64];
- byte hashed[32];
- #pragma unroll
- for (int i = 0; i < 10; i++) {
- input[i] = address[i];
- }
- #pragma unroll
- for (int i = 10; i < 22; i++) {
- input[i] = block[i - 10];
- }
- #pragma unroll
- for (int i = 22; i < 24; i++) {
- input[i] = prefix[i-22];
- }
- #pragma unroll
- for (int i = 24; i < 34; i++) {
- input[i] = ((nonce >> ((i - 24) * 5)) & 31) + 48;
- }
- digest(input, 34, hashed);
- long score = hashToLong(hashed);
- if (score < work) {
- #pragma unroll
- for (int i = 0; i < 10; i++) {
- output[i] = address[i];
- }
- #pragma unroll
- for (int i = 10; i < 22; i++) {
- output[i] = block[i - 10];
- }
- #pragma unroll
- for (int i = 22; i < 24; i++) {
- output[i] = prefix[i-22];
- }
- #pragma unroll
- for (int i = 24; i < 34; i++) {
- output[i] = ((nonce >> ((i - 24) * 5)) & 31) + 48;
- }
- }
- }
- >>> ) (make sure to log all errors with environment variable CL_LOG_ERRORS=stdout)
- at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
- at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
- at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
- at java.lang.reflect.Constructor.newInstance(Unknown Source)
- at java.lang.Class.newInstance(Unknown Source)
- at com.nativelibs4java.opencl.CLException.error(CLException.java:302)
- at com.nativelibs4java.opencl.CLKernel.setKernelArg(CLKernel.java:273)
- at com.nativelibs4java.opencl.CLKernel.setArg(CLKernel.java:406)
- at com.nativelibs4java.opencl.CLKernel.setObjectArg(CLKernel.java:201)
- at com.nativelibs4java.opencl.CLKernel.setArgs(CLKernel.java:191)
- at me.apemanzilla.jclminer.miners.GPUMiner.run(GPUMiner.java:142)
- at java.lang.Thread.run(Unknown Source)
- 10.92 MH/s
- 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 = <<<
- // This file contains code for hashing and mining on OpenCL hardware
- typedef uchar byte;
- // macro so i can change it later
- #define mult_add(a,b,c) (a * b + c)
- // right rotate macro
- #define RR(X, Y) rotate((uint)X, -((uint)Y))
- // optimized padding macro
- // takes a character array and integer
- // character array is used as both input and output
- // character array should be 64 items long regardless of content
- // actual input present in character array should not exceed 55 items
- // second argument should be the length of the input content
- // example usage:
- // char data[64];
- // data[0] = 'h';
- // data[1] = 'e';
- // data[2] = 'l';
- // data[3] = 'l';
- // data[4] = 'o';
- // PAD(data, 5);
- // // data array now contains 'hello' padded
- #define PAD(X, Y) X[63] = Y * 8; X[62] = Y >> 5; X[Y] = 0x80;
- // SHA256 macros
- #define CH(x,y,z) bitselect(z,y,x)
- #define MAJ(x,y,z) bitselect(x,y,z^x)
- #define EP0(x) (RR(x,2) ^ RR(x,13) ^ RR(x,22))
- #define EP1(x) (RR(x,6) ^ RR(x,11) ^ RR(x,25))
- #define SIG0(x) (RR(x,7) ^ RR(x,18) ^ ((x) >> 3))
- #define SIG1(x) (RR(x,17) ^ RR(x,19) ^ ((x) >> 10))
- __constant uint K[64] = {
- 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
- 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
- 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
- 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
- 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
- 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
- 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
- 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2};
- // SHA256 digest function - optimization pending
- // takes a byte array of size 64 with 55 or fewer items, and writes
- // hash to 32 item byte array.
- // make sure to pass the input size as the second argument.
- // example usage:
- // char data[64];
- // char hash[32];
- // data[0] = 'h';
- // data[1] = 'e';
- // data[2] = 'l';
- // data[3] = 'l';
- // data[4] = 'o';
- // digest(data, 5, hash);
- // // hash array now contains hash of 'hello'
- void digest(byte* data, uint inputLen, byte* hash) {
- /* init vars */
- uint h0, h1, h2, h3, h4, h5, h6, h7;
- uint a, b, c, d, e, f, g, h, i, j, l, t1, t2, m[64] = {0};
- PAD(data, inputLen);
- /* init hash state */
- h0 = 0x6a09e667;
- h1 = 0xbb67ae85;
- h2 = 0x3c6ef372;
- h3 = 0xa54ff53a;
- h4 = 0x510e527f;
- h5 = 0x9b05688c;
- h6 = 0x1f83d9ab;
- h7 = 0x5be0cd19;
- /* transform */
- #pragma unroll
- for (i = 0; i < 16; i++)
- 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)]);
- #pragma unroll
- for (i = 16; i < 64; ++i)
- m[i] = SIG1(m[i - 2]) + m[i - 7] + SIG0(m[i - 15]) + m[i - 16];
- a = h0;
- b = h1;
- c = h2;
- d = h3;
- e = h4;
- f = h5;
- g = h6;
- h = h7;
- #pragma unroll
- for (i = 0; i < 64; ++i) {
- t1 = h + EP1(e) + CH(e,f,g) + K[i] + m[i];
- t2 = EP0(a) + MAJ(a,b,c);
- h = g;
- g = f;
- f = e;
- e = d + t1;
- d = c;
- c = b;
- b = a;
- a = t1 + t2;
- }
- h0 += a;
- h1 += b;
- // only first 2 hash values needed.
- h2 += c;
- h3 += d;
- h4 += e;
- h5 += f;
- h6 += g;
- h7 += h;
- /* finish */
- #pragma unroll
- for (i = 0; i < 4; ++i) {
- l = mult_add(i, -8, 24);
- hash[i] = (h0 >> l) & 0x000000ff;
- hash[i + 4] = (h1 >> l) & 0x000000ff;
- // only the first 6 bytes are needed.
- hash[i + 8] = (h2 >> l) & 0x000000ff;
- hash[i + 12] = (h3 >> l) & 0x000000ff;
- hash[i + 16] = (h4 >> l) & 0x000000ff;
- hash[i + 20] = (h5 >> l) & 0x000000ff;
- hash[i + 24] = (h6 >> l) & 0x000000ff;
- hash[i + 28] = (h7 >> l) & 0x000000ff;
- }
- }
- long hashToLong(byte* hash) {
- return hash[5] + (hash[4] << 8) + (hash[3] << 16) + ((long)hash[2] << 24) + ((long) hash[1] << 32) + ((long) hash[0] << 40);
- }
- // converts one long into 12 hex characters
- void longToHex(long in, byte* hex, int offset) {
- #pragma unroll
- for (int i = offset; i < 34; i++) {
- hex[i] = (in >> ((i - offset) * 5) & 31) + 48;
- }
- }
- __kernel void krist_miner_basic(
- __global const byte* address, // 10 chars
- __global const byte* block, // 12 chars
- __global const byte* prefix, // 2 chars
- const long base, // convert to 10 chars
- const long work,
- __global byte* output) {
- int id = get_global_id(0);
- long nonce = id + base;
- byte input[64];
- byte hashed[32];
- #pragma unroll
- for (int i = 0; i < 10; i++) {
- input[i] = address[i];
- }
- #pragma unroll
- for (int i = 10; i < 22; i++) {
- input[i] = block[i - 10];
- }
- #pragma unroll
- for (int i = 22; i < 24; i++) {
- input[i] = prefix[i-22];
- }
- #pragma unroll
- for (int i = 24; i < 34; i++) {
- input[i] = ((nonce >> ((i - 24) * 5)) & 31) + 48;
- }
- digest(input, 34, hashed);
- long score = hashToLong(hashed);
- if (score < work) {
- #pragma unroll
- for (int i = 0; i < 10; i++) {
- output[i] = address[i];
- }
- #pragma unroll
- for (int i = 10; i < 22; i++) {
- output[i] = block[i - 10];
- }
- #pragma unroll
- for (int i = 22; i < 24; i++) {
- output[i] = prefix[i-22];
- }
- #pragma unroll
- for (int i = 24; i < 34; i++) {
- output[i] = ((nonce >> ((i - 24) * 5)) & 31) + 48;
- }
- }
- }
- >>> ) (make sure to log all errors with environment variable CL_LOG_ERRORS=stdout)
- at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
- at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
- at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
- at java.lang.reflect.Constructor.newInstance(Unknown Source)
- at java.lang.Class.newInstance(Unknown Source)
- at com.nativelibs4java.opencl.CLException.error(CLException.java:302)
- at com.nativelibs4java.opencl.CLKernel.setKernelArg(CLKernel.java:273)
- at com.nativelibs4java.opencl.CLKernel.setArg(CLKernel.java:406)
- at com.nativelibs4java.opencl.CLKernel.setObjectArg(CLKernel.java:201)
- at com.nativelibs4java.opencl.CLKernel.setArgs(CLKernel.java:191)
- at me.apemanzilla.jclminer.miners.GPUMiner.run(GPUMiner.java:142)
- at java.lang.Thread.run(Unknown Source)
- 12.90 MH/s
- Test #12 > 13.16 MH/s
- 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 = <<<
- // This file contains code for hashing and mining on OpenCL hardware
- typedef uchar byte;
- // macro so i can change it later
- #define mult_add(a,b,c) (a * b + c)
- // right rotate macro
- #define RR(X, Y) rotate((uint)X, -((uint)Y))
- // optimized padding macro
- // takes a character array and integer
- // character array is used as both input and output
- // character array should be 64 items long regardless of content
- // actual input present in character array should not exceed 55 items
- // second argument should be the length of the input content
- // example usage:
- // char data[64];
- // data[0] = 'h';
- // data[1] = 'e';
- // data[2] = 'l';
- // data[3] = 'l';
- // data[4] = 'o';
- // PAD(data, 5);
- // // data array now contains 'hello' padded
- #define PAD(X, Y) X[63] = Y * 8; X[62] = Y >> 5; X[Y] = 0x80;
- // SHA256 macros
- #define CH(x,y,z) bitselect(z,y,x)
- #define MAJ(x,y,z) bitselect(x,y,z^x)
- #define EP0(x) (RR(x,2) ^ RR(x,13) ^ RR(x,22))
- #define EP1(x) (RR(x,6) ^ RR(x,11) ^ RR(x,25))
- #define SIG0(x) (RR(x,7) ^ RR(x,18) ^ ((x) >> 3))
- #define SIG1(x) (RR(x,17) ^ RR(x,19) ^ ((x) >> 10))
- __constant uint K[64] = {
- 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
- 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
- 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
- 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
- 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
- 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
- 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
- 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2};
- // SHA256 digest function - optimization pending
- // takes a byte array of size 64 with 55 or fewer items, and writes
- // hash to 32 item byte array.
- // make sure to pass the input size as the second argument.
- // example usage:
- // char data[64];
- // char hash[32];
- // data[0] = 'h';
- // data[1] = 'e';
- // data[2] = 'l';
- // data[3] = 'l';
- // data[4] = 'o';
- // digest(data, 5, hash);
- // // hash array now contains hash of 'hello'
- void digest(byte* data, uint inputLen, byte* hash) {
- /* init vars */
- uint h0, h1, h2, h3, h4, h5, h6, h7;
- uint a, b, c, d, e, f, g, h, i, j, l, t1, t2, m[64] = {0};
- PAD(data, inputLen);
- /* init hash state */
- h0 = 0x6a09e667;
- h1 = 0xbb67ae85;
- h2 = 0x3c6ef372;
- h3 = 0xa54ff53a;
- h4 = 0x510e527f;
- h5 = 0x9b05688c;
- h6 = 0x1f83d9ab;
- h7 = 0x5be0cd19;
- /* transform */
- #pragma unroll
- for (i = 0; i < 16; i++)
- 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)]);
- #pragma unroll
- for (i = 16; i < 64; ++i)
- m[i] = SIG1(m[i - 2]) + m[i - 7] + SIG0(m[i - 15]) + m[i - 16];
- a = h0;
- b = h1;
- c = h2;
- d = h3;
- e = h4;
- f = h5;
- g = h6;
- h = h7;
- #pragma unroll
- for (i = 0; i < 64; ++i) {
- t1 = h + EP1(e) + CH(e,f,g) + K[i] + m[i];
- t2 = EP0(a) + MAJ(a,b,c);
- h = g;
- g = f;
- f = e;
- e = d + t1;
- d = c;
- c = b;
- b = a;
- a = t1 + t2;
- }
- h0 += a;
- h1 += b;
- // only first 2 hash values needed.
- h2 += c;
- h3 += d;
- h4 += e;
- h5 += f;
- h6 += g;
- h7 += h;
- /* finish */
- #pragma unroll
- for (i = 0; i < 4; ++i) {
- l = mult_add(i, -8, 24);
- hash[i] = (h0 >> l) & 0x000000ff;
- hash[i + 4] = (h1 >> l) & 0x000000ff;
- // only the first 6 bytes are needed.
- hash[i + 8] = (h2 >> l) & 0x000000ff;
- hash[i + 12] = (h3 >> l) & 0x000000ff;
- hash[i + 16] = (h4 >> l) & 0x000000ff;
- hash[i + 20] = (h5 >> l) & 0x000000ff;
- hash[i + 24] = (h6 >> l) & 0x000000ff;
- hash[i + 28] = (h7 >> l) & 0x000000ff;
- }
- }
- long hashToLong(byte* hash) {
- return hash[5] + (hash[4] << 8) + (hash[3] << 16) + ((long)hash[2] << 24) + ((long) hash[1] << 32) + ((long) hash[0] << 40);
- }
- // converts one long into 12 hex characters
- void longToHex(long in, byte* hex, int offset) {
- #pragma unroll
- for (int i = offset; i < 34; i++) {
- hex[i] = (in >> ((i - offset) * 5) & 31) + 48;
- }
- }
- __kernel void krist_miner_basic(
- __global const byte* address, // 10 chars
- __global const byte* block, // 12 chars
- __global const byte* prefix, // 2 chars
- const long base, // convert to 10 chars
- const long work,
- __global byte* output) {
- int id = get_global_id(0);
- long nonce = id + base;
- byte input[64];
- byte hashed[32];
- #pragma unroll
- for (int i = 0; i < 10; i++) {
- input[i] = address[i];
- }
- #pragma unroll
- for (int i = 10; i < 22; i++) {
- input[i] = block[i - 10];
- }
- #pragma unroll
- for (int i = 22; i < 24; i++) {
- input[i] = prefix[i-22];
- }
- #pragma unroll
- for (int i = 24; i < 34; i++) {
- input[i] = ((nonce >> ((i - 24) * 5)) & 31) + 48;
- }
- digest(input, 34, hashed);
- long score = hashToLong(hashed);
- if (score < work) {
- #pragma unroll
- for (int i = 0; i < 10; i++) {
- output[i] = address[i];
- }
- #pragma unroll
- for (int i = 10; i < 22; i++) {
- output[i] = block[i - 10];
- }
- #pragma unroll
- for (int i = 22; i < 24; i++) {
- output[i] = prefix[i-22];
- }
- #pragma unroll
- for (int i = 24; i < 34; i++) {
- output[i] = ((nonce >> ((i - 24) * 5)) & 31) + 48;
- }
- }
- }
- >>> ) (make sure to log all errors with environment variable CL_LOG_ERRORS=stdout)
- at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
- at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
- at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
- at java.lang.reflect.Constructor.newInstance(Unknown Source)
- at java.lang.Class.newInstance(Unknown Source)
- at com.nativelibs4java.opencl.CLException.error(CLException.java:302)
- at com.nativelibs4java.opencl.CLKernel.setKernelArg(CLKernel.java:273)
- at com.nativelibs4java.opencl.CLKernel.setArg(CLKernel.java:406)
- at com.nativelibs4java.opencl.CLKernel.setObjectArg(CLKernel.java:201)
- at com.nativelibs4java.opencl.CLKernel.setArgs(CLKernel.java:191)
- at me.apemanzilla.jclminer.miners.GPUMiner.run(GPUMiner.java:142)
- at java.lang.Thread.run(Unknown Source)
- 13.21 MH/s
- Test #14 > 13.11 MH/s
- Performance decrease - stopping tests.
- Profiling complete! Use the following launch arguments for optimal performance:
- -a -d 513176346:1048576;
- C:\Users\Jaden\Downloads\JCLMiner\bin>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement