Configuration#

#include <hpk/configuration.hpp>

An instance of Configuration is passed to makeFactory() to provide parameters and their values for constructing a factory.

Parameter

Default value

Notes

architecture

Architecture::detect

value is an hpk::Architecture

threads

0 => detectCores()

int, where -n => ncores - n

teams

0 => detectPackages()

int, where -n => npkgs - n

l1size

0 => detectDataCache(1).size

int, L1 size measured in KiB

l2size

0 => detectDataCache(2).size

int, L2 size measured in KiB

l3size

0 => detectDataCache(3).size

int, L3 size measured in KiB

The threads parameter sets the maximum number of threads that can be used by a compute object. Note that the default is the number of cores, not the number of cpus. On a core with hyperthreading, you can try setting threads to the value returned by detectCpus().

The teams parameter may be used by a factory to determine how to divvy up the threads among work items. Similarly, cache sizes are used to guide how the problem is decomposed into work items.

See Also:

ENUMERATION

enum class hpk::Parameter#

Enumerates the parameters that can be set in a Configuration.

Values:

enumerator invalid#

Parameter is invalid.

enumerator architecture#

value has type hpk::Architecture

enumerator threads#

value has type int (max total number of threads)

enumerator teams#

value has type int (number of teams of threads)

enumerator l1size#

value has type int (L1 size measured in KiB)

enumerator l2size#

value has type int (L2 size measured in KiB)

enumerator l3size#

value has type int (L3 size measured in KiB)


CLASS

class Configuration#

A collection of configuration settings.

A Configuration is a container for parameters and their associated values.

Example:

hpk::Configuration cfg{ hpk::Architecture::avx2,
                       {hpk::Parameter::threads, 1},
                       {hpk::Parameter::l1size, 32} };

Public Functions

inline Configuration()#

Default constructor.

inline Configuration(std::initializer_list<ConfigItem> init)#

Constructs a Configuration instance from an initializer list. Each ConfigItem in the list is either an Architecture or a key and integer value, {Parameter, int}. If multiple entries in the list have the same parameter, it is unspecified which one will be used.

inline Configuration(const std::vector<ConfigItem> &v)#

Constructs a Configuration instance from a vector by copying its contents.

inline Configuration(std::vector<ConfigItem> &&v) noexcept#

Constructs a Configuration instance from a vector using move semantics.

Architecture getArchitecture() const#

Returns the Architecture that was set in this configuration. If an architecture was not set, it returns Architecture::detect.

int get(Parameter p) const#

Returns the value of the specified parameter that was set in this configuration. If a value for the parameter was not set, it returns 0.

std::string toString() const#

Returns a string description of a Configuration.

Friends

friend std::ostream &operator<<(std::ostream &os, const Configuration &cfg)#

Overload for ostream’s << operator for a Configuration.