crack5opencl - textual

This commit is contained in:
iceman1001 2021-04-09 15:41:00 +02:00
parent d77a4d1a5c
commit c850b5376d
2 changed files with 15 additions and 24 deletions

View file

@ -6,7 +6,7 @@
#include <stdint.h>
#include <unistd.h>
#include <string.h>
#ifndef (__MINGW64__)
#ifndef __MINGW64__
# include <sys/mman.h>
#endif
#include <sys/types.h>

View file

@ -427,20 +427,6 @@ int thread_stop(thread_ctx_t *ctx) {
return 0;
}
__attribute__((format(printf, 1, 2)))
void tprintf(const char *restrict format, ...) {
flockfile(stdout);
va_list va_args;
va_start(va_args, format);
vprintf(format, va_args);
va_end(va_args);
funlockfile(stdout);
fflush(stdout);
}
const char *thread_status_strdesc(thread_status_t s) {
switch (s) {
case TH_START:
@ -470,13 +456,13 @@ bool thread_setEnd(thread_ctx_t *ctx, thread_args_t *t_arg) {
for (z = 0; z < ctx->thread_count; z++) {
int m_ret = pthread_mutex_lock(&ctx->thread_mutexs[z]);
if (m_ret != 0) {
tprintf("[%zu] [%s] Error: pthread_mutex_lock() failed (%d): %s\n", z, __func__, m_ret, strerror(m_ret));
printf("[%zu] [%s] Error: pthread_mutex_lock() failed (%d): %s\n", z, __func__, m_ret, strerror(m_ret));
}
thread_status_t tmp = t_arg[z].status;
#if DEBUGME > 0
tprintf("[%zu] [%s] Thread status: %s\n", z, __func__, thread_status_strdesc(t_arg[z].status));
printf("[%zu] [%s] Thread status: %s\n", z, __func__, thread_status_strdesc(t_arg[z].status));
#endif
if (tmp == TH_FOUND_KEY || tmp == TH_END || tmp == TH_ERROR) {
@ -486,19 +472,19 @@ bool thread_setEnd(thread_ctx_t *ctx, thread_args_t *t_arg) {
}
#if DEBUGME > 0
tprintf("[%zu] [%s] Set thread status to TH_END\n", z, __func__);
printf("[%zu] [%s] Set thread status to TH_END\n", z, __func__);
#endif
t_arg[z].status = TH_END;
if (tmp == TH_WAIT) {
#if DEBUGME > 0
tprintf("[%zu] [%s] Send cond_signal to thread\n", z, __func__);
printf("[%zu] [%s] Send cond_signal to thread\n", z, __func__);
#endif
c_ret = pthread_cond_signal(&ctx->thread_conds[z]);
if (c_ret != 0) {
tprintf("[%zu] [%s] Error: pthread_cond_signal() failed (%d): %s\n", z, __func__, c_ret, strerror(c_ret));
printf("[%zu] [%s] Error: pthread_cond_signal() failed (%d): %s\n", z, __func__, c_ret, strerror(c_ret));
}
}
@ -529,17 +515,19 @@ void *computing_process(void *arg) {
off = wu.off;
a->slice = wu.id + 1;
float progress = (((wu.id + 1) * 100.0) / wu.max);
if (ctx->queue_ctx.queue_type == QUEUE_TYPE_RANDOM) {
#if DEBUGME > 0
printf("[%zu] Slice %zu (off %zu), max %zu, remain %zu slice(s)\n", z, wu.id + 1, wu.off, wu.max, wu.rem);
#else
printf("[%zu] Slice %zu/%zu (%zu remain)\n", z, wu.id + 1, wu.max, wu.rem);
printf("\r[%zu] Slice %zu/%zu (%zu remain) ( %2.1f%% )", z, wu.id + 1, wu.max, wu.rem, progress);
#endif // DEBUGME
} else {
#if DEBUGME > 0
printf("[%zu] Slice %zu/%zu, off %zu\n", z, wu.id + 1, wu.max, wu.off);
#else
printf("[%zu] Slice %zu/%zu\n", z, wu.id + 1, wu.max);
printf("\r[%zu] Slice %zu/%zu ( %2.1f%% )", z, wu.id + 1, wu.max, progress);
#endif // DEBUGME
}
fflush(stdout);
@ -577,6 +565,7 @@ void *computing_process(void *arg) {
}
pthread_exit(NULL);
return NULL;
}
void *computing_process_async(void *arg) {
@ -684,17 +673,18 @@ void *computing_process_async(void *arg) {
off = wu.off;
a->slice = wu.id + 1;
float progress = (((wu.id + 1) * 100.0) / wu.max);
if (ctx->queue_ctx.queue_type == QUEUE_TYPE_RANDOM) {
#if DEBUGME > 0
printf("[%zu] Slice %zu (off %zu), max %zu, remain %zu slice(s)\n", z, wu.id + 1, wu.off, wu.max, wu.rem);
#else
printf("[%zu] Slice %zu/%zu (%zu remain)\n", z, wu.id + 1, wu.max, wu.rem);
printf("[%zu] Slice %zu/%zu (%zu remain) ( %2.1f%% )", z, wu.id + 1, wu.max, wu.rem, progress);
#endif // DEBUGME
} else {
#if DEBUGME > 0
printf("[%zu] Slice %zu/%zu, off %zu\n", z, wu.id + 1, wu.max, wu.off);
#else
printf("[%zu] Slice %zu/%zu\n", z, wu.id + 1, wu.max);
printf("\r[%zu] Slice %zu/%zu ( %2.1f%% )", z, wu.id + 1, wu.max, progress);
#endif // DEBUGME
}
@ -874,4 +864,5 @@ void *computing_process_async(void *arg) {
} while (status < TH_FOUND_KEY);
pthread_exit(NULL);
return NULL;
}