From 0ce86efe4057aa93066ec473f00fe0e9ba7e7480 Mon Sep 17 00:00:00 2001 From: Martin Beyer Date: Sat, 11 Sep 2010 17:47:52 +0200 Subject: [PATCH] cuda handlers support multiple CUmodules per context --- src/util-cuda-handlers.c | 278 ++++++++++++++++++++++++++------------- src/util-cuda-handlers.h | 18 ++- src/util-mpm-b2g-cuda.c | 50 ++++--- 3 files changed, 234 insertions(+), 112 deletions(-) diff --git a/src/util-cuda-handlers.c b/src/util-cuda-handlers.c index 305c9cfed8..75d496b307 100644 --- a/src/util-cuda-handlers.c +++ b/src/util-cuda-handlers.c @@ -47,9 +47,8 @@ * cuda_context that is associated with the handle, against which you * want to call SCCudaHlGetCudaModule(). * - * \todo Provide support for multiple cuda context storage and creating multiple - * cuda modules against a cuda_context, although it is highly unlikely we - * would need this feature. + * \todo Provide support for multiple cuda context storage, although it is + * highly unlikely we would need this feature. * * We also need to use a mutex for module_data. */ @@ -187,6 +186,20 @@ void SCCudaHlCleanProfiles(void) return; } +/** + * \internal + * \brief Get a unique handle for a new module registration. This new handle + * returned uniquely represents a module. All future calls to functions + * requires suppling this handle. + * + * \param module_handle A unique module handle that needs to used to refer + * to data(like cuda_contexts, cuda_modules, device pointers). + */ +static int SCCudaHlGetUniqueHandle(void) +{ + return module_handle++; +} + /** * \internal * \brief Returns a SCCudaHlModuleData instance from the global data store @@ -210,25 +223,61 @@ SCCudaHlModuleData *SCCudaHlGetModuleData(uint8_t handle) return data; } +/** + * \internal + * \brief Returns a SCCudaHlModuleCUmodule instance that matches the cumodule_handle + * from a SCCudaHlModuleData. + * + * \param data The module data this CUmodule belongs to, obtained by a call to + * SCCudaHlGetModuleData() + * \param cumodule_handle The handle for the SCCudaHlModuleCUmodule that has to be returned. + * + * \retval The SCCudaHlModuleCUmodule instance that matches the handle. + */ +static SCCudaHlModuleCUmodule *SCCudaHlGetModuleCUmodule(SCCudaHlModuleData *data, uint8_t cumodule_handle) +{ + SCCudaHlModuleCUmodule *cumodule = NULL; + + if (data == NULL) { + SCLogError(SC_ERR_INVALID_ARGUMENT, "Argument data cannot be NULL"); + return NULL; + } + + cumodule = data->cuda_modules; + if (cumodule == NULL) { + SCLogError(SC_ERR_CUDA_HANDLER_ERROR, + "No cumodule registered by the cumodule_handle %"PRIu8, cumodule_handle); + return NULL; + } + + while (cumodule != NULL && cumodule->cuda_module_handle != cumodule_handle) { + cumodule = cumodule->next; + } + + return cumodule; +} + /** * \brief Returns a cuda_module against the handle in the argument. * * If a cuda_module is not present for a handle, it is created * and associated with this handle and the cuda_module is returned - * in the argument. If a cuda_module is already present for - * a handle, it is returned. + * in the argument. * - * \param p_context Pointer to a cuda context instance that should be updated - * with a cuda context. + * \param p_module Pointer to a cuda module instance that should be updated + * with a cuda module. * \param handle A unique handle which identifies a module. Obtained from * a call to SCCudaHlGetUniqueHandle(). * - * \retval 0 On success. - * \retval -1 On failure. + * \retval A unique handle within the module that is associated with the + * loaded CUmodule. Needed for future API calls. + * \retval -1 on failure. */ int SCCudaHlGetCudaModuleFromFile(CUmodule *p_module, const char *filename, int handle) { SCCudaHlModuleData *data = NULL; + SCCudaHlModuleCUmodule *new_module_cumodule = NULL; + SCCudaHlModuleCUmodule *module_cumodules = NULL; if (p_module == NULL) { SCLogError(SC_ERR_INVALID_ARGUMENTS, "Error invalid arguments" @@ -239,14 +288,14 @@ int SCCudaHlGetCudaModuleFromFile(CUmodule *p_module, const char *filename, int /* check if the particular module that wants a CUDA module is already * registered or not. If it is registered, check if a context has * been associated with the module. If yes, then we can go ahead and - * create a cuda module or return the reference to the cuda module if - * we already have a cuda module associated with the module. If no, " - * log warning and get out of here */ + * create a cuda module and associate it with the module referenced by + * the handle in the functions arguments. If no, log warning and get + * out of here */ if ( ((data = SCCudaHlGetModuleData(handle)) == NULL) || (data->cuda_context == 0)) { SCLogDebug("Module not registered or no cuda context associated with " "this module. You can't create a CUDA module without" - "associatin a context with a module first. To use this " + "associating a context with a module first. To use this " "registration facility, first register a module using " "context using SCCudaHlRegisterModule(), and then register " "a cuda context with that module using " @@ -255,41 +304,40 @@ int SCCudaHlGetCudaModuleFromFile(CUmodule *p_module, const char *filename, int return -1; } - /* we already have a cuda module associated with this module. Return the - * cuda module */ - if (data->cuda_module != 0) { - p_module[0] = data->cuda_module; - return 0; + /* Register new CUmodule in the module */ + new_module_cumodule = SCMalloc(sizeof(SCCudaHlModuleCUmodule)); + if (new_module_cumodule == NULL) { + SCLogError(SC_ERR_FATAL, "Fatal error encountered in SCCudaHlRegisterModule. Exiting..."); + exit(EXIT_FAILURE); } + memset(new_module_cumodule, 0, sizeof(SCCudaHlModuleCUmodule)); - /* we don't have a cuda module associated with this module. Create a - * cuda module, update the module with this cuda module reference and - * then return the module refernce back to the calling function using + /* Create a cuda module, update the module with this cuda module reference + * and then return the module reference back to the calling function using * the argument */ if (SCCudaModuleLoad(p_module, filename) == -1) goto error; - data->cuda_module = p_module[0]; - return 0; + new_module_cumodule->cuda_module = p_module[0]; + new_module_cumodule->cuda_module_handle = SCCudaHlGetUniqueHandle(); + + /* insert it into the cuda_modules list for the module instance */ + if (data->cuda_modules == NULL) { + data->cuda_modules = new_module_cumodule; + return new_module_cumodule->cuda_module_handle; + } + + module_cumodules = data->cuda_modules; + while (module_cumodules->next != NULL) + module_cumodules = module_cumodules->next; + module_cumodules->next = new_module_cumodule; + + return new_module_cumodule->cuda_module_handle; error: return -1; } -/** - * \internal - * \brief Get a unique handle for a new module registration. This new handle - * returned uniquely represents a module. All future calls to functions - * requires suppling this handle. - * - * \param module_handle A unique module handle that needs to used to refer - * to data(like cuda_contexts, cuda_modules, device pointers). - */ -static int SCCudaHlGetUniqueHandle(void) -{ - return module_handle++; -} - /** * \brief Returns a cuda context against the handle in the argument. * @@ -368,20 +416,22 @@ int SCCudaHlGetCudaContext(CUcontext *p_context, char *cuda_profile, int handle) * * If a cuda_module is not present for a handle, it is created * and associated with this handle and the cuda_module is returned - * in the argument. If a cuda_module is already present for - * a handle, it is returned. + * in the argument. * - * \param p_context Pointer to a cuda context instance that should be updated - * with a cuda context. + * \param p_module Pointer to a cuda module instance that should be updated + * with a cuda module. * \param handle A unique handle which identifies a module. Obtained from * a call to SCCudaHlGetUniqueHandle(). * - * \retval 0 On success. - * \retval -1 On failure. + * \retval A unique handle within the module that is associated with the + * loaded CUmodule. Needed for future API calls. + * \retval -1 on failure. */ int SCCudaHlGetCudaModule(CUmodule *p_module, const char *ptx_image, int handle) { SCCudaHlModuleData *data = NULL; + SCCudaHlModuleCUmodule *new_module_cumodule = NULL; + SCCudaHlModuleCUmodule *module_cumodules = NULL; if (p_module == NULL) { SCLogError(SC_ERR_INVALID_ARGUMENTS, "Error invalid arguments" @@ -392,14 +442,14 @@ int SCCudaHlGetCudaModule(CUmodule *p_module, const char *ptx_image, int handle) /* check if the particular module that wants a CUDA module is already * registered or not. If it is registered, check if a context has * been associated with the module. If yes, then we can go ahead and - * create a cuda module or return the reference to the cuda module if - * we already have a cuda module associated with the module. If no, " - * log warning and get out of here */ + * create a cuda module and associate it with the module referenced by + * the handle in the functions arguments. If no, log warning and get + * out of here */ if ( ((data = SCCudaHlGetModuleData(handle)) == NULL) || (data->cuda_context == 0)) { SCLogDebug("Module not registered or no cuda context associated with " "this module. You can't create a CUDA module without" - "associatin a context with a module first. To use this " + "associating a context with a module first. To use this " "registration facility, first register a module using " "context using SCCudaHlRegisterModule(), and then register " "a cuda context with that module using " @@ -408,22 +458,35 @@ int SCCudaHlGetCudaModule(CUmodule *p_module, const char *ptx_image, int handle) return -1; } - /* we already have a cuda module associated with this module. Return the - * cuda module */ - if (data->cuda_module != 0) { - p_module[0] = data->cuda_module; - return 0; + /* Register new CUmodule in the module */ + new_module_cumodule = SCMalloc(sizeof(SCCudaHlModuleCUmodule)); + if (new_module_cumodule == NULL) { + SCLogError(SC_ERR_FATAL, "Fatal error encountered in SCCudaHlRegisterModule. Exiting..."); + exit(EXIT_FAILURE); } + memset(new_module_cumodule, 0, sizeof(SCCudaHlModuleCUmodule)); - /* we don't have a cuda module associated with this module. Create a - * cuda module, update the module with this cuda module reference and - * then return the module refernce back to the calling function using + /* Create a cuda module, update the module with this cuda module reference + * and then return the module reference back to the calling function using * the argument */ if (SCCudaModuleLoadData(p_module, (void *)ptx_image) == -1) goto error; - data->cuda_module = p_module[0]; - return 0; + new_module_cumodule->cuda_module = p_module[0]; + new_module_cumodule->cuda_module_handle = SCCudaHlGetUniqueHandle(); + + /* insert it into the cuda_modules list for the module instance */ + if (data->cuda_modules == NULL) { + data->cuda_modules = new_module_cumodule; + return new_module_cumodule->cuda_module_handle; + } + + module_cumodules = data->cuda_modules; + while (module_cumodules->next != NULL) + module_cumodules = module_cumodules->next; + module_cumodules->next = new_module_cumodule; + + return new_module_cumodule->cuda_module_handle; error: return -1; @@ -441,10 +504,10 @@ int SCCudaHlGetCudaModule(CUmodule *p_module, const char *ptx_image, int handle) * \retval module_device_ptr Pointer to the device pointer instance on finding * it; NULL otherwise. */ -SCCudaHlModuleDevicePointer *SCCudaHlCudaDevicePtrAvailable(SCCudaHlModuleData *data, +SCCudaHlModuleDevicePointer *SCCudaHlCudaDevicePtrAvailable(SCCudaHlModuleCUmodule *cumodule, const char *name) { - SCCudaHlModuleDevicePointer *module_device_ptr = data->device_ptrs; + SCCudaHlModuleDevicePointer *module_device_ptr = cumodule->device_ptrs; while (module_device_ptr != NULL && strcmp(module_device_ptr->name, name) != 0) { @@ -473,14 +536,19 @@ SCCudaHlModuleDevicePointer *SCCudaHlCudaDevicePtrAvailable(SCCudaHlModuleData * * hold atleast size bytes in memory. * \param handle A unique handle which identifies a module. Obtained from * a call to SCCudaHlGetUniqueHandle(). + * \param cumodule_handle A handle that identifies the CUmodule within the above module. + * Obtained from a call to SCCudaHlGetCudaModule() or + * SCCudaHlGetCudaModuleFromFile(). * * \retval 0 On success. * \retval -1 On failure. */ int SCCudaHlGetCudaDevicePtr(CUdeviceptr *device_ptr, const char *name, - size_t size, void *host_ptr, int handle) + size_t size, void *host_ptr, int handle, + int cumodule_handle) { SCCudaHlModuleData *data = NULL; + SCCudaHlModuleCUmodule *cumodule = NULL; SCCudaHlModuleDevicePointer *new_module_device_ptr = NULL; SCCudaHlModuleDevicePointer *module_device_ptr = NULL; @@ -500,7 +568,7 @@ int SCCudaHlGetCudaDevicePtr(CUdeviceptr *device_ptr, const char *name, (data->cuda_context == 0)) { SCLogDebug("Module not registered or no cuda context associated with " "this module. You can't create a CUDA module without" - "associatin a context with a module first. To use this " + "associating a context with a module first. To use this " "registration facility, first register a module using " "context using SCCudaHlRegisterModule(), and then register " "a cuda context with that module using " @@ -509,9 +577,17 @@ int SCCudaHlGetCudaDevicePtr(CUdeviceptr *device_ptr, const char *name, goto error; } + if ( (cumodule = SCCudaHlGetModuleCUmodule(data, cumodule_handle)) == NULL ) { + SCLogDebug("CUmodule not registered with the module. Before you can request" + "a device pointer for a module you need to load the CUmodule into" + "the engine module using SCCudaHlGetCudaModule() or" + "SCCudaHlGetCudaModuleFromFile()."); + goto error; + } + /* if we already have a device pointer registered by this name return the * cuda device pointer instance */ - if ( (module_device_ptr = SCCudaHlCudaDevicePtrAvailable(data, name)) != NULL) { + if ( (module_device_ptr = SCCudaHlCudaDevicePtrAvailable(cumodule, name)) != NULL) { device_ptr[0] = module_device_ptr->d_ptr; return 0; } @@ -542,12 +618,12 @@ int SCCudaHlGetCudaDevicePtr(CUdeviceptr *device_ptr, const char *name, device_ptr[0] = new_module_device_ptr->d_ptr; /* insert it into the device_ptr list for the module instance */ - if (data->device_ptrs == NULL) { - data->device_ptrs = new_module_device_ptr; + if (cumodule->device_ptrs == NULL) { + cumodule->device_ptrs = new_module_device_ptr; return 0; } - module_device_ptr = data->device_ptrs; + module_device_ptr = cumodule->device_ptrs; while (module_device_ptr->next != NULL) module_device_ptr = module_device_ptr->next; module_device_ptr->next = new_module_device_ptr; @@ -570,13 +646,16 @@ int SCCudaHlGetCudaDevicePtr(CUdeviceptr *device_ptr, const char *name, * module for its existance. * \param handle A unique handle which identifies a module. Obtained from * a call to SCCudaHlGetUniqueHandle(). - * + * \param cumodule A handle that identifies the CUmodule within the above module. + * Obtained from a call to SCCudaHlGetCudaModule() or + * SCCudaHlGetCudaModuleFromFile(). * \retval 0 On success. * \retval -1 On failure. */ -int SCCudaHlFreeCudaDevicePtr(const char *name, int handle) +int SCCudaHlFreeCudaDevicePtr(const char *name, int handle, int cumodule_handle) { SCCudaHlModuleData *data = NULL; + SCCudaHlModuleCUmodule *cumodule = NULL; SCCudaHlModuleDevicePointer *module_device_ptr = NULL; SCCudaHlModuleDevicePointer *temp_module_device_ptr = NULL; @@ -595,7 +674,7 @@ int SCCudaHlFreeCudaDevicePtr(const char *name, int handle) (data->cuda_context == 0)) { SCLogDebug("Module not registered or no cuda context associated with " "this module. You can't create a CUDA module without" - "associatin a context with a module first. To use this " + "associating a context with a module first. To use this " "registration facility, first register a module using " "context using SCCudaHlRegisterModule(), and then register " "a cuda context with that module using " @@ -604,18 +683,25 @@ int SCCudaHlFreeCudaDevicePtr(const char *name, int handle) goto error; } - /* if we already have a device pointer registered by this name return the - * cuda device pointer instance */ - if ( (module_device_ptr = SCCudaHlCudaDevicePtrAvailable(data, name)) == NULL) { + if ( (cumodule = SCCudaHlGetModuleCUmodule(data, cumodule_handle)) == NULL ) { + SCLogDebug("CUmodule not registered with the module. Before you can request" + "a device pointer for a module you need to load the CUmodule into" + "the engine module using SCCudaHlGetCudaModule() or" + "SCCudaHlGetCudaModuleFromFile()."); + goto error; + } + + /* if we do not have a device pointer registered by this name get out */ + if ( (module_device_ptr = SCCudaHlCudaDevicePtrAvailable(cumodule, name)) == NULL) { goto error; } SCCudaMemFree(module_device_ptr->d_ptr); module_device_ptr->d_ptr = 0; - if (module_device_ptr == data->device_ptrs) { - data->device_ptrs = data->device_ptrs->next; + if (module_device_ptr == cumodule->device_ptrs) { + cumodule->device_ptrs = cumodule->device_ptrs->next; } else { - temp_module_device_ptr = data->device_ptrs; + temp_module_device_ptr = cumodule->device_ptrs; while (strcmp(temp_module_device_ptr->next->name, name) != 0) { temp_module_device_ptr = temp_module_device_ptr->next; } @@ -781,6 +867,8 @@ int SCCudaHlDeRegisterModule(const char *name) { SCCudaHlModuleData *data = NULL; SCCudaHlModuleData *prev_data = NULL; + SCCudaHlModuleCUmodule *cumodule = NULL; + SCCudaHlModuleCUmodule *temp_cumodule = NULL; SCCudaHlModuleDevicePointer *device_ptr = NULL; SCCudaHlModuleDevicePointer *temp_device_ptr = NULL; int module_handle = SCCudaHlGetModuleHandle(name); @@ -795,23 +883,37 @@ int SCCudaHlDeRegisterModule(const char *name) return -1; } - /* the applicationg must take care to check that the following cuda context + /* the application must take care to check that the following cuda context * which is being freed is floating(not attached to any host thread) */ if (data->cuda_context != 0) SCCudaCtxPushCurrent(data->cuda_context); - /* looks like we do have a module registered by this name */ - /* first clean the cuda device pointers */ - device_ptr = data->device_ptrs; - while (device_ptr != NULL) { - temp_device_ptr = device_ptr; - device_ptr = device_ptr->next; - if (SCCudaMemFree(temp_device_ptr->d_ptr) == -1) + /* looks like we do have a module registered by this name. + * Go through all CUmodules registered in this module and + * free cuda device pointers and unload the module. + */ + cumodule = data->cuda_modules; + while (cumodule != NULL) { + /* free all device pointers */ + device_ptr = cumodule->device_ptrs; + while (device_ptr != NULL) { + temp_device_ptr = device_ptr; + device_ptr = device_ptr->next; + if (SCCudaMemFree(temp_device_ptr->d_ptr) == -1) + goto error; + SCFree(temp_device_ptr->name); + SCFree(temp_device_ptr); + } + cumodule->device_ptrs = NULL; + + /* unload the cuda module */ + temp_cumodule = cumodule; + cumodule = cumodule->next; + if (SCCudaModuleUnload(temp_cumodule->cuda_module) == -1) goto error; - SCFree(temp_device_ptr->name); - SCFree(temp_device_ptr); + SCFree(temp_cumodule); } - data->device_ptrs = NULL; + data->cuda_modules = NULL; if (data->name != NULL) SCFree((void *)data->name); @@ -819,12 +921,6 @@ int SCCudaHlDeRegisterModule(const char *name) /* clean the dispatcher function registered */ data->SCCudaHlDispFunc = NULL; - /* unload the cuda module */ - if (data->cuda_module != 0) { - if (SCCudaModuleUnload(data->cuda_module) == -1) - goto error; - } - /* destroy the cuda context */ if (data->cuda_context != 0) { if (SCCudaCtxDestroy(data->cuda_context) == -1) diff --git a/src/util-cuda-handlers.h b/src/util-cuda-handlers.h index 2d135abaaf..1b2e04b18d 100644 --- a/src/util-cuda-handlers.h +++ b/src/util-cuda-handlers.h @@ -47,6 +47,17 @@ typedef struct SCCudaHlModuleDevicePointer_ { struct SCCudaHlModuleDevicePointer_ *next; } SCCudaHlModuleDevicePointer; +typedef struct SCCudaHlModuleCUmodule_ { + /* Handle for this CUmodule. This has to be first obtained from the + * call to SCCudaHlGetCudaModule() or SCCudaHlGetCudaModuleFromFile() */ + int cuda_module_handle; + + CUmodule cuda_module; + SCCudaHlModuleDevicePointer *device_ptrs; + + struct SCCudaHlModuleCUmodule_ *next; +} SCCudaHlModuleCUmodule; + typedef struct SCCudaHlModuleData_ { /* The unique module handle. This has to be first obtained from the * call to SCCudaHlGetUniqueHandle() */ @@ -54,9 +65,8 @@ typedef struct SCCudaHlModuleData_ { int handle; CUcontext cuda_context; - CUmodule cuda_module; + SCCudaHlModuleCUmodule *cuda_modules; void *(*SCCudaHlDispFunc)(void *); - SCCudaHlModuleDevicePointer *device_ptrs; struct SCCudaHlModuleData_ *next; } SCCudaHlModuleData; @@ -82,8 +92,8 @@ void SCCudaHlRestoreBackupRegisteredProfiles(void); int SCCudaHlGetCudaContext(CUcontext *, char *, int); int SCCudaHlGetCudaModule(CUmodule *, const char *, int); int SCCudaHlGetCudaModuleFromFile(CUmodule *, const char *, int); -int SCCudaHlGetCudaDevicePtr(CUdeviceptr *, const char *, size_t, void *, int); -int SCCudaHlFreeCudaDevicePtr(const char *, int); +int SCCudaHlGetCudaDevicePtr(CUdeviceptr *, const char *, size_t, void *, int, int); +int SCCudaHlFreeCudaDevicePtr(const char *, int, int); int SCCudaHlRegisterDispatcherFunc(void *(*SCCudaHlDispFunc)(void *), int); SCCudaHlModuleData *SCCudaHlGetModuleData(uint8_t); diff --git a/src/util-mpm-b2g-cuda.c b/src/util-mpm-b2g-cuda.c index b92303f6b6..35160e18a2 100644 --- a/src/util-mpm-b2g-cuda.c +++ b/src/util-mpm-b2g-cuda.c @@ -1656,6 +1656,7 @@ uint32_t B2gCudaSearch1(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, typedef struct B2gCudaMpmThreadCtxData_ { int b2g_cuda_module_handle; + int b2g_cuda_cumodule_handle; CUcontext b2g_cuda_context; CUmodule b2g_cuda_module; @@ -1725,16 +1726,18 @@ TmEcode B2gCudaMpmDispThreadInit(ThreadVars *tv, void *initdata, void **data) } #if defined(__x86_64__) || defined(__ia64__) - if (SCCudaHlGetCudaModule(&tctx->b2g_cuda_module, b2g_cuda_ptx_image_64_bit, - module_data->handle) == -1) { - SCLogError(SC_ERR_B2G_CUDA_ERROR, "Error getting a cuda module"); - } + tctx->b2g_cuda_cumodule_handle = SCCudaHlGetCudaModule(&tctx->b2g_cuda_module, + b2g_cuda_ptx_image_64_bit, + module_data->handle); #else - if (SCCudaHlGetCudaModule(&tctx->b2g_cuda_module, b2g_cuda_ptx_image_32_bit, - module_data->handle) == -1) { + tctx->b2g_cuda_cumodule_handle = SCCudaHlGetCudaModule(&tctx->b2g_cuda_module, + b2g_cuda_ptx_image_32_bit, + module_data->handle); +#endif + if (tctx->b2g_cuda_cumodule_handle == -1) { SCLogError(SC_ERR_B2G_CUDA_ERROR, "Error getting a cuda module"); + goto error; } -#endif if (SCCudaModuleGetFunction(&tctx->b2g_cuda_search_kernel, tctx->b2g_cuda_module, @@ -1807,13 +1810,15 @@ TmEcode B2gCudaMpmDispThreadInit(ThreadVars *tv, void *initdata, void **data) sizeof(uint16_t) * (profile->packet_size_limit + 1) * profile->packet_buffer_limit, - NULL, module_data->handle) == -1) { + NULL, module_data->handle, + tctx->b2g_cuda_cumodule_handle) == -1) { goto error; } if (SCCudaHlGetCudaDevicePtr(&tctx->cuda_g_u8_lowercasetable, "G_U8_LOWERCASETABLE", 256 * sizeof(char), - g_u8_lowercasetable, module_data->handle) == -1) { + g_u8_lowercasetable, module_data->handle, + tctx->b2g_cuda_cumodule_handle) == -1) { goto error; } @@ -1822,21 +1827,24 @@ TmEcode B2gCudaMpmDispThreadInit(ThreadVars *tv, void *initdata, void **data) profile->packet_buffer_limit * (profile->packet_size_limit + sizeof(SCCudaPBPacketDataForGPUNonPayload)), - NULL, module_data->handle) == -1) { + NULL, module_data->handle, + tctx->b2g_cuda_cumodule_handle) == -1) { goto error; } if (SCCudaHlGetCudaDevicePtr(&tctx->cuda_packets_offset_buffer, "MPM_B2G_PACKETS_BUFFER_OFFSETS", sizeof(uint32_t) * profile->packet_buffer_limit, - NULL, module_data->handle) == -1) { + NULL, module_data->handle, + tctx->b2g_cuda_cumodule_handle) == -1) { goto error; } if (SCCudaHlGetCudaDevicePtr(&tctx->cuda_packets_payload_offset_buffer, "MPM_B2G_PACKETS_PAYLOAD_BUFFER_OFFSETS", sizeof(uint32_t) * profile->packet_buffer_limit, - NULL, module_data->handle) == -1) { + NULL, module_data->handle, + tctx->b2g_cuda_cumodule_handle) == -1) { goto error; } @@ -1933,13 +1941,21 @@ TmEcode B2gCudaMpmDispThreadDeInit(ThreadVars *tv, void *data) } else { free(tctx->results_buffer); } - SCCudaHlFreeCudaDevicePtr("MPM_B2G_RESULTS", tctx->b2g_cuda_module_handle); - SCCudaHlFreeCudaDevicePtr("MPM_B2G_PACKETS_BUFFER", tctx->b2g_cuda_module_handle); + SCCudaHlFreeCudaDevicePtr("MPM_B2G_RESULTS", + tctx->b2g_cuda_module_handle, + tctx->b2g_cuda_cumodule_handle); + SCCudaHlFreeCudaDevicePtr("MPM_B2G_PACKETS_BUFFER", + tctx->b2g_cuda_module_handle, + tctx->b2g_cuda_cumodule_handle); SCCudaHlFreeCudaDevicePtr("MPM_B2G_PACKETS_BUFFER_OFFSETS", - tctx->b2g_cuda_module_handle); + tctx->b2g_cuda_module_handle, + tctx->b2g_cuda_cumodule_handle); SCCudaHlFreeCudaDevicePtr("MPM_B2G_PACKETS_PAYLOAD_BUFFER_OFFSETS", - tctx->b2g_cuda_module_handle); - SCCudaHlFreeCudaDevicePtr("G_U8_LOWERCASETABLE", tctx->b2g_cuda_module_handle); + tctx->b2g_cuda_module_handle, + tctx->b2g_cuda_cumodule_handle); + SCCudaHlFreeCudaDevicePtr("G_U8_LOWERCASETABLE", + tctx->b2g_cuda_module_handle, + tctx->b2g_cuda_cumodule_handle); free(tctx);