mirror of
https://github.com/matrix-construct/construct
synced 2024-11-12 13:01:07 +01:00
ircd::simt: Split is_pow() util to math header for now.
This commit is contained in:
parent
521a04730c
commit
0fb7577066
4 changed files with 23 additions and 8 deletions
20
include/ircd/simt/math.h
Normal file
20
include/ircd/simt/math.h
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
// Matrix Construct
|
||||||
|
//
|
||||||
|
// Copyright (C) Matrix Construct Developers, Authors & Contributors
|
||||||
|
// Copyright (C) 2016-2022 Jason Volk <jason@zemos.net>
|
||||||
|
//
|
||||||
|
// Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
// purpose with or without fee is hereby granted, provided that the above
|
||||||
|
// copyright notice and this permission notice is present in all copies. The
|
||||||
|
// full license for this software is available in the LICENSE file.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#define HAVE_IRCD_SIMT_MATH_H
|
||||||
|
|
||||||
|
#ifdef __OPENCL_VERSION__
|
||||||
|
inline bool
|
||||||
|
ircd_math_is_pow2(const uint val)
|
||||||
|
{
|
||||||
|
return val > 0 && (val & (val - 1)) == 0;
|
||||||
|
}
|
||||||
|
#endif
|
|
@ -11,14 +11,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#define HAVE_IRCD_SIMT_REDUCE_ADD_H
|
#define HAVE_IRCD_SIMT_REDUCE_ADD_H
|
||||||
|
|
||||||
#ifdef __OPENCL_VERSION__
|
|
||||||
inline bool
|
|
||||||
ircd_math_is_pow2(const uint val)
|
|
||||||
{
|
|
||||||
return val > 0 && (val & (val - 1)) == 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __OPENCL_VERSION__
|
#ifdef __OPENCL_VERSION__
|
||||||
/// Sum all elements in the buffer. All threads in the group participate;
|
/// Sum all elements in the buffer. All threads in the group participate;
|
||||||
/// result is placed in index [0], the rest of the buffer is trashed.
|
/// result is placed in index [0], the rest of the buffer is trashed.
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#include "portable.h"
|
#include "portable.h"
|
||||||
#include "assert.h"
|
#include "assert.h"
|
||||||
#include "cycles.h"
|
#include "cycles.h"
|
||||||
|
#include "math.h"
|
||||||
#include "broadcast.h"
|
#include "broadcast.h"
|
||||||
#include "reduce_add.h"
|
#include "reduce_add.h"
|
||||||
#include "reduce_max.h"
|
#include "reduce_max.h"
|
||||||
|
|
|
@ -66,6 +66,8 @@ ircd_simt_sort_idx16_flldr(__local ushort *const idx,
|
||||||
const uint ln,
|
const uint ln,
|
||||||
const uint li)
|
const uint li)
|
||||||
{
|
{
|
||||||
|
assert(ircd_math_is_pow2(ln));
|
||||||
|
|
||||||
#pragma clang loop unroll(disable)
|
#pragma clang loop unroll(disable)
|
||||||
for(uint up = 1; up < ln; up <<= 1)
|
for(uint up = 1; up < ln; up <<= 1)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue