<commit_before>#ifndef __EXPR_COMMON__
#define __EXPR_COMMON__


const char* common_ocl_functions = " \
size_t clip_ulong(float x) { \
    return (size_t)round(clamp(x, 0.0f, (float)(ULONG_MAX))); \
} \
    \
ptrdiff_t clip_long(float x) { \
    return (ptrdiff_t)round(clamp(x, (float)(LONG_MIN), (float)(LONG_MAX))); \
} \
 \
float interrogation(float x, float y, float z) { \
	return x > 0 ? y : z; \
} \
 \
float equal(float x, float y) { \
	return fabs(x - y) < 0.000001f ? 1.0f : -1.0f;  \
} \
 \
float notEqual(float x, float y) { \
	return fabs(x - y) >= 0.000001f ? 1.0f : -1.0f;  \
} \
 \
float inferior(float x, float y) { \
	return x <= y ? 1.0f : -1.0f;  \
} \
 \
float inferiorStrict(float x, float y) { \
	return x < y ? 1.0f : -1.0f;  \
} \
 \
float superior(float x, float y) { \
	return x >= y ? 1.0f : -1.0f;  \
} \
 \
float superiorStrict(float x, float y) { \
	return x > y ? 1.0f : -1.0f;  \
} \
 \
float mt_and(float x, float y) { \
	return ((x > 0) && (y > 0)) ? 1.0f : -1.0f;  \
} \
 \
float mt_or(float x, float y) { \
	return ((x > 0) || (y > 0)) ? 1.0f : -1.0f;  \
} \
 \
float mt_andNot(float x, float y) { \
	return ((x > 0) && (y <= 0)) ? 1.0f : -1.0f;  \
} \
 \
float mt_xor(float x, float y) { \
	return (((x > 0) && (y <= 0)) || ((x <= 0) && (y > 0))) ? 1.0f : -1.0f;  \
} \
 \
float andUB(float x, float y) { \
	return (float)(clip_ulong(x) & clip_ulong(y));  \
} \
 \
float orUB(float x, float y) { \
	return (float)(clip_ulong(x) | clip_ulong(y));  \
} \
 \
float xorUB(float x, float y) { \
	return (float)(clip_ulong(x) ^ clip_ulong(y));  \
} \
 \
float negateUB(float x) { \
	return (float)(~clip_ulong(x));  \
} \
 \
float posshiftUB(float x, float y) { \
	return y >= 0 ? (float)(clip_ulong(x) << clip_long(y)) : (float)(clip_ulong(x) >> clip_long(-y));  \
} \
 \
float negshiftUB(float x, float y) { \
	return y >= 0 ? (float)(clip_ulong(x) >> clip_long(y)) : (float)(clip_ulong(x) << clip_long(-y));  \
} \
 \
float andSB(float x, float y) { \
	return (float)(clip_long(x) & clip_long(y));  \
} \
 \
float orSB(float x, float y) { \
	return (float)(clip_long(x) | clip_long(y));  \
} \
 \
float xorSB(float x, float y) { \
	return (float)(clip_long(x) ^ clip_long(y));  \
} \
 \
float negateSB(float x) { \
	return (float)(~clip_long(x));  \
} \
 \
float posshiftSB(float x, float y) { \
	return y >= 0 ? (float)(clip_long(x) << clip_long(y)) : (float)(clip_long(x) >> clip_long(-y));  \
} \
 \
float negshiftSB(float x, float y) { \
	return y >= 0 ? (float)(clip_long(x) >> clip_long(y)) : (float)(clip_long(x) << clip_long(-y));  \
} \
\
";


const char* expr_source = "__kernel void expr(__global uchar *dstp, __global uchar* srcp, int width) {    \
    int offset = get_global_id(0);   \
    float x = srcp[offset];   \
    dstp[offset] = (uchar)clamp((int)round({{expression}}), 0, 255);  \
}";

const char* exprxy_source = "__kernel void expr(__global uchar *dstp, __global uchar* srcp1, __global uchar* srcp2, int width) {    \
    int offset = get_global_id(0);   \
    float x = srcp1[offset];   \
    float y = srcp2[offset];   \
    dstp[offset] = (uchar)clamp((int)round({{expression}}), 0, 255);  \
}";

const char* exprxyz_source = "__kernel void expr(__global uchar *dstp, __global uchar* srcp1, __global uchar* srcp2, __global uchar* srcp3, int width) {    \
    int offset = get_global_id(0);   \
    float x = srcp1[offset];   \
    float y = srcp2[offset];   \
    float z = srcp3[offset];   \
    dstp[offset] = (uchar)clamp((int)round({{expression}}), 0, 255);  \
}";<commit_msg>Use proper int/uint converts in OpenCL code<commit_after>#ifndef __EXPR_COMMON__
#define __EXPR_COMMON__


const char* common_ocl_functions = " \
uint clip_uint(float x) { \
    return convert_uint_sat(round(x)); \
} \
    \
int clip_int(float x) { \
    return convert_int_sat(round(x)); \
} \
 \
float interrogation(float x, float y, float z) { \
	return x > 0 ? y : z; \
} \
 \
float equal(float x, float y) { \
	return fabs(x - y) < 0.000001f ? 1.0f : -1.0f;  \
} \
 \
float notEqual(float x, float y) { \
	return fabs(x - y) >= 0.000001f ? 1.0f : -1.0f;  \
} \
 \
float inferior(float x, float y) { \
	return x <= y ? 1.0f : -1.0f;  \
} \
 \
float inferiorStrict(float x, float y) { \
	return x < y ? 1.0f : -1.0f;  \
} \
 \
float superior(float x, float y) { \
	return x >= y ? 1.0f : -1.0f;  \
} \
 \
float superiorStrict(float x, float y) { \
	return x > y ? 1.0f : -1.0f;  \
} \
 \
float mt_and(float x, float y) { \
	return ((x > 0) && (y > 0)) ? 1.0f : -1.0f;  \
} \
 \
float mt_or(float x, float y) { \
	return ((x > 0) || (y > 0)) ? 1.0f : -1.0f;  \
} \
 \
float mt_andNot(float x, float y) { \
	return ((x > 0) && (y <= 0)) ? 1.0f : -1.0f;  \
} \
 \
float mt_xor(float x, float y) { \
	return (((x > 0) && (y <= 0)) || ((x <= 0) && (y > 0))) ? 1.0f : -1.0f;  \
} \
 \
float andUB(float x, float y) { \
	return (float)(clip_uint(x) & clip_uint(y));  \
} \
 \
float orUB(float x, float y) { \
	return (float)(clip_uint(x) | clip_uint(y));  \
} \
 \
float xorUB(float x, float y) { \
	return (float)(clip_uint(x) ^ clip_uint(y));  \
} \
 \
float negateUB(float x) { \
	return (float)(~clip_uint(x));  \
} \
 \
float posshiftUB(float x, float y) { \
	return y >= 0 ? (float)(clip_uint(x) << clip_int(y)) : (float)(clip_uint(x) >> clip_int(-y));  \
} \
 \
float negshiftUB(float x, float y) { \
	return y >= 0 ? (float)(clip_uint(x) >> clip_int(y)) : (float)(clip_uint(x) << clip_int(-y));  \
} \
 \
float andSB(float x, float y) { \
	return (float)(clip_int(x) & clip_int(y));  \
} \
 \
float orSB(float x, float y) { \
	return (float)(clip_int(x) | clip_int(y));  \
} \
 \
float xorSB(float x, float y) { \
	return (float)(clip_int(x) ^ clip_int(y));  \
} \
 \
float negateSB(float x) { \
	return (float)(~clip_int(x));  \
} \
 \
float posshiftSB(float x, float y) { \
	return y >= 0 ? (float)(clip_int(x) << clip_int(y)) : (float)(clip_int(x) >> clip_int(-y));  \
} \
 \
float negshiftSB(float x, float y) { \
	return y >= 0 ? (float)(clip_int(x) >> clip_int(y)) : (float)(clip_int(x) << clip_int(-y));  \
} \
\
";


const char* expr_source = "__kernel void expr(__global uchar *dstp, __global uchar* srcp, int width) {    \
    int offset = get_global_id(0);   \
    float x = srcp[offset];   \
    dstp[offset] = (uchar)clamp((int)round({{expression}}), 0, 255);  \
}";

const char* exprxy_source = "__kernel void expr(__global uchar *dstp, __global uchar* srcp1, __global uchar* srcp2, int width) {    \
    int offset = get_global_id(0);   \
    float x = srcp1[offset];   \
    float y = srcp2[offset];   \
    dstp[offset] = (uchar)clamp((int)round({{expression}}), 0, 255);  \
}";

const char* exprxyz_source = "__kernel void expr(__global uchar *dstp, __global uchar* srcp1, __global uchar* srcp2, __global uchar* srcp3, int width) {    \
    int offset = get_global_id(0);   \
    float x = srcp1[offset];   \
    float y = srcp2[offset];   \
    float z = srcp3[offset];   \
    dstp[offset] = (uchar)clamp((int)round({{expression}}), 0, 255);  \
}";
{'fraction_non_alphanumeric': 0.20581527936145952, 'fraction_numerical': 0.02708095781071836, 'mean_word_length': 2.803252032520325, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 49, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6909642', 'n_tokens_mistral': 3119, 'n_tokens_neox': 3012, 'n_words': 682}