RandomX self-test: try to allocate using large pages first
This commit is contained in:
+12
-3
@@ -111,18 +111,24 @@ int p2pool_test()
|
|||||||
char hash[RANDOMX_HASH_SIZE];
|
char hash[RANDOMX_HASH_SIZE];
|
||||||
|
|
||||||
const randomx_flags flags = randomx_get_flags() | RANDOMX_FLAG_FULL_MEM;
|
const randomx_flags flags = randomx_get_flags() | RANDOMX_FLAG_FULL_MEM;
|
||||||
randomx_cache* myCache = randomx_alloc_cache(flags);
|
randomx_cache* myCache = randomx_alloc_cache(flags | RANDOMX_FLAG_LARGE_PAGES);
|
||||||
|
if (!myCache) {
|
||||||
|
myCache = randomx_alloc_cache(flags);
|
||||||
if (!myCache) {
|
if (!myCache) {
|
||||||
printf("Cache allocation failed\n");
|
printf("Cache allocation failed\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
randomx_init_cache(myCache, myKey, sizeof(myKey) - 1);
|
randomx_init_cache(myCache, myKey, sizeof(myKey) - 1);
|
||||||
|
|
||||||
randomx_dataset* myDataset = randomx_alloc_dataset(flags);
|
randomx_dataset* myDataset = randomx_alloc_dataset(flags | RANDOMX_FLAG_LARGE_PAGES);
|
||||||
|
if (!myDataset) {
|
||||||
|
myDataset = randomx_alloc_dataset(flags);
|
||||||
if (!myDataset) {
|
if (!myDataset) {
|
||||||
printf("Dataset allocation failed\n");
|
printf("Dataset allocation failed\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const uint32_t numThreads = std::max(std::thread::hardware_concurrency(), 1U);
|
const uint32_t numThreads = std::max(std::thread::hardware_concurrency(), 1U);
|
||||||
@@ -146,11 +152,14 @@ int p2pool_test()
|
|||||||
|
|
||||||
randomx_release_cache(myCache);
|
randomx_release_cache(myCache);
|
||||||
|
|
||||||
randomx_vm* myMachine = randomx_create_vm(flags, nullptr, myDataset);
|
randomx_vm* myMachine = randomx_create_vm(flags | RANDOMX_FLAG_LARGE_PAGES, nullptr, myDataset);
|
||||||
|
if (!myMachine) {
|
||||||
|
myMachine = randomx_create_vm(flags, nullptr, myDataset);
|
||||||
if (!myMachine) {
|
if (!myMachine) {
|
||||||
printf("Failed to create a virtual machine");
|
printf("Failed to create a virtual machine");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
memset(hash, 0, sizeof(hash));
|
memset(hash, 0, sizeof(hash));
|
||||||
memcpy(hash, myInput, sizeof(myInput));
|
memcpy(hash, myInput, sizeof(myInput));
|
||||||
|
|||||||
Reference in New Issue
Block a user