Skip to content
Snippets Groups Projects
Select Git revision
  • paranoid
  • master default protected
  • split-space-split
  • better-space-split-tpool
  • melion/BalsaraKim
  • darwin/gear_preSN_fbk_merge
  • reyz/gear_preSN_feedback
  • mark_bug
  • FS_VP_m2_allGrad
  • nickishch/MHD_canvas/OWAR_fully_symmetric_ShearAndRotation
  • fstasys/VEP_Fm2
  • beyond-mesh-pair-removal
  • darwin/gear_chemistry_fluxes
  • MHD_canvas protected
  • sidm_merge protected
  • fewer_gpart_comms
  • zoom_merge protected
  • MAGMA2_matthieu
  • darwin/sink_mpi_physics
  • darwin/gear_mechanical_feedback
  • improve-snap-to-ic
  • v2025.10 protected
  • v2025.04 protected
  • v2025.01 protected
  • v1.0.0 protected
  • v0.9.0 protected
  • v0.8.5 protected
  • v0.8.4 protected
  • v0.8.3 protected
  • v0.8.2 protected
  • v0.8.1 protected
  • v0.8.0 protected
  • v0.7.0 protected
  • v0.6.0 protected
  • v0.5.0 protected
  • v0.4.0 protected
  • v0.3.0 protected
  • v0.2.0 protected
  • v0.1.0-pre protected
  • v0.1 protected
  • v0.0 protected
41 results

runner.h

Blame
  • Pedro Gonnet's avatar
    Pedro Gonnet authored
    Former-commit-id: 08929cc7d4d18b19f7307c801321528e48723186
    7f27b385
    History
    runner.h 3.25 KiB
    /*******************************************************************************
     * This file is part of SWIFT.
     * Coypright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk)
     *
     * This program is free software: you can redistribute it and/or modify
     * it under the terms of the GNU Lesser General Public License as published
     * by the Free Software Foundation, either version 3 of the License, or
     * (at your option) any later version.
     *
     * This program is distributed in the hope that it will be useful,
     * but WITHOUT ANY WARRANTY; without even the implied warranty of
     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     * GNU General Public License for more details.
     *
     * You should have received a copy of the GNU Lesser General Public License
     * along with this program.  If not, see <http://www.gnu.org/licenses/>.
     *
     ******************************************************************************/
    #ifndef SWIFT_RUNNER_H
    #define SWIFT_RUNNER_H
    
    /* Some standard headers. */
    #include <pthread.h>
    
    /* Includes. */
    #include "cell.h"
    #include "inline.h"
    
    /* Forward-declare the engine type to avoid cyclic header dependencies. */
    struct engine;
    
    /* Some constants/flags. */
    #define runner_prefetch 0
    
    /* SID stuff. */
    extern const char runner_flip[];
    
    /* Counters. */
    enum runner_counters {
      runner_counter_swap = 0,
      runner_counter_stall,
      runner_counter_steal_stall,
      runner_counter_steal_empty,
      runner_counter_keep,
      runner_counter_iact,
      runner_counter_count,
    };
    extern int runner_counter[runner_counter_count];
    
    /* Counter macros. */
    #ifdef COUNTER
    #define COUNT(c) (__sync_add_and_fetch(&runner_counter[c], 1))
    #else
    #define COUNT(c)
    #endif
    
    /* Histogram functions. */
    #define runner_hist_a 1.0
    #define runner_hist_b 100.0
    #define runner_hist_N 99
    long long int runner_hist_bins[runner_hist_N];
    #define runner_hist_hit(x)                                                   \
      __sync_add_and_fetch(                                                      \
          &runner_hist_bins[(int)fmax(                                           \
              0.0, fmin(runner_hist_N - 1, ((x) - runner_hist_a) /               \
                                               (runner_hist_b - runner_hist_a) * \
                                               runner_hist_N))],                 \
          1)
    
    /* A struct representing a runner's thread and its data. */
    struct runner {
    
      /* The id of this thread. */
      int id;
    
      /* The thread which it is running. */
      pthread_t thread;
    
      /* The queue to use to get tasks. */
      int cpuid, qid;
    
      /* The underlying runner. */
      struct engine *e;
    };
    
    /* Function prototypes. */
    void runner_doghost(struct runner *r, struct cell *c);
    void runner_dopair_density(struct runner *r, struct cell *ci, struct cell *cj);
    void runner_doself_density(struct runner *r, struct cell *c);
    void runner_dosub_density(struct runner *r, struct cell *ci, struct cell *cj,
                              int flags);
    void runner_dosort(struct runner *r, struct cell *c, int flag, int clock);
    void runner_dogsort(struct runner *r, struct cell *c, int flag, int clock);
    void runner_dokick(struct runner *r, struct cell *c, int timer);
    void runner_dokick1(struct runner *r, struct cell *c);
    void runner_dokick2(struct runner *r, struct cell *c);
    void *runner_main(void *data);
    
    #endif /* SWIFT_RUNNER_H */