Skip to content

Commit 580d19b

Browse files
committed
gtests: fix linking for test_api_ocl with mem_debug
1 parent 6d806a6 commit 580d19b

File tree

1 file changed

+68
-3
lines changed

1 file changed

+68
-3
lines changed

tests/gtests/dnnl_test_common_ocl.hpp

+68-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright 2019-2024 Intel Corporation
2+
* Copyright 2019-2025 Intel Corporation
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -17,7 +17,6 @@
1717
#ifndef DNNL_TEST_COMMON_OCL_HPP
1818
#define DNNL_TEST_COMMON_OCL_HPP
1919

20-
#include "gpu/intel/ocl/ocl_utils.hpp"
2120
#include "oneapi/dnnl/dnnl.hpp"
2221
#include "oneapi/dnnl/dnnl_debug.h"
2322
#include "oneapi/dnnl/dnnl_ocl.hpp"
@@ -27,9 +26,75 @@
2726

2827
// Define a separate macro, that does not clash with OCL_CHECK from the library.
2928
#ifdef DNNL_ENABLE_MEM_DEBUG
29+
30+
namespace mem_debug_utils {
31+
// Copy-pasted from src/xpu/ocl/utils.cpp::convert_to_dnnl() to avoid including
32+
// .cpp file or exposing the symbol.
33+
inline dnnl_status_t convert_to_dnnl(cl_int cl_status) {
34+
switch (cl_status) {
35+
case CL_SUCCESS: return dnnl_success;
36+
case CL_MEM_OBJECT_ALLOCATION_FAILURE:
37+
case CL_OUT_OF_RESOURCES:
38+
case CL_OUT_OF_HOST_MEMORY: return dnnl_out_of_memory;
39+
case CL_DEVICE_NOT_FOUND:
40+
case CL_DEVICE_NOT_AVAILABLE:
41+
case CL_COMPILER_NOT_AVAILABLE:
42+
case CL_PROFILING_INFO_NOT_AVAILABLE:
43+
case CL_MEM_COPY_OVERLAP:
44+
case CL_IMAGE_FORMAT_MISMATCH:
45+
case CL_IMAGE_FORMAT_NOT_SUPPORTED:
46+
case CL_BUILD_PROGRAM_FAILURE:
47+
case CL_MAP_FAILURE:
48+
case CL_MISALIGNED_SUB_BUFFER_OFFSET:
49+
case CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST:
50+
case CL_COMPILE_PROGRAM_FAILURE:
51+
case CL_LINKER_NOT_AVAILABLE:
52+
case CL_LINK_PROGRAM_FAILURE:
53+
case CL_DEVICE_PARTITION_FAILED:
54+
case CL_KERNEL_ARG_INFO_NOT_AVAILABLE:
55+
case CL_INVALID_PLATFORM:
56+
case CL_INVALID_DEVICE: return dnnl_runtime_error;
57+
case CL_INVALID_VALUE:
58+
case CL_INVALID_DEVICE_TYPE:
59+
case CL_INVALID_CONTEXT:
60+
case CL_INVALID_QUEUE_PROPERTIES:
61+
case CL_INVALID_COMMAND_QUEUE:
62+
case CL_INVALID_HOST_PTR:
63+
case CL_INVALID_MEM_OBJECT:
64+
case CL_INVALID_IMAGE_FORMAT_DESCRIPTOR:
65+
case CL_INVALID_IMAGE_SIZE:
66+
case CL_INVALID_SAMPLER:
67+
case CL_INVALID_BINARY:
68+
case CL_INVALID_BUILD_OPTIONS:
69+
case CL_INVALID_PROGRAM:
70+
case CL_INVALID_PROGRAM_EXECUTABLE:
71+
case CL_INVALID_KERNEL_NAME:
72+
case CL_INVALID_KERNEL_DEFINITION:
73+
case CL_INVALID_KERNEL:
74+
case CL_INVALID_ARG_INDEX:
75+
case CL_INVALID_ARG_VALUE:
76+
case CL_INVALID_ARG_SIZE:
77+
case CL_INVALID_KERNEL_ARGS:
78+
case CL_INVALID_WORK_DIMENSION:
79+
case CL_INVALID_WORK_GROUP_SIZE:
80+
case CL_INVALID_WORK_ITEM_SIZE:
81+
case CL_INVALID_GLOBAL_OFFSET:
82+
case CL_INVALID_EVENT_WAIT_LIST:
83+
case CL_INVALID_EVENT:
84+
case CL_INVALID_OPERATION:
85+
case CL_INVALID_GL_OBJECT:
86+
case CL_INVALID_BUFFER_SIZE:
87+
case CL_INVALID_MIP_LEVEL:
88+
case CL_INVALID_GLOBAL_WORK_SIZE: return dnnl_invalid_arguments;
89+
90+
default: return dnnl_runtime_error;
91+
}
92+
}
93+
} // namespace mem_debug_utils
94+
3095
#define TEST_OCL_CHECK(x) \
3196
do { \
32-
dnnl_status_t s = dnnl::impl::xpu::ocl::convert_to_dnnl(x); \
97+
dnnl_status_t s = mem_debug_utils::convert_to_dnnl(x); \
3398
dnnl::error::wrap_c_api(s, dnnl_status2str(s)); \
3499
} while (0)
35100
#else

0 commit comments

Comments
 (0)