-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathfloat.h
56 lines (45 loc) · 1.2 KB
/
float.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
* Copyright (C) 2015-2018, Nils Moehrle
* All rights reserved.
*
* This software may be modified and distributed under the terms
* of the BSD 3-Clause license. See the LICENSE.txt file for details.
*/
#ifndef CACC_FLOAT_HEADER
#define CACC_FLOAT_HEADER
#include "defines.h"
CACC_NAMESPACE_BEGIN
struct __align__(16) Float4 {
float4 data;
__forceinline__ __host__ __device__
float const & operator[] (int i) const {
switch (i) {
case 0: return data.x;
case 1: return data.y;
case 2: return data.z;
default: return data.w;
}
}
__forceinline__ __host__ __device__
float & operator[] (int i) {
switch (i) {
case 0: return data.x;
case 1: return data.y;
case 2: return data.z;
default: return data.w;
}
}
};
struct __align__(8) Float2 {
float2 data;
__forceinline__ __host__ __device__
float const & operator[] (int i) const {
return i ? data.y : data.x;
}
__forceinline__ __host__ __device__
float & operator[] (int i) {
return i ? data.y : data.x;
}
};
CACC_NAMESPACE_END
#endif /* CACC_FLOAT_HEADER */