! An object representing a configured and instantiated kernel ready * for launching. */
| 2923 | * for launching. |
| 2924 | */ |
| 2925 | class KernelLauncher { |
| 2926 | std::unique_ptr<KernelLauncher_impl const> _impl; |
| 2927 | |
| 2928 | public: |
| 2929 | inline KernelLauncher(KernelInstantiation const& kernel_inst, dim3 grid, |
| 2930 | dim3 block, unsigned int smem = 0, |
| 2931 | cudaStream_t stream = 0); |
| 2932 | |
| 2933 | // Note: It's important that there is no implicit conversion required |
| 2934 | // for arg_ptrs, because otherwise the parameter pack version |
| 2935 | // below gets called instead (probably resulting in a segfault). |
| 2936 | /*! Launch the kernel. |
| 2937 | * |
| 2938 | * \param arg_ptrs A vector of pointers to each function argument for the |
| 2939 | * kernel. |
| 2940 | * \param arg_types A vector of function argument types represented |
| 2941 | * as code-strings. This parameter is optional and is only used to print |
| 2942 | * out the function signature. |
| 2943 | */ |
| 2944 | inline CUresult launch( |
| 2945 | std::vector<void*> arg_ptrs = std::vector<void*>(), |
| 2946 | jitify::detail::vector<std::string> arg_types = 0) const { |
| 2947 | return _impl->launch(arg_ptrs, arg_types); |
| 2948 | } |
| 2949 | // Regular function call syntax |
| 2950 | /*! Launch the kernel. |
| 2951 | * |
| 2952 | * \see launch |
| 2953 | */ |
| 2954 | template <typename... ArgTypes> |
| 2955 | inline CUresult operator()(ArgTypes... args) const { |
| 2956 | return this->launch(args...); |
| 2957 | } |
| 2958 | /*! Launch the kernel. |
| 2959 | * |
| 2960 | * \param args Function arguments for the kernel. |
| 2961 | */ |
| 2962 | template <typename... ArgTypes> |
| 2963 | inline CUresult launch(ArgTypes... args) const { |
| 2964 | return this->launch(std::vector<void*>({(void*)&args...}), |
| 2965 | {reflection::reflect<ArgTypes>()...}); |
| 2966 | } |
| 2967 | }; |
| 2968 | |
| 2969 | /*! An object representing a kernel instantiation made up of a Kernel and |
| 2970 | * template arguments. |