mirror of
				https://git.wownero.com/wownero/RandomWOW.git
				synced 2024-08-15 00:23:14 +00:00 
			
		
		
		
	Restored software AES support
This commit is contained in:
		
							parent
							
								
									f76e8c2e20
								
							
						
					
					
						commit
						1df975e583
					
				
					 3 changed files with 15 additions and 26 deletions
				
			
		|  | @ -117,19 +117,12 @@ namespace RandomX { | |||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	template<bool softAes> | ||||
| 	void datasetInit(Cache* cache, dataset_t ds, uint32_t startBlock, uint32_t blockCount) { | ||||
| 		for (uint32_t i = startBlock; i < startBlock + blockCount; ++i) { | ||||
| 			initBlock(cache->getCache(), ds.dataset + i * CacheLineSize, i, cache->getKeys()); | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	template | ||||
| 		void datasetInit<false>(Cache*, dataset_t, uint32_t, uint32_t); | ||||
| 
 | ||||
| 	template | ||||
| 		void datasetInit<true>(Cache*, dataset_t, uint32_t, uint32_t); | ||||
| 
 | ||||
| 	template<bool softAes> | ||||
| 	void datasetInitCache(const void* seed, dataset_t& ds, bool largePages) { | ||||
| 		ds.cache = new(Cache::alloc(largePages)) Cache(); | ||||
|  |  | |||
|  | @ -35,7 +35,6 @@ namespace RandomX { | |||
| 
 | ||||
| 	void datasetAlloc(dataset_t& ds, bool largePages); | ||||
| 
 | ||||
| 	template<bool softAes> | ||||
| 	void datasetInit(Cache* cache, dataset_t ds, uint32_t startBlock, uint32_t blockCount); | ||||
| 
 | ||||
| 	void datasetRead(addr_t addr, MemoryRegisters& memory, RegisterFile&); | ||||
|  |  | |||
							
								
								
									
										33
									
								
								src/main.cpp
									
										
									
									
									
								
							
							
						
						
									
										33
									
								
								src/main.cpp
									
										
									
									
									
								
							|  | @ -153,6 +153,7 @@ void generateNative(int nonce) { | |||
| 	std::cout << prog << std::endl; | ||||
| } | ||||
| 
 | ||||
| template<bool softAes> | ||||
| void mine(RandomX::VirtualMachine* vm, std::atomic<int>& atomicNonce, AtomicHash& result, int noncesCount, int thread, uint8_t* scratchpad) { | ||||
| 	alignas(16) uint64_t hash[8]; | ||||
| 	uint8_t blockTemplate[sizeof(blockTemplate__)]; | ||||
|  | @ -164,19 +165,19 @@ void mine(RandomX::VirtualMachine* vm, std::atomic<int>& atomicNonce, AtomicHash | |||
| 		//std::cout << "Thread " << thread << " nonce " << nonce << std::endl;
 | ||||
| 		*noncePtr = nonce; | ||||
| 		blake2b(hash, sizeof(hash), blockTemplate, sizeof(blockTemplate), nullptr, 0); | ||||
| 		fillAes1Rx4<false>((void*)hash, RandomX::ScratchpadSize, scratchpad); | ||||
| 		fillAes1Rx4<softAes>((void*)hash, RandomX::ScratchpadSize, scratchpad); | ||||
| 		vm->setScratchpad(scratchpad); | ||||
| 		//dump((char*)((RandomX::CompiledVirtualMachine*)vm)->getProgram(), RandomX::CodeSize, "code-1337-jmp.txt");
 | ||||
| 		for (int chain = 0; chain < RandomX::ChainLength - 1; ++chain) { | ||||
| 			fillAes1Rx4<false>((void*)hash, sizeof(RandomX::Program), vm->getProgramBuffer()); | ||||
| 			fillAes1Rx4<softAes>((void*)hash, sizeof(RandomX::Program), vm->getProgramBuffer()); | ||||
| 			vm->initialize(); | ||||
| 			vm->execute(); | ||||
| 			vm->getResult<false>(nullptr, 0, hash); | ||||
| 		} | ||||
| 		fillAes1Rx4<false>((void*)hash, sizeof(RandomX::Program), vm->getProgramBuffer()); | ||||
| 		fillAes1Rx4<softAes>((void*)hash, sizeof(RandomX::Program), vm->getProgramBuffer()); | ||||
| 		vm->initialize(); | ||||
| 		vm->execute(); | ||||
| 		vm->getResult<false>(scratchpad, RandomX::ScratchpadSize, hash); | ||||
| 		vm->getResult<softAes>(scratchpad, RandomX::ScratchpadSize, hash); | ||||
| 		result.xorWith(hash); | ||||
| 		if (RandomX::trace) { | ||||
| 			std::cout << "Nonce: " << nonce << " "; | ||||
|  | @ -257,24 +258,14 @@ int main(int argc, char** argv) { | |||
| 				auto remainder = RandomX::DatasetBlockCount % threadCount; | ||||
| 				for (int i = 0; i < threadCount; ++i) { | ||||
| 					auto count = perThread + (i == threadCount - 1 ? remainder : 0); | ||||
| 					if (softAes) { | ||||
| 						threads.push_back(std::thread(&RandomX::datasetInit<true>, cache, dataset, i * perThread, count)); | ||||
| 					} | ||||
| 					else { | ||||
| 						threads.push_back(std::thread(&RandomX::datasetInit<false>, cache, dataset, i * perThread, count)); | ||||
| 					} | ||||
| 					threads.push_back(std::thread(&RandomX::datasetInit, cache, dataset, i * perThread, count)); | ||||
| 				} | ||||
| 				for (unsigned i = 0; i < threads.size(); ++i) { | ||||
| 					threads[i].join(); | ||||
| 				} | ||||
| 			} | ||||
| 			else { | ||||
| 				if (softAes) { | ||||
| 					RandomX::datasetInit<true>(cache, dataset, 0, RandomX::DatasetBlockCount); | ||||
| 				} | ||||
| 				else { | ||||
| 					RandomX::datasetInit<false>(cache, dataset, 0, RandomX::DatasetBlockCount); | ||||
| 				} | ||||
| 				RandomX::datasetInit(cache, dataset, 0, RandomX::DatasetBlockCount); | ||||
| 			} | ||||
| 			RandomX::Cache::dealloc(cache, largePages); | ||||
| 			threads.clear(); | ||||
|  | @ -303,14 +294,20 @@ int main(int argc, char** argv) { | |||
| 		sw.restart(); | ||||
| 		if (threadCount > 1) { | ||||
| 			for (unsigned i = 0; i < vms.size(); ++i) { | ||||
| 				threads.push_back(std::thread(&mine, vms[i], std::ref(atomicNonce), std::ref(result), programCount, i, scratchpadMem + RandomX::ScratchpadSize * i)); | ||||
| 				if (softAes) | ||||
| 					threads.push_back(std::thread(&mine<true>, vms[i], std::ref(atomicNonce), std::ref(result), programCount, i, scratchpadMem + RandomX::ScratchpadSize * i)); | ||||
| 				else | ||||
| 					threads.push_back(std::thread(&mine<false>, vms[i], std::ref(atomicNonce), std::ref(result), programCount, i, scratchpadMem + RandomX::ScratchpadSize * i)); | ||||
| 			} | ||||
| 			for (unsigned i = 0; i < threads.size(); ++i) { | ||||
| 				threads[i].join(); | ||||
| 			} | ||||
| 		} | ||||
| 		else { | ||||
| 			mine(vms[0], std::ref(atomicNonce), std::ref(result), programCount, 0, scratchpadMem); | ||||
| 			if(softAes) | ||||
| 				mine<true>(vms[0], std::ref(atomicNonce), std::ref(result), programCount, 0, scratchpadMem); | ||||
| 			else | ||||
| 				mine<false>(vms[0], std::ref(atomicNonce), std::ref(result), programCount, 0, scratchpadMem); | ||||
| 			if (miningMode) | ||||
| 				std::cout << "Average program size: " << ((RandomX::CompiledVirtualMachine*)vms[0])->getTotalSize() / programCount / RandomX::ChainLength << std::endl; | ||||
| 		} | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue