<commit_before>#ifndef SIXTRACKLIB_COMMON_IMPL_PARTICLES_TYPE_H__
#define SIXTRACKLIB_COMMON_IMPL_PARTICLES_TYPE_H__

#if !defined( _GPUCODE )

#include "sixtracklib/_impl/namespace_begin.h"

#include <assert.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>

#include "sixtracklib/_impl/inline.h"
#include "sixtracklib/common/restrict.h"

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

#endif /* !defined( _GPUCODE ) */

typedef struct NS( Particles )
{
    uint64_t npart;

    double* q0;     /* C */
    double* mass0;  /* eV */
    double* beta0;  /* nounit */
    double* gamma0; /* nounit */
    double* p0c;    /* eV */

    /* coordinate arrays */
    int64_t* partid;
    int64_t* elemid; /* element at which the particle was lost */
    int64_t* turn;   /* turn at which the particle was lost */
    int64_t* state;  /* negative means particle lost */

    double* s;     /* [m] */
    double* x;     /* [m] */
    double* px;    /* Px/P0 */
    double* y;     /* [m] */
    double* py;    /* Py/P0 */
    double* sigma; /* s-beta0*c*t  where t is the time
                      since the beginning of the simulation */

    double* psigma; /* (E-E0) / (beta0 P0c) conjugate of sigma */
    double* delta;  /* P/P0-1 = 1/rpp-1 */
    double* rpp;    /* ratio P0 /P */
    double* rvv;    /* ratio beta / beta0 */
    double* chi;    /* q/q0 * m/m0  */

    uint64_t flags;         /* particle flags */
    void* ptr_mem_context;  /* memory_context -> can contain */
    void* ptr_mem_begin; /* reference memory addr for (un)packing (optional) */
} NS( Particles );

static int64_t const NS( PARTICLE_VALID_STATE ) = INT64_C( 0 );

static uint64_t const NS( PARTICLES_FLAGS_NONE ) = UINT64_C( 0x0000 );

static uint64_t const NS( PARTICLES_FLAGS_PACKED ) = UINT64_C( 0x0001 );

static uint64_t const NS( PARTICLES_FLAGS_OWNS_MEMORY ) = UINT64_C( 0x0002 );

static uint64_t const
    NS( PARTICLES_FLAGS_MEM_CTX_MEMPOOL ) = UINT64_C( 0x0010 );

static uint64_t const
    NS( PARTICLES_FLAGS_MEM_CTX_SINGLEPARTICLE ) = UINT64_C( 0x0020 );

static uint64_t const NS( PARTICLES_FLAGS_ALIGN_MASK ) = UINT64_C( 0xFFFF00 );

static uint64_t const NS( PARTICLES_MAX_ALIGNMENT ) = UINT64_C( 0xFFFF );

static uint64_t const
    NS( PARTICLES_FLAGS_ALIGN_MASK_OFFSET_BITS ) = UINT64_C( 8 );

/* ========================================================================= */

static size_t const NS( PARTICLES_DEFAULT_MEMPOOL_CHUNK_SIZE ) = (size_t)8u;
static size_t const NS( PARTICLES_DEFAULT_MEMPOOL_ALIGNMENT ) = (size_t)16u;
static size_t const NS( PARTICLES_NUM_OF_DOUBLE_ELEMENTS ) = (size_t)16u;
static size_t const NS( PARTICLES_NUM_OF_INT64_ELEMENTS ) = (size_t)4u;



/* ========================================================================= */

static uint64_t NS( Particles_get_size )( const struct NS( Particles ) *
                                          const SIXTRL_RESTRICT p );

static void NS( Particles_set_size )( struct NS( Particles ) *
                                          SIXTRL_RESTRICT p,
                                      uint64_t npart );

static uint64_t NS( Particles_get_flags )( const struct NS( Particles ) *
                                           const SIXTRL_RESTRICT p );
<commit_msg>Added support for mapped memory backend (required for generic unpacking impl)<commit_after>#ifndef SIXTRACKLIB_COMMON_IMPL_PARTICLES_TYPE_H__
#define SIXTRACKLIB_COMMON_IMPL_PARTICLES_TYPE_H__

#if !defined( _GPUCODE )

#include "sixtracklib/_impl/namespace_begin.h"

#include <assert.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>

#include "sixtracklib/_impl/inline.h"
#include "sixtracklib/common/restrict.h"

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

#endif /* !defined( _GPUCODE ) */

typedef struct NS( Particles )
{
    uint64_t npart;

    double* q0;     /* C */
    double* mass0;  /* eV */
    double* beta0;  /* nounit */
    double* gamma0; /* nounit */
    double* p0c;    /* eV */

    /* coordinate arrays */
    int64_t* partid;
    int64_t* elemid; /* element at which the particle was lost */
    int64_t* turn;   /* turn at which the particle was lost */
    int64_t* state;  /* negative means particle lost */

    double* s;     /* [m] */
    double* x;     /* [m] */
    double* px;    /* Px/P0 */
    double* y;     /* [m] */
    double* py;    /* Py/P0 */
    double* sigma; /* s-beta0*c*t  where t is the time
                      since the beginning of the simulation */

    double* psigma; /* (E-E0) / (beta0 P0c) conjugate of sigma */
    double* delta;  /* P/P0-1 = 1/rpp-1 */
    double* rpp;    /* ratio P0 /P */
    double* rvv;    /* ratio beta / beta0 */
    double* chi;    /* q/q0 * m/m0  */

    uint64_t flags;         /* particle flags */
    void* ptr_mem_context;  /* memory_context -> can contain */
    void* ptr_mem_begin; /* reference memory addr for (un)packing (optional) */
} NS( Particles );

static uint64_t const NS(PARTICLES_PACK_INDICATOR) = UINT64_C( 1 );

static int64_t const NS( PARTICLE_VALID_STATE ) = INT64_C( 0 );

static uint64_t const NS( PARTICLES_FLAGS_NONE ) = UINT64_C( 0x0000 );

static uint64_t const NS( PARTICLES_FLAGS_PACKED ) = UINT64_C( 0x0001 );

static uint64_t const NS( PARTICLES_FLAGS_OWNS_MEMORY ) = UINT64_C( 0x0002 );

static uint64_t const
    NS( PARTICLES_FLAGS_MEM_CTX_MEMPOOL ) = UINT64_C( 0x0010 );

static uint64_t const
    NS( PARTICLES_FLAGS_MEM_CTX_SINGLEPARTICLE ) = UINT64_C( 0x0020 );
    
static uint64_t const 
    NS(PARTICLES_FLAGS_MEM_CTX_FLAT_MEMORY ) = UINT64_C( 0x0040 );

static uint64_t const NS( PARTICLES_FLAGS_ALIGN_MASK ) = UINT64_C( 0xFFFF00 );

static uint64_t const NS( PARTICLES_MAX_ALIGNMENT ) = UINT64_C( 0xFFFF );

static uint64_t const
    NS( PARTICLES_FLAGS_ALIGN_MASK_OFFSET_BITS ) = UINT64_C( 8 );

/* ========================================================================= */

static size_t const NS( PARTICLES_DEFAULT_MEMPOOL_CHUNK_SIZE ) = (size_t)8u;
static size_t const NS( PARTICLES_DEFAULT_MEMPOOL_ALIGNMENT ) = (size_t)16u;
static size_t const NS( PARTICLES_NUM_OF_DOUBLE_ELEMENTS ) = (size_t)16u;
static size_t const NS( PARTICLES_NUM_OF_INT64_ELEMENTS ) = (size_t)4u;
static size_t const NS( PARTICLES_NUM_OF_ATTRIBUTES ) = ( size_t )20u;
static size_t const NS( PARTICLES_PACK_BLOCK_LENGTH ) = ( size_t )192u;


static uint64_t const NS( PARTICLES_UNPACK_MAP  ) = UINT64_C( 0x0000 );
static uint64_t const NS( PARTICLES_UNPACK_COPY ) = UINT64_C( 0x0001 );
static uint64_t const NS( PARTICLES_UNPACK_CHECK_CONSISTENCY ) = 
    UINT64_C( 0x02 );

/* ========================================================================= */

static uint64_t NS( Particles_get_size )( const struct NS( Particles ) *
                                          const SIXTRL_RESTRICT p );

static void NS( Particles_set_size )( struct NS( Particles ) *
                                          SIXTRL_RESTRICT p,
                                      uint64_t npart );

static uint64_t NS( Particles_get_flags )( const struct NS( Particles ) *
                                           const SIXTRL_RESTRICT p );

{'fraction_non_alphanumeric': 0.1453885865773685, 'fraction_numerical': 0.03739360959955351, 'mean_word_length': 2.9888703394546465, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5616001', 'n_tokens_mistral': 2667, 'n_tokens_neox': 2466, 'n_words': 607}