Skip to content

Commit 41b51a4

Browse files
committedApr 21, 2019
Cleaned up legacy code
1 parent 360c8ed commit 41b51a4

16 files changed

+6
-657
lines changed
 

Diff for: ‎src/allocator.cpp

+2-6
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ You should have received a copy of the GNU General Public License
1717
along with RandomX. If not, see<http://www.gnu.org/licenses/>.
1818
*/
1919

20-
#pragma once
21-
2220
#include "allocator.hpp"
2321
#include "intrin_portable.h"
2422
#include "virtual_memory.hpp"
@@ -36,10 +34,8 @@ namespace randomx {
3634
_mm_free(ptr);
3735
}
3836

39-
template void* AlignedAllocator<CacheLineSize>::allocMemory(size_t count);
40-
template void AlignedAllocator<CacheLineSize>::freeMemory(void* ptr, size_t count);
41-
template void* AlignedAllocator<sizeof(__m128i)>::allocMemory(size_t count);
42-
template void AlignedAllocator<sizeof(__m128i)>::freeMemory(void* ptr, size_t count);
37+
template class AlignedAllocator<CacheLineSize>;
38+
template class AlignedAllocator<sizeof(__m128i)>;;
4339

4440
void* LargePageAllocator::allocMemory(size_t count) {
4541
return allocLargePagesMemory(count);

Diff for: ‎src/asm/initBlock.inc

-155
This file was deleted.

Diff for: ‎src/asm/program_prologue_load.inc

-21
This file was deleted.

Diff for: ‎src/asm/program_read_dataset_light_sub.inc

-171
This file was deleted.

Diff for: ‎src/asm/squareHash.inc

-87
This file was deleted.

Diff for: ‎src/common.hpp

+2-5
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ namespace randomx {
3030
static_assert((RANDOMX_ARGON_MEMORY & (RANDOMX_ARGON_MEMORY - 1)) == 0, "RANDOMX_ARGON_MEMORY must be a power of 2.");
3131
static_assert((RANDOMX_DATASET_SIZE & (RANDOMX_DATASET_SIZE - 1)) == 0, "RANDOMX_DATASET_SIZE must be a power of 2.");
3232
static_assert(RANDOMX_DATASET_SIZE <= 4294967296ULL, "RANDOMX_DATASET_SIZE must not exceed 4294967296.");
33-
static_assert(RANDOMX_DS_GROWTH % 64 == 0, "RANDOMX_DS_GROWTH must be divisible by 64.");
34-
static_assert(RANDOMX_ARGON_GROWTH >= 0, "RANDOMX_ARGON_GROWTH must be greater than or equal to 0.");
3533
static_assert(RANDOMX_PROGRAM_SIZE > 0, "RANDOMX_PROGRAM_SIZE must be greater than 0");
3634
static_assert(RANDOMX_PROGRAM_ITERATIONS > 0, "RANDOMX_PROGRAM_ITERATIONS must be greater than 0");
3735
static_assert(RANDOMX_PROGRAM_COUNT > 0, "RANDOMX_PROGRAM_COUNT must be greater than 0");
@@ -54,15 +52,14 @@ namespace randomx {
5452

5553
using addr_t = uint32_t;
5654

57-
constexpr int SeedSize = 32;
58-
constexpr int ResultSize = 64;
5955
constexpr int ArgonBlockSize = 1024;
6056
constexpr int ArgonSaltSize = sizeof(RANDOMX_ARGON_SALT) - 1;
6157
constexpr int CacheLineSize = 64;
6258
constexpr int ScratchpadSize = RANDOMX_SCRATCHPAD_L3;
6359
constexpr uint32_t CacheLineAlignMask = (RANDOMX_DATASET_SIZE - 1) & ~(CacheLineSize - 1);
6460
constexpr uint32_t CacheSize = RANDOMX_ARGON_MEMORY * 1024;
65-
constexpr int CacheBlockCount = CacheSize / CacheLineSize;
61+
62+
static_assert(RANDOMX_DATASET_BLOCKS == RANDOMX_DATASET_SIZE / CacheLineSize, "Invalid value of RANDOMX_DATASET_BLOCKS");
6663

6764
#ifdef TRACE
6865
constexpr bool trace = true;

Diff for: ‎src/configuration.h

-6
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ along with RandomX. If not, see<http://www.gnu.org/licenses/>.
2222
//Cache size in KiB. Must be a power of 2.
2323
#define RANDOMX_ARGON_MEMORY (256 * 1024)
2424

25-
//Cache growth per epoch in KiB.
26-
#define RANDOMX_ARGON_GROWTH 0
27-
2825
//Number of Argon2d iterations for Cache initialization
2926
#define RANDOMX_ARGON_ITERATIONS 3
3027

@@ -43,9 +40,6 @@ along with RandomX. If not, see<http://www.gnu.org/licenses/>.
4340
//Dataset size in bytes. Must be a power of 2.
4441
#define RANDOMX_DATASET_SIZE (2ULL * 1024 * 1024 * 1024)
4542

46-
//Dataset growth per epoch in bytes. Must be divisible by 64.
47-
#define RANDOMX_DS_GROWTH 0
48-
4943
//Number of blocks per epoch
5044
#define RANDOMX_EPOCH_BLOCKS 2048
5145

Diff for: ‎src/dataset.cpp

-19
Original file line numberDiff line numberDiff line change
@@ -211,23 +211,4 @@ namespace randomx {
211211
for (uint32_t blockNumber = startBlock; blockNumber < endBlock; ++blockNumber, dataset += CacheLineSize)
212212
initDatasetBlock(cache, dataset, blockNumber);
213213
}
214-
215-
/*void datasetAlloc(dataset_t& ds, bool largePages) {
216-
if (std::numeric_limits<size_t>::max() < RANDOMX_DATASET_SIZE)
217-
throw std::runtime_error("Platform doesn't support enough memory for the dataset");
218-
if (largePages) {
219-
ds.dataset.memory = (uint8_t*)allocLargePagesMemory(ds.dataset.size);
220-
}
221-
else {
222-
ds.dataset.memory = (uint8_t*)_mm_malloc(ds.dataset.size, 64);
223-
if (ds.dataset.memory == nullptr) {
224-
throw std::runtime_error("Dataset memory allocation failed. >4 GiB of free virtual memory is needed.");
225-
}
226-
}
227-
}
228-
229-
void datasetInitCache(const void* seed, dataset_t& ds, bool largePages) {
230-
ds.cache.memory = allocCache(ds.cache.size, largePages);
231-
argonFill(ds.cache, seed, SeedSize);
232-
}*/
233214
}

Diff for: ‎src/jit_compiler_x86.cpp

-8
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ namespace randomx {
105105
const uint8_t* codeDatasetInit = (uint8_t*)&randomx_dataset_init;
106106
const uint8_t* codeLoopStore = (uint8_t*)&randomx_program_loop_store;
107107
const uint8_t* codeLoopEnd = (uint8_t*)&randomx_program_loop_end;
108-
const uint8_t* codeReadDatasetLightSub = (uint8_t*)&randomx_program_read_dataset_light_sub;
109108
const uint8_t* codeEpilogue = (uint8_t*)&randomx_program_epilogue;
110109
const uint8_t* codeProgramEnd = (uint8_t*)&randomx_program_end;
111110
const uint8_t* codeShhLoad = (uint8_t*)&randomx_sshash_load;
@@ -120,15 +119,13 @@ namespace randomx {
120119
const int32_t readDatasetLightInitSize = codeReadDatasetLightSshFin - codeReadDatasetLightSshInit;
121120
const int32_t readDatasetLightFinSize = codeLoopStore - codeReadDatasetLightSshFin;
122121
const int32_t loopStoreSize = codeLoopEnd - codeLoopStore;
123-
const int32_t readDatasetLightSubSize = codeDatasetInit - codeReadDatasetLightSub;
124122
const int32_t datasetInitSize = codeEpilogue - codeDatasetInit;
125123
const int32_t epilogueSize = codeShhLoad - codeEpilogue;
126124
const int32_t codeSshLoadSize = codeShhPrefetch - codeShhLoad;
127125
const int32_t codeSshPrefetchSize = codeShhEnd - codeShhPrefetch;
128126
const int32_t codeSshInitSize = codeProgramEnd - codeShhInit;
129127

130128
const int32_t epilogueOffset = CodeSize - epilogueSize;
131-
const int32_t readDatasetLightSubOffset = epilogueOffset - readDatasetLightSubSize;
132129
constexpr int32_t superScalarHashOffset = 32768;
133130

134131
static const uint8_t REX_ADD_RR[] = { 0x4d, 0x03 };
@@ -226,7 +223,6 @@ namespace randomx {
226223
code = (uint8_t*)allocExecutableMemory(CodeSize);
227224
memcpy(code, codePrologue, prologueSize);
228225
memcpy(code + epilogueOffset, codeEpilogue, epilogueSize);
229-
memcpy(code + readDatasetLightSubOffset, codeReadDatasetLightSub, readDatasetLightSubSize);
230226
}
231227

232228
JitCompilerX86::~JitCompilerX86() {
@@ -241,10 +237,6 @@ namespace randomx {
241237
}
242238

243239
void JitCompilerX86::generateProgramLight(Program& prog, ProgramConfiguration& pcfg) {
244-
if (RANDOMX_CACHE_ACCESSES != 8)
245-
throw std::runtime_error("JIT compiler: Unsupported value of RANDOMX_CACHE_ACCESSES");
246-
if (RANDOMX_ARGON_GROWTH != 0)
247-
throw std::runtime_error("JIT compiler: Unsupported value of RANDOMX_ARGON_GROWTH");
248240
generateProgramPrologue(prog, pcfg);
249241
//if (superscalar) {
250242
emit(codeReadDatasetLightSshInit, readDatasetLightInitSize);

Diff for: ‎src/jit_compiler_x86_static.S

+1-9
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,9 @@
3434
.global DECL(randomx_program_read_dataset_light)
3535
.global DECL(randomx_program_read_dataset_sshash_init)
3636
.global DECL(randomx_program_read_dataset_sshash_fin)
37-
.global DECL(randomx_program_read_dataset_light_sub)
38-
.global DECL(randomx_dataset_init)
3937
.global DECL(randomx_program_loop_store)
4038
.global DECL(randomx_program_loop_end)
41-
.global DECL(randomx_program_read_dataset_light_sub)
39+
.global DECL(randomx_dataset_init)
4240
.global DECL(randomx_program_epilogue)
4341
.global DECL(randomx_sshash_load)
4442
.global DECL(randomx_sshash_prefetch)
@@ -83,12 +81,6 @@ DECL(randomx_program_loop_store):
8381
DECL(randomx_program_loop_end):
8482
nop
8583

86-
.balign 64
87-
DECL(randomx_program_read_dataset_light_sub):
88-
#include "asm/program_read_dataset_light_sub.inc"
89-
squareHashSub:
90-
#include "asm/squareHash.inc"
91-
9284
.balign 64
9385
DECL(randomx_dataset_init):
9486
push rbx

Diff for: ‎src/jit_compiler_x86_static.asm

-8
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ PUBLIC randomx_program_read_dataset
2727
PUBLIC randomx_program_read_dataset_light
2828
PUBLIC randomx_program_read_dataset_sshash_init
2929
PUBLIC randomx_program_read_dataset_sshash_fin
30-
PUBLIC randomx_program_read_dataset_light_sub
3130
PUBLIC randomx_dataset_init
3231
PUBLIC randomx_program_loop_store
3332
PUBLIC randomx_program_loop_end
@@ -83,13 +82,6 @@ randomx_program_loop_end PROC
8382
nop
8483
randomx_program_loop_end ENDP
8584

86-
ALIGN 64
87-
randomx_program_read_dataset_light_sub PROC
88-
include asm/program_read_dataset_light_sub.inc
89-
squareHashSub:
90-
include asm/squareHash.inc
91-
randomx_program_read_dataset_light_sub ENDP
92-
9385
ALIGN 64
9486
randomx_dataset_init PROC
9587
push rbx

Diff for: ‎src/jit_compiler_x86_static.hpp

-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ extern "C" {
3030
void randomx_program_read_dataset_sshash_fin();
3131
void randomx_program_loop_store();
3232
void randomx_program_loop_end();
33-
void randomx_program_read_dataset_light_sub();
3433
void randomx_dataset_init();
3534
void randomx_program_epilogue();
3635
void randomx_sshash_load();

Diff for: ‎src/squareHash.S

-41
This file was deleted.

Diff for: ‎src/squareHash.asm

-43
This file was deleted.

Diff for: ‎src/squareHash.h

-76
This file was deleted.

Diff for: ‎src/superscalar.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ along with RandomX. If not, see<http://www.gnu.org/licenses/>.
1818
*/
1919

2020
#include "configuration.h"
21-
#include "Program.hpp"
21+
#include "program.hpp"
2222
#include "blake2/endian.h"
2323
#include <iostream>
2424
#include <vector>

0 commit comments

Comments
 (0)
Please sign in to comment.