Program Listing for File cimba.h

Return to documentation for file (include/cimba.h)

/*
 * Copyright (c) Asbjørn M. Bonvik 1994, 1995, 2025-26.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef CIMBA_CIMBA_H
#define CIMBA_CIMBA_H

#define CIMBA_VERSION_MAJOR 3
#define CIMBA_VERSION_MINOR 0
#define CIMBA_VERSION_PATCH 0
#define CIMBA_VERSION_PRE_RELEASE beta

#define CMI_STRINGIFY(x) #x

#define CMI_TOSTRING(A, B, C, D) CMI_STRINGIFY(A) "." CMI_STRINGIFY(B) "." \
                                 CMI_STRINGIFY(C) "-" CMI_STRINGIFY(D)

#define CIMBA_VERSION CMI_TOSTRING(CIMBA_VERSION_MAJOR, \
                                   CIMBA_VERSION_MINOR, \
                                   CIMBA_VERSION_PATCH, \
                                   CIMBA_VERSION_PRE_RELEASE)
extern const char *cimba_version(void);

/*
 * Declarations of the different "classes" and functions provided by Cimba
 */
#include "cmb_assert.h"
#include "cmb_buffer.h"
#include "cmb_condition.h"
#include "cmb_dataset.h"
#include "cmb_datasummary.h"
#include "cmb_event.h"
#include "cmb_logger.h"
#include "cmb_objectqueue.h"
#include "cmb_process.h"
#include "cmb_random.h"
#include "cmb_resource.h"
#include "cmb_resourceguard.h"
#include "cmb_resourcepool.h"
#include "cmb_timeseries.h"
#include "cmb_wtdsummary.h"

typedef void (cimba_trial_func)(void *trial_struct);

extern uint64_t cimba_run(void *your_experiment_array,
                          uint64_t num_trials,
                          size_t trial_struct_size,
                          cimba_trial_func *your_trial_func);

/* Wrapper for deprecated long form */
[[maybe_unused]]
static inline void cimba_run_experiment(void *your_experiment_array,
                                        uint64_t num_trials,
                                        size_t trial_struct_size,
                                        cimba_trial_func *your_trial_func)
{
    cimba_run(your_experiment_array,num_trials,trial_struct_size, your_trial_func);
}
typedef void *(cimba_thread_init_func)(void *usrarg, uint64_t tid);

typedef void (cimba_thread_exit_func)(void *thrctx);

extern void cimba_thread_hooks_set(cimba_thread_init_func *initfunc,
                                   void *usrarg,
                                   cimba_thread_exit_func *exitfunc);

extern void *cimba_thread_context(void);

extern uint64_t cimba_thread_id(void);

extern uint32_t cimba_threads_num(void);

extern uint32_t cimba_threads_use(uint32_t n_threads);

extern uint64_t cimba_trials_total(void);

extern uint64_t cimba_trials_remaining(void);

extern uint64_t cimba_trial_index(void);

#endif // CIMBA_CIMBA_H