1/*******************************************************************************
2* Copyright 2021-2022 Intel Corporation
3*
4* Licensed under the Apache License, Version 2.0 (the "License");
5* you may not use this file except in compliance with the License.
6* You may obtain a copy of the License at
7*
8* http://www.apache.org/licenses/LICENSE-2.0
9*
10* Unless required by applicable law or agreed to in writing, software
11* distributed under the License is distributed on an "AS IS" BASIS,
12* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13* See the License for the specific language governing permissions and
14* limitations under the License.
15*******************************************************************************/
16
17#ifndef GPU_OCL_OCL_USM_UTILS_HPP
18#define GPU_OCL_OCL_USM_UTILS_HPP
19
20#include <CL/cl.h>
21
22#include "common/engine.hpp"
23#include "common/stream.hpp"
24
25namespace dnnl {
26namespace impl {
27namespace gpu {
28namespace ocl {
29namespace usm {
30
31enum class ocl_usm_kind_t { unknown, host, device, shared };
32
33bool is_usm_supported(engine_t *engine);
34void *malloc_host(engine_t *engine, size_t size);
35void DNNL_API *malloc_device(engine_t *engine, size_t size);
36void DNNL_API *malloc_shared(engine_t *engine, size_t size);
37
38void DNNL_API free(engine_t *engine, void *ptr);
39status_t set_kernel_arg_usm(engine_t *engine, cl_kernel kernel, int arg_index,
40 const void *arg_value);
41status_t DNNL_API memcpy(
42 stream_t *stream, void *dst, const void *src, size_t size);
43status_t fill(stream_t *stream, void *ptr, const void *pattern,
44 size_t pattern_size, size_t size);
45status_t DNNL_API memset(stream_t *stream, void *ptr, int value, size_t size);
46ocl_usm_kind_t DNNL_API get_pointer_type(engine_t *engine, const void *ptr);
47
48} // namespace usm
49} // namespace ocl
50} // namespace gpu
51} // namespace impl
52} // namespace dnnl
53
54#endif
55