'Adapt a code library ``codelib`` with the numba compiled CUDA kernel
with name ``fname`` and arguments ``argtypes`` for NVVM.
A new library is created with a wrapper function that can be used as
the kernel entry point for the given kernel.
Returns the new code library and the wrapper function.'

def prepare_cuda_kernel(self, codelib, fname, argtypes):

    library = self.codegen().create_library('')
    library.add_linking_library(codelib)
    wrapper = self.generate_kernel_wrapper(library, fname, argtypes)
    nvvm.fix_data_layout(library._final_module)
    return (library, wrapper)
