mirror of
https://github.com/wownero/RandomX.git
synced 2026-10-19 00:08:45 +02:00
C API - first working version
This commit is contained in:
@@ -24,22 +24,27 @@ along with RandomX. If not, see<http://www.gnu.org/licenses/>.
|
||||
#include "JitCompilerX86.hpp"
|
||||
#include "intrinPortable.h"
|
||||
|
||||
namespace RandomX {
|
||||
namespace randomx {
|
||||
|
||||
template<bool superscalar>
|
||||
class CompiledLightVirtualMachine : public CompiledVirtualMachine {
|
||||
template<class Allocator, bool softAes>
|
||||
class CompiledLightVm : public CompiledVm<Allocator, softAes> {
|
||||
public:
|
||||
void* operator new(size_t size) {
|
||||
void* ptr = _mm_malloc(size, 64);
|
||||
void* ptr = AlignedAllocator<CacheLineSize>::allocMemory(size);
|
||||
if (ptr == nullptr)
|
||||
throw std::bad_alloc();
|
||||
return ptr;
|
||||
}
|
||||
void operator delete(void* ptr) {
|
||||
_mm_free(ptr);
|
||||
AlignedAllocator<CacheLineSize>::freeMemory(ptr, sizeof(CompiledLightVm));
|
||||
}
|
||||
CompiledLightVirtualMachine() {}
|
||||
void setDataset(dataset_t ds, uint64_t size, SuperscalarProgram(&programs)[RANDOMX_CACHE_ACCESSES]) override;
|
||||
void setCache(randomx_cache* cache) override;
|
||||
void setDataset(randomx_dataset* dataset) override {}
|
||||
void initialize() override;
|
||||
};
|
||||
|
||||
using CompiledLightVmDefault = CompiledLightVm<AlignedAllocator<CacheLineSize>, true>;
|
||||
using CompiledLightVmHardAes = CompiledLightVm<AlignedAllocator<CacheLineSize>, false>;
|
||||
using CompiledLightVmLargePage = CompiledLightVm<LargePageAllocator, false>;
|
||||
using CompiledLightVmLargePageHardAes = CompiledLightVm<LargePageAllocator, true>;
|
||||
}
|
||||
Reference in New Issue
Block a user