libgpuverify

Signature verification on GPUs (WiP)
Log | Files | Refs | README | LICENSE

commit 6f5ee4cf72c8ad42a214880a84370b2dbfbefacd
parent 965f1e57a29b2f5d85f0fa21fa40bb9567bc5701
Author: Christian Grothoff <christian@grothoff.org>
Date:   Sun, 14 Jan 2024 11:54:29 +0100

-fix autoconf build

Diffstat:
Msource/Makefile.am | 4++--
Msource/util.h | 220+++++++++++++++++++++++++++++++++++++++++--------------------------------------
2 files changed, 116 insertions(+), 108 deletions(-)

diff --git a/source/Makefile.am b/source/Makefile.am @@ -1,7 +1,7 @@ # This Makefile.am is in the public domain AM_CPPFLAGS = \ - -DCL_TARGET_OPENCL_VERSION=100 + -DCL_TARGET_OPENCL_VERSION=110 lib_LTLIBRARIES = \ libgpuverify.la @@ -10,7 +10,7 @@ libgpuverify_la_LDFLAGS = \ -version-info 0:0:0 \ -no-undefined libgpuverify_la_SOURCES = \ - gpuv.c \ + gpuv-montg.c \ universal.c \ util.c diff --git a/source/util.h b/source/util.h @@ -34,7 +34,7 @@ typedef u_int64_t gpu_register; typedef uint32_t DIGIT_T; -unsigned long gpuvt_estimate_pairs(void); +unsigned long gpuvt_estimate_pairs (void); cl_platform_id select_platform (unsigned int offset, bool print_platforms); @@ -64,123 +64,131 @@ create_kernel (cl_program program, // Implementations of structures, their fields should be private -struct gpuv_public_key { - - - char * n; - unsigned long len_n; - - unsigned long e; - - // calculated - - char * ni; - unsigned long len_ni; - - char * r_1; - unsigned long len_r_1; - - int prepared; - +struct gpuv_public_key +{ + + + char *n; + unsigned long len_n; + + unsigned long e; + + // calculated + + char *ni; + unsigned long len_ni; + + char *r_1; + unsigned long len_r_1; + + int prepared; + }; -struct gpuv_signature_message { - - struct gpuv_public_key * pubkey; - - char * m; - unsigned long len_m; - - char * s; - unsigned long len_s; - - // calculated - - char * x; - unsigned long len_x; - - char * M; - unsigned long len_M; - - //unsigned long count; - int prepared; +struct gpuv_signature_message +{ + + struct gpuv_public_key *pubkey; + + char *m; + unsigned long len_m; + + char *s; + unsigned long len_s; + + // calculated + + char *x; + unsigned long len_x; + + char *M; + unsigned long len_M; + + // unsigned long count; + int prepared; }; -struct gpuv_batch { - - struct gpuv_signature_message * pairs; - unsigned long max_count; - unsigned long current; - - // this is needed here, to make it easier to load it into the gpu - uint32_t *pk_indices; - unsigned long pk_max_count; - unsigned long pk_current; - - // a list, containing indices of pubkeys - uint32_t *pk_list; - +struct gpuv_batch +{ + + struct gpuv_signature_message *pairs; + unsigned long max_count; + unsigned long current; + + // this is needed here, to make it easier to load it into the gpu + uint32_t *pk_indices; + unsigned long pk_max_count; + unsigned long pk_current; + + // a list, containing indices of pubkeys + uint32_t *pk_list; + }; -struct gpuv_info { - - cl_platform_id platform; - cl_device_id device_id; - cl_context context; - cl_program program; - cl_kernel kernel; - - enum GPUV_VARIANT variant; - - int in_progress; - +struct gpuv_info +{ + + cl_platform_id platform; + cl_device_id device_id; + cl_context context; + cl_program program; + cl_kernel kernel; + + enum GPUV_VARIANT variant; + + int in_progress; + }; -struct gpuv_state { - - struct gpuv_info *info; - cl_command_queue queue; - - // the callback the user defines - void (*cls)(void *, int, struct timespec, unsigned long, uint32_t *); // pointer to the results and how long the array is - void * arg; - - int stale; // says if we can enqueue it or not (0 at init) - int ready; - - // user provided - cl_mem n_mem; - cl_mem msg_mem; - cl_mem exp_mem; - cl_mem sig_mem; - unsigned long sig_count; - unsigned long pubkey_count; - - // calculated - cl_mem x_mem; - cl_mem m_mem; - cl_mem ni_mem; - cl_mem res_mem; - cl_mem pks_indices; - - // measuring times - struct timespec t; - struct timespec p; - - int valid; // 0 in the beginning - - uint32_t *results; - unsigned long results_len; - +struct gpuv_state +{ + + struct gpuv_info *info; + cl_command_queue queue; + + // the callback the user defines + void (*cls)(void *, int, struct timespec, unsigned long, uint32_t *); // pointer to the results and how long the array is + void *arg; + + int stale; // says if we can enqueue it or not (0 at init) + int ready; + + // user provided + cl_mem n_mem; + cl_mem msg_mem; + cl_mem exp_mem; + cl_mem sig_mem; + unsigned long sig_count; + unsigned long pubkey_count; + + // calculated + cl_mem x_mem; + cl_mem m_mem; + cl_mem ni_mem; + cl_mem res_mem; + cl_mem pks_indices; + + // measuring times + struct timespec t; + struct timespec p; + + int valid; // 0 in the beginning + + uint32_t *results; + unsigned long results_len; + }; -void CL_CALLBACK callback_result(cl_event event, cl_int event_command_status, void *user_data); -void CL_CALLBACK callback_kernel(cl_event event, cl_int event_command_status, void *user_data); +void CL_CALLBACK callback_result (cl_event event, cl_int event_command_status, + void *user_data); + +void CL_CALLBACK callback_kernel (cl_event event, cl_int event_command_status, + void *user_data); -void pk_to_mont(struct gpuv_public_key * pk); -void sig_msg_to_mont(struct gpuv_signature_message * sig_msg); +void pk_to_mont (struct gpuv_public_key *pk); +void sig_msg_to_mont (struct gpuv_signature_message *sig_msg); -void cpu_verify(struct gpuv_batch *batch, struct gpuv_state *state); +void cpu_verify (struct gpuv_batch *batch, struct gpuv_state *state); #endif /* util_h */