All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
context.hpp
Go to the documentation of this file.
#ifndef VIENNACL_TRAITS_CONTEXT_HPP_
#define VIENNACL_TRAITS_CONTEXT_HPP_
/* =========================================================================
Copyright (c) 2010-2016, Institute for Microelectronics,
Institute for Analysis and Scientific Computing,
TU Wien.
Portions of this software are copyright by UChicago Argonne, LLC.
-----------------
ViennaCL - The Vienna Computing Library
-----------------
Project Head: Karl Rupp rupp@iue.tuwien.ac.at
(A list of authors and contributors can be found in the manual)
License: MIT (X11), see file LICENSE in the base directory
============================================================================= */
#include <string>
#include <fstream>
#include <sstream>
#include "viennacl/forwards.h"
#include "viennacl/context.hpp"
#include "viennacl/traits/handle.hpp"
namespace viennacl
{
namespace traits
{
// Context
template<typename T>
viennacl::context context(T const & t)
{
#ifdef VIENNACL_WITH_OPENCL
if (traits::active_handle_id(t) == OPENCL_MEMORY)
return viennacl::context(traits::opencl_handle(t).context());
#endif
return viennacl::context(traits::active_handle_id(t));
}
inline viennacl::context context(viennacl::backend::mem_handle const & h)
{
#ifdef VIENNACL_WITH_OPENCL
if (h.get_active_handle_id() == OPENCL_MEMORY)
return viennacl::context(h.opencl_handle().context());
#endif
return viennacl::context(h.get_active_handle_id());
}
} //namespace traits
} //namespace viennacl
#endif
viennacl::OPENCL_MEMORY
Definition: forwards.h:349
forwards.h
This file provides the forward declarations for the main types used within ViennaCL.
viennacl::traits::context
viennacl::context context(viennacl::backend::mem_handle const &h)
Returns an ID for the currently active memory domain of an object.
Definition: context.hpp:51
context.hpp
Implementation of a OpenCL-like context, which serves as a unification of {OpenMP, CUDA, OpenCL} at the user API.
viennacl::context
Represents a generic 'context' similar to an OpenCL context, but is backend-agnostic and thus also su...
Definition: context.hpp:39
viennacl::traits::active_handle_id
viennacl::memory_types active_handle_id(T const &obj)
Returns an ID for the currently active memory domain of an object.
Definition: handle.hpp:218
viennacl::traits::context
viennacl::context context(T const &t)
Returns an ID for the currently active memory domain of an object.
Definition: context.hpp:40
viennacl::backend::mem_handle
Main abstraction class for multiple memory domains. Represents a buffer in either main RAM...
Definition: mem_handle.hpp:89
handle.hpp
Extracts the underlying OpenCL handle from a vector, a matrix, an expression etc. ...
viennacl::backend::mem_handle::get_active_handle_id
memory_types get_active_handle_id() const
Returns an ID for the currently active memory buffer. Other memory buffers might contain old or no da...
Definition: mem_handle.hpp:118