#define DISTANCE_MAX DISTANCE_MIN + 16U
#define THREAD_COUNT 8U
+
#undef ENABLE_STATS
+#undef ENABLE_TRACE
#define ROW_NUM (UINT8_MAX+2) /*total number of rows*/
#define ROW_LEN (HASH_LEN / CHAR_BIT) /*number of bits per row*/
#define MAGIC_NUMBER 0x3C6058A7C1132CB2ui64
#define THREAD_ID (pthread_getw32threadid_np(pthread_self()))
-#ifdef ENABLE_STATS
-#include <intrin.h>
-#endif
-
//-----------------------------------------------------------------------------
// Globals
//-----------------------------------------------------------------------------
static char SPINNER[4] = { '/', '-', '\\', '|' };
#ifdef ENABLE_STATS
+#include <intrin.h>
static volatile long long g_stat_too_hi = 0i64;
static volatile long long g_stat_too_lo = 0i64;
#endif //ENABLE_STATS
// Utility Functions
//-----------------------------------------------------------------------------
+#ifdef ENABLE_TRACE
+#define TRACE(X, ...) printf("[%04X] " X "\n", THREAD_ID, __VA_ARGS__)
+#else
+#define TRACE(X, ...) __noop()
+#endif
+
static inline void print_row(uint8_t *const row_buffer)
{
for (size_t w = 0; w < ROW_LEN; ++w)
uint32_t error = check_distance_buff(data->index, data->row_buffer, HASH_LEN);
if(error > 0U)
{
- for (int32_t round = 0; round < 1499; ++round)
+ for (int32_t round = 0; round < 4999; ++round)
{
if (!(round & 0xFF))
{
memcpy(data->row_buffer, temp, sizeof(uint8_t) * ROW_LEN);
if (!((error = next_error) > 0U))
{
+ TRACE("Success by rand-init");
goto success;
}
}
const uint32_t next_error = check_distance_buff(data->index, data->row_buffer, error);
if (next_error < error)
{
+ TRACE("Improved by flip-1");
revert_w = false;
round = -1;
if (!((error = next_error) > 0U))
{
+ TRACE("Sucess by flip-1");
goto success;
}
}
const uint32_t next_error = check_distance_buff(data->index, data->row_buffer, error);
if (next_error < error)
{
+ TRACE("Improved by flip-2");
revert_w = false;
revert_x = false;
round = -1;
if (!((error = next_error) > 0U))
{
+ TRACE("Sucess by flip-2");
goto success;
}
}
const uint32_t next_error = check_distance_buff(data->index, data->row_buffer, error);
if (next_error < error)
{
+ TRACE("Improved by flip-3");
revert_w = false;
revert_x = false;
revert_y = false;
round = -1;
if (!((error = next_error) > 0U))
{
+ TRACE("Sucess by flip-3");
goto success;
}
}
const uint32_t next_error = check_distance_buff(data->index, data->row_buffer, error);
if (next_error < error)
{
+ TRACE("Improved by flip-4");
revert_w = false;
revert_x = false;
revert_y = false;
round = -1;
if (!((error = next_error) > 0U))
{
+ TRACE("Sucess by flip-4");
goto success;
}
}
const uint32_t next_error = check_distance_buff(data->index, temp, error);
if (next_error < error)
{
+ TRACE("Improved by rand-flip (%u)", flip_count);
round = -1;
memcpy(data->row_buffer, temp, sizeof(uint8_t) * ROW_LEN);
if (!((error = next_error) > 0U))
{
+ TRACE("Success by rand-flip (%u)", flip_count);
goto success;
}
}
}
}
}
+ TRACE("Restarting");
}
else
{