Compare commits

...

2 Commits

Author SHA1 Message Date
tevador dbd373839d Native load from the cache
5 years ago
tevador 32009fb02c Interpreter debugging
5 years ago

@ -74,8 +74,9 @@ namespace RandomX {
}
static void print(__m128d f) {
uint64_t lo = *(((uint64_t*)&f) + 0);
uint64_t hi = *(((uint64_t*)&f) + 1);
uint64_t hi, lo;
memcpy(&lo, &f, 8);
memcpy(&hi, (uint8_t*)&f + 8, 8);
std::cout << std::hex << std::setw(16) << std::setfill('0') << hi << '-' << std::hex << std::setw(16) << std::setfill('0') << lo << std::endl;
}
@ -417,6 +418,9 @@ namespace RandomX {
_mm_store_pd(&reg.e[1].lo, e[1]);
_mm_store_pd(&reg.e[2].lo, e[2]);
_mm_store_pd(&reg.e[3].lo, e[3]);
printState(r, f, e, a);
std::cout << "=================================================" << std::endl;
}
static int getConditionRegister(int(&registerUsage)[8]) {

@ -60,6 +60,12 @@ static FORCE_INLINE uint64_t load64(const void *src) {
#endif
}
static FORCE_INLINE uint64_t load64np(const void *src) {
uint64_t w;
memcpy(&w, src, sizeof w);
return w;
}
static FORCE_INLINE void store32(void *dst, uint32_t w) {
#if defined(NATIVE_LITTLE_ENDIAN)
memcpy(dst, &w, sizeof w);

@ -57,14 +57,14 @@ namespace RandomX {
}
static FORCE_INLINE void mixCache(uint8_t* mixBlock, uint64_t& c0, uint64_t& c1, uint64_t& c2, uint64_t& c3, uint64_t& c4, uint64_t& c5, uint64_t& c6, uint64_t& c7) {
c0 ^= load64(mixBlock + 0);
c1 ^= load64(mixBlock + 8);
c2 ^= load64(mixBlock + 16);
c3 ^= load64(mixBlock + 24);
c4 ^= load64(mixBlock + 32);
c5 ^= load64(mixBlock + 40);
c6 ^= load64(mixBlock + 48);
c7 ^= load64(mixBlock + 56);
c0 ^= load64np(mixBlock + 0);
c1 ^= load64np(mixBlock + 8);
c2 ^= load64np(mixBlock + 16);
c3 ^= load64np(mixBlock + 24);
c4 ^= load64np(mixBlock + 32);
c5 ^= load64np(mixBlock + 40);
c6 ^= load64np(mixBlock + 48);
c7 ^= load64np(mixBlock + 56);
}
void initBlock(const Cache& cache, uint8_t* out, uint64_t blockNumber, unsigned iterations) {

@ -16,7 +16,7 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with RandomX. If not, see<http://www.gnu.org/licenses/>.
*/
//#define TRACE
#define TRACE
#include "InterpretedVirtualMachine.hpp"
#include "CompiledVirtualMachine.hpp"
#include "CompiledLightVirtualMachine.hpp"
@ -179,11 +179,21 @@ void mine(RandomX::VirtualMachine* vm, std::atomic<uint32_t>& atomicNonce, Atomi
for (int chain = 0; chain < RANDOMX_PROGRAM_COUNT - 1; ++chain) {
fillAes1Rx4<softAes>((void*)hash, sizeof(RandomX::Program), vm->getProgramBuffer());
vm->initialize();
if (RandomX::trace) {
std::cout << "Program " << chain << std::endl;
std::cout << *vm->getProgramBuffer();
std::cout << "=================================================" << std::endl;
}
vm->execute();
vm->getResult<false>(nullptr, 0, hash);
}
fillAes1Rx4<softAes>((void*)hash, sizeof(RandomX::Program), vm->getProgramBuffer());
vm->initialize();
if (RandomX::trace) {
std::cout << "Program 7" << std::endl;
std::cout << *vm->getProgramBuffer();
std::cout << "=================================================" << std::endl;
}
vm->execute();
/*if (RandomX::trace) {
for (int j = 0; j < RandomX::ProgramLength; ++j) {
@ -191,6 +201,7 @@ void mine(RandomX::VirtualMachine* vm, std::atomic<uint32_t>& atomicNonce, Atomi
std::cout << std::hex << std::setw(16) << std::setfill('0') << res << std::endl;
}
}*/
dump((char*)scratchpad, RANDOMX_SCRATCHPAD_L3, "scratchpad");
vm->getResult<softAes>(scratchpad, RANDOMX_SCRATCHPAD_L3, hash);
result.xorWith(hash);
if (RandomX::trace) {
@ -211,7 +222,7 @@ int main(int argc, char** argv) {
readOption("--mine", argc, argv, miningMode);
readOption("--verify", argc, argv, verificationMode);
readIntOption("--threads", argc, argv, threadCount, 1);
readIntOption("--nonces", argc, argv, programCount, 1000);
readIntOption("--nonces", argc, argv, programCount, 1);
readIntOption("--init", argc, argv, initThreadCount, 1);
readIntOption("--epoch", argc, argv, epoch, 0);
readOption("--largePages", argc, argv, largePages);

Loading…
Cancel
Save