libadc-cxx 1.0.0
Structured logging for scientific computing
Loading...
Searching...
No Matches
Modules | Classes | Macros | Typedefs | Enumerations | Functions | Variables
Factory and interfaces for application use
Collaboration diagram for Factory and interfaces for application use:

Modules

 Builder_add_host_options
 
 Builder_add_mpi_options
 

Classes

class  adc::builder_api
 The builder api is used to construct structured log (json) messages that follow naming conventions. More...
 
class  adc::factory
 provides publishers and builders of application metadata. More...
 
class  adc::multi_publisher_api
 Interface for a group of publishers all being fed the same message(s). More...
 
class  adc::publisher_api
 Publisher plugin interface. More...
 
struct  adc::version
 A version with tags list. More...
 
struct  adc::field
 
class  adc::var_string
 return string for printing from variant v.
More...
 

Macros

#define ADC_SUPPORT_GPU_FLOATS   0
 Set to 1 if 8/16 float types for gpus are supported. ADC_SUPPORT_GPU_FLOATS should be defined by build-time configuration.
 
#define ADC_SUPPORT_EXTENDED_FLOATS   0
 Set to 1 if 80 bit floats for cpus are supported. ADC_SUPPORT_EXTENDED_FLOATS should be defined by build-time configuration.
 
#define ADC_SUPPORT_QUAD_FLOATS   0
 Set to 1 if 128 bit floats for cpus are supported. ADC_SUPPORT_QUAD_FLOATS should be defined by build-time configuration.
 
#define ADC_BOOST_JSON_PUBLIC   0
 include boost::json support in the API ADC_BOOST_JSON_PUBLIC could be defined by build-time configuration. If it is, this library forces boost::json and other boost dependencies on the build of any application which uses it.
 

Typedefs

typedef std::map< const std::string, std::shared_ptr< publisher_api > > adc::plugin_map
 name/plugin map.
 
typedef std::vector< std::shared_ptr< publisher_api > > adc::publisher_vector
 list of publishers
 
typedef std::pair< std::string, std::shared_ptr< publisher_api > > adc::pair_string_publisher_api
 named publisher
 
typedef std::variant< bool, char, char16_t, char32_t, int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t, uint32_t, uint64_t, float, double, std::complex< float >, std::complex< double >, std::array< int64_t, 2 >, std::string, std::shared_ptr< bool[]>, std::shared_ptr< char[]>, std::shared_ptr< char16_t[]>, std::shared_ptr< char32_t[]>, std::shared_ptr< int8_t[]>, std::shared_ptr< int16_t[]>, std::shared_ptr< int32_t[]>, std::shared_ptr< int64_t[]>, std::shared_ptr< uint8_t[]>, std::shared_ptr< uint16_t[]>, std::shared_ptr< uint32_t[]>, std::shared_ptr< uint64_t[]>, std::shared_ptr< float[]>, std::shared_ptr< double[]>, std::shared_ptr< std::complex< float >[]>, std::shared_ptr< std::complex< double >[]>, std::shared_ptr< std::string[]> > adc::variant
 variant for querying builder data.
 

Enumerations

enum  adc::scalar_type {
  adc::cp_none , adc::cp_bool , adc::cp_char , adc::cp_char16 ,
  adc::cp_char32 , adc::cp_cstr , adc::cp_json_str , adc::cp_yaml_str ,
  adc::cp_xml_str , adc::cp_json , adc::cp_path , adc::cp_number_str ,
  adc::cp_uint8 , adc::cp_uint16 , adc::cp_uint32 , adc::cp_uint64 ,
  adc::cp_int8 , adc::cp_int16 , adc::cp_int32 , adc::cp_int64 ,
  adc::cp_f32 , adc::cp_f64 , adc::cp_f80 , adc::cp_f128 ,
  adc::cp_f8_e4m3 , adc::cp_f8_e5m2 , adc::cp_f16_e5m10 , adc::cp_f16_e8m7 ,
  adc::cp_c_f32 , adc::cp_c_f64 , adc::cp_c_f80 , adc::cp_c_f128 ,
  adc::cp_timespec , adc::cp_timeval , adc::cp_epoch , adc::cp_char8 ,
  adc::cp_last
}
 field types for scientific data encode/decode with json. More...
 
enum  adc::key_type { adc::k_none , adc::k_section , adc::k_value }
 when expanding scalar_type, always update enum.ipp to match. More...
 
enum  adc::object_type { adc::co_list = cp_last , adc::co_map , adc::co_array , adc::co_scalar }
 classification of json-adjacent structure elements. This is not currently in use and may be retired soon. More...
 

Functions

std::string adc::format_timespec_8601 (struct timespec &ts)
 
std::string adc::format_timespec_utc_ns (struct timespec &ts)
 
std::string adc::get_default_affinity ()
 
const std::string adc::to_string (scalar_type st)
 get the string representation of a scalar_type value
 
const std::string adc::to_string (float)
 get string of float using to_chars.
 
const std::string adc::to_string (double)
 get string of double using to_chars.
 
const std::string adc::to_string (void *data, scalar_type cptype, size_t count)
 get string of array
 
scalar_type adc::scalar_type_from_name (const std::string &name)
 get the enum representation of a scalar_type string
 
int adc::test_enum_strings ()
 return non-zero if to_string and enum scalar_type are inconsisent.
 
ADC_VISIBLE std::string adc::get_multifile_log_path (string_view dir, string_view wfid)
 
ADC_VISIBLE std::vector< std::string > adc::consolidate_multifile_logs (const std::string &match, std::vector< std::string > &old_paths, bool debug=false)
 
ADC_VISIBLE std::vector< size_t > adc::validate_multifile_log (string_view filename, bool check_json, size_t &record_count)
 

Variables

version adc::builder_api_version ("1.0.0", {"none"})
 
version adc::adc_factory_version ("1.0.0", {"none"})
 
version adc::multi_publisher_version (MULTI_PUBLISHER_VERSION, MULTI_PUBLISHER_TAGS)
 
version adc::publisher_api_version ("1.0.0", {"none"})
 
version adc::enum_version ("1.0.0", {"none"})
 the version number of enum scalar_type and object_type
 
version adc::adc_utility_version ("1.0.0", {"none"})
 

Detailed Description

Macro Definition Documentation

◆ ADC_SUPPORT_GPU_FLOATS

#define ADC_SUPPORT_GPU_FLOATS   0

Set to 1 if 8/16 float types for gpus are supported. ADC_SUPPORT_GPU_FLOATS should be defined by build-time configuration.

Definition at line 36 of file types.hpp.

◆ ADC_SUPPORT_EXTENDED_FLOATS

#define ADC_SUPPORT_EXTENDED_FLOATS   0

Set to 1 if 80 bit floats for cpus are supported. ADC_SUPPORT_EXTENDED_FLOATS should be defined by build-time configuration.

Definition at line 40 of file types.hpp.

◆ ADC_SUPPORT_QUAD_FLOATS

#define ADC_SUPPORT_QUAD_FLOATS   0

Set to 1 if 128 bit floats for cpus are supported. ADC_SUPPORT_QUAD_FLOATS should be defined by build-time configuration.

Definition at line 44 of file types.hpp.

◆ ADC_BOOST_JSON_PUBLIC

#define ADC_BOOST_JSON_PUBLIC   0

include boost::json support in the API ADC_BOOST_JSON_PUBLIC could be defined by build-time configuration. If it is, this library forces boost::json and other boost dependencies on the build of any application which uses it.

Definition at line 50 of file types.hpp.

Typedef Documentation

◆ plugin_map

typedef std::map< const std::string, std::shared_ptr<publisher_api> > adc::plugin_map

name/plugin map.

Definition at line 101 of file publisher.hpp.

◆ publisher_vector

typedef std::vector< std::shared_ptr<publisher_api> > adc::publisher_vector

list of publishers

Definition at line 104 of file publisher.hpp.

◆ pair_string_publisher_api

typedef std::pair<std::string, std::shared_ptr<publisher_api> > adc::pair_string_publisher_api

named publisher

Definition at line 107 of file publisher.hpp.

◆ variant

typedef std::variant< bool, char, char16_t, char32_t, int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t, uint32_t, uint64_t, float, double, std::complex<float>, std::complex<double>, std::array<int64_t, 2>, std::string, std::shared_ptr<bool[]>, std::shared_ptr<char[]>, std::shared_ptr<char16_t[]>, std::shared_ptr<char32_t[]>, std::shared_ptr<int8_t[]>, std::shared_ptr<int16_t[]>, std::shared_ptr<int32_t[]>, std::shared_ptr<int64_t[]>, std::shared_ptr<uint8_t[]>, std::shared_ptr<uint16_t[]>, std::shared_ptr<uint32_t[]>, std::shared_ptr<uint64_t[]>, std::shared_ptr<float[]>, std::shared_ptr<double[]>, std::shared_ptr<std::complex<float>[]>, std::shared_ptr<std::complex<double>[]>, std::shared_ptr<std::string[]> > adc::variant

variant for querying builder data.

Any changes here must be reflected in the var_string operations.

Definition at line 159 of file types.hpp.

Enumeration Type Documentation

◆ scalar_type

field types for scientific data encode/decode with json.

Bit precision and C vs specialized strings are preserved when data is tagged following this enum. The add() functions on the builder api automatically tag with this.

Enumerator
cp_none 
cp_bool 

bool (true/false,1/0)

cp_char 

char (8 bit)

cp_char16 

char16_t

cp_char32 

char32_t

cp_cstr 

c null-terminated string

cp_json_str 

c null-terminated string that contains valid json

cp_yaml_str 

c null-terminated string that contains valid yaml

cp_xml_str 

c null-terminated string that contains valid xml

cp_json 

json value (object, list, etc)

cp_path 

c null-terminated string which names a file-system path

cp_number_str 

c null-terminated string containing an exact decimal representation of arbitrary precision

cp_uint8 

uint8_t

cp_uint16 

uint16_t

cp_uint32 

uint32_t

cp_uint64 

uint64_t

cp_int8 

int8_t

cp_int16 

int16_t

cp_int32 

int32_t

cp_int64 

int64_t

cp_f32 

32 bit float

cp_f64 

64 bit float

cp_f80 

80 bit float; requires ADC_SUPPORT_EXTENDED_FLOATS support

cp_f128 

128 bit float; requires ADC_SUPPORT_QUAD_FLOATS support

cp_f8_e4m3 

8 bit float (3 mantissa, 4 exponent); requires ADC_SUPPORT_GPU_FLOATS support

cp_f8_e5m2 

8 bit float (2 mantissa, 5 exponent); requires ADC_SUPPORT_GPU_FLOATS support

cp_f16_e5m10 

16 bit float (10 mantissa, 5 exponent); requires ADC_SUPPORT_GPU_FLOATS support

cp_f16_e8m7 

16 bit bfloat (7 mantissa, 8 exponent); requires ADC_SUPPORT_GPU_FLOATS support

cp_c_f32 

complex<float>

cp_c_f64 

complex<double>

cp_c_f80 

complex<extended>; requires ADC_SUPPORT_EXTENDED_FLOATS support

cp_c_f128 

complex<quad>; requires ADC_SUPPORT_QUAD_FLOATS support

cp_timespec 

(second, nanosecond) as int64_t, int64_t pair from clock_gettime

cp_timeval 

gettimeofday struct timeval (second, microsecond) as int64_t pair

cp_epoch 

time(NULL) seconds since the epoch (UNIX) as int64_t

cp_char8 

unsigned 8-bit char; reserved

cp_last 

Definition at line 62 of file types.hpp.

◆ key_type

when expanding scalar_type, always update enum.ipp to match.

Enumerator
k_none 
k_section 
k_value 

Definition at line 112 of file types.hpp.

◆ object_type

classification of json-adjacent structure elements. This is not currently in use and may be retired soon.

Enumerator
co_list 

ordered list of arbitrary values

co_map 

string keyed map of arbitrary values

co_array 

0-indexed continguous array of type-identical values

co_scalar 

single value

Definition at line 193 of file types.hpp.

Function Documentation

◆ format_timespec_8601()

std::string adc::format_timespec_8601 ( struct timespec &  ts)
Returns
iso 8601 formatted string based on ts

Definition at line 81 of file builder.ipp.

◆ format_timespec_utc_ns()

std::string adc::format_timespec_utc_ns ( struct timespec &  ts)
Returns
utc seconds.nanoseconds formatted string based on ts

Definition at line 96 of file builder.ipp.

◆ get_default_affinity()

std::string adc::get_default_affinity ( )

Get the default processor affinity list. This may be useful to publishers that spawn processes.

Definition at line 112 of file builder.ipp.

◆ to_string() [1/4]

ADC_VISIBLE const std::string adc::to_string ( scalar_type  st)

get the string representation of a scalar_type value

Definition at line 358 of file enums.ipp.

◆ to_string() [2/4]

ADC_VISIBLE const std::string adc::to_string ( float  f)

get string of float using to_chars.

Definition at line 132 of file enums.ipp.

◆ to_string() [3/4]

ADC_VISIBLE const std::string adc::to_string ( double  f)

get string of double using to_chars.

Definition at line 147 of file enums.ipp.

◆ to_string() [4/4]

ADC_VISIBLE const std::string adc::to_string ( void *  data,
scalar_type  cptype,
size_t  count 
)

get string of array

Definition at line 194 of file enums.ipp.

◆ scalar_type_from_name()

ADC_VISIBLE scalar_type adc::scalar_type_from_name ( const std::string &  name)

get the enum representation of a scalar_type string

Definition at line 104 of file enums.ipp.

◆ test_enum_strings()

ADC_VISIBLE int adc::test_enum_strings ( )

return non-zero if to_string and enum scalar_type are inconsisent.

Definition at line 364 of file enums.ipp.

◆ get_multifile_log_path()

ADC_VISIBLE std::string adc::get_multifile_log_path ( string_view  dir,
string_view  wfid 
)

Utility to get output directory from the multifile_publisher.

Utility to get output directory glob pattern from the multifile_publisher, given the ADC_MULTIFILE_DIRECTORY and ADC_WFID values in use or their library-prefixed-versions.

Definition at line 37 of file utility.ipp.

◆ consolidate_multifile_logs()

ADC_VISIBLE std::vector< std::string > adc::consolidate_multifile_logs ( const std::string &  match,
std::vector< std::string > &  old_paths,
bool  debug = false 
)

Utility to merge parallel outputs from multifile publisher. Consolidation should only happen after the multifile publisher is finalized; If a multi_publisher is in use, consolidation should only happen after terminate has been called on the multi_publisher (which calls finalize). On slow nfs-based file systems, some delay may be needed to ensure all files are seen on the aggregating client.

Returns
the list of consolidated logs from reduction of a multifile publisher tree.

/FS/adc/$user/$adc_wfid/$app/$host-$pid_$start-$publisherptr.log /FS/adc/$user/no_wfid/$app/$host-$pid_$start-$publisherptr.log /FS/adc/$user/$cluster/$jobidraw/$task/$rank/$app/$host-$pid_$start-$publisherptr.log /FS/adc/ is multiuser; $user is owned/writable by $user

Utility to merge parallel outputs from multifile publisher. Consolidation should only happen after the multifile publisher is finalized; If a multi_publisher is in use, consolidation should only happen after terminate has been called on the multi_publisher (which calls finalize). On slow nfs-based file systems, some delay may be needed to ensure all files are seen on the aggregating client.

Parameters
matchthe result of an appropriate call to get_multifile_log_path.
old_pathsthe names of files that were successfully merged. May be empty; if not empty, deleting the files in the list is recommended.
Returns
the list of new consolidated logs from reduction of a multifile publisher tree.

Example: /FS/adc/ may be multiuser /FS/adc/$user is owned/writable by $user /FS/adc/$user/$adc_wfid.* are created to prevent output conflicts, and then consolidated to: /FS/adc/$user/consolidated.$adc_wfid.adct-json.multi.xml Where ADC_WFID is not defined, a timestamp is used in its place.

Definition at line 29 of file utility.ipp.

◆ validate_multifile_log()

ADC_VISIBLE std::vector< size_t > adc::validate_multifile_log ( std::string_view  filename,
bool  check_json,
size_t &  record_count 
)

Utility to validate that multi-record files were correctly written. Each record is a json object delimited by <adct-json></adct-json> xml tags.

Returns
vector of the start positions of invalid records.
Parameters
filenameinput to check.
check_jsonvalidates that individual record contents are json formatted (but does not check adct schema compliance).
countoutput of number of valid records found.

<adc-json> tags cannot be nested. Unclosed tags are assumed closed by the start of the next record.

BUGS: not yet implemented. returns emtpy vector and 0 record_count until implemented.

Definition at line 42 of file utility.ipp.

Variable Documentation

◆ builder_api_version

version adc::builder_api_version("1.0.0", {"none"}) ( "1.0.0"  ,
{"none"}   
)
inline

◆ adc_factory_version

version adc::adc_factory_version("1.0.0", {"none"}) ( "1.0.0"  ,
{"none"}   
)
inline

◆ multi_publisher_version

◆ publisher_api_version

version adc::publisher_api_version("1.0.0", {"none"}) ( "1.0.0"  ,
{"none"}   
)
inline

◆ enum_version

version adc::enum_version("1.0.0", {"none"}) ( "1.0.0"  ,
{"none"}   
)
inline

the version number of enum scalar_type and object_type

◆ adc_utility_version

version adc::adc_utility_version("1.0.0", {"none"}) ( "1.0.0"  ,
{"none"}   
)
inline