Skip to content

Commit

Permalink
Fixes #637: Hide the flag-related members from the public interface o…
Browse files Browse the repository at this point in the history
…f the device and context classes
  • Loading branch information
eyalroz committed Apr 29, 2024
1 parent 3fc369e commit 55bd71d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 19 deletions.
4 changes: 3 additions & 1 deletion src/cuda/api/context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,10 +237,12 @@ inline void synchronize(const context_t& context);
* to properties of the context is a const-respecting operation on this class.
*/
class context_t {
public: // types
protected: // types
/// A container type for the features of a context configurable at creation time
using flags_type = context::flags_t;

public: // types

static_assert(
::std::is_same<::std::underlying_type<CUsharedconfig>::type, ::std::underlying_type<cudaSharedMemConfig>::type>::value,
"Unexpected difference between enumerators used for the same purpose by the CUDA runtime and the CUDA driver");
Expand Down
37 changes: 19 additions & 18 deletions src/cuda/api/device.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,12 @@ inline ::std::string get_name(id_t id)
* to properties of the device is a const-respecting operation on this class.
*/
class device_t {
protected: // types
using flags_type = device::flags_t;

public: // types
using properties_t = device::properties_t;
using attribute_value_t = device::attribute_value_t;
using flags_type = device::flags_t;

/**
*
Expand Down Expand Up @@ -213,18 +215,6 @@ class device_t {
return primary_context_handle_;
}


public:
/**
* Produce a proxy for the device's primary context - the one used by runtime API calls.
*
* @param scoped When true, the primary proxy object returned will not perform its
* own reference accounting, and will assume the primary context is active while
* this device object exists. When false, the returned primary context proxy object
* _will_ take care of its own reference count unit, and can outlive this object.
*/
device::primary_context_t primary_context(bool hold_pc_refcount_unit = false) const;

void set_flags(flags_type new_flags) const
{
new_flags &= ~CU_CTX_MAP_HOST;
Expand All @@ -237,6 +227,22 @@ class device_t {
throw_if_error_lazy(status, "Failed setting (primary context) flags for device " + device::detail_::identify(id_));
}

context::flags_t flags() const
{
return device::primary_context::detail_::flags(id_);
}

public:
/**
* Produce a proxy for the device's primary context - the one used by runtime API calls.
*
* @param scoped When true, the primary proxy object returned will not perform its
* own reference accounting, and will assume the primary context is active while
* this device object exists. When false, the returned primary context proxy object
* _will_ take care of its own reference count unit, and can outlive this object.
*/
device::primary_context_t primary_context(bool hold_pc_refcount_unit = false) const;

#if CUDA_VERSION >= 11020
memory::pool_t default_memory_pool() const;
#endif
Expand Down Expand Up @@ -588,11 +594,6 @@ class device_t {
}

public:
context::flags_t flags() const
{
return device::primary_context::detail_::flags(id_);
}

context::host_thread_sync_scheduling_policy_t sync_scheduling_policy() const
{
return context::host_thread_sync_scheduling_policy_t(flags() & CU_CTX_SCHED_MASK);
Expand Down

0 comments on commit 55bd71d

Please sign in to comment.