Skip to content

Commit

Permalink
Remove commented braces since they've been causing occasional formatt…
Browse files Browse the repository at this point in the history
…ing inconsistencies.
  • Loading branch information
insertinterestingnamehere committed Jan 22, 2025
1 parent 708fbd3 commit e57a1cc
Show file tree
Hide file tree
Showing 49 changed files with 1,001 additions and 1,105 deletions.
2 changes: 0 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ AC_CANONICAL_HOST
## ----------------- ##
## Check the options ##
## ----------------- ##
#{{{
AC_ARG_ENABLE([picky],
[AS_HELP_STRING([--enable-picky],
[turns on extra compiler warnings (for developers of qthreads)])])
Expand Down Expand Up @@ -154,7 +153,6 @@ AC_ARG_VAR([MPICC], [Path to the MPI C compiler-wrapper.])
AC_ARG_VAR([MPICXX], [Path to the MPI C++ compiler-wrapper.])

AC_CACHE_SAVE
#}}}

## ------------------- ##
## Checks for programs ##
Expand Down
8 changes: 4 additions & 4 deletions include/qt_addrstat.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* This allocates a new, initialized addrstat structure, which is used for
* keeping track of the FEB status of an address. It expects a shepherd pointer
* to use to find the right memory pool to use. */
static inline qthread_addrstat_t *qthread_addrstat_new(void) { /*{{{ */
static inline qthread_addrstat_t *qthread_addrstat_new(void) {
qthread_addrstat_t *ret = ALLOC_ADDRSTAT();
QTHREAD_FASTLOCK_INIT_PTR(&ret->lock);
QTHREAD_FASTLOCK_LOCK(&ret->lock);
Expand All @@ -19,15 +19,15 @@ static inline qthread_addrstat_t *qthread_addrstat_new(void) { /*{{{ */
QTHREAD_FASTLOCK_UNLOCK(&ret->lock);

return ret;
} /*}}} */
}

/* this function is for maintenance of the FEB hashtables. SHOULD only be
* necessary for things left over when qthread_finalize is called */
static void qthread_addrstat_delete(void *m_void) { /*{{{ */
static void qthread_addrstat_delete(void *m_void) {
qthread_addrstat_t *m = (qthread_addrstat_t *)m_void;
QTHREAD_FASTLOCK_DESTROY(m->lock);
FREE_ADDRSTAT(m);
} /*}}} */
}

#endif // ifndef QT_ADDRSTAT_H
/* vim:set expandtab: */
13 changes: 6 additions & 7 deletions include/qt_atomics.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,9 @@ static inline int QTHREAD_TRYLOCK_TRY(qt_spin_trylock_t *x) {
#define qthread_internal_incr_mod(op, m, lock) qthread_internal_incr_mod_(op, m)
#define QTHREAD_OPTIONAL_LOCKARG

static inline aligned_t qthread_internal_incr_mod_(
aligned_t *operand,
unsigned int const max QTHREAD_OPTIONAL_LOCKARG) { /*{{{ */
static inline aligned_t
qthread_internal_incr_mod_(aligned_t *operand,
unsigned int const max QTHREAD_OPTIONAL_LOCKARG) {
aligned_t retval;

#if QTHREAD_BITS == 32
Expand Down Expand Up @@ -279,10 +279,9 @@ static inline aligned_t qthread_internal_incr_mod_(
#endif /* if QTHREAD_BITS == 32 */

return retval;
} /*}}} */
}

static inline void *qt_internal_atomic_swap_ptr(void **addr,
void *newval) { /*{{{*/
static inline void *qt_internal_atomic_swap_ptr(void **addr, void *newval) {
void *oldval =
atomic_load_explicit((void *_Atomic *)addr, memory_order_relaxed);
void *tmp;
Expand All @@ -291,7 +290,7 @@ static inline void *qt_internal_atomic_swap_ptr(void **addr,
oldval = tmp;
}
return oldval;
} /*}}}*/
}

#endif /* ifndef QT_ATOMICS_H */

Expand Down
8 changes: 4 additions & 4 deletions include/qt_blocking_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,16 @@ extern qt_mpool generic_addrstat_pool;

extern qt_mpool generic_addrres_pool;

static inline qthread_addrres_t *ALLOC_ADDRRES(void) { /*{{{ */
static inline qthread_addrres_t *ALLOC_ADDRRES(void) {
qthread_addrres_t *tmp =
(qthread_addrres_t *)qt_mpool_alloc(generic_addrres_pool);

return tmp;
} /*}}} */
}

static inline void FREE_ADDRRES(qthread_addrres_t *t) { /*{{{ */
static inline void FREE_ADDRRES(qthread_addrres_t *t) {
qt_mpool_free(generic_addrres_pool, t);
} /*}}} */
}

#endif // ifndef QT_BLOCKING_STRUCTS_H
/* vim:set expandtab: */
4 changes: 2 additions & 2 deletions include/qt_gcd.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ static inline size_t qt_gcd(size_t a, size_t b) {
#endif
}

static inline size_t qt_lcm(size_t a, size_t b) { /*{{{ */
static inline size_t qt_lcm(size_t a, size_t b) {
size_t tmp = qt_gcd(a, b);
/* on 32 bit platforms, it's pretty easy for a * b to overflow so we force
* 64 bit multiplication*/
uint64_t largeA = a;
uint64_t largeB = b;
return (tmp != 0) ? (largeA * largeB / tmp) : 0;
} /*}}} */
}
28 changes: 14 additions & 14 deletions include/qthread/qloop.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,49 +4,49 @@
#include "qloop.h"

template <typename T>
void qloop_cpp_wrapper(size_t startat, size_t stopat, void *_arg) { /*{{{ */
void qloop_cpp_wrapper(size_t startat, size_t stopat, void *_arg) {
T *arg = (T *)_arg;

(*arg)(startat, stopat);
} /*}}} */
}

template <typename T>
void qt_loop(size_t start, size_t stop, T const &obj) { /*{{{ */
void qt_loop(size_t start, size_t stop, T const &obj) {
qt_loop(start, stop, qloop_cpp_wrapper<T>, &(const_cast<T &>(obj)));
} /*}}} */
}

template <typename T>
void qt_loop_future(size_t start, size_t stop, T const &obj) { /*{{{*/
void qt_loop_future(size_t start, size_t stop, T const &obj) {
qt_loop_future(start, stop, qloop_cpp_wrapper<T>, &(const_cast<T &>(obj)));
} /*}}}*/
}

template <typename T>
void qt_loop_balance(size_t start, size_t stop, T const &obj) { /*{{{ */
void qt_loop_balance(size_t start, size_t stop, T const &obj) {
qt_loop_balance(start, stop, qloop_cpp_wrapper<T>, &(const_cast<T &>(obj)));
} /*}}} */
}

template <typename T>
void qt_loop_balance_simple(size_t start, size_t stop, T const &obj) { /*{{{ */
void qt_loop_balance_simple(size_t start, size_t stop, T const &obj) {
qt_loop_balance_simple(
start, stop, qloop_cpp_wrapper<T>, &(const_cast<T &>(obj)));
} /*}}} */
}

template <typename T>
void qt_loop_balance_future(size_t start, size_t stop, T const &obj) { /*{{{ */
void qt_loop_balance_future(size_t start, size_t stop, T const &obj) {
qt_loop_balance_future(
start, stop, qloop_cpp_wrapper<T>, &(const_cast<T &>(obj)));
} /*}}} */
}

template <typename T>
void qloop_accum_cpp_wrapper(size_t startat,
size_t stopat,
void *_arg,
void *ret) { /*{{{ */
void *ret) {
T *arg = (T *)_arg;

typename T::acctype tmp = (*arg)(startat, stopat);
*(typename T::acctype *)ret = tmp;
} /*}}} */
}

template <typename T>
typename T::acctype
Expand Down
25 changes: 10 additions & 15 deletions include/qthread/qthread.h
Original file line number Diff line number Diff line change
Expand Up @@ -634,8 +634,7 @@ int qthread_lock_destroy(aligned_t *a);
* All of these functions return the value of the contents of the operand
* *after* incrementing.
*/
static inline float qthread_fincr(float *operand, float incr) { /*{{{ */

static inline float qthread_fincr(float *operand, float incr) {
union {
float f;
uint32_t i;
Expand All @@ -649,10 +648,9 @@ static inline float qthread_fincr(float *operand, float incr) { /*{{{ */
__sync_val_compare_and_swap((uint32_t *)operand, oldval.i, newval.i);
} while (res.i != oldval.i); /* if res!=old, the calc is out of date */
return oldval.f;
} /*}}} */

static inline double qthread_dincr(double *operand, double incr) { /*{{{ */
}

static inline double qthread_dincr(double *operand, double incr) {
union {
uint64_t i;
double d;
Expand All @@ -666,20 +664,17 @@ static inline double qthread_dincr(double *operand, double incr) { /*{{{ */
__sync_val_compare_and_swap((uint64_t *)operand, oldval.i, newval.i);
} while (res.i != oldval.i); /* if res!=old, the calc is out of date */
return oldval.d;
} /*}}} */
}

static inline uint32_t qthread_incr32(uint32_t *operand,
uint32_t incr) { /*{{{ */
static inline uint32_t qthread_incr32(uint32_t *operand, uint32_t incr) {
return __sync_fetch_and_add(operand, incr);
} /*}}} */
}

static inline uint64_t qthread_incr64(uint64_t *operand,
uint64_t incr) { /*{{{ */
static inline uint64_t qthread_incr64(uint64_t *operand, uint64_t incr) {
return __sync_fetch_and_add(operand, incr);
} /*}}} */
}

static inline int64_t
qthread_incr_xx(void *addr, int64_t incr, size_t length) { /*{{{ */
static inline int64_t qthread_incr_xx(void *addr, int64_t incr, size_t length) {
switch (length) {
case 4: return qthread_incr32((uint32_t *)addr, incr);

Expand All @@ -688,7 +683,7 @@ qthread_incr_xx(void *addr, int64_t incr, size_t length) { /*{{{ */
default: QTHREAD_TRAP();
}
return 0; /* compiler check */
} /*}}} */
}

uint64_t qthread_syncvar_incrF(syncvar_t *restrict operand, uint64_t inc);

Expand Down
42 changes: 20 additions & 22 deletions src/affinity/hwloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ static unsigned int num_usable_by_depth(unsigned int depth) {
return ret;
}

static void qt_affinity_internal_hwloc_teardown(void) { /*{{{*/
static void qt_affinity_internal_hwloc_teardown(void) {
hwloc_set_cpubind(topology, mccoy_thread_bindings, HWLOC_CPUBIND_THREAD);
FREEBMAP(mccoy_thread_bindings);
if (my_topology) {
Expand All @@ -80,11 +80,11 @@ static void qt_affinity_internal_hwloc_teardown(void) { /*{{{*/
my_topology = 0;
}
initialized = 0;
} /*}}}*/
}

void INTERNAL qt_affinity_init(qthread_shepherd_id_t *nbshepherds,
qthread_worker_id_t *nbworkers,
size_t *hw_par) { /*{{{ */
size_t *hw_par) {
if (qthread_cas(&initialized, 0, 1) == 0) {
if (topology == NULL) {
qassert(hwloc_topology_init(&topology), 0);
Expand Down Expand Up @@ -259,14 +259,12 @@ void INTERNAL qt_affinity_init(qthread_shepherd_id_t *nbshepherds,
if (*nbworkers == 0) { *nbworkers = tmp; }
}
}
} /*}}} */
}

void INTERNAL qt_affinity_deinit(void) {}

#ifdef USE_HWLOC_MEM_AFFINITY
void INTERNAL qt_affinity_mem_tonode(void *addr,
size_t bytes,
int node) { /*{{{ */
void INTERNAL qt_affinity_mem_tonode(void *addr, size_t bytes, int node) {
hwloc_nodeset_t nodeset = hwloc_bitmap_alloc();

hwloc_bitmap_set(nodeset, node);
Expand All @@ -277,13 +275,13 @@ void INTERNAL qt_affinity_mem_tonode(void *addr,
HWLOC_MEMBIND_BIND,
HWLOC_MEMBIND_NOCPUBIND);
hwloc_bitmap_free(nodeset);
} /*}}} */
}

void INTERNAL *qt_affinity_alloc(size_t bytes) { /*{{{ */
void INTERNAL *qt_affinity_alloc(size_t bytes) {
return hwloc_alloc(topology, bytes);
} /*}}} */
}

void INTERNAL *qt_affinity_alloc_onnode(size_t bytes, int node) { /*{{{ */
void INTERNAL *qt_affinity_alloc_onnode(size_t bytes, int node) {
void *ret;
hwloc_nodeset_t nodeset;

Expand All @@ -293,24 +291,24 @@ void INTERNAL *qt_affinity_alloc_onnode(size_t bytes, int node) { /*{{{ */
topology, bytes, nodeset, HWLOC_MEMBIND_BIND, HWLOC_MEMBIND_NOCPUBIND);
hwloc_bitmap_free(nodeset);
return ret;
} /*}}} */
}

void INTERNAL qt_affinity_free(void *ptr, size_t bytes) { /*{{{ */
void INTERNAL qt_affinity_free(void *ptr, size_t bytes) {
hwloc_free(topology, ptr, bytes);
} /*}}} */
}

#endif /* ifdef USE_HWLOC_MEM_AFFINITY */

qthread_shepherd_id_t INTERNAL guess_num_shepherds(void) { /*{{{ */
qthread_shepherd_id_t INTERNAL guess_num_shepherds(void) {
qthread_shepherd_id_t ret = 1;

ret = num_usable_by_depth(shep_depth);
if (ret == 0) { ret = 1; }
return ret;
} /*}}} */
}

qthread_worker_id_t INTERNAL
guess_num_workers_per_shep(qthread_shepherd_id_t nshepherds) { /*{{{ */
guess_num_workers_per_shep(qthread_shepherd_id_t nshepherds) {
qthread_worker_id_t ret = 0;
size_t total = 0;

Expand Down Expand Up @@ -411,10 +409,10 @@ guess_num_workers_per_shep(qthread_shepherd_id_t nshepherds) { /*{{{ */
}
if (ret == 0) { ret = 1; }
return ret;
} /*}}} */
}

void INTERNAL qt_affinity_set(qthread_worker_t *me,
unsigned int nworkerspershep) { /*{{{ */
unsigned int nworkerspershep) {
ASSERT_ONLY(hwloc_topology_check(topology));

hwloc_const_cpuset_t const allowed_cpuset =
Expand Down Expand Up @@ -463,10 +461,10 @@ void INTERNAL qt_affinity_set(qthread_worker_t *me,
i);
FREE(str, strlen(str));
}
} /*}}} */
}

int INTERNAL qt_affinity_gendists(qthread_shepherd_t *sheps,
qthread_shepherd_id_t nshepherds) { /*{{{ */
qthread_shepherd_id_t nshepherds) {
hwloc_const_cpuset_t allowed_cpuset =
hwloc_topology_get_allowed_cpuset(topology); // where am I allowed to run?
size_t num_extant_objs;
Expand Down Expand Up @@ -494,6 +492,6 @@ int INTERNAL qt_affinity_gendists(qthread_shepherd_t *sheps,
}
/* there does not seem to be a way to extract distances... <sigh> */
return QTHREAD_SUCCESS;
} /*}}} */
}

/* vim:set expandtab: */
8 changes: 4 additions & 4 deletions src/affinity/no.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@

void INTERNAL qt_affinity_init(qthread_shepherd_id_t *nbshepherds,
qthread_worker_id_t *nbworkers,
size_t *hw_par) { /*{{{ */
size_t *hw_par) {
if (*nbshepherds == 0) { *nbshepherds = 1; }
if (*nbworkers == 0) { *nbworkers = 1; }
} /*}}} */
}

void INTERNAL qt_affinity_deinit(void) {}

void INTERNAL qt_affinity_set(qthread_worker_t *me, unsigned int Q_UNUSED(nw)) {
}

int INTERNAL qt_affinity_gendists(qthread_shepherd_t *sheps,
qthread_shepherd_id_t nshepherds) { /*{{{ */
qthread_shepherd_id_t nshepherds) {
for (size_t i = 0; i < nshepherds; ++i) {
sheps[i].sorted_sheplist =
qt_calloc(nshepherds - 1, sizeof(qthread_shepherd_id_t));
Expand All @@ -33,6 +33,6 @@ int INTERNAL qt_affinity_gendists(qthread_shepherd_t *sheps,
shuffle_sheps(sheps[i].sorted_sheplist, nshepherds - 1);
}
return QTHREAD_SUCCESS;
} /*}}} */
}

/* vim:set expandtab: */
Loading

0 comments on commit e57a1cc

Please sign in to comment.