<commit_before>#include "sixtracklib/cuda/control/default_kernel_config.h"

#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>

#include "sixtracklib/common/definitions.h"
#include "sixtracklib/common/control/definitions.h"
#include "sixtracklib/common/control/kernel_config_base.h"
#include "sixtracklib/cuda/definitions.h"
#include "sixtracklib/cuda/control/kernel_config.h"
#include "sixtracklib/cuda/control/node_info.h"

SIXTRL_STATIC SIXTRL_HOST_FN NS(arch_status_t)
NS(CudaKernelConfig_configure_generic_track_kernel)(
    NS(CudaKernelConfig)* SIXTRL_RESTRICT kernel_config,
    const NS(CudaNodeInfo) *const SIXTRL_RESTRICT node_info,
    NS(buffer_size_t) const total_num_particles_to_track,
    NS(buffer_size_t) const threads_per_block );


NS(arch_status_t) NS(CudaKernelConfig_configure_track_until_turn_kernel)(
    NS(CudaKernelConfig)* SIXTRL_RESTRICT kernel_config,
    const NS(CudaNodeInfo) *const SIXTRL_RESTRICT node_info,
    NS(buffer_size_t) const total_num_particles_to_track,
    NS(buffer_size_t) const threads_per_block )
{
    return NS(CudaKernelConfig_configure_generic_track_kernel)( kernel_config,
        node_info, total_num_particles_to_track, threads_per_block );
}

NS(arch_status_t)
NS(CudaKernelConfig_configure_track_elem_by_elem_until_turn_kernel)(
    NS(CudaKernelConfig)* SIXTRL_RESTRICT kernel_config,
    const NS(CudaNodeInfo) *const SIXTRL_RESTRICT node_info,
    NS(buffer_size_t) const total_num_particles_to_track,
    NS(buffer_size_t) const threads_per_block )
{
    return NS(CudaKernelConfig_configure_generic_track_kernel)( kernel_config,
        node_info, total_num_particles_to_track, threads_per_block );
}

NS(arch_status_t) NS(CudaKernelConfig_configure_track_line_kernel)(
    NS(CudaKernelConfig)* SIXTRL_RESTRICT kernel_config,
    const NS(CudaNodeInfo) *const SIXTRL_RESTRICT node_info,
    NS(buffer_size_t) const total_num_particles_to_track,
    NS(buffer_size_t) const threads_per_block )
{
    return NS(CudaKernelConfig_configure_generic_track_kernel)( kernel_config,
        node_info, total_num_particles_to_track, threads_per_block );
}

/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

NS(arch_status_t) NS(CudaKernelConfig_configure_fetch_particles_addresses_kernel)(
    NS(CudaKernelConfig)* SIXTRL_RESTRICT kernel_config,
    const NS(CudaNodeInfo) *const SIXTRL_RESTRICT node_info,
    NS(buffer_size_t) const num_particle_sets,
    NS(buffer_size_t) const threads_per_block )
{
    NS(arch_status_t) status = NS(ARCH_STATUS_GENERAL_FAILURE);

     if( ( kernel_config != SIXTRL_NULLPTR ) &&
         ( threads_per_block > ( NS(buffer_size_t) )0u ) &&
         ( node_info != SIXTRL_NULLPTR ) )
    {
        NS(buffer_size_t) const warp_size =
            NS(CudaNodeInfo_get_warp_size)( node_info );

        NS(buffer_size_t) threads_per_block =
            ( NS(buffer_size_t) )threads_per_block;


        NS(buffer_size_t) num_blocks = num_particle_sets / threads_per_block;

        if( ( num_blocks * threads_per_block ) < num_particle_sets )
        {
            ++num_blocks;
        }

        if( ( NS(ARCH_STATUS_SUCCESS) ==
              NS(KernelConfig_set_num_work_items_1d)(
                kernel_config, num_blocks ) ) &&
            ( NS(ARCH_STATUS_SUCCESS) ==
              NS(KernelConfig_set_work_group_sizes_1d)(
                kernel_config, threads_per_block ) ) &&
            ( NS(ARCH_STATUS_SUCCESS) ==
              NS(KernelConfig_set_preferred_work_group_multiple_1d)(<commit_msg>cuda: fixes self-assignment & shadowing variable bug in configuration routine for the default assing addresses kernel<commit_after>#include "sixtracklib/cuda/control/default_kernel_config.h"

#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>

#include "sixtracklib/common/definitions.h"
#include "sixtracklib/common/control/definitions.h"
#include "sixtracklib/common/control/kernel_config_base.h"
#include "sixtracklib/cuda/definitions.h"
#include "sixtracklib/cuda/control/kernel_config.h"
#include "sixtracklib/cuda/control/node_info.h"

SIXTRL_STATIC SIXTRL_HOST_FN NS(arch_status_t)
NS(CudaKernelConfig_configure_generic_track_kernel)(
    NS(CudaKernelConfig)* SIXTRL_RESTRICT kernel_config,
    const NS(CudaNodeInfo) *const SIXTRL_RESTRICT node_info,
    NS(buffer_size_t) const total_num_particles_to_track,
    NS(buffer_size_t) const threads_per_block );


NS(arch_status_t) NS(CudaKernelConfig_configure_track_until_turn_kernel)(
    NS(CudaKernelConfig)* SIXTRL_RESTRICT kernel_config,
    const NS(CudaNodeInfo) *const SIXTRL_RESTRICT node_info,
    NS(buffer_size_t) const total_num_particles_to_track,
    NS(buffer_size_t) const threads_per_block )
{
    return NS(CudaKernelConfig_configure_generic_track_kernel)( kernel_config,
        node_info, total_num_particles_to_track, threads_per_block );
}

NS(arch_status_t)
NS(CudaKernelConfig_configure_track_elem_by_elem_until_turn_kernel)(
    NS(CudaKernelConfig)* SIXTRL_RESTRICT kernel_config,
    const NS(CudaNodeInfo) *const SIXTRL_RESTRICT node_info,
    NS(buffer_size_t) const total_num_particles_to_track,
    NS(buffer_size_t) const threads_per_block )
{
    return NS(CudaKernelConfig_configure_generic_track_kernel)( kernel_config,
        node_info, total_num_particles_to_track, threads_per_block );
}

NS(arch_status_t) NS(CudaKernelConfig_configure_track_line_kernel)(
    NS(CudaKernelConfig)* SIXTRL_RESTRICT kernel_config,
    const NS(CudaNodeInfo) *const SIXTRL_RESTRICT node_info,
    NS(buffer_size_t) const total_num_particles_to_track,
    NS(buffer_size_t) const threads_per_block )
{
    return NS(CudaKernelConfig_configure_generic_track_kernel)( kernel_config,
        node_info, total_num_particles_to_track, threads_per_block );
}

/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

NS(arch_status_t) NS(CudaKernelConfig_configure_fetch_particles_addresses_kernel)(
    NS(CudaKernelConfig)* SIXTRL_RESTRICT kernel_config,
    const NS(CudaNodeInfo) *const SIXTRL_RESTRICT node_info,
    NS(buffer_size_t) const num_particle_sets,
    NS(buffer_size_t) const threads_per_block )
{
    NS(arch_status_t) status = NS(ARCH_STATUS_GENERAL_FAILURE);

     if( ( kernel_config != SIXTRL_NULLPTR ) &&
         ( threads_per_block > ( NS(buffer_size_t) )0u ) &&
         ( node_info != SIXTRL_NULLPTR ) )
    {
        NS(buffer_size_t) const warp_size =
            NS(CudaNodeInfo_get_warp_size)( node_info );

        NS(buffer_size_t) num_blocks = num_particle_sets / threads_per_block;

        if( ( num_blocks * threads_per_block ) < num_particle_sets )
        {
            ++num_blocks;
        }

        if( ( NS(ARCH_STATUS_SUCCESS) ==
              NS(KernelConfig_set_num_work_items_1d)(
                kernel_config, num_blocks ) ) &&
            ( NS(ARCH_STATUS_SUCCESS) ==
              NS(KernelConfig_set_work_group_sizes_1d)(
                kernel_config, threads_per_block ) ) &&
            ( NS(ARCH_STATUS_SUCCESS) ==
              NS(KernelConfig_set_preferred_work_group_multiple_1d)(
{'fraction_non_alphanumeric': 0.09102455546147332, 'fraction_numerical': 0.0011289867344058708, 'mean_word_length': 4.300673148840688, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6808721', 'n_tokens_mistral': 2532, 'n_tokens_neox': 2498, 'n_words': 329}