NVlabs / CGBN

CGBN: CUDA Accelerated Multiple Precision Arithmetic (Big Num) using Cooperative Groups
Other
206 stars 55 forks source link

CGBN context creation and Too few arguments in function call #29

Open hiddenvs opened 1 month ago

hiddenvs commented 1 month ago

Part of source code:

 20 // Define the kernel
 21 __global__ void solve_kernel(problem_instance_t *problem_instances, uint32_t instance_count) {
 22     // Create a CGBN context
 23     cgbn_error_report_t *report = cgbn_error_report_alloc();
 24     cgbn_context_t<TPI> bn_context(cgbn_error_report_alloc(), report);
 25     // Construct a bn environment for 256-bit math
 26     typedef cgbn_env_t<cgbn_context_t<TPI>, 256> env256_t;
 27     env256_t bn256_env(bn_context);
 28     // Define 256-bit values
 29     env256_t::cgbn_t c, p, temp, Z_val, N_val;
 30
 31     int32_t my_instance = (blockIdx.x * blockDim.x + threadIdx.x) / TPI;  // Determine instance number
 32     if (my_instance >= instance_count) return;  // Return if instance is not valid

Compiling error:

test3.cu(23): error: too few arguments in function call
test3.cu(24): error: too few arguments in function call

What I found in examples and source codes for CGBN: cudaError_t cgbn_error_report_alloc(cgbn_error_report_t **report);

What am I missing ?

luitjens commented 1 month ago

As a heads up this project is unstaffed and support for it is extremely limited. With that said it looks like this error message is because you are not using cgbn_error_report_alloc() correctly. Have you looked at the examples? It also looks like you might be using host functions on the device. You will notice in the example pasted below this function is called from the host and takes an object by reference which gets allocated. You then pass this to the device via a kernel argument.

https://github.com/NVlabs/CGBN/blob/master/samples/sample_01_add/add.cu#L132