mirror of
				https://git.wownero.com/wownero/RandomWOW.git
				synced 2024-08-15 00:23:14 +00:00 
			
		
		
		
	fix test 92 not failing properly on GCC/amd64
This commit is contained in:
		
							parent
							
								
									6a764e90d0
								
							
						
					
					
						commit
						148b923f71
					
				
					 3 changed files with 24 additions and 3 deletions
				
			
		|  | @ -157,6 +157,21 @@ void rx_set_rounding_mode(uint32_t mode) { | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | uint32_t rx_get_rounding_mode() { | ||||||
|  | 	switch (fegetround()) { | ||||||
|  | 	case FE_DOWNWARD: | ||||||
|  | 		return RoundDown; | ||||||
|  | 	case FE_UPWARD: | ||||||
|  | 		return RoundUp; | ||||||
|  | 	case FE_TOWARDZERO: | ||||||
|  | 		return RoundToZero; | ||||||
|  | 	case FE_TONEAREST: | ||||||
|  | 		return RoundToNearest; | ||||||
|  | 	default: | ||||||
|  | 		UNREACHABLE; | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  | 
 | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| #ifdef RANDOMX_USE_X87 | #ifdef RANDOMX_USE_X87 | ||||||
|  |  | ||||||
|  | @ -173,6 +173,10 @@ FORCE_INLINE void rx_set_rounding_mode(uint32_t mode) { | ||||||
| 	_mm_setcsr(rx_mxcsr_default | (mode << 13)); | 	_mm_setcsr(rx_mxcsr_default | (mode << 13)); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | FORCE_INLINE uint32_t rx_get_rounding_mode() { | ||||||
|  | 	return (_mm_getcsr() >> 13) & 3; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| #elif defined(__PPC64__) && defined(__ALTIVEC__) && defined(__VSX__) //sadly only POWER7 and newer will be able to use SIMD acceleration. Earlier processors cant use doubles or 64 bit integers with SIMD
 | #elif defined(__PPC64__) && defined(__ALTIVEC__) && defined(__VSX__) //sadly only POWER7 and newer will be able to use SIMD acceleration. Earlier processors cant use doubles or 64 bit integers with SIMD
 | ||||||
| #include <cstdint> | #include <cstdint> | ||||||
| #include <stdexcept> | #include <stdexcept> | ||||||
|  | @ -736,6 +740,8 @@ void rx_reset_float_state(); | ||||||
| 
 | 
 | ||||||
| void rx_set_rounding_mode(uint32_t mode); | void rx_set_rounding_mode(uint32_t mode); | ||||||
| 
 | 
 | ||||||
|  | uint32_t rx_get_rounding_mode(); | ||||||
|  | 
 | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| double loadDoublePortable(const void* addr); | double loadDoublePortable(const void* addr); | ||||||
|  |  | ||||||
|  | @ -4,7 +4,6 @@ | ||||||
| 
 | 
 | ||||||
| #include <cassert> | #include <cassert> | ||||||
| #include <iomanip> | #include <iomanip> | ||||||
| #include <cfenv> |  | ||||||
| #include "utility.hpp" | #include "utility.hpp" | ||||||
| #include "../bytecode_machine.hpp" | #include "../bytecode_machine.hpp" | ||||||
| #include "../dataset.hpp" | #include "../dataset.hpp" | ||||||
|  | @ -1076,10 +1075,11 @@ int main() { | ||||||
| 	}); | 	}); | ||||||
| 
 | 
 | ||||||
| 	runTest("Preserve rounding mode", RANDOMX_FREQ_CFROUND > 0, []() { | 	runTest("Preserve rounding mode", RANDOMX_FREQ_CFROUND > 0, []() { | ||||||
| 		fesetround(FE_TONEAREST); | 		rx_set_rounding_mode(RoundToNearest); | ||||||
| 		char hash[RANDOMX_HASH_SIZE]; | 		char hash[RANDOMX_HASH_SIZE]; | ||||||
| 		calcStringHash("test key 000", "Lorem ipsum dolor sit amet", &hash); | 		calcStringHash("test key 000", "Lorem ipsum dolor sit amet", &hash); | ||||||
| 		assert(fegetround() == FE_TONEAREST); | 		assert(equalsHex(hash, "300a0adb47603dedb42228ccb2b211104f4da45af709cd7547cd049e9489c969")); | ||||||
|  | 		assert(rx_get_rounding_mode() == RoundToNearest); | ||||||
| 	}); | 	}); | ||||||
| 
 | 
 | ||||||
| 	randomx_destroy_vm(vm); | 	randomx_destroy_vm(vm); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue