summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/cl_accelerator_intel.c9
-rw-r--r--src/cl_accelerator_intel.h11
-rw-r--r--src/cl_api.c3
-rw-r--r--src/cl_utils.h2
4 files changed, 14 insertions, 11 deletions
diff --git a/src/cl_accelerator_intel.c b/src/cl_accelerator_intel.c
index cda89635..545a6139 100644
--- a/src/cl_accelerator_intel.c
+++ b/src/cl_accelerator_intel.c
@@ -19,9 +19,7 @@ cl_accelerator_intel_new(cl_context ctx,
/* Allocate and inialize the structure itself */
TRY_ALLOC(accel, CALLOC(struct _cl_accelerator_intel));
- SET_ICD(accel->dispatch)
- accel->ref_n = 1;
- accel->magic = CL_MAGIC_ACCELERATOR_INTEL_HEADER;
+ CL_OBJECT_INIT_BASE(accel, CL_OBJECT_ACCELERATOR_INTEL_MAGIC);
if (accel_type != CL_ACCELERATOR_TYPE_MOTION_ESTIMATION_INTEL) {
err = CL_INVALID_ACCELERATOR_TYPE_INTEL;
@@ -60,7 +58,7 @@ error:
LOCAL void
cl_accelerator_intel_add_ref(cl_accelerator_intel accel)
{
- atomic_inc(&accel->ref_n);
+ CL_OBJECT_INC_REF(accel);
}
LOCAL void
@@ -68,7 +66,7 @@ cl_accelerator_intel_delete(cl_accelerator_intel accel)
{
if (UNLIKELY(accel == NULL))
return;
- if (atomic_dec(&accel->ref_n) > 1)
+ if (CL_OBJECT_DEC_REF(accel) > 1)
return;
/* Remove the accelerator_intel in the context accelerator_intel list */
@@ -82,5 +80,6 @@ cl_accelerator_intel_delete(cl_accelerator_intel accel)
pthread_mutex_unlock(&accel->ctx->accelerator_intel_lock);
cl_context_delete(accel->ctx);
+ CL_OBJECT_DESTROY_BASE(accel);
cl_free(accel);
}
diff --git a/src/cl_accelerator_intel.h b/src/cl_accelerator_intel.h
index cecfd2a8..435ae737 100644
--- a/src/cl_accelerator_intel.h
+++ b/src/cl_accelerator_intel.h
@@ -1,22 +1,25 @@
#ifndef __CL_ACCELERATOR_INTEL_H__
#define __CL_ACCELERATOR_INTEL_H__
+#include "cl_base_object.h"
#include "CL/cl.h"
#include "CL/cl_ext.h"
#include <stdint.h>
struct _cl_accelerator_intel {
- DEFINE_ICD(dispatch)
- uint64_t magic; /* To identify it as a accelerator_intel object */
- volatile int ref_n; /* This object is reference counted */
+ _cl_base_object base;
cl_accelerator_intel prev, next; /* We chain in the allocator, why chain? */
cl_context ctx; /* Context it belongs to */
cl_accelerator_type_intel type;
union {
cl_motion_estimation_desc_intel me;
- }desc; /* save desc before we decide how to handle it */
+ } desc; /* save desc before we decide how to handle it */
};
+#define CL_OBJECT_ACCELERATOR_INTEL_MAGIC 0x7e6a08c9a7ac3e3fLL
+#define CL_OBJECT_IS_ACCELERATOR_INTEL(obj) \
+ (((cl_base_object)obj)->magic == CL_OBJECT_ACCELERATOR_INTEL_MAGIC)
+
cl_accelerator_intel cl_accelerator_intel_new(cl_context ctx,
cl_accelerator_type_intel accel_type,
size_t desc_sz,
diff --git a/src/cl_api.c b/src/cl_api.c
index 7a98d08a..a2fee158 100644
--- a/src/cl_api.c
+++ b/src/cl_api.c
@@ -3567,7 +3567,8 @@ clGetAcceleratorInfoINTEL(cl_accelerator_intel accel,
CHECK_ACCELERATOR_INTEL(accel);
if (param_name == CL_ACCELERATOR_REFERENCE_COUNT_INTEL) {
- FILL_GETINFO_RET (cl_uint, 1, (cl_uint*)&accel->ref_n, CL_SUCCESS);
+ cl_uint ref = CL_OBJECT_GET_REF(accel);
+ FILL_GETINFO_RET (cl_uint, 1, &ref, CL_SUCCESS);
} else if (param_name == CL_ACCELERATOR_CONTEXT_INTEL) {
FILL_GETINFO_RET (cl_context, 1, &accel->ctx, CL_SUCCESS);
} else if (param_name == CL_ACCELERATOR_TYPE_INTEL) {
diff --git a/src/cl_utils.h b/src/cl_utils.h
index 8eb20945..dc7a3d6a 100644
--- a/src/cl_utils.h
+++ b/src/cl_utils.h
@@ -239,7 +239,7 @@ do {
err = CL_INVALID_ACCELERATOR_INTEL; \
goto error; \
} \
- if (UNLIKELY(ACCELERATOR_INTEL->magic != CL_MAGIC_ACCELERATOR_INTEL_HEADER)) {\
+ if (UNLIKELY(!CL_OBJECT_IS_ACCELERATOR_INTEL(ACCELERATOR_INTEL))) { \
err = CL_INVALID_ACCELERATOR_INTEL; \
goto error; \
} \