Skip to content

Instantly share code, notes, and snippets.

@gmarkall
Created January 14, 2015 11:38
Show Gist options
  • Save gmarkall/8ea8e3373d5584e88971 to your computer and use it in GitHub Desktop.
Save gmarkall/8ea8e3373d5584e88971 to your computer and use it in GitHub Desktop.
Generate debug and line number info in matrixMulDynlinkGIT CUDA 7 RC example for GPU PC Sampling
From 6db58ab934b7210787f5bd7ad92f7050f43edcb3 Mon Sep 17 00:00:00 2001
From: Graham Markall <[email protected]>
Date: Wed, 14 Jan 2015 11:10:28 +0000
Subject: [PATCH 1/2] Add debug and lineinfo options
---
matrixMulDynlinkJIT.cpp | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/matrixMulDynlinkJIT.cpp b/matrixMulDynlinkJIT.cpp
index 2015509..af5695c 100644
--- a/matrixMulDynlinkJIT.cpp
+++ b/matrixMulDynlinkJIT.cpp
@@ -160,7 +160,7 @@ CUresult initCUDA(int argc, char **argv, CUfunction *pMatrixMul, int *block_size
// setup JIT compilation options and perform compilation
{
// in this branch we use compilation with parameters
- const unsigned int jitNumOptions = 3;
+ const unsigned int jitNumOptions = 5;
CUjit_option *jitOptions = new CUjit_option[jitNumOptions];
void **jitOptVals = new void *[jitNumOptions];
@@ -179,6 +179,16 @@ CUresult initCUDA(int argc, char **argv, CUfunction *pMatrixMul, int *block_size
int jitRegCount = 32;
jitOptVals[2] = (void *)(size_t)jitRegCount;
+ // Build with debug info
+ jitOptions[3] = CU_JIT_GENERATE_DEBUG_INFO;
+ int jitDebugInfo = 1;
+ jitOptVals[3] = (void*)(size_t)jitDebugInfo;
+
+ // Generate line number info
+ jitOptions[4] = CU_JIT_GENERATE_LINE_INFO;
+ int jitLineInfo = 1;
+ jitOptVals[4] = (void*)(size_t)jitLineInfo;
+
// compile with set parameters
printf("> Compiling CUDA module\n");
--
2.1.2
From d091fb7a5a165607eaacdf5a702dd9ec63653590 Mon Sep 17 00:00:00 2001
From: Graham Markall <[email protected]>
Date: Wed, 14 Jan 2015 11:11:49 +0000
Subject: [PATCH 2/2] Copy missing CUjit_option_enum entries from cuda.h
---
cuda_drvapi_dynlink_cuda.h | 34 +++++++++++++++++++++++++++++++++-
1 file changed, 33 insertions(+), 1 deletion(-)
diff --git a/cuda_drvapi_dynlink_cuda.h b/cuda_drvapi_dynlink_cuda.h
index 84c55bf..0d1ce38 100644
--- a/cuda_drvapi_dynlink_cuda.h
+++ b/cuda_drvapi_dynlink_cuda.h
@@ -407,7 +407,39 @@ typedef enum CUjit_option_enum
* Choice is based on supplied ::CUjit_fallback_enum.\n
* Option type: unsigned int for enumerated type ::CUjit_fallback_enum
*/
- CU_JIT_FALLBACK_STRATEGY
+ CU_JIT_FALLBACK_STRATEGY,
+
+ /**
+ * Specifies whether to create debug information in output (-g)
+ * (0: false, default)\n
+ * Option type: int\n
+ * Applies to: compiler and linker
+ */
+ CU_JIT_GENERATE_DEBUG_INFO,
+
+ /**
+ * Generate verbose log messages (0: false, default)\n
+ * Option type: int\n
+ * Applies to: compiler and linker
+ */
+ CU_JIT_LOG_VERBOSE,
+
+ /**
+ * Generate line number information (-lineinfo) (0: false, default)\n
+ * Option type: int\n
+ * Applies to: compiler only
+ */
+ CU_JIT_GENERATE_LINE_INFO,
+
+ /**
+ * Specifies whether to enable caching explicitly (-dlcm) \n
+ * Choice is based on supplied ::CUjit_cacheMode_enum.\n
+ * Option type: unsigned int for enumerated type ::CUjit_cacheMode_enum\n
+ * Applies to: compiler only
+ */
+ CU_JIT_CACHE_MODE,
+
+ CU_JIT_NUM_OPTIONS
} CUjit_option;
--
2.1.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment