Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/api/unified/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ target_sources(af
${CMAKE_CURRENT_SOURCE_DIR}/memory.cpp
${CMAKE_CURRENT_SOURCE_DIR}/ml.cpp
${CMAKE_CURRENT_SOURCE_DIR}/moments.cpp
${CMAKE_CURRENT_SOURCE_DIR}/opencl.cpp
${CMAKE_CURRENT_SOURCE_DIR}/random.cpp
${CMAKE_CURRENT_SOURCE_DIR}/signal.cpp
${CMAKE_CURRENT_SOURCE_DIR}/sparse.cpp
Expand Down
83 changes: 83 additions & 0 deletions src/api/unified/opencl.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/*******************************************************
* Copyright (c) 2020, ArrayFire
* All rights reserved.
*
* This file is distributed under 3-clause BSD license.
* The complete license agreement can be obtained at:
* http://arrayfire.com/licenses/BSD-3-Clause
********************************************************/

#include <af/backend.h>
#include "symbol_manager.hpp"

#include <af/opencl.h>

af_err afcl_get_device_type(afcl_device_type* res) {
af_backend backend;
af_get_active_backend(&backend);
if (backend == AF_BACKEND_OPENCL) { CALL(afcl_get_device_type, res); }
return AF_ERR_NOT_SUPPORTED;
}

af_err afcl_get_platform(afcl_platform* res) {
af_backend backend;
af_get_active_backend(&backend);
if (backend == AF_BACKEND_OPENCL) { CALL(afcl_get_platform, res); }
return AF_ERR_NOT_SUPPORTED;
}

af_err afcl_get_context(cl_context* ctx, const bool retain) {
af_backend backend;
af_get_active_backend(&backend);
if (backend == AF_BACKEND_OPENCL) { CALL(afcl_get_context, ctx, retain); }
return AF_ERR_NOT_SUPPORTED;
}

af_err afcl_get_queue(cl_command_queue* queue, const bool retain) {
af_backend backend;
af_get_active_backend(&backend);
if (backend == AF_BACKEND_OPENCL) { CALL(afcl_get_queue, queue, retain); }
return AF_ERR_NOT_SUPPORTED;
}

af_err afcl_get_device_id(cl_device_id* id) {
af_backend backend;
af_get_active_backend(&backend);
if (backend == AF_BACKEND_OPENCL) { CALL(afcl_get_device_id, id); }
return AF_ERR_NOT_SUPPORTED;
}

af_err afcl_set_device_id(cl_device_id id) {
af_backend backend;
af_get_active_backend(&backend);
if (backend == AF_BACKEND_OPENCL) { CALL(afcl_set_device_id, id); }
return AF_ERR_NOT_SUPPORTED;
}

af_err afcl_add_device_context(cl_device_id dev, cl_context ctx,
cl_command_queue que) {
af_backend backend;
af_get_active_backend(&backend);
if (backend == AF_BACKEND_OPENCL) {
CALL(afcl_add_device_context, dev, ctx, que);
}
return AF_ERR_NOT_SUPPORTED;
}

af_err afcl_set_device_context(cl_device_id dev, cl_context ctx) {
af_backend backend;
af_get_active_backend(&backend);
if (backend == AF_BACKEND_OPENCL) {
CALL(afcl_set_device_context, dev, ctx);
}
return AF_ERR_NOT_SUPPORTED;
}

af_err afcl_delete_device_context(cl_device_id dev, cl_context ctx) {
af_backend backend;
af_get_active_backend(&backend);
if (backend == AF_BACKEND_OPENCL) {
CALL(afcl_delete_device_context, dev, ctx);
}
return AF_ERR_NOT_SUPPORTED;
}