@@ -164,25 +164,33 @@ struct PostprocessKeyFunctor<double> {
164
164
//
165
165
166
166
template <> struct KeyConversion <char > {
167
- typedef unsigned char UnsignedBits;
167
+ typedef unsigned char UnsignedBits;
168
168
};
169
169
170
170
template <>
171
171
struct PreprocessKeyFunctor <char > {
172
- __device__ __host__ __forceinline__ void operator ()(unsigned char &converted_key) {
173
- const unsigned int SIGN_MASK = 1u << ((sizeof (char ) * 8 ) - 1 );
174
- converted_key ^= SIGN_MASK;
175
- }
176
- __device__ __host__ __forceinline__ static bool MustApply (){ return true ;}
172
+ __device__ __host__ __forceinline__ void operator ()(unsigned char &converted_key) {
173
+ // char is unsigned on some platforms, so we have to check
174
+ if (std::numeric_limits<char >::is_signed)
175
+ {
176
+ const unsigned int SIGN_MASK = 1u << ((sizeof (char ) * 8 ) - 1 );
177
+ converted_key ^= SIGN_MASK;
178
+ }
179
+ }
180
+ __device__ __host__ __forceinline__ static bool MustApply (){ return std::numeric_limits<char >::is_signed;}
177
181
};
178
182
179
183
template <>
180
184
struct PostprocessKeyFunctor <char > {
181
- __device__ __host__ __forceinline__ void operator ()(unsigned char &converted_key) {
182
- const unsigned int SIGN_MASK = 1u << ((sizeof (char ) * 8 ) - 1 );
183
- converted_key ^= SIGN_MASK;
185
+ __device__ __host__ __forceinline__ void operator ()(unsigned char &converted_key) {
186
+ // char is unsigned on some platforms, so we have to check
187
+ if (std::numeric_limits<char >::is_signed)
188
+ {
189
+ const unsigned int SIGN_MASK = 1u << ((sizeof (char ) * 8 ) - 1 );
190
+ converted_key ^= SIGN_MASK;
184
191
}
185
- __device__ __host__ __forceinline__ static bool MustApply (){ return true ;}
192
+ }
193
+ __device__ __host__ __forceinline__ static bool MustApply (){ return std::numeric_limits<char >::is_signed;}
186
194
};
187
195
188
196
0 commit comments