summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunyan He <junyan.he@intel.com>2016-04-22 16:28:19 +0800
committerJunyan He <junyan.he@intel.com>2016-04-22 16:28:19 +0800
commitd39b3d356496c86075001927419ef6b0a4a5b215 (patch)
tree951d5f3a9b58cfdd59947429e3b67bd5723ca58b
parentcaabffe3a38337aadfce6c5c585f5c52ea69a342 (diff)
init
-rw-r--r--libclapi/cl_alloc.c3
-rw-r--r--libclapi/cl_alloc.h15
-rw-r--r--libclapi/cl_mutex.c3
-rw-r--r--libclapi/cl_mutex.h16
-rw-r--r--libclapi/cl_platform_id.c2
5 files changed, 38 insertions, 1 deletions
diff --git a/libclapi/cl_alloc.c b/libclapi/cl_alloc.c
index ef68fe62..a0bffa2a 100644
--- a/libclapi/cl_alloc.c
+++ b/libclapi/cl_alloc.c
@@ -23,6 +23,8 @@
#include "cl_alloc.h"
#include "cl_internals.h"
+#ifdef CL_ALLOC_DEBUG
+
static pthread_mutex_t cl_alloc_log_lock;
static unsigned int cl_alloc_log_num;
@@ -196,3 +198,4 @@ void cl_alloc_report_unfreed(void)
pthread_mutex_unlock(&cl_alloc_log_lock);
}
+#endif
diff --git a/libclapi/cl_alloc.h b/libclapi/cl_alloc.h
index fde52f30..6cd5264c 100644
--- a/libclapi/cl_alloc.h
+++ b/libclapi/cl_alloc.h
@@ -22,6 +22,8 @@
#include <stdlib.h>
+#ifdef CL_ALLOC_DEBUG
+
/* Return a valid pointer for the requested memory block size */
extern void* cl_malloc(size_t sz, char* file, int line);
#define CL_MALLOC(SZ) cl_malloc(SZ, __FILE__, __LINE__)
@@ -46,5 +48,18 @@ extern void cl_free(void *ptr, char* file, int line);
* allocation still unfreed
*/
extern void cl_alloc_report_unfreed(void);
+#define CL_ALLOC_REPORT_UNFREED() cl_alloc_report_unfreed()
+
extern void cl_alloc_debug_init(void);
+#define CL_ALLOC_DEBUG_INIT cl_alloc_debug_init()
+
+#else
+#define CL_MALLOC(SZ) malloc(SZ)
+#define CL_ALIGNED_MALLOC(SZ, ALIGN) memalign(SZ, ALIGN)
+#define CL_CALLOC(N, ELEM_SIZE) calloc(N, ELEM_SIZE)
+#define CL_REALLOC(PTR, SZ) realloc(PTR, SZ)
+#define CL_FREE(PTR) free(PTR)
+#define CL_ALLOC_REPORT_UNFREED()
+#define CL_ALLOC_DEBUG_INIT()
+#endif /* end of CL_ALLOC_DEBUG */
#endif /* __CL_ALLOC_H__ */
diff --git a/libclapi/cl_mutex.c b/libclapi/cl_mutex.c
index ec4795a0..def0ebf1 100644
--- a/libclapi/cl_mutex.c
+++ b/libclapi/cl_mutex.c
@@ -23,6 +23,8 @@
#include "cl_mutex.h"
#include "cl_internals.h"
+#ifdef CL_DEBUG_MUTEX
+
static pthread_mutex_t cl_mutex_log_lock;
static unsigned int cl_mutex_log_num;
@@ -433,3 +435,4 @@ void cl_mutex_report(void)
pthread_mutex_unlock(&cl_mutex_log_lock);
}
+#endif
diff --git a/libclapi/cl_mutex.h b/libclapi/cl_mutex.h
index 7a5d3714..bc26fadd 100644
--- a/libclapi/cl_mutex.h
+++ b/libclapi/cl_mutex.h
@@ -22,7 +22,9 @@
#include <stdlib.h>
#include <pthread.h>
+#ifdef CL_DEBUG_MUTEX
extern void cl_mutex_debug_init(void);
+#define CL_MUTEX_DEBUG_INIT() cl_mutex_debug_init()
extern void cl_mutex_lock(pthread_mutex_t* mutex, char* file, int line);
#define CL_MUTEX_LOCK(mutex) cl_mutex_lock(mutex, __FILE__, __LINE__)
@@ -37,4 +39,18 @@ extern int cl_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex,
const struct timespec *abstime, char* file, int line);
#define CL_COND_TIMEDWAIT(cond, mutex, abstime) cl_cond_timedwait(cond, mutex, abstime, __FILE__, __LINE__)
+void cl_mutex_report(void);
+#define CL_MUTEX_REPORT() cl_mutex_report()
+
+#else
+
+#define CL_MUTEX_DEBUG_INIT()
+#define CL_MUTEX_LOCK(mutex) pthread_mutex_lock(mutex)
+#define CL_MUTEX_UNLOCK(mutex) pthread_mutex_lock(mutex)
+#define CL_COND_WAIT(cond, mutex) pthread_cond_wait(cond, mutex)
+#define CL_COND_TIMEDWAIT(cond, mutex, abstime) pthread_cond_timedwait(cond, mutex, abstime)
+#define CL_MUTEX_REPORT()
+#endif /* End of CL_DEBUG_MUTEX */
+
+#define PTHREAD_MUTEX_INIT(mutex) pthread_mutex_init(mutex, NULL)
#endif /* __CL_MUTEX_H__ */
diff --git a/libclapi/cl_platform_id.c b/libclapi/cl_platform_id.c
index 074606a4..f5f870dd 100644
--- a/libclapi/cl_platform_id.c
+++ b/libclapi/cl_platform_id.c
@@ -112,7 +112,7 @@ void static cl_init_platform(void)
static int inited = 0;
if (!inited) {
- cl_alloc_debug_init();
+ CL_ALLOC_DEBUG_INIT();
cl_platform_extension_init(intel_platform.all_extensions,
intel_platform.extensions, CL_MAX_EXTENSION_LENGTH);
intel_platform.extensions_sz = strlen(intel_platform.extensions);