C API - first working version

This commit is contained in:
tevador
2019-04-20 11:08:01 +02:00
parent 67046a9f38
commit 296e77eebc
36 changed files with 1286 additions and 938 deletions
+12 -7
View File
@@ -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>;
}