C Configuration Space and Tuning Library (CCS)
Loading...
Searching...
No Matches
CCS: C Configuration Space and Tuning Library

CCS provides a C interface for describing autotuning problems and autotuners, enabling interoperability between autotuning frameworks and applications with auto-tuning needs. It was greatly inspired by ConfigSpace.

Features

  • Parameter types: numerical (integer/float), categorical, ordinal, discrete, and string parameters
  • Configuration spaces: define search spaces with parameters, conditions, and forbidden clauses
  • Objective spaces: specify optimization objectives (minimize/maximize)
  • Tuners: built-in random tuner and user-defined tuner interface using an ask/tell pattern
  • Feature spaces: support for contextual tuning with feature-dependent optimization
  • Tree spaces: static and dynamic tree-structured search spaces
  • Expressions: expression trees for conditions and forbidden clauses
  • Serialization: binary serialization/deserialization of all objects
  • Thread safety: optional thread-safe mode (--enable-thread-safe, enabled by default)
  • Bindings: Ruby and Python bindings
  • Connectors: Kokkos profiling connector
  • Reference counting: all objects are reference-counted for safe memory management

Dependencies

Required:

  • C compiler (GCC or Clang) with C99 support
  • C++ compiler with C++14 support (for the Kokkos connector)
  • GNU Autotools (autoconf, automake, libtool)
  • GSL (GNU Scientific Library)

Optional:

  • Ruby (>= 2.3) with FFI gem — for Ruby bindings and tests
  • Python 3 (>= 3.6) with ctypes — for Python bindings and samples
  • Valgrind — for memory checking

Building

# Generate the configure script
./autogen.sh
# Configure (out-of-source build recommended)
mkdir build && cd build
../configure
# Build
make -j$(nproc)
# Run tests
make check

Configure options

Option Default Description
--enable-strict no Enable -Werror (treat warnings as errors)
--enable-thread-safe yes Build with thread safety (reader-writer locks)
--enable-kokkos-connector yes Build the Kokkos tuning connector
--enable-samples yes Build interoperability samples (requires Python 3)

Installation

make install

The library installs a pkg-config file (cconfigspace.pc) for easy integration.

Quick example

The following C example demonstrates the core workflow: define parameters, create a configuration space and an objective space, then use a random tuner with the ask/tell pattern to minimize a simple function.

#include <cconfigspace.h>
#include <assert.h>
#include <math.h>
int main() {
ccs_parameter_t parameters[2];
ccs_parameter_t obj_param;
ccs_expression_t obj_expr;
ccs_tuner_t tuner;
/* Create two numerical parameters: x in [-5, 5], y in [-5, 5] */
CCSF(-5.0), CCSF(5.0), CCSF(0.0), CCSF(0), &parameters[0]);
assert(err == CCS_RESULT_SUCCESS);
CCSF(-5.0), CCSF(5.0), CCSF(0.0), CCSF(0), &parameters[1]);
assert(err == CCS_RESULT_SUCCESS);
/* Create a configuration space from the parameters */
"2dplane", 2, parameters, NULL, 0, NULL,
NULL, NULL, &cspace);
assert(err == CCS_RESULT_SUCCESS);
/* Create an objective space: minimize z */
obj_param = NULL;
CCSF(0.0), CCSF(0), &obj_param);
assert(err == CCS_RESULT_SUCCESS);
err = ccs_create_variable(obj_param, &obj_expr);
assert(err == CCS_RESULT_SUCCESS);
"height", (ccs_search_space_t)cspace, 1, &obj_param,
1, &obj_expr, &obj_type, &ospace);
assert(err == CCS_RESULT_SUCCESS);
/* Create a random tuner */
err = ccs_create_random_tuner("problem", ospace, &tuner);
assert(err == CCS_RESULT_SUCCESS);
/* Ask/tell loop: sample 100 configurations and report results */
for (int i = 0; i < 100; i++) {
ccs_datum_t values[2], result;
err = ccs_tuner_ask(tuner, NULL, 1, &config, NULL);
assert(err == CCS_RESULT_SUCCESS);
(ccs_binding_t)config, 2, values, NULL);
assert(err == CCS_RESULT_SUCCESS);
/* Objective: (x-1)^2 + (y-2)^2 (minimum at x=1, y=2) */
double x = values[0].value.f, y = values[1].value.f;
result = ccs_float((x - 1) * (x - 1) + (y - 2) * (y - 2));
ospace, config, CCS_RESULT_SUCCESS, 1, &result, &eval);
assert(err == CCS_RESULT_SUCCESS);
err = ccs_tuner_tell(tuner, 1, &eval);
assert(err == CCS_RESULT_SUCCESS);
}
/* Retrieve the best configuration found */
ccs_datum_t best_value;
err = ccs_tuner_get_optima(tuner, NULL, 1, &best, NULL);
assert(err == CCS_RESULT_SUCCESS);
err = ccs_evaluation_get_objective_value(best, 0, &best_value);
assert(err == CCS_RESULT_SUCCESS);
/* Clean up */
ccs_release_object(obj_expr);
ccs_release_object(obj_param);
ccs_release_object(parameters[0]);
ccs_release_object(parameters[1]);
return 0;
}
ccs_result_t ccs_release_object(ccs_object_t object)
Release a CCS object, decrementing the internal reference counting.
#define CCS_INFINITY
A macro defining the (positive) infinity value of a ccs_float_t.
Definition base.h:82
struct _ccs_expression_s * ccs_expression_t
An opaque type defining a CCS expression.
Definition base.h:99
struct _ccs_binding_s * ccs_binding_t
An opaque type defining a CCS binding.
Definition base.h:119
#define CCSF(v)
A macro casting a value to a CCS floating point numeric.
Definition base.h:435
struct _ccs_search_configuration_s * ccs_search_configuration_t
An opaque type defining a CCS search space configuration.
Definition base.h:123
struct _ccs_parameter_s * ccs_parameter_t
An opaque type defining a CCS parameter.
Definition base.h:95
struct _ccs_objective_space_s * ccs_objective_space_t
An opaque type defining a CCS objective space.
Definition base.h:139
@ CCS_RESULT_SUCCESS
Success.
Definition base.h:179
struct _ccs_search_space_s * ccs_search_space_t
An opaque type defining a CCS search space.
Definition base.h:111
struct _ccs_tuner_s * ccs_tuner_t
An opaque type defining a CCS tuner.
Definition base.h:147
struct _ccs_evaluation_s * ccs_evaluation_t
An opaque type defining a CCS evaluation.
Definition base.h:143
static ccs_datum_t ccs_float(ccs_float_t v)
A helper function to construct a datum containing a floating point value.
Definition base.h:529
struct _ccs_configuration_space_s * ccs_configuration_space_t
An opaque type defining a CCS configuration space.
Definition base.h:115
enum ccs_result_e ccs_result_t
A commodity type to represent CCS errors and returned by most functions.
Definition base.h:247
@ CCS_NUMERIC_TYPE_FLOAT
A ccs_float_t.
Definition base.h:374
ccs_result_t ccs_binding_get_values(ccs_binding_t binding, size_t num_values, ccs_datum_t *values, size_t *num_values_ret)
Get all the values in the binding.
The C configuration Space and Tuning library (CCS) provides an interface to define tuning problems an...
ccs_result_t ccs_create_configuration_space(const char *name, size_t num_parameters, ccs_parameter_t *parameters, ccs_expression_t *conditions, size_t num_forbidden_clauses, ccs_expression_t *forbidden_clauses, ccs_feature_space_t feature_space, ccs_rng_t rng, ccs_configuration_space_t *configuration_space_ret)
Create a new configuration space.
ccs_result_t ccs_evaluation_get_objective_value(ccs_evaluation_t evaluation, size_t index, ccs_datum_t *value_ret)
Get the value of an objective for a valid evaluation in the context of its objective space.
ccs_result_t ccs_create_evaluation(ccs_objective_space_t objective_space, ccs_search_configuration_t configuration, ccs_evaluation_result_t result, size_t num_values, ccs_datum_t *values, ccs_evaluation_t *evaluation_ret)
Create a new instance of an evaluation on a given objective_space for a given configuration.
ccs_result_t ccs_create_variable(ccs_parameter_t parameter, ccs_expression_t *expression_ret)
Create a new variable expression.
enum ccs_objective_type_e ccs_objective_type_t
A commodity type to represent objective types.
Definition objective_space.h:33
ccs_result_t ccs_create_objective_space(const char *name, ccs_search_space_t search_space, size_t num_parameters, ccs_parameter_t *parameters, size_t num_objectives, ccs_expression_t *objectives, ccs_objective_type_t *types, ccs_objective_space_t *objective_space_ret)
Create a new objective space.
@ CCS_OBJECTIVE_TYPE_MINIMIZE
Objective should be minimized.
Definition objective_space.h:21
ccs_result_t ccs_create_numerical_parameter(const char *name, ccs_numeric_type_t data_type, ccs_numeric_t lower, ccs_numeric_t upper, ccs_numeric_t quantization, ccs_numeric_t default_value, ccs_parameter_t *parameter_ret)
Create a new numerical parameter of the specified data_type.
A Structure containing a CCS datum.
Definition base.h:494
ccs_value_t value
The value of the datum.
Definition base.h:496
ccs_result_t ccs_create_random_tuner(const char *name, ccs_objective_space_t objective_space, ccs_tuner_t *tuner_ret)
Create a new random tuner.
ccs_result_t ccs_tuner_ask(ccs_tuner_t tuner, ccs_features_t features, size_t num_configurations, ccs_search_configuration_t *configurations, size_t *num_configurations_ret)
Ask a tuner for a set of configurations to evaluate.
ccs_result_t ccs_tuner_tell(ccs_tuner_t tuner, size_t num_evaluations, ccs_evaluation_t *evaluations)
Give a list of results to a tuner through evaluations.
ccs_result_t ccs_tuner_get_optima(ccs_tuner_t tuner, ccs_features_t features, size_t num_evaluations, ccs_evaluation_t *evaluations, size_t *num_evaluations_ret)
Ask a tuner for the discovered Pareto front.
ccs_float_t f
The floating point value of the union.
Definition base.h:447

Compile with:

gcc -o example example.c $(pkg-config --cflags --libs cconfigspace) -lm

Documentation

API documentation is generated with Doxygen and published at: https://argonne-lcf.github.io/CCS/index.html

To build locally:

doxygen Doxyfile

License

BSD 3-Clause. See LICENSE for details.

Copyright (c) 2020, UChicago Argonne, LLC.