def set_device_context(dev, ctx):
    """
    Set a device as current active device

    Parameters
    ----------

    dev  : cl_device_id

    ctx  : cl_context

    """
    import ctypes as ct
    from .util import safe_call as safe_call
    from .library import backend
    if backend.name() != 'opencl':
        raise RuntimeError('Invalid backend loaded')
    safe_call(backend.get().afcl_set_device_context(dev, ctx))
