0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-06-02 18:18:56 +02:00

ircd::simt: Consolidate portables and macros from units into headers.

This commit is contained in:
Jason Volk 2022-10-10 22:39:55 +00:00
parent 831141727b
commit 54e3b8f5b4
5 changed files with 112 additions and 52 deletions

View file

@ -11,22 +11,6 @@
#pragma once
#define HAVE_IRCD_GPT_VECTOR_H
#if !defined(__SIZEOF_FLOAT4__) && defined(__OPENCL_VERSION__)
#define __SIZEOF_FLOAT4__ 16
#endif
#if !defined(__SIZEOF_FLOAT8__) && defined(__OPENCL_VERSION__)
#define __SIZEOF_FLOAT8__ 32
#endif
#if !defined(__SIZEOF_FLOAT16__) && defined(__OPENCL_VERSION__)
#define __SIZEOF_FLOAT16__ 64
#endif
#ifndef __OPENCL_VERSION__
#define __constant
#endif
static __constant const uint
ircd_gpt_context_tokens = 512, // 1024,
ircd_gpt_vector_elems = 768,

View file

@ -0,0 +1,31 @@
// 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_ASSERT_H
//
// Trapping assert() on supporting platforms.
//
#if defined(__OPENCL_VERSION__)
#if __OPENCL_VERSION__ >= 200 \
&& !defined(assert) \
&& !defined(NDEBUG) \
&& __has_builtin(__builtin_trap)
#define assert(expr) \
({ \
if(unlikely(!(bool)(x))) \
__builtin_trap(); \
})
#else
#define assert(x)
#endif
#endif

View file

@ -0,0 +1,79 @@
// 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_PORTABLE_H
//
// Decide the proper form of the restrict qualifier for the platform, if any.
//
#if defined(__OPENCL_VERSION__)
#if defined(__SPIR)
#define restrict
#elif defined(__cplusplus)
#define restrict __restrict
#endif
#endif
//
// Decide the proper form of static linkage for the platform
//
#if defined(__OPENCL_VERSION__)
#if __OPENCL_VERSION__ < 120
#define static __attribute__((internal_linkage))
#elif __OPENCL_VERSION__ < 200
#define static __constant static
#endif
#endif
//
// When headers are shared between opencl and non-opencl units, address space
// qualifiers may be required for the former and can be ignored for the latter.
// Note this header itself may be included by both opencl and non-opencl units.
//
#if !defined(__OPENCL_VERSION__)
#define __constant
#endif
//
// Silently drop calls to printf() on unsupporting platforms; this way we can
// leave the same code unmodified and quietly discard the output.
//
#if defined(__OPENCL_VERSION__)
#if __OPENCL_VERSION__ < 200
#define printf(...)
#endif
#endif
//
// XXX
//
#if defined(__OPENCL_VERSION__)
#if !defined(__SIZEOF_FLOAT4__)
#define __SIZEOF_FLOAT4__ 16
#endif
#endif
#if defined(__OPENCL_VERSION__)
#if !defined(__SIZEOF_FLOAT8__)
#define __SIZEOF_FLOAT8__ 32
#endif
#endif
#if defined(__OPENCL_VERSION__)
#if !defined(__SIZEOF_FLOAT16__)
#define __SIZEOF_FLOAT16__ 64
#endif
#endif

View file

@ -11,6 +11,8 @@
#pragma once
#define HAVE_IRCD_SIMT_H
#include "portable.h"
#include "assert.h"
#include "broadcast.h"
#include "reduce_add.h"
#include "reduce_max.h"

View file

@ -15,46 +15,10 @@
#include <ircd/config.h>
#include <ircd/portable.h>
#include <clc/clc.h>
#if !defined(assert) \
&& !defined(NDEBUG) \
&& defined(RB_ASSERT_INTRINSIC) \
&& __has_builtin(__builtin_trap) \
&& __OPENCL_VERSION__ >= 200
#define assert(x) ((void)(unlikely(!(bool)(x))? __builtin_trap(): 0))
#else
#define assert(x)
#endif
#if defined(__SPIR)
#define restrict
#elif defined(__cplusplus)
#define restrict __restrict
#endif
#if __OPENCL_VERSION__ < 120
#define static __attribute__((internal_linkage))
#elif __OPENCL_VERSION__ < 200
#define static __constant static
#endif
#if __OPENCL_VERSION__ < 200
#define printf(...)
#endif
#pragma clang attribute push(__attribute__((always_inline)), apply_to = function)
#pragma clang attribute push(__attribute__((internal_linkage)), apply_to = function)
#include <ircd/simt/simt.h>
#include <ircd/gpt/vector.h>
#include <ircd/gpt/opts.h>
#include <ircd/gpt/ctrl.h>
#pragma clang attribute pop
#pragma clang attribute pop
#if __OPENCL_VERSION__ >= 120
#undef static
#endif
#include <ircd/gpt/gpu.h>
//