-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9cf7e2f
commit 66d5282
Showing
8 changed files
with
139 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
//===--------- kernel.hpp - OpenCL Adapter ---------------------------===// | ||
// | ||
// Copyright (C) 2023 Intel Corporation | ||
// | ||
// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM | ||
// Exceptions. See LICENSE.TXT | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
#pragma once | ||
|
||
#include "common.hpp" | ||
|
||
#include <vector> | ||
|
||
struct ur_kernel_handle_t_ { | ||
using native_type = cl_kernel; | ||
native_type Kernel; | ||
ur_program_handle_t Program; | ||
ur_context_handle_t Context; | ||
|
||
ur_kernel_handle_t_(native_type Kernel, ur_program_handle_t Program, | ||
ur_context_handle_t Context) | ||
: Kernel(Kernel), Program(Program), Context(Context) {} | ||
|
||
~ur_kernel_handle_t_() {} | ||
|
||
ur_result_t initWithNative() { | ||
if (!Program) { | ||
cl_program CLProgram; | ||
CL_RETURN_ON_FAILURE(clGetKernelInfo( | ||
Kernel, CL_KERNEL_PROGRAM, sizeof(CLProgram), &CLProgram, nullptr)); | ||
ur_native_handle_t NativeProgram = | ||
reinterpret_cast<ur_native_handle_t>(CLProgram); | ||
UR_RETURN_ON_FAILURE(urProgramCreateWithNativeHandle( | ||
NativeProgram, nullptr, nullptr, &Program)); | ||
} | ||
if (!Context) { | ||
cl_context CLContext; | ||
CL_RETURN_ON_FAILURE(clGetKernelInfo( | ||
Kernel, CL_KERNEL_CONTEXT, sizeof(CLContext), &CLContext, nullptr)); | ||
ur_native_handle_t NativeContext = | ||
reinterpret_cast<ur_native_handle_t>(CLContext); | ||
UR_RETURN_ON_FAILURE(urContextCreateWithNativeHandle( | ||
NativeContext, 0, nullptr, nullptr, &Context)); | ||
} | ||
return UR_RESULT_SUCCESS; | ||
} | ||
|
||
native_type get() { return Kernel; } | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.