<commit_before>#ifndef __GHOST_TASKQ_H__
#define __GHOST_TASKQ_H__

#include <pthread.h>
#include <semaphore.h>
#include <hwloc.h>

#define GHOST_TASK_LD_UNDEFINED -1 // initializer
#define GHOST_TASK_LD_ANY 0 // execute task on any LD

#define GHOST_TASK_DEFAULT 0
#define GHOST_TASK_PRIO_HIGH 1 // task will be added to the head of the queue
#define GHOST_TASK_LD_STRICT 2 // task _must_ be executed on the defined LD
#define GHOST_TASK_USE_PARENTS 4 // task can use the parent's resources if added from within a task 
#define GHOST_TASK_NO_PIN 8 
#define GHOST_TASK_ONLY_HYPERTHREADS 16
#define GHOST_TASK_NO_HYPERTHREADS 32

#define GHOST_TASK_INVALID 0 // task has not been enqueued
#define GHOST_TASK_ENQUEUED 1 // task has been enqueued
#define GHOST_TASK_RUNNING 2 // task is currently running
#define GHOST_TASK_FINISHED 3 // task has finished

#define GHOST_TASK_FILL_LD -1 // use all threads of the given LD
#define GHOST_TASK_FILL_ALL -2 // use all threads of all LDs

#define GHOST_THPOOL_NTHREADS_FULLNODE ((int*)(0xBEEF))
#define GHOST_THPOOL_FTHREAD_DEFAULT ((int *)(0xBEEF))
#define GHOST_THPOOL_LEVELS_FULLSMT 0


#ifdef __cplusplus
extern "C" {
#endif

/**
 * @brief This structure represents a GHOST task.
 *
 * This data structure holds all necessary information for
 * a task. The members #nThreads, #LD, #flags, #func and #arg have to be set by
 * the user in ghost_task_init(). All other members are set by the library at
 * some point.
 */
typedef struct ghost_task_t {
	/**
	 * @brief The number of threads the task should use. (user-defined)
	 */
	int nThreads;
	/**
	 * @brief The index of the queue in which the task should be present and
	 * (preferrably) running. (user-defined)
	 */
	int LD;
	/**
	 * @brief Optional flags for the task. (user-defined)
	 */
	int flags;
	/**
	 * @brief The function to be executed by the task. (user-defined)
	 */
	void *(*func)(void *);
	/**
	 * @brief The arguments to the task's function. (user-defined)
	 */
	void *arg;

	// set by the library
	/**
	 * @brief The current state of the task. (set by the library)
	 */
	int *state;
	/**
	 * @brief The list of cores where the task's threads are running. (set by the library)
	 */
	int *cores;
	hwloc_bitmap_t coremap; // map of cores this task is using
	hwloc_bitmap_t childusedmap; // map of cores a child of this task is using
	/**
	 * @brief The return value of the task's funtion. (set by the library)
	 */
	void *ret;
	/**
	 * @brief Pointer to the next task in the queue. (set by the library)
	 */
	struct ghost_task_t *next; 
	/**
	 * @brief Pointer to the previous task in the queue. (set by the library)
	 */
	struct ghost_task_t *prev;
	/**
	 * @brief The adding task if the task has been added from within a task.
	 * (set by the library)
	 */
	struct ghost_task_t *parent;
	/**
	 * @brief Indicator that the task is finished. (set by the library)
	 */
	pthread_cond_t *finishedCond;
	/**
	 * @brief Protect accesses to the task's members. (set by the library)
	 */<commit_msg>documentation<commit_after>#ifndef __GHOST_TASKQ_H__
#define __GHOST_TASKQ_H__

#include <pthread.h>
#include <semaphore.h>
#include <hwloc.h>

#define GHOST_TASK_LD_UNDEFINED -1 // initializer
#define GHOST_TASK_LD_ANY 0 // execute task on any LD

#define GHOST_TASK_DEFAULT 0
#define GHOST_TASK_PRIO_HIGH 1 // task will be added to the head of the queue
#define GHOST_TASK_LD_STRICT 2 // task _must_ be executed on the defined LD
#define GHOST_TASK_USE_PARENTS 4 // task can use the parent's resources if added from within a task 
#define GHOST_TASK_NO_PIN 8 
#define GHOST_TASK_ONLY_HYPERTHREADS 16
#define GHOST_TASK_NO_HYPERTHREADS 32

#define GHOST_TASK_INVALID 0 // task has not been enqueued
#define GHOST_TASK_ENQUEUED 1 // task has been enqueued
#define GHOST_TASK_RUNNING 2 // task is currently running
#define GHOST_TASK_FINISHED 3 // task has finished

#define GHOST_TASK_FILL_LD -1 // use all threads of the given LD
#define GHOST_TASK_FILL_ALL -2 // use all threads of all LDs

#define GHOST_THPOOL_NTHREADS_FULLNODE ((int*)(0xBEEF))
#define GHOST_THPOOL_FTHREAD_DEFAULT ((int *)(0xBEEF))
#define GHOST_THPOOL_LEVELS_FULLSMT 0


#ifdef __cplusplus
extern "C" {
#endif

/**
 * @brief This structure represents a GHOST task.
 *
 * This data structure holds all necessary information for
 * a task. The members #nThreads, #LD, #flags, #func and #arg have to be set by
 * the user in ghost_task_init(). All other members are set by the library at
 * some point.
 */
typedef struct ghost_task_t {
	/**
	 * @brief The number of threads the task should use. (user-defined)
	 */
	int nThreads;
	/**
	 * @brief The index of the queue in which the task should be present and
	 * (preferrably) running. (user-defined)
	 */
	int LD;
	/**
	 * @brief Optional flags for the task. (user-defined)
	 */
	int flags;
	/**
	 * @brief The function to be executed by the task. (user-defined)
	 */
	void *(*func)(void *);
	/**
	 * @brief The arguments to the task's function. (user-defined)
	 */
	void *arg;

	// set by the library
	/**
	 * @brief The current state of the task. (set by the library)
	 */
	int *state;
	/**
	 * @brief The list of cores where the task's threads are running. (set by the library)
	 */
	int *cores;
	/**
	 * @brief Map of cores this task is using. (set by the library)
	 */
	hwloc_bitmap_t coremap;
	/**
	 * @brief Map of cores a child of this task is using. (set by the library)
	 */
	hwloc_bitmap_t childusedmap;
	/**
	 * @brief The return value of the task's funtion. (set by the library)
	 */
	void *ret;
	/**
	 * @brief Pointer to the next task in the queue. (set by the library)
	 */
	struct ghost_task_t *next; 
	/**
	 * @brief Pointer to the previous task in the queue. (set by the library)
	 */
	struct ghost_task_t *prev;
	/**
	 * @brief The adding task if the task has been added from within a task.
	 * (set by the library)
	 */
	struct ghost_task_t *parent;
	/**
	 * @brief Indicator that the task is finished. (set by the library)
	 */
	pthread_cond_t *finishedCond;
	/**
	 * @brief Protect accesses to the task's members. (set by the library)
	 */
{'fraction_non_alphanumeric': 0.09625492772667543, 'fraction_numerical': 0.006570302233902759, 'mean_word_length': 3.6304182509505702, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6304975', 'n_tokens_mistral': 2182, 'n_tokens_neox': 2042, 'n_words': 792}