xmrig/scripts/generate_cl.js

109 lines
2.8 KiB
JavaScript
Raw Normal View History

#!/usr/bin/env node
'use strict';
const fs = require('fs');
const path = require('path');
2019-09-03 07:36:27 +00:00
const { text2h, text2h_bundle, addIncludes } = require('./js/opencl');
2019-09-12 11:50:35 +00:00
const { opencl_minify } = require('./js/opencl_minify');
const cwd = process.cwd();
function cn()
{
2019-09-12 11:50:35 +00:00
const cn = opencl_minify(addIncludes('cryptonight.cl', [
'algorithm.cl',
'wolf-aes.cl',
'wolf-skein.cl',
'jh.cl',
'blake256.cl',
'groestl256.cl',
'fast_int_math_v2.cl',
2019-09-01 01:49:28 +00:00
'fast_div_heavy.cl',
'keccak.cl'
2019-09-12 11:50:35 +00:00
]));
2019-09-12 11:50:35 +00:00
// fs.writeFileSync('cryptonight_gen.cl', cn);
fs.writeFileSync('cryptonight_cl.h', text2h(cn, 'xmrig', 'cryptonight_cl'));
}
2019-09-03 07:36:27 +00:00
function cn_r()
{
const items = {};
2019-09-12 11:50:35 +00: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 07:36:27 +00:00
// for (let key in items) {
2019-09-12 11:50:35 +00:00
// fs.writeFileSync(key + '_gen.cl', items[key]);
2019-09-03 07:36:27 +00:00
// }
fs.writeFileSync('cryptonight_r_cl.h', text2h_bundle('xmrig', items));
}
function rx()
{
let rx = addIncludes('randomx.cl', [
'../cn/algorithm.cl',
'randomx_constants_monero.h',
'randomx_constants_wow.h',
2019-10-08 17:00:19 +00:00
'randomx_constants_arqma.h',
2020-03-03 02:37:43 +00:00
'randomx_constants_keva.h',
2021-08-27 14:19:54 +00:00
'randomx_constants_graft.h',
'aes.cl',
'blake2b.cl',
'randomx_vm.cl',
'randomx_jit.cl'
]);
2019-09-11 08:48:02 +00: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 11:50:35 +00:00
rx = opencl_minify(rx);
//fs.writeFileSync('randomx_gen.cl', rx);
fs.writeFileSync('randomx_cl.h', text2h(rx, 'xmrig', 'randomx_cl'));
}
2020-03-22 21:36:21 +00:00
function astrobwt()
{
const astrobwt = opencl_minify(addIncludes('astrobwt.cl', [ 'BWT.cl', 'salsa20.cl', 'sha3.cl' ]));
// fs.writeFileSync('astrobwt_gen.cl', astrobwt);
fs.writeFileSync('astrobwt_cl.h', text2h(astrobwt, 'xmrig', 'astrobwt_cl'));
}
2020-05-24 21:57:41 +00: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 07:36:27 +00:00
process.chdir(path.resolve('src/backend/opencl/cl/cn'));
cn();
2019-09-08 01:59:17 +00:00
cn_r();
process.chdir(cwd);
process.chdir(path.resolve('src/backend/opencl/cl/rx'));
2020-03-22 21:36:21 +00:00
rx();
process.chdir(cwd);
process.chdir(path.resolve('src/backend/opencl/cl/astrobwt'));
astrobwt();
2020-05-24 21:57:41 +00:00
process.chdir(cwd);
process.chdir(path.resolve('src/backend/opencl/cl/kawpow'));
kawpow();