2019-08-28 00:33:49 +07:00
|
|
|
#!/usr/bin/env node
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const fs = require('fs');
|
|
|
|
const path = require('path');
|
2019-09-03 14:36:27 +07:00
|
|
|
const { text2h, text2h_bundle, addIncludes } = require('./js/opencl');
|
2019-09-12 18:50:35 +07:00
|
|
|
const { opencl_minify } = require('./js/opencl_minify');
|
2019-09-08 21:56:18 +07:00
|
|
|
const cwd = process.cwd();
|
2019-08-28 00:33:49 +07:00
|
|
|
|
|
|
|
|
|
|
|
function cn()
|
|
|
|
{
|
2019-09-12 18:50:35 +07:00
|
|
|
const cn = opencl_minify(addIncludes('cryptonight.cl', [
|
2019-08-28 00:33:49 +07:00
|
|
|
'algorithm.cl',
|
|
|
|
'wolf-aes.cl',
|
|
|
|
'wolf-skein.cl',
|
|
|
|
'jh.cl',
|
|
|
|
'blake256.cl',
|
|
|
|
'groestl256.cl',
|
|
|
|
'fast_int_math_v2.cl',
|
2019-09-01 08:49:28 +07:00
|
|
|
'fast_div_heavy.cl',
|
|
|
|
'keccak.cl'
|
2019-09-12 18:50:35 +07:00
|
|
|
]));
|
2019-08-28 00:33:49 +07:00
|
|
|
|
2019-09-12 18:50:35 +07:00
|
|
|
// fs.writeFileSync('cryptonight_gen.cl', cn);
|
2019-08-28 00:33:49 +07:00
|
|
|
fs.writeFileSync('cryptonight_cl.h', text2h(cn, 'xmrig', 'cryptonight_cl'));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-09-03 14:36:27 +07:00
|
|
|
function cn_r()
|
|
|
|
{
|
|
|
|
const items = {};
|
|
|
|
|
2019-09-12 18:50:35 +07:00
|
|
|
items.cryptonight_r_defines_cl = opencl_minify(addIncludes('cryptonight_r_defines.cl', [ 'wolf-aes.cl' ]));
|
|
|
|
items.cryptonight_r_cl = opencl_minify(fs.readFileSync('cryptonight_r.cl', 'utf8'));
|
2019-09-03 14:36:27 +07:00
|
|
|
|
|
|
|
// for (let key in items) {
|
2019-09-12 18:50:35 +07:00
|
|
|
// fs.writeFileSync(key + '_gen.cl', items[key]);
|
2019-09-03 14:36:27 +07:00
|
|
|
// }
|
|
|
|
|
|
|
|
fs.writeFileSync('cryptonight_r_cl.h', text2h_bundle('xmrig', items));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-09-08 21:56:18 +07:00
|
|
|
function rx()
|
|
|
|
{
|
|
|
|
let rx = addIncludes('randomx.cl', [
|
|
|
|
'../cn/algorithm.cl',
|
|
|
|
'randomx_constants_monero.h',
|
|
|
|
'randomx_constants_wow.h',
|
2019-10-08 19:00:19 +02:00
|
|
|
'randomx_constants_arqma.h',
|
2021-08-27 08:19:54 -06:00
|
|
|
'randomx_constants_graft.h',
|
2019-09-08 21:56:18 +07:00
|
|
|
'aes.cl',
|
|
|
|
'blake2b.cl',
|
|
|
|
'randomx_vm.cl',
|
|
|
|
'randomx_jit.cl'
|
|
|
|
]);
|
|
|
|
|
2019-09-11 15:48:02 +07:00
|
|
|
rx = rx.replace(/(\t| )*#include "fillAes1Rx4.cl"/g, fs.readFileSync('fillAes1Rx4.cl', 'utf8'));
|
|
|
|
rx = rx.replace(/(\t| )*#include "blake2b_double_block.cl"/g, fs.readFileSync('blake2b_double_block.cl', 'utf8'));
|
2019-09-12 18:50:35 +07:00
|
|
|
rx = opencl_minify(rx);
|
2019-09-08 21:56:18 +07:00
|
|
|
|
|
|
|
//fs.writeFileSync('randomx_gen.cl', rx);
|
|
|
|
fs.writeFileSync('randomx_cl.h', text2h(rx, 'xmrig', 'randomx_cl'));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-05-24 23:57:41 +02:00
|
|
|
function kawpow()
|
|
|
|
{
|
|
|
|
const kawpow = opencl_minify(addIncludes('kawpow.cl', [ 'defs.h' ]));
|
|
|
|
const kawpow_dag = opencl_minify(addIncludes('kawpow_dag.cl', [ 'defs.h' ]));
|
|
|
|
|
|
|
|
// fs.writeFileSync('kawpow_gen.cl', kawpow);
|
|
|
|
fs.writeFileSync('kawpow_cl.h', text2h(kawpow, 'xmrig', 'kawpow_cl'));
|
|
|
|
fs.writeFileSync('kawpow_dag_cl.h', text2h(kawpow_dag, 'xmrig', 'kawpow_dag_cl'));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-09-03 14:36:27 +07:00
|
|
|
process.chdir(path.resolve('src/backend/opencl/cl/cn'));
|
|
|
|
|
|
|
|
cn();
|
2019-09-08 08:59:17 +07:00
|
|
|
cn_r();
|
2019-09-08 21:56:18 +07:00
|
|
|
|
|
|
|
process.chdir(cwd);
|
|
|
|
process.chdir(path.resolve('src/backend/opencl/cl/rx'));
|
|
|
|
|
2020-03-22 22:36:21 +01:00
|
|
|
rx();
|
|
|
|
|
2020-05-24 23:57:41 +02:00
|
|
|
process.chdir(cwd);
|
|
|
|
process.chdir(path.resolve('src/backend/opencl/cl/kawpow'));
|
|
|
|
|
|
|
|
kawpow();
|