配色: 字号:
cl_platform
2012-08-12 | 阅:  转:  |  分享 
  
/

Copyright(c)2008-2009TheKhronosGroupInc.



Permissionisherebygranted,freeofcharge,toanypersonobtaininga

copyofthissoftwareand/orassociateddocumentationfiles(the

"Materials"),todealintheMaterialswithoutrestriction,including

withoutlimitationtherightstouse,copy,modify,merge,publish,

distribute,sublicense,and/orsellcopiesoftheMaterials,andto

permitpersonstowhomtheMaterialsarefurnishedtodoso,subjectto

thefollowingconditions:



Theabovecopyrightnoticeandthispermissionnoticeshallbeincluded

inallcopiesorsubstantialportionsoftheMaterials.



THEMATERIALSAREPROVIDED"ASIS",WITHOUTWARRANTYOFANYKIND,

EXPRESSORIMPLIED,INCLUDINGBUTNOTLIMITEDTOTHEWARRANTIESOF

MERCHANTABILITY,FITNESSFORAPARTICULARPURPOSEANDNONINFRINGEMENT.

INNOEVENTSHALLTHEAUTHORSORCOPYRIGHTHOLDERSBELIABLEFORANY

CLAIM,DAMAGESOROTHERLIABILITY,WHETHERINANACTIONOFCONTRACT,

TORTOROTHERWISE,ARISINGFROM,OUTOFORINCONNECTIONWITHTHE

MATERIALSORTHEUSEOROTHERDEALINGSINTHEMATERIALS.

/



/$Revision:9283$on$Date:2009-10-1410:18:57-0700(Wed,14Oct2009)$/



#ifndef__CL_PLATFORM_H

#define__CL_PLATFORM_H



#ifdef__APPLE__

/Contains#definesforAVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATERbelow/

#include

#endif



#ifdef__cplusplus

extern"C"{

#endif



#defineCL_API_ENTRY

#defineCL_API_CALL

#ifdef__APPLE__

#defineCL_API_SUFFIX__VERSION_1_0AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER

#defineCL_EXTENSION_WEAK_LINK__attribute__((weak_import))

#else

#defineCL_API_SUFFIX__VERSION_1_0

#defineCL_EXTENSION_WEAK_LINK

#endif



#if(defined(WIN32)&&(_MSC_VER))



/scalartypes/

typedefsigned__int8cl_char;

typedefunsigned__int8cl_uchar;

typedefsigned__int16cl_short;

typedefunsigned__int16cl_ushort;

typedefsigned__int32cl_int;

typedefunsigned__int32cl_uint;

typedefsigned__int64cl_long;

typedefunsigned__int64cl_ulong;



typedefunsigned__int16cl_half;

typedeffloatcl_float;

typedefdoublecl_double;





/

Vectortypes



Note:OpenCLrequiresthatalltypesbenaturallyaligned.

Thismeansthatvectortypesmustbenaturallyaligned.

Forexample,avectoroffourfloatsmustbealignedto

a16byteboundary(calculatedas4thenatural4-byte

alignmentofthefloat).Thealignmentqualifiershere

willonlyfunctionproperlyifyourcompilersupportsthem

andifyoudon''tactivelyworktodefeatthem.Forexample,

inorderforacl_float4tobe16bytealignedinastruct,

thestartofthestructmustitselfbe16-bytealigned.



Maintainingproperalignmentistheuser''sresponsibility.

/

typedefsigned__int8cl_char2[2];

typedefsigned__int8cl_char4[4];

typedefsigned__int8cl_char8[8];

typedefsigned__int8cl_char16[16];

typedefunsigned__int8cl_uchar2[2];

typedefunsigned__int8cl_uchar4[4];

typedefunsigned__int8cl_uchar8[8];

typedefunsigned__int8cl_uchar16[16];



typedefsigned__int16cl_short2[2];

typedefsigned__int16cl_short4[4];

typedefsigned__int16cl_short8[8];

typedefsigned__int16cl_short16[16];

typedefunsigned__int16cl_ushort2[2];

typedefunsigned__int16cl_ushort4[4];

typedefunsigned__int16cl_ushort8[8];

typedefunsigned__int16cl_ushort16[16];



typedefsigned__int32cl_int2[2];

typedefsigned__int32cl_int4[4];

typedefsigned__int32cl_int8[8];

typedefsigned__int32cl_int16[16];

typedefunsigned__int32cl_uint2[2];

typedefunsigned__int32cl_uint4[4];

typedefunsigned__int32cl_uint8[8];

typedefunsigned__int32cl_uint16[16];



typedefsigned__int64cl_long2[2];

typedefsigned__int64cl_long4[4];

typedefsigned__int64cl_long8[8];

typedefsigned__int64cl_long16[16];

typedefunsigned__int64cl_ulong2[2];

typedefunsigned__int64cl_ulong4[4];

typedefunsigned__int64cl_ulong8[8];

typedefunsigned__int64cl_ulong16[16];



typedeffloatcl_float2[2];

typedeffloatcl_float4[4];

typedeffloatcl_float8[8];

typedeffloatcl_float16[16];



typedefdoublecl_double2[2];

typedefdoublecl_double4[4];

typedefdoublecl_double8[8];

typedefdoublecl_double16[16];

/Therearenovectortypesforhalf/



#defineCL_CHAR_BIT8

#defineCL_SCHAR_MAX127

#defineCL_SCHAR_MIN(-127-1)

#defineCL_CHAR_MAXCL_SCHAR_MAX

#defineCL_CHAR_MINCL_SCHAR_MIN

#defineCL_UCHAR_MAX255

#defineCL_SHRT_MAX32767

#defineCL_SHRT_MIN(-32767-1)

#defineCL_USHRT_MAX65535

#defineCL_INT_MAX2147483647

#defineCL_INT_MIN(-2147483647-1)

#defineCL_UINT_MAX0xffffffffU

#defineCL_LONG_MAX((cl_long)0x7FFFFFFFFFFFFFFFLL)

#defineCL_LONG_MIN((cl_long)-0x7FFFFFFFFFFFFFFFLL-1LL)

#defineCL_ULONG_MAX((cl_ulong)0xFFFFFFFFFFFFFFFFULL)



#defineCL_FLT_DIG6

#defineCL_FLT_MANT_DIG24

#defineCL_FLT_MAX_10_EXP+38

#defineCL_FLT_MAX_EXP+128

#defineCL_FLT_MIN_10_EXP-37

#defineCL_FLT_MIN_EXP-125

#defineCL_FLT_RADIX2

#defineCL_FLT_MAX340282346638528859811704183484516925440.0f

#defineCL_FLT_MIN1.175494350822287507969e-38f

#defineCL_FLT_EPSILON0x1.0p-23f



#defineCL_DBL_DIG15

#defineCL_DBL_MANT_DIG53

#defineCL_DBL_MAX_10_EXP+308

#defineCL_DBL_MAX_EXP+1024

#defineCL_DBL_MIN_10_EXP-307

#defineCL_DBL_MIN_EXP-1021

#defineCL_DBL_RADIX2

#defineCL_DBL_MAX179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.0

#defineCL_DBL_MIN2.225073858507201383090e-308

#defineCL_DBL_EPSILON2.220446049250313080847e-16





#else



#include



/scalartypes/

typedefint8_tcl_char;

typedefuint8_tcl_uchar;

typedefint16_tcl_short__attribute__((aligned(2)));

typedefuint16_tcl_ushort__attribute__((aligned(2)));

typedefint32_tcl_int__attribute__((aligned(4)));

typedefuint32_tcl_uint__attribute__((aligned(4)));

typedefint64_tcl_long__attribute__((aligned(8)));

typedefuint64_tcl_ulong__attribute__((aligned(8)));



typedefuint16_tcl_half__attribute__((aligned(2)));

typedeffloatcl_float__attribute__((aligned(4)));

typedefdoublecl_double__attribute__((aligned(8)));



/

Vectortypes



Note:OpenCLrequiresthatalltypesbenaturallyaligned.

Thismeansthatvectortypesmustbenaturallyaligned.

Forexample,avectoroffourfloatsmustbealignedto

a16byteboundary(calculatedas4thenatural4-byte

alignmentofthefloat).Thealignmentqualifiershere

willonlyfunctionproperlyifyourcompilersupportsthem

andifyoudon''tactivelyworktodefeatthem.Forexample,

inorderforacl_float4tobe16bytealignedinastruct,

thestartofthestructmustitselfbe16-bytealigned.



Maintainingproperalignmentistheuser''sresponsibility.

/

typedefint8_tcl_char2[2]__attribute__((aligned(2)));

typedefint8_tcl_char4[4]__attribute__((aligned(4)));

typedefint8_tcl_char8[8]__attribute__((aligned(8)));

typedefint8_tcl_char16[16]__attribute__((aligned(16)));

typedefuint8_tcl_uchar2[2]__attribute__((aligned(2)));

typedefuint8_tcl_uchar4[4]__attribute__((aligned(4)));

typedefuint8_tcl_uchar8[8]__attribute__((aligned(8)));

typedefuint8_tcl_uchar16[16]__attribute__((aligned(16)));



typedefint16_tcl_short2[2]__attribute__((aligned(4)));

typedefint16_tcl_short4[4]__attribute__((aligned(8)));

typedefint16_tcl_short8[8]__attribute__((aligned(16)));

typedefint16_tcl_short16[16]__attribute__((aligned(32)));

typedefuint16_tcl_ushort2[2]__attribute__((aligned(4)));

typedefuint16_tcl_ushort4[4]__attribute__((aligned(8)));

typedefuint16_tcl_ushort8[8]__attribute__((aligned(16)));

typedefuint16_tcl_ushort16[16]__attribute__((aligned(32)));



typedefint32_tcl_int2[2]__attribute__((aligned(8)));

typedefint32_tcl_int4[4]__attribute__((aligned(16)));

typedefint32_tcl_int8[8]__attribute__((aligned(32)));

typedefint32_tcl_int16[16]__attribute__((aligned(64)));

typedefuint32_tcl_uint2[2]__attribute__((aligned(8)));

typedefuint32_tcl_uint4[4]__attribute__((aligned(16)));

typedefuint32_tcl_uint8[8]__attribute__((aligned(32)));

typedefuint32_tcl_uint16[16]__attribute__((aligned(64)));



typedefint64_tcl_long2[2]__attribute__((aligned(16)));

typedefint64_tcl_long4[4]__attribute__((aligned(32)));

typedefint64_tcl_long8[8]__attribute__((aligned(64)));

typedefint64_tcl_long16[16]__attribute__((aligned(128)));

typedefuint64_tcl_ulong2[2]__attribute__((aligned(16)));

typedefuint64_tcl_ulong4[4]__attribute__((aligned(32)));

typedefuint64_tcl_ulong8[8]__attribute__((aligned(64)));

typedefuint64_tcl_ulong16[16]__attribute__((aligned(128)));



typedeffloatcl_float2[2]__attribute__((aligned(8)));

typedeffloatcl_float4[4]__attribute__((aligned(16)));

typedeffloatcl_float8[8]__attribute__((aligned(32)));

typedeffloatcl_float16[16]__attribute__((aligned(64)));



typedefdoublecl_double2[2]__attribute__((aligned(16)));

typedefdoublecl_double4[4]__attribute__((aligned(32)));

typedefdoublecl_double8[8]__attribute__((aligned(64)));

typedefdoublecl_double16[16]__attribute__((aligned(128)));



/Therearenovectortypesforhalf/



//



//MacronamesandcorrespondingvaluesdefinedbyOpenCL



#defineCL_CHAR_BIT8

#defineCL_SCHAR_MAX127

#defineCL_SCHAR_MIN(-127-1)

#defineCL_CHAR_MAXCL_SCHAR_MAX

#defineCL_CHAR_MINCL_SCHAR_MIN

#defineCL_UCHAR_MAX255

#defineCL_SHRT_MAX32767

#defineCL_SHRT_MIN(-32767-1)

#defineCL_USHRT_MAX65535

#defineCL_INT_MAX2147483647

#defineCL_INT_MIN(-2147483647-1)

#defineCL_UINT_MAX0xffffffffU

#defineCL_LONG_MAX((cl_long)0x7FFFFFFFFFFFFFFFLL)

#defineCL_LONG_MIN((cl_long)-0x7FFFFFFFFFFFFFFFLL-1LL)

#defineCL_ULONG_MAX((cl_ulong)0xFFFFFFFFFFFFFFFFULL)



#defineCL_FLT_DIG6

#defineCL_FLT_MANT_DIG24

#defineCL_FLT_MAX_10_EXP+38

#defineCL_FLT_MAX_EXP+128

#defineCL_FLT_MIN_10_EXP-37

#defineCL_FLT_MIN_EXP-125

#defineCL_FLT_RADIX2

#defineCL_FLT_MAX0x1.fffffep127f

#defineCL_FLT_MIN0x1.0p-126f

#defineCL_FLT_EPSILON0x1.0p-23f



#defineCL_DBL_DIG15

#defineCL_DBL_MANT_DIG53

#defineCL_DBL_MAX_10_EXP+308

#defineCL_DBL_MAX_EXP+1024

#defineCL_DBL_MIN_10_EXP-307

#defineCL_DBL_MIN_EXP-1021

#defineCL_DBL_RADIX2

#defineCL_DBL_MAX0x1.fffffffffffffp1023

#defineCL_DBL_MIN0x1.0p-1022

#defineCL_DBL_EPSILON0x1.0p-52



#endif



#include





#ifdef__cplusplus

}

#endif



#endif//__CL_PLATFORM_H

献花(0)
+1
(本文系yangshiquan...首藏)