Added cuda logs for the engine, which shows device info and memory usage

remotes/origin/master-1.0.x
Anoop Saldanha 16 years ago committed by Victor Julien
parent 30940c9a94
commit 1a5ee37bd3

@ -2829,19 +2829,46 @@ int SigGroupBuild (DetectEngineCtx *de_ctx) {
SigAddressPrepareStage2(de_ctx);
#ifdef __SC_CUDA_SUPPORT__
unsigned int cuda_total = 0;
unsigned int cuda_free_before_alloc = 0;
/* we register a module that would require cuda handler service. This
* module would hold the context for all the patterns in the rules */
de_ctx->cuda_rc_mod_handle = SCCudaHlRegisterModule("SC_RULES_CONTENT_B2G_CUDA");
if (de_ctx->mpm_matcher == MPM_B2G_CUDA) {
CUcontext dummy_context;
if (SCCudaHlGetCudaContext(&dummy_context,
de_ctx->cuda_rc_mod_handle) == -1) {
SCLogError(SC_ERR_B2G_CUDA_ERROR, "Error getting a cuda context for the "
"module SC_RULES_CONTENT_B2G_CUDA");
}
if (SCCudaMemGetInfo(&cuda_free_before_alloc, &cuda_total) == 0) {
SCLogInfo("Total Memory available in the CUDA context used for mpm "
"with b2g: %.2f MB", cuda_total/(1024.0 * 1024.0));
SCLogInfo("Free Memory available in the CUDA context used for b2g "
"mpm before any allocation is made on the GPU for the "
"context: %.2f MB", cuda_free_before_alloc/(1024.0 * 1024.0));
}
}
#endif
SigAddressPrepareStage3(de_ctx);
#ifdef __SC_CUDA_SUPPORT__
unsigned int cuda_free_after_alloc = 0;
/* if a user has selected some other mpm algo other than b2g_cuda, inspite of
* enabling cuda support, then no cuda contexts or cuda vars would be created.
* Pop the cuda context, only on confirming that the MPM algo selected is the
* CUDA mpm algo */
if (de_ctx->mpm_matcher == MPM_B2G_CUDA) {
if (SCCudaMemGetInfo(&cuda_free_after_alloc, &cuda_total) == 0) {
SCLogInfo("Free Memory available in the CUDA context used for b2g mpm "
"after allocation is made on the GPU for the context: %.2f MB",
cuda_free_after_alloc/(1024.0 * 1024.0));
SCLogInfo("Total memory consumed by the CUDA context for the b2g mpm: "
"%.2f MB", (cuda_free_before_alloc/(1024.0 * 1024.0)) -
(cuda_free_after_alloc/(1024.0 * 1024.0)));
}
/* the AddressPrepareStage3 actually handles the creation of device
* pointers on the gpu. The cuda context that stage3 used would still be
* attached to this host thread. We need to pop this cuda context so that

@ -390,11 +390,6 @@ int main(int argc, char **argv)
/* Initialize the configuration module. */
ConfInit();
#ifdef __SC_CUDA_SUPPORT__
/* Init the CUDA environment */
SCCudaInitCudaEnvironment();
#endif
struct option long_opts[] = {
{"dump-config", 0, &dump_config, 1},
{"pfring-int", required_argument, 0, 0},
@ -563,6 +558,11 @@ int main(int argc, char **argv)
SCLogInfo("This is %s version %s", PROG_NAME, PROG_VER);
UtilCpuPrintSummary();
#ifdef __SC_CUDA_SUPPORT__
/* Init the CUDA environment */
SCCudaInitCudaEnvironment();
#endif
if (!CheckValidDaemonModes(daemon, run_mode)) {
exit(EXIT_FAILURE);
}

@ -3944,6 +3944,43 @@ void SCCudaPrintDeviceList(SCCudaDevices *devices)
return;
}
/**
* \brief Prints some basic information for the default device(the first devie)
* we will be using on this cuda platform for use by our engine. This
* function is basically to be used to print some minimal information to
* the user at engine startup.
*
* \param devices Pointer to a SCCudaDevices instance that holds information on
* the devices.
*/
void SCCudaPrintBasicDeviceInfo(SCCudaDevices *devices)
{
int i = 0;
if (devices == NULL) {
SCLogError(SC_ERR_CUDA_ERROR, "CUDA environment not initialized. "
"Please initialized the CUDA environment by calling "
"SCCudaInitCudaEnvironment() before making any calls "
"to the CUDA API.");
return;
}
SCLogInfo("Printing graphics card device details used by our engine");
SCLogInfo("No of devices: %d", devices->count);
for (i = 0; i < devices->count && i <= 1; i++) {
SCLogInfo("Device Name: %s", devices->devices[i]->name);
SCLogInfo("Device Major Revision: %d", devices->devices[i]->major_rev);
SCLogInfo("Device Minor Revision: %d", devices->devices[i]->minor_rev);
SCLogInfo("Device Multiprocessor Count: %d",
devices->devices[i]->attr_multiprocessor_count);
SCLogInfo("Device Clock Rate: %d", devices->devices[i]->attr_clock_rate);
SCLogInfo("Device Clock Frequency: %d", devices->devices[i]->prop.clockRate);
}
return;
}
/**
* \brief Gets the device list, for the CUDA platform environment initialized by
* the engine.
@ -4013,6 +4050,8 @@ int SCCudaInitCudaEnvironment(void)
goto error;
}
SCCudaPrintBasicDeviceInfo(devices);
return 0;
error:

@ -154,6 +154,7 @@ int SCCudaCtxSynchronize(void);
int SCCudaDriverGetVersion(int *);
void SCCudaPrintDeviceList(SCCudaDevices *);
void SCCudaPrintBasicDeviceInfo(SCCudaDevices *);
SCCudaDevices *SCCudaGetDeviceList(void);
int SCCudaInitCudaEnvironment(void);

Loading…
Cancel
Save