'CGBN: How to send to device memory short cgbn_mem_t, but make calculations over long cgbn_mem_t?

I'm somewhat lost on the point of converting, for instance, cgbn_mem_t<256> into cgbn_mem_t<1024> in device code. Say, the kernel receives two pointers to cgbn_mem_t<256>, it's quite straightforward to call cgbn_load on them, but it would work out only for typedef cgbn_env_t<context_t, 256> env_256_t;, but I would like to make calculations with 1024 bit precision. In other words, An attempt to cgbn_load 256bit bn into 1024bit env will not compile.

So, I wonder, how one should go about conversion between sending bit-size and operational bit-size on device ?

i.e. how to convert env_256_t::cgbn_t to env_1024_t::cgbn_t and vice versa?

where:

#define TPI 32
#define BITS 1024

typedef cgbn_context_t<TPI> context_t;
typedef cgbn_env_t<context_t, BITS> env_t;
typedef cgbn_env_t<context_t, 256> env_256_t;


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source