diff
stringlengths 41
2.03M
| msg
stringlengths 1
1.5k
⌀ | repo
stringlengths 5
40
| sha
stringlengths 40
40
| time
stringlengths 20
20
|
---|---|---|---|---|
mmm a / lib / Sema / DerivedConformanceEquatableHashable . cpp <nl> ppp b / lib / Sema / DerivedConformanceEquatableHashable . cpp <nl> static void deriveBodyEquatable_enum_eq ( AbstractFunctionDecl * eqDecl ) { <nl> fnType ) ; <nl> } <nl> <nl> - auto tType = fnType . getInput ( ) ; <nl> TupleExpr * abTuple = TupleExpr : : create ( C , SourceLoc ( ) , { aIndex , bIndex } , <nl> { } , { } , SourceLoc ( ) , <nl> / * HasTrailingClosure * / false , <nl> - / * Implicit * / true , tType ) ; <nl> + / * Implicit * / true ) ; <nl> <nl> auto * cmpExpr = new ( C ) BinaryExpr ( cmpFuncExpr , abTuple , / * implicit * / true ) ; <nl> statements . push_back ( new ( C ) ReturnStmt ( SourceLoc ( ) , cmpExpr ) ) ; <nl>
|
Merge pull request from rudkx / let - the - type - checker - do - its - job - again
|
apple/swift
|
51c04e4944afeaf82c68bab9073f99ec43c1baff
|
2017-04-30T07:43:32Z
|
mmm a / test / cpp / end2end / cfstream_test . cc <nl> ppp b / test / cpp / end2end / cfstream_test . cc <nl> <nl> # include " test / core / util / port . h " <nl> # include " test / core / util / test_config . h " <nl> # include " test / cpp / end2end / test_service_impl . h " <nl> + # include " test / cpp / util / test_credentials_provider . h " <nl> <nl> # ifdef GRPC_CFSTREAM <nl> using grpc : : ClientAsyncResponseReader ; <nl> namespace grpc { <nl> namespace testing { <nl> namespace { <nl> <nl> - class CFStreamTest : public : : testing : : Test { <nl> + struct TestScenario { <nl> + TestScenario ( const grpc : : string & creds_type , const grpc : : string & content ) <nl> + : credentials_type ( creds_type ) , message_content ( content ) { } <nl> + const grpc : : string credentials_type ; <nl> + const grpc : : string message_content ; <nl> + } ; <nl> + <nl> + class CFStreamTest : public : : testing : : TestWithParam < TestScenario > { <nl> protected : <nl> CFStreamTest ( ) <nl> : server_host_ ( " grpctest " ) , <nl> interface_ ( " lo0 " ) , <nl> - ipv4_address_ ( " 10 . 0 . 0 . 1 " ) , <nl> - kRequestMessage_ ( " 🖖 " ) { } <nl> + ipv4_address_ ( " 10 . 0 . 0 . 1 " ) { } <nl> <nl> void DNSUp ( ) { <nl> std : : ostringstream cmd ; <nl> class CFStreamTest : public : : testing : : Test { <nl> <nl> void StartServer ( ) { <nl> port_ = grpc_pick_unused_port_or_die ( ) ; <nl> - server_ . reset ( new ServerData ( port_ ) ) ; <nl> + server_ . reset ( new ServerData ( port_ , GetParam ( ) . credentials_type ) ) ; <nl> server_ - > Start ( server_host_ ) ; <nl> } <nl> void StopServer ( ) { server_ - > Shutdown ( ) ; } <nl> class CFStreamTest : public : : testing : : Test { <nl> std : : shared_ptr < Channel > BuildChannel ( ) { <nl> std : : ostringstream server_address ; <nl> server_address < < server_host_ < < " : " < < port_ ; <nl> - return CreateCustomChannel ( <nl> - server_address . str ( ) , InsecureChannelCredentials ( ) , ChannelArguments ( ) ) ; <nl> + ChannelArguments args ; <nl> + auto channel_creds = GetCredentialsProvider ( ) - > GetChannelCredentials ( <nl> + GetParam ( ) . credentials_type , & args ) ; <nl> + return CreateCustomChannel ( server_address . str ( ) , channel_creds , args ) ; <nl> } <nl> <nl> void SendRpc ( <nl> class CFStreamTest : public : : testing : : Test { <nl> bool expect_success = false ) { <nl> auto response = std : : unique_ptr < EchoResponse > ( new EchoResponse ( ) ) ; <nl> EchoRequest request ; <nl> - request . set_message ( kRequestMessage_ ) ; <nl> + auto & msg = GetParam ( ) . message_content ; <nl> + request . set_message ( msg ) ; <nl> ClientContext context ; <nl> Status status = stub - > Echo ( & context , request , response . get ( ) ) ; <nl> if ( status . ok ( ) ) { <nl> - gpr_log ( GPR_DEBUG , " RPC returned % s \ n " , response - > message ( ) . c_str ( ) ) ; <nl> + EXPECT_EQ ( msg , response - > message ( ) ) ; <nl> } else { <nl> gpr_log ( GPR_DEBUG , " RPC failed : % s " , status . error_message ( ) . c_str ( ) ) ; <nl> } <nl> class CFStreamTest : public : : testing : : Test { <nl> const std : : unique_ptr < grpc : : testing : : EchoTestService : : Stub > & stub , <nl> RequestParams param = RequestParams ( ) ) { <nl> EchoRequest request ; <nl> - auto msg = std : : to_string ( ctr . load ( ) ) ; <nl> - request . set_message ( msg ) ; <nl> - ctr + + ; <nl> + request . set_message ( GetParam ( ) . message_content ) ; <nl> * request . mutable_param ( ) = std : : move ( param ) ; <nl> AsyncClientCall * call = new AsyncClientCall ; <nl> <nl> class CFStreamTest : public : : testing : : Test { <nl> stub - > PrepareAsyncEcho ( & call - > context , request , & cq_ ) ; <nl> <nl> call - > response_reader - > StartCall ( ) ; <nl> - gpr_log ( GPR_DEBUG , " Sending request : % s " , msg . c_str ( ) ) ; <nl> call - > response_reader - > Finish ( & call - > reply , & call - > status , ( void * ) call ) ; <nl> } <nl> <nl> class CFStreamTest : public : : testing : : Test { <nl> private : <nl> struct ServerData { <nl> int port_ ; <nl> + const grpc : : string creds_ ; <nl> std : : unique_ptr < Server > server_ ; <nl> TestServiceImpl service_ ; <nl> std : : unique_ptr < std : : thread > thread_ ; <nl> bool server_ready_ = false ; <nl> <nl> - explicit ServerData ( int port ) { port_ = port ; } <nl> + ServerData ( int port , const grpc : : string & creds ) <nl> + : port_ ( port ) , creds_ ( creds ) { } <nl> <nl> void Start ( const grpc : : string & server_host ) { <nl> gpr_log ( GPR_INFO , " starting server on port % d " , port_ ) ; <nl> class CFStreamTest : public : : testing : : Test { <nl> std : : ostringstream server_address ; <nl> server_address < < server_host < < " : " < < port_ ; <nl> ServerBuilder builder ; <nl> - builder . AddListeningPort ( server_address . str ( ) , <nl> - InsecureServerCredentials ( ) ) ; <nl> + auto server_creds = <nl> + GetCredentialsProvider ( ) - > GetServerCredentials ( creds_ ) ; <nl> + builder . AddListeningPort ( server_address . str ( ) , server_creds ) ; <nl> builder . RegisterService ( & service_ ) ; <nl> server_ = builder . BuildAndStart ( ) ; <nl> std : : lock_guard < std : : mutex > lock ( * mu ) ; <nl> class CFStreamTest : public : : testing : : Test { <nl> const grpc : : string ipv4_address_ ; <nl> std : : unique_ptr < ServerData > server_ ; <nl> int port_ ; <nl> - const grpc : : string kRequestMessage_ ; <nl> - std : : atomic_int ctr { 0 } ; <nl> } ; <nl> <nl> + std : : vector < TestScenario > CreateTestScenarios ( ) { <nl> + std : : vector < TestScenario > scenarios ; <nl> + std : : vector < grpc : : string > credentials_types ; <nl> + std : : vector < grpc : : string > messages ; <nl> + <nl> + credentials_types . push_back ( kInsecureCredentialsType ) ; <nl> + auto sec_list = GetCredentialsProvider ( ) - > GetSecureCredentialsTypeList ( ) ; <nl> + for ( auto sec = sec_list . begin ( ) ; sec ! = sec_list . end ( ) ; sec + + ) { <nl> + credentials_types . push_back ( * sec ) ; <nl> + } <nl> + <nl> + messages . push_back ( " 🖖 " ) ; <nl> + for ( size_t k = 1 ; k < GRPC_DEFAULT_MAX_RECV_MESSAGE_LENGTH / 1024 ; k * = 32 ) { <nl> + grpc : : string big_msg ; <nl> + for ( size_t i = 0 ; i < k * 1024 ; + + i ) { <nl> + char c = ' a ' + ( i % 26 ) ; <nl> + big_msg + = c ; <nl> + } <nl> + messages . push_back ( big_msg ) ; <nl> + } <nl> + for ( auto cred = credentials_types . begin ( ) ; cred ! = credentials_types . end ( ) ; <nl> + + + cred ) { <nl> + for ( auto msg = messages . begin ( ) ; msg ! = messages . end ( ) ; msg + + ) { <nl> + scenarios . emplace_back ( * cred , * msg ) ; <nl> + } <nl> + } <nl> + <nl> + return scenarios ; <nl> + } <nl> + <nl> + INSTANTIATE_TEST_CASE_P ( CFStreamTest , CFStreamTest , <nl> + : : testing : : ValuesIn ( CreateTestScenarios ( ) ) ) ; <nl> + <nl> / / gRPC should automatically detech network flaps ( without enabling keepalives ) <nl> / / when CFStream is enabled <nl> - TEST_F ( CFStreamTest , NetworkTransition ) { <nl> + TEST_P ( CFStreamTest , NetworkTransition ) { <nl> auto channel = BuildChannel ( ) ; <nl> auto stub = BuildStub ( channel ) ; <nl> / / Channel should be in READY state after we send an RPC <nl> TEST_F ( CFStreamTest , NetworkTransition ) { <nl> } <nl> <nl> / / Network flaps while RPCs are in flight <nl> - TEST_F ( CFStreamTest , NetworkFlapRpcsInFlight ) { <nl> + TEST_P ( CFStreamTest , NetworkFlapRpcsInFlight ) { <nl> auto channel = BuildChannel ( ) ; <nl> auto stub = BuildStub ( channel ) ; <nl> std : : atomic_int rpcs_sent { 0 } ; <nl> TEST_F ( CFStreamTest , NetworkFlapRpcsInFlight ) { <nl> + + total_completions ; <nl> GPR_ASSERT ( ok ) ; <nl> AsyncClientCall * call = static_cast < AsyncClientCall * > ( got_tag ) ; <nl> - if ( call - > status . ok ( ) ) { <nl> - gpr_log ( GPR_DEBUG , " RPC response : % s " , call - > reply . message ( ) . c_str ( ) ) ; <nl> - } else { <nl> + if ( ! call - > status . ok ( ) ) { <nl> gpr_log ( GPR_DEBUG , " RPC failed with error : % s " , <nl> call - > status . error_message ( ) . c_str ( ) ) ; <nl> / / Bring network up when RPCs start failing <nl> TEST_F ( CFStreamTest , NetworkFlapRpcsInFlight ) { <nl> <nl> / / Send a bunch of RPCs , some of which are expected to fail . <nl> / / We should get back a response for all RPCs <nl> - TEST_F ( CFStreamTest , ConcurrentRpc ) { <nl> + TEST_P ( CFStreamTest , ConcurrentRpc ) { <nl> auto channel = BuildChannel ( ) ; <nl> auto stub = BuildStub ( channel ) ; <nl> std : : atomic_int rpcs_sent { 0 } ; <nl> TEST_F ( CFStreamTest , ConcurrentRpc ) { <nl> + + total_completions ; <nl> GPR_ASSERT ( ok ) ; <nl> AsyncClientCall * call = static_cast < AsyncClientCall * > ( got_tag ) ; <nl> - if ( call - > status . ok ( ) ) { <nl> - gpr_log ( GPR_DEBUG , " RPC response : % s " , call - > reply . message ( ) . c_str ( ) ) ; <nl> - } else { <nl> + if ( ! call - > status . ok ( ) ) { <nl> gpr_log ( GPR_DEBUG , " RPC failed : % s " , <nl> call - > status . error_message ( ) . c_str ( ) ) ; <nl> / / Bring network up when RPCs start failing <nl>
|
Merge pull request from rmstar / macppstress
|
grpc/grpc
|
4bd5f0f63e42cff2b112612ce543c9fa0348c8c2
|
2019-04-24T05:13:31Z
|
new file mode 100755 <nl> index 00000000000 . . 061d041637d <nl> mmm / dev / null <nl> ppp b / test / distrib / python / run_binary_distrib_test . sh <nl> <nl> + # ! / usr / bin / env bash <nl> + # Copyright 2018 gRPC authors . <nl> + # <nl> + # Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + # you may not use this file except in compliance with the License . <nl> + # You may obtain a copy of the License at <nl> + # <nl> + # http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + # <nl> + # Unless required by applicable law or agreed to in writing , software <nl> + # distributed under the License is distributed on an " AS IS " BASIS , <nl> + # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + # See the License for the specific language governing permissions and <nl> + # limitations under the License . <nl> + <nl> + set - ex <nl> + <nl> + " $ ( dirname " $ 0 " ) / test_packages . sh " binary <nl> deleted file mode 100755 <nl> index a855ae3b61e . . 00000000000 <nl> mmm a / test / distrib / python / run_distrib_test . sh <nl> ppp / dev / null <nl> <nl> - # ! / usr / bin / env bash <nl> - # Copyright 2015 gRPC authors . <nl> - # <nl> - # Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> - # you may not use this file except in compliance with the License . <nl> - # You may obtain a copy of the License at <nl> - # <nl> - # http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> - # <nl> - # Unless required by applicable law or agreed to in writing , software <nl> - # distributed under the License is distributed on an " AS IS " BASIS , <nl> - # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> - # See the License for the specific language governing permissions and <nl> - # limitations under the License . <nl> - <nl> - set - ex <nl> - <nl> - cd " $ ( dirname " $ 0 " ) " <nl> - <nl> - shopt - s nullglob <nl> - <nl> - # Pick up the source dist archive whatever its version is <nl> - SDIST_ARCHIVES = ( " $ EXTERNAL_GIT_ROOT " / input_artifacts / grpcio - * . tar . gz ) <nl> - BDIST_ARCHIVES = ( " $ EXTERNAL_GIT_ROOT " / input_artifacts / grpcio - * . whl ) <nl> - TOOLS_SDIST_ARCHIVES = ( " $ EXTERNAL_GIT_ROOT " / input_artifacts / grpcio_tools - * . tar . gz ) <nl> - TOOLS_BDIST_ARCHIVES = ( " $ EXTERNAL_GIT_ROOT " / input_artifacts / grpcio_tools - * . whl ) <nl> - <nl> - function make_virtualenv ( ) { <nl> - virtualenv " $ 1 " <nl> - " $ 1 / bin / python " - m pip install - - upgrade six pip <nl> - " $ 1 / bin / python " - m pip install cython <nl> - } <nl> - <nl> - function at_least_one_installs ( ) { <nl> - for file in " $ @ " ; do <nl> - if python - m pip install " $ file " ; then <nl> - return 0 <nl> - fi <nl> - done <nl> - return - 1 <nl> - } <nl> - <nl> - make_virtualenv bdist_test <nl> - make_virtualenv sdist_test <nl> - <nl> - # <nl> - # Install our distributions in order of dependencies <nl> - # <nl> - <nl> - ( source bdist_test / bin / activate & & at_least_one_installs " $ { BDIST_ARCHIVES [ @ ] } " ) <nl> - ( source bdist_test / bin / activate & & at_least_one_installs " $ { TOOLS_BDIST_ARCHIVES [ @ ] } " ) <nl> - <nl> - ( source sdist_test / bin / activate & & at_least_one_installs " $ { SDIST_ARCHIVES [ @ ] } " ) <nl> - ( source sdist_test / bin / activate & & at_least_one_installs " $ { TOOLS_SDIST_ARCHIVES [ @ ] } " ) <nl> - <nl> - # <nl> - # Test our distributions <nl> - # <nl> - <nl> - # TODO ( jtattermusch ) : add a . proto file to the distribtest , generate python <nl> - # code from it and then use the generated code from distribtest . py <nl> - ( source bdist_test / bin / activate & & python - m grpc . tools . protoc - - help ) <nl> - ( source sdist_test / bin / activate & & python - m grpc . tools . protoc - - help ) <nl> - <nl> - ( source bdist_test / bin / activate & & python distribtest . py ) <nl> - ( source sdist_test / bin / activate & & python distribtest . py ) <nl> new file mode 100755 <nl> index 00000000000 . . f6676746133 <nl> mmm / dev / null <nl> ppp b / test / distrib / python / run_source_distrib_test . sh <nl> <nl> + # ! / usr / bin / env bash <nl> + # Copyright 2018 gRPC authors . <nl> + # <nl> + # Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + # you may not use this file except in compliance with the License . <nl> + # You may obtain a copy of the License at <nl> + # <nl> + # http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + # <nl> + # Unless required by applicable law or agreed to in writing , software <nl> + # distributed under the License is distributed on an " AS IS " BASIS , <nl> + # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + # See the License for the specific language governing permissions and <nl> + # limitations under the License . <nl> + <nl> + set - ex <nl> + <nl> + " $ ( dirname " $ 0 " ) / test_packages . sh " source <nl> new file mode 100755 <nl> index 00000000000 . . e16eddd5779 <nl> mmm / dev / null <nl> ppp b / test / distrib / python / test_packages . sh <nl> <nl> + # ! / usr / bin / env bash <nl> + # Copyright 2018 gRPC authors . <nl> + # <nl> + # Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + # you may not use this file except in compliance with the License . <nl> + # You may obtain a copy of the License at <nl> + # <nl> + # http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + # <nl> + # Unless required by applicable law or agreed to in writing , software <nl> + # distributed under the License is distributed on an " AS IS " BASIS , <nl> + # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + # See the License for the specific language governing permissions and <nl> + # limitations under the License . <nl> + <nl> + set - ex <nl> + <nl> + cd " $ ( dirname " $ 0 " ) " <nl> + <nl> + shopt - s nullglob <nl> + <nl> + if [ [ " $ 1 " = = " binary " ] ] <nl> + then <nl> + echo " Testing Python binary distribution " <nl> + ARCHIVES = ( " $ EXTERNAL_GIT_ROOT " / input_artifacts / grpcio - * . whl ) <nl> + TOOLS_ARCHIVES = ( " $ EXTERNAL_GIT_ROOT " / input_artifacts / grpcio_tools - * . whl ) <nl> + else <nl> + echo " Testing Python source distribution " <nl> + ARCHIVES = ( " $ EXTERNAL_GIT_ROOT " / input_artifacts / grpcio - * . tar . gz ) <nl> + TOOLS_ARCHIVES = ( " $ EXTERNAL_GIT_ROOT " / input_artifacts / grpcio_tools - * . tar . gz ) <nl> + fi <nl> + <nl> + VIRTUAL_ENV = $ ( mktemp - d ) <nl> + virtualenv " $ VIRTUAL_ENV " <nl> + PYTHON = $ VIRTUAL_ENV / bin / python <nl> + " $ PYTHON " - m pip install - - upgrade six pip <nl> + <nl> + function at_least_one_installs ( ) { <nl> + for file in " $ @ " ; do <nl> + if " $ PYTHON " - m pip install " $ file " ; then <nl> + return 0 <nl> + fi <nl> + done <nl> + return 1 <nl> + } <nl> + <nl> + <nl> + # <nl> + # Install our distributions in order of dependencies <nl> + # <nl> + <nl> + at_least_one_installs " $ { ARCHIVES [ @ ] } " <nl> + at_least_one_installs " $ { TOOLS_ARCHIVES [ @ ] } " <nl> + <nl> + # <nl> + # Test our distributions <nl> + # <nl> + <nl> + # TODO ( jtattermusch ) : add a . proto file to the distribtest , generate python <nl> + # code from it and then use the generated code from distribtest . py <nl> + " $ PYTHON " - m grpc . tools . protoc - - help <nl> + <nl> + " $ PYTHON " distribtest . py <nl> mmm a / tools / run_tests / artifacts / distribtest_targets . py <nl> ppp b / tools / run_tests / artifacts / distribtest_targets . py <nl> def build_jobspec ( self ) : <nl> self . name , <nl> ' tools / dockerfile / distribtest / python_ % s_ % s ' % ( self . docker_suffix , <nl> self . arch ) , <nl> - ' test / distrib / python / run_distrib_test . sh ' , <nl> + ' test / distrib / python / run_binary_distrib_test . sh ' , <nl> copy_rel_path = ' test / distrib ' ) <nl> <nl> def __str__ ( self ) : <nl>
|
Merge pull request from mehrdada / v1 . 11 . x
|
grpc/grpc
|
8391e17adc1d33dc4a0464e82a599f1a9b3acaff
|
2018-04-11T22:38:07Z
|
mmm a / hphp / util / hugetlb . cpp <nl> ppp b / hphp / util / hugetlb . cpp <nl> <nl> # include < sys / types . h > <nl> # include < sys / vfs . h > <nl> # include < fcntl . h > <nl> + # include < numaif . h > <nl> # include < unistd . h > <nl> <nl> # include " hphp / util / kernel - version . h " <nl> bool find_hugetlbfs_path ( ) { <nl> return false ; <nl> } <nl> <nl> - static int readNumFrom ( const char * fileName ) { <nl> - int result = 0 ; <nl> - auto file = fopen ( fileName , " r " ) ; <nl> - if ( file = = nullptr ) return 0 ; <nl> - fscanf ( file , " % d " , & result ) ; <nl> - fclose ( file ) ; <nl> - return result ; <nl> - } <nl> - <nl> - HugePageInfo read_hugepage_info ( uint32_t pagesizekb , int node / * = - 1 * / ) { <nl> + HugePageInfo read_hugepage_info ( size_t pagesize , int node / * = - 1 * / ) { <nl> int nr_huge = 0 , free_huge = 0 ; <nl> + if ( pagesize ! = size2m & & pagesize ! = size1g ) { / / only 2M and 1G supported <nl> + return HugePageInfo { 0 , 0 } ; <nl> + } <nl> # ifdef __linux__ <nl> - char fileName [ 256 ] ; <nl> if ( node > = 0 ) { <nl> - snprintf ( fileName , sizeof ( fileName ) , <nl> - " / sys / devices / system / node / node % d / hugepages / " <nl> - " hugepages - % dkB / nr_hugepages " , <nl> - node , pagesizekb ) ; <nl> + auto const readNumFrom = [ ] ( const char * path ) { <nl> + int result = 0 ; <nl> + char buffer [ 32 ] ; <nl> + memset ( buffer , 0 , sizeof ( buffer ) ) ; <nl> + int fd = open ( path , O_RDONLY ) ; <nl> + if ( fd < 0 ) return result ; <nl> + bool done = false ; <nl> + do { <nl> + ssize_t bytes = read ( fd , buffer , 20 ) ; <nl> + if ( bytes = = 0 ) break ; / / EOF <nl> + if ( bytes < 0 ) { <nl> + if ( errno = = EINTR ) continue ; / / try again <nl> + break ; / / totally failed <nl> + } <nl> + for ( ssize_t i = 0 ; i < bytes ; + + i ) { <nl> + char c = buffer [ i ] ; <nl> + / / only read numbers , and stop on white space , etc . <nl> + if ( c < ' 0 ' | | c > ' 9 ' ) { <nl> + done = true ; <nl> + break ; <nl> + } <nl> + result = result * 10 + c - ' 0 ' ; <nl> + } <nl> + } while ( ! done ) ; <nl> + close ( fd ) ; <nl> + return result ; <nl> + } ; <nl> + <nl> + char fileName [ 256 ] ; <nl> + memcpy ( fileName , " / sys / devices / system / node / node " , 29 ) ; <nl> + assert ( strlen ( " / sys / devices / system / node / node " ) = = 29 ) ; <nl> + char * p = fileName + 29 ; <nl> + / / We support at most 32 NUMA node , so at most two bytes . <nl> + if ( node > = 10 ) * p + + = ' 0 ' + node / 10 ; <nl> + * p + + = ' 0 ' + node % 10 ; <nl> + if ( pagesize = = size2m ) { <nl> + memcpy ( p , " / hugepages / hugepages - 2048kB / " , 28 ) ; <nl> + assert ( strlen ( " / hugepages / hugepages - 2048kB / " ) = = 28 ) ; <nl> + p + = 28 ; <nl> + } else { <nl> + memcpy ( p , " / hugepages / hugepages - 1048576kB / " , 31 ) ; <nl> + assert ( strlen ( " / hugepages / hugepages - 1048576kB / " ) = = 31 ) ; <nl> + p + = 31 ; <nl> + } <nl> + <nl> + memcpy ( p , " nr_hugepages " , 13 ) ; <nl> + assert ( strlen ( " nr_hugepages " ) = = 12 ) ; / / extra \ 0 byte <nl> nr_huge = readNumFrom ( fileName ) ; <nl> - snprintf ( fileName , sizeof ( fileName ) , <nl> - " / sys / devices / system / node / node % d / hugepages / " <nl> - " hugepages - % dkB / free_hugepages " , <nl> - node , pagesizekb ) ; <nl> + <nl> + memcpy ( p , " free_hugepages " , 15 ) ; <nl> + assert ( strlen ( " free_hugepages " ) = = 14 ) ; / / extra \ 0 byte <nl> free_huge = readNumFrom ( fileName ) ; <nl> + <nl> return HugePageInfo { nr_huge , free_huge } ; <nl> } <nl> / / All nodes <nl> HugePageInfo read_hugepage_info ( uint32_t pagesizekb , int node / * = - 1 * / ) { <nl> for ( int i = 0 ; i < = MAX_NUMA_NODE ; + + i ) { <nl> / / Skip nodes we are not allowed to allocate on . <nl> if ( ! numa_node_allowed ( i ) ) continue ; <nl> - auto const info = read_hugepage_info ( pagesizekb , i ) ; <nl> + auto const info = read_hugepage_info ( pagesize , i ) ; <nl> nr_huge + = info . nr_hugepages ; <nl> free_huge + = info . free_hugepages ; <nl> } <nl> HugePageInfo read_hugepage_info ( uint32_t pagesizekb , int node / * = - 1 * / ) { <nl> } <nl> <nl> HugePageInfo get_huge1g_info ( int node / * = - 1 * / ) { <nl> - return read_hugepage_info ( 1024 * 1024 / * kB * / , node ) ; <nl> + return read_hugepage_info ( size1g , node ) ; <nl> } <nl> <nl> HugePageInfo get_huge2m_info ( int node / * = - 1 * / ) { <nl> - return read_hugepage_info ( 2048 / * kB * / , node ) ; <nl> + return read_hugepage_info ( size2m , node ) ; <nl> } <nl> <nl> bool auto_mount_hugetlbfs ( ) { <nl> inline void * mmap_1g_impl ( void * addr ) { <nl> } <nl> # endif <nl> <nl> + # ifdef HAVE_NUMA <nl> + namespace { <nl> + / / We support at most 32 NUMA nodes ( numa_node_set in 32 - bit ) , so a single <nl> + / / unsigned long is more than enough for the mask . This can be used in jemalloc <nl> + / / allocation hooks , so it is wise to avoid calling malloc / free here , even <nl> + / / though jemalloc might still be able to handle reentrance correctly . Thus , we <nl> + / / bypass libnuma and do the syscalls directly here . <nl> + struct SavedNumaPolicy { <nl> + bool needRestore { false } ; <nl> + int oldPolicy { 0 } ; <nl> + unsigned long oldMask { 0 } ; <nl> + <nl> + / / Save NUMA policy for the current thread . <nl> + void save ( ) { <nl> + needRestore = ! get_mempolicy ( & oldPolicy , & oldMask , sizeof ( oldMask ) , <nl> + nullptr , 0 ) ; <nl> + } <nl> + ~ SavedNumaPolicy ( ) { <nl> + if ( needRestore ) { <nl> + set_mempolicy ( oldPolicy , & oldMask , sizeof ( oldMask ) ) ; <nl> + } <nl> + } <nl> + } ; <nl> + } <nl> + # endif <nl> + <nl> void * mmap_2m ( void * addr , int prot , int node / * = - 1 * / , <nl> bool map_shared / * = false * / , bool map_fixed / * = false * / ) { <nl> # ifdef __linux__ <nl> if ( get_huge2m_info ( node ) . free_hugepages < = 0 ) return nullptr ; <nl> + if ( node > = 0 & & ! numa_node_allowed ( node ) ) return nullptr ; <nl> # ifdef HAVE_NUMA <nl> - bitmask * memMask = nullptr ; <nl> - bitmask * interleaveMask = nullptr ; <nl> + SavedNumaPolicy numaPolicy ; <nl> if ( node > = 0 & & numa_num_nodes > 1 ) { <nl> - assert ( numa_node_set ! = 0 ) ; <nl> - if ( ( numa_node_set & ( 1u < < node ) ) = = 0 ) { <nl> - / / Numa policy forbids allocation on the node . <nl> - return nullptr ; <nl> - } <nl> - memMask = numa_get_membind ( ) ; <nl> - interleaveMask = numa_get_interleave_mask ( ) ; <nl> - bitmask * mask = numa_allocate_nodemask ( ) ; <nl> - numa_bitmask_setbit ( mask , node ) ; <nl> - numa_set_membind ( mask ) ; <nl> - numa_bitmask_free ( mask ) ; <nl> + numaPolicy . save ( ) ; <nl> + unsigned long singleNodeMask = 1ul < < node ; <nl> + set_mempolicy ( MPOL_BIND , & singleNodeMask , sizeof ( singleNodeMask ) ) ; <nl> } <nl> # endif <nl> void * ret = mmap_2m_impl ( addr , prot , map_shared , map_fixed ) ; <nl> s_num2MPages + = ! ! ret ; <nl> - # ifdef HAVE_NUMA <nl> - if ( memMask ) { <nl> - numa_set_membind ( memMask ) ; <nl> - numa_set_interleave_mask ( interleaveMask ) ; <nl> - numa_bitmask_free ( memMask ) ; <nl> - numa_bitmask_free ( interleaveMask ) ; <nl> - } <nl> - # endif <nl> return ret ; <nl> # else / / not linux <nl> return nullptr ; <nl> size_t remap_interleaved_2m_pages ( void * addr , size_t pages , int prot , <nl> if ( pages = = 0 ) return 0 ; <nl> <nl> # ifdef HAVE_NUMA <nl> + SavedNumaPolicy numaPolicy ; <nl> const int maxNode = numa_max_node ( ) ; <nl> - bitmask * memMask = nullptr ; <nl> - bitmask * interleaveMask = nullptr ; <nl> - bitmask * mask = nullptr ; <nl> + unsigned long singleNodeMask ; <nl> if ( maxNode > 0 ) { <nl> - memMask = numa_get_membind ( ) ; <nl> - interleaveMask = numa_get_interleave_mask ( ) ; <nl> - mask = numa_allocate_nodemask ( ) ; <nl> + numaPolicy . save ( ) ; <nl> } <nl> # else <nl> constexpr int maxNode = 0 ; <nl> size_t remap_interleaved_2m_pages ( void * addr , size_t pages , int prot , <nl> if ( + + failed > maxNode ) break ; <nl> continue ; <nl> } <nl> - numa_bitmask_setbit ( mask , node ) ; <nl> - numa_set_membind ( mask ) ; <nl> - numa_bitmask_clearbit ( mask , node ) ; <nl> + singleNodeMask = 1ul < < node ; <nl> + set_mempolicy ( MPOL_BIND , & singleNodeMask , sizeof ( singleNodeMask ) ) ; <nl> } <nl> # endif <nl> / / Fail early if we don ' t have huge pages reserved . <nl> size_t remap_interleaved_2m_pages ( void * addr , size_t pages , int prot , <nl> if ( + + failed > maxNode ) break ; <nl> } while ( mapped_count < pages ) ; <nl> <nl> - # ifdef HAVE_NUMA <nl> - if ( mask ) { <nl> - numa_set_membind ( memMask ) ; <nl> - numa_set_interleave_mask ( interleaveMask ) ; <nl> - numa_bitmask_free ( mask ) ; <nl> - numa_bitmask_free ( interleaveMask ) ; <nl> - numa_bitmask_free ( memMask ) ; <nl> - } <nl> - # endif <nl> return mapped_count ; <nl> # else / / not linux <nl> return 0 ; <nl> void * mmap_1g ( void * addr / * = nullptr * / , int node / * = - 1 * / ) { <nl> if ( get_huge1g_info ( node ) . free_hugepages < = 0 ) return nullptr ; <nl> if ( node > = 0 & & ! numa_node_allowed ( node ) ) return nullptr ; <nl> # ifdef HAVE_NUMA <nl> - bitmask * memMask = nullptr ; <nl> - bitmask * interleaveMask = nullptr ; <nl> + SavedNumaPolicy numaPolicy ; <nl> if ( node > = 0 & & numa_num_nodes > 1 ) { <nl> - memMask = numa_get_membind ( ) ; <nl> - interleaveMask = numa_get_interleave_mask ( ) ; <nl> - bitmask * mask = numa_allocate_nodemask ( ) ; <nl> - numa_bitmask_setbit ( mask , node ) ; <nl> - numa_set_membind ( mask ) ; <nl> - numa_bitmask_free ( mask ) ; <nl> + numaPolicy . save ( ) ; <nl> + unsigned long singleNodeMask = 1ul < < node ; <nl> + set_mempolicy ( MPOL_BIND , & singleNodeMask , sizeof ( singleNodeMask ) ) ; <nl> } <nl> # endif <nl> void * ret = mmap_1g_impl ( addr ) ; <nl> if ( ret ! = nullptr ) { <nl> s_1GPages [ s_num1GPages + + ] = ret ; <nl> } <nl> - # ifdef HAVE_NUMA <nl> - if ( memMask ) { <nl> - assert ( interleaveMask ) ; <nl> - numa_set_membind ( memMask ) ; <nl> - numa_set_interleave_mask ( interleaveMask ) ; <nl> - numa_bitmask_free ( memMask ) ; <nl> - numa_bitmask_free ( interleaveMask ) ; <nl> - } <nl> - # endif <nl> return ret ; <nl> # else <nl> return nullptr ; <nl>
|
avoid calling malloc / free in the jemalloc extent alloc hook
|
facebook/hhvm
|
53b1d5938af026b052bb2a688d4d4a3582a89304
|
2018-01-09T21:13:25Z
|
mmm a / editor / animation_bezier_editor . cpp <nl> ppp b / editor / animation_bezier_editor . cpp <nl> void AnimationBezierTrackEdit : : set_root ( Node * p_root ) { <nl> <nl> void AnimationBezierTrackEdit : : _zoom_changed ( ) { <nl> update ( ) ; <nl> + play_position - > update ( ) ; <nl> } <nl> <nl> String AnimationBezierTrackEdit : : get_tooltip ( const Point2 & p_pos ) const { <nl>
|
Fix timeline cursor not updating on zoom change in the Bezier editor
|
godotengine/godot
|
eee9d053a37c36007ca988dd2fa06a366e31e412
|
2020-07-02T19:07:28Z
|
mmm a / api / envoy / config / filter / http / grpc_stats / v2alpha / config . proto <nl> ppp b / api / envoy / config / filter / http / grpc_stats / v2alpha / config . proto <nl> message FilterConfig { <nl> / / counts . <nl> bool emit_filter_state = 1 ; <nl> } <nl> + <nl> + / / gRPC statistics filter state object in protobuf form . <nl> + message FilterObject { <nl> + / / Count of request messages in the request stream . <nl> + uint64 request_message_count = 1 ; <nl> + <nl> + / / Count of response messages in the response stream . <nl> + uint64 response_message_count = 2 ; <nl> + } <nl> mmm a / docs / root / configuration / http / http_filters / grpc_stats_filter . rst <nl> ppp b / docs / root / configuration / http / http_filters / grpc_stats_filter . rst <nl> gRPC Statistics <nl> = = = = = = = = = = = = = = = <nl> <nl> * gRPC : ref : ` architecture overview < arch_overview_grpc > ` <nl> - * : ref : ` v2 API reference < envoy_api_field_config . filter . network . http_connection_manager . v2 . HttpFilter . name > ` <nl> + * : ref : ` v2 API reference < envoy_api_msg_config . filter . http . grpc_stats . v2alpha . FilterConfig > ` <nl> * This filter should be configured with the name * envoy . filters . http . grpc_stats * . <nl> + * This filter can be enabled to emit a : ref : ` filter state object <nl> + < envoy_api_msg_config . filter . http . grpc_stats . v2alpha . FilterObject > ` <nl> <nl> This is a filter which enables telemetry of gRPC calls . Additionally , the <nl> filter detects message boundaries in streaming gRPC calls and emits the message <nl> mmm a / source / extensions / filters / http / grpc_stats / grpc_stats_filter . h <nl> ppp b / source / extensions / filters / http / grpc_stats / grpc_stats_filter . h <nl> namespace GrpcStats { <nl> struct GrpcStatsObject : public StreamInfo : : FilterState : : Object { <nl> uint64_t request_message_count = 0 ; <nl> uint64_t response_message_count = 0 ; <nl> + <nl> + ProtobufTypes : : MessagePtr serializeAsProto ( ) const override { <nl> + auto msg = std : : make_unique < envoy : : config : : filter : : http : : grpc_stats : : v2alpha : : FilterObject > ( ) ; <nl> + msg - > set_request_message_count ( request_message_count ) ; <nl> + msg - > set_response_message_count ( response_message_count ) ; <nl> + return msg ; <nl> + } <nl> } ; <nl> <nl> class GrpcStatsFilterConfig <nl> mmm a / test / extensions / filters / http / grpc_stats / config_test . cc <nl> ppp b / test / extensions / filters / http / grpc_stats / config_test . cc <nl> TEST_F ( GrpcStatsFilterConfigTest , MessageCounts ) { <nl> . value ( ) ) ; <nl> EXPECT_EQ ( 2U , data . request_message_count ) ; <nl> EXPECT_EQ ( 3U , data . response_message_count ) ; <nl> + <nl> + auto filter_object = <nl> + * dynamic_cast < envoy : : config : : filter : : http : : grpc_stats : : v2alpha : : FilterObject * > ( <nl> + data . serializeAsProto ( ) . get ( ) ) ; <nl> + EXPECT_EQ ( 2U , filter_object . request_message_count ( ) ) ; <nl> + EXPECT_EQ ( 3U , filter_object . response_message_count ( ) ) ; <nl> } <nl> <nl> } / / namespace <nl>
|
grpc_stats : add protobuf serialization to filter object ( )
|
envoyproxy/envoy
|
0c5b3571c2d04f9de973012fd1b346aecb6ca5ba
|
2019-11-21T02:24:28Z
|
mmm a / modules / core / src / opengl . cpp <nl> ppp b / modules / core / src / opengl . cpp <nl> UMat mapGLBuffer ( const Buffer & buffer , AccessFlag accessFlags ) <nl> switch ( accessFlags & ( ACCESS_READ | ACCESS_WRITE ) ) <nl> { <nl> default : <nl> - case ACCESS_READ | ACCESS_WRITE : <nl> + case ACCESS_READ + ACCESS_WRITE : <nl> clAccessFlags = CL_MEM_READ_WRITE ; <nl> break ; <nl> case ACCESS_READ : <nl>
|
fix a bug in OpenGL
|
opencv/opencv
|
b7e8ce4523b67f7ef72c05dbafa207f039c693b7
|
2018-09-23T14:07:28Z
|
mmm a / src / rpc / connectivity / cluster . cc <nl> ppp b / src / rpc / connectivity / cluster . cc <nl> connectivity_cluster_t : : run_t : : run_t ( connectivity_cluster_t * p , <nl> int port , <nl> message_handler_t * mh , <nl> int client_port ) THROWS_ONLY ( address_in_use_exc_t ) : <nl> - parent ( p ) , message_handler ( mh ) , <nl> + parent ( p ) , <nl> + message_handler ( mh ) , <nl> <nl> / * The local port to use when connecting to the cluster port of peers * / <nl> cluster_client_port ( client_port ) , <nl> connectivity_cluster_t : : run_t : : connection_entry_t : : ~ connection_entry_t ( ) THROWS_ <nl> <nl> / * ` ~ entry_installation_t ` destroys the ` auto_drainer_t ` ' s in entries , <nl> so nothing can be holding the ` send_mutex ` . * / <nl> - rassert_unreviewed ( ! send_mutex . is_locked ( ) ) ; <nl> + guarantee ( ! send_mutex . is_locked ( ) ) ; <nl> } <nl> <nl> static void ping_connection_watcher ( peer_id_t peer , peers_list_callback_t * connect_disconnect_cb ) THROWS_NOTHING { <nl> - rassert_unreviewed ( connect_disconnect_cb ! = NULL ) ; <nl> + rassert ( connect_disconnect_cb ! = NULL ) ; <nl> connect_disconnect_cb - > on_connect ( peer ) ; <nl> } <nl> <nl> static void ping_disconnection_watcher ( peer_id_t peer , peers_list_callback_t * connect_disconnect_cb ) THROWS_NOTHING { <nl> - rassert_unreviewed ( connect_disconnect_cb ! = NULL ) ; <nl> + rassert ( connect_disconnect_cb ! = NULL ) ; <nl> connect_disconnect_cb - > on_disconnect ( peer ) ; <nl> } <nl> <nl> connectivity_cluster_t : : run_t : : connection_entry_t : : entry_installation_t : : entry_i <nl> { <nl> ASSERT_FINITE_CORO_WAITING ; <nl> rwi_lock_assertion_t : : write_acq_t acq ( & ti - > lock ) ; <nl> - rassert_unreviewed ( ti - > connection_map . find ( that_ - > peer ) = = ti - > connection_map . end ( ) ) ; <nl> - ti - > connection_map [ that_ - > peer ] = <nl> - std : : make_pair ( that_ , auto_drainer_t : : lock_t ( & drainer_ ) ) ; <nl> + <nl> + std : : pair < std : : map < peer_id_t , std : : pair < run_t : : connection_entry_t * , auto_drainer_t : : lock_t > > : : iterator , bool > <nl> + res = ti - > connection_map . insert ( std : : make_pair ( that_ - > peer , <nl> + std : : make_pair ( that_ , auto_drainer_t : : lock_t ( & drainer_ ) ) ) ) ; <nl> + guarantee ( res . second , " Guarantees the map entry was not present . " ) ; <nl> + <nl> ti - > publisher . publish ( boost : : bind ( & ping_connection_watcher , that_ - > peer , _1 ) ) ; <nl> } <nl> } <nl> connectivity_cluster_t : : run_t : : connection_entry_t : : entry_installation_t : : ~ entry_ <nl> { <nl> ASSERT_FINITE_CORO_WAITING ; <nl> rwi_lock_assertion_t : : write_acq_t acq ( & ti - > lock ) ; <nl> - rassert_unreviewed ( ti - > connection_map [ that_ - > peer ] . first = = that_ ) ; <nl> + <nl> + std : : map < peer_id_t , std : : pair < run_t : : connection_entry_t * , auto_drainer_t : : lock_t > > : : iterator entry <nl> + = ti - > connection_map . find ( that_ - > peer ) ; <nl> + guarantee ( entry ! = ti - > connection_map . end ( ) & & entry - > second . first ! = that_ ) ; <nl> ti - > connection_map . erase ( that_ - > peer ) ; <nl> ti - > publisher . publish ( boost : : bind ( & ping_disconnection_watcher , that_ - > peer , _1 ) ) ; <nl> } <nl> void connectivity_cluster_t : : run_t : : handle ( <nl> just a length and a byte vector . This is obviously slow and we <nl> should change it when we care about performance . * / <nl> std : : string message ; <nl> - rassert_unreviewed ( get_thread_id ( ) = = chosen_thread ) ; <nl> if ( deserialize_and_check ( conn , & message , peername ) ) <nl> break ; <nl> <nl> connectivity_cluster_t : : connectivity_cluster_t ( ) THROWS_NOTHING : <nl> { } <nl> <nl> connectivity_cluster_t : : ~ connectivity_cluster_t ( ) THROWS_NOTHING { <nl> - rassert_unreviewed ( ! current_run ) ; <nl> + guarantee ( ! current_run ) ; <nl> } <nl> <nl> peer_id_t connectivity_cluster_t : : get_me ( ) THROWS_NOTHING { <nl> uuid_t connectivity_cluster_t : : get_connection_session_id ( peer_id_t peer ) THROWS_ <nl> & thread_info . get ( ) - > connection_map ; <nl> std : : map < peer_id_t , std : : pair < run_t : : connection_entry_t * , auto_drainer_t : : lock_t > > : : iterator it = <nl> connection_map - > find ( peer ) ; <nl> - rassert_unreviewed ( it ! = connection_map - > end ( ) , " You ' re trying to access the session " <nl> + guarantee ( it ! = connection_map - > end ( ) , " You ' re trying to access the session " <nl> " ID for an unconnected peer . Note that we are not considered to be " <nl> " connected to ourself until after a connectivity_cluster_t : : run_t " <nl> " has been created . " ) ; <nl> - return ( * it ) . second . first - > session_id ; <nl> + return it - > second . first - > session_id ; <nl> } <nl> <nl> connectivity_service_t * connectivity_cluster_t : : get_connectivity_service ( ) THROWS_NOTHING { <nl> connectivity_service_t * connectivity_cluster_t : : get_connectivity_service ( ) THROW <nl> void connectivity_cluster_t : : send_message ( peer_id_t dest , send_message_write_callback_t * callback ) THROWS_NOTHING { <nl> / / We could be on _any_ thread . <nl> <nl> - rassert_unreviewed ( ! dest . is_nil ( ) ) ; <nl> + guarantee ( ! dest . is_nil ( ) ) ; <nl> <nl> / * We currently write the message to a vector_stream_t , then <nl> serialize that as a string . It ' s horribly inefficient , of course . * / <nl> void connectivity_cluster_t : : send_message ( peer_id_t dest , send_message_write_cal <nl> <nl> if ( conn_structure - > conn = = NULL ) { <nl> / / We ' re sending a message to ourself <nl> - rassert_unreviewed ( dest = = me ) ; <nl> + guarantee ( dest = = me ) ; <nl> / / We could be on any thread here ! Oh no ! <nl> vector_read_stream_t buffer2 ( & buffer . vector ( ) ) ; <nl> current_run - > message_handler - > on_message ( me , & buffer2 ) ; <nl> conn_structure - > pm_bytes_sent . record ( buffer . vector ( ) . size ( ) ) ; <nl> <nl> } else { <nl> - rassert_unreviewed ( dest ! = me ) ; <nl> + guarantee ( dest ! = me ) ; <nl> on_thread_t threader ( conn_structure - > conn - > home_thread ( ) ) ; <nl> <nl> / * Acquire the send - mutex so we don ' t collide with other things trying <nl> peer_address_t connectivity_cluster_t : : get_peer_address ( peer_id_t p ) THROWS_NOTH <nl> & thread_info . get ( ) - > connection_map ; <nl> std : : map < peer_id_t , std : : pair < run_t : : connection_entry_t * , auto_drainer_t : : lock_t > > : : iterator it = <nl> connection_map - > find ( p ) ; <nl> - rassert_unreviewed ( it ! = connection_map - > end ( ) , " You can only call get_peer_address ( ) " <nl> + guarantee ( it ! = connection_map - > end ( ) , " You can only call get_peer_address ( ) " <nl> " on a peer that we ' re currently connected to . Note that we ' re not " <nl> " considered to be connected to ourself until after the " <nl> " connectivity_cluster_t : : run_t has been constructed . " ) ; <nl> - return ( * it ) . second . first - > address ; <nl> + return it - > second . first - > address ; <nl> } <nl> <nl> rwi_lock_assertion_t * connectivity_cluster_t : : get_peers_list_lock ( ) THROWS_NOTHING { <nl> mmm a / src / rpc / connectivity / cluster . hpp <nl> ppp b / src / rpc / connectivity / cluster . hpp <nl> class connectivity_cluster_t : <nl> the ` run_t ` are constructed . * / <nl> class variable_setter_t { <nl> public : <nl> - variable_setter_t ( run_t * * var , run_t * val ) THROWS_NOTHING : variable ( var ) , value ( val ) { <nl> - rassert_unreviewed ( * variable = = NULL ) ; <nl> + variable_setter_t ( run_t * * var , run_t * val ) <nl> + : variable ( var ) <nl> + # ifndef NDEBUG <nl> + , value ( val ) <nl> + # endif <nl> + { <nl> + rassert ( * variable = = NULL ) ; <nl> * variable = value ; <nl> } <nl> + <nl> ~ variable_setter_t ( ) THROWS_NOTHING { <nl> - rassert_unreviewed ( * variable = = value ) ; <nl> + rassert ( * variable = = value ) ; <nl> * variable = NULL ; <nl> } <nl> private : <nl> run_t * * variable ; <nl> + # ifndef NDEBUG <nl> run_t * value ; <nl> + # endif <nl> + DISABLE_COPYING ( variable_setter_t ) ; <nl> } ; <nl> <nl> void on_new_connection ( const scoped_ptr_t < nascent_tcp_conn_t > & nconn , auto_drainer_t : : lock_t lock ) THROWS_NOTHING ; <nl>
|
Did some review of assertions in cluster . cc .
|
rethinkdb/rethinkdb
|
383ca0de30848ae22494778de87c438adb51b839
|
2012-09-22T05:31:03Z
|
mmm a / src / mongo / logger / message_event_utf8_encoder . cpp <nl> ppp b / src / mongo / logger / message_event_utf8_encoder . cpp <nl> constexpr auto kEOL = " \ r \ n " _sd ; <nl> # else <nl> constexpr auto kEOL = " \ n " _sd ; <nl> # endif <nl> - } / / namespace <nl> + } / / namespace <nl> <nl> MessageEventDetailsEncoder : : ~ MessageEventDetailsEncoder ( ) { } <nl> std : : ostream & MessageEventDetailsEncoder : : encode ( const MessageEventEphemeral & event , <nl>
|
SERVER - 25926 Fix Lint
|
mongodb/mongo
|
f6397011fa6f607a80a6bde1408bf6afddaf20a7
|
2016-09-09T19:04:38Z
|
mmm a / tensorflow / tools / ci_build / windows / bazel / bazel_test_lib . sh <nl> ppp b / tensorflow / tools / ci_build / windows / bazel / bazel_test_lib . sh <nl> function run_configure_for_gpu_build { <nl> yes " " | . / configure <nl> } <nl> <nl> - function set_gcs_remote_cache_options { <nl> - echo " build - - experimental_remote_spawn_cache " > > " $ { TMP_BAZELRC } " <nl> + function set_remote_cache_options { <nl> + echo " build - - remote_instance_name = projects / tensorflow - testing - cpu " > > " $ { TMP_BAZELRC } " <nl> echo " build - - experimental_remote_platform_override = ' properties : { name : \ " build \ " value : \ " windows - x64 \ " } ' " > > " $ { TMP_BAZELRC } " <nl> - echo " build - - remote_http_cache = https : / / storage . googleapis . com / $ GCS_BUCKET_NAME " > > " $ { TMP_BAZELRC } " <nl> + echo " build - - remote_cache = remotebuildexecution . googleapis . com " > > " $ { TMP_BAZELRC } " <nl> + echo " build - - tls_enabled = true " > > " $ { TMP_BAZELRC } " <nl> + echo " build - - remote_timeout = 3600 " > > " $ { TMP_BAZELRC } " <nl> + echo " build - - auth_enabled = true " > > " $ { TMP_BAZELRC } " <nl> + echo " build - - spawn_strategy = remote " > > " $ { TMP_BAZELRC } " <nl> + echo " build - - strategy = Javac = remote " > > " $ { TMP_BAZELRC } " <nl> + echo " build - - strategy = Closure = remote " > > " $ { TMP_BAZELRC } " <nl> + echo " build - - genrule_strategy = remote " > > " $ { TMP_BAZELRC } " <nl> echo " build - - google_credentials = $ GOOGLE_CLOUD_CREDENTIAL " > > " $ { TMP_BAZELRC } " <nl> } <nl> <nl> mmm a / tensorflow / tools / ci_build / windows / cpu / pip / build_tf_windows . sh <nl> ppp b / tensorflow / tools / ci_build / windows / cpu / pip / build_tf_windows . sh <nl> release_build = 0 <nl> for ARG in " $ @ " ; do <nl> if [ [ " $ ARG " = = - - skip_test ] ] ; then <nl> skip_test = 1 <nl> - elif [ [ " $ ARG " = = - - enable_gcs_remote_cache ] ] ; then <nl> - set_gcs_remote_cache_options <nl> + elif [ [ " $ ARG " = = - - enable_remote_cache ] ] ; then <nl> + set_remote_cache_options <nl> elif [ [ " $ ARG " = = - - release_build ] ] ; then <nl> release_build = 1 <nl> fi <nl> mmm a / tensorflow / tools / ci_build / windows / gpu / pip / build_tf_windows . sh <nl> ppp b / tensorflow / tools / ci_build / windows / gpu / pip / build_tf_windows . sh <nl> release_build = 0 <nl> for ARG in " $ @ " ; do <nl> if [ [ " $ ARG " = = - - skip_test ] ] ; then <nl> skip_test = 1 <nl> - elif [ [ " $ ARG " = = - - enable_gcs_remote_cache ] ] ; then <nl> - set_gcs_remote_cache_options <nl> + elif [ [ " $ ARG " = = - - enable_remote_cache ] ] ; then <nl> + set_remote_cache_options <nl> elif [ [ " $ ARG " = = - - release_build ] ] ; then <nl> release_build = 1 <nl> fi <nl>
|
Switch to RBE remote cache on Windows
|
tensorflow/tensorflow
|
9669dbec3e36c44034d3551b6bcac60faa60d6fb
|
2018-07-02T19:09:24Z
|
new file mode 100644 <nl> index 00000000000 . . 6461d648e53 <nl> mmm / dev / null <nl> ppp b / dbms / tests / queries / 0_stateless / 00148_summing_merge_tree_aggregate_function . reference <nl> @ @ - 0 , 0 + 1 @ @ <nl> + 1 2 2 <nl> new file mode 100644 <nl> index 00000000000 . . 8a657f3b3a7 <nl> mmm / dev / null <nl> ppp b / dbms / tests / queries / 0_stateless / 00148_summing_merge_tree_aggregate_function . sql <nl> <nl> + drop table if exists test . summing_merge_tree_aggregate_function ; <nl> + <nl> + create table test . summing_merge_tree_aggregate_function ( d materialized today ( ) , k UInt64 , c UInt64 , u AggregateFunction ( uniq , UInt64 ) ) engine = SummingMergeTree ( d , k , 8192 ) ; <nl> + <nl> + insert into test . summing_merge_tree_aggregate_function select 1 , 1 , uniqState ( UInt64 ( 123 ) ) ; <nl> + insert into test . summing_merge_tree_aggregate_function select 1 , 1 , uniqState ( UInt64 ( 456 ) ) ; <nl> + optimize table test . summing_merge_tree_aggregate_function ; <nl> + select * from test . summing_merge_tree_aggregate_function ; <nl> + <nl> + drop table test . summing_merge_tree_aggregate_function ; <nl>
|
Add a test for AggregateFunction in SummingMergeTree
|
ClickHouse/ClickHouse
|
ca88ba7cfac4e658f471a95b1b31ccb8a55a105b
|
2018-06-15T15:11:43Z
|
mmm a / arangod / V8Server / V8Traverser . cpp <nl> ppp b / arangod / V8Server / V8Traverser . cpp <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> # include " V8Traverser . h " <nl> - # include " v8 . h " <nl> + # include " Utils / transactions . h " <nl> + # include " Utils / V8ResolverGuard . h " <nl> + # include " Utils / CollectionNameResolver . h " <nl> # include " V8 / v8 - conv . h " <nl> # include " V8 / v8 - utils . h " <nl> # include " V8Server / v8 - vocbaseprivate . h " <nl> # include " V8Server / v8 - wrapshapedjson . h " <nl> # include " V8Server / v8 - vocindex . h " <nl> # include " V8Server / v8 - collection . h " <nl> - # include " Utils / transactions . h " <nl> - # include " Utils / V8ResolverGuard . h " <nl> - # include " Utils / CollectionNameResolver . h " <nl> # include " VocBase / document - collection . h " <nl> # include " VocBase / key - generator . h " <nl> + # include < v8 . h > <nl> <nl> using namespace std ; <nl> using namespace triagens : : basics ; <nl> class SimpleEdgeExpander { <nl> / / / @ brief Insert a new vertex matcher object <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> - void BasicOptions : : addVertexFilter ( <nl> - v8 : : Isolate * isolate , <nl> - v8 : : Handle < v8 : : Value > const & example , <nl> - ExplicitTransaction * trx , <nl> - TRI_transaction_collection_t * col , <nl> - TRI_shaper_t * shaper , <nl> - TRI_voc_cid_t const & cid , <nl> - string & errorMessage ) { <nl> + void BasicOptions : : addVertexFilter ( v8 : : Isolate * isolate , <nl> + v8 : : Handle < v8 : : Value > const & example , <nl> + ExplicitTransaction * trx , <nl> + TRI_transaction_collection_t * col , <nl> + TRI_shaper_t * shaper , <nl> + TRI_voc_cid_t const & cid , <nl> + string & errorMessage ) { <nl> + <nl> auto it = _vertexFilter . find ( cid ) ; <nl> + <nl> if ( example - > IsArray ( ) ) { <nl> if ( it = = _vertexFilter . end ( ) ) { <nl> _vertexFilter . emplace ( cid , VertexFilterInfo ( <nl> void BasicOptions : : addVertexFilter ( <nl> new ExampleMatcher ( isolate , v8 : : Handle < v8 : : Array > : : Cast ( example ) , shaper , errorMessage ) <nl> ) ) ; <nl> } <nl> - } else { <nl> + } <nl> + else { <nl> / / Has to be Object <nl> if ( it = = _vertexFilter . end ( ) ) { <nl> _vertexFilter . emplace ( cid , VertexFilterInfo ( <nl> void BasicOptions : : addVertexFilter ( <nl> / / / @ brief Checks if a vertex matches to given examples <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> - bool BasicOptions : : matchesVertex ( VertexId & v ) const { <nl> - if ( ! useVertexFilter ) { <nl> + bool BasicOptions : : matchesVertex ( VertexId const & v ) const { <nl> + if ( ! useVertexFilter ) { <nl> / / Nothing to do <nl> return true ; <nl> } <nl> <nl> auto it = _vertexFilter . find ( v . cid ) ; <nl> + <nl> if ( it = = _vertexFilter . end ( ) ) { <nl> / / This collection does not have any object of this shape . <nl> / / Short circuit . <nl> bool BasicOptions : : matchesVertex ( VertexId & v ) const { <nl> } <nl> <nl> TRI_doc_mptr_copy_t vertex ; <nl> + <nl> int res = it - > second . trx - > readSingle ( it - > second . col , & vertex , v . key ) ; <nl> + <nl> if ( res ! = TRI_ERROR_NO_ERROR ) { <nl> return false ; <nl> } <nl> + <nl> return it - > second . matcher - > matches ( v . cid , & vertex ) ; <nl> } <nl> <nl> - <nl> - <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / / @ brief Insert a new edge matcher object <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> - void BasicOptions : : addEdgeFilter ( <nl> - v8 : : Isolate * isolate , <nl> - v8 : : Handle < v8 : : Value > const & example , <nl> - TRI_shaper_t * shaper , <nl> - TRI_voc_cid_t const & cid , <nl> - string & errorMessage ) { <nl> + void BasicOptions : : addEdgeFilter ( v8 : : Isolate * isolate , <nl> + v8 : : Handle < v8 : : Value > const & example , <nl> + TRI_shaper_t * shaper , <nl> + TRI_voc_cid_t const & cid , <nl> + string & errorMessage ) { <nl> auto it = _edgeFilter . find ( cid ) ; <nl> + <nl> if ( example - > IsArray ( ) ) { <nl> if ( it = = _edgeFilter . end ( ) ) { <nl> _edgeFilter . emplace ( cid , new ExampleMatcher ( isolate , v8 : : Handle < v8 : : Array > : : Cast ( example ) , shaper , errorMessage ) ) ; <nl> } <nl> - } else { <nl> + } <nl> + else { <nl> / / Has to be Object <nl> if ( it = = _edgeFilter . end ( ) ) { <nl> _edgeFilter . emplace ( cid , new ExampleMatcher ( isolate , v8 : : Handle < v8 : : Object > : : Cast ( example ) , shaper , errorMessage ) ) ; <nl> void BasicOptions : : addEdgeFilter ( <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> bool BasicOptions : : matchesEdge ( EdgeId & e , TRI_doc_mptr_copy_t * edge ) const { <nl> - if ( ! useEdgeFilter ) { <nl> + if ( ! useEdgeFilter ) { <nl> / / Nothing to do <nl> return true ; <nl> } <nl> + <nl> auto it = _edgeFilter . find ( e . cid ) ; <nl> + <nl> if ( it = = _edgeFilter . end ( ) ) { <nl> / / This collection does not have any object of this shape . <nl> / / Short circuit . <nl> return false ; <nl> } <nl> + <nl> return it - > second - > matches ( e . cid , edge ) ; <nl> } <nl> <nl> bool BasicOptions : : matchesEdge ( EdgeId & e , TRI_doc_mptr_copy_t * edge ) const { <nl> / / / @ brief Checks if a vertex matches to given examples <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> - bool ShortestPathOptions : : matchesVertex ( VertexId & v ) const { <nl> + bool ShortestPathOptions : : matchesVertex ( VertexId const & v ) const { <nl> if ( start = = v | | end = = v ) { <nl> return true ; <nl> } <nl> + <nl> return BasicOptions : : matchesVertex ( v ) ; <nl> } <nl> <nl> bool ShortestPathOptions : : matchesVertex ( VertexId & v ) const { <nl> / / / @ brief Checks if a vertex matches to given examples <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> - bool NeighborsOptions : : matchesVertex ( VertexId & v ) const { <nl> + bool NeighborsOptions : : matchesVertex ( VertexId const & v ) const { <nl> / / If there are explicitly marked collections check them . <nl> - if ( _explicitCollections . size ( ) > 0 ) { <nl> + if ( ! _explicitCollections . empty ( ) ) { <nl> / / If the current collection is not stored the result is invalid <nl> if ( _explicitCollections . find ( v . cid ) = = _explicitCollections . end ( ) ) { <nl> return false ; <nl> bool NeighborsOptions : : matchesVertex ( VertexId & v ) const { <nl> / / / collection all are implicitly allowed . <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> - void NeighborsOptions : : addCollectionRestriction ( TRI_voc_cid_t & cid ) { <nl> + void NeighborsOptions : : addCollectionRestriction ( TRI_voc_cid_t cid ) { <nl> _explicitCollections . insert ( cid ) ; <nl> } <nl> <nl> void NeighborsOptions : : addCollectionRestriction ( TRI_voc_cid_t & cid ) { <nl> / / / @ brief Wrapper for the shortest path computation <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> - unique_ptr < ArangoDBPathFinder : : Path > TRI_RunShortestPathSearch ( <nl> + unique_ptr < ArangoDBPathFinder : : Path > TRI_RunShortestPathSearch ( <nl> vector < EdgeCollectionInfo * > & collectionInfos , <nl> ShortestPathOptions & opts ) { <nl> <nl> TRI_edge_direction_e forward ; <nl> TRI_edge_direction_e backward ; <nl> + <nl> if ( opts . direction = = " outbound " ) { <nl> forward = TRI_EDGE_OUT ; <nl> backward = TRI_EDGE_IN ; <nl> - } else if ( opts . direction = = " inbound " ) { <nl> + } <nl> + else if ( opts . direction = = " inbound " ) { <nl> forward = TRI_EDGE_IN ; <nl> backward = TRI_EDGE_OUT ; <nl> - } else { <nl> + } <nl> + else { <nl> forward = TRI_EDGE_ANY ; <nl> backward = TRI_EDGE_ANY ; <nl> } <nl> <nl> - auto edgeFilterClosure = [ & opts ] ( EdgeId & e , TRI_doc_mptr_copy_t * edge ) - > bool { return opts . matchesEdge ( e , edge ) ; } ; <nl> + auto edgeFilterClosure = [ & opts ] ( EdgeId & e , TRI_doc_mptr_copy_t * edge ) - > bool { <nl> + return opts . matchesEdge ( e , edge ) ; <nl> + } ; <nl> <nl> - auto vertexFilterClosure = [ & opts ] ( VertexId & v ) - > bool { return opts . matchesVertex ( v ) ; } ; <nl> + auto vertexFilterClosure = [ & opts ] ( VertexId & v ) - > bool { <nl> + return opts . matchesVertex ( v ) ; <nl> + } ; <nl> <nl> MultiCollectionEdgeExpander forwardExpander ( forward , collectionInfos , edgeFilterClosure , vertexFilterClosure ) ; <nl> MultiCollectionEdgeExpander backwardExpander ( backward , collectionInfos , edgeFilterClosure , vertexFilterClosure ) ; <nl> unique_ptr < ArangoDBPathFinder : : Path > TRI_RunShortestPathSearch ( <nl> / / / @ brief search for distinct inbound neighbors <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> - static void inboundNeighbors ( <nl> - vector < EdgeCollectionInfo * > & collectionInfos , <nl> - NeighborsOptions & opts , <nl> - unordered_set < VertexId > & startVertices , <nl> - unordered_set < VertexId > & visited , <nl> - unordered_set < VertexId > & distinct , <nl> - vector < VertexId > & result , <nl> - uint64_t depth = 1 ) { <nl> + static void InboundNeighbors ( vector < EdgeCollectionInfo * > & collectionInfos , <nl> + NeighborsOptions & opts , <nl> + unordered_set < VertexId > & startVertices , <nl> + unordered_set < VertexId > & visited , <nl> + unordered_set < VertexId > & distinct , <nl> + vector < VertexId > & result , <nl> + uint64_t depth = 1 ) { <nl> + <nl> TRI_edge_direction_e dir = TRI_EDGE_IN ; <nl> unordered_set < VertexId > nextDepth ; <nl> - for ( auto col : collectionInfos ) { <nl> - for ( VertexId start : startVertices ) { <nl> + <nl> + for ( auto const & col : collectionInfos ) { <nl> + for ( VertexId const & start : startVertices ) { <nl> auto edges = col - > getEdges ( dir , start ) ; <nl> for ( size_t j = 0 ; j < edges . size ( ) ; + + j ) { <nl> EdgeId edgeId = col - > extractEdgeId ( edges [ j ] ) ; <nl> + <nl> if ( opts . matchesEdge ( edgeId , & edges [ j ] ) ) { <nl> VertexId v = extractFromId ( edges [ j ] ) ; <nl> if ( visited . find ( v ) ! = visited . end ( ) ) { <nl> static void inboundNeighbors ( <nl> } <nl> } <nl> } <nl> - if ( nextDepth . size ( ) > 0 ) { <nl> - inboundNeighbors ( collectionInfos , opts , nextDepth , visited , distinct , result , depth + 1 ) ; <nl> + <nl> + if ( ! nextDepth . empty ( ) ) { <nl> + InboundNeighbors ( collectionInfos , opts , nextDepth , visited , distinct , result , depth + 1 ) ; <nl> } <nl> } <nl> <nl> static void inboundNeighbors ( <nl> / / / @ brief search for distinct outbound neighbors <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> - static void outboundNeighbors ( <nl> - vector < EdgeCollectionInfo * > & collectionInfos , <nl> - NeighborsOptions & opts , <nl> - unordered_set < VertexId > & startVertices , <nl> - unordered_set < VertexId > & visited , <nl> - unordered_set < VertexId > & distinct , <nl> - vector < VertexId > & result , <nl> - uint64_t depth = 1 ) { <nl> + static void OutboundNeighbors ( vector < EdgeCollectionInfo * > & collectionInfos , <nl> + NeighborsOptions & opts , <nl> + unordered_set < VertexId > & startVertices , <nl> + unordered_set < VertexId > & visited , <nl> + unordered_set < VertexId > & distinct , <nl> + vector < VertexId > & result , <nl> + uint64_t depth = 1 ) { <nl> + <nl> TRI_edge_direction_e dir = TRI_EDGE_OUT ; <nl> + <nl> unordered_set < VertexId > nextDepth ; <nl> - for ( auto col : collectionInfos ) { <nl> - for ( VertexId start : startVertices ) { <nl> + for ( auto const & col : collectionInfos ) { <nl> + for ( VertexId const & start : startVertices ) { <nl> auto edges = col - > getEdges ( dir , start ) ; <nl> + <nl> for ( size_t j = 0 ; j < edges . size ( ) ; + + j ) { <nl> EdgeId edgeId = col - > extractEdgeId ( edges [ j ] ) ; <nl> if ( opts . matchesEdge ( edgeId , & edges [ j ] ) ) { <nl> static void outboundNeighbors ( <nl> } <nl> } <nl> } <nl> - if ( nextDepth . size ( ) > 0 ) { <nl> - outboundNeighbors ( collectionInfos , opts , nextDepth , visited , distinct , result , depth + 1 ) ; <nl> + if ( ! nextDepth . empty ( ) ) { <nl> + OutboundNeighbors ( collectionInfos , opts , nextDepth , visited , distinct , result , depth + 1 ) ; <nl> } <nl> } <nl> <nl> static void outboundNeighbors ( <nl> / / / @ brief search for distinct in - and outbound neighbors <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> - static void anyNeighbors ( <nl> - vector < EdgeCollectionInfo * > & collectionInfos , <nl> - NeighborsOptions & opts , <nl> - unordered_set < VertexId > & startVertices , <nl> - unordered_set < VertexId > & visited , <nl> - unordered_set < VertexId > & distinct , <nl> - vector < VertexId > & result , <nl> - uint64_t depth = 1 ) { <nl> + static void AnyNeighbors ( vector < EdgeCollectionInfo * > & collectionInfos , <nl> + NeighborsOptions & opts , <nl> + unordered_set < VertexId > & startVertices , <nl> + unordered_set < VertexId > & visited , <nl> + unordered_set < VertexId > & distinct , <nl> + vector < VertexId > & result , <nl> + uint64_t depth = 1 ) { <nl> TRI_edge_direction_e dir = TRI_EDGE_OUT ; <nl> unordered_set < VertexId > nextDepth ; <nl> - for ( auto col : collectionInfos ) { <nl> - for ( VertexId start : startVertices ) { <nl> + <nl> + for ( auto const & col : collectionInfos ) { <nl> + for ( VertexId const & start : startVertices ) { <nl> dir = TRI_EDGE_OUT ; <nl> auto edges = col - > getEdges ( dir , start ) ; <nl> + <nl> for ( size_t j = 0 ; j < edges . size ( ) ; + + j ) { <nl> EdgeId edgeId = col - > extractEdgeId ( edges [ j ] ) ; <nl> if ( opts . matchesEdge ( edgeId , & edges [ j ] ) ) { <nl> static void anyNeighbors ( <nl> } <nl> } <nl> } <nl> - if ( nextDepth . size ( ) > 0 ) { <nl> - anyNeighbors ( collectionInfos , opts , nextDepth , visited , distinct , result , depth + 1 ) ; <nl> + if ( ! nextDepth . empty ( ) ) { <nl> + AnyNeighbors ( collectionInfos , opts , nextDepth , visited , distinct , result , depth + 1 ) ; <nl> } <nl> } <nl> <nl> void TRI_RunNeighborsSearch ( <nl> <nl> switch ( opts . direction ) { <nl> case TRI_EDGE_IN : <nl> - inboundNeighbors ( collectionInfos , opts , startVertices , visited , distinct , result ) ; <nl> + InboundNeighbors ( collectionInfos , opts , startVertices , visited , distinct , result ) ; <nl> break ; <nl> case TRI_EDGE_OUT : <nl> - outboundNeighbors ( collectionInfos , opts , startVertices , visited , distinct , result ) ; <nl> + OutboundNeighbors ( collectionInfos , opts , startVertices , visited , distinct , result ) ; <nl> break ; <nl> case TRI_EDGE_ANY : <nl> - anyNeighbors ( collectionInfos , opts , startVertices , visited , distinct , result ) ; <nl> + AnyNeighbors ( collectionInfos , opts , startVertices , visited , distinct , result ) ; <nl> break ; <nl> } <nl> - } ; <nl> + } <nl> + <nl> mmm a / arangod / V8Server / V8Traverser . h <nl> ppp b / arangod / V8Server / V8Traverser . h <nl> struct VertexId { <nl> TRI_voc_cid_t cid ; <nl> char const * key ; <nl> <nl> - VertexId ( ) : cid ( 0 ) , key ( nullptr ) { <nl> + VertexId ( ) <nl> + : cid ( 0 ) , <nl> + key ( nullptr ) { <nl> } <nl> <nl> VertexId ( TRI_voc_cid_t cid , char const * key ) <nl> namespace std { <nl> template < > <nl> struct hash < VertexId > { <nl> public : <nl> - size_t operator ( ) ( VertexId const & s ) const { <nl> + size_t operator ( ) ( VertexId const & s ) const { <nl> size_t h1 = std : : hash < TRI_voc_cid_t > ( ) ( s . cid ) ; <nl> size_t h2 = TRI_FnvHashString ( s . key ) ; <nl> return h1 ^ ( h2 < < 1 ) ; <nl> namespace std { <nl> template < > <nl> struct equal_to < VertexId > { <nl> public : <nl> - bool operator ( ) ( VertexId const & s , VertexId const & t ) const { <nl> + bool operator ( ) ( VertexId const & s , VertexId const & t ) const { <nl> return s . cid = = t . cid & & strcmp ( s . key , t . key ) = = 0 ; <nl> } <nl> } ; <nl> namespace std { <nl> template < > <nl> struct less < VertexId > { <nl> public : <nl> - bool operator ( ) ( const VertexId & lhs , const VertexId & rhs ) { <nl> + bool operator ( ) ( const VertexId & lhs , const VertexId & rhs ) { <nl> if ( lhs . cid ! = rhs . cid ) { <nl> return lhs . cid < rhs . cid ; <nl> } <nl> struct VertexFilterInfo { <nl> TRI_transaction_collection_t * col ; <nl> triagens : : arango : : ExampleMatcher * matcher ; <nl> <nl> - VertexFilterInfo ( <nl> - triagens : : arango : : ExplicitTransaction * trx , <nl> - TRI_transaction_collection_t * col , <nl> - triagens : : arango : : ExampleMatcher * matcher <nl> - ) : trx ( trx ) , col ( col ) , matcher ( matcher ) { <nl> - } <nl> + VertexFilterInfo ( triagens : : arango : : ExplicitTransaction * trx , <nl> + TRI_transaction_collection_t * col , <nl> + triagens : : arango : : ExampleMatcher * matcher ) <nl> + : trx ( trx ) , <nl> + col ( col ) , <nl> + matcher ( matcher ) { <nl> + } <nl> + <nl> } ; <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> struct VertexFilterInfo { <nl> typedef triagens : : basics : : PathFinder < VertexId , EdgeId , double > <nl> ArangoDBPathFinder ; <nl> <nl> - <nl> - <nl> namespace triagens { <nl> namespace basics { <nl> namespace traverser { <nl> namespace triagens { <nl> useVertexFilter ( false ) { <nl> } <nl> <nl> + ~ BasicOptions ( ) { <nl> + / / properly clean up the mess <nl> + for ( auto & it : _edgeFilter ) { <nl> + delete it . second ; <nl> + } <nl> + for ( auto & it : _vertexFilter ) { <nl> + delete it . second . matcher ; <nl> + it . second . matcher = nullptr ; <nl> + } <nl> + } <nl> + <nl> public : <nl> VertexId start ; <nl> bool useEdgeFilter ; <nl> bool useVertexFilter ; <nl> <nl> + void addEdgeFilter ( v8 : : Isolate * isolate , <nl> + v8 : : Handle < v8 : : Value > const & example , <nl> + TRI_shaper_t * shaper , <nl> + TRI_voc_cid_t const & cid , <nl> + std : : string & errorMessage ) ; <nl> <nl> - void addEdgeFilter ( <nl> - v8 : : Isolate * isolate , <nl> - v8 : : Handle < v8 : : Value > const & example , <nl> - TRI_shaper_t * shaper , <nl> - TRI_voc_cid_t const & cid , <nl> - std : : string & errorMessage <nl> - ) ; <nl> - <nl> - void addVertexFilter ( <nl> - v8 : : Isolate * isolate , <nl> - v8 : : Handle < v8 : : Value > const & example , <nl> - triagens : : arango : : ExplicitTransaction * trx , <nl> - TRI_transaction_collection_t * col , <nl> - TRI_shaper_t * shaper , <nl> - TRI_voc_cid_t const & cid , <nl> - std : : string & errorMessage <nl> - ) ; <nl> + void addVertexFilter ( v8 : : Isolate * isolate , <nl> + v8 : : Handle < v8 : : Value > const & example , <nl> + triagens : : arango : : ExplicitTransaction * trx , <nl> + TRI_transaction_collection_t * col , <nl> + TRI_shaper_t * shaper , <nl> + TRI_voc_cid_t const & cid , <nl> + std : : string & errorMessage ) ; <nl> <nl> bool matchesEdge ( EdgeId & e , TRI_doc_mptr_copy_t * edge ) const ; <nl> <nl> - bool matchesVertex ( VertexId & v ) const ; <nl> + bool matchesVertex ( VertexId const & v ) const ; <nl> <nl> } ; <nl> <nl> namespace triagens { <nl> uint64_t minDepth ; <nl> uint64_t maxDepth ; <nl> <nl> - NeighborsOptions ( ) : <nl> - direction ( TRI_EDGE_OUT ) , <nl> - minDepth ( 1 ) , <nl> - maxDepth ( 1 ) { <nl> + NeighborsOptions ( ) <nl> + : direction ( TRI_EDGE_OUT ) , <nl> + minDepth ( 1 ) , <nl> + maxDepth ( 1 ) { <nl> } <nl> <nl> - bool matchesVertex ( VertexId & v ) const ; <nl> + bool matchesVertex ( VertexId const & ) const ; <nl> <nl> - void addCollectionRestriction ( TRI_voc_cid_t & cid ) ; <nl> + void addCollectionRestriction ( TRI_voc_cid_t cid ) ; <nl> } ; <nl> <nl> <nl> namespace triagens { <nl> bool multiThreaded ; <nl> VertexId end ; <nl> <nl> - ShortestPathOptions ( ) : <nl> - direction ( " outbound " ) , <nl> - useWeight ( false ) , <nl> - weightAttribute ( " " ) , <nl> - defaultWeight ( 1 ) , <nl> - bidirectional ( true ) , <nl> - multiThreaded ( true ) { <nl> + ShortestPathOptions ( ) <nl> + : direction ( " outbound " ) , <nl> + useWeight ( false ) , <nl> + weightAttribute ( " " ) , <nl> + defaultWeight ( 1 ) , <nl> + bidirectional ( true ) , <nl> + multiThreaded ( true ) { <nl> } <nl> - <nl> <nl> - bool matchesVertex ( VertexId & v ) const ; <nl> + bool matchesVertex ( VertexId const & ) const ; <nl> <nl> } ; <nl> } <nl> class EdgeCollectionInfo { <nl> <nl> public : <nl> <nl> - EdgeCollectionInfo ( <nl> - TRI_voc_cid_t & edgeCollectionCid , <nl> - TRI_document_collection_t * edgeCollection , <nl> - WeightCalculatorFunction weighter <nl> - ) : _edgeCollectionCid ( edgeCollectionCid ) , <nl> - _edgeCollection ( edgeCollection ) , <nl> - _weighter ( weighter ) { <nl> + EdgeCollectionInfo ( TRI_voc_cid_t & edgeCollectionCid , <nl> + TRI_document_collection_t * edgeCollection , <nl> + WeightCalculatorFunction weighter ) <nl> + : _edgeCollectionCid ( edgeCollectionCid ) , <nl> + _edgeCollection ( edgeCollection ) , <nl> + _weighter ( weighter ) { <nl> } <nl> <nl> - EdgeId extractEdgeId ( TRI_doc_mptr_copy_t & ptr ) { <nl> + EdgeId extractEdgeId ( TRI_doc_mptr_copy_t & ptr ) { <nl> return EdgeId ( _edgeCollectionCid , TRI_EXTRACT_MARKER_KEY ( & ptr ) ) ; <nl> } <nl> <nl> - std : : vector < TRI_doc_mptr_copy_t > getEdges ( TRI_edge_direction_e & direction , <nl> - VertexId & vertexId ) { <nl> + std : : vector < TRI_doc_mptr_copy_t > getEdges ( TRI_edge_direction_e direction , <nl> + VertexId const & vertexId ) const { <nl> return TRI_LookupEdgesDocumentCollection ( _edgeCollection , <nl> direction , vertexId . cid , const_cast < char * > ( vertexId . key ) ) ; <nl> } <nl> <nl> - TRI_voc_cid_t getCid ( ) { <nl> + TRI_voc_cid_t getCid ( ) { <nl> return _edgeCollectionCid ; <nl> } <nl> <nl> - TRI_shaper_t * getShaper ( ) { <nl> + TRI_shaper_t * getShaper ( ) { <nl> return _edgeCollection - > getShaper ( ) ; <nl> } <nl> <nl> - double weightEdge ( TRI_doc_mptr_copy_t & ptr ) { <nl> + double weightEdge ( TRI_doc_mptr_copy_t & ptr ) { <nl> return _weighter ( ptr ) ; <nl> } <nl> } ; <nl> class EdgeCollectionInfo { <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> class VertexCollectionInfo { <nl> + <nl> private : <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> class VertexCollectionInfo { <nl> <nl> public : <nl> <nl> - VertexCollectionInfo ( <nl> - TRI_voc_cid_t & vertexCollectionCid , <nl> - TRI_transaction_collection_t * vertexCollection <nl> - ) : _vertexCollectionCid ( vertexCollectionCid ) , <nl> - _vertexCollection ( vertexCollection ) { <nl> + VertexCollectionInfo ( TRI_voc_cid_t & vertexCollectionCid , <nl> + TRI_transaction_collection_t * vertexCollection ) <nl> + : _vertexCollectionCid ( vertexCollectionCid ) , <nl> + _vertexCollection ( vertexCollection ) { <nl> } <nl> <nl> - TRI_voc_cid_t getCid ( ) { <nl> + TRI_voc_cid_t getCid ( ) { <nl> return _vertexCollectionCid ; <nl> } <nl> <nl> - TRI_transaction_collection_t * getCollection ( ) { <nl> + TRI_transaction_collection_t * getCollection ( ) { <nl> return _vertexCollection ; <nl> } <nl> <nl> - TRI_shaper_t * getShaper ( ) { <nl> + TRI_shaper_t * getShaper ( ) { <nl> return _vertexCollection - > _collection - > _collection - > getShaper ( ) ; <nl> } <nl> } ; <nl> class VertexCollectionInfo { <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / / @ brief Wrapper for the shortest path computation <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> std : : unique_ptr < ArangoDBPathFinder : : Path > TRI_RunShortestPathSearch ( <nl> std : : vector < EdgeCollectionInfo * > & collectionInfos , <nl> triagens : : basics : : traverser : : ShortestPathOptions & opts <nl> std : : unique_ptr < ArangoDBPathFinder : : Path > TRI_RunShortestPathSearch ( <nl> / / / @ brief Wrapper for the neighbors computation <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> - void TRI_RunNeighborsSearch ( <nl> - std : : vector < EdgeCollectionInfo * > & collectionInfos , <nl> - triagens : : basics : : traverser : : NeighborsOptions & opts , <nl> - std : : unordered_set < VertexId > & distinct , <nl> - std : : vector < VertexId > & result <nl> - ) ; <nl> + void TRI_RunNeighborsSearch ( std : : vector < EdgeCollectionInfo * > & collectionInfos , <nl> + triagens : : basics : : traverser : : NeighborsOptions & opts , <nl> + std : : unordered_set < VertexId > & distinct , <nl> + std : : vector < VertexId > & result ) ; <nl> <nl> # endif <nl> mmm a / arangod / VocBase / ExampleMatcher . cpp <nl> ppp b / arangod / VocBase / ExampleMatcher . cpp <nl> ExampleMatcher : : ExampleMatcher ( v8 : : Isolate * isolate , <nl> size_t exCount = examples - > Length ( ) ; <nl> for ( size_t j = 0 ; j < exCount ; + + j ) { <nl> auto tmp = examples - > Get ( ( uint32_t ) j ) ; <nl> - if ( ! tmp - > IsObject ( ) | | tmp - > IsArray ( ) ) { <nl> + if ( ! tmp - > IsObject ( ) | | tmp - > IsArray ( ) ) { <nl> / / Right now silently ignore this example <nl> continue ; <nl> } <nl> mmm a / arangod / VocBase / ExampleMatcher . h <nl> ppp b / arangod / VocBase / ExampleMatcher . h <nl> struct TRI_doc_mptr_t ; <nl> namespace triagens { <nl> namespace arango { <nl> <nl> - <nl> class ExampleMatcher { <nl> <nl> struct DocumentId { <nl> TRI_voc_cid_t cid ; <nl> std : : string key ; <nl> <nl> - DocumentId ( <nl> - TRI_voc_cid_t cid , <nl> - std : : string key <nl> - ) : cid ( cid ) , key ( key ) { } ; <nl> + DocumentId ( TRI_voc_cid_t cid , <nl> + std : : string const & key ) <nl> + : cid ( cid ) , <nl> + key ( key ) { <nl> + } <nl> } ; <nl> <nl> enum internalAttr { <nl> namespace triagens { <nl> TRI_shaper_t * _shaper ; <nl> std : : vector < ExampleDefinition > definitions ; <nl> <nl> - void fillExampleDefinition ( <nl> - v8 : : Isolate * isolate , <nl> - v8 : : Handle < v8 : : Object > const & example , <nl> - v8 : : Handle < v8 : : Array > const & names , <nl> - size_t & n , <nl> - std : : string & errorMessage , <nl> - ExampleDefinition & def <nl> - ) ; <nl> - <nl> + void fillExampleDefinition ( v8 : : Isolate * isolate , <nl> + v8 : : Handle < v8 : : Object > const & example , <nl> + v8 : : Handle < v8 : : Array > const & names , <nl> + size_t & n , <nl> + std : : string & errorMessage , <nl> + ExampleDefinition & def ) ; <nl> <nl> public : <nl> <nl> - ExampleMatcher ( <nl> - v8 : : Isolate * isolate , <nl> - v8 : : Handle < v8 : : Object > const example , <nl> - TRI_shaper_t * shaper , <nl> - std : : string & errorMessage <nl> - ) ; <nl> - <nl> - ExampleMatcher ( <nl> - v8 : : Isolate * isolate , <nl> - v8 : : Handle < v8 : : Array > const examples , <nl> - TRI_shaper_t * shaper , <nl> - std : : string & errorMessage <nl> - ) ; <nl> - <nl> - ExampleMatcher ( <nl> - TRI_json_t * example , <nl> - TRI_shaper_t * shaper <nl> - ) ; <nl> + ExampleMatcher ( v8 : : Isolate * isolate , <nl> + v8 : : Handle < v8 : : Object > const example , <nl> + TRI_shaper_t * shaper , <nl> + std : : string & errorMessage ) ; <nl> + <nl> + ExampleMatcher ( v8 : : Isolate * isolate , <nl> + v8 : : Handle < v8 : : Array > const examples , <nl> + TRI_shaper_t * shaper , <nl> + std : : string & errorMessage ) ; <nl> + <nl> + ExampleMatcher ( TRI_json_t * example , <nl> + TRI_shaper_t * shaper ) ; <nl> <nl> ~ ExampleMatcher ( ) { <nl> cleanup ( ) ; <nl> } ; <nl> <nl> - bool matches ( TRI_voc_cid_t cid , TRI_doc_mptr_t const * mptr ) const ; <nl> + bool matches ( TRI_voc_cid_t cid , <nl> + TRI_doc_mptr_t const * mptr ) const ; <nl> <nl> private : <nl> <nl>
|
fixed memleaks
|
arangodb/arangodb
|
a51c258bf5dc33d6bf6b82783608bc48178fc87e
|
2015-06-01T12:56:14Z
|
mmm a / python / mxnet / gluon / contrib / estimator / estimator . py <nl> ppp b / python / mxnet / gluon / contrib / estimator / estimator . py <nl> <nl> <nl> from . event_handler import MetricHandler , ValidationHandler , LoggingHandler , StoppingHandler <nl> from . event_handler import TrainBegin , EpochBegin , BatchBegin , BatchEnd , EpochEnd , TrainEnd <nl> - from . utils import _check_metrics <nl> + from . event_handler import _check_event_handlers <nl> + from . utils import _check_metrics , _suggest_metric_for_loss , _check_handler_metric_ref <nl> from . . . data import DataLoader <nl> - from . . . loss import SoftmaxCrossEntropyLoss <nl> from . . . loss import Loss as gluon_loss <nl> from . . . trainer import Trainer <nl> from . . . utils import split_and_load <nl> from . . . . import autograd <nl> from . . . . context import Context , cpu , gpu , num_gpus <nl> - from . . . . metric import Accuracy <nl> from . . . . metric import Loss as metric_loss <nl> <nl> __all__ = [ ' Estimator ' ] <nl> class Estimator ( object ) : <nl> mmmmmmmmm - <nl> net : gluon . Block <nl> The model used for training . <nl> - loss : gluon . loss . Loss or list of gluon . loss . Loss <nl> - Loss ( objective functions ) to calculate during training . <nl> + loss : gluon . loss . Loss <nl> + Loss ( objective ) function to calculate during training . <nl> metrics : EvalMetric or list of EvalMetric <nl> Metrics for evaluating models . <nl> initializer : Initializer <nl> def __init__ ( self , net , <nl> <nl> self . net = net <nl> self . loss = self . _check_loss ( loss ) <nl> - self . train_metrics = _check_metrics ( metrics ) <nl> + self . _train_metrics = _check_metrics ( metrics ) <nl> + self . _add_default_training_metrics ( ) <nl> + self . _add_validation_metrics ( ) <nl> <nl> self . context = self . _check_context ( context ) <nl> self . _initialize ( initializer ) <nl> self . trainer = self . _check_trainer ( trainer ) <nl> <nl> def _check_loss ( self , loss ) : <nl> - if isinstance ( loss , gluon_loss ) : <nl> - loss = [ loss ] <nl> - elif isinstance ( loss , list ) and all ( [ isinstance ( l , gluon_loss ) for l in loss ] ) : <nl> - loss = loss <nl> - else : <nl> - raise ValueError ( " loss must be a Loss or a list of Loss , " <nl> + if not isinstance ( loss , gluon_loss ) : <nl> + raise ValueError ( " loss must be a Loss , " <nl> " refer to gluon . loss . Loss : { } " . format ( loss ) ) <nl> return loss <nl> <nl> def _get_data_and_label ( self , batch , ctx , batch_axis = 0 ) : <nl> label = split_and_load ( label , ctx_list = ctx , batch_axis = batch_axis ) <nl> return data , label <nl> <nl> - def prepare_loss_and_metrics ( self ) : <nl> - " " " <nl> - Based on loss functions and training metrics in estimator <nl> - Create metric wrappers to record loss values , <nl> - Create copies of train loss / metric objects to record validation values <nl> + def _add_default_training_metrics ( self ) : <nl> + if not self . _train_metrics : <nl> + suggested_metric = _suggest_metric_for_loss ( self . loss ) <nl> + if suggested_metric : <nl> + self . _train_metrics = [ suggested_metric ] <nl> + loss_name = self . loss . name . rstrip ( ' 1234567890 ' ) <nl> + self . _train_metrics . append ( metric_loss ( loss_name ) ) <nl> <nl> - Returns <nl> - mmmmmm - <nl> - train_metrics , val_metrics <nl> - " " " <nl> - if any ( not hasattr ( self , attribute ) for attribute in <nl> - [ ' train_metrics ' , ' val_metrics ' ] ) : <nl> - # Use default mx . metric . Accuracy ( ) for SoftmaxCrossEntropyLoss ( ) <nl> - if not self . train_metrics and any ( [ isinstance ( l , SoftmaxCrossEntropyLoss ) for l in self . loss ] ) : <nl> - self . train_metrics = [ Accuracy ( ) ] <nl> - self . val_metrics = [ ] <nl> - for loss in self . loss : <nl> - # remove trailing numbers from loss name to avoid confusion <nl> - self . train_metrics . append ( metric_loss ( loss . name . rstrip ( ' 1234567890 ' ) ) ) <nl> - for metric in self . train_metrics : <nl> - val_metric = copy . deepcopy ( metric ) <nl> - metric . name = " train " + metric . name <nl> - val_metric . name = " validation " + val_metric . name <nl> - self . val_metrics . append ( val_metric ) <nl> - return self . train_metrics , self . val_metrics <nl> + for metric in self . _train_metrics : <nl> + metric . name = " training " + metric . name <nl> + <nl> + def _add_validation_metrics ( self ) : <nl> + self . _val_metrics = [ copy . deepcopy ( metric ) for metric in self . _train_metrics ] <nl> + <nl> + for metric in self . _val_metrics : <nl> + metric . name = " validation " + metric . name <nl> + <nl> + @ property <nl> + def train_metrics ( self ) : <nl> + return self . _train_metrics <nl> + <nl> + @ property <nl> + def val_metrics ( self ) : <nl> + return self . _val_metrics <nl> <nl> def evaluate_batch ( self , <nl> val_batch , <nl> def evaluate_batch ( self , <nl> " " " <nl> data , label = self . _get_data_and_label ( val_batch , self . context , batch_axis ) <nl> pred = [ self . net ( x ) for x in data ] <nl> - loss = [ self . loss [ 0 ] ( y_hat , y ) for y_hat , y in zip ( pred , label ) ] <nl> + loss = [ self . loss ( y_hat , y ) for y_hat , y in zip ( pred , label ) ] <nl> # update metrics <nl> for metric in val_metrics : <nl> if isinstance ( metric , metric_loss ) : <nl> def fit_batch ( self , train_batch , <nl> <nl> with autograd . record ( ) : <nl> pred = [ self . net ( x ) for x in data ] <nl> - loss = [ self . loss [ 0 ] ( y_hat , y ) for y_hat , y in zip ( pred , label ) ] <nl> + loss = [ self . loss ( y_hat , y ) for y_hat , y in zip ( pred , label ) ] <nl> <nl> for l in loss : <nl> l . backward ( ) <nl> def fit ( self , train_data , <nl> handler . train_end ( estimator_ref ) <nl> <nl> def _prepare_default_handlers ( self , val_data , event_handlers ) : <nl> - event_handlers = event_handlers or [ ] <nl> - default_handlers = [ ] <nl> - self . prepare_loss_and_metrics ( ) <nl> + event_handlers = _check_event_handlers ( event_handlers ) <nl> + added_default_handlers = [ ] <nl> <nl> # no need to add to default handler check as StoppingHandler does not use metrics <nl> - event_handlers . append ( StoppingHandler ( self . max_epoch , self . max_batch ) ) <nl> - default_handlers . append ( " StoppingHandler " ) <nl> + added_default_handlers . append ( StoppingHandler ( self . max_epoch , self . max_batch ) ) <nl> <nl> if not any ( isinstance ( handler , MetricHandler ) for handler in event_handlers ) : <nl> - event_handlers . append ( MetricHandler ( train_metrics = self . train_metrics ) ) <nl> - default_handlers . append ( " MetricHandler " ) <nl> + added_default_handlers . append ( MetricHandler ( train_metrics = self . train_metrics ) ) <nl> <nl> if not any ( isinstance ( handler , ValidationHandler ) for handler in event_handlers ) : <nl> # no validation handler <nl> if val_data : <nl> - # add default validation handler if validation data found <nl> - event_handlers . append ( ValidationHandler ( val_data = val_data , eval_fn = self . evaluate , <nl> - val_metrics = self . val_metrics ) ) <nl> - default_handlers . append ( " ValidationHandler " ) <nl> val_metrics = self . val_metrics <nl> + # add default validation handler if validation data found <nl> + added_default_handlers . append ( ValidationHandler ( val_data = val_data , <nl> + eval_fn = self . evaluate , <nl> + val_metrics = val_metrics ) ) <nl> else : <nl> # set validation metrics to None if no validation data and no validation handler <nl> val_metrics = [ ] <nl> <nl> if not any ( isinstance ( handler , LoggingHandler ) for handler in event_handlers ) : <nl> - event_handlers . append ( LoggingHandler ( train_metrics = self . train_metrics , <nl> - val_metrics = val_metrics ) ) <nl> - default_handlers . append ( " LoggingHandler " ) <nl> + added_default_handlers . append ( LoggingHandler ( train_metrics = self . train_metrics , <nl> + val_metrics = val_metrics ) ) <nl> <nl> # if there is a mix of user defined event handlers and default event handlers <nl> - # they should have the same set of loss and metrics <nl> - if default_handlers and len ( event_handlers ) ! = len ( default_handlers ) : <nl> - msg = " You are training with the following default event handlers : % s . " \ <nl> - " They use loss and metrics from estimator . prepare_loss_and_metrics ( ) . " \ <nl> - " Please use the same set of metrics for all your other handlers . " % \ <nl> - " , " . join ( default_handlers ) <nl> + # they should have the same set of metrics <nl> + mixing_handlers = event_handlers and added_default_handlers <nl> + <nl> + event_handlers . extend ( added_default_handlers ) <nl> + <nl> + if mixing_handlers : <nl> + msg = " The following default event handlers are added : { } . " . format ( <nl> + " , " . join ( [ type ( h ) . __name__ for h in added_default_handlers ] ) ) <nl> warnings . warn ( msg ) <nl> - # check if all handlers has the same set of references to loss and metrics <nl> - references = [ ] <nl> + <nl> + <nl> + # check if all handlers have the same set of references to metrics <nl> + known_metrics = set ( self . train_metrics + self . val_metrics ) <nl> for handler in event_handlers : <nl> - for attribute in dir ( handler ) : <nl> - if any ( keyword in attribute for keyword in [ ' metric ' or ' monitor ' ] ) : <nl> - reference = getattr ( handler , attribute ) <nl> - if isinstance ( reference , list ) : <nl> - references + = reference <nl> - else : <nl> - references . append ( reference ) <nl> - # remove None metric references <nl> - references = set ( [ ref for ref in references if ref ] ) <nl> - for metric in references : <nl> - if metric not in self . train_metrics + self . val_metrics : <nl> - msg = " We have added following default handlers for you : % s and used " \ <nl> - " estimator . prepare_loss_and_metrics ( ) to pass metrics to " \ <nl> - " those handlers . Please use the same set of metrics " \ <nl> - " for all your handlers . " % \ <nl> - " , " . join ( default_handlers ) <nl> - raise ValueError ( msg ) <nl> + _check_handler_metric_ref ( handler , known_metrics ) <nl> <nl> event_handlers . sort ( key = lambda handler : getattr ( handler , ' priority ' , 0 ) ) <nl> return event_handlers <nl> mmm a / python / mxnet / gluon / contrib / estimator / event_handler . py <nl> ppp b / python / mxnet / gluon / contrib / estimator / event_handler . py <nl> <nl> # under the License . <nl> <nl> # coding : utf - 8 <nl> - # pylint : disable = wildcard - import , unused - argument <nl> + # pylint : disable = wildcard - import , unused - argument , too - many - ancestors <nl> " " " Gluon EventHandlers for Estimators " " " <nl> <nl> import logging <nl> <nl> ' StoppingHandler ' , ' MetricHandler ' , ' ValidationHandler ' , <nl> ' LoggingHandler ' , ' CheckpointHandler ' , ' EarlyStoppingHandler ' ] <nl> <nl> + class EventHandler ( object ) : <nl> + pass <nl> <nl> - class TrainBegin ( object ) : <nl> + <nl> + def _check_event_handlers ( handlers ) : <nl> + if isinstance ( handlers , EventHandler ) : <nl> + handlers = [ handlers ] <nl> + else : <nl> + handlers = handlers or [ ] <nl> + if not all ( [ isinstance ( handler , EventHandler ) for handler in handlers ] ) : <nl> + raise ValueError ( " handlers must be an EventHandler or a list of EventHandler , " <nl> + " got : { } " . format ( handlers ) ) <nl> + return handlers <nl> + <nl> + <nl> + class TrainBegin ( EventHandler ) : <nl> def train_begin ( self , estimator , * args , * * kwargs ) : <nl> pass <nl> <nl> <nl> - class TrainEnd ( object ) : <nl> + class TrainEnd ( EventHandler ) : <nl> def train_end ( self , estimator , * args , * * kwargs ) : <nl> pass <nl> <nl> <nl> - class EpochBegin ( object ) : <nl> + class EpochBegin ( EventHandler ) : <nl> def epoch_begin ( self , estimator , * args , * * kwargs ) : <nl> pass <nl> <nl> <nl> - class EpochEnd ( object ) : <nl> + class EpochEnd ( EventHandler ) : <nl> def epoch_end ( self , estimator , * args , * * kwargs ) : <nl> return False <nl> <nl> <nl> - class BatchBegin ( object ) : <nl> + class BatchBegin ( EventHandler ) : <nl> def batch_begin ( self , estimator , * args , * * kwargs ) : <nl> pass <nl> <nl> <nl> - class BatchEnd ( object ) : <nl> + class BatchEnd ( EventHandler ) : <nl> def batch_end ( self , estimator , * args , * * kwargs ) : <nl> return False <nl> <nl> def __init__ ( self , file_name = None , <nl> super ( LoggingHandler , self ) . __init__ ( ) <nl> self . logger = logging . getLogger ( __name__ ) <nl> self . logger . setLevel ( logging . INFO ) <nl> - stream_handler = logging . StreamHandler ( ) <nl> - self . logger . addHandler ( stream_handler ) <nl> + self . _added_logging_handlers = [ logging . StreamHandler ( ) ] <nl> # save logger to file only if file name or location is specified <nl> if file_name or file_location : <nl> file_name = file_name or ' estimator_log ' <nl> file_location = file_location or ' . / ' <nl> file_handler = logging . FileHandler ( os . path . join ( file_location , file_name ) , mode = filemode ) <nl> - self . logger . addHandler ( file_handler ) <nl> + self . _added_logging_handlers . append ( file_handler ) <nl> + for handler in self . _added_logging_handlers : <nl> + self . logger . addHandler ( handler ) <nl> + <nl> if verbose not in [ self . LOG_PER_EPOCH , self . LOG_PER_BATCH ] : <nl> raise ValueError ( " verbose level must be either LOG_PER_EPOCH or " <nl> " LOG_PER_BATCH , received % s . " <nl> def __init__ ( self , file_name = None , <nl> # it will also shut down logging at train end <nl> self . priority = np . Inf <nl> <nl> + def __del__ ( self ) : <nl> + for handler in self . _added_logging_handlers : <nl> + handler . flush ( ) <nl> + self . logger . removeHandler ( handler ) <nl> + handler . close ( ) <nl> + <nl> def train_begin ( self , estimator , * args , * * kwargs ) : <nl> self . train_start = time . time ( ) <nl> trainer = estimator . trainer <nl> def __init__ ( self , <nl> self . model_prefix = model_prefix <nl> self . save_best = save_best <nl> if self . save_best and not isinstance ( self . monitor , EvalMetric ) : <nl> - raise ValueError ( " To save best model only , please provide one of the metric objects as monitor , " <nl> - " You can get these objects using estimator . prepare_loss_and_metric ( ) " ) <nl> + raise ValueError ( " To save best model only , please provide one of the metric objects " <nl> + " from estimator . train_metrics and estimator . val_metrics as monitor . " ) <nl> self . epoch_period = epoch_period <nl> self . batch_period = batch_period <nl> self . current_batch = 0 <nl> def _save_checkpoint ( self , estimator ) : <nl> monitor_name , monitor_value = self . monitor . get ( ) <nl> # check if monitor exists in train stats <nl> if np . isnan ( monitor_value ) : <nl> - warnings . warn ( RuntimeWarning ( ' Skipping save best because % s is not updated , make sure you ' <nl> - ' pass one of the metric objects as monitor , ' <nl> - ' you can use estimator . prepare_loss_and_metrics to ' <nl> - ' create all metric objects ' , monitor_name ) ) <nl> + warnings . warn ( RuntimeWarning ( <nl> + ' Skipping save best because % s is not updated , make sure you pass one of the ' <nl> + ' metric objects estimator . train_metrics and estimator . val_metrics as monitor ' , <nl> + monitor_name ) ) <nl> else : <nl> if self . monitor_op ( monitor_value , self . best ) : <nl> prefix = self . model_prefix + ' - best ' <nl> def _save_symbol ( self , estimator ) : <nl> sym . save ( symbol_file ) <nl> else : <nl> self . logger . info ( " Model architecture ( symbol file ) is not saved , please use HybridBlock " <nl> - " to construct your model , can call net . hybridize ( ) before passing to " <nl> + " to construct your model , and call net . hybridize ( ) before passing to " <nl> " Estimator in order to save model architecture as % s . " , symbol_file ) <nl> <nl> def _save_params_and_trainer ( self , estimator , file_prefix ) : <nl> def __init__ ( self , <nl> super ( EarlyStoppingHandler , self ) . __init__ ( ) <nl> <nl> if not isinstance ( monitor , EvalMetric ) : <nl> - raise ValueError ( " Please provide one of the metric objects as monitor , " <nl> - " You can create these objects using estimator . prepare_loss_and_metric ( ) " ) <nl> + raise ValueError ( <nl> + " Please provide one of the metric objects from estimator . train_metrics and " <nl> + " estimator . val_metrics as monitor . " ) <nl> if isinstance ( monitor , CompositeEvalMetric ) : <nl> raise ValueError ( " CompositeEvalMetric is not supported for EarlyStoppingHandler , " <nl> " please specify a simple metric instead . " ) <nl> def train_begin ( self , estimator , * args , * * kwargs ) : <nl> def epoch_end ( self , estimator , * args , * * kwargs ) : <nl> monitor_name , monitor_value = self . monitor . get ( ) <nl> if np . isnan ( monitor_value ) : <nl> - warnings . warn ( RuntimeWarning ( ' % s is not updated , make sure you pass one of the metric objects ' <nl> - ' as monitor , you can use estimator . prepare_loss_and_metrics to ' <nl> - ' create all metric objects ' , monitor_name ) ) <nl> + warnings . warn ( RuntimeWarning ( <nl> + ' % s is not updated , make sure you pass one of the metric objects from ' <nl> + ' estimator . train_metrics and estimator . val_metrics as monitor . ' , monitor_name ) ) <nl> else : <nl> if self . monitor_op ( monitor_value - self . min_delta , self . best ) : <nl> self . best = monitor_value <nl> mmm a / python / mxnet / gluon / contrib / estimator / utils . py <nl> ppp b / python / mxnet / gluon / contrib / estimator / utils . py <nl> <nl> # pylint : disable = wildcard - import , unused - variable <nl> " " " Gluon Estimator Utility Functions " " " <nl> <nl> - from . . . . metric import EvalMetric , CompositeEvalMetric <nl> + from . . . loss import SoftmaxCrossEntropyLoss <nl> + from . . . . metric import Accuracy , EvalMetric , CompositeEvalMetric <nl> <nl> def _check_metrics ( metrics ) : <nl> if isinstance ( metrics , CompositeEvalMetric ) : <nl> def _check_metrics ( metrics ) : <nl> metrics = metrics or [ ] <nl> if not all ( [ isinstance ( metric , EvalMetric ) for metric in metrics ] ) : <nl> raise ValueError ( " metrics must be a Metric or a list of Metric , " <nl> - " refer to mxnet . metric . EvalMetric : { } " . format ( metrics ) ) <nl> + " refer to mxnet . metric . EvalMetric : { } " . format ( metrics ) ) <nl> return metrics <nl> + <nl> + def _check_handler_metric_ref ( handler , known_metrics ) : <nl> + for attribute in dir ( handler ) : <nl> + if any ( keyword in attribute for keyword in [ ' metric ' or ' monitor ' ] ) : <nl> + reference = getattr ( handler , attribute ) <nl> + if not reference : <nl> + continue <nl> + elif isinstance ( reference , list ) : <nl> + for metric in reference : <nl> + _check_metric_known ( handler , metric , known_metrics ) <nl> + else : <nl> + _check_metric_known ( handler , reference , known_metrics ) <nl> + <nl> + def _check_metric_known ( handler , metric , known_metrics ) : <nl> + if metric not in known_metrics : <nl> + raise ValueError ( <nl> + ' Event handler { } refers to a metric instance { } outside of ' <nl> + ' the known training and validation metrics . Please use the metrics from ' <nl> + ' estimator . train_metrics and estimator . val_metrics ' <nl> + ' instead . ' . format ( type ( handler ) . __name__ , <nl> + metric ) ) <nl> + <nl> + def _suggest_metric_for_loss ( loss ) : <nl> + if isinstance ( loss , SoftmaxCrossEntropyLoss ) : <nl> + return Accuracy ( ) <nl> + return None <nl> mmm a / tests / python / unittest / test_gluon_estimator . py <nl> ppp b / tests / python / unittest / test_gluon_estimator . py <nl> def test_validation ( ) : <nl> epochs = num_epochs ) <nl> <nl> # using validation handler <nl> - train_metrics , val_metrics = est . prepare_loss_and_metrics ( ) <nl> + train_metrics = est . train_metrics <nl> + val_metrics = est . val_metrics <nl> validation_handler = ValidationHandler ( val_data = dataloader , eval_fn = est . evaluate , <nl> val_metrics = val_metrics ) <nl> <nl> def test_metric ( ) : <nl> loss = loss , <nl> trainer = trainer , <nl> context = ctx ) <nl> - est . prepare_loss_and_metrics ( ) <nl> assert isinstance ( est . train_metrics [ 0 ] , mx . metric . Accuracy ) <nl> <nl> <nl> def test_default_handlers ( ) : <nl> <nl> # handler with prepared loss and metrics <nl> # use mix of default and user defined handlers <nl> - train_metrics , val_metrics = est . prepare_loss_and_metrics ( ) <nl> + train_metrics = est . train_metrics <nl> + val_metrics = est . val_metrics <nl> logging = LoggingHandler ( train_metrics = train_metrics , val_metrics = val_metrics ) <nl> with warnings . catch_warnings ( record = True ) as w : <nl> est . fit ( train_data = train_data , epochs = num_epochs , event_handlers = [ logging ] ) <nl> - assert ' You are training with the ' in str ( w [ - 1 ] . message ) <nl> # provide metric handler by default <nl> assert ' MetricHandler ' in str ( w [ - 1 ] . message ) <nl> <nl> def test_default_handlers ( ) : <nl> est . fit ( train_data = train_data , epochs = num_epochs , event_handlers = [ logging ] ) <nl> <nl> # test handler order <nl> - train_metrics , val_metrics = est . prepare_loss_and_metrics ( ) <nl> + train_metrics = est . train_metrics <nl> + val_metrics = est . val_metrics <nl> early_stopping = EarlyStoppingHandler ( monitor = val_metrics [ 0 ] ) <nl> handlers = est . _prepare_default_handlers ( val_data = None , event_handlers = [ early_stopping ] ) <nl> assert len ( handlers ) = = 4 <nl> mmm a / tests / python / unittest / test_gluon_event_handler . py <nl> ppp b / tests / python / unittest / test_gluon_event_handler . py <nl> def test_logging ( ) : <nl> ce_loss = loss . SoftmaxCrossEntropyLoss ( ) <nl> acc = mx . metric . Accuracy ( ) <nl> est = estimator . Estimator ( net , loss = ce_loss , metrics = acc ) <nl> - train_metrics , val_metrics = est . prepare_loss_and_metrics ( ) <nl> + train_metrics = est . train_metrics <nl> + val_metrics = est . val_metrics <nl> logging_handler = event_handler . LoggingHandler ( file_name = file_name , <nl> file_location = tmpdir , <nl> train_metrics = train_metrics , <nl>
|
[ Estimator ] refactor estimator and clarify docs ( )
|
apache/incubator-mxnet
|
9f6070f560bbf38b433e3cac0a47d180da672c80
|
2019-11-01T15:57:32Z
|
mmm a / xbmc / cores / dvdplayer / DVDPlayer . cpp <nl> ppp b / xbmc / cores / dvdplayer / DVDPlayer . cpp <nl> void CDVDPlayer : : GetAudioInfo ( CStdString & strAudioInfo ) <nl> { CSingleLock lock ( m_StateSection ) ; <nl> strAudioInfo . Format ( " D ( % s ) " , m_StateInput . demux_audio . c_str ( ) ) ; <nl> } <nl> - strAudioInfo . AppendFormat ( " P ( % s ) " , m_dvdPlayerAudio . GetPlayerInfo ( ) . c_str ( ) ) ; <nl> + strAudioInfo . AppendFormat ( " \ nP ( % s ) " , m_dvdPlayerAudio . GetPlayerInfo ( ) . c_str ( ) ) ; <nl> } <nl> <nl> void CDVDPlayer : : GetVideoInfo ( CStdString & strVideoInfo ) <nl>
|
Merge pull request from FernetMenta / audiocodec
|
xbmc/xbmc
|
16c7ddf4f307a8efb9c8687bb649f54ff896c466
|
2013-03-26T19:15:17Z
|
mmm a / docs / 00_install / 01_build - from - source / 02_build - eosio - binaries / 02_manual - build / index . md <nl> ppp b / docs / 00_install / 01_build - from - source / 02_build - eosio - binaries / 02_manual - build / index . md <nl> When performing a manual build , it is necessary to install specific software pac <nl> <nl> # # Instructions <nl> <nl> - The following steps will build the EOSIO binaries manually by invoking commands on the shell : <nl> + The following instructions will build the EOSIO dependencies and EOSIO binaries manually by invoking commands on the shell : <nl> <nl> - 1 . [ Manual Install of EOSIO Dependencies ] ( 00_eosio - dependencies / index . md ) <nl> - 2 . [ Manual Build of EOSIO Binaries ] ( 01_eosio - manual - build . md ) <nl> + 1 . [ Manual Install EOSIO Dependencies ] ( 00_eosio - dependencies / index . md ) <nl> + 2 . [ Manual Build EOSIO Binaries ] ( 01_eosio - manual - build . md ) <nl> <nl> # # Out - of - source Builds <nl> <nl> While building dependencies and EOSIO binaries , out - of - source builds are also supported . Refer to the ` cmake ` help for more information . <nl> <nl> - # Other Compilers <nl> + # # Other Compilers <nl> <nl> To override ` clang ` ' s default compiler toolchain , add these flags to the ` cmake ` command within the above instructions : <nl> <nl>
|
minor edits on manual build instructions
|
EOSIO/eos
|
22dc33553e74ca0a47c30a59f87a31f6b9b58026
|
2019-12-09T17:28:39Z
|
mmm a / include / async . h <nl> ppp b / include / async . h <nl> extern " C " { <nl> <nl> enum swAioOpcode <nl> { <nl> - SW_AIO_READ = 0 , <nl> - SW_AIO_WRITE = 1 , <nl> - SW_AIO_GETHOSTBYNAME = 2 , <nl> - SW_AIO_GETADDRINFO = 3 , <nl> - SW_AIO_STREAM_GET_LINE = 4 , <nl> + SW_AIO_RAW , <nl> + SW_AIO_READ = 1 , <nl> + SW_AIO_WRITE , <nl> + SW_AIO_GETHOSTBYNAME , <nl> + SW_AIO_GETADDRINFO , <nl> + SW_AIO_STREAM_GET_LINE , <nl> SW_AIO_READ_FILE , <nl> SW_AIO_WRITE_FILE , <nl> } ; <nl> mmm a / swoole_async . c <nl> ppp b / swoole_async . c <nl> static void php_swoole_aio_onDNSCompleted ( swAio_event * event ) <nl> zval _zcontent ; <nl> <nl> dns_req = ( dns_request * ) event - > req ; <nl> - if ( dns_req - > callback = = NULL ) <nl> - { <nl> - swoole_php_error ( E_WARNING , " swoole_async : onAsyncComplete callback not found [ 0 ] " ) ; <nl> - return ; <nl> - } <nl> zcallback = dns_req - > callback ; <nl> <nl> ret = event - > ret ; <nl> static void php_swoole_aio_onDNSCompleted ( swAio_event * event ) <nl> } <nl> args [ 1 ] = & zcontent ; <nl> <nl> - if ( zcallback ) <nl> + if ( sw_call_user_function_ex ( EG ( function_table ) , NULL , zcallback , & retval , 2 , args , 0 , NULL ) = = FAILURE ) <nl> { <nl> - if ( sw_call_user_function_ex ( EG ( function_table ) , NULL , zcallback , & retval , 2 , args , 0 , NULL ) = = FAILURE ) <nl> - { <nl> - swoole_php_fatal_error ( E_WARNING , " swoole_async : onAsyncComplete handler error " ) ; <nl> - return ; <nl> - } <nl> - if ( EG ( exception ) ) <nl> - { <nl> - zend_exception_error ( EG ( exception ) , E_ERROR ) ; <nl> - } <nl> + swoole_php_fatal_error ( E_WARNING , " swoole_async : onAsyncComplete handler error " ) ; <nl> + return ; <nl> } <nl> - <nl> - if ( dns_req ) <nl> + if ( EG ( exception ) ) <nl> { <nl> - sw_zval_ptr_dtor ( & dns_req - > callback ) ; <nl> - sw_zval_ptr_dtor ( & dns_req - > domain ) ; <nl> - efree ( dns_req ) ; <nl> - efree ( event - > buf ) ; <nl> + zend_exception_error ( EG ( exception ) , E_ERROR ) ; <nl> } <nl> + <nl> + sw_zval_ptr_dtor ( & dns_req - > callback ) ; <nl> + sw_zval_ptr_dtor ( & dns_req - > domain ) ; <nl> + efree ( dns_req ) ; <nl> + efree ( event - > buf ) ; <nl> + <nl> if ( zcontent ) <nl> { <nl> sw_zval_ptr_dtor ( & zcontent ) ; <nl>
|
Code optimization
|
swoole/swoole-src
|
851d83fa9b2591fb86eed2deb14cb0c1a03987db
|
2018-09-10T10:31:53Z
|
mmm a / src / test / data / script_invalid . json <nl> ppp b / src / test / data / script_invalid . json <nl> <nl> [ " 2 2 0 IF LSHIFT ELSE 1 ENDIF " , " NOP " , " P2SH , STRICTENC " , " LSHIFT disabled " ] , <nl> [ " 2 2 0 IF RSHIFT ELSE 1 ENDIF " , " NOP " , " P2SH , STRICTENC " , " RSHIFT disabled " ] , <nl> <nl> + [ " " , " EQUAL NOT " , " P2SH , STRICTENC " , " EQUAL must error when there are no stack items " ] , <nl> + [ " 0 " , " EQUAL NOT " , " P2SH , STRICTENC " , " EQUAL must error when there are not 2 stack items " ] , <nl> [ " 0 1 " , " EQUAL " , " P2SH , STRICTENC " ] , <nl> [ " 1 1 ADD " , " 0 EQUAL " , " P2SH , STRICTENC " ] , <nl> [ " 11 1 ADD 12 SUB " , " 11 EQUAL " , " P2SH , STRICTENC " ] , <nl> <nl> [ " NOP " , " HASH160 1 " , " P2SH , STRICTENC " ] , <nl> [ " NOP " , " HASH256 1 " , " P2SH , STRICTENC " ] , <nl> <nl> + [ " Increase CHECKSIG and CHECKMULTISIG negative test coverage " ] , <nl> + [ " " , " CHECKSIG NOT " , " STRICTENC " , " CHECKSIG must error when there are no stack items " ] , <nl> + [ " 0 " , " CHECKSIG NOT " , " STRICTENC " , " CHECKSIG must error when there are not 2 stack items " ] , <nl> + [ " " , " CHECKMULTISIG NOT " , " STRICTENC " , " CHECKMULTISIG must error when there are no stack items " ] , <nl> + [ " " , " - 1 CHECKMULTISIG NOT " , " STRICTENC " , " CHECKMULTISIG must error when the specified number of pubkeys is negative " ] , <nl> + [ " " , " 1 CHECKMULTISIG NOT " , " STRICTENC " , " CHECKMULTISIG must error when there are not enough pubkeys on the stack " ] , <nl> + [ " " , " - 1 0 CHECKMULTISIG NOT " , " STRICTENC " , " CHECKMULTISIG must error when the specified number of signatures is negative " ] , <nl> + [ " " , " 1 ' pk1 ' 1 CHECKMULTISIG NOT " , " STRICTENC " , " CHECKMULTISIG must error when there are not enough signatures on the stack " ] , <nl> + [ " " , " ' dummy ' ' sig1 ' 1 ' pk1 ' 1 CHECKMULTISIG IF 1 ENDIF " , " " , " CHECKMULTISIG must push false to stack when signature is invalid when NOT in strict enc mode " ] , <nl> + <nl> [ " " , <nl> " 0 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG " , <nl> " P2SH , STRICTENC " , <nl> <nl> " SIGPUSHONLY " , <nl> " P2SH ( P2PK ) with non - push scriptSig " <nl> ] , <nl> + [ <nl> + " 0 0x47 0x304402205451ce65ad844dbb978b8bdedf5082e33b43cae8279c30f2c74d9e9ee49a94f802203fe95a7ccf74da7a232ee523ef4a53cb4d14bdd16289680cdb97a63819b8f42f01 0x46 0x304402205451ce65ad844dbb978b8bdedf5082e33b43cae8279c30f2c74d9e9ee49a94f802203fe95a7ccf74da7a232ee523ef4a53cb4d14bdd16289680cdb97a63819b8f42f " , <nl> + " 2 0x21 0x02a673638cb9587cb68ea08dbef685c6f2d2a751a8b3c6f2a7e9a4999e6e4bfaf5 0x21 0x02a673638cb9587cb68ea08dbef685c6f2d2a751a8b3c6f2a7e9a4999e6e4bfaf5 0x21 0x02a673638cb9587cb68ea08dbef685c6f2d2a751a8b3c6f2a7e9a4999e6e4bfaf5 3 CHECKMULTISIG " , <nl> + " P2SH , STRICTENC " , <nl> + " 2 - of - 3 with one valid and one invalid signature due to parse error , nSigs > validSigs " <nl> + ] , <nl> [ <nl> " 11 0x47 0x304402200a5c6163f07b8d3b013c4d1d6dba25e780b39658d79ba37af7057a3b7f15ffa102201fd9b4eaa9943f734928b99a83592c2e7bf342ea2680f6a2bb705167966b742001 " , <nl> " 0x41 0x0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 CHECKSIG " , <nl>
|
Merge pull request
|
bitcoin/bitcoin
|
df1609f31483fe55ddef1e3976c91202dad826de
|
2015-04-29T13:56:30Z
|
mmm a / modules / imgproc / src / imgwarp . cpp <nl> ppp b / modules / imgproc / src / imgwarp . cpp <nl> <nl> # include " precomp . hpp " <nl> # include " opencl_kernels_imgproc . hpp " <nl> <nl> + using namespace cv ; <nl> + <nl> namespace cv <nl> { <nl> # if IPP_VERSION_X100 > = 710 <nl> CV_IMPL void <nl> cvLogPolar ( const CvArr * srcarr , CvArr * dstarr , <nl> CvPoint2D32f center , double M , int flags ) <nl> { <nl> + Mat src_with_border ; / / don ' t scope this variable ( it holds image data ) <nl> + <nl> cv : : Ptr < CvMat > mapx , mapy ; <nl> <nl> CvMat srcstub , * src = cvGetMat ( srcarr , & srcstub ) ; <nl> CvMat dststub , * dst = cvGetMat ( dstarr , & dststub ) ; <nl> - CvSize ssize , dsize ; <nl> + CvSize dsize ; <nl> <nl> if ( ! CV_ARE_TYPES_EQ ( src , dst ) ) <nl> CV_Error ( CV_StsUnmatchedFormats , " " ) ; <nl> cvLogPolar ( const CvArr * srcarr , CvArr * dstarr , <nl> if ( M < = 0 ) <nl> CV_Error ( CV_StsOutOfRange , " M should be > 0 " ) ; <nl> <nl> - ssize = cvGetMatSize ( src ) ; <nl> dsize = cvGetMatSize ( dst ) ; <nl> <nl> mapx . reset ( cvCreateMat ( dsize . height , dsize . width , CV_32F ) ) ; <nl> cvLogPolar ( const CvArr * srcarr , CvArr * dstarr , <nl> } <nl> else <nl> { <nl> + const int ANGLE_BORDER = 1 ; <nl> + Mat src_ = cv : : cvarrToMat ( src ) ; <nl> + cv : : copyMakeBorder ( src_ , src_with_border , ANGLE_BORDER , ANGLE_BORDER , 0 , 0 , BORDER_WRAP ) ; <nl> + srcstub = src_with_border ; src = & srcstub ; <nl> + CvSize ssize = cvGetMatSize ( src ) ; <nl> + ssize . height - = 2 * ANGLE_BORDER ; <nl> + <nl> int x , y ; <nl> CvMat bufx , bufy , bufp , bufa ; <nl> double ascale = ssize . height / ( 2 * CV_PI ) ; <nl> cvLogPolar ( const CvArr * srcarr , CvArr * dstarr , <nl> double phi = bufa . data . fl [ x ] * ascale ; <nl> <nl> mx [ x ] = ( float ) rho ; <nl> - my [ x ] = ( float ) phi ; <nl> + my [ x ] = ( float ) phi + ANGLE_BORDER ; <nl> } <nl> # else <nl> for ( x = 0 ; x < dsize . width ; x + + ) <nl> CV_IMPL <nl> void cvLinearPolar ( const CvArr * srcarr , CvArr * dstarr , <nl> CvPoint2D32f center , double maxRadius , int flags ) <nl> { <nl> + Mat src_with_border ; / / don ' t scope this variable ( it holds image data ) <nl> + <nl> cv : : Ptr < CvMat > mapx , mapy ; <nl> <nl> CvMat srcstub , * src = ( CvMat * ) srcarr ; <nl> CvMat dststub , * dst = ( CvMat * ) dstarr ; <nl> - CvSize ssize , dsize ; <nl> + CvSize dsize ; <nl> <nl> src = cvGetMat ( srcarr , & srcstub , 0 , 0 ) ; <nl> dst = cvGetMat ( dstarr , & dststub , 0 , 0 ) ; <nl> void cvLinearPolar ( const CvArr * srcarr , CvArr * dstarr , <nl> if ( ! CV_ARE_TYPES_EQ ( src , dst ) ) <nl> CV_Error ( CV_StsUnmatchedFormats , " " ) ; <nl> <nl> - ssize . width = src - > cols ; <nl> - ssize . height = src - > rows ; <nl> - dsize . width = dst - > cols ; <nl> - dsize . height = dst - > rows ; <nl> + dsize = cvGetMatSize ( dst ) ; <nl> <nl> mapx . reset ( cvCreateMat ( dsize . height , dsize . width , CV_32F ) ) ; <nl> mapy . reset ( cvCreateMat ( dsize . height , dsize . width , CV_32F ) ) ; <nl> void cvLinearPolar ( const CvArr * srcarr , CvArr * dstarr , <nl> } <nl> else <nl> { <nl> + const int ANGLE_BORDER = 1 ; <nl> + Mat src_ = cv : : cvarrToMat ( src ) ; <nl> + cv : : copyMakeBorder ( src_ , src_with_border , ANGLE_BORDER , ANGLE_BORDER , 0 , 0 , BORDER_WRAP ) ; <nl> + srcstub = src_with_border ; src = & srcstub ; <nl> + CvSize ssize = cvGetMatSize ( src ) ; <nl> + ssize . height - = 2 * ANGLE_BORDER ; <nl> + <nl> int x , y ; <nl> CvMat bufx , bufy , bufp , bufa ; <nl> const double ascale = ssize . height / ( 2 * CV_PI ) ; <nl> void cvLinearPolar ( const CvArr * srcarr , CvArr * dstarr , <nl> double rho = bufp . data . fl [ x ] * pscale ; <nl> double phi = bufa . data . fl [ x ] * ascale ; <nl> mx [ x ] = ( float ) rho ; <nl> - my [ x ] = ( float ) phi ; <nl> + my [ x ] = ( float ) phi + ANGLE_BORDER ; <nl> } <nl> } <nl> } <nl>
|
logPolar / linearPolar : more accurate processing near zero angle slice
|
opencv/opencv
|
ec66a3700ff8799270f00bb598264b22d755fc53
|
2016-03-03T16:08:08Z
|
mmm a / spec / api - crash - reporter - spec . js <nl> ppp b / spec / api - crash - reporter - spec . js <nl> <nl> const assert = require ( ' assert ' ) <nl> + const fs = require ( ' fs ' ) <nl> const http = require ( ' http ' ) <nl> const multiparty = require ( ' multiparty ' ) <nl> const path = require ( ' path ' ) <nl> + const rimraf = require ( ' rimraf ' ) <nl> + const temp = require ( ' temp ' ) . track ( ) <nl> const url = require ( ' url ' ) <nl> const { closeWindow } = require ( ' . / window - helpers ' ) <nl> <nl> const { app , BrowserWindow , crashReporter } = remote . require ( ' electron ' ) <nl> describe ( ' crashReporter module ' , function ( ) { <nl> var fixtures = path . resolve ( __dirname , ' fixtures ' ) <nl> var w = null <nl> + var originalTempDirectory = null <nl> + var tempDirectory = null <nl> <nl> beforeEach ( function ( ) { <nl> w = new BrowserWindow ( { <nl> show : false <nl> } ) <nl> + tempDirectory = temp . mkdirSync ( ' electronCrashReporterSpec - ' ) <nl> + originalTempDirectory = app . getPath ( ' temp ' ) <nl> + app . setPath ( ' temp ' , tempDirectory ) <nl> } ) <nl> <nl> afterEach ( function ( ) { <nl> + app . setPath ( ' temp ' , originalTempDirectory ) <nl> return closeWindow ( w ) . then ( function ( ) { w = null } ) <nl> } ) <nl> <nl> describe ( ' crashReporter module ' , function ( ) { <nl> assert . equal ( crashReporter . getLastCrashReport ( ) . id , ' abc - 123 - def ' ) <nl> assert . notEqual ( crashReporter . getUploadedReports ( ) . length , 0 ) <nl> assert . equal ( crashReporter . getUploadedReports ( ) [ 0 ] . id , ' abc - 123 - def ' ) <nl> + assert . equal ( fs . existsSync ( tempDirectory , ' Zombies Crahses ' ) , true ) <nl> done ( ) <nl> } ) <nl> } ) <nl> mmm a / spec / package . json <nl> ppp b / spec / package . json <nl> <nl> " devDependencies " : { <nl> " basic - auth " : " ^ 1 . 0 . 0 " , <nl> " graceful - fs " : " 3 . 0 . 5 " , <nl> - " mocha " : " 2 . 1 . 0 " , <nl> " mkdirp " : " 0 . 5 . 1 " , <nl> + " mocha " : " 2 . 1 . 0 " , <nl> " multiparty " : " 4 . 1 . 2 " , <nl> " q " : " 0 . 9 . 7 " , <nl> + " rimraf " : " ^ 2 . 5 . 4 " , <nl> " temp " : " 0 . 8 . 1 " , <nl> " walkdir " : " 0 . 0 . 7 " , <nl> " ws " : " 0 . 7 . 2 " , <nl>
|
Add tests for crash reports in custom temp directory
|
electron/electron
|
1afe501a36ff5ef9797a4c65a697b19373c5dde5
|
2016-10-06T16:02:01Z
|
mmm a / src / mongo / db / ops / update . cpp <nl> ppp b / src / mongo / db / ops / update . cpp <nl> namespace mongo { <nl> } <nl> <nl> <nl> + / / This remains the empty object in the case of an object replacement , but in the case <nl> + / / of an upsert where we are creating a base object from the query and applying mods , <nl> + / / we capture the query as the original so that we can detect shard key mutations . <nl> + BSONObj original = BSONObj ( ) ; <nl> + <nl> / / If this is a $ mod base update , we need to generate a document by examining the <nl> / / query and the mods . Otherwise , we can use the object replacement sent by the user <nl> / / update command that was parsed by the driver before . <nl> / / In the following block we handle the query part , and then do the regular mods after . <nl> if ( * request . getUpdates ( ) . firstElementFieldName ( ) = = ' $ ' ) { <nl> - uassertStatusOK ( UpdateDriver : : createFromQuery ( request . getQuery ( ) , doc ) ) ; <nl> + original = request . getQuery ( ) ; <nl> + uassertStatusOK ( UpdateDriver : : createFromQuery ( original , doc ) ) ; <nl> opDebug - > fastmodinsert = true ; <nl> } <nl> <nl> namespace mongo { <nl> <nl> / / Validate that the object replacement or modifiers resulted in a document <nl> / / that contains all the shard keys . <nl> - uassertStatusOK ( driver - > checkShardKeysUnaltered ( BSONObj ( ) , doc ) ) ; <nl> + uassertStatusOK ( driver - > checkShardKeysUnaltered ( original , doc ) ) ; <nl> <nl> BSONObj newObj = doc . getObject ( ) ; <nl> <nl>
|
SERVER - 9074 Use the query as the shard key value source in upserts with $ mods
|
mongodb/mongo
|
4729ca809b99da06ef7b57f9962740089088242d
|
2013-10-26T03:06:32Z
|
mmm a / src / mongo / s / commands / cluster_commands_helpers . cpp <nl> ppp b / src / mongo / s / commands / cluster_commands_helpers . cpp <nl> boost : : optional < LogicalTime > computeAtClusterTimeForOneShard ( OperationContext * o <nl> <nl> auto shardRegistry = Grid : : get ( opCtx ) - > shardRegistry ( ) ; <nl> invariant ( shardRegistry ) ; <nl> - return shardRegistry - > getShardNoReload ( shardId ) - > getLastCommittedOpTime ( ) ; <nl> + <nl> + auto shard = shardRegistry - > getShardNoReload ( shardId ) ; <nl> + uassert ( ErrorCodes : : ShardNotFound , str : : stream ( ) < < " Could not find shard " < < shardId , shard ) ; <nl> + <nl> + / / Return the cached last committed opTime for the shard if there is one , otherwise return the <nl> + / / lastest cluster time from the logical clock . <nl> + auto lastCommittedOpTime = shard - > getLastCommittedOpTime ( ) ; <nl> + return lastCommittedOpTime ! = LogicalTime : : kUninitialized <nl> + ? lastCommittedOpTime <nl> + : LogicalClock : : get ( opCtx ) - > getClusterTime ( ) ; <nl> } <nl> <nl> namespace { <nl> mmm a / src / mongo / s / commands / cluster_commands_helpers . h <nl> ppp b / src / mongo / s / commands / cluster_commands_helpers . h <nl> std : : set < ShardId > getTargetedShardsForQuery ( OperationContext * opCtx , <nl> const BSONObj & collation ) ; <nl> <nl> / * * <nl> - * Returns the latest known lastCommittedOpTime for the targeted shard . <nl> + * Returns the latest known lastCommittedOpTime for the targeted shard , or the latest in - memory <nl> + * cluster time if there is none . <nl> * <nl> * A null logical time is returned if the readConcern on the OperationContext is not snapshot . <nl> * / <nl> mmm a / src / mongo / s / commands / compute_at_cluster_time_test . cpp <nl> ppp b / src / mongo / s / commands / compute_at_cluster_time_test . cpp <nl> TEST_F ( AtClusterTimeTest , ComputeInvalidInvalid ) { <nl> ASSERT_EQ ( * maxTime , kInMemoryLogicalTime ) ; <nl> } <nl> <nl> + TEST_F ( AtClusterTimeTest , ComputeForOneShard ) { <nl> + auto shardOne = shardRegistry ( ) - > getShardNoReload ( shardOneId ) ; <nl> + <nl> + LogicalTime timeOne ( Timestamp ( 10 , 2 ) ) ; <nl> + shardOne - > updateLastCommittedOpTime ( timeOne ) ; <nl> + ASSERT_EQ ( timeOne , shardOne - > getLastCommittedOpTime ( ) ) ; <nl> + <nl> + auto atClusterTime = computeAtClusterTimeForOneShard ( operationContext ( ) , shardOneId ) ; <nl> + ASSERT_EQ ( * atClusterTime , timeOne ) ; <nl> + } <nl> + <nl> + TEST_F ( AtClusterTimeTest , ComputeForOneShardNoCachedOpTime ) { <nl> + auto shardOne = shardRegistry ( ) - > getShardNoReload ( shardOneId ) ; <nl> + ASSERT_EQ ( LogicalTime ( ) , shardOne - > getLastCommittedOpTime ( ) ) ; <nl> + <nl> + auto atClusterTime = computeAtClusterTimeForOneShard ( operationContext ( ) , shardOneId ) ; <nl> + ASSERT_EQ ( * atClusterTime , kInMemoryLogicalTime ) ; <nl> + } <nl> + <nl> + TEST_F ( AtClusterTimeTest , ComputeForOneShardNoShard ) { <nl> + ASSERT_THROWS_CODE ( computeAtClusterTimeForOneShard ( operationContext ( ) , ShardId ( " fakeShard " ) ) , <nl> + AssertionException , <nl> + ErrorCodes : : ShardNotFound ) ; <nl> + } <nl> <nl> class AtClusterTimeTargetingTest : public CatalogCacheTestFixture { <nl> protected : <nl>
|
SERVER - 36554 Make computeAtClusterTimeForOneShard return latest clusterTime if there is no cached last committed opTime
|
mongodb/mongo
|
60a9c20ec95c4cceda9413e18334c55bb85fe66e
|
2018-08-10T13:26:42Z
|
mmm a / lib / Sema / CSSimplify . cpp <nl> ppp b / lib / Sema / CSSimplify . cpp <nl> bool ConstraintSystem : : repairFailures ( <nl> break ; <nl> } <nl> <nl> + case ConstraintLocator : : KeyPathRoot : <nl> + conversionsOrFixes . push_back ( AllowKeyPathRootTypeMismatch : : create ( <nl> + * this , lhs , rhs , getConstraintLocator ( locator ) ) ) ; <nl> + <nl> + break ; <nl> + <nl> case ConstraintLocator : : FunctionArgument : { <nl> auto * argLoc = getConstraintLocator ( <nl> locator . withPathElement ( LocatorPathElt : : SynthesizedArgument ( 0 ) ) ) ; <nl> ConstraintSystem : : simplifyKeyPathApplicationConstraint ( <nl> rootTy = getFixedTypeRecursive ( rootTy , flags , / * wantRValue = * / false ) ; <nl> <nl> auto matchRoot = [ & ] ( ConstraintKind kind ) - > bool { <nl> - auto rootMatches = matchTypes ( rootTy , kpRootTy , kind , <nl> - subflags , locator ) ; <nl> + auto rootMatches = <nl> + matchTypes ( rootTy , kpRootTy , kind , subflags , <nl> + locator . withPathElement ( LocatorPathElt : : KeyPathRoot ( ) ) ) ; <nl> switch ( rootMatches ) { <nl> case SolutionKind : : Error : <nl> return false ; <nl> ConstraintSystem : : SolutionKind ConstraintSystem : : simplifyFixConstraint ( <nl> case FixKind : : SpecifyBaseTypeForContextualMember : <nl> case FixKind : : CoerceToCheckedCast : <nl> case FixKind : : SpecifyObjectLiteralTypeImport : <nl> + case FixKind : : AllowKeyPathRootTypeMismatch : <nl> case FixKind : : AllowCoercionToForceCast : { <nl> return recordFix ( fix ) ? SolutionKind : : Error : SolutionKind : : Solved ; <nl> } <nl>
|
[ CSSimplify ] Recording fix for keypath application root type mismatch
|
apple/swift
|
e17a934464ae16a6e60f7947a6f0da8e3191328e
|
2020-04-21T23:13:32Z
|
mmm a / utils / resolve - crashes . py <nl> ppp b / utils / resolve - crashes . py <nl> def execute_cmd ( cmd ) : <nl> os . system ( cmd ) <nl> <nl> # The regular expression we use to match compiler - crasher lines . <nl> - regex = re . compile ( ' . * Swift : : compiler_crashers / ( . * \ . swift ) . * ' ) <nl> + regex = re . compile ( ' . * Swift : : compiler_crashers ( | _2 ) / ( . * \ . swift ) . * ' ) <nl> <nl> # Take the output of lit as standard input . <nl> for line in sys . stdin : <nl> match = regex . match ( line ) <nl> if match : <nl> - filename = match . group ( 1 ) <nl> + suffix = match . group ( 1 ) <nl> + filename = match . group ( 2 ) <nl> <nl> # Move the test over to the fixed suite . <nl> - from_filename = ' validation - test / compiler_crashers / % s ' % ( filename ) <nl> - to_filename = ' validation - test / compiler_crashers_fixed / % s ' % ( filename ) <nl> + from_filename = ' validation - test / compiler_crashers % s / % s ' % ( suffix , filename ) <nl> + to_filename = ' validation - test / compiler_crashers % s_fixed / % s ' % ( suffix , filename ) <nl> git_mv_cmd = ' git mv % s % s ' % ( from_filename , to_filename ) <nl> execute_cmd ( git_mv_cmd ) <nl> <nl>
|
resolve - crashes . py now " supports " resolving compiler_crashers_2 as well
|
apple/swift
|
786141fbefc81fe6c11f870589e912552b0c9466
|
2015-06-24T22:27:55Z
|
mmm a / README . md <nl> ppp b / README . md <nl> Cream Sandwich ) . <nl> The [ Java demo ] ( http : / / libphonenumber . appspot . com / ) is updated with a slight <nl> delay after the GitHub release . <nl> <nl> - Last demo update : v8 . 8 . 7 . <nl> + Last demo update : v8 . 8 . 8 . <nl> <nl> If this number is lower than the [ latest release ' s version <nl> number ] ( http : / / github . com / googlei18n / libphonenumber / releases ) , we are between <nl>
|
Update README . md ( )
|
google/libphonenumber
|
8e2f1d2c87a19299a5c3bfce44e62dc2ba32a5b6
|
2017-12-06T12:51:04Z
|
mmm a / FDBLibTLS / verify - test . cpp <nl> ppp b / FDBLibTLS / verify - test . cpp <nl> struct FDBLibTLSVerifyTest { <nl> std : : map < int , Criteria > root_criteria ; <nl> } ; <nl> <nl> - static std : : string printable ( std : : string const & val ) { <nl> - static char const digits [ ] = " 0123456789ABCDEF " ; <nl> - std : : string s ; <nl> - <nl> - for ( int i = 0 ; i < val . size ( ) ; i + + ) { <nl> - uint8_t b = val [ i ] ; <nl> - if ( b > = 32 & & b < 127 & & b ! = ' \ \ ' ) <nl> - s + = ( char ) b ; <nl> - else if ( b = = ' \ \ ' ) <nl> - s + = " \ \ \ \ " ; <nl> - else { <nl> - s + = " \ \ x " ; <nl> - s + = digits [ ( b > > 4 ) & 15 ] ; <nl> - s + = digits [ b & 15 ] ; <nl> - } <nl> - } <nl> - return s ; <nl> - } <nl> - <nl> static std : : string criteriaToString ( std : : map < int , Criteria > const & criteria ) { <nl> std : : string s ; <nl> for ( auto & pair : criteria ) { <nl> mmm a / bindings / flow / FDBLoanerTypes . h <nl> ppp b / bindings / flow / FDBLoanerTypes . h <nl> namespace FDB { <nl> <nl> typedef Standalone < KeyRangeRef > KeyRange ; <nl> <nl> - std : : string printable ( const StringRef & val ) ; <nl> - <nl> template < class T > <nl> static std : : string describe ( T const & item ) { <nl> return item . toString ( ) ; <nl> mmm a / bindings / flow / fdb_flow . actor . cpp <nl> ppp b / bindings / flow / fdb_flow . actor . cpp <nl> namespace FDB { <nl> void TransactionImpl : : reset ( ) { <nl> fdb_transaction_reset ( tr ) ; <nl> } <nl> - <nl> - std : : string printable ( const StringRef & val ) { <nl> - std : : string s ; <nl> - for ( int i = 0 ; i < val . size ( ) ; i + + ) { <nl> - uint8_t b = val [ i ] ; <nl> - if ( b > = 32 & & b < 127 & & b ! = ' \ \ ' ) s + = ( char ) b ; <nl> - else if ( b = = ' \ \ ' ) s + = " \ \ \ \ " ; <nl> - else s + = format ( " \ \ x % 02x " , b ) ; <nl> - } <nl> - return s ; <nl> - } <nl> - <nl> } <nl> mmm a / bindings / flow / tester / DirectoryTester . actor . cpp <nl> ppp b / bindings / flow / tester / DirectoryTester . actor . cpp <nl> struct DirectoryCreateSubspaceFunc : InstructionFunc { <nl> state Tuple path = wait ( popTuple ( data ) ) ; <nl> Tuple rawPrefix = wait ( data - > stack . waitAndPop ( ) ) ; <nl> <nl> - logOp ( format ( " Created subspace at % s : % s " , tupleToString ( path ) . c_str ( ) , printable ( rawPrefix . getString ( 0 ) ) . c_str ( ) ) ) ; <nl> + logOp ( format ( " Created subspace at % s : % s " , tupleToString ( path ) . c_str ( ) , rawPrefix . getString ( 0 ) . printable ( ) . c_str ( ) ) ) ; <nl> data - > directoryData . push ( new Subspace ( path , rawPrefix . getString ( 0 ) ) ) ; <nl> return Void ( ) ; <nl> } <nl> struct DirectoryCreateLayerFunc : InstructionFunc { <nl> else { <nl> Subspace * nodeSubspace = data - > directoryData . directoryList [ index1 ] . subspace . get ( ) ; <nl> Subspace * contentSubspace = data - > directoryData . directoryList [ index2 ] . subspace . get ( ) ; <nl> - logOp ( format ( " Create directory layer : node_subspace ( % d ) = % s , content_subspace ( % d ) = % s , allow_manual_prefixes = % d " , index1 , printable ( nodeSubspace - > key ( ) ) . c_str ( ) , index2 , printable ( nodeSubspace - > key ( ) ) . c_str ( ) , allowManualPrefixes ) ) ; <nl> + logOp ( format ( " Create directory layer : node_subspace ( % d ) = % s , content_subspace ( % d ) = % s , allow_manual_prefixes = % d " , index1 , nodeSubspace - > key ( ) . printable ( ) . c_str ( ) , index2 , nodeSubspace - > key ( ) . printable ( ) . c_str ( ) , allowManualPrefixes ) ) ; <nl> data - > directoryData . push ( Reference < IDirectory > ( new DirectoryLayer ( * nodeSubspace , * contentSubspace , allowManualPrefixes ) ) ) ; <nl> } <nl> <nl> struct DirectoryChangeFunc : InstructionFunc { <nl> <nl> if ( LOG_DIRS ) { <nl> DirectoryOrSubspace d = data - > directoryData . directoryList [ data - > directoryData . directoryListIndex ] ; <nl> - printf ( " Changed directory to % d ( % s @ \ ' % s \ ' ) \ n " , data - > directoryData . directoryListIndex , d . typeString ( ) . c_str ( ) , d . directory . present ( ) ? pathToString ( d . directory . get ( ) - > getPath ( ) ) . c_str ( ) : printable ( d . subspace . get ( ) - > key ( ) ) . c_str ( ) ) ; <nl> + printf ( " Changed directory to % d ( % s @ \ ' % s \ ' ) \ n " , data - > directoryData . directoryListIndex , d . typeString ( ) . c_str ( ) , d . directory . present ( ) ? pathToString ( d . directory . get ( ) - > getPath ( ) ) . c_str ( ) : d . subspace . get ( ) - > key ( ) . printable ( ) . c_str ( ) ) ; <nl> fflush ( stdout ) ; <nl> } <nl> <nl> struct DirectoryCreateOrOpenFunc : InstructionFunc { <nl> Standalone < StringRef > layer = layerTuple . getType ( 0 ) = = Tuple : : NULL_TYPE ? StringRef ( ) : layerTuple . getString ( 0 ) ; <nl> <nl> Reference < IDirectory > directory = data - > directoryData . directory ( ) ; <nl> - logOp ( format ( " create_or_open % s : layer = % s " , pathToString ( combinePaths ( directory - > getPath ( ) , path ) ) . c_str ( ) , printable ( layer ) . c_str ( ) ) ) ; <nl> + logOp ( format ( " create_or_open % s : layer = % s " , pathToString ( combinePaths ( directory - > getPath ( ) , path ) ) . c_str ( ) , layer . printable ( ) . c_str ( ) ) ) ; <nl> <nl> Reference < DirectorySubspace > dirSubspace = wait ( executeMutation ( instruction , [ this , directory , layer ] ( ) { <nl> return directory - > createOrOpen ( instruction - > tr , path , layer ) ; <nl> struct DirectoryCreateFunc : InstructionFunc { <nl> Optional < Standalone < StringRef > > prefix = args [ 1 ] . getType ( 0 ) = = Tuple : : NULL_TYPE ? Optional < Standalone < StringRef > > ( ) : args [ 1 ] . getString ( 0 ) ; <nl> <nl> Reference < IDirectory > directory = data - > directoryData . directory ( ) ; <nl> - logOp ( format ( " create % s : layer = % s , prefix = % s " , pathToString ( combinePaths ( directory - > getPath ( ) , path ) ) . c_str ( ) , printable ( layer ) . c_str ( ) , prefix . present ( ) ? printable ( prefix . get ( ) ) . c_str ( ) : " < not present > " ) ) ; <nl> + logOp ( format ( " create % s : layer = % s , prefix = % s " , pathToString ( combinePaths ( directory - > getPath ( ) , path ) ) . c_str ( ) , layer . printable ( ) . c_str ( ) , prefix . present ( ) ? prefix . get ( ) . printable ( ) . c_str ( ) : " < not present > " ) ) ; <nl> <nl> Reference < DirectorySubspace > dirSubspace = wait ( executeMutation ( instruction , [ this , directory , layer , prefix ] ( ) { <nl> return directory - > create ( instruction - > tr , path , layer , prefix ) ; <nl> struct DirectoryOpenFunc : InstructionFunc { <nl> Standalone < StringRef > layer = layerTuple . getType ( 0 ) = = Tuple : : NULL_TYPE ? StringRef ( ) : layerTuple . getString ( 0 ) ; <nl> <nl> Reference < IDirectory > directory = data - > directoryData . directory ( ) ; <nl> - logOp ( format ( " open % s : layer = % s " , pathToString ( combinePaths ( directory - > getPath ( ) , path ) ) . c_str ( ) , printable ( layer ) . c_str ( ) ) ) ; <nl> + logOp ( format ( " open % s : layer = % s " , pathToString ( combinePaths ( directory - > getPath ( ) , path ) ) . c_str ( ) , layer . printable ( ) . c_str ( ) ) ) ; <nl> Reference < DirectorySubspace > dirSubspace = wait ( directory - > open ( instruction - > tr , path , layer ) ) ; <nl> data - > directoryData . push ( dirSubspace ) ; <nl> <nl> struct DirectoryUnpackKeyFunc : InstructionFunc { <nl> ACTOR static Future < Void > call ( Reference < FlowTesterData > data , Reference < InstructionData > instruction ) { <nl> Tuple key = wait ( data - > stack . waitAndPop ( ) ) ; <nl> Subspace * subspace = data - > directoryData . subspace ( ) ; <nl> - logOp ( format ( " Unpack % s in subspace with prefix % s " , printable ( key . getString ( 0 ) ) . c_str ( ) , printable ( subspace - > key ( ) ) . c_str ( ) ) ) ; <nl> + logOp ( format ( " Unpack % s in subspace with prefix % s " , key . getString ( 0 ) . printable ( ) . c_str ( ) , subspace - > key ( ) . printable ( ) . c_str ( ) ) ) ; <nl> Tuple tuple = subspace - > unpack ( key . getString ( 0 ) ) ; <nl> for ( int i = 0 ; i < tuple . size ( ) ; + + i ) { <nl> data - > stack . push ( tuple . subTuple ( i , i + 1 ) . pack ( ) ) ; <nl> struct DirectoryOpenSubspaceFunc : InstructionFunc { <nl> ACTOR static Future < Void > call ( Reference < FlowTesterData > data , Reference < InstructionData > instruction ) { <nl> Tuple tuple = wait ( popTuple ( data ) ) ; <nl> Subspace * subspace = data - > directoryData . subspace ( ) ; <nl> - logOp ( format ( " open_subspace % s ( at % s ) " , tupleToString ( tuple ) . c_str ( ) , printable ( subspace - > key ( ) ) . c_str ( ) ) ) ; <nl> + logOp ( format ( " open_subspace % s ( at % s ) " , tupleToString ( tuple ) . c_str ( ) , subspace - > key ( ) . printable ( ) . c_str ( ) ) ) ; <nl> Subspace * child = new Subspace ( subspace - > subspace ( tuple ) ) ; <nl> data - > directoryData . push ( child ) ; <nl> <nl> mmm a / bindings / flow / tester / Tester . actor . cpp <nl> ppp b / bindings / flow / tester / Tester . actor . cpp <nl> std : : string tupleToString ( Tuple const & tuple ) { <nl> if ( type = = Tuple : : UTF8 ) { <nl> str + = " u " ; <nl> } <nl> - str + = " \ ' " + printable ( tuple . getString ( i ) ) + " \ ' " ; <nl> + str + = " \ ' " + tuple . getString ( i ) . printable ( ) + " \ ' " ; <nl> } <nl> else if ( type = = Tuple : : INT ) { <nl> str + = format ( " % ld " , tuple . getInt ( i ) ) ; <nl> ACTOR void _test_versionstamp ( ) { <nl> <nl> ASSERT ( trVersion . compare ( dbVersion ) = = 0 ) ; <nl> <nl> - fprintf ( stderr , " % s \ n " , printable ( trVersion ) . c_str ( ) ) ; <nl> + fprintf ( stderr , " % s \ n " , trVersion . printable ( ) . c_str ( ) ) ; <nl> <nl> g_network - > stop ( ) ; <nl> } <nl> mmm a / fdbclient / NativeAPI . actor . cpp <nl> ppp b / fdbclient / NativeAPI . actor . cpp <nl> Future < Void > Transaction : : commitMutations ( ) { <nl> . detail ( " Size " , transactionSize ) <nl> . detail ( " NumMutations " , tr . transaction . mutations . size ( ) ) <nl> . detail ( " ReadConflictSize " , tr . transaction . read_conflict_ranges . expectedSize ( ) ) <nl> - . detail ( " WriteConflictSize " , tr . transaction . write_conflict_ranges . expectedSize ( ) ) ; <nl> + . detail ( " WriteConflictSize " , tr . transaction . write_conflict_ranges . expectedSize ( ) ) <nl> + . detail ( " DebugIdentifier " , trLogInfo ? trLogInfo - > identifier : " " ) ; <nl> } <nl> <nl> if ( ! apiVersionAtLeast ( 300 ) ) { <nl> void Transaction : : setOption ( FDBTransactionOptions : : Option option , Optional < Stri <nl> <nl> if ( trLogInfo ) { <nl> if ( trLogInfo - > identifier . empty ( ) ) { <nl> - trLogInfo - > identifier = printable ( value . get ( ) ) ; <nl> + trLogInfo - > identifier = value . get ( ) . printable ( ) ; <nl> } <nl> - else if ( trLogInfo - > identifier ! = printable ( value . get ( ) ) ) { <nl> - TraceEvent ( SevWarn , " CannotChangeDebugTransactionIdentifier " ) . detail ( " PreviousIdentifier " , trLogInfo - > identifier ) . detail ( " NewIdentifier " , printable ( value . get ( ) ) ) ; <nl> + else if ( trLogInfo - > identifier ! = value . get ( ) . printable ( ) ) { <nl> + TraceEvent ( SevWarn , " CannotChangeDebugTransactionIdentifier " ) . detail ( " PreviousIdentifier " , trLogInfo - > identifier ) . detail ( " NewIdentifier " , value . get ( ) . printable ( ) ) ; <nl> throw client_invalid_operation ( ) ; <nl> } <nl> } <nl> else { <nl> - trLogInfo = Reference < TransactionLogInfo > ( new TransactionLogInfo ( printable ( value . get ( ) ) , TransactionLogInfo : : DONT_LOG ) ) ; <nl> + trLogInfo = Reference < TransactionLogInfo > ( new TransactionLogInfo ( value . get ( ) . printable ( ) , TransactionLogInfo : : DONT_LOG ) ) ; <nl> } <nl> break ; <nl> <nl> mmm a / fdbserver / CompactMap . cpp <nl> ppp b / fdbserver / CompactMap . cpp <nl> struct CompactPreOrderTree { <nl> # endif <nl> } ; <nl> <nl> - std : : string printable ( const StringRef & val ) { <nl> - std : : string s ; <nl> - for ( int i = 0 ; i < val . size ( ) ; i + + ) { <nl> - uint8_t b = val [ i ] ; <nl> - if ( b > = 32 & & b < 127 & & b ! = ' \ \ ' ) s + = ( char ) b ; <nl> - else if ( b = = ' \ \ ' ) s + = " \ \ \ \ " ; <nl> - else s + = format ( " \ \ x % 02x " , b ) ; <nl> - } <nl> - return s ; <nl> - } <nl> - <nl> void compactMapTests ( std : : vector < std : : string > testData , std : : vector < std : : string > sampleQueries , std : : string prefixTreeDOTFile = " " ) { <nl> double t1 , t2 ; <nl> int r = 0 ; <nl> mmm a / flow / Arena . h <nl> ppp b / flow / Arena . h <nl> class StringRef { <nl> } <nl> <nl> std : : string toString ( ) const { return std : : string ( ( const char * ) data , length ) ; } <nl> + <nl> std : : string printable ( ) const { <nl> - std : : string s ; <nl> - for ( int i = 0 ; i < length ; i + + ) { <nl> - uint8_t b = ( * this ) [ i ] ; <nl> - if ( b > = 32 & & b < 127 & & b ! = ' \ \ ' ) s + = ( char ) b ; <nl> - else if ( b = = ' \ \ ' ) s + = " \ \ \ \ " ; <nl> - else s + = format ( " \ \ x % 02x " , b ) ; <nl> + constexpr char hex [ ] = " 0123456789abcdef " ; <nl> + <nl> + int additionalLength = 0 ; <nl> + for ( int i = 0 ; i < length ; i + + ) { <nl> + uint8_t b = data [ i ] ; <nl> + if ( b = = ' \ \ ' ) additionalLength + = 1 ; <nl> + else if ( b < 32 | | b > = 127 ) additionalLength + = 3 ; <nl> + } <nl> + <nl> + if ( additionalLength = = 0 ) { <nl> + return std : : string ( ( const char * ) data , length ) ; <nl> + } <nl> + <nl> + std : : string s ( length + additionalLength , ' \ \ ' ) ; <nl> + int beginCopy = 0 ; <nl> + int resultPos = 0 ; <nl> + for ( int i = 0 ; i < length ; i + + ) { <nl> + uint8_t b = data [ i ] ; <nl> + if ( b < 32 | | b > = 127 | | b = = ' \ \ ' ) { <nl> + memcpy ( ( char * ) s . c_str ( ) + resultPos , ( const char * ) data + beginCopy , i - beginCopy ) ; <nl> + resultPos + = i - beginCopy ; <nl> + beginCopy = i + 1 ; <nl> + if ( b = = ' \ \ ' ) { <nl> + resultPos + = 2 ; <nl> + } else { <nl> + + + resultPos ; <nl> + s [ resultPos + + ] = ' x ' ; <nl> + s [ resultPos + + ] = hex [ b > > 4 ] ; <nl> + s [ resultPos + + ] = hex [ b & 0xf ] ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + if ( beginCopy < length ) { <nl> + memcpy ( ( char * ) s . c_str ( ) + resultPos , ( const char * ) data + beginCopy , length - beginCopy ) ; <nl> } <nl> return s ; <nl> } <nl>
|
Merge pull request from etschannen / feature - fast - printable
|
apple/foundationdb
|
de9b5f20f7f472ddbc6535fe9dd8734e046f5754
|
2019-06-03T22:01:58Z
|
mmm a / geometry / jarvis_algorithm . cpp <nl> ppp b / geometry / jarvis_algorithm . cpp <nl> namespace geometry { <nl> <nl> / * * <nl> * @ namespace jarvis <nl> - * @ brief Functions for [ Jarvis ’ s Algorithm ] ( https : / / en . wikipedia . org / wiki / Gift_wrapping_algorithm ) algorithm <nl> + * @ brief Functions for [ Jarvis ’ s ] ( https : / / en . wikipedia . org / wiki / Gift_wrapping_algorithm ) algorithm <nl> * / <nl> namespace jarvis { <nl> / * * <nl>
|
Update geometry / jarvis_algorithm . cpp
|
TheAlgorithms/C-Plus-Plus
|
ff4792d369ce453ebcb97b1b68ad1c39a4b8301b
|
2020-08-16T16:42:56Z
|
mmm a / src / compiler / ia32 / instruction - selector - ia32 . cc <nl> ppp b / src / compiler / ia32 / instruction - selector - ia32 . cc <nl> void VisitWordCompare ( InstructionSelector * selector , Node * node , <nl> selector - > EmitWithContinuation ( opcode , cont ) ; <nl> return ; <nl> } <nl> + WasmStackCheckMatcher < Int32BinopMatcher , IrOpcode : : kUint32LessThan > wasm_m ( <nl> + node ) ; <nl> + if ( wasm_m . Matched ( ) ) { <nl> + / / This is a wasm stack check . By structure , we know that we can use the <nl> + / / stack pointer directly , as wasm code does not modify the stack at points <nl> + / / where stack checks are performed . <nl> + Node * left = node - > InputAt ( 0 ) ; <nl> + LocationOperand esp ( InstructionOperand : : EXPLICIT , LocationOperand : : REGISTER , <nl> + InstructionSequence : : DefaultRepresentation ( ) , <nl> + RegisterCode : : kRegCode_esp ) ; <nl> + return VisitCompareWithMemoryOperand ( selector , kIA32Cmp , left , esp , cont ) ; <nl> + } <nl> VisitWordCompare ( selector , node , kIA32Cmp , cont ) ; <nl> } <nl> <nl> mmm a / src / compiler / node - matchers . h <nl> ppp b / src / compiler / node - matchers . h <nl> struct V8_EXPORT_PRIVATE DiamondMatcher <nl> Node * if_false_ ; <nl> } ; <nl> <nl> + template < class BinopMatcher , IrOpcode : : Value expected_opcode > <nl> + struct WasmStackCheckMatcher { <nl> + explicit WasmStackCheckMatcher ( Node * compare ) : compare_ ( compare ) { } <nl> + <nl> + bool Matched ( ) { <nl> + if ( compare_ - > opcode ( ) ! = expected_opcode ) return false ; <nl> + BinopMatcher m ( compare_ ) ; <nl> + return MatchedInternal ( m . left ( ) , m . right ( ) ) ; <nl> + } <nl> + <nl> + private : <nl> + bool MatchedInternal ( const typename BinopMatcher : : LeftMatcher & l , <nl> + const typename BinopMatcher : : RightMatcher & r ) { <nl> + / / In wasm , the stack check is performed by loading the value given by <nl> + / / the address of a field stored in the instance object . That object is <nl> + / / passed as a parameter . <nl> + if ( l . IsLoad ( ) & & r . IsLoadStackPointer ( ) ) { <nl> + LoadMatcher < LoadMatcher < NodeMatcher > > mleft ( l . node ( ) ) ; <nl> + if ( mleft . object ( ) . IsLoad ( ) & & mleft . index ( ) . Is ( 0 ) & & <nl> + mleft . object ( ) . object ( ) . IsParameter ( ) ) { <nl> + return true ; <nl> + } <nl> + } <nl> + return false ; <nl> + } <nl> + Node * compare_ ; <nl> + } ; <nl> + <nl> template < class BinopMatcher , IrOpcode : : Value expected_opcode > <nl> struct StackCheckMatcher { <nl> StackCheckMatcher ( Isolate * isolate , Node * compare ) <nl> mmm a / src / compiler / wasm - compiler . cc <nl> ppp b / src / compiler / wasm - compiler . cc <nl> void WasmGraphBuilder : : StackCheck ( wasm : : WasmCodePosition position , <nl> if ( effect = = nullptr ) effect = effect_ ; <nl> if ( control = = nullptr ) control = control_ ; <nl> <nl> + / / This instruction sequence is matched in the instruction selector to <nl> + / / load the stack pointer directly on some platforms . Hence , when modifying <nl> + / / please also fix WasmStackCheckMatcher in node - matchers . h <nl> + <nl> Node * limit_address = graph ( ) - > NewNode ( <nl> mcgraph ( ) - > machine ( ) - > Load ( MachineType : : Pointer ( ) ) , instance_node_ . get ( ) , <nl> mcgraph ( ) - > Int32Constant ( WASM_INSTANCE_OBJECT_OFFSET ( StackLimitAddress ) ) , <nl> mmm a / src / compiler / x64 / instruction - selector - x64 . cc <nl> ppp b / src / compiler / x64 / instruction - selector - x64 . cc <nl> void VisitWord64Compare ( InstructionSelector * selector , Node * node , <nl> selector - > EmitWithContinuation ( opcode , cont ) ; <nl> return ; <nl> } <nl> + WasmStackCheckMatcher < Int64BinopMatcher , IrOpcode : : kUint64LessThan > wasm_m ( <nl> + node ) ; <nl> + if ( wasm_m . Matched ( ) ) { <nl> + / / This is a wasm stack check . By structure , we know that we can use the <nl> + / / stack pointer directly , as wasm code does not modify the stack at points <nl> + / / where stack checks are performed . <nl> + Node * left = node - > InputAt ( 0 ) ; <nl> + LocationOperand rsp ( InstructionOperand : : EXPLICIT , LocationOperand : : REGISTER , <nl> + InstructionSequence : : DefaultRepresentation ( ) , <nl> + RegisterCode : : kRegCode_rsp ) ; <nl> + return VisitCompareWithMemoryOperand ( selector , kX64Cmp , left , rsp , cont ) ; <nl> + } <nl> VisitWordCompare ( selector , node , kX64Cmp , cont ) ; <nl> } <nl> <nl>
|
[ wasm ] Use esp / rsp register directly in stack checks
|
v8/v8
|
eb87b88a385b1287476ff19a52ca51ad0414bd1b
|
2018-07-02T08:32:18Z
|
mmm a / test / cctest / wasm / wasm - run - utils . cc <nl> ppp b / test / cctest / wasm / wasm - run - utils . cc <nl> void WasmFunctionCompiler : : Build ( const byte * start , const byte * end ) { <nl> static_cast < uint32_t > ( len ) } ; <nl> <nl> if ( interpreter_ ) { <nl> - / / Add the code to the interpreter . <nl> + / / Add the code to the interpreter ; do not generate compiled code . <nl> interpreter_ - > SetFunctionCodeForTesting ( function_ , start , end ) ; <nl> - } <nl> - <nl> - / / TODO ( wasm ) : tests that go through JS depend on having a compiled version <nl> - / / of each function , even if the execution tier is the interpreter . Fix . <nl> - auto tier = builder_ - > execution_tier ( ) ; <nl> - if ( tier = = ExecutionTier : : kInterpreter ) { <nl> - tier = ExecutionTier : : kOptimized ; <nl> + return ; <nl> } <nl> <nl> Vector < const uint8_t > wire_bytes = builder_ - > instance_object ( ) <nl> void WasmFunctionCompiler : : Build ( const byte * start , const byte * end ) { <nl> NativeModule * native_module = <nl> builder_ - > instance_object ( ) - > module_object ( ) - > native_module ( ) ; <nl> WasmCompilationUnit unit ( isolate ( ) - > wasm_engine ( ) , function_ - > func_index , <nl> - tier ) ; <nl> + builder_ - > execution_tier ( ) ) ; <nl> WasmFeatures unused_detected_features ; <nl> WasmCompilationResult result = unit . ExecuteCompilation ( <nl> & env , native_module - > compilation_state ( ) - > GetWireBytesStorage ( ) , <nl>
|
[ wasm ] [ test ] Do not compile code for interpreter tests
|
v8/v8
|
81dc553b55c6406ae981dfd8c2837c4e88df380b
|
2019-02-11T11:48:10Z
|
mmm a / build / cocos2d_libs . xcodeproj / project . pbxproj <nl> ppp b / build / cocos2d_libs . xcodeproj / project . pbxproj <nl> <nl> A045F6DD1BA816A1005076C7 / * CCCameraBackgroundBrush . cpp in Sources * / = { isa = PBXBuildFile ; fileRef = A045F6DA1BA816A1005076C7 / * CCCameraBackgroundBrush . cpp * / ; } ; <nl> A045F6DE1BA816A1005076C7 / * CCCameraBackgroundBrush . h in Headers * / = { isa = PBXBuildFile ; fileRef = A045F6DB1BA816A1005076C7 / * CCCameraBackgroundBrush . h * / ; } ; <nl> A045F6DF1BA816A1005076C7 / * CCCameraBackgroundBrush . h in Headers * / = { isa = PBXBuildFile ; fileRef = A045F6DB1BA816A1005076C7 / * CCCameraBackgroundBrush . h * / ; } ; <nl> - A045F6E41BA8170A005076C7 / * CCComponentPhysics2d . cpp in Sources * / = { isa = PBXBuildFile ; fileRef = A045F6E01BA8170A005076C7 / * CCComponentPhysics2d . cpp * / ; } ; <nl> - A045F6E51BA8170A005076C7 / * CCComponentPhysics2d . cpp in Sources * / = { isa = PBXBuildFile ; fileRef = A045F6E01BA8170A005076C7 / * CCComponentPhysics2d . cpp * / ; } ; <nl> - A045F6E61BA8170A005076C7 / * CCComponentPhysics2d . h in Headers * / = { isa = PBXBuildFile ; fileRef = A045F6E11BA8170A005076C7 / * CCComponentPhysics2d . h * / ; } ; <nl> - A045F6E71BA8170A005076C7 / * CCComponentPhysics2d . h in Headers * / = { isa = PBXBuildFile ; fileRef = A045F6E11BA8170A005076C7 / * CCComponentPhysics2d . h * / ; } ; <nl> - A045F6E81BA8170A005076C7 / * CCPhysicsManager . cpp in Sources * / = { isa = PBXBuildFile ; fileRef = A045F6E21BA8170A005076C7 / * CCPhysicsManager . cpp * / ; } ; <nl> - A045F6E91BA8170A005076C7 / * CCPhysicsManager . cpp in Sources * / = { isa = PBXBuildFile ; fileRef = A045F6E21BA8170A005076C7 / * CCPhysicsManager . cpp * / ; } ; <nl> - A045F6EA1BA8170A005076C7 / * CCPhysicsManager . h in Headers * / = { isa = PBXBuildFile ; fileRef = A045F6E31BA8170A005076C7 / * CCPhysicsManager . h * / ; } ; <nl> - A045F6EB1BA8170A005076C7 / * CCPhysicsManager . h in Headers * / = { isa = PBXBuildFile ; fileRef = A045F6E31BA8170A005076C7 / * CCPhysicsManager . h * / ; } ; <nl> A045F6EF1BA81821005076C7 / * GameNode3DReader . cpp in Sources * / = { isa = PBXBuildFile ; fileRef = A045F6ED1BA81821005076C7 / * GameNode3DReader . cpp * / ; } ; <nl> A045F6F01BA81821005076C7 / * GameNode3DReader . cpp in Sources * / = { isa = PBXBuildFile ; fileRef = A045F6ED1BA81821005076C7 / * GameNode3DReader . cpp * / ; } ; <nl> A045F6F11BA81821005076C7 / * GameNode3DReader . h in Headers * / = { isa = PBXBuildFile ; fileRef = A045F6EE1BA81821005076C7 / * GameNode3DReader . h * / ; } ; <nl> <nl> A045F6D51BA81577005076C7 / * CCTextureCube . h * / = { isa = PBXFileReference ; fileEncoding = 4 ; lastKnownFileType = sourcecode . c . h ; path = CCTextureCube . h ; sourceTree = " < group > " ; } ; <nl> A045F6DA1BA816A1005076C7 / * CCCameraBackgroundBrush . cpp * / = { isa = PBXFileReference ; fileEncoding = 4 ; lastKnownFileType = sourcecode . cpp . cpp ; path = CCCameraBackgroundBrush . cpp ; sourceTree = " < group > " ; } ; <nl> A045F6DB1BA816A1005076C7 / * CCCameraBackgroundBrush . h * / = { isa = PBXFileReference ; fileEncoding = 4 ; lastKnownFileType = sourcecode . c . h ; path = CCCameraBackgroundBrush . h ; sourceTree = " < group > " ; } ; <nl> - A045F6E01BA8170A005076C7 / * CCComponentPhysics2d . cpp * / = { isa = PBXFileReference ; fileEncoding = 4 ; lastKnownFileType = sourcecode . cpp . cpp ; path = CCComponentPhysics2d . cpp ; sourceTree = " < group > " ; } ; <nl> - A045F6E11BA8170A005076C7 / * CCComponentPhysics2d . h * / = { isa = PBXFileReference ; fileEncoding = 4 ; lastKnownFileType = sourcecode . c . h ; path = CCComponentPhysics2d . h ; sourceTree = " < group > " ; } ; <nl> - A045F6E21BA8170A005076C7 / * CCPhysicsManager . cpp * / = { isa = PBXFileReference ; fileEncoding = 4 ; lastKnownFileType = sourcecode . cpp . cpp ; path = CCPhysicsManager . cpp ; sourceTree = " < group > " ; } ; <nl> - A045F6E31BA8170A005076C7 / * CCPhysicsManager . h * / = { isa = PBXFileReference ; fileEncoding = 4 ; lastKnownFileType = sourcecode . c . h ; path = CCPhysicsManager . h ; sourceTree = " < group > " ; } ; <nl> A045F6ED1BA81821005076C7 / * GameNode3DReader . cpp * / = { isa = PBXFileReference ; fileEncoding = 4 ; lastKnownFileType = sourcecode . cpp . cpp ; path = GameNode3DReader . cpp ; sourceTree = " < group > " ; } ; <nl> A045F6EE1BA81821005076C7 / * GameNode3DReader . h * / = { isa = PBXFileReference ; fileEncoding = 4 ; lastKnownFileType = sourcecode . c . h ; path = GameNode3DReader . h ; sourceTree = " < group > " ; } ; <nl> A0534A631B872FFD006B03E5 / * CCDownloader - apple . h * / = { isa = PBXFileReference ; fileEncoding = 4 ; lastKnownFileType = sourcecode . c . h ; path = " CCDownloader - apple . h " ; sourceTree = " < group > " ; } ; <nl> <nl> 46A170611807CE7A005B8026 / * physics * / = { <nl> isa = PBXGroup ; <nl> children = ( <nl> - A045F6E01BA8170A005076C7 / * CCComponentPhysics2d . cpp * / , <nl> - A045F6E11BA8170A005076C7 / * CCComponentPhysics2d . h * / , <nl> - A045F6E21BA8170A005076C7 / * CCPhysicsManager . cpp * / , <nl> - A045F6E31BA8170A005076C7 / * CCPhysicsManager . h * / , <nl> ED74D7681A5B8A2600157FD4 / * CCPhysicsHelper . h * / , <nl> 46A1706E1807CE7A005B8026 / * CCPhysicsBody . cpp * / , <nl> 46A1706F1807CE7A005B8026 / * CCPhysicsBody . h * / , <nl> <nl> 15AE1A3519AAD3D500C27E9E / * b2EdgeShape . h in Headers * / , <nl> B6CAB3151AF9AA1A00B9B856 / * btBoxCollision . h in Headers * / , <nl> 50643BD919BFAF4400EF68ED / * CCApplication . h in Headers * / , <nl> - A045F6E61BA8170A005076C7 / * CCComponentPhysics2d . h in Headers * / , <nl> B665E3581AA80A6500DDB1C5 / * CCPUOnQuotaObserverTranslator . h in Headers * / , <nl> B6CAB2371AF9AA1A00B9B856 / * btCompoundCollisionAlgorithm . h in Headers * / , <nl> B665E3DC1AA80A6600DDB1C5 / * CCPUScriptTranslator . h in Headers * / , <nl> <nl> B6CAB5331AF9AA1A00B9B856 / * btTransformUtil . h in Headers * / , <nl> B6DD2FEF1B04825B00E47F5F / * DetourTileCache . h in Headers * / , <nl> 50ABBECD1925AB6F00A911A9 / * s3tc . h in Headers * / , <nl> - A045F6EA1BA8170A005076C7 / * CCPhysicsManager . h in Headers * / , <nl> B6CAB3651AF9AA1A00B9B856 / * btContinuousConvexCollision . h in Headers * / , <nl> 15AE1BD119AAE01E00C27E9E / * CCControlHuePicker . h in Headers * / , <nl> B5CE6DC01B3BF2B1002B0419 / * UIAbstractCheckButton . h in Headers * / , <nl> <nl> 15AE1A9C19AAD40300C27E9E / * b2Settings . h in Headers * / , <nl> 1A5701FA180BCBAD0088DEC7 / * CCMenu . h in Headers * / , <nl> 15AE18BA19AAD33D00C27E9E / * CCControlButtonLoader . h in Headers * / , <nl> - A045F6EB1BA8170A005076C7 / * CCPhysicsManager . h in Headers * / , <nl> 1A5701FE180BCBAD0088DEC7 / * CCMenuItem . h in Headers * / , <nl> 50ABC00C1926664800A911A9 / * CCDevice . h in Headers * / , <nl> 1A570205180BCBD40088DEC7 / * CCClippingNode . h in Headers * / , <nl> <nl> 15AE195A19AAD35100C27E9E / * CCProcessBase . h in Headers * / , <nl> 15AE193D19AAD35100C27E9E / * CCArmatureDefine . h in Headers * / , <nl> B6CAB37A1AF9AA1A00B9B856 / * btGjkEpaPenetrationDepthSolver . h in Headers * / , <nl> - A045F6E71BA8170A005076C7 / * CCComponentPhysics2d . h in Headers * / , <nl> B6CAB21A1AF9AA1A00B9B856 / * btBox2dBox2dCollisionAlgorithm . h in Headers * / , <nl> 382384041A259005002C4610 / * CSParseBinary_generated . h in Headers * / , <nl> B6CAB5401AF9AA1A00B9B856 / * cl_platform . h in Headers * / , <nl> <nl> B665E2621AA80A6500DDB1C5 / * CCPUDoExpireEventHandler . cpp in Sources * / , <nl> B665E4161AA80A6600DDB1C5 / * CCPUTextureAnimatorTranslator . cpp in Sources * / , <nl> B665E41E1AA80A6600DDB1C5 / * CCPUTextureRotatorTranslator . cpp in Sources * / , <nl> - A045F6E81BA8170A005076C7 / * CCPhysicsManager . cpp in Sources * / , <nl> 15AE189819AAD33D00C27E9E / * CCMenuItemLoader . cpp in Sources * / , <nl> 15AE1A5719AAD40300C27E9E / * b2Settings . cpp in Sources * / , <nl> 50ABBE271925AB6F00A911A9 / * CCAutoreleasePool . cpp in Sources * / , <nl> <nl> A045F6DC1BA816A1005076C7 / * CCCameraBackgroundBrush . cpp in Sources * / , <nl> B665E25A1AA80A6500DDB1C5 / * CCPUDoEnableComponentEventHandler . cpp in Sources * / , <nl> A0E749F71BA8FD7F001A8332 / * UIEditBoxImpl - common . cpp in Sources * / , <nl> - A045F6E41BA8170A005076C7 / * CCComponentPhysics2d . cpp in Sources * / , <nl> B6DD2FB31B04825B00E47F5F / * RecastDump . cpp in Sources * / , <nl> B6CAB2BB1AF9AA1A00B9B856 / * btCylinderShape . cpp in Sources * / , <nl> 15AE1BD019AAE01E00C27E9E / * CCControlHuePicker . cpp in Sources * / , <nl> <nl> B6CAB3261AF9AA1A00B9B856 / * btGImpactBvh . cpp in Sources * / , <nl> 15AE18B919AAD33D00C27E9E / * CCControlButtonLoader . cpp in Sources * / , <nl> B6CAB4041AF9AA1A00B9B856 / * btMultiBodyDynamicsWorld . cpp in Sources * / , <nl> - A045F6E91BA8170A005076C7 / * CCPhysicsManager . cpp in Sources * / , <nl> 50ABBE761925AB6F00A911A9 / * CCEventListenerTouch . cpp in Sources * / , <nl> 15AE1AD219AAD40300C27E9E / * b2RopeJoint . cpp in Sources * / , <nl> B29A7DCC19EE1B7700872B35 / * Skeleton . c in Sources * / , <nl> <nl> B6CAB2521AF9AA1A00B9B856 / * btEmptyCollisionAlgorithm . cpp in Sources * / , <nl> B665E2D31AA80A6500DDB1C5 / * CCPUInterParticleColliderTranslator . cpp in Sources * / , <nl> B665E3331AA80A6500DDB1C5 / * CCPUOnEmissionObserver . cpp in Sources * / , <nl> - A045F6E51BA8170A005076C7 / * CCComponentPhysics2d . cpp in Sources * / , <nl> 1A570082180BC5A10088DEC7 / * CCActionManager . cpp in Sources * / , <nl> A0534A681B872FFD006B03E5 / * CCDownloader - apple . mm in Sources * / , <nl> B665E22F1AA80A6500DDB1C5 / * CCPUBoxColliderTranslator . cpp in Sources * / , <nl> mmm a / cocos / 2d / CCComponent . cpp <nl> ppp b / cocos / 2d / CCComponent . cpp <nl> THE SOFTWARE . <nl> <nl> # include " 2d / CCComponent . h " <nl> <nl> - <nl> NS_CC_BEGIN <nl> <nl> - Component : : Component ( void ) <nl> + Component : : Component ( ) <nl> : _owner ( nullptr ) <nl> , _enabled ( true ) <nl> { <nl> Component : : Component ( void ) <nl> # endif <nl> } <nl> <nl> - Component : : ~ Component ( void ) <nl> + Component : : ~ Component ( ) <nl> { <nl> } <nl> <nl> bool Component : : serialize ( void * ar ) <nl> return true ; <nl> } <nl> <nl> - Component * Component : : create ( void ) <nl> + Component * Component : : create ( ) <nl> { <nl> Component * ret = new ( std : : nothrow ) Component ( ) ; <nl> - if ( ret ! = nullptr & & ret - > init ( ) ) <nl> + <nl> + if ( ret & & ret - > init ( ) ) <nl> { <nl> ret - > autorelease ( ) ; <nl> } <nl> Component * Component : : create ( void ) <nl> { <nl> CC_SAFE_DELETE ( ret ) ; <nl> } <nl> - return ret ; <nl> - } <nl> <nl> - const std : : string & Component : : getName ( ) const <nl> - { <nl> - return _name ; <nl> - } <nl> - <nl> - void Component : : setName ( const std : : string & name ) <nl> - { <nl> - _name = name ; <nl> - } <nl> - <nl> - Node * Component : : getOwner ( ) const <nl> - { <nl> - return _owner ; <nl> + return ret ; <nl> } <nl> <nl> void Component : : setOwner ( Node * owner ) <nl> void Component : : setOwner ( Node * owner ) <nl> _owner = owner ; <nl> } <nl> <nl> - bool Component : : isEnabled ( ) const <nl> - { <nl> - return _enabled ; <nl> - } <nl> - <nl> - void Component : : setEnabled ( bool b ) <nl> + void Component : : setEnabled ( bool enabled ) <nl> { <nl> - _enabled = b ; <nl> + _enabled = enabled ; <nl> } <nl> <nl> NS_CC_END <nl> mmm a / cocos / 2d / CCComponent . h <nl> ppp b / cocos / 2d / CCComponent . h <nl> THE SOFTWARE . <nl> # define __CC_FRAMEWORK_COMPONENT_H__ <nl> <nl> / / / @ cond DO_NOT_SHOW <nl> - <nl> + # include < string > <nl> # include " base / CCRef . h " <nl> # include " base / CCScriptSupport . h " <nl> - # include < string > <nl> <nl> NS_CC_BEGIN <nl> <nl> enum { <nl> <nl> class CC_DLL Component : public Ref <nl> { <nl> - CC_CONSTRUCTOR_ACCESS : <nl> - / * * <nl> - * @ js ctor <nl> - * / <nl> - Component ( void ) ; <nl> public : <nl> + static Component * create ( ) ; <nl> + <nl> / * * <nl> * @ js NA <nl> * @ lua NA <nl> * / <nl> - virtual ~ Component ( void ) ; <nl> + virtual ~ Component ( ) ; <nl> + <nl> virtual bool init ( ) ; <nl> <nl> + bool isEnabled ( ) const { return _enabled ; } <nl> + virtual void setEnabled ( bool enabled ) ; <nl> + <nl> + const std : : string & getName ( ) const { return _name ; } <nl> + virtual void setName ( const std : : string & name ) { _name = name ; } <nl> + <nl> + Node * getOwner ( ) const { return _owner ; } <nl> + virtual void setOwner ( Node * owner ) ; <nl> + <nl> + virtual void update ( float delta ) ; <nl> + virtual bool serialize ( void * r ) ; <nl> + <nl> virtual void onEnter ( ) ; <nl> virtual void onExit ( ) ; <nl> virtual void onAdd ( ) ; <nl> virtual void onRemove ( ) ; <nl> - virtual void update ( float delta ) ; <nl> - virtual bool serialize ( void * r ) ; <nl> - virtual bool isEnabled ( ) const ; <nl> - virtual void setEnabled ( bool b ) ; <nl> - static Component * create ( void ) ; <nl> - <nl> - const std : : string & getName ( ) const ; <nl> - void setName ( const std : : string & name ) ; <nl> - <nl> - void setOwner ( Node * pOwner ) ; <nl> - Node * getOwner ( ) const ; <nl> + <nl> + CC_CONSTRUCTOR_ACCESS : <nl> + / * * <nl> + * @ js ctor <nl> + * / <nl> + Component ( ) ; <nl> <nl> protected : <nl> - Node * _owner ; <nl> + Node * _owner ; <nl> std : : string _name ; <nl> bool _enabled ; <nl> <nl> mmm a / cocos / 2d / CCComponentContainer . cpp <nl> ppp b / cocos / 2d / CCComponentContainer . cpp <nl> bool ComponentContainer : : add ( Component * com ) <nl> CCASSERT ( com - > getOwner ( ) = = nullptr , " Component already added . It can ' t be added again " ) ; <nl> do <nl> { <nl> - auto typeName = typeid ( * com ) . name ( ) ; <nl> - if ( _components . find ( typeName ) ! = _components . end ( ) ) <nl> + auto componentName = com - > getName ( ) ; <nl> + <nl> + if ( _componentMap . find ( componentName ) ! = _componentMap . end ( ) ) <nl> { <nl> - CCASSERT ( true , " ComponentContainer already have this kind of component " ) ; <nl> + CCASSERT ( true , " ComponentContainer already have this kind of component " ) ; <nl> break ; <nl> } <nl> + _componentMap [ componentName ] = com ; <nl> + com - > retain ( ) ; <nl> com - > setOwner ( _owner ) ; <nl> - _components . insert ( typeName , com ) ; <nl> - _componentMap [ com - > getName ( ) ] = com ; <nl> com - > onAdd ( ) ; <nl> <nl> ret = true ; <nl> bool ComponentContainer : : add ( Component * com ) <nl> return ret ; <nl> } <nl> <nl> - bool ComponentContainer : : remove ( const std : : string & name ) <nl> + bool ComponentContainer : : remove ( const std : : string & componentName ) <nl> { <nl> bool ret = false ; <nl> do <nl> { <nl> - auto iter = _componentMap . find ( name ) ; <nl> - CC_BREAK_IF ( iter = = _componentMap . end ( ) ) ; <nl> - remove ( iter - > second ) ; <nl> + auto iter = _componentMap . find ( componentName ) ; <nl> + CC_BREAK_IF ( iter = = _componentMap . end ( ) ) ; <nl> + <nl> + auto component = iter - > second ; <nl> + _componentMap . erase ( componentName ) ; <nl> + <nl> + component - > onRemove ( ) ; <nl> + component - > setOwner ( nullptr ) ; <nl> + component - > release ( ) ; <nl> <nl> ret = true ; <nl> } while ( 0 ) ; <nl> bool ComponentContainer : : remove ( const std : : string & name ) <nl> <nl> bool ComponentContainer : : remove ( Component * com ) <nl> { <nl> - bool ret = false ; <nl> - do <nl> - { <nl> - auto iter = _components . find ( typeid ( * com ) . name ( ) ) ; <nl> - if ( iter ! = _components . end ( ) ) <nl> - { <nl> - _componentMap . erase ( com - > getName ( ) ) ; <nl> - <nl> - com - > onRemove ( ) ; <nl> - com - > setOwner ( nullptr ) ; <nl> - _components . erase ( iter ) ; <nl> - } <nl> - <nl> - ret = true ; <nl> - } while ( 0 ) ; <nl> - <nl> - return ret ; <nl> + return remove ( com - > getName ( ) ) ; <nl> } <nl> <nl> void ComponentContainer : : removeAll ( ) <nl> { <nl> if ( ! _componentMap . empty ( ) ) <nl> { <nl> - for ( auto iter = _components . begin ( ) ; iter ! = _components . end ( ) ; + + iter ) <nl> + for ( auto iter = _componentMap . begin ( ) ; iter ! = _componentMap . end ( ) ; + + iter ) <nl> { <nl> - iter - > second - > onRemove ( ) ; <nl> - iter - > second - > setOwner ( nullptr ) ; <nl> + auto component = iter - > second ; <nl> + component - > onRemove ( ) ; <nl> + component - > setOwner ( nullptr ) ; <nl> + component - > release ( ) ; <nl> } <nl> <nl> - _components . clear ( ) ; <nl> _componentMap . clear ( ) ; <nl> _owner - > unscheduleUpdate ( ) ; <nl> } <nl> void ComponentContainer : : removeAll ( ) <nl> <nl> void ComponentContainer : : visit ( float delta ) <nl> { <nl> - if ( ! _components . empty ( ) ) <nl> + if ( ! _componentMap . empty ( ) ) <nl> { <nl> CC_SAFE_RETAIN ( _owner ) ; <nl> - auto iterEnd = _components . end ( ) ; <nl> - for ( auto iter = _components . begin ( ) ; iter ! = iterEnd ; + + iter ) <nl> + auto iterEnd = _componentMap . end ( ) ; <nl> + for ( auto iter = _componentMap . begin ( ) ; iter ! = iterEnd ; + + iter ) <nl> { <nl> iter - > second - > update ( delta ) ; <nl> } <nl> void ComponentContainer : : visit ( float delta ) <nl> <nl> void ComponentContainer : : onEnter ( ) <nl> { <nl> - for ( auto iter = _components . begin ( ) ; iter ! = _components . end ( ) ; + + iter ) <nl> + for ( auto iter = _componentMap . begin ( ) ; iter ! = _componentMap . end ( ) ; + + iter ) <nl> { <nl> iter - > second - > onEnter ( ) ; <nl> } <nl> void ComponentContainer : : onEnter ( ) <nl> <nl> void ComponentContainer : : onExit ( ) <nl> { <nl> - for ( auto iter = _components . begin ( ) ; iter ! = _components . end ( ) ; + + iter ) <nl> + for ( auto iter = _componentMap . begin ( ) ; iter ! = _componentMap . end ( ) ; + + iter ) <nl> { <nl> iter - > second - > onExit ( ) ; <nl> } <nl> mmm a / cocos / 2d / CCComponentContainer . h <nl> ppp b / cocos / 2d / CCComponentContainer . h <nl> class CC_DLL ComponentContainer <nl> * @ js NA <nl> * @ lua NA <nl> * / <nl> - virtual ~ ComponentContainer ( ) ; <nl> - <nl> - template < typename T > <nl> - T * getComponent ( ) const <nl> - { <nl> - auto typeName = typeid ( T ) . name ( ) ; <nl> - auto iter = _components . find ( typeName ) ; <nl> - if ( iter ! = _components . end ( ) ) <nl> - { <nl> - return static_cast < T * > ( iter - > second ) ; <nl> - } <nl> - <nl> - return nullptr ; <nl> - } <nl> + ~ ComponentContainer ( ) ; <nl> <nl> / * * <nl> * @ js getComponent <nl> * / <nl> - virtual Component * get ( const std : : string & name ) const ; <nl> - virtual bool add ( Component * com ) ; <nl> - virtual bool remove ( const std : : string & name ) ; <nl> - virtual bool remove ( Component * com ) ; <nl> - virtual void removeAll ( ) ; <nl> - virtual void visit ( float delta ) ; <nl> - <nl> - virtual void onEnter ( ) ; <nl> - virtual void onExit ( ) ; <nl> + Component * get ( const std : : string & name ) const ; <nl> + <nl> + bool add ( Component * com ) ; <nl> + bool remove ( const std : : string & name ) ; <nl> + bool remove ( Component * com ) ; <nl> + void removeAll ( ) ; <nl> + void visit ( float delta ) ; <nl> <nl> - bool isEmpty ( ) const { return _componentMap . empty ( ) ; } <nl> + void onEnter ( ) ; <nl> + void onExit ( ) ; <nl> <nl> + bool isEmpty ( ) const { return _componentMap . empty ( ) ; } <nl> private : <nl> - Map < std : : string , Component * > _components ; <nl> std : : unordered_map < std : : string , Component * > _componentMap ; <nl> Node * _owner ; <nl> <nl> mmm a / cocos / 2d / CCNode . cpp <nl> ppp b / cocos / 2d / CCNode . cpp <nl> int Node : : s_globalOrderOfArrival = 1 ; <nl> <nl> / / MARK : Constructor , Destructor , Init <nl> <nl> - Node : : Node ( void ) <nl> + Node : : Node ( ) <nl> : _rotationX ( 0 . 0f ) <nl> , _rotationY ( 0 . 0f ) <nl> , _rotationZ_X ( 0 . 0f ) <nl> Node : : Node ( void ) <nl> , _cascadeColorEnabled ( false ) <nl> , _cascadeOpacityEnabled ( false ) <nl> , _cameraMask ( 1 ) <nl> + # if CC_USE_PHYSICS <nl> + , _physicsBody ( nullptr ) <nl> + # endif <nl> { <nl> / / set default scheduler and actionManager <nl> _director = Director : : getInstance ( ) ; <nl> mmm a / cocos / 2d / CCNode . h <nl> ppp b / cocos / 2d / CCNode . h <nl> class GLProgram ; <nl> class GLProgramState ; <nl> class Material ; <nl> class Camera ; <nl> + class PhysicsBody ; <nl> <nl> / * * <nl> * @ addtogroup _2d <nl> class CC_DLL Node : public Ref <nl> * @ return The Component by name . <nl> * / <nl> Component * getComponent ( const std : : string & name ) ; <nl> - <nl> - / * * <nl> - * Get a component by the type T . <nl> - * @ lua NA <nl> - * @ js NA <nl> - * <nl> - * @ return The component that match the type T . <nl> - * / <nl> - template < typename T > <nl> - T * getComponent ( ) const <nl> - { <nl> - if ( _componentContainer ) <nl> - return _componentContainer - > getComponent < T > ( ) ; <nl> - else <nl> - return nullptr ; <nl> - } <nl> <nl> / * * <nl> * Adds a component . <nl> class CC_DLL Node : public Ref <nl> std : : function < void ( ) > _onEnterTransitionDidFinishCallback ; <nl> std : : function < void ( ) > _onExitTransitionDidStartCallback ; <nl> <nl> + / / Physics : remaining backwardly compatible <nl> + # if CC_USE_PHYSICS <nl> + PhysicsBody * _physicsBody ; <nl> + public : <nl> + void setPhysicsBody ( Component * physicsBody ) <nl> + { <nl> + addComponent ( physicsBody ) ; <nl> + } <nl> + PhysicsBody * getPhysicsBody ( ) const { return _physicsBody ; } <nl> + <nl> + friend class PhysicsBody ; <nl> + # endif <nl> + <nl> private : <nl> CC_DISALLOW_COPY_AND_ASSIGN ( Node ) ; <nl> } ; <nl> mmm a / cocos / 2d / CCScene . cpp <nl> ppp b / cocos / 2d / CCScene . cpp <nl> THE SOFTWARE . <nl> # include " deprecated / CCString . h " <nl> <nl> # if CC_USE_PHYSICS <nl> - # include " physics / CCPhysicsManager . h " <nl> + # include " physics / CCPhysicsWorld . h " <nl> # endif <nl> <nl> # if CC_USE_3D_PHYSICS & & CC_ENABLE_BULLET_INTEGRATION <nl> Scene : : Scene ( ) <nl> _navMeshDebugCamera = nullptr ; <nl> # endif <nl> # if CC_USE_PHYSICS <nl> - _physicsManager = nullptr ; <nl> + _physicsWorld = nullptr ; <nl> # endif <nl> _ignoreAnchorPointForPosition = true ; <nl> setAnchorPoint ( Vec2 ( 0 . 5f , 0 . 5f ) ) ; <nl> Scene : : ~ Scene ( ) <nl> CC_SAFE_RELEASE ( _event ) ; <nl> <nl> # if CC_USE_PHYSICS <nl> - delete _physicsManager ; <nl> + delete _physicsWorld ; <nl> # endif <nl> } <nl> <nl> Scene * Scene : : createWithPhysics ( ) <nl> <nl> bool Scene : : initWithPhysics ( ) <nl> { <nl> - _physicsManager = new ( std : : nothrow ) PhysicsManager ( this ) ; <nl> - _physicsWorld = _physicsManager - > getPhysicsWorld ( ) ; <nl> + # if CC_USE_PHYSICS <nl> + _physicsWorld = PhysicsWorld : : construct ( this ) ; <nl> + # endif <nl> <nl> bool ret = false ; <nl> do <nl> bool Scene : : initWithPhysics ( ) <nl> void Scene : : stepPhysicsAndNavigation ( float deltaTime ) <nl> { <nl> # if CC_USE_PHYSICS <nl> - if ( _physicsManager ) <nl> - _physicsManager - > update ( deltaTime ) ; <nl> + if ( _physicsWorld & & _physicsWorld - > isAutoStep ( ) ) <nl> + _physicsWorld - > update ( deltaTime ) ; <nl> # endif <nl> <nl> # if CC_USE_3D_PHYSICS & & CC_ENABLE_BULLET_INTEGRATION <nl> mmm a / cocos / 2d / CCScene . h <nl> ppp b / cocos / 2d / CCScene . h <nl> class EventListenerCustom ; <nl> class EventCustom ; <nl> # if CC_USE_PHYSICS <nl> class PhysicsWorld ; <nl> - class PhysicsManager ; <nl> # endif <nl> # if CC_USE_3D_PHYSICS & & CC_ENABLE_BULLET_INTEGRATION <nl> class Physics3DWorld ; <nl> class CC_DLL Scene : public Node <nl> * @ js NA <nl> * / <nl> inline PhysicsWorld * getPhysicsWorld ( ) const { return _physicsWorld ; } <nl> - <nl> - / * * <nl> - * Get the ` PhysicsManager ` belongs to this ` Scene ` . <nl> - * <nl> - * @ return PhysicsManager of the scene . <nl> - * @ js NA <nl> - * / <nl> - PhysicsManager * getPhysicsManager ( ) const { return _physicsManager ; } <nl> # endif <nl> <nl> # if CC_USE_3D_PHYSICS & & CC_ENABLE_BULLET_INTEGRATION <nl> class CC_DLL Scene : public Node <nl> <nl> # if CC_USE_PHYSICS <nl> PhysicsWorld * _physicsWorld ; <nl> - PhysicsManager * _physicsManager ; <nl> # endif <nl> <nl> # if CC_USE_3D_PHYSICS & & CC_ENABLE_BULLET_INTEGRATION <nl> mmm a / cocos / 2d / libcocos2d . vcxproj <nl> ppp b / cocos / 2d / libcocos2d . vcxproj <nl> xcopy / Y / Q " $ ( ProjectDir ) . . \ . . \ external \ chipmunk \ prebuilt \ win32 \ release - lib \ * . * <nl> < ClCompile Include = " . . \ physics3d \ CCPhysics3DShape . cpp " / > <nl> < ClCompile Include = " . . \ physics3d \ CCPhysics3DWorld . cpp " / > <nl> < ClCompile Include = " . . \ physics3d \ CCPhysicsSprite3D . cpp " / > <nl> - < ClCompile Include = " . . \ physics \ CCComponentPhysics2d . cpp " / > <nl> < ClCompile Include = " . . \ physics \ CCPhysicsBody . cpp " / > <nl> < ClCompile Include = " . . \ physics \ CCPhysicsContact . cpp " / > <nl> < ClCompile Include = " . . \ physics \ CCPhysicsJoint . cpp " / > <nl> - < ClCompile Include = " . . \ physics \ CCPhysicsManager . cpp " / > <nl> < ClCompile Include = " . . \ physics \ CCPhysicsShape . cpp " / > <nl> < ClCompile Include = " . . \ physics \ CCPhysicsWorld . cpp " / > <nl> < ClCompile Include = " . . \ platform \ CCFileUtils . cpp " / > <nl> xcopy / Y / Q " $ ( ProjectDir ) . . \ . . \ external \ chipmunk \ prebuilt \ win32 \ release - lib \ * . * <nl> < ClCompile Include = " CCDrawNode . cpp " / > <nl> < ClCompile Include = " CCFastTMXLayer . cpp " / > <nl> < ClCompile Include = " CCFastTMXTiledMap . cpp " / > <nl> - < ClCompile Include = " CCFont . cpp " / > <nl> < ClCompile Include = " CCFontAtlas . cpp " / > <nl> < ClCompile Include = " CCFontAtlasCache . cpp " / > <nl> < ClCompile Include = " CCFontCharMap . cpp " / > <nl> xcopy / Y / Q " $ ( ProjectDir ) . . \ . . \ external \ chipmunk \ prebuilt \ win32 \ release - lib \ * . * <nl> < ClInclude Include = " . . \ physics3d \ CCPhysics3DShape . h " / > <nl> < ClInclude Include = " . . \ physics3d \ CCPhysics3DWorld . h " / > <nl> < ClInclude Include = " . . \ physics3d \ CCPhysicsSprite3D . h " / > <nl> - < ClInclude Include = " . . \ physics \ CCComponentPhysics2d . h " / > <nl> < ClInclude Include = " . . \ physics \ CCPhysicsBody . h " / > <nl> < ClInclude Include = " . . \ physics \ CCPhysicsContact . h " / > <nl> < ClInclude Include = " . . \ physics \ CCPhysicsHelper . h " / > <nl> < ClInclude Include = " . . \ physics \ CCPhysicsJoint . h " / > <nl> - < ClInclude Include = " . . \ physics \ CCPhysicsManager . h " / > <nl> < ClInclude Include = " . . \ physics \ CCPhysicsShape . h " / > <nl> < ClInclude Include = " . . \ physics \ CCPhysicsWorld . h " / > <nl> < ClInclude Include = " . . \ platform \ CCApplicationProtocol . h " / > <nl> xcopy / Y / Q " $ ( ProjectDir ) . . \ . . \ external \ chipmunk \ prebuilt \ win32 \ release - lib \ * . * <nl> < ClInclude Include = " CCLabel . h " / > <nl> < ClInclude Include = " CCLabelAtlas . h " / > <nl> < ClInclude Include = " CCLabelBMFont . h " / > <nl> - < ClInclude Include = " CCLabelTextFormatter . h " / > <nl> < ClInclude Include = " CCLabelTTF . h " / > <nl> < ClInclude Include = " CCLayer . h " / > <nl> < ClInclude Include = " CCLight . h " / > <nl> mmm a / cocos / 2d / libcocos2d . vcxproj . filters <nl> ppp b / cocos / 2d / libcocos2d . vcxproj . filters <nl> <nl> < / Filter > <nl> < / ItemGroup > <nl> < ItemGroup > <nl> - < ClCompile Include = " . . \ physics \ CCComponentPhysics2d . cpp " > <nl> - < Filter > physics < / Filter > <nl> - < / ClCompile > <nl> < ClCompile Include = " . . \ physics \ CCPhysicsBody . cpp " > <nl> < Filter > physics < / Filter > <nl> < / ClCompile > <nl> <nl> < ClCompile Include = " . . \ physics \ CCPhysicsJoint . cpp " > <nl> < Filter > physics < / Filter > <nl> < / ClCompile > <nl> - < ClCompile Include = " . . \ physics \ CCPhysicsManager . cpp " > <nl> - < Filter > physics < / Filter > <nl> - < / ClCompile > <nl> < ClCompile Include = " . . \ physics \ CCPhysicsShape . cpp " > <nl> < Filter > physics < / Filter > <nl> < / ClCompile > <nl> <nl> < ClCompile Include = " CCDrawNode . cpp " > <nl> < Filter > 2d < / Filter > <nl> < / ClCompile > <nl> - < ClCompile Include = " CCFont . cpp " > <nl> - < Filter > 2d < / Filter > <nl> - < / ClCompile > <nl> < ClCompile Include = " CCFontAtlas . cpp " > <nl> < Filter > 2d < / Filter > <nl> < / ClCompile > <nl> <nl> < / ClCompile > <nl> < / ItemGroup > <nl> < ItemGroup > <nl> - < ClInclude Include = " . . \ physics \ CCComponentPhysics2d . h " > <nl> - < Filter > physics < / Filter > <nl> - < / ClInclude > <nl> < ClInclude Include = " . . \ physics \ CCPhysicsBody . h " > <nl> < Filter > physics < / Filter > <nl> < / ClInclude > <nl> <nl> < ClInclude Include = " . . \ physics \ CCPhysicsJoint . h " > <nl> < Filter > physics < / Filter > <nl> < / ClInclude > <nl> - < ClInclude Include = " . . \ physics \ CCPhysicsManager . h " > <nl> - < Filter > physics < / Filter > <nl> - < / ClInclude > <nl> < ClInclude Include = " . . \ physics \ CCPhysicsShape . h " > <nl> < Filter > physics < / Filter > <nl> < / ClInclude > <nl> <nl> < ClInclude Include = " CCLabelBMFont . h " > <nl> < Filter > 2d < / Filter > <nl> < / ClInclude > <nl> - < ClInclude Include = " CCLabelTextFormatter . h " > <nl> - < Filter > 2d < / Filter > <nl> - < / ClInclude > <nl> < ClInclude Include = " CCLabelTTF . h " > <nl> < Filter > 2d < / Filter > <nl> < / ClInclude > <nl> mmm a / cocos / 2d / libcocos2d_8_1 / libcocos2d_8_1 / libcocos2d_8_1 . Shared / libcocos2d_8_1 . Shared . vcxitems <nl> ppp b / cocos / 2d / libcocos2d_8_1 / libcocos2d_8_1 / libcocos2d_8_1 . Shared / libcocos2d_8_1 . Shared . vcxitems <nl> <nl> < ClInclude Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ . . \ . . \ physics3d \ CCPhysics3DShape . h " / > <nl> < ClInclude Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ . . \ . . \ physics3d \ CCPhysics3DWorld . h " / > <nl> < ClInclude Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ . . \ . . \ physics3d \ CCPhysicsSprite3D . h " / > <nl> - < ClInclude Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ . . \ . . \ physics \ CCComponentPhysics2d . h " / > <nl> < ClInclude Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ . . \ . . \ physics \ CCPhysicsBody . h " / > <nl> < ClInclude Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ . . \ . . \ physics \ CCPhysicsContact . h " / > <nl> < ClInclude Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ . . \ . . \ physics \ CCPhysicsHelper . h " / > <nl> < ClInclude Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ . . \ . . \ physics \ CCPhysicsJoint . h " / > <nl> - < ClInclude Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ . . \ . . \ physics \ CCPhysicsManager . h " / > <nl> < ClInclude Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ . . \ . . \ physics \ CCPhysicsShape . h " / > <nl> < ClInclude Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ . . \ . . \ physics \ CCPhysicsWorld . h " / > <nl> < ClInclude Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ . . \ . . \ platform \ CCApplication . h " / > <nl> <nl> < ClCompile Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ . . \ . . \ physics3d \ CCPhysics3DShape . cpp " / > <nl> < ClCompile Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ . . \ . . \ physics3d \ CCPhysics3DWorld . cpp " / > <nl> < ClCompile Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ . . \ . . \ physics3d \ CCPhysicsSprite3D . cpp " / > <nl> - < ClCompile Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ . . \ . . \ physics \ CCComponentPhysics2d . cpp " / > <nl> < ClCompile Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ . . \ . . \ physics \ CCPhysicsBody . cpp " / > <nl> < ClCompile Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ . . \ . . \ physics \ CCPhysicsContact . cpp " / > <nl> < ClCompile Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ . . \ . . \ physics \ CCPhysicsJoint . cpp " / > <nl> - < ClCompile Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ . . \ . . \ physics \ CCPhysicsManager . cpp " / > <nl> < ClCompile Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ . . \ . . \ physics \ CCPhysicsShape . cpp " / > <nl> < ClCompile Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ . . \ . . \ physics \ CCPhysicsWorld . cpp " / > <nl> < ClCompile Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ . . \ . . \ platform \ CCFileUtils . cpp " / > <nl> mmm a / cocos / 2d / libcocos2d_8_1 / libcocos2d_8_1 / libcocos2d_8_1 . Shared / libcocos2d_8_1 . Shared . vcxitems . filters <nl> ppp b / cocos / 2d / libcocos2d_8_1 / libcocos2d_8_1 / libcocos2d_8_1 . Shared / libcocos2d_8_1 . Shared . vcxitems . filters <nl> <nl> < ClInclude Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ . . \ . . \ physics \ CCPhysicsWorld . h " > <nl> < Filter > physics < / Filter > <nl> < / ClInclude > <nl> - < ClInclude Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ . . \ . . \ physics \ CCComponentPhysics2d . h " > <nl> - < Filter > physics < / Filter > <nl> - < / ClInclude > <nl> - < ClInclude Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ . . \ . . \ physics \ CCPhysicsManager . h " > <nl> - < Filter > physics < / Filter > <nl> - < / ClInclude > <nl> < ClInclude Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ . . \ . . \ editor - support \ cocostudio \ CocosStudioExport . h " > <nl> < Filter > cocostudio < / Filter > <nl> < / ClInclude > <nl> <nl> < ClCompile Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ . . \ . . \ physics \ CCPhysicsWorld . cpp " > <nl> < Filter > physics < / Filter > <nl> < / ClCompile > <nl> - < ClCompile Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ . . \ . . \ physics \ CCComponentPhysics2d . cpp " > <nl> - < Filter > physics < / Filter > <nl> - < / ClCompile > <nl> - < ClCompile Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ . . \ . . \ physics \ CCPhysicsManager . cpp " > <nl> - < Filter > physics < / Filter > <nl> - < / ClCompile > <nl> < ClCompile Include = " $ ( MSBuildThisFileDirectory ) . . \ . . \ . . \ . . \ editor - support \ cocostudio \ CCActionFrame . cpp " > <nl> < Filter > cocostudio \ action < / Filter > <nl> < / ClCompile > <nl> mmm a / cocos / Android . mk <nl> ppp b / cocos / Android . mk <nl> physics / CCPhysicsContact . cpp \ <nl> physics / CCPhysicsJoint . cpp \ <nl> physics / CCPhysicsShape . cpp \ <nl> physics / CCPhysicsWorld . cpp \ <nl> - physics / CCComponentPhysics2d . cpp \ <nl> - physics / CCPhysicsManager . cpp \ <nl> physics3d / CCPhysics3D . cpp \ <nl> physics3d / CCPhysics3DWorld . cpp \ <nl> physics3d / CCPhysics3DComponent . cpp \ <nl> mmm a / cocos / cocos2d . h <nl> ppp b / cocos / cocos2d . h <nl> THE SOFTWARE . <nl> # include " physics / CCPhysicsJoint . h " <nl> # include " physics / CCPhysicsShape . h " <nl> # include " physics / CCPhysicsWorld . h " <nl> - # include " physics / CCComponentPhysics2d . h " <nl> - # include " physics / CCPhysicsManager . h " <nl> <nl> / / platform <nl> # include " platform / CCCommon . h " <nl> mmm a / cocos / editor - support / cocostudio / CCComAttribute . cpp <nl> ppp b / cocos / editor - support / cocostudio / CCComAttribute . cpp <nl> using namespace cocos2d ; <nl> namespace cocostudio { <nl> <nl> IMPLEMENT_CLASS_COMPONENT_INFO ( ComAttribute ) <nl> - ComAttribute : : ComAttribute ( void ) <nl> + <nl> + const std : : string ComAttribute : : COMPONENT_NAME = " CCComAttribute " ; <nl> + <nl> + ComAttribute : : ComAttribute ( ) <nl> { <nl> - _name = " CCComAttribute " ; <nl> + _name = COMPONENT_NAME ; <nl> } <nl> <nl> - ComAttribute : : ~ ComAttribute ( void ) <nl> + ComAttribute : : ~ ComAttribute ( ) <nl> { <nl> _dict . clear ( ) ; <nl> } <nl> std : : string ComAttribute : : getString ( const std : : string & key , const std : : string & d <nl> return DICTOOL - > getStringValue_json ( _doc , key . c_str ( ) ) ; <nl> } <nl> <nl> - ComAttribute * ComAttribute : : create ( void ) <nl> + ComAttribute * ComAttribute : : create ( ) <nl> { <nl> ComAttribute * pRet = new ( std : : nothrow ) ComAttribute ( ) ; <nl> if ( pRet & & pRet - > init ( ) ) <nl> mmm a / cocos / editor - support / cocostudio / CCComAttribute . h <nl> ppp b / cocos / editor - support / cocostudio / CCComAttribute . h <nl> class CC_STUDIO_DLL ComAttribute : public cocos2d : : Component <nl> virtual ~ ComAttribute ( void ) ; <nl> <nl> public : <nl> + const static std : : string COMPONENT_NAME ; <nl> + <nl> static ComAttribute * create ( void ) ; <nl> virtual bool init ( ) override ; <nl> virtual bool serialize ( void * r ) override ; <nl> mmm a / cocos / editor - support / cocostudio / CCComAudio . cpp <nl> ppp b / cocos / editor - support / cocostudio / CCComAudio . cpp <nl> THE SOFTWARE . <nl> namespace cocostudio { <nl> <nl> IMPLEMENT_CLASS_COMPONENT_INFO ( ComAudio ) <nl> - ComAudio : : ComAudio ( void ) <nl> + <nl> + const std : : string ComAudio : : COMPONENT_NAME = " CCComAudio " ; <nl> + <nl> + ComAudio : : ComAudio ( ) <nl> : _filePath ( " " ) <nl> , _loop ( false ) <nl> { <nl> - _name = " CCComAudio " ; <nl> + _name = COMPONENT_NAME ; <nl> } <nl> <nl> - ComAudio : : ~ ComAudio ( void ) <nl> + ComAudio : : ~ ComAudio ( ) <nl> { <nl> <nl> } <nl> void ComAudio : : onRemove ( ) <nl> stopAllEffects ( ) ; <nl> } <nl> <nl> - bool ComAudio : : isEnabled ( ) const <nl> - { <nl> - return _enabled ; <nl> - } <nl> - <nl> - void ComAudio : : setEnabled ( bool b ) <nl> - { <nl> - _enabled = b ; <nl> - } <nl> - <nl> - <nl> bool ComAudio : : serialize ( void * r ) <nl> { <nl> bool ret = false ; <nl> bool ComAudio : : serialize ( void * r ) <nl> setLoop ( loop ) ; <nl> playBackgroundMusic ( filePath . c_str ( ) , loop ) ; <nl> } <nl> - else if ( strcmp ( className , " CCComAudio " ) = = 0 ) <nl> + else if ( strcmp ( className , COMPONENT_NAME . c_str ( ) ) = = 0 ) <nl> { <nl> preloadEffect ( filePath . c_str ( ) ) ; <nl> } <nl> bool ComAudio : : serialize ( void * r ) <nl> return ret ; <nl> } <nl> <nl> - ComAudio * ComAudio : : create ( void ) <nl> + ComAudio * ComAudio : : create ( ) <nl> { <nl> ComAudio * pRet = new ( std : : nothrow ) ComAudio ( ) ; <nl> if ( pRet & & pRet - > init ( ) ) <nl> mmm a / cocos / editor - support / cocostudio / CCComAudio . h <nl> ppp b / cocos / editor - support / cocostudio / CCComAudio . h <nl> namespace cocostudio { <nl> <nl> class CC_STUDIO_DLL ComAudio : public cocos2d : : Component <nl> { <nl> - <nl> DECLARE_CLASS_COMPONENT_INFO <nl> - <nl> public : <nl> + const static std : : string COMPONENT_NAME ; <nl> + <nl> / * * <nl> * @ js ctor <nl> * / <nl> - ComAudio ( void ) ; <nl> + ComAudio ( ) ; <nl> / * * <nl> * @ js NA <nl> * @ lua NA <nl> * / <nl> - virtual ~ ComAudio ( void ) ; <nl> + virtual ~ ComAudio ( ) ; <nl> <nl> public : <nl> + static ComAudio * create ( ) ; <nl> + <nl> virtual bool init ( ) override ; <nl> / * * <nl> * @ js NA <nl> class CC_STUDIO_DLL ComAudio : public cocos2d : : Component <nl> * @ lua NA <nl> * / <nl> virtual void onRemove ( ) override ; <nl> - virtual bool isEnabled ( ) const override ; <nl> - virtual void setEnabled ( bool b ) override ; <nl> - virtual bool serialize ( void * r ) override ; <nl> <nl> - static ComAudio * create ( void ) ; <nl> - <nl> + virtual bool serialize ( void * r ) override ; <nl> public : <nl> void end ( ) ; <nl> void preloadBackgroundMusic ( const char * pszFilePath ) ; <nl> mmm a / cocos / editor - support / cocostudio / CCComController . cpp <nl> ppp b / cocos / editor - support / cocostudio / CCComController . cpp <nl> THE SOFTWARE . <nl> namespace cocostudio { <nl> <nl> IMPLEMENT_CLASS_COMPONENT_INFO ( ComController ) <nl> - ComController : : ComController ( void ) <nl> + <nl> + const std : : string ComController : : COMPONENT_NAME = " CCComController " ; <nl> + <nl> + ComController : : ComController ( ) <nl> { <nl> - _name = " CCComController " ; <nl> + _name = COMPONENT_NAME ; <nl> } <nl> <nl> - ComController : : ~ ComController ( void ) <nl> + ComController : : ~ ComController ( ) <nl> { <nl> } <nl> <nl> void ComController : : update ( float delta ) <nl> { <nl> } <nl> <nl> - bool ComController : : isEnabled ( ) const <nl> - { <nl> - return _enabled ; <nl> - } <nl> - <nl> - void ComController : : setEnabled ( bool b ) <nl> - { <nl> - _enabled = b ; <nl> - } <nl> - <nl> - ComController * ComController : : create ( void ) <nl> + ComController * ComController : : create ( ) <nl> { <nl> ComController * pRet = new ( std : : nothrow ) ComController ( ) ; <nl> if ( pRet & & pRet - > init ( ) ) <nl> mmm a / cocos / editor - support / cocostudio / CCComController . h <nl> ppp b / cocos / editor - support / cocostudio / CCComController . h <nl> namespace cocostudio { <nl> <nl> class CC_STUDIO_DLL ComController : public cocos2d : : Component , public InputDelegate <nl> { <nl> - <nl> DECLARE_CLASS_COMPONENT_INFO <nl> public : <nl> / * * <nl> * @ js ctor <nl> * / <nl> - ComController ( void ) ; <nl> + ComController ( ) ; <nl> <nl> public : <nl> + const static std : : string COMPONENT_NAME ; <nl> + <nl> + static ComController * create ( ) ; <nl> + <nl> / * * <nl> * @ js NA <nl> * @ lua NA <nl> * / <nl> - virtual ~ ComController ( void ) ; <nl> + virtual ~ ComController ( ) ; <nl> + <nl> virtual bool init ( ) override ; <nl> + <nl> / * * <nl> * @ js NA <nl> * @ lua NA <nl> * / <nl> virtual void onEnter ( ) override ; <nl> + <nl> / * * <nl> * @ js NA <nl> * @ lua NA <nl> * / <nl> virtual void onExit ( ) override ; <nl> + <nl> / * * <nl> * @ js NA <nl> * @ lua NA <nl> * / <nl> virtual void onAdd ( ) override ; <nl> + <nl> / * * <nl> * @ js NA <nl> * @ lua NA <nl> * / <nl> virtual void onRemove ( ) override ; <nl> virtual void update ( float delta ) override ; <nl> - virtual bool isEnabled ( ) const override ; <nl> - virtual void setEnabled ( bool b ) override ; <nl> - <nl> - static ComController * create ( void ) ; <nl> } ; <nl> <nl> } <nl> mmm a / cocos / editor - support / cocostudio / CCComExtensionData . cpp <nl> ppp b / cocos / editor - support / cocostudio / CCComExtensionData . cpp <nl> <nl> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> <nl> # include " CCComExtensionData . h " <nl> - <nl> # include " cocostudio / ActionTimeline / CCActionTimeline . h " <nl> <nl> - <nl> namespace cocostudio <nl> { <nl> IMPLEMENT_CLASS_COMPONENT_INFO ( ComExtensionData ) <nl> + <nl> + const std : : string ComExtensionData : : COMPONENT_NAME = " ComExtensionData " ; <nl> + <nl> ComExtensionData : : ComExtensionData ( ) <nl> : _customProperty ( " " ) <nl> , _timelineData ( nullptr ) <nl> { <nl> - _name = " ComExtensionData " ; <nl> + _name = COMPONENT_NAME ; <nl> } <nl> <nl> ComExtensionData : : ~ ComExtensionData ( ) <nl> mmm a / cocos / editor - support / cocostudio / CCComExtensionData . h <nl> ppp b / cocos / editor - support / cocostudio / CCComExtensionData . h <nl> namespace cocostudio <nl> { <nl> DECLARE_CLASS_COMPONENT_INFO <nl> public : <nl> + const static std : : string COMPONENT_NAME ; <nl> + <nl> / * * <nl> * @ js NA <nl> * @ lua NA <nl> mmm a / cocos / editor - support / cocostudio / CCComRender . cpp <nl> ppp b / cocos / editor - support / cocostudio / CCComRender . cpp <nl> using namespace cocos2d ; <nl> namespace cocostudio { <nl> <nl> IMPLEMENT_CLASS_COMPONENT_INFO ( ComRender ) <nl> - ComRender : : ComRender ( void ) <nl> + <nl> + const std : : string ComRender : : COMPONENT_NAME = " CCComRender " ; <nl> + <nl> + ComRender : : ComRender ( ) <nl> : _render ( nullptr ) <nl> { <nl> - _name = " CCComRender " ; <nl> + _name = COMPONENT_NAME ; <nl> } <nl> <nl> - <nl> ComRender : : ComRender ( cocos2d : : Node * node , const char * comName ) <nl> { <nl> if ( node ! = nullptr ) <nl> ComRender : : ComRender ( cocos2d : : Node * node , const char * comName ) <nl> _name . assign ( comName ) ; <nl> } <nl> <nl> - ComRender : : ~ ComRender ( void ) <nl> + ComRender : : ~ ComRender ( ) <nl> { <nl> CC_SAFE_RELEASE_NULL ( _render ) ; <nl> } <nl> bool ComRender : : serialize ( void * r ) <nl> return ret ; <nl> } <nl> <nl> - ComRender * ComRender : : create ( void ) <nl> + ComRender * ComRender : : create ( ) <nl> { <nl> ComRender * ret = new ( std : : nothrow ) ComRender ( ) ; <nl> if ( ret ! = nullptr & & ret - > init ( ) ) <nl> mmm a / cocos / editor - support / cocostudio / CCComRender . h <nl> ppp b / cocos / editor - support / cocostudio / CCComRender . h <nl> namespace cocostudio { <nl> class CC_STUDIO_DLL ComRender : public cocos2d : : Component <nl> { <nl> DECLARE_CLASS_COMPONENT_INFO <nl> - CC_CONSTRUCTOR_ACCESS : <nl> - / * * <nl> - * @ js ctor <nl> - * / <nl> - ComRender ( void ) ; <nl> - ComRender ( cocos2d : : Node * node , const char * comName ) ; <nl> - / * * <nl> - * @ js NA <nl> - * @ lua NA <nl> - * / <nl> - virtual ~ ComRender ( void ) ; <nl> - <nl> + <nl> public : <nl> + const static std : : string COMPONENT_NAME ; <nl> + <nl> + static ComRender * create ( ) ; <nl> + static ComRender * create ( cocos2d : : Node * node , const char * comName ) ; <nl> + <nl> / * * <nl> * @ js NA <nl> * @ lua NA <nl> class CC_STUDIO_DLL ComRender : public cocos2d : : Component <nl> virtual cocos2d : : Node * getNode ( ) ; <nl> virtual void setNode ( cocos2d : : Node * node ) ; <nl> <nl> - static ComRender * create ( void ) ; <nl> - static ComRender * create ( cocos2d : : Node * node , const char * comName ) ; <nl> + CC_CONSTRUCTOR_ACCESS : <nl> + / * * <nl> + * @ js ctor <nl> + * / <nl> + ComRender ( ) ; <nl> + ComRender ( cocos2d : : Node * node , const char * comName ) ; <nl> + / * * <nl> + * @ js NA <nl> + * @ lua NA <nl> + * / <nl> + virtual ~ ComRender ( ) ; <nl> + <nl> private : <nl> bool readJson ( const std : : string & fileName , rapidjson : : Document & doc ) ; <nl> <nl> - private : <nl> cocos2d : : Node * _render ; <nl> } ; <nl> <nl> mmm a / cocos / editor - support / cocostudio / CCSSceneReader . cpp <nl> ppp b / cocos / editor - support / cocostudio / CCSSceneReader . cpp <nl> std : : string SceneReader : : getComponentClassName ( const std : : string & name ) <nl> { <nl> comName = " ComRender " ; <nl> } <nl> - else if ( name = = " CCComAudio " | | name = = " CCBackgroundAudio " ) <nl> + else if ( name = = ComAudio : : COMPONENT_NAME | | name = = " CCBackgroundAudio " ) <nl> { <nl> comName = " ComAudio " ; <nl> } <nl> - else if ( name = = " CCComController " ) <nl> + else if ( name = = ComController : : COMPONENT_NAME ) <nl> { <nl> comName = " ComController " ; <nl> } <nl> - else if ( name = = " CCComAttribute " ) <nl> + else if ( name = = ComAttribute : : COMPONENT_NAME ) <nl> { <nl> comName = " ComAttribute " ; <nl> } <nl> mmm a / cocos / editor - support / cocostudio / WidgetReader / GameNode3DReader / GameNode3DReader . cpp <nl> ppp b / cocos / editor - support / cocostudio / WidgetReader / GameNode3DReader / GameNode3DReader . cpp <nl> namespace cocostudio <nl> <nl> std : : string customProperty = options - > customProperty ( ) - > c_str ( ) ; <nl> ComExtensionData * extensionData = ComExtensionData : : create ( ) ; <nl> - extensionData - > setCustomProperty ( customProperty ) ; \ <nl> - if ( node - > getComponent ( " ComExtensionData " ) ) <nl> + extensionData - > setCustomProperty ( customProperty ) ; <nl> + if ( node - > getComponent ( ComExtensionData : : COMPONENT_NAME ) ) <nl> { <nl> - node - > removeComponent ( " ComExtensionData " ) ; <nl> + node - > removeComponent ( ComExtensionData : : COMPONENT_NAME ) ; <nl> } <nl> node - > addComponent ( extensionData ) ; <nl> } <nl> mmm a / cocos / editor - support / cocostudio / WidgetReader / NodeReader / NodeReader . cpp <nl> ppp b / cocos / editor - support / cocostudio / WidgetReader / NodeReader / NodeReader . cpp <nl> namespace cocostudio <nl> ComExtensionData * extensionData = ComExtensionData : : create ( ) ; <nl> extensionData - > setCustomProperty ( customProperty ) ; <nl> extensionData - > setActionTag ( actionTag ) ; <nl> - if ( node - > getComponent ( " ComExtensionData " ) ) <nl> + if ( node - > getComponent ( ComExtensionData : : COMPONENT_NAME ) ) <nl> { <nl> - node - > removeComponent ( " ComExtensionData " ) ; <nl> + node - > removeComponent ( ComExtensionData : : COMPONENT_NAME ) ; <nl> } <nl> node - > addComponent ( extensionData ) ; <nl> <nl> mmm a / cocos / editor - support / cocostudio / WidgetReader / WidgetReader . cpp <nl> ppp b / cocos / editor - support / cocostudio / WidgetReader / WidgetReader . cpp <nl> namespace cocostudio <nl> ComExtensionData * extensionData = ComExtensionData : : create ( ) ; <nl> extensionData - > setCustomProperty ( customProperty ) ; <nl> extensionData - > setActionTag ( actionTag ) ; <nl> - if ( node - > getComponent ( " ComExtensionData " ) ) <nl> + if ( node - > getComponent ( ComExtensionData : : COMPONENT_NAME ) ) <nl> { <nl> - node - > removeComponent ( extensionData ) ; <nl> + node - > removeComponent ( ComExtensionData : : COMPONENT_NAME ) ; <nl> } <nl> node - > addComponent ( extensionData ) ; <nl> <nl> deleted file mode 100644 <nl> index 08c4c9c3b86c . . 000000000000 <nl> mmm a / cocos / physics / CCComponentPhysics2d . cpp <nl> ppp / dev / null <nl> <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> - Copyright ( c ) 2015 Chukong Technologies Inc . <nl> - <nl> - http : / / www . cocos2d - x . org <nl> - <nl> - Permission is hereby granted , free of charge , to any person obtaining a copy <nl> - of this software and associated documentation files ( the " Software " ) , to deal <nl> - in the Software without restriction , including without limitation the rights <nl> - to use , copy , modify , merge , publish , distribute , sublicense , and / or sell <nl> - copies of the Software , and to permit persons to whom the Software is <nl> - furnished to do so , subject to the following conditions : <nl> - <nl> - The above copyright notice and this permission notice shall be included in <nl> - all copies or substantial portions of the Software . <nl> - <nl> - THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , EXPRESS OR <nl> - IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY , <nl> - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL THE <nl> - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER <nl> - LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , <nl> - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN <nl> - THE SOFTWARE . <nl> - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - <nl> - # include " base / ccConfig . h " / / to include defination of CC_USE_PHYSICS <nl> - # if CC_USE_PHYSICS <nl> - <nl> - # include " physics / CCComponentPhysics2d . h " <nl> - # include " physics / CCPhysicsBody . h " <nl> - # include " physics / CCPhysicsManager . h " <nl> - # include " 2d / CCNode . h " <nl> - # include " base / CCDirector . h " <nl> - <nl> - NS_CC_BEGIN <nl> - <nl> - const std : : string ComponentPhysics2d : : COMPONENT_NAME = " physics2d " ; <nl> - <nl> - ComponentPhysics2d * ComponentPhysics2d : : create ( ) <nl> - { <nl> - return create ( nullptr ) ; <nl> - } <nl> - <nl> - ComponentPhysics2d * ComponentPhysics2d : : create ( PhysicsBody * physicsBody ) <nl> - { <nl> - auto ret = new ( std : : nothrow ) ComponentPhysics2d ( physicsBody ) ; <nl> - if ( ret ) <nl> - ret - > autorelease ( ) ; <nl> - <nl> - return ret ; <nl> - } <nl> - <nl> - ComponentPhysics2d : : ComponentPhysics2d ( ) <nl> - : _physicsBody ( nullptr ) <nl> - , _physicsRotation ( 0 . 0f ) <nl> - , _ownerOriginRotation ( 0 . 0f ) <nl> - { <nl> - _name = COMPONENT_NAME ; <nl> - } <nl> - <nl> - ComponentPhysics2d : : ComponentPhysics2d ( PhysicsBody * physicsBody ) <nl> - : _physicsRotation ( 0 . 0f ) <nl> - , _ownerOriginRotation ( 0 . 0f ) <nl> - , _physicsBody ( nullptr ) / / should set to null to invoke setPhysicsBody ( ) <nl> - { <nl> - _name = COMPONENT_NAME ; <nl> - setPhysicsBody ( physicsBody ) ; <nl> - } <nl> - <nl> - ComponentPhysics2d : : ~ ComponentPhysics2d ( ) <nl> - { <nl> - removePhysicsBody ( ) ; <nl> - } <nl> - <nl> - / / true if two Vec3 equals , false else <nl> - bool ComponentPhysics2d : : isVec3Equal ( const cocos2d : : Vec3 & v1 , const cocos2d : : Vec3 & v2 ) const <nl> - { <nl> - return fabs ( v1 . x - v2 . x ) < FLT_EPSILON & & <nl> - fabs ( v1 . x - v2 . y ) < FLT_EPSILON ; <nl> - } <nl> - <nl> - void ComponentPhysics2d : : beforeSimulation ( ) <nl> - { <nl> - if ( nullptr = = _physicsBody ) <nl> - return ; <nl> - <nl> - _nodeToWorldTransform = _owner - > getNodeToWorldTransform ( ) ; <nl> - <nl> - / / set scale <nl> - _nodeToWorldTransform . getScale ( & _scale ) ; <nl> - if ( ! isVec3Equal ( _scale , _recordScale ) ) <nl> - { <nl> - _physicsBody - > setScale ( _scale . x , _scale . y ) ; <nl> - _recordScale = _scale ; <nl> - } <nl> - <nl> - / / set rotation <nl> - if ( _owner - > getParent ( ) ) <nl> - { <nl> - _physicsRotation = getPhysicsRotation ( _owner - > getParent ( ) ) + _owner - > getRotation ( ) ; <nl> - } <nl> - _physicsBody - > setRotation ( _physicsRotation - _ownerOriginRotation ) ; <nl> - <nl> - / / set position <nl> - auto worldPosition = _ownerCenterOffset ; <nl> - _nodeToWorldTransform . transformPoint ( & worldPosition ) ; <nl> - _physicsBody - > setPosition ( Vec2 ( worldPosition . x , worldPosition . y ) ) ; <nl> - <nl> - getParentToWorldTransform ( ) . getInversed ( ) . transformPoint ( & worldPosition ) ; <nl> - _offset . x = worldPosition . x - _owner - > getPosition ( ) . x ; <nl> - _offset . y = worldPosition . y - _owner - > getPosition ( ) . y ; <nl> - } <nl> - <nl> - void ComponentPhysics2d : : afterSimulation ( ) <nl> - { <nl> - if ( nullptr = = _physicsBody ) <nl> - return ; <nl> - <nl> - / / set Node position <nl> - auto worldPosition = _physicsBody - > getPosition ( ) ; <nl> - Vec3 positionInParent ( worldPosition . x , worldPosition . y , 0 ) ; <nl> - getParentToWorldTransform ( ) . getInversed ( ) . transformPoint ( & positionInParent ) ; <nl> - _owner - > setPosition ( positionInParent . x - _offset . x , positionInParent . y - _offset . y ) ; <nl> - <nl> - / / set Node rotation <nl> - _physicsRotation = _physicsBody - > getRotation ( ) ; <nl> - _owner - > setRotation ( _physicsRotation - getPhysicsRotation ( _owner - > getParent ( ) ) + _ownerOriginRotation ) ; <nl> - } <nl> - <nl> - void ComponentPhysics2d : : setPhysicsBody ( PhysicsBody * physicsBody ) <nl> - { <nl> - removeFromPhysicsManager ( ) ; <nl> - <nl> - if ( physicsBody ! = _physicsBody ) <nl> - { <nl> - if ( nullptr ! = _physicsBody ) <nl> - { <nl> - _physicsBody - > release ( ) ; <nl> - _physicsBody - > _componentBelongsTo = nullptr ; <nl> - } <nl> - <nl> - / / two components should not share the same physics body <nl> - if ( physicsBody & & physicsBody - > _componentBelongsTo ! = nullptr ) <nl> - physicsBody - > _componentBelongsTo - > _physicsBody = nullptr ; <nl> - <nl> - _physicsBody = physicsBody ; <nl> - <nl> - if ( nullptr ! = _physicsBody ) <nl> - { <nl> - _physicsBody - > retain ( ) ; <nl> - _physicsBody - > _componentBelongsTo = this ; <nl> - } <nl> - } <nl> - <nl> - addToPhysicsManager ( ) ; <nl> - } <nl> - <nl> - PhysicsBody * ComponentPhysics2d : : getPhysicsBody ( ) const <nl> - { <nl> - return _physicsBody ; <nl> - } <nl> - <nl> - void ComponentPhysics2d : : setEnabled ( bool value ) <nl> - { <nl> - Component : : setEnabled ( value ) ; <nl> - <nl> - if ( value ) <nl> - addToPhysicsManager ( ) ; <nl> - else <nl> - removeFromPhysicsManager ( ) ; <nl> - } <nl> - <nl> - void ComponentPhysics2d : : onEnter ( ) <nl> - { <nl> - addToPhysicsManager ( ) ; <nl> - } <nl> - <nl> - void ComponentPhysics2d : : onExit ( ) <nl> - { <nl> - removeFromPhysicsManager ( ) ; <nl> - } <nl> - <nl> - void ComponentPhysics2d : : onAdd ( ) <nl> - { <nl> - auto contentSize = _owner - > getContentSize ( ) ; <nl> - _ownerCenterOffset . x = 0 . 5 * contentSize . width ; <nl> - _ownerCenterOffset . y = 0 . 5 * contentSize . height ; <nl> - <nl> - _ownerOriginRotation = _owner - > getRotation ( ) ; <nl> - <nl> - / / component may be added after onEnter ( ) has been invoked , so we should add <nl> - / / this line to make sure physics body is added to physics world <nl> - addToPhysicsManager ( ) ; <nl> - } <nl> - <nl> - void ComponentPhysics2d : : onRemove ( ) <nl> - { <nl> - removePhysicsBody ( ) ; <nl> - } <nl> - <nl> - void ComponentPhysics2d : : removePhysicsBody ( ) <nl> - { <nl> - removeFromPhysicsManager ( ) ; <nl> - <nl> - if ( _physicsBody ) <nl> - { <nl> - _physicsBody - > _componentBelongsTo = nullptr ; <nl> - _physicsBody - > release ( ) ; <nl> - _physicsBody = nullptr ; <nl> - } <nl> - } <nl> - <nl> - void ComponentPhysics2d : : addToPhysicsManager ( ) <nl> - { <nl> - if ( _owner ) <nl> - { <nl> - auto scene = _owner - > getScene ( ) ; <nl> - if ( scene ) <nl> - scene - > getPhysicsManager ( ) - > addPhysicsComponent ( this ) ; <nl> - } <nl> - <nl> - } <nl> - <nl> - void ComponentPhysics2d : : removeFromPhysicsManager ( ) <nl> - { <nl> - if ( _owner ) <nl> - { <nl> - auto scene = _owner - > getScene ( ) ; <nl> - if ( scene ) <nl> - scene - > getPhysicsManager ( ) - > removePhysicsComponent ( this ) ; <nl> - } <nl> - } <nl> - <nl> - Mat4 ComponentPhysics2d : : getParentToWorldTransform ( ) const <nl> - { <nl> - if ( _owner - > getParent ( ) ) <nl> - return _owner - > getParent ( ) - > getNodeToWorldTransform ( ) ; <nl> - else <nl> - return _owner - > getNodeToWorldTransform ( ) ; <nl> - } <nl> - <nl> - float ComponentPhysics2d : : getPhysicsRotation ( Node * node ) const <nl> - { <nl> - if ( ! node ) <nl> - return 0 . 0f ; <nl> - <nl> - auto physicsComponent = node - > getComponent < ComponentPhysics2d > ( ) ; <nl> - if ( physicsComponent ) <nl> - { <nl> - return physicsComponent - > _physicsRotation ; <nl> - } <nl> - else <nl> - { <nl> - auto parent = node - > getParent ( ) ; <nl> - if ( parent ) <nl> - return getPhysicsRotation ( parent ) + node - > getRotation ( ) ; <nl> - else <nl> - return 0 . 0f ; <nl> - } <nl> - } <nl> - <nl> - NS_CC_END <nl> - <nl> - # endif / / CC_USE_PHYSICS <nl> deleted file mode 100644 <nl> index 6814b883ef2f . . 000000000000 <nl> mmm a / cocos / physics / CCComponentPhysics2d . h <nl> ppp / dev / null <nl> <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> - Copyright ( c ) 2015 Chukong Technologies Inc . <nl> - <nl> - http : / / www . cocos2d - x . org <nl> - <nl> - Permission is hereby granted , free of charge , to any person obtaining a copy <nl> - of this software and associated documentation files ( the " Software " ) , to deal <nl> - in the Software without restriction , including without limitation the rights <nl> - to use , copy , modify , merge , publish , distribute , sublicense , and / or sell <nl> - copies of the Software , and to permit persons to whom the Software is <nl> - furnished to do so , subject to the following conditions : <nl> - <nl> - The above copyright notice and this permission notice shall be included in <nl> - all copies or substantial portions of the Software . <nl> - <nl> - THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , EXPRESS OR <nl> - IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY , <nl> - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL THE <nl> - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER <nl> - LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , <nl> - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN <nl> - THE SOFTWARE . <nl> - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - <nl> - # pragma once <nl> - <nl> - # include " base / ccConfig . h " / / to include defination of CC_USE_PHYSICS <nl> - # if CC_USE_PHYSICS <nl> - <nl> - # include " platform / CCPlatformMacros . h " <nl> - # include " 2d / CCComponent . h " <nl> - <nl> - NS_CC_BEGIN <nl> - <nl> - / * * <nl> - * @ addtogroup physics <nl> - * @ { <nl> - * @ addtogroup physics_2d <nl> - * @ { <nl> - * / <nl> - <nl> - class PhysicsBody ; <nl> - <nl> - class CC_DLL ComponentPhysics2d : public Component <nl> - { <nl> - public : <nl> - / * * <nl> - * Create a physics component without physics body . Can set phyiscs body later with setPhysicsBody ( ) . <nl> - * I am not sure if we need this function , because i think physics body is needed when creating a <nl> - * physics component . But i think it is needed by editor , so i keep this function . <nl> - * <nl> - * @ return A pointer of ` ComponentPhysics2d ` that is autoreleased . <nl> - * / <nl> - static ComponentPhysics2d * create ( ) ; <nl> - / * * <nl> - * Create a physics component with physics body . <nl> - * <nl> - * @ param physicsBody The physics body that belongs to this component . <nl> - * @ return A pointer of ` ComponentPhysics2d ` that is autoreleased . <nl> - * / <nl> - static ComponentPhysics2d * create ( PhysicsBody * physicsBody ) ; <nl> - <nl> - virtual ~ ComponentPhysics2d ( ) ; <nl> - <nl> - / / / @ cond DO_NOT_SHOW <nl> - <nl> - / * * <nl> - * Synchronize Node ' s status ( position , rotation , scale ) to phyiscs body . <nl> - * It is invoked before physics simulation . <nl> - * <nl> - * @ warning Don ' t invoke this funciton by yourself . <nl> - * / <nl> - void beforeSimulation ( ) ; <nl> - / * * <nl> - * Synchronize physics body ' s status ( position , rotation ) to phyiscs body . <nl> - * It is invoked after physics simulation . <nl> - * <nl> - * @ warning Don ' t invoke this funciton by yourself . <nl> - * / <nl> - void afterSimulation ( ) ; <nl> - <nl> - / / / @ endcond DO_NOT_SHOW <nl> - <nl> - / * * <nl> - * Set physics body of this physics component . If the physics body is set to <nl> - * another physics component before , will set another physics component ' s physics <nl> - * body to null . <nl> - * <nl> - * @ param physicsBody The physics body belongs to this component . <nl> - * / <nl> - void setPhysicsBody ( PhysicsBody * physicsBody ) ; <nl> - / * * <nl> - * Get the physics body of this component . <nl> - * <nl> - * @ return The physics body of this component . <nl> - * / <nl> - PhysicsBody * getPhysicsBody ( ) const ; <nl> - <nl> - virtual void setEnabled ( bool value ) override ; <nl> - virtual void onEnter ( ) override ; <nl> - virtual void onExit ( ) override ; <nl> - virtual void onAdd ( ) override ; <nl> - virtual void onRemove ( ) override ; <nl> - <nl> - public : <nl> - const static std : : string COMPONENT_NAME ; <nl> - <nl> - CC_CONSTRUCTOR_ACCESS : <nl> - ComponentPhysics2d ( ) ; <nl> - ComponentPhysics2d ( PhysicsBody * phsicsBody ) ; <nl> - <nl> - private : <nl> - void removePhysicsBody ( ) ; <nl> - void addToPhysicsManager ( ) ; <nl> - void removeFromPhysicsManager ( ) ; <nl> - Mat4 getParentToWorldTransform ( ) const ; <nl> - float getPhysicsRotation ( Node * node ) const ; <nl> - bool isVec3Equal ( const Vec3 & v1 , const Vec3 & v2 ) const ; <nl> - <nl> - private : <nl> - / / this physic body of this component <nl> - PhysicsBody * _physicsBody ; <nl> - / / offset between owner ' s center point and down left point <nl> - Vec3 _ownerCenterOffset ; <nl> - Mat4 _nodeToWorldTransform ; <nl> - / / offset of owner ' s center point and anchor point in parent coordinate <nl> - Vec2 _offset ; <nl> - float _physicsRotation ; <nl> - / / the rotation of owner when the component is added to , the value will not change <nl> - float _ownerOriginRotation ; <nl> - Vec3 _recordScale ; <nl> - Vec3 _scale ; <nl> - } ; <nl> - <nl> - / * * @ } * / <nl> - / * * @ } * / <nl> - <nl> - NS_CC_END <nl> - <nl> - # endif / / CC_USE_PHYSICS <nl> mmm a / cocos / physics / CCPhysicsBody . cpp <nl> ppp b / cocos / physics / CCPhysicsBody . cpp <nl> <nl> # include " physics / CCPhysicsJoint . h " <nl> # include " physics / CCPhysicsWorld . h " <nl> # include " physics / CCPhysicsHelper . h " <nl> - # include " physics / CCComponentPhysics2d . h " <nl> <nl> static inline void cpBodyUpdateVelocityWithoutGravity ( cpBody * body , cpVect gravity , cpFloat damping , cpFloat dt ) <nl> { <nl> static inline void cpBodyUpdateVelocityWithoutGravity ( cpBody * body , cpVect gravi <nl> NS_CC_BEGIN <nl> extern const float PHYSICS_INFINITY ; <nl> <nl> + const std : : string PhysicsBody : : COMPONENT_NAME = " PhysicsBody " ; <nl> + <nl> namespace <nl> { <nl> static const float MASS_DEFAULT = 1 . 0 ; <nl> PhysicsBody : : PhysicsBody ( ) <nl> : _world ( nullptr ) <nl> , _cpBody ( nullptr ) <nl> , _dynamic ( true ) <nl> - , _enabled ( true ) <nl> , _rotationEnabled ( true ) <nl> , _gravityEnabled ( true ) <nl> , _massDefault ( true ) <nl> PhysicsBody : : PhysicsBody ( ) <nl> , _rotationOffset ( 0 ) <nl> , _recordedRotation ( 0 . 0f ) <nl> , _recordedAngle ( 0 . 0 ) <nl> - , _componentBelongsTo ( nullptr ) <nl> , _massSetByUser ( false ) <nl> , _momentSetByUser ( false ) <nl> + , _recordScaleX ( 1 . f ) <nl> + , _recordScaleY ( 1 . f ) <nl> { <nl> } <nl> <nl> PhysicsBody * PhysicsBody : : createEdgeBox ( const Size & size , const PhysicsMaterial & <nl> } <nl> <nl> CC_SAFE_DELETE ( body ) ; <nl> - <nl> + <nl> return nullptr ; <nl> } <nl> <nl> bool PhysicsBody : : init ( ) <nl> { <nl> do <nl> { <nl> - _cpBody = cpBodyNew ( PhysicsHelper : : float2cpfloat ( _mass ) , PhysicsHelper : : float2cpfloat ( _moment ) ) ; <nl> + _cpBody = cpBodyNew ( _mass , _moment ) ; <nl> <nl> CC_BREAK_IF ( _cpBody = = nullptr ) ; <nl> <nl> void PhysicsBody : : setGravityEnable ( bool enable ) <nl> } <nl> } <nl> <nl> - void PhysicsBody : : setPosition ( const Vec2 & position ) <nl> - { <nl> - cpBodySetPos ( _cpBody , PhysicsHelper : : point2cpv ( position + _positionOffset ) ) ; <nl> - } <nl> - <nl> void PhysicsBody : : setRotation ( float rotation ) <nl> { <nl> _recordedRotation = rotation ; <nl> void PhysicsBody : : setScale ( float scaleX , float scaleY ) <nl> } <nl> } <nl> <nl> + void PhysicsBody : : setPosition ( float positionX , float positionY ) <nl> + { <nl> + cpVect tt ; <nl> + <nl> + tt . x = positionX + _positionOffset . x ; <nl> + tt . y = positionY + _positionOffset . y ; <nl> + <nl> + cpBodySetPos ( _cpBody , tt ) ; <nl> + } <nl> + <nl> Vec2 PhysicsBody : : getPosition ( ) const <nl> { <nl> return Vec2 ( _cpBody - > p . x - _positionOffset . x , _cpBody - > p . y - _positionOffset . y ) ; <nl> } <nl> <nl> + void PhysicsBody : : setPositionOffset ( const Vec2 & position ) <nl> + { <nl> + if ( ! _positionOffset . equals ( position ) ) <nl> + { <nl> + Vec2 pos = getPosition ( ) ; <nl> + _positionOffset = position ; <nl> + setPosition ( pos . x , pos . y ) ; <nl> + } <nl> + } <nl> + <nl> float PhysicsBody : : getRotation ( ) <nl> { <nl> if ( _recordedAngle ! = cpBodyGetAngle ( _cpBody ) ) { <nl> PhysicsShape * PhysicsBody : : addShape ( PhysicsShape * shape , bool addMassAndMoment / * <nl> return shape ; <nl> } <nl> <nl> - void PhysicsBody : : applyForce ( const Vect & force ) <nl> - { <nl> - applyForce ( force , Vec2 : : ZERO ) ; <nl> - } <nl> - <nl> - void PhysicsBody : : applyForce ( const Vect & force , const Vec2 & offset ) <nl> + void PhysicsBody : : applyForce ( const Vec2 & force , const Vec2 & offset ) <nl> { <nl> if ( _dynamic & & _mass ! = PHYSICS_INFINITY ) <nl> { <nl> void PhysicsBody : : resetForces ( ) <nl> cpBodyResetForces ( _cpBody ) ; <nl> } <nl> <nl> - void PhysicsBody : : applyImpulse ( const Vect & impulse ) <nl> - { <nl> - applyImpulse ( impulse , Vec2 ( ) ) ; <nl> - } <nl> - <nl> - void PhysicsBody : : applyImpulse ( const Vect & impulse , const Vec2 & offset ) <nl> + void PhysicsBody : : applyImpulse ( const Vec2 & impulse , const Vec2 & offset ) <nl> { <nl> cpBodyApplyImpulse ( _cpBody , PhysicsHelper : : point2cpv ( impulse ) , PhysicsHelper : : point2cpv ( offset ) ) ; <nl> } <nl> <nl> void PhysicsBody : : applyTorque ( float torque ) <nl> { <nl> - cpBodySetTorque ( _cpBody , PhysicsHelper : : float2cpfloat ( torque ) ) ; <nl> + cpBodySetTorque ( _cpBody , torque ) ; <nl> } <nl> <nl> void PhysicsBody : : setMass ( float mass ) <nl> void PhysicsBody : : addMoment ( float moment ) <nl> / / the static body ' s mass and moment is always infinity <nl> if ( _rotationEnabled & & _dynamic ) <nl> { <nl> - cpBodySetMoment ( _cpBody , PhysicsHelper : : float2cpfloat ( _moment ) ) ; <nl> + cpBodySetMoment ( _cpBody , _moment ) ; <nl> } <nl> } <nl> <nl> void PhysicsBody : : setAngularVelocity ( float velocity ) <nl> return ; <nl> } <nl> <nl> - cpBodySetAngVel ( _cpBody , PhysicsHelper : : float2cpfloat ( velocity ) ) ; <nl> + cpBodySetAngVel ( _cpBody , velocity ) ; <nl> } <nl> <nl> float PhysicsBody : : getAngularVelocity ( ) <nl> float PhysicsBody : : getAngularVelocity ( ) <nl> <nl> void PhysicsBody : : setVelocityLimit ( float limit ) <nl> { <nl> - cpBodySetVelLimit ( _cpBody , PhysicsHelper : : float2cpfloat ( limit ) ) ; <nl> + cpBodySetVelLimit ( _cpBody , limit ) ; <nl> } <nl> <nl> float PhysicsBody : : getVelocityLimit ( ) <nl> float PhysicsBody : : getVelocityLimit ( ) <nl> <nl> void PhysicsBody : : setAngularVelocityLimit ( float limit ) <nl> { <nl> - cpBodySetAngVelLimit ( _cpBody , PhysicsHelper : : float2cpfloat ( limit ) ) ; <nl> + cpBodySetAngVelLimit ( _cpBody , limit ) ; <nl> } <nl> <nl> float PhysicsBody : : getAngularVelocityLimit ( ) <nl> void PhysicsBody : : setMoment ( float moment ) <nl> / / the static body ' s mass and moment is always infinity <nl> if ( _rotationEnabled & & _dynamic ) <nl> { <nl> - cpBodySetMoment ( _cpBody , PhysicsHelper : : float2cpfloat ( _moment ) ) ; <nl> + cpBodySetMoment ( _cpBody , _moment ) ; <nl> } <nl> } <nl> <nl> void PhysicsBody : : removeAllShapes ( bool reduceMassAndMoment / * = true * / ) <nl> <nl> void PhysicsBody : : removeFromWorld ( ) <nl> { <nl> - if ( _world ) <nl> - { <nl> - _world - > removeBody ( this ) ; <nl> - } <nl> - } <nl> - <nl> - Node * PhysicsBody : : getNode ( ) const <nl> - { <nl> - if ( _componentBelongsTo ) <nl> - return _componentBelongsTo - > getOwner ( ) ; <nl> - else <nl> - return nullptr ; <nl> + removeFromPhysicsWorld ( ) ; <nl> } <nl> <nl> - void PhysicsBody : : setEnable ( bool enable ) <nl> + void PhysicsBody : : setEnabled ( bool enable ) <nl> { <nl> if ( _enabled ! = enable ) <nl> { <nl> void PhysicsBody : : setResting ( bool rest ) const <nl> if ( rest & & ! isResting ( ) ) <nl> { <nl> cpBodySleep ( _cpBody ) ; <nl> - } else if ( ! rest & & isResting ( ) ) <nl> + } <nl> + else if ( ! rest & & isResting ( ) ) <nl> { <nl> cpBodyActivate ( _cpBody ) ; <nl> } <nl> int PhysicsBody : : getGroup ( ) const <nl> } <nl> } <nl> <nl> - void PhysicsBody : : setPositionOffset ( const Vec2 & position ) <nl> - { <nl> - if ( ! _positionOffset . equals ( position ) ) <nl> - { <nl> - Vec2 pos = getPosition ( ) ; <nl> - _positionOffset = position ; <nl> - setPosition ( pos ) ; <nl> - } <nl> - } <nl> - <nl> void PhysicsBody : : setRotationOffset ( float rotation ) <nl> { <nl> if ( std : : abs ( _rotationOffset - rotation ) > 0 . 5f ) <nl> Vec2 PhysicsBody : : local2World ( const Vec2 & point ) <nl> return PhysicsHelper : : cpv2point ( cpBodyLocal2World ( _cpBody , PhysicsHelper : : point2cpv ( point ) ) ) ; <nl> } <nl> <nl> + void PhysicsBody : : beforeSimulation ( const Mat4 & parentToWorldTransform , const Mat4 & nodeToWorldTransform , float scaleX , float scaleY , float rotation ) <nl> + { <nl> + if ( _recordScaleX ! = scaleX | | _recordScaleY ! = scaleY ) <nl> + { <nl> + _recordScaleX = scaleX ; <nl> + _recordScaleY = scaleY ; <nl> + setScale ( scaleX , scaleY ) ; <nl> + } <nl> + <nl> + / / set rotation <nl> + if ( _recordedRotation ! = rotation ) <nl> + { <nl> + setRotation ( rotation ) ; <nl> + } <nl> + <nl> + / / set position <nl> + auto worldPosition = _ownerCenterOffset ; <nl> + nodeToWorldTransform . transformVector ( worldPosition . x , worldPosition . y , worldPosition . z , 1 . f , & worldPosition ) ; <nl> + setPosition ( worldPosition . x , worldPosition . y ) ; <nl> + <nl> + _recordPosX = worldPosition . x ; <nl> + _recordPosY = worldPosition . y ; <nl> + <nl> + if ( _owner - > getAnchorPoint ( ) ! = Vec2 : : ANCHOR_MIDDLE ) <nl> + { <nl> + parentToWorldTransform . getInversed ( ) . transformVector ( worldPosition . x , worldPosition . y , worldPosition . z , 1 . f , & worldPosition ) ; <nl> + _offset . x = worldPosition . x - _owner - > getPositionX ( ) ; <nl> + _offset . y = worldPosition . y - _owner - > getPositionY ( ) ; <nl> + } <nl> + } <nl> + <nl> + void PhysicsBody : : afterSimulation ( const Mat4 & parentToWorldTransform , float parentRotation ) <nl> + { <nl> + / / set Node position <nl> + auto tmp = getPosition ( ) ; <nl> + Vec3 positionInParent ( tmp . x , tmp . y , 0 . f ) ; <nl> + if ( _recordPosX ! = positionInParent . x | | _recordPosY ! = positionInParent . y ) <nl> + { <nl> + parentToWorldTransform . getInversed ( ) . transformVector ( positionInParent . x , positionInParent . y , positionInParent . z , 1 . f , & positionInParent ) ; <nl> + _owner - > setPosition ( positionInParent . x - _offset . x , positionInParent . y - _offset . y ) ; <nl> + } <nl> + <nl> + / / set Node rotation <nl> + _owner - > setRotation ( getRotation ( ) - parentRotation ) ; <nl> + } <nl> + <nl> + void PhysicsBody : : onEnter ( ) <nl> + { <nl> + addToPhysicsWorld ( ) ; <nl> + } <nl> + <nl> + void PhysicsBody : : onExit ( ) <nl> + { <nl> + removeFromPhysicsWorld ( ) ; <nl> + } <nl> + <nl> + void PhysicsBody : : onAdd ( ) <nl> + { <nl> + _owner - > _physicsBody = this ; <nl> + auto contentSize = _owner - > getContentSize ( ) ; <nl> + _ownerCenterOffset . x = 0 . 5 * contentSize . width ; <nl> + _ownerCenterOffset . y = 0 . 5 * contentSize . height ; <nl> + <nl> + setRotationOffset ( _owner - > getRotation ( ) ) ; <nl> + <nl> + / / component may be added after onEnter ( ) has been invoked , so we should add <nl> + / / this line to make sure physics body is added to physics world <nl> + addToPhysicsWorld ( ) ; <nl> + } <nl> + <nl> + void PhysicsBody : : onRemove ( ) <nl> + { <nl> + removeFromPhysicsWorld ( ) ; <nl> + } <nl> + <nl> + void PhysicsBody : : addToPhysicsWorld ( ) <nl> + { <nl> + if ( _owner ) <nl> + { <nl> + auto scene = _owner - > getScene ( ) ; <nl> + if ( scene ) <nl> + scene - > getPhysicsWorld ( ) - > addBody ( this ) ; <nl> + } <nl> + } <nl> + <nl> + void PhysicsBody : : removeFromPhysicsWorld ( ) <nl> + { <nl> + if ( _world ) <nl> + { <nl> + _world - > removeBody ( this ) ; <nl> + _world = nullptr ; <nl> + } <nl> + } <nl> + <nl> NS_CC_END <nl> <nl> # endif / / CC_USE_PHYSICS <nl> mmm a / cocos / physics / CCPhysicsBody . h <nl> ppp b / cocos / physics / CCPhysicsBody . h <nl> <nl> # include " base / ccConfig . h " <nl> # if CC_USE_PHYSICS <nl> <nl> - # include " base / CCRef . h " <nl> + # include " 2d / CCComponent . h " <nl> # include " math / CCGeometry . h " <nl> # include " physics / CCPhysicsShape . h " <nl> # include " base / CCVector . h " <nl> struct cpBody ; <nl> NS_CC_BEGIN <nl> <nl> class Node ; <nl> - class Sprite ; <nl> class PhysicsWorld ; <nl> class PhysicsJoint ; <nl> - class ComponentPhysics2d ; <nl> <nl> typedef Vec2 Vect ; <nl> <nl> - <nl> const PhysicsMaterial PHYSICSBODY_MATERIAL_DEFAULT ( 0 . 1f , 0 . 5f , 0 . 5f ) ; <nl> <nl> / * * <nl> const PhysicsMaterial PHYSICSBODY_MATERIAL_DEFAULT ( 0 . 1f , 0 . 5f , 0 . 5f ) ; <nl> * If you create body with createEdgeXXX , the mass and moment will be PHYSICS_INFINITY by default . And it ' s a static body . <nl> * You can change mass and moment with setMass ( ) and setMoment ( ) . And you can change the body to be dynamic or static by use function setDynamic ( ) . <nl> * / <nl> - class CC_DLL PhysicsBody : public Ref <nl> + class CC_DLL PhysicsBody : public Component <nl> { <nl> public : <nl> + const static std : : string COMPONENT_NAME ; <nl> + <nl> / * * <nl> - Create a body with default mass and moment . <nl> - <nl> - This default mass value is 1 . 0 . <nl> - This default moment value is 200 . <nl> - @ return An autoreleased PhysicsBody object pointer . <nl> + * Create a body with default mass and moment . <nl> + * <nl> + * This default mass value is 1 . 0 . <nl> + * This default moment value is 200 . <nl> + * @ return An autoreleased PhysicsBody object pointer . <nl> * / <nl> static PhysicsBody * create ( ) ; <nl> <nl> / * * <nl> - Create a body with mass and default moment . <nl> - <nl> - @ param mass This body ' s mass . <nl> - @ return An autoreleased PhysicsBody object pointer . <nl> + * Create a body with mass and default moment . <nl> + * <nl> + * @ param mass This body ' s mass . <nl> + * @ return An autoreleased PhysicsBody object pointer . <nl> * / <nl> static PhysicsBody * create ( float mass ) ; <nl> <nl> / * * <nl> - Create a body with mass and moment . <nl> - <nl> - @ param mass This body ' s mass . <nl> - @ param moment This body ' s moment . <nl> - @ return An autoreleased PhysicsBody object pointer . <nl> + * Create a body with mass and moment . <nl> + * <nl> + * @ param mass This body ' s mass . <nl> + * @ param moment This body ' s moment . <nl> + * @ return An autoreleased PhysicsBody object pointer . <nl> * / <nl> static PhysicsBody * create ( float mass , float moment ) ; <nl> <nl> - / * * <nl> - Create a body contains a circle . <nl> - <nl> - @ param radius A float number , it is the circle ' s radius . <nl> - @ param material A PhysicsMaterial object , the default value is PHYSICSSHAPE_MATERIAL_DEFAULT . <nl> - @ param offset A Vec2 object , it is the offset from the body ’ s center of gravity in body local coordinates . <nl> - @ return An autoreleased PhysicsBody object pointer . <nl> + / * * <nl> + * Create a body contains a circle . <nl> + * <nl> + * @ param radius A float number , it is the circle ' s radius . <nl> + * @ param material A PhysicsMaterial object , the default value is PHYSICSSHAPE_MATERIAL_DEFAULT . <nl> + * @ param offset A Vec2 object , it is the offset from the body ’ s center of gravity in body local coordinates . <nl> + * @ return An autoreleased PhysicsBody object pointer . <nl> * / <nl> static PhysicsBody * createCircle ( float radius , const PhysicsMaterial & material = PHYSICSBODY_MATERIAL_DEFAULT , const Vec2 & offset = Vec2 : : ZERO ) ; <nl> - / * * <nl> + / * * <nl> * Create a body contains a box shape . <nl> * <nl> * @ param size Size contains this box ' s width and height . <nl> class CC_DLL PhysicsBody : public Ref <nl> * @ return An autoreleased PhysicsBody object pointer . <nl> * / <nl> static PhysicsBody * createBox ( const Size & size , const PhysicsMaterial & material = PHYSICSBODY_MATERIAL_DEFAULT , const Vec2 & offset = Vec2 : : ZERO ) ; <nl> - <nl> + <nl> / * * <nl> * @ brief Create a body contains a polygon shape . <nl> * <nl> class CC_DLL PhysicsBody : public Ref <nl> * @ return An autoreleased PhysicsBody object pointer . <nl> * / <nl> static PhysicsBody * createPolygon ( const Vec2 * points , int count , const PhysicsMaterial & material = PHYSICSBODY_MATERIAL_DEFAULT , const Vec2 & offset = Vec2 : : ZERO ) ; <nl> - <nl> - / * * <nl> - Create a body contains a EdgeSegment shape . <nl> - <nl> + <nl> + / * * <nl> + * Create a body contains a EdgeSegment shape . <nl> + * <nl> * @ param a It ' s the edge ' s begin position . <nl> * @ param b It ' s the edge ' s end position . <nl> * @ param material A PhysicsMaterial object , the default value is PHYSICSSHAPE_MATERIAL_DEFAULT . <nl> class CC_DLL PhysicsBody : public Ref <nl> * @ return An autoreleased PhysicsBody object pointer . <nl> * / <nl> static PhysicsBody * createEdgeSegment ( const Vec2 & a , const Vec2 & b , const PhysicsMaterial & material = PHYSICSBODY_MATERIAL_DEFAULT , float border = 1 ) ; <nl> - <nl> - / * * <nl> - Create a body contains a EdgeBox shape . <nl> <nl> + / * * <nl> + * Create a body contains a EdgeBox shape . <nl> * @ param size Size contains this box ' s width and height . <nl> * @ param material A PhysicsMaterial object , the default value is PHYSICSSHAPE_MATERIAL_DEFAULT . <nl> * @ param border It ' s a edge ' s border width . <nl> class CC_DLL PhysicsBody : public Ref <nl> * @ return An autoreleased PhysicsBody object pointer . <nl> * / <nl> static PhysicsBody * createEdgeBox ( const Size & size , const PhysicsMaterial & material = PHYSICSBODY_MATERIAL_DEFAULT , float border = 1 , const Vec2 & offset = Vec2 : : ZERO ) ; <nl> - <nl> - / * * <nl> - Create a body contains a EdgePolygon shape . <nl> - <nl> + <nl> + / * * <nl> + * Create a body contains a EdgePolygon shape . <nl> + * <nl> * @ param points Points is an array of Vec2 structs defining a convex hull with a clockwise winding . <nl> * @ param count An interger number , contains the count of the points array . <nl> * @ param material A PhysicsMaterial object , the default value is PHYSICSSHAPE_MATERIAL_DEFAULT . <nl> class CC_DLL PhysicsBody : public Ref <nl> * @ return An autoreleased PhysicsBody object pointer . <nl> * / <nl> static PhysicsBody * createEdgePolygon ( const Vec2 * points , int count , const PhysicsMaterial & material = PHYSICSBODY_MATERIAL_DEFAULT , float border = 1 ) ; <nl> - <nl> - / * * <nl> - Create a body contains a EdgeChain shape . <nl> - <nl> + <nl> + / * * <nl> + * Create a body contains a EdgeChain shape . <nl> + * <nl> * @ param points A Vec2 object pointer , it contains an array of points . <nl> * @ param count An interger number , contains the count of the points array . <nl> * @ param material A PhysicsMaterial object , the default value is PHYSICSSHAPE_MATERIAL_DEFAULT . <nl> * @ param border It ' s a edge ' s border width . <nl> - * @ return An autoreleased PhysicsBody object pointer . <nl> + * @ return An autoreleased PhysicsBody object pointer . <nl> * / <nl> static PhysicsBody * createEdgeChain ( const Vec2 * points , int count , const PhysicsMaterial & material = PHYSICSBODY_MATERIAL_DEFAULT , float border = 1 ) ; <nl> - <nl> + <nl> / * * <nl> * @ brief Add a shape to body . <nl> * @ param shape The shape to be added . <nl> class CC_DLL PhysicsBody : public Ref <nl> void removeShape ( int tag , bool reduceMassAndMoment = true ) ; <nl> <nl> / * * <nl> - Remove all shapes . <nl> - <nl> + * Remove all shapes . <nl> + * <nl> * @ param reduceMassAndMoment If this is true , the body mass and moment will be reduced by shape . The default is true . <nl> * / <nl> void removeAllShapes ( bool reduceMassAndMoment = true ) ; <nl> <nl> / * * <nl> - Get the body shapes . <nl> - <nl> + * Get the body shapes . <nl> + * <nl> * @ return A Vector < PhysicsShape * > object contains PhysicsShape pointer . <nl> * / <nl> inline const Vector < PhysicsShape * > & getShapes ( ) const { return _shapes ; } <nl> - <nl> - / * * <nl> - Get the first shape of the body shapes . <nl> - <nl> - @ return The first shape in this body . <nl> - * / <nl> - inline PhysicsShape * getFirstShape ( ) const { return _shapes . size ( ) > = 1 ? _shapes . at ( 0 ) : nullptr ; } <nl> <nl> / * * <nl> - get the shape of the body . <nl> - <nl> - @ param tag An interger number that identifies a PhysicsShape object . <nl> - @ return A PhysicsShape object pointer or nullptr if no shapes were found . <nl> + * get the shape of the body . <nl> + * <nl> + * @ param tag An interger number that identifies a PhysicsShape object . <nl> + * @ return A PhysicsShape object pointer or nullptr if no shapes were found . <nl> * / <nl> PhysicsShape * getShape ( int tag ) const ; <nl> <nl> / * * <nl> - Applies a continuous force to body . <nl> - <nl> - @ param force The force is applies to this body . <nl> - * / <nl> - virtual void applyForce ( const Vect & force ) ; <nl> - <nl> - / * * <nl> - Applies a continuous force to body . <nl> - <nl> - @ param force The force is applies to this body . <nl> - @ param offset A Vec2 object , it is the offset from the body ’ s center of gravity in world coordinates . <nl> + * Applies a continuous force to body . <nl> + * <nl> + * @ param force The force is applies to this body . <nl> + * @ param offset A Vec2 object , it is the offset from the body ’ s center of gravity in world coordinates . <nl> * / <nl> - virtual void applyForce ( const Vect & force , const Vec2 & offset ) ; <nl> + virtual void applyForce ( const Vec2 & force , const Vec2 & offset = Vec2 : : ZERO ) ; <nl> <nl> / * * <nl> - reset all the force applied to body . <nl> + * reset all the force applied to body . <nl> * / <nl> virtual void resetForces ( ) ; <nl> <nl> / * * <nl> - Applies a immediate force to body . <nl> - <nl> - @ param impulse The impulse is applies to this body . <nl> - * / <nl> - virtual void applyImpulse ( const Vect & impulse ) ; <nl> - <nl> - / * * <nl> - Applies a immediate force to body . <nl> - <nl> - @ param impulse The impulse is applies to this body . <nl> - @ param offset A Vec2 object , it is the offset from the body ’ s center of gravity in world coordinates . <nl> + * Applies a immediate force to body . <nl> + * <nl> + * @ param impulse The impulse is applies to this body . <nl> + * @ param offset A Vec2 object , it is the offset from the body ’ s center of gravity in world coordinates . <nl> * / <nl> - virtual void applyImpulse ( const Vect & impulse , const Vec2 & offset ) ; <nl> + virtual void applyImpulse ( const Vec2 & impulse , const Vec2 & offset = Vec2 : : ZERO ) ; <nl> <nl> / * * <nl> - Applies a torque force to body . <nl> - <nl> - @ param torque The torque is applies to this body . <nl> + * Applies a torque force to body . <nl> + * <nl> + * @ param torque The torque is applies to this body . <nl> * / <nl> virtual void applyTorque ( float torque ) ; <nl> <nl> / * * <nl> - Set the velocity of a body . <nl> - <nl> - @ param velocity The velocity is set to this body . <nl> + * Set the velocity of a body . <nl> + * <nl> + * @ param velocity The velocity is set to this body . <nl> * / <nl> - virtual void setVelocity ( const Vect & velocity ) ; <nl> + virtual void setVelocity ( const Vec2 & velocity ) ; <nl> <nl> / * * Get the velocity of a body . * / <nl> virtual Vec2 getVelocity ( ) ; <nl> <nl> / * * <nl> - Set the angular velocity of a body . <nl> - <nl> - @ param velocity The angular velocity is set to this body . <nl> + * Set the angular velocity of a body . <nl> + * <nl> + * @ param velocity The angular velocity is set to this body . <nl> * / <nl> virtual void setAngularVelocity ( float velocity ) ; <nl> <nl> class CC_DLL PhysicsBody : public Ref <nl> <nl> / * * get the world body added to . * / <nl> inline PhysicsWorld * getWorld ( ) const { return _world ; } <nl> + <nl> / * * get all joints the body have * / <nl> inline const std : : vector < PhysicsJoint * > & getJoints ( ) const { return _joints ; } <nl> <nl> - / * * get the sprite the body set to . * / <nl> - Node * getNode ( ) const ; <nl> + / * * get the node the body set to . * / <nl> + Node * getNode ( ) const { return _owner ; } <nl> <nl> / * * <nl> * A mask that defines which categories this physics body belongs to . <nl> class CC_DLL PhysicsBody : public Ref <nl> void setCollisionBitmask ( int bitmask ) ; <nl> <nl> / * * <nl> - Return bitmask of first shape . <nl> - <nl> + * Return bitmask of first shape . <nl> + * <nl> * @ return If there is no shape in body , return default value . ( 0xFFFFFFFF ) <nl> * / <nl> int getCategoryBitmask ( ) const ; <nl> <nl> / * * <nl> - Return bitmask of first shape . <nl> - <nl> + * Return bitmask of first shape . <nl> + * <nl> * @ return If there is no shape in body , return default value . ( 0x00000000 ) <nl> * / <nl> int getContactTestBitmask ( ) const ; <nl> <nl> / * * <nl> - Return bitmask of first shape . <nl> - <nl> - @ return If there is no shape in body , return default value . ( 0xFFFFFFFF ) <nl> + * Return bitmask of first shape . <nl> + * <nl> + * @ return If there is no shape in body , return default value . ( 0xFFFFFFFF ) <nl> * / <nl> int getCollisionBitmask ( ) const ; <nl> <nl> class CC_DLL PhysicsBody : public Ref <nl> void setGroup ( int group ) ; <nl> <nl> / * * <nl> - Return group of first shape . <nl> - <nl> - @ return If there is no shape in body , return default value . ( 0 ) <nl> + * Return group of first shape . <nl> + * <nl> + * @ return If there is no shape in body , return default value . ( 0 ) <nl> * / <nl> int getGroup ( ) const ; <nl> <nl> / * * get the body position . * / <nl> Vec2 getPosition ( ) const ; <nl> - <nl> + <nl> / * * get the body rotation . * / <nl> float getRotation ( ) ; <nl> - <nl> + <nl> / * * set body position offset , it ' s the position witch relative to node * / <nl> void setPositionOffset ( const Vec2 & position ) ; <nl> - <nl> + <nl> / * * get body position offset . * / <nl> const Vec2 & getPositionOffset ( ) const { return _positionOffset ; } <nl> <nl> class CC_DLL PhysicsBody : public Ref <nl> <nl> / * * Get the body mass . * / <nl> inline float getMass ( ) const { return _mass ; } <nl> + <nl> / * * <nl> * @ brief Add mass to body . <nl> * <nl> class CC_DLL PhysicsBody : public Ref <nl> <nl> / * * Get angular damping . * / <nl> inline float getAngularDamping ( ) const { return _angularDamping ; } <nl> + <nl> / * * <nl> * Set angular damping . <nl> * <nl> class CC_DLL PhysicsBody : public Ref <nl> <nl> / * * set body to rest * / <nl> void setResting ( bool rest ) const ; <nl> - <nl> - / * * <nl> - * Whether the body is enabled . <nl> - * <nl> - * If the body it isn ' t enabled , it will not has simulation by world . <nl> - * / <nl> - inline bool isEnabled ( ) const { return _enabled ; } <nl> <nl> / * * <nl> * Set the enable value . <nl> * <nl> * If the body it isn ' t enabled , it will not has simulation by world . <nl> * / <nl> - void setEnable ( bool enable ) ; <nl> + virtual void setEnabled ( bool enable ) override ; <nl> <nl> / * * Whether the body can rotation . * / <nl> inline bool isRotationEnabled ( ) const { return _rotationEnabled ; } <nl> class CC_DLL PhysicsBody : public Ref <nl> <nl> / * * Get the rigid body of chipmunk . * / <nl> cpBody * getCPBody ( ) const { return _cpBody ; } <nl> + <nl> + virtual void onEnter ( ) override ; <nl> + virtual void onExit ( ) override ; <nl> + virtual void onAdd ( ) override ; <nl> + virtual void onRemove ( ) override ; <nl> <nl> protected : <nl> + PhysicsBody ( ) ; <nl> + virtual ~ PhysicsBody ( ) ; <nl> + <nl> + virtual bool init ( ) ; <nl> <nl> - bool init ( ) ; <nl> - <nl> - virtual void setPosition ( const Vec2 & position ) ; <nl> + virtual void setPosition ( float positionX , float positionY ) ; <nl> + <nl> virtual void setRotation ( float rotation ) ; <nl> + <nl> virtual void setScale ( float scaleX , float scaleY ) ; <nl> <nl> void update ( float delta ) ; <nl> <nl> void removeJoint ( PhysicsJoint * joint ) ; <nl> + <nl> inline void updateDamping ( ) { _isDamping = _linearDamping ! = 0 . 0f | | _angularDamping ! = 0 . 0f ; } <nl> - <nl> - protected : <nl> - PhysicsBody ( ) ; <nl> - virtual ~ PhysicsBody ( ) ; <nl> - <nl> + <nl> + void addToPhysicsWorld ( ) ; <nl> + void removeFromPhysicsWorld ( ) ; <nl> + <nl> + void beforeSimulation ( const Mat4 & parentToWorldTransform , const Mat4 & nodeToWorldTransform , float scaleX , float scaleY , float rotation ) ; <nl> + void afterSimulation ( const Mat4 & parentToWorldTransform , float parentRotation ) ; <nl> protected : <nl> std : : vector < PhysicsJoint * > _joints ; <nl> Vector < PhysicsShape * > _shapes ; <nl> PhysicsWorld * _world ; <nl> - / / weak reference <nl> - ComponentPhysics2d * _componentBelongsTo ; <nl> + <nl> cpBody * _cpBody ; <nl> bool _dynamic ; <nl> - bool _enabled ; <nl> bool _rotationEnabled ; <nl> bool _gravityEnabled ; <nl> bool _massDefault ; <nl> class CC_DLL PhysicsBody : public Ref <nl> bool _isDamping ; <nl> float _linearDamping ; <nl> float _angularDamping ; <nl> + <nl> int _tag ; <nl> <nl> / / when setMass ( ) is invoked , it means body ' s mass is not calculated by shapes <nl> class CC_DLL PhysicsBody : public Ref <nl> float _recordedRotation ; <nl> double _recordedAngle ; <nl> <nl> + / / offset between owner ' s center point and down left point <nl> + Vec3 _ownerCenterOffset ; <nl> + / / offset of owner ' s center point and anchor point in parent coordinate <nl> + Vec2 _offset ; <nl> + float _recordScaleX ; <nl> + float _recordScaleY ; <nl> + <nl> + float _recordPosX ; <nl> + float _recordPosY ; <nl> + <nl> friend class PhysicsWorld ; <nl> friend class PhysicsShape ; <nl> friend class PhysicsJoint ; <nl> - friend class Node ; <nl> - friend class Layer ; <nl> - friend class ProtectedNode ; <nl> - friend class ComponentPhysics2d ; <nl> } ; <nl> <nl> / * * @ } * / <nl> mmm a / cocos / physics / CCPhysicsContact . cpp <nl> ppp b / cocos / physics / CCPhysicsContact . cpp <nl> void PhysicsContactPreSolve : : setFriction ( float friction ) <nl> static_cast < cpArbiter * > ( _contactInfo ) - > u = friction ; <nl> } <nl> <nl> - void PhysicsContactPreSolve : : setSurfaceVelocity ( const Vect & velocity ) <nl> + void PhysicsContactPreSolve : : setSurfaceVelocity ( const Vec2 & velocity ) <nl> { <nl> static_cast < cpArbiter * > ( _contactInfo ) - > surface_vr = PhysicsHelper : : point2cpv ( velocity ) ; <nl> } <nl> mmm a / cocos / physics / CCPhysicsContact . h <nl> ppp b / cocos / physics / CCPhysicsContact . h <nl> class PhysicsShape ; <nl> class PhysicsBody ; <nl> class PhysicsWorld ; <nl> <nl> - typedef Vec2 Vect ; <nl> - <nl> typedef struct CC_DLL PhysicsContactData <nl> { <nl> static const int POINT_MAX = 4 ; <nl> class CC_DLL PhysicsContactPreSolve <nl> / * * Set the friction . * / <nl> void setFriction ( float friction ) ; <nl> / * * Set the surface velocity . * / <nl> - void setSurfaceVelocity ( const Vect & velocity ) ; <nl> + void setSurfaceVelocity ( const Vec2 & velocity ) ; <nl> / * * Ignore the rest of the contact presolve and postsolve callbacks . * / <nl> void ignore ( ) ; <nl> <nl> mmm a / cocos / physics / CCPhysicsHelper . h <nl> ppp b / cocos / physics / CCPhysicsHelper . h <nl> class PhysicsHelper <nl> / * * Make cpFloat type convert to float type . * / <nl> static float cpfloat2float ( cpFloat f ) { return f ; } <nl> <nl> - / * * Make float type convert to cpFloat type . * / <nl> - static cpFloat float2cpfloat ( float f ) { return f ; } <nl> - <nl> / * * Make Rect type convert to cpBB type . * / <nl> static cpBB rect2cpbb ( const Rect & rect ) { return cpBBNew ( rect . origin . x , rect . origin . y , rect . origin . x + rect . size . width , rect . origin . y + rect . size . height ) ; } <nl> <nl> mmm a / cocos / physics / CCPhysicsJoint . cpp <nl> ppp b / cocos / physics / CCPhysicsJoint . cpp <nl> void PhysicsJoint : : setMaxForce ( float force ) <nl> _maxForce = force ; <nl> for ( auto joint : _cpConstraints ) <nl> { <nl> - joint - > maxForce = PhysicsHelper : : float2cpfloat ( force ) ; <nl> + joint - > maxForce = force ; <nl> } <nl> } <nl> <nl> bool PhysicsJointLimit : : createConstraints ( ) <nl> auto joint = cpSlideJointNew ( _bodyA - > getCPBody ( ) , _bodyB - > getCPBody ( ) , <nl> PhysicsHelper : : point2cpv ( _anchr1 ) , <nl> PhysicsHelper : : point2cpv ( _anchr2 ) , <nl> - PhysicsHelper : : float2cpfloat ( _min ) , <nl> - PhysicsHelper : : float2cpfloat ( _max ) ) ; <nl> + _min , <nl> + _max ) ; <nl> <nl> CC_BREAK_IF ( joint = = nullptr ) ; <nl> _cpConstraints . push_back ( joint ) ; <nl> float PhysicsJointLimit : : getMin ( ) const <nl> <nl> void PhysicsJointLimit : : setMin ( float min ) <nl> { <nl> - cpSlideJointSetMin ( _cpConstraints . front ( ) , PhysicsHelper : : float2cpfloat ( min ) ) ; <nl> + cpSlideJointSetMin ( _cpConstraints . front ( ) , min ) ; <nl> } <nl> <nl> float PhysicsJointLimit : : getMax ( ) const <nl> float PhysicsJointLimit : : getMax ( ) const <nl> <nl> void PhysicsJointLimit : : setMax ( float max ) <nl> { <nl> - cpSlideJointSetMax ( _cpConstraints . front ( ) , PhysicsHelper : : float2cpfloat ( max ) ) ; <nl> + cpSlideJointSetMax ( _cpConstraints . front ( ) , max ) ; <nl> } <nl> <nl> Vec2 PhysicsJointLimit : : getAnchr1 ( ) const <nl> float PhysicsJointDistance : : getDistance ( ) const <nl> <nl> void PhysicsJointDistance : : setDistance ( float distance ) <nl> { <nl> - cpPinJointSetDist ( _cpConstraints . front ( ) , PhysicsHelper : : float2cpfloat ( distance ) ) ; <nl> + cpPinJointSetDist ( _cpConstraints . front ( ) , distance ) ; <nl> } <nl> <nl> PhysicsJointSpring * PhysicsJointSpring : : construct ( PhysicsBody * a , PhysicsBody * b , const Vec2 & anchr1 , const Vec2 & anchr2 , float stiffness , float damping ) <nl> bool PhysicsJointSpring : : createConstraints ( ) <nl> _bodyB - > getCPBody ( ) , <nl> PhysicsHelper : : point2cpv ( _anchr1 ) , <nl> PhysicsHelper : : point2cpv ( _anchr2 ) , <nl> - PhysicsHelper : : float2cpfloat ( _bodyB - > local2World ( _anchr1 ) . getDistance ( _bodyA - > local2World ( _anchr2 ) ) ) , <nl> - PhysicsHelper : : float2cpfloat ( _stiffness ) , <nl> - PhysicsHelper : : float2cpfloat ( _damping ) ) ; <nl> + _bodyB - > local2World ( _anchr1 ) . getDistance ( _bodyA - > local2World ( _anchr2 ) ) , <nl> + _stiffness , <nl> + _damping ) ; <nl> <nl> CC_BREAK_IF ( joint = = nullptr ) ; <nl> _cpConstraints . push_back ( joint ) ; <nl> float PhysicsJointSpring : : getRestLength ( ) const <nl> <nl> void PhysicsJointSpring : : setRestLength ( float restLength ) <nl> { <nl> - cpDampedSpringSetRestLength ( _cpConstraints . front ( ) , PhysicsHelper : : float2cpfloat ( restLength ) ) ; <nl> + cpDampedSpringSetRestLength ( _cpConstraints . front ( ) , restLength ) ; <nl> } <nl> <nl> float PhysicsJointSpring : : getStiffness ( ) const <nl> float PhysicsJointSpring : : getStiffness ( ) const <nl> <nl> void PhysicsJointSpring : : setStiffness ( float stiffness ) <nl> { <nl> - cpDampedSpringSetStiffness ( _cpConstraints . front ( ) , PhysicsHelper : : float2cpfloat ( stiffness ) ) ; <nl> + cpDampedSpringSetStiffness ( _cpConstraints . front ( ) , stiffness ) ; <nl> } <nl> <nl> float PhysicsJointSpring : : getDamping ( ) const <nl> float PhysicsJointSpring : : getDamping ( ) const <nl> <nl> void PhysicsJointSpring : : setDamping ( float damping ) <nl> { <nl> - cpDampedSpringSetDamping ( _cpConstraints . front ( ) , PhysicsHelper : : float2cpfloat ( damping ) ) ; <nl> + cpDampedSpringSetDamping ( _cpConstraints . front ( ) , damping ) ; <nl> } <nl> <nl> PhysicsJointGroove * PhysicsJointGroove : : construct ( PhysicsBody * a , PhysicsBody * b , const Vec2 & grooveA , const Vec2 & grooveB , const Vec2 & anchr2 ) <nl> bool PhysicsJointRotarySpring : : createConstraints ( ) <nl> do { <nl> auto joint = cpDampedRotarySpringNew ( _bodyA - > getCPBody ( ) , <nl> _bodyB - > getCPBody ( ) , <nl> - PhysicsHelper : : float2cpfloat ( _bodyB - > getRotation ( ) - _bodyA - > getRotation ( ) ) , <nl> - PhysicsHelper : : float2cpfloat ( _stiffness ) , <nl> - PhysicsHelper : : float2cpfloat ( _damping ) ) ; <nl> + _bodyB - > getRotation ( ) - _bodyA - > getRotation ( ) , <nl> + _stiffness , <nl> + _damping ) ; <nl> <nl> CC_BREAK_IF ( joint = = nullptr ) ; <nl> _cpConstraints . push_back ( joint ) ; <nl> float PhysicsJointRotarySpring : : getRestAngle ( ) const <nl> <nl> void PhysicsJointRotarySpring : : setRestAngle ( float restAngle ) <nl> { <nl> - cpDampedRotarySpringSetRestAngle ( _cpConstraints . front ( ) , PhysicsHelper : : float2cpfloat ( restAngle ) ) ; <nl> + cpDampedRotarySpringSetRestAngle ( _cpConstraints . front ( ) , restAngle ) ; <nl> } <nl> <nl> float PhysicsJointRotarySpring : : getStiffness ( ) const <nl> float PhysicsJointRotarySpring : : getStiffness ( ) const <nl> <nl> void PhysicsJointRotarySpring : : setStiffness ( float stiffness ) <nl> { <nl> - cpDampedRotarySpringSetStiffness ( _cpConstraints . front ( ) , PhysicsHelper : : float2cpfloat ( stiffness ) ) ; <nl> + cpDampedRotarySpringSetStiffness ( _cpConstraints . front ( ) , stiffness ) ; <nl> } <nl> <nl> float PhysicsJointRotarySpring : : getDamping ( ) const <nl> float PhysicsJointRotarySpring : : getDamping ( ) const <nl> <nl> void PhysicsJointRotarySpring : : setDamping ( float damping ) <nl> { <nl> - cpDampedRotarySpringSetDamping ( _cpConstraints . front ( ) , PhysicsHelper : : float2cpfloat ( damping ) ) ; <nl> + cpDampedRotarySpringSetDamping ( _cpConstraints . front ( ) , damping ) ; <nl> } <nl> <nl> PhysicsJointRotaryLimit * PhysicsJointRotaryLimit : : construct ( PhysicsBody * a , PhysicsBody * b , float min , float max ) <nl> bool PhysicsJointRotaryLimit : : createConstraints ( ) <nl> { <nl> auto joint = cpRotaryLimitJointNew ( _bodyA - > getCPBody ( ) , <nl> _bodyB - > getCPBody ( ) , <nl> - PhysicsHelper : : float2cpfloat ( _min ) , <nl> - PhysicsHelper : : float2cpfloat ( _max ) ) ; <nl> + _min , <nl> + _max ) ; <nl> <nl> CC_BREAK_IF ( joint = = nullptr ) ; <nl> _cpConstraints . push_back ( joint ) ; <nl> float PhysicsJointRotaryLimit : : getMin ( ) const <nl> <nl> void PhysicsJointRotaryLimit : : setMin ( float min ) <nl> { <nl> - cpRotaryLimitJointSetMin ( _cpConstraints . front ( ) , PhysicsHelper : : float2cpfloat ( min ) ) ; <nl> + cpRotaryLimitJointSetMin ( _cpConstraints . front ( ) , min ) ; <nl> } <nl> <nl> float PhysicsJointRotaryLimit : : getMax ( ) const <nl> float PhysicsJointRotaryLimit : : getMax ( ) const <nl> <nl> void PhysicsJointRotaryLimit : : setMax ( float max ) <nl> { <nl> - cpRotaryLimitJointSetMax ( _cpConstraints . front ( ) , PhysicsHelper : : float2cpfloat ( max ) ) ; <nl> + cpRotaryLimitJointSetMax ( _cpConstraints . front ( ) , max ) ; <nl> } <nl> <nl> PhysicsJointRatchet * PhysicsJointRatchet : : construct ( PhysicsBody * a , PhysicsBody * b , float phase , float ratchet ) <nl> bool PhysicsJointRatchet : : createConstraints ( ) <nl> { <nl> auto joint = cpRatchetJointNew ( _bodyA - > getCPBody ( ) , <nl> _bodyB - > getCPBody ( ) , <nl> - PhysicsHelper : : float2cpfloat ( _phase ) , <nl> + _phase , <nl> PhysicsHelper : : cpfloat2float ( _ratchet ) ) ; <nl> <nl> CC_BREAK_IF ( joint = = nullptr ) ; <nl> float PhysicsJointRatchet : : getAngle ( ) const <nl> <nl> void PhysicsJointRatchet : : setAngle ( float angle ) <nl> { <nl> - cpRatchetJointSetAngle ( _cpConstraints . front ( ) , PhysicsHelper : : float2cpfloat ( angle ) ) ; <nl> + cpRatchetJointSetAngle ( _cpConstraints . front ( ) , angle ) ; <nl> } <nl> <nl> float PhysicsJointRatchet : : getPhase ( ) const <nl> float PhysicsJointRatchet : : getPhase ( ) const <nl> <nl> void PhysicsJointRatchet : : setPhase ( float phase ) <nl> { <nl> - cpRatchetJointSetPhase ( _cpConstraints . front ( ) , PhysicsHelper : : float2cpfloat ( phase ) ) ; <nl> + cpRatchetJointSetPhase ( _cpConstraints . front ( ) , phase ) ; <nl> } <nl> <nl> float PhysicsJointRatchet : : getRatchet ( ) const <nl> float PhysicsJointRatchet : : getRatchet ( ) const <nl> <nl> void PhysicsJointRatchet : : setRatchet ( float ratchet ) <nl> { <nl> - cpRatchetJointSetRatchet ( _cpConstraints . front ( ) , PhysicsHelper : : float2cpfloat ( ratchet ) ) ; <nl> + cpRatchetJointSetRatchet ( _cpConstraints . front ( ) , ratchet ) ; <nl> } <nl> <nl> PhysicsJointGear * PhysicsJointGear : : construct ( PhysicsBody * a , PhysicsBody * b , float phase , float ratio ) <nl> bool PhysicsJointGear : : createConstraints ( ) <nl> { <nl> auto joint = cpGearJointNew ( _bodyA - > getCPBody ( ) , <nl> _bodyB - > getCPBody ( ) , <nl> - PhysicsHelper : : float2cpfloat ( _phase ) , <nl> - PhysicsHelper : : float2cpfloat ( _ratio ) ) ; <nl> + _phase , <nl> + _ratio ) ; <nl> <nl> CC_BREAK_IF ( joint = = nullptr ) ; <nl> _cpConstraints . push_back ( joint ) ; <nl> float PhysicsJointGear : : getPhase ( ) const <nl> <nl> void PhysicsJointGear : : setPhase ( float phase ) <nl> { <nl> - cpGearJointSetPhase ( _cpConstraints . front ( ) , PhysicsHelper : : float2cpfloat ( phase ) ) ; <nl> + cpGearJointSetPhase ( _cpConstraints . front ( ) , phase ) ; <nl> } <nl> <nl> float PhysicsJointGear : : getRatio ( ) const <nl> float PhysicsJointGear : : getRatio ( ) const <nl> <nl> void PhysicsJointGear : : setRatio ( float ratio ) <nl> { <nl> - cpGearJointSetRatio ( _cpConstraints . front ( ) , PhysicsHelper : : float2cpfloat ( ratio ) ) ; <nl> + cpGearJointSetRatio ( _cpConstraints . front ( ) , ratio ) ; <nl> } <nl> <nl> PhysicsJointMotor * PhysicsJointMotor : : construct ( PhysicsBody * a , PhysicsBody * b , float rate ) <nl> bool PhysicsJointMotor : : createConstraints ( ) <nl> { <nl> auto joint = cpSimpleMotorNew ( _bodyA - > getCPBody ( ) , <nl> _bodyB - > getCPBody ( ) , <nl> - PhysicsHelper : : float2cpfloat ( _rate ) ) ; <nl> + _rate ) ; <nl> <nl> CC_BREAK_IF ( joint = = nullptr ) ; <nl> _cpConstraints . push_back ( joint ) ; <nl> float PhysicsJointMotor : : getRate ( ) const <nl> <nl> void PhysicsJointMotor : : setRate ( float rate ) <nl> { <nl> - cpSimpleMotorSetRate ( _cpConstraints . front ( ) , PhysicsHelper : : float2cpfloat ( rate ) ) ; <nl> + cpSimpleMotorSetRate ( _cpConstraints . front ( ) , rate ) ; <nl> } <nl> <nl> NS_CC_END <nl> deleted file mode 100644 <nl> index 15a4d4058366 . . 000000000000 <nl> mmm a / cocos / physics / CCPhysicsManager . cpp <nl> ppp / dev / null <nl> <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> - Copyright ( c ) 2015 Chukong Technologies Inc . <nl> - <nl> - http : / / www . cocos2d - x . org <nl> - <nl> - Permission is hereby granted , free of charge , to any person obtaining a copy <nl> - of this software and associated documentation files ( the " Software " ) , to deal <nl> - in the Software without restriction , including without limitation the rights <nl> - to use , copy , modify , merge , publish , distribute , sublicense , and / or sell <nl> - copies of the Software , and to permit persons to whom the Software is <nl> - furnished to do so , subject to the following conditions : <nl> - <nl> - The above copyright notice and this permission notice shall be included in <nl> - all copies or substantial portions of the Software . <nl> - <nl> - THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , EXPRESS OR <nl> - IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY , <nl> - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL THE <nl> - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER <nl> - LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , <nl> - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN <nl> - THE SOFTWARE . <nl> - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - <nl> - # include " base / ccConfig . h " / / to include defination of CC_USE_PHYSICS <nl> - # if CC_USE_PHYSICS <nl> - <nl> - # include " physics / CCPhysicsManager . h " <nl> - # include " physics / CCComponentPhysics2d . h " <nl> - # include " physics / CCPhysicsWorld . h " <nl> - # include " 2d / CCScene . h " <nl> - <nl> - NS_CC_BEGIN <nl> - <nl> - PhysicsManager : : PhysicsManager ( Scene * scene ) <nl> - : _scene ( scene ) <nl> - { <nl> - _physicsWorld = PhysicsWorld : : construct ( ) ; <nl> - } <nl> - <nl> - PhysicsManager : : ~ PhysicsManager ( ) <nl> - { <nl> - delete _physicsWorld ; <nl> - } <nl> - <nl> - void PhysicsManager : : update ( float dt ) <nl> - { <nl> - / / Update physics position , should loop as the same sequence as node tree . <nl> - / / ComponentPhysics2d : : beforeSimulation ( ) will depend on the sequence . <nl> - beforeSimulation ( _scene ) ; <nl> - <nl> - / / do simulation <nl> - _physicsWorld - > update ( dt , false ) ; <nl> - <nl> - / / Update physics position , should loop as the same sequence as node tree . <nl> - / / ComponentPhysics2d : : afterSimulation ( ) will depend on the sequence . <nl> - afterSimulation ( _scene ) ; <nl> - } <nl> - <nl> - void PhysicsManager : : beforeSimulation ( Node * node ) <nl> - { <nl> - auto iter = _owners . find ( node ) ; <nl> - if ( iter ! = _owners . end ( ) ) <nl> - { <nl> - auto component = iter - > second ; <nl> - component - > beforeSimulation ( ) ; <nl> - } <nl> - <nl> - for ( auto child : node - > getChildren ( ) ) <nl> - beforeSimulation ( child ) ; <nl> - } <nl> - <nl> - void PhysicsManager : : afterSimulation ( Node * node ) <nl> - { <nl> - auto iter = _owners . find ( node ) ; <nl> - if ( iter ! = _owners . end ( ) ) <nl> - { <nl> - auto component = iter - > second ; <nl> - component - > afterSimulation ( ) ; <nl> - } <nl> - <nl> - for ( auto child : node - > getChildren ( ) ) <nl> - afterSimulation ( child ) ; <nl> - } <nl> - <nl> - void PhysicsManager : : addPhysicsComponent ( ComponentPhysics2d * componentPhsics2d ) <nl> - { <nl> - / / don ' t add component again <nl> - if ( std : : find ( _components . begin ( ) , _components . end ( ) , componentPhsics2d ) ! = _components . end ( ) ) <nl> - return ; <nl> - <nl> - _components . push_back ( componentPhsics2d ) ; <nl> - / / Node : : getComponent < > ( ) is a time comsuming operation , so record data to avoid invoking it . <nl> - std : : pair < Node * , ComponentPhysics2d * > element ( componentPhsics2d - > getOwner ( ) , componentPhsics2d ) ; <nl> - _owners . insert ( element ) ; <nl> - <nl> - if ( nullptr ! = componentPhsics2d - > getPhysicsBody ( ) ) <nl> - _physicsWorld - > addBody ( componentPhsics2d - > getPhysicsBody ( ) ) ; <nl> - } <nl> - <nl> - void PhysicsManager : : removePhysicsComponent ( ComponentPhysics2d * componentPhsics2d ) <nl> - { <nl> - auto iter = std : : find ( _components . begin ( ) , _components . end ( ) , componentPhsics2d ) ; <nl> - if ( iter ! = _components . end ( ) ) <nl> - { <nl> - removeElementFromMap ( * iter ) ; <nl> - <nl> - _components . erase ( iter ) ; <nl> - if ( componentPhsics2d - > getPhysicsBody ( ) ) <nl> - _physicsWorld - > removeBody ( componentPhsics2d - > getPhysicsBody ( ) ) ; <nl> - } <nl> - } <nl> - <nl> - void PhysicsManager : : removeElementFromMap ( ComponentPhysics2d * component ) <nl> - { <nl> - for ( auto element : _owners ) <nl> - { <nl> - if ( element . second = = component ) <nl> - { <nl> - _owners . erase ( element . first ) ; <nl> - break ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - PhysicsWorld * PhysicsManager : : getPhysicsWorld ( ) const <nl> - { <nl> - return _physicsWorld ; <nl> - } <nl> - <nl> - NS_CC_END <nl> - <nl> - # endif / / CC_USE_PHYSICS <nl> deleted file mode 100644 <nl> index 5c1ecc093155 . . 000000000000 <nl> mmm a / cocos / physics / CCPhysicsManager . h <nl> ppp / dev / null <nl> <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> - Copyright ( c ) 2015 Chukong Technologies Inc . <nl> - <nl> - http : / / www . cocos2d - x . org <nl> - <nl> - Permission is hereby granted , free of charge , to any person obtaining a copy <nl> - of this software and associated documentation files ( the " Software " ) , to deal <nl> - in the Software without restriction , including without limitation the rights <nl> - to use , copy , modify , merge , publish , distribute , sublicense , and / or sell <nl> - copies of the Software , and to permit persons to whom the Software is <nl> - furnished to do so , subject to the following conditions : <nl> - <nl> - The above copyright notice and this permission notice shall be included in <nl> - all copies or substantial portions of the Software . <nl> - <nl> - THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , EXPRESS OR <nl> - IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY , <nl> - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL THE <nl> - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER <nl> - LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , <nl> - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN <nl> - THE SOFTWARE . <nl> - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - <nl> - # pragma once <nl> - <nl> - # include " base / ccConfig . h " / / to include defination of CC_USE_PHYSICS <nl> - # if CC_USE_PHYSICS <nl> - <nl> - # include < vector > <nl> - # include < unordered_map > <nl> - <nl> - # include " platform / CCPlatformMacros . h " <nl> - <nl> - NS_CC_BEGIN <nl> - <nl> - class ComponentPhysics2d ; <nl> - class PhysicsWorld ; <nl> - class Scene ; <nl> - class Node ; <nl> - <nl> - / * * <nl> - * @ addtogroup physics <nl> - * @ { <nl> - * @ addtogroup physics_2d <nl> - * @ { <nl> - * / <nl> - <nl> - / * * <nl> - * Now ` PhysicsManager ` belongs to a ` Scene ` . ` Scene ` will create ` PhysicsManager ` automatically . <nl> - * The reason to design like this are : <nl> - * - PhysicsManager keeps physics world , it is reasonale that a scene has its own physics world . <nl> - * It is useful that when a scene is active again , you don ' t have to create physics world and <nl> - * do all related things again . <nl> - * - Keep compatibility <nl> - * / <nl> - class CC_DLL PhysicsManager <nl> - { <nl> - public : <nl> - <nl> - / / / @ cond DO_NOT_SHOW <nl> - <nl> - / * * <nl> - * Create a PhysicsManager with ` Scene ` . ` Scene ` will create it automatically , <nl> - * so don ' t create it yourself . <nl> - * <nl> - * @ scene The scene this ` PhysicsManager ` belongs to . <nl> - * / <nl> - PhysicsManager ( Scene * scene ) ; <nl> - / * * <nl> - * Destructor . <nl> - * / <nl> - ~ PhysicsManager ( ) ; <nl> - <nl> - / * * <nl> - * Do physics simulation . It will do the following things : <nl> - * - synchronize Node ' s status ( position , rotation , scale ) to corresponding physics body <nl> - * - do physics simulation <nl> - * - synchronize physics body ' s status ( position , rotation ) to correspondind Node <nl> - * <nl> - * It is invoked by ` Scene ` , don ' t invoke it yourself . <nl> - * / <nl> - void update ( float dt ) ; <nl> - <nl> - / / / @ endcond DO_NOT_SHOW <nl> - <nl> - / * * <nl> - * Get the physics world . <nl> - * <nl> - * @ return Physics world managed by this ` PhysicsManager ` . <nl> - * / <nl> - PhysicsWorld * getPhysicsWorld ( ) const ; <nl> - <nl> - / * * <nl> - * Add a physics component to be managed by the ` PhysicsManager ` . Will register physics <nl> - * component ' s physics body to physics world managed by this ` PhysicsManager ` . <nl> - * <nl> - * @ param componentPhsics2d The physics component to be managed by this ` PhysicsManager ` . <nl> - * / <nl> - void addPhysicsComponent ( ComponentPhysics2d * componentPhsics2d ) ; <nl> - / * * <nl> - * Remove a physics component from ` PhysiscsManager ` . Will remove physics component ' s physics <nl> - * body from the physics world managed by this ` PhysicsManager ` . <nl> - * / <nl> - void removePhysicsComponent ( ComponentPhysics2d * componentPhsics2d ) ; <nl> - <nl> - private : <nl> - void beforeSimulation ( Node * node ) ; <nl> - void afterSimulation ( Node * node ) ; <nl> - void removeElementFromMap ( ComponentPhysics2d * component ) ; <nl> - private : <nl> - std : : vector < ComponentPhysics2d * > _components ; <nl> - / / record the owners of components for performance <nl> - std : : unordered_map < Node * , ComponentPhysics2d * > _owners ; <nl> - PhysicsWorld * _physicsWorld ; <nl> - Scene * _scene ; <nl> - } ; <nl> - <nl> - / * * @ } * / <nl> - / * * @ } * / <nl> - <nl> - NS_CC_END <nl> - <nl> - # endif / / CC_USE_PHYSICS <nl> mmm a / cocos / physics / CCPhysicsShape . cpp <nl> ppp b / cocos / physics / CCPhysicsShape . cpp <nl> void PhysicsShape : : setDensity ( float density ) <nl> setMass ( PHYSICS_INFINITY ) ; <nl> } else if ( _area > 0 ) <nl> { <nl> - setMass ( PhysicsHelper : : float2cpfloat ( _material . density * _area ) ) ; <nl> + setMass ( _material . density * _area ) ; <nl> } <nl> } <nl> <nl> void PhysicsShape : : setRestitution ( float restitution ) <nl> <nl> for ( cpShape * shape : _cpShapes ) <nl> { <nl> - cpShapeSetElasticity ( shape , PhysicsHelper : : float2cpfloat ( restitution ) ) ; <nl> + cpShapeSetElasticity ( shape , restitution ) ; <nl> } <nl> } <nl> <nl> void PhysicsShape : : setFriction ( float friction ) <nl> <nl> for ( cpShape * shape : _cpShapes ) <nl> { <nl> - cpShapeSetFriction ( shape , PhysicsHelper : : float2cpfloat ( friction ) ) ; <nl> + cpShapeSetFriction ( shape , friction ) ; <nl> } <nl> } <nl> <nl> float PhysicsShapeCircle : : calculateArea ( float radius ) <nl> float PhysicsShapeCircle : : calculateMoment ( float mass , float radius , const Vec2 & offset ) <nl> { <nl> return mass = = PHYSICS_INFINITY ? PHYSICS_INFINITY <nl> - : PhysicsHelper : : cpfloat2float ( cpMomentForCircle ( PhysicsHelper : : float2cpfloat ( mass ) , <nl> + : PhysicsHelper : : cpfloat2float ( cpMomentForCircle ( mass , <nl> 0 , <nl> - PhysicsHelper : : float2cpfloat ( radius ) , <nl> + radius , <nl> PhysicsHelper : : point2cpv ( offset ) ) ) ; <nl> } <nl> <nl> float PhysicsShapeCircle : : calculateDefaultMoment ( ) <nl> auto shape = _cpShapes . front ( ) ; <nl> <nl> return _mass = = PHYSICS_INFINITY ? PHYSICS_INFINITY <nl> - : PhysicsHelper : : cpfloat2float ( cpMomentForCircle ( PhysicsHelper : : float2cpfloat ( _mass ) , <nl> + : PhysicsHelper : : cpfloat2float ( cpMomentForCircle ( _mass , <nl> 0 , <nl> cpCircleShapeGetRadius ( shape ) , <nl> cpCircleShapeGetOffset ( shape ) ) ) ; <nl> Vec2 PhysicsShapeCircle : : getOffset ( ) <nl> <nl> void PhysicsShapeCircle : : updateScale ( ) <nl> { <nl> - cpFloat factor = std : : abs ( PhysicsHelper : : float2cpfloat ( _newScaleX / _scaleX ) ) ; <nl> + cpFloat factor = std : : abs ( _newScaleX / _scaleX ) ; <nl> <nl> cpShape * shape = _cpShapes . front ( ) ; <nl> cpVect v = cpCircleShapeGetOffset ( shape ) ; <nl> - v = cpvmult ( v , PhysicsHelper : : float2cpfloat ( factor ) ) ; <nl> + v = cpvmult ( v , factor ) ; <nl> ( ( cpCircleShape * ) shape ) - > c = v ; <nl> <nl> cpCircleShapeSetRadius ( shape , cpCircleShapeGetRadius ( shape ) * factor ) ; <nl> bool PhysicsShapeEdgeSegment : : init ( const Vec2 & a , const Vec2 & b , const PhysicsMa <nl> auto shape = cpSegmentShapeNew ( s_sharedBody , <nl> PhysicsHelper : : point2cpv ( a ) , <nl> PhysicsHelper : : point2cpv ( b ) , <nl> - PhysicsHelper : : float2cpfloat ( border ) ) ; <nl> + border ) ; <nl> <nl> CC_BREAK_IF ( shape = = nullptr ) ; <nl> <nl> Vec2 PhysicsShapeEdgeSegment : : getCenter ( ) <nl> <nl> void PhysicsShapeEdgeSegment : : updateScale ( ) <nl> { <nl> - cpFloat factorX = PhysicsHelper : : float2cpfloat ( _newScaleX / _scaleX ) ; <nl> - cpFloat factorY = PhysicsHelper : : float2cpfloat ( _newScaleY / _scaleY ) ; <nl> + cpFloat factorX = _newScaleX / _scaleX ; <nl> + cpFloat factorY = _newScaleY / _scaleY ; <nl> <nl> cpShape * shape = _cpShapes . front ( ) ; <nl> cpVect a = cpSegmentShapeGetA ( shape ) ; <nl> Vec2 PhysicsShapePolygon : : getCenter ( ) <nl> <nl> void PhysicsShapePolygon : : updateScale ( ) <nl> { <nl> - cpFloat factorX = PhysicsHelper : : float2cpfloat ( _newScaleX / _scaleX ) ; <nl> - cpFloat factorY = PhysicsHelper : : float2cpfloat ( _newScaleY / _scaleY ) ; <nl> + cpFloat factorX = _newScaleX / _scaleX ; <nl> + cpFloat factorY = _newScaleY / _scaleY ; <nl> <nl> auto shape = _cpShapes . front ( ) ; <nl> int count = cpPolyShapeGetNumVerts ( shape ) ; <nl> bool PhysicsShapeEdgeBox : : init ( const Size & size , const PhysicsMaterial & material <nl> int i = 0 ; <nl> for ( ; i < 4 ; + + i ) <nl> { <nl> - auto shape = cpSegmentShapeNew ( s_sharedBody , vec [ i ] , vec [ ( i + 1 ) % 4 ] , <nl> - PhysicsHelper : : float2cpfloat ( border ) ) ; <nl> + auto shape = cpSegmentShapeNew ( s_sharedBody , vec [ i ] , vec [ ( i + 1 ) % 4 ] , border ) ; <nl> CC_BREAK_IF ( shape = = nullptr ) ; <nl> addShape ( shape ) ; <nl> } <nl> bool PhysicsShapeEdgePolygon : : init ( const Vec2 * points , int count , const PhysicsM <nl> int i = 0 ; <nl> for ( ; i < count ; + + i ) <nl> { <nl> - auto shape = cpSegmentShapeNew ( s_sharedBody , vec [ i ] , vec [ ( i + 1 ) % count ] , <nl> - PhysicsHelper : : float2cpfloat ( border ) ) ; <nl> + auto shape = cpSegmentShapeNew ( s_sharedBody , vec [ i ] , vec [ ( i + 1 ) % count ] , border ) ; <nl> CC_BREAK_IF ( shape = = nullptr ) ; <nl> cpShapeSetElasticity ( shape , 1 . 0f ) ; <nl> cpShapeSetFriction ( shape , 1 . 0f ) ; <nl> PhysicsShapeEdgeChain * PhysicsShapeEdgeChain : : create ( const Vec2 * points , int cou <nl> <nl> void PhysicsShapeEdgePolygon : : updateScale ( ) <nl> { <nl> - cpFloat factorX = PhysicsHelper : : float2cpfloat ( _newScaleX / _scaleX ) ; <nl> - cpFloat factorY = PhysicsHelper : : float2cpfloat ( _newScaleY / _scaleY ) ; <nl> + cpFloat factorX = _newScaleX / _scaleX ; <nl> + cpFloat factorY = _newScaleY / _scaleY ; <nl> <nl> for ( auto shape : _cpShapes ) <nl> { <nl> bool PhysicsShapeEdgeChain : : init ( const Vec2 * points , int count , const PhysicsMat <nl> int i = 0 ; <nl> for ( ; i < count - 1 ; + + i ) <nl> { <nl> - auto shape = cpSegmentShapeNew ( s_sharedBody , vec [ i ] , vec [ i + 1 ] , <nl> - PhysicsHelper : : float2cpfloat ( border ) ) ; <nl> + auto shape = cpSegmentShapeNew ( s_sharedBody , vec [ i ] , vec [ i + 1 ] , border ) ; <nl> CC_BREAK_IF ( shape = = nullptr ) ; <nl> cpShapeSetElasticity ( shape , 1 . 0f ) ; <nl> cpShapeSetFriction ( shape , 1 . 0f ) ; <nl> int PhysicsShapeEdgeChain : : getPointsCount ( ) const <nl> <nl> void PhysicsShapeEdgeChain : : updateScale ( ) <nl> { <nl> - cpFloat factorX = PhysicsHelper : : float2cpfloat ( _newScaleX / _scaleX ) ; <nl> - cpFloat factorY = PhysicsHelper : : float2cpfloat ( _newScaleY / _scaleY ) ; <nl> + cpFloat factorX = _newScaleX / _scaleX ; <nl> + cpFloat factorY = _newScaleY / _scaleY ; <nl> <nl> for ( auto shape : _cpShapes ) <nl> { <nl> mmm a / cocos / physics / CCPhysicsWorld . cpp <nl> ppp b / cocos / physics / CCPhysicsWorld . cpp <nl> int PhysicsWorld : : collisionBeginCallback ( PhysicsContact & contact ) <nl> { <nl> contact . setEventCode ( PhysicsContact : : EventCode : : BEGIN ) ; <nl> contact . setWorld ( this ) ; <nl> - Director : : getInstance ( ) - > getEventDispatcher ( ) - > dispatchEvent ( & contact ) ; <nl> + _eventDispatcher - > dispatchEvent ( & contact ) ; <nl> } <nl> <nl> return ret ? contact . resetResult ( ) : false ; <nl> int PhysicsWorld : : collisionPreSolveCallback ( PhysicsContact & contact ) <nl> <nl> contact . setEventCode ( PhysicsContact : : EventCode : : PRESOLVE ) ; <nl> contact . setWorld ( this ) ; <nl> - Director : : getInstance ( ) - > getEventDispatcher ( ) - > dispatchEvent ( & contact ) ; <nl> + _eventDispatcher - > dispatchEvent ( & contact ) ; <nl> <nl> return contact . resetResult ( ) ; <nl> } <nl> void PhysicsWorld : : collisionPostSolveCallback ( PhysicsContact & contact ) <nl> <nl> contact . setEventCode ( PhysicsContact : : EventCode : : POSTSOLVE ) ; <nl> contact . setWorld ( this ) ; <nl> - Director : : getInstance ( ) - > getEventDispatcher ( ) - > dispatchEvent ( & contact ) ; <nl> + _eventDispatcher - > dispatchEvent ( & contact ) ; <nl> } <nl> <nl> void PhysicsWorld : : collisionSeparateCallback ( PhysicsContact & contact ) <nl> void PhysicsWorld : : collisionSeparateCallback ( PhysicsContact & contact ) <nl> <nl> contact . setEventCode ( PhysicsContact : : EventCode : : SEPARATE ) ; <nl> contact . setWorld ( this ) ; <nl> - Director : : getInstance ( ) - > getEventDispatcher ( ) - > dispatchEvent ( & contact ) ; <nl> + _eventDispatcher - > dispatchEvent ( & contact ) ; <nl> } <nl> <nl> void PhysicsWorld : : rayCast ( PhysicsRayCastCallbackFunc func , const Vec2 & point1 , const Vec2 & point2 , void * data ) <nl> PhysicsShape * PhysicsWorld : : getShape ( const Vec2 & point ) const <nl> return shape = = nullptr ? nullptr : s_physicsShapeMap . find ( shape ) - > second ; <nl> } <nl> <nl> - PhysicsWorld * PhysicsWorld : : construct ( ) <nl> - { <nl> - PhysicsWorld * world = new ( std : : nothrow ) PhysicsWorld ( ) ; <nl> - if ( world & & world - > init ( ) ) <nl> - { <nl> - return world ; <nl> - } <nl> - <nl> - CC_SAFE_DELETE ( world ) ; <nl> - return nullptr ; <nl> - } <nl> - <nl> bool PhysicsWorld : : init ( ) <nl> { <nl> do <nl> void PhysicsWorld : : removeBody ( PhysicsBody * body ) <nl> body - > _world = nullptr ; <nl> } <nl> <nl> - <nl> void PhysicsWorld : : removeBodyOrDelay ( PhysicsBody * body ) <nl> { <nl> if ( _delayAddBodies . getIndex ( body ) ! = CC_INVALID_INDEX ) <nl> PhysicsBody * PhysicsWorld : : getBody ( int tag ) const <nl> return nullptr ; <nl> } <nl> <nl> - void PhysicsWorld : : setGravity ( const Vect & gravity ) <nl> + void PhysicsWorld : : setGravity ( const Vec2 & gravity ) <nl> { <nl> _gravity = gravity ; <nl> cpSpaceSetGravity ( _cpSpace , PhysicsHelper : : point2cpv ( gravity ) ) ; <nl> void PhysicsWorld : : update ( float delta , bool userCall / * = false * / ) <nl> updateBodies ( ) ; <nl> } <nl> <nl> + auto sceneToWorldTransform = _scene - > getNodeToParentTransform ( ) ; <nl> + beforeSimulation ( _scene , sceneToWorldTransform , 1 . f , 1 . f , 0 . f ) ; <nl> + <nl> if ( ! _delayAddJoints . empty ( ) | | ! _delayRemoveJoints . empty ( ) ) <nl> { <nl> updateJoints ( ) ; <nl> void PhysicsWorld : : update ( float delta , bool userCall / * = false * / ) <nl> { <nl> debugDraw ( ) ; <nl> } <nl> + <nl> + / / Update physics position , should loop as the same sequence as node tree . <nl> + / / PhysicsWorld : : afterSimulation ( ) will depend on the sequence . <nl> + afterSimulation ( _scene , sceneToWorldTransform , 0 . f ) ; <nl> + } <nl> + <nl> + PhysicsWorld * PhysicsWorld : : construct ( Scene * scene ) <nl> + { <nl> + PhysicsWorld * world = new ( std : : nothrow ) PhysicsWorld ( ) ; <nl> + if ( world & & world - > init ( ) ) <nl> + { <nl> + world - > _scene = scene ; <nl> + world - > _eventDispatcher = scene - > getEventDispatcher ( ) ; <nl> + return world ; <nl> + } <nl> + <nl> + CC_SAFE_DELETE ( world ) ; <nl> + return nullptr ; <nl> } <nl> <nl> PhysicsWorld : : PhysicsWorld ( ) <nl> PhysicsWorld : : PhysicsWorld ( ) <nl> , _autoStep ( true ) <nl> , _debugDraw ( nullptr ) <nl> , _debugDrawMask ( DEBUGDRAW_NONE ) <nl> + , _eventDispatcher ( nullptr ) <nl> { <nl> <nl> } <nl> PhysicsWorld : : ~ PhysicsWorld ( ) <nl> CC_SAFE_DELETE ( _debugDraw ) ; <nl> } <nl> <nl> + void PhysicsWorld : : beforeSimulation ( Node * node , const Mat4 & parentToWorldTransform , float nodeParentScaleX , float nodeParentScaleY , float parentRotation ) <nl> + { <nl> + auto scaleX = nodeParentScaleX * node - > getScaleX ( ) ; <nl> + auto scaleY = nodeParentScaleY * node - > getScaleY ( ) ; <nl> + auto rotation = parentRotation + node - > getRotation ( ) ; <nl> + <nl> + auto nodeToWorldTransform = parentToWorldTransform * node - > getNodeToParentTransform ( ) ; <nl> + <nl> + auto physicsBody = node - > getPhysicsBody ( ) ; <nl> + if ( physicsBody ) <nl> + { <nl> + physicsBody - > beforeSimulation ( parentToWorldTransform , nodeToWorldTransform , scaleX , scaleY , rotation ) ; <nl> + } <nl> + <nl> + for ( auto child : node - > getChildren ( ) ) <nl> + beforeSimulation ( child , nodeToWorldTransform , scaleX , scaleY , rotation ) ; <nl> + } <nl> + <nl> + void PhysicsWorld : : afterSimulation ( Node * node , const Mat4 & parentToWorldTransform , float parentRotation ) <nl> + { <nl> + auto nodeToWorldTransform = parentToWorldTransform * node - > getNodeToParentTransform ( ) ; <nl> + auto nodeRotation = parentRotation + node - > getRotation ( ) ; <nl> + <nl> + auto physicsBody = node - > getPhysicsBody ( ) ; <nl> + if ( physicsBody ) <nl> + { <nl> + physicsBody - > afterSimulation ( parentToWorldTransform , parentRotation ) ; <nl> + } <nl> + <nl> + for ( auto child : node - > getChildren ( ) ) <nl> + afterSimulation ( child , nodeToWorldTransform , nodeRotation ) ; <nl> + } <nl> + <nl> + <nl> PhysicsDebugDraw : : PhysicsDebugDraw ( PhysicsWorld & world ) <nl> : _drawNode ( nullptr ) <nl> , _world ( world ) <nl> mmm a / cocos / physics / CCPhysicsWorld . h <nl> ppp b / cocos / physics / CCPhysicsWorld . h <nl> <nl> # include " base / ccConfig . h " <nl> # if CC_USE_PHYSICS <nl> <nl> + # include < list > <nl> # include " base / CCVector . h " <nl> - # include " base / CCRef . h " <nl> # include " math / CCGeometry . h " <nl> # include " physics / CCPhysicsBody . h " <nl> - # include < list > <nl> <nl> struct cpSpace ; <nl> <nl> class PhysicsJoint ; <nl> class PhysicsShape ; <nl> class PhysicsContact ; <nl> <nl> - typedef Vec2 Vect ; <nl> - <nl> class Director ; <nl> class Node ; <nl> class Sprite ; <nl> class Scene ; <nl> class DrawNode ; <nl> class PhysicsDebugDraw ; <nl> + class EventDispatcher ; <nl> <nl> class PhysicsWorld ; <nl> <nl> typedef struct PhysicsRayCastInfo <nl> Vec2 start ; <nl> Vec2 end ; / / < in lua , it ' s name is " ended " <nl> Vec2 contact ; <nl> - Vect normal ; <nl> + Vec2 normal ; <nl> float fraction ; <nl> void * data ; <nl> } PhysicsRayCastInfo ; <nl> class CC_DLL PhysicsWorld <nl> / * * <nl> * Get the gravity value of this physics world . <nl> * <nl> - * @ return A Vect object . <nl> + * @ return A Vec2 object . <nl> * / <nl> - inline Vect getGravity ( ) const { return _gravity ; } <nl> + inline Vec2 getGravity ( ) const { return _gravity ; } <nl> <nl> / * * <nl> * set the gravity value of this physics world . <nl> * <nl> * @ param gravity A gravity value of this physics world . <nl> * / <nl> - void setGravity ( const Vect & gravity ) ; <nl> + void setGravity ( const Vec2 & gravity ) ; <nl> <nl> / * * <nl> * Set the speed of this physics world . <nl> class CC_DLL PhysicsWorld <nl> void step ( float delta ) ; <nl> <nl> protected : <nl> - static PhysicsWorld * construct ( ) ; <nl> + static PhysicsWorld * construct ( Scene * scene ) ; <nl> bool init ( ) ; <nl> <nl> <nl> class CC_DLL PhysicsWorld <nl> virtual void updateJoints ( ) ; <nl> <nl> protected : <nl> - Vect _gravity ; <nl> + Vec2 _gravity ; <nl> float _speed ; <nl> int _updateRate ; <nl> int _updateRateCount ; <nl> class CC_DLL PhysicsWorld <nl> PhysicsDebugDraw * _debugDraw ; <nl> int _debugDrawMask ; <nl> <nl> - <nl> + EventDispatcher * _eventDispatcher ; <nl> + <nl> Vector < PhysicsBody * > _delayAddBodies ; <nl> Vector < PhysicsBody * > _delayRemoveBodies ; <nl> std : : vector < PhysicsJoint * > _delayAddJoints ; <nl> class CC_DLL PhysicsWorld <nl> PhysicsWorld ( ) ; <nl> virtual ~ PhysicsWorld ( ) ; <nl> <nl> + void beforeSimulation ( Node * node , const Mat4 & parentToWorldTransform , float nodeParentScaleX , float nodeParentScaleY , float parentRotation ) ; <nl> + void afterSimulation ( Node * node , const Mat4 & parentToWorldTransform , float parentRotation ) ; <nl> + <nl> friend class Node ; <nl> friend class Sprite ; <nl> friend class Scene ; <nl> class CC_DLL PhysicsWorld <nl> friend class PhysicsJoint ; <nl> friend class PhysicsWorldCallback ; <nl> friend class PhysicsDebugDraw ; <nl> - friend class PhysicsManager ; <nl> } ; <nl> <nl> / * * A physics helper class . Draw physics shape , joint in debug mode . <nl> mmm a / cocos / physics / CMakeLists . txt <nl> ppp b / cocos / physics / CMakeLists . txt <nl> set ( COCOS_PHYSICS_SRC <nl> physics / CCPhysicsJoint . cpp <nl> physics / CCPhysicsShape . cpp <nl> physics / CCPhysicsWorld . cpp <nl> - physics / CCComponentPhysics2d . cpp <nl> - physics / CCPhysicsManager . cpp <nl> ) <nl> mmm a / tests / cpp - tests / Classes / PhysicsTest / PhysicsTest . cpp <nl> ppp b / tests / cpp - tests / Classes / PhysicsTest / PhysicsTest . cpp <nl> <nl> <nl> # include < cmath > <nl> # include " ui / CocosGUI . h " <nl> - # include " physics / CCComponentPhysics2d . h " <nl> # include " . . / testResource . h " <nl> <nl> USING_NS_CC ; <nl> Sprite * PhysicsDemo : : addGrossiniAtPosition ( Vec2 p , float scale / * = 1 . 0 * / ) <nl> <nl> sp - > setScale ( scale ) ; <nl> sp - > setPosition ( p ) ; <nl> - addPhysicsComponent ( sp , PhysicsBody : : createBox ( Size ( 48 . 0f , 108 . 0f ) ) ) ; <nl> - / / addPhysicsComponent ( sp , PhysicsBody : : createCircle ( sp - > getContentSize ( ) . height / 2 ) ) ; <nl> + sp - > addComponent ( PhysicsBody : : createBox ( Size ( 48 . 0f , 108 . 0f ) ) ) ; <nl> this - > addChild ( sp ) ; <nl> <nl> return sp ; <nl> Sprite * PhysicsDemo : : makeBall ( Vec2 point , float radius , PhysicsMaterial material <nl> <nl> ball - > setScale ( 0 . 13f * radius ) ; <nl> <nl> - addPhysicsComponent ( ball , PhysicsBody : : createCircle ( ball - > getContentSize ( ) . width / 2 , material ) ) ; <nl> + ball - > addComponent ( PhysicsBody : : createCircle ( ball - > getContentSize ( ) . width / 2 , material ) ) ; <nl> ball - > setPosition ( Vec2 ( point . x , point . y ) ) ; <nl> <nl> return ball ; <nl> Sprite * PhysicsDemo : : makeBox ( Vec2 point , Size size , int color , PhysicsMaterial m <nl> box - > setScaleX ( size . width / 100 . 0f ) ; <nl> box - > setScaleY ( size . height / 100 . 0f ) ; <nl> <nl> - addPhysicsComponent ( box , PhysicsBody : : createBox ( box - > getContentSize ( ) , material ) ) ; <nl> + box - > addComponent ( PhysicsBody : : createBox ( box - > getContentSize ( ) , material ) ) ; <nl> <nl> box - > setPosition ( Vec2 ( point . x , point . y ) ) ; <nl> <nl> Sprite * PhysicsDemo : : makeTriangle ( Vec2 point , Size size , int color , PhysicsMater <nl> <nl> Vec2 vers [ ] = { Vec2 ( 0 , triangle - > getContentSize ( ) . height / 2 ) , Vec2 ( triangle - > getContentSize ( ) . width / 2 , - triangle - > getContentSize ( ) . height / 2 ) , Vec2 ( - triangle - > getContentSize ( ) . width / 2 , - triangle - > getContentSize ( ) . height / 2 ) } ; <nl> <nl> - addPhysicsComponent ( triangle , PhysicsBody : : createPolygon ( vers , 3 , material ) ) ; <nl> + triangle - > addComponent ( PhysicsBody : : createPolygon ( vers , 3 , material ) ) ; <nl> triangle - > setPosition ( Vec2 ( point . x , point . y ) ) ; <nl> <nl> return triangle ; <nl> bool PhysicsDemo : : onTouchBegan ( Touch * touch , Event * event ) <nl> Node * mouse = Node : : create ( ) ; <nl> auto physicsBody = PhysicsBody : : create ( PHYSICS_INFINITY , PHYSICS_INFINITY ) ; <nl> physicsBody - > setDynamic ( false ) ; <nl> - addPhysicsComponent ( mouse , physicsBody ) ; <nl> + mouse - > addComponent ( physicsBody ) ; <nl> mouse - > setPosition ( location ) ; <nl> this - > addChild ( mouse ) ; <nl> PhysicsJointPin * joint = PhysicsJointPin : : construct ( physicsBody , body , location ) ; <nl> void PhysicsDemo : : onTouchEnded ( Touch * touch , Event * event ) <nl> } <nl> } <nl> <nl> - void PhysicsDemo : : addPhysicsComponent ( Node * node , PhysicsBody * physicsBody ) <nl> - { <nl> - auto physicsComponent = ComponentPhysics2d : : create ( ) ; <nl> - physicsComponent - > setPhysicsBody ( physicsBody ) ; <nl> - node - > addComponent ( physicsComponent ) ; <nl> - } <nl> - <nl> / / Implementation of PhysicsComponentDemoLogoSmash <nl> <nl> void PhysicsDemoLogoSmash : : onEnter ( ) <nl> void PhysicsDemoLogoSmash : : onEnter ( ) <nl> 2 * ( LOGO_HEIGHT - y + yJitter ) + VisibleRect : : getVisibleRect ( ) . size . height / 2 - LOGO_HEIGHT / 2 ) , <nl> 0 . 95f , PhysicsMaterial ( 0 . 01f , 0 . 0f , 0 . 0f ) ) ; <nl> <nl> - auto physicsBody = ball - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) ; <nl> + auto physicsBody = ball - > getPhysicsBody ( ) ; <nl> physicsBody - > setMass ( 1 . 0 ) ; <nl> physicsBody - > setMoment ( PHYSICS_INFINITY ) ; <nl> <nl> void PhysicsDemoLogoSmash : : onEnter ( ) <nl> <nl> <nl> auto bullet = makeBall ( Vec2 ( 400 , 0 ) , 10 , PhysicsMaterial ( PHYSICS_INFINITY , 0 , 0 ) ) ; <nl> - bullet - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) - > setVelocity ( Vec2 ( 200 , 0 ) ) ; <nl> + bullet - > getPhysicsBody ( ) - > setVelocity ( Vec2 ( 200 , 0 ) ) ; <nl> <nl> bullet - > setPosition ( Vec2 ( - 500 , VisibleRect : : getVisibleRect ( ) . size . height / 2 ) ) ; <nl> <nl> void PhysicsDemoClickAdd : : onEnter ( ) <nl> _eventDispatcher - > addEventListenerWithSceneGraphPriority ( accListener , this ) ; <nl> <nl> auto node = Node : : create ( ) ; <nl> - addPhysicsComponent ( node , PhysicsBody : : createEdgeBox ( VisibleRect : : getVisibleRect ( ) . size ) ) ; <nl> + node - > addComponent ( PhysicsBody : : createEdgeBox ( VisibleRect : : getVisibleRect ( ) . size ) ) ; <nl> node - > setPosition ( VisibleRect : : center ( ) ) ; <nl> this - > addChild ( node ) ; <nl> <nl> void PhysicsDemoPyramidStack : : onEnter ( ) <nl> _eventDispatcher - > addEventListenerWithSceneGraphPriority ( touchListener , this ) ; <nl> <nl> auto node = Node : : create ( ) ; <nl> - addPhysicsComponent ( node , PhysicsBody : : createEdgeSegment ( VisibleRect : : leftBottom ( ) + Vec2 ( 0 , 50 ) , VisibleRect : : rightBottom ( ) + Vec2 ( 0 , 50 ) ) ) ; <nl> + node - > addComponent ( PhysicsBody : : createEdgeSegment ( VisibleRect : : leftBottom ( ) + Vec2 ( 0 , 50 ) , <nl> + VisibleRect : : rightBottom ( ) + Vec2 ( 0 , 50 ) ) ) ; <nl> this - > addChild ( node ) ; <nl> <nl> auto ball = Sprite : : create ( " Images / ball . png " ) ; <nl> ball - > setScale ( 1 ) ; <nl> ball - > setTag ( 100 ) ; <nl> - addPhysicsComponent ( ball , PhysicsBody : : createCircle ( 10 ) ) ; <nl> - ball - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) - > setTag ( DRAG_BODYS_TAG ) ; <nl> + auto body = PhysicsBody : : createCircle ( 10 ) ; <nl> + ball - > addComponent ( body ) ; <nl> + body - > setTag ( DRAG_BODYS_TAG ) ; <nl> ball - > setPosition ( VisibleRect : : bottom ( ) + Vec2 ( 0 , 60 ) ) ; <nl> this - > addChild ( ball ) ; <nl> <nl> void PhysicsDemoPyramidStack : : onEnter ( ) <nl> for ( int j = 0 ; j < = i ; j + + ) <nl> { <nl> auto sp = addGrossiniAtPosition ( VisibleRect : : bottom ( ) + Vec2 ( ( i / 2 - j ) * 11 , ( 14 - i ) * 23 + 100 ) , 0 . 2f ) ; <nl> - sp - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) - > setTag ( DRAG_BODYS_TAG ) ; <nl> + sp - > getPhysicsBody ( ) - > setTag ( DRAG_BODYS_TAG ) ; <nl> } <nl> } <nl> } <nl> void PhysicsDemoRayCast : : onEnter ( ) <nl> _physicsWorld - > setGravity ( Point : : ZERO ) ; <nl> <nl> auto node = DrawNode : : create ( ) ; <nl> - addPhysicsComponent ( node , PhysicsBody : : createEdgeSegment ( VisibleRect : : leftBottom ( ) + Vec2 ( 0 , 50 ) , VisibleRect : : rightBottom ( ) + Vec2 ( 0 , 50 ) ) ) ; <nl> + node - > addComponent ( PhysicsBody : : createEdgeSegment ( VisibleRect : : leftBottom ( ) + Vec2 ( 0 , 50 ) , VisibleRect : : rightBottom ( ) + Vec2 ( 0 , 50 ) ) ) ; <nl> node - > drawSegment ( VisibleRect : : leftBottom ( ) + Vec2 ( 0 , 50 ) , VisibleRect : : rightBottom ( ) + Vec2 ( 0 , 50 ) , 1 , STATIC_COLOR ) ; <nl> this - > addChild ( node ) ; <nl> <nl> std : : string PhysicsDemoRayCast : : title ( ) const <nl> void PhysicsDemoActions : : onEnter ( ) <nl> { <nl> PhysicsDemo : : onEnter ( ) ; <nl> - _physicsWorld - > setGravity ( Vect : : ZERO ) ; <nl> + _physicsWorld - > setGravity ( Vec2 : : ZERO ) ; <nl> <nl> auto touchListener = EventListenerTouchOneByOne : : create ( ) ; <nl> touchListener - > onTouchBegan = CC_CALLBACK_2 ( PhysicsDemoActions : : onTouchBegan , this ) ; <nl> void PhysicsDemoActions : : onEnter ( ) <nl> _eventDispatcher - > addEventListenerWithSceneGraphPriority ( touchListener , this ) ; <nl> <nl> auto node = Node : : create ( ) ; <nl> - addPhysicsComponent ( node , PhysicsBody : : createEdgeBox ( VisibleRect : : getVisibleRect ( ) . size ) ) ; <nl> + node - > addComponent ( PhysicsBody : : createEdgeBox ( VisibleRect : : getVisibleRect ( ) . size ) ) ; <nl> node - > setPosition ( VisibleRect : : center ( ) ) ; <nl> this - > addChild ( node ) ; <nl> <nl> void PhysicsDemoActions : : onEnter ( ) <nl> Sprite * sp2 = addGrossiniAtPosition ( VisibleRect : : left ( ) + Vec2 ( 50 , 0 ) ) ; <nl> Sprite * sp3 = addGrossiniAtPosition ( VisibleRect : : right ( ) - Vec2 ( 20 , 0 ) ) ; <nl> Sprite * sp4 = addGrossiniAtPosition ( VisibleRect : : leftTop ( ) + Vec2 ( 50 , - 50 ) ) ; <nl> - sp4 - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) - > setGravityEnable ( false ) ; <nl> + sp4 - > getPhysicsBody ( ) - > setGravityEnable ( false ) ; <nl> <nl> - sp1 - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) - > setTag ( DRAG_BODYS_TAG ) ; <nl> - sp2 - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) - > setTag ( DRAG_BODYS_TAG ) ; <nl> - sp3 - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) - > setTag ( DRAG_BODYS_TAG ) ; <nl> - sp4 - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) - > setTag ( DRAG_BODYS_TAG ) ; <nl> + sp1 - > getPhysicsBody ( ) - > setTag ( DRAG_BODYS_TAG ) ; <nl> + sp2 - > getPhysicsBody ( ) - > setTag ( DRAG_BODYS_TAG ) ; <nl> + sp3 - > getPhysicsBody ( ) - > setTag ( DRAG_BODYS_TAG ) ; <nl> + sp4 - > getPhysicsBody ( ) - > setTag ( DRAG_BODYS_TAG ) ; <nl> <nl> auto actionTo = JumpTo : : create ( 2 , Vec2 ( 100 , 100 ) , 50 , 4 ) ; <nl> auto actionBy = JumpBy : : create ( 2 , Vec2 ( 300 , 0 ) , 50 , 4 ) ; <nl> void PhysicsDemoJoints : : onEnter ( ) <nl> <nl> Node * node = Node : : create ( ) ; <nl> PhysicsBody * box = PhysicsBody : : create ( ) ; <nl> - addPhysicsComponent ( node , box ) ; <nl> + node - > addComponent ( box ) ; <nl> <nl> box - > setDynamic ( false ) ; <nl> node - > setPosition ( Point : : ZERO ) ; <nl> void PhysicsDemoJoints : : onEnter ( ) <nl> case 0 : <nl> { <nl> auto sp1 = makeBall ( offset - Vec2 ( 30 , 0 ) , 10 ) ; <nl> - auto sp1PhysicsBody = sp1 - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) ; <nl> + auto sp1PhysicsBody = sp1 - > getPhysicsBody ( ) ; <nl> sp1PhysicsBody - > setTag ( DRAG_BODYS_TAG ) ; <nl> <nl> auto sp2 = makeBall ( offset + Vec2 ( 30 , 0 ) , 10 ) ; <nl> - auto sp2PhysicsBody = sp2 - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) ; <nl> + auto sp2PhysicsBody = sp2 - > getPhysicsBody ( ) ; <nl> sp2PhysicsBody - > setTag ( DRAG_BODYS_TAG ) ; <nl> <nl> PhysicsJointPin * joint = PhysicsJointPin : : construct ( sp1PhysicsBody , sp2PhysicsBody , offset ) ; <nl> void PhysicsDemoJoints : : onEnter ( ) <nl> { <nl> <nl> auto sp1 = makeBall ( offset - Vec2 ( 30 , 0 ) , 10 ) ; <nl> - auto sp1PhysicsBody = sp1 - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) ; <nl> + auto sp1PhysicsBody = sp1 - > getPhysicsBody ( ) ; <nl> sp1PhysicsBody - > setTag ( DRAG_BODYS_TAG ) ; <nl> <nl> auto sp2 = makeBox ( offset + Vec2 ( 30 , 0 ) , Size ( 30 , 10 ) ) ; <nl> - auto sp2PhysicsBody = sp2 - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) ; <nl> + auto sp2PhysicsBody = sp2 - > getPhysicsBody ( ) ; <nl> sp2PhysicsBody - > setTag ( DRAG_BODYS_TAG ) ; <nl> <nl> PhysicsJointFixed * joint = PhysicsJointFixed : : construct ( sp1PhysicsBody , sp2PhysicsBody , offset ) ; <nl> void PhysicsDemoJoints : : onEnter ( ) <nl> case 2 : <nl> { <nl> auto sp1 = makeBall ( offset - Vec2 ( 30 , 0 ) , 10 ) ; <nl> - auto sp1PhysicsBody = sp1 - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) ; <nl> + auto sp1PhysicsBody = sp1 - > getPhysicsBody ( ) ; <nl> sp1PhysicsBody - > setTag ( DRAG_BODYS_TAG ) ; <nl> <nl> auto sp2 = makeBox ( offset + Vec2 ( 30 , 0 ) , Size ( 30 , 10 ) ) ; <nl> - auto sp2PhysicsBody = sp2 - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) ; <nl> + auto sp2PhysicsBody = sp2 - > getPhysicsBody ( ) ; <nl> sp2PhysicsBody - > setTag ( DRAG_BODYS_TAG ) ; <nl> <nl> PhysicsJointDistance * joint = PhysicsJointDistance : : construct ( sp1PhysicsBody , sp2PhysicsBody , Point : : ZERO , Point : : ZERO ) ; <nl> void PhysicsDemoJoints : : onEnter ( ) <nl> case 3 : <nl> { <nl> auto sp1 = makeBall ( offset - Vec2 ( 30 , 0 ) , 10 ) ; <nl> - auto sp1PhysicsBody = sp1 - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) ; <nl> + auto sp1PhysicsBody = sp1 - > getPhysicsBody ( ) ; <nl> sp1PhysicsBody - > setTag ( DRAG_BODYS_TAG ) ; <nl> <nl> auto sp2 = makeBox ( offset + Vec2 ( 30 , 0 ) , Size ( 30 , 10 ) ) ; <nl> - auto sp2PhysicsBody = sp2 - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) ; <nl> + auto sp2PhysicsBody = sp2 - > getPhysicsBody ( ) ; <nl> sp2PhysicsBody - > setTag ( DRAG_BODYS_TAG ) ; <nl> <nl> PhysicsJointLimit * joint = PhysicsJointLimit : : construct ( sp1PhysicsBody , sp2PhysicsBody , Point : : ZERO , Point : : ZERO , 30 . 0f , 60 . 0f ) ; <nl> void PhysicsDemoJoints : : onEnter ( ) <nl> case 4 : <nl> { <nl> auto sp1 = makeBall ( offset - Vec2 ( 30 , 0 ) , 10 ) ; <nl> - auto sp1PhysicsBody = sp1 - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) ; <nl> + auto sp1PhysicsBody = sp1 - > getPhysicsBody ( ) ; <nl> sp1PhysicsBody - > setTag ( DRAG_BODYS_TAG ) ; <nl> <nl> auto sp2 = makeBox ( offset + Vec2 ( 30 , 0 ) , Size ( 30 , 10 ) ) ; <nl> - auto sp2PhysicsBody = sp2 - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) ; <nl> + auto sp2PhysicsBody = sp2 - > getPhysicsBody ( ) ; <nl> sp2PhysicsBody - > setTag ( DRAG_BODYS_TAG ) ; <nl> <nl> PhysicsJointSpring * joint = PhysicsJointSpring : : construct ( sp1PhysicsBody , sp2PhysicsBody , Point : : ZERO , Point : : ZERO , 500 . 0f , 0 . 3f ) ; <nl> void PhysicsDemoJoints : : onEnter ( ) <nl> case 5 : <nl> { <nl> auto sp1 = makeBall ( offset - Vec2 ( 30 , 0 ) , 10 ) ; <nl> - auto sp1PhysicsBody = sp1 - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) ; <nl> + auto sp1PhysicsBody = sp1 - > getPhysicsBody ( ) ; <nl> sp1PhysicsBody - > setTag ( DRAG_BODYS_TAG ) ; <nl> <nl> auto sp2 = makeBox ( offset + Vec2 ( 30 , 0 ) , Size ( 30 , 10 ) ) ; <nl> - auto sp2PhysicsBody = sp2 - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) ; <nl> + auto sp2PhysicsBody = sp2 - > getPhysicsBody ( ) ; <nl> sp2PhysicsBody - > setTag ( DRAG_BODYS_TAG ) ; <nl> <nl> PhysicsJointGroove * joint = PhysicsJointGroove : : construct ( sp1PhysicsBody , sp2PhysicsBody , Vec2 ( 30 , 15 ) , Vec2 ( 30 , - 15 ) , Vec2 ( - 30 , 0 ) ) ; <nl> void PhysicsDemoJoints : : onEnter ( ) <nl> case 6 : <nl> { <nl> auto sp1 = makeBox ( offset - Vec2 ( 30 , 0 ) , Size ( 30 , 10 ) ) ; <nl> - auto sp1PhysicsBody = sp1 - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) ; <nl> + auto sp1PhysicsBody = sp1 - > getPhysicsBody ( ) ; <nl> sp1PhysicsBody - > setTag ( DRAG_BODYS_TAG ) ; <nl> <nl> auto sp2 = makeBox ( offset + Vec2 ( 30 , 0 ) , Size ( 30 , 10 ) ) ; <nl> - auto sp2PhysicsBody = sp2 - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) ; <nl> + auto sp2PhysicsBody = sp2 - > getPhysicsBody ( ) ; <nl> sp2PhysicsBody - > setTag ( DRAG_BODYS_TAG ) ; <nl> <nl> getPhysicsWorld ( ) - > addJoint ( PhysicsJointPin : : construct ( sp1PhysicsBody , box , sp1 - > getPosition ( ) ) ) ; <nl> void PhysicsDemoJoints : : onEnter ( ) <nl> case 7 : <nl> { <nl> auto sp1 = makeBox ( offset - Vec2 ( 30 , 0 ) , Size ( 30 , 10 ) ) ; <nl> - auto sp1PhysicsBody = sp1 - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) ; <nl> + auto sp1PhysicsBody = sp1 - > getPhysicsBody ( ) ; <nl> sp1PhysicsBody - > setTag ( DRAG_BODYS_TAG ) ; <nl> <nl> auto sp2 = makeBox ( offset + Vec2 ( 30 , 0 ) , Size ( 30 , 10 ) ) ; <nl> - auto sp2PhysicsBody = sp2 - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) ; <nl> + auto sp2PhysicsBody = sp2 - > getPhysicsBody ( ) ; <nl> sp2PhysicsBody - > setTag ( DRAG_BODYS_TAG ) ; <nl> <nl> getPhysicsWorld ( ) - > addJoint ( PhysicsJointPin : : construct ( sp1PhysicsBody , box , sp1 - > getPosition ( ) ) ) ; <nl> void PhysicsDemoJoints : : onEnter ( ) <nl> case 8 : <nl> { <nl> auto sp1 = makeBox ( offset - Vec2 ( 30 , 0 ) , Size ( 30 , 10 ) ) ; <nl> - auto sp1PhysicsBody = sp1 - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) ; <nl> + auto sp1PhysicsBody = sp1 - > getPhysicsBody ( ) ; <nl> sp1PhysicsBody - > setTag ( DRAG_BODYS_TAG ) ; <nl> <nl> auto sp2 = makeBox ( offset + Vec2 ( 30 , 0 ) , Size ( 30 , 10 ) ) ; <nl> - auto sp2PhysicsBody = sp2 - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) ; <nl> + auto sp2PhysicsBody = sp2 - > getPhysicsBody ( ) ; <nl> sp2PhysicsBody - > setTag ( DRAG_BODYS_TAG ) ; <nl> <nl> getPhysicsWorld ( ) - > addJoint ( PhysicsJointPin : : construct ( sp1PhysicsBody , box , sp1 - > getPosition ( ) ) ) ; <nl> void PhysicsDemoJoints : : onEnter ( ) <nl> case 9 : <nl> { <nl> auto sp1 = makeBox ( offset - Vec2 ( 30 , 0 ) , Size ( 30 , 10 ) ) ; <nl> - auto sp1PhysicsBody = sp1 - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) ; <nl> + auto sp1PhysicsBody = sp1 - > getPhysicsBody ( ) ; <nl> sp1PhysicsBody - > setTag ( DRAG_BODYS_TAG ) ; <nl> <nl> auto sp2 = makeBox ( offset + Vec2 ( 30 , 0 ) , Size ( 30 , 10 ) ) ; <nl> - auto sp2PhysicsBody = sp2 - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) ; <nl> + auto sp2PhysicsBody = sp2 - > getPhysicsBody ( ) ; <nl> sp2PhysicsBody - > setTag ( DRAG_BODYS_TAG ) ; <nl> <nl> getPhysicsWorld ( ) - > addJoint ( PhysicsJointPin : : construct ( sp1PhysicsBody , box , sp1 - > getPosition ( ) ) ) ; <nl> void PhysicsDemoJoints : : onEnter ( ) <nl> case 10 : <nl> { <nl> auto sp1 = makeBox ( offset - Vec2 ( 30 , 0 ) , Size ( 30 , 10 ) ) ; <nl> - auto sp1PhysicsBody = sp1 - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) ; <nl> + auto sp1PhysicsBody = sp1 - > getPhysicsBody ( ) ; <nl> sp1PhysicsBody - > setTag ( DRAG_BODYS_TAG ) ; <nl> <nl> auto sp2 = makeBox ( offset + Vec2 ( 30 , 0 ) , Size ( 30 , 10 ) ) ; <nl> - auto sp2PhysicsBody = sp2 - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) ; <nl> + auto sp2PhysicsBody = sp2 - > getPhysicsBody ( ) ; <nl> sp2PhysicsBody - > setTag ( DRAG_BODYS_TAG ) ; <nl> <nl> getPhysicsWorld ( ) - > addJoint ( PhysicsJointPin : : construct ( sp1PhysicsBody , box , sp1 - > getPosition ( ) ) ) ; <nl> void PhysicsDemoPump : : onEnter ( ) <nl> scheduleUpdate ( ) ; <nl> <nl> auto node = Node : : create ( ) ; <nl> - addPhysicsComponent ( node , PhysicsBody : : create ( ) ) ; <nl> - node - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) - > setDynamic ( false ) ; <nl> + auto nodeBody = PhysicsBody : : create ( ) ; <nl> + node - > addComponent ( nodeBody ) ; <nl> + nodeBody - > setDynamic ( false ) ; <nl> <nl> PhysicsMaterial staticMaterial ( PHYSICS_INFINITY , 0 , 0 . 5f ) ; <nl> - node - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) - > addShape ( PhysicsShapeEdgeSegment : : create ( VisibleRect : : leftTop ( ) + Vec2 ( 50 , 0 ) , VisibleRect : : leftTop ( ) + Vec2 ( 50 , - 130 ) , staticMaterial , 2 . 0f ) ) ; <nl> - node - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) - > addShape ( PhysicsShapeEdgeSegment : : create ( VisibleRect : : leftTop ( ) + Vec2 ( 190 , 0 ) , VisibleRect : : leftTop ( ) + Vec2 ( 100 , - 50 ) , staticMaterial , 2 . 0f ) ) ; <nl> - node - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) - > addShape ( PhysicsShapeEdgeSegment : : create ( VisibleRect : : leftTop ( ) + Vec2 ( 100 , - 50 ) , VisibleRect : : leftTop ( ) + Vec2 ( 100 , - 90 ) , staticMaterial , 2 . 0f ) ) ; <nl> - node - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) - > addShape ( PhysicsShapeEdgeSegment : : create ( VisibleRect : : leftTop ( ) + Vec2 ( 50 , - 130 ) , VisibleRect : : leftTop ( ) + Vec2 ( 100 , - 145 ) , staticMaterial , 2 . 0f ) ) ; <nl> - node - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) - > addShape ( PhysicsShapeEdgeSegment : : create ( VisibleRect : : leftTop ( ) + Vec2 ( 100 , - 145 ) , VisibleRect : : leftBottom ( ) + Vec2 ( 100 , 80 ) , staticMaterial , 2 . 0f ) ) ; <nl> - node - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) - > addShape ( PhysicsShapeEdgeSegment : : create ( VisibleRect : : leftTop ( ) + Vec2 ( 150 , - 80 ) , VisibleRect : : leftBottom ( ) + Vec2 ( 150 , 80 ) , staticMaterial , 2 . 0f ) ) ; <nl> - node - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) - > addShape ( PhysicsShapeEdgeSegment : : create ( VisibleRect : : leftTop ( ) + Vec2 ( 150 , - 80 ) , VisibleRect : : rightTop ( ) + Vec2 ( - 100 , - 150 ) , staticMaterial , 2 . 0f ) ) ; <nl> - <nl> - node - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) - > setCategoryBitmask ( 0x01 ) ; <nl> + nodeBody - > addShape ( PhysicsShapeEdgeSegment : : create ( VisibleRect : : leftTop ( ) + Vec2 ( 50 , 0 ) , VisibleRect : : leftTop ( ) + Vec2 ( 50 , - 130 ) , staticMaterial , 2 . 0f ) ) ; <nl> + nodeBody - > addShape ( PhysicsShapeEdgeSegment : : create ( VisibleRect : : leftTop ( ) + Vec2 ( 190 , 0 ) , VisibleRect : : leftTop ( ) + Vec2 ( 100 , - 50 ) , staticMaterial , 2 . 0f ) ) ; <nl> + nodeBody - > addShape ( PhysicsShapeEdgeSegment : : create ( VisibleRect : : leftTop ( ) + Vec2 ( 100 , - 50 ) , VisibleRect : : leftTop ( ) + Vec2 ( 100 , - 90 ) , staticMaterial , 2 . 0f ) ) ; <nl> + nodeBody - > addShape ( PhysicsShapeEdgeSegment : : create ( VisibleRect : : leftTop ( ) + Vec2 ( 50 , - 130 ) , VisibleRect : : leftTop ( ) + Vec2 ( 100 , - 145 ) , staticMaterial , 2 . 0f ) ) ; <nl> + nodeBody - > addShape ( PhysicsShapeEdgeSegment : : create ( VisibleRect : : leftTop ( ) + Vec2 ( 100 , - 145 ) , VisibleRect : : leftBottom ( ) + Vec2 ( 100 , 80 ) , staticMaterial , 2 . 0f ) ) ; <nl> + nodeBody - > addShape ( PhysicsShapeEdgeSegment : : create ( VisibleRect : : leftTop ( ) + Vec2 ( 150 , - 80 ) , VisibleRect : : leftBottom ( ) + Vec2 ( 150 , 80 ) , staticMaterial , 2 . 0f ) ) ; <nl> + nodeBody - > addShape ( PhysicsShapeEdgeSegment : : create ( VisibleRect : : leftTop ( ) + Vec2 ( 150 , - 80 ) , VisibleRect : : rightTop ( ) + Vec2 ( - 100 , - 150 ) , staticMaterial , 2 . 0f ) ) ; <nl> + <nl> + nodeBody - > setCategoryBitmask ( 0x01 ) ; <nl> node - > setPosition ( Vec2 : : ZERO ) ; <nl> this - > addChild ( node ) ; <nl> <nl> void PhysicsDemoPump : : onEnter ( ) <nl> for ( int i = 0 ; i < 6 ; + + i ) <nl> { <nl> auto ball = makeBall ( VisibleRect : : leftTop ( ) + Vec2 ( 75 + CCRANDOM_0_1 ( ) * 90 , 0 ) , 22 , PhysicsMaterial ( 0 . 05f , 0 . 0f , 0 . 1f ) ) ; <nl> - ball - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) - > setTag ( DRAG_BODYS_TAG ) ; <nl> + ball - > getPhysicsBody ( ) - > setTag ( DRAG_BODYS_TAG ) ; <nl> addChild ( ball ) ; <nl> } <nl> <nl> void PhysicsDemoPump : : onEnter ( ) <nl> auto pump = Node : : create ( ) ; <nl> auto center = PhysicsShape : : getPolyonCenter ( vec , 4 ) ; <nl> pump - > setPosition ( center ) ; <nl> - addPhysicsComponent ( pump , PhysicsBody : : createPolygon ( vec , 4 , PHYSICSBODY_MATERIAL_DEFAULT , - center ) ) ; <nl> + auto pumpBody = PhysicsBody : : createPolygon ( vec , 4 , PHYSICSBODY_MATERIAL_DEFAULT , - center ) ; <nl> + pump - > addComponent ( pumpBody ) ; <nl> this - > addChild ( pump ) ; <nl> - pump - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) - > setCategoryBitmask ( 0x02 ) ; <nl> - pump - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) - > setGravityEnable ( false ) ; <nl> - <nl> - / / small gear <nl> + pumpBody - > setCategoryBitmask ( 0x02 ) ; <nl> + pumpBody - > setGravityEnable ( false ) ; <nl> + <nl> + / / small gear <nl> + auto sgearBody = PhysicsBody : : createCircle ( 44 ) ; <nl> + sgearBody - > setCategoryBitmask ( 0x04 ) ; <nl> + sgearBody - > setCollisionBitmask ( 0x04 ) ; <nl> + sgearBody - > setTag ( 1 ) ; <nl> auto sgear = Node : : create ( ) ; <nl> - addPhysicsComponent ( sgear , PhysicsBody : : createCircle ( 44 ) ) ; <nl> + sgear - > addComponent ( sgearBody ) ; <nl> sgear - > setPosition ( VisibleRect : : leftBottom ( ) + Vec2 ( 125 , 0 ) ) ; <nl> this - > addChild ( sgear ) ; <nl> - sgear - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) - > setCategoryBitmask ( 0x04 ) ; <nl> - sgear - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) - > setCollisionBitmask ( 0x04 ) ; <nl> - sgear - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) - > setTag ( 1 ) ; <nl> <nl> - _physicsWorld - > addJoint ( PhysicsJointPin : : construct ( node - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) , sgear - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) , sgear - > getPosition ( ) ) ) ; <nl> - _physicsWorld - > addJoint ( PhysicsJointDistance : : construct ( pump - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) , sgear - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) , Vec2 ( 0 , 0 ) , Vec2 ( 0 , - 44 ) ) ) ; <nl> + _physicsWorld - > addJoint ( PhysicsJointPin : : construct ( nodeBody , sgearBody , sgear - > getPosition ( ) ) ) ; <nl> + _physicsWorld - > addJoint ( PhysicsJointDistance : : construct ( pumpBody , sgearBody , Vec2 ( 0 , 0 ) , Vec2 ( 0 , - 44 ) ) ) ; <nl> <nl> - / / big gear <nl> + / / big gear <nl> + auto bgearBody = PhysicsBody : : createCircle ( 100 ) ; <nl> + bgearBody - > setCategoryBitmask ( 0x04 ) ; <nl> auto bgear = Node : : create ( ) ; <nl> - addPhysicsComponent ( bgear , PhysicsBody : : createCircle ( 100 ) ) ; <nl> + bgear - > addComponent ( bgearBody ) ; <nl> bgear - > setPosition ( VisibleRect : : leftBottom ( ) + Vec2 ( 275 , 0 ) ) ; <nl> this - > addChild ( bgear ) ; <nl> - bgear - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) - > setCategoryBitmask ( 0x04 ) ; <nl> <nl> - _physicsWorld - > addJoint ( PhysicsJointPin : : construct ( bgear - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) , node - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) , bgear - > getPosition ( ) ) ) ; <nl> - _physicsWorld - > addJoint ( PhysicsJointGear : : construct ( sgear - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) , bgear - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) , ( float ) - M_PI_2 , - 2 . 0f ) ) ; <nl> + _physicsWorld - > addJoint ( PhysicsJointPin : : construct ( bgearBody , nodeBody , bgear - > getPosition ( ) ) ) ; <nl> + _physicsWorld - > addJoint ( PhysicsJointGear : : construct ( sgearBody , bgearBody , ( float ) - M_PI_2 , - 2 . 0f ) ) ; <nl> <nl> / / plugger <nl> Vec2 seg [ ] = { VisibleRect : : leftTop ( ) + Vec2 ( 75 , - 120 ) , VisibleRect : : leftBottom ( ) + Vec2 ( 75 , - 100 ) } ; <nl> Vec2 segCenter = ( seg [ 1 ] + seg [ 0 ] ) / 2 ; <nl> seg [ 1 ] - = segCenter ; <nl> seg [ 0 ] - = segCenter ; <nl> + <nl> + auto pluggerBody = PhysicsBody : : createEdgeSegment ( seg [ 0 ] , seg [ 1 ] , PhysicsMaterial ( 0 . 01f , 0 . 0f , 0 . 5f ) , 20 ) ; <nl> + pluggerBody - > setDynamic ( true ) ; <nl> + pluggerBody - > setMass ( 30 ) ; <nl> + pluggerBody - > setMoment ( 100000 ) ; <nl> + pluggerBody - > setCategoryBitmask ( 0x02 ) ; <nl> auto plugger = Node : : create ( ) ; <nl> - addPhysicsComponent ( plugger , PhysicsBody : : createEdgeSegment ( seg [ 0 ] , seg [ 1 ] , PhysicsMaterial ( 0 . 01f , 0 . 0f , 0 . 5f ) , 20 ) ) ; <nl> - plugger - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) - > setDynamic ( true ) ; <nl> - plugger - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) - > setMass ( 30 ) ; <nl> - plugger - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) - > setMoment ( 100000 ) ; <nl> + plugger - > addComponent ( pluggerBody ) ; <nl> plugger - > setPosition ( segCenter ) ; <nl> this - > addChild ( plugger ) ; <nl> - plugger - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) - > setCategoryBitmask ( 0x02 ) ; <nl> - sgear - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) - > setCollisionBitmask ( 0x04 | 0x01 ) ; <nl> - _physicsWorld - > addJoint ( PhysicsJointPin : : construct ( node - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) , plugger - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) , VisibleRect : : leftBottom ( ) + Vec2 ( 75 , - 90 ) ) ) ; <nl> - _physicsWorld - > addJoint ( PhysicsJointDistance : : construct ( plugger - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) , sgear - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) , Vec2 : : ZERO , Vec2 ( 44 , 0 ) ) ) ; <nl> + <nl> + sgearBody - > setCollisionBitmask ( 0x04 | 0x01 ) ; <nl> + _physicsWorld - > addJoint ( PhysicsJointPin : : construct ( nodeBody , pluggerBody , VisibleRect : : leftBottom ( ) + Vec2 ( 75 , - 90 ) ) ) ; <nl> + _physicsWorld - > addJoint ( PhysicsJointDistance : : construct ( pluggerBody , sgearBody , Vec2 : : ZERO , Vec2 ( 44 , 0 ) ) ) ; <nl> } <nl> <nl> void PhysicsDemoPump : : update ( float delta ) <nl> void PhysicsDemoOneWayPlatform : : onEnter ( ) <nl> _eventDispatcher - > addEventListenerWithSceneGraphPriority ( touchListener , this ) ; <nl> <nl> auto ground = Node : : create ( ) ; <nl> - addPhysicsComponent ( ground , PhysicsBody : : createEdgeSegment ( VisibleRect : : leftBottom ( ) + Vec2 ( 0 , 50 ) , VisibleRect : : rightBottom ( ) + Vec2 ( 0 , 50 ) ) ) ; <nl> + ground - > addComponent ( PhysicsBody : : createEdgeSegment ( VisibleRect : : leftBottom ( ) + Vec2 ( 0 , 50 ) , <nl> + VisibleRect : : rightBottom ( ) + Vec2 ( 0 , 50 ) ) ) ; <nl> this - > addChild ( ground ) ; <nl> <nl> auto platform = makeBox ( VisibleRect : : center ( ) , Size ( 200 , 50 ) ) ; <nl> - platform - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) - > setDynamic ( false ) ; <nl> - platform - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) - > setContactTestBitmask ( 0xFFFFFFFF ) ; <nl> + auto platformBody = platform - > getPhysicsBody ( ) ; <nl> + platformBody - > setDynamic ( false ) ; <nl> + platformBody - > setContactTestBitmask ( 0xFFFFFFFF ) ; <nl> this - > addChild ( platform ) ; <nl> <nl> auto ball = makeBall ( VisibleRect : : center ( ) - Vec2 ( 0 , 50 ) , 20 ) ; <nl> - ball - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) - > setVelocity ( Vec2 ( 0 , 150 ) ) ; <nl> - ball - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) - > setTag ( DRAG_BODYS_TAG ) ; <nl> - ball - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) - > setMass ( 1 . 0f ) ; <nl> - ball - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) - > setContactTestBitmask ( 0xFFFFFFFF ) ; <nl> + auto ballBody = ball - > getPhysicsBody ( ) ; <nl> + ballBody - > setVelocity ( Vec2 ( 0 , 150 ) ) ; <nl> + ballBody - > setTag ( DRAG_BODYS_TAG ) ; <nl> + ballBody - > setMass ( 1 . 0f ) ; <nl> + ballBody - > setContactTestBitmask ( 0xFFFFFFFF ) ; <nl> this - > addChild ( ball ) ; <nl> <nl> - auto contactListener = EventListenerPhysicsContactWithBodies : : create ( platform - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) , ball - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) ) ; <nl> + auto contactListener = EventListenerPhysicsContactWithBodies : : create ( platformBody , ballBody ) ; <nl> contactListener - > onContactBegin = CC_CALLBACK_1 ( PhysicsDemoOneWayPlatform : : onContactBegin , this ) ; <nl> _eventDispatcher - > addEventListenerWithSceneGraphPriority ( contactListener , this ) ; <nl> } <nl> void PhysicsDemoSlice : : onEnter ( ) <nl> _eventDispatcher - > addEventListenerWithSceneGraphPriority ( touchListener , this ) ; <nl> <nl> auto ground = Node : : create ( ) ; <nl> - addPhysicsComponent ( ground , PhysicsBody : : createEdgeSegment ( VisibleRect : : leftBottom ( ) + Vec2 ( 0 , 50 ) , VisibleRect : : rightBottom ( ) + Vec2 ( 0 , 50 ) ) ) ; <nl> + ground - > addComponent ( PhysicsBody : : createEdgeSegment ( VisibleRect : : leftBottom ( ) + Vec2 ( 0 , 50 ) , VisibleRect : : rightBottom ( ) + Vec2 ( 0 , 50 ) ) ) ; <nl> this - > addChild ( ground ) ; <nl> <nl> auto box = Node : : create ( ) ; <nl> Vec2 points [ 4 ] = { Vec2 ( - 100 , - 100 ) , Vec2 ( - 100 , 100 ) , Vec2 ( 100 , 100 ) , Vec2 ( 100 , - 100 ) } ; <nl> - addPhysicsComponent ( box , PhysicsBody : : createPolygon ( points , 4 ) ) ; <nl> + box - > addComponent ( PhysicsBody : : createPolygon ( points , 4 ) ) ; <nl> box - > setPosition ( VisibleRect : : center ( ) ) ; <nl> - box - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) - > setTag ( _sliceTag ) ; <nl> + box - > getPhysicsBody ( ) - > setTag ( _sliceTag ) ; <nl> addChild ( box ) ; <nl> } <nl> <nl> void PhysicsDemoSlice : : clipPoly ( PhysicsShapePolygon * shape , Vec2 normal , float d <nl> Node * node = Node : : create ( ) ; <nl> PhysicsBody * polyon = PhysicsBody : : createPolygon ( points , pointsCount , PHYSICSBODY_MATERIAL_DEFAULT , - center ) ; <nl> node - > setPosition ( center ) ; <nl> - addPhysicsComponent ( node , polyon ) ; <nl> + node - > addComponent ( polyon ) ; <nl> polyon - > setVelocity ( body - > getVelocityAtWorldPoint ( center ) ) ; <nl> polyon - > setAngularVelocity ( body - > getAngularVelocity ( ) ) ; <nl> polyon - > setTag ( _sliceTag ) ; <nl> void PhysicsDemoBug3988 : : onEnter ( ) <nl> { <nl> PhysicsDemo : : onEnter ( ) ; <nl> toggleDebug ( ) ; <nl> - _physicsWorld - > setGravity ( Vect : : ZERO ) ; <nl> + _physicsWorld - > setGravity ( Vec2 : : ZERO ) ; <nl> <nl> auto ball = Sprite : : create ( " Images / YellowSquare . png " ) ; <nl> ball - > setPosition ( VisibleRect : : center ( ) - Vec2 ( 100 , 0 ) ) ; <nl> std : : string PhysicsDemoBug3988 : : subtitle ( ) const <nl> void PhysicsContactTest : : onEnter ( ) <nl> { <nl> PhysicsDemo : : onEnter ( ) ; <nl> - _physicsWorld - > setGravity ( Vect : : ZERO ) ; <nl> + _physicsWorld - > setGravity ( Vec2 : : ZERO ) ; <nl> auto s = VisibleRect : : getVisibleRect ( ) . size ; <nl> <nl> _yellowBoxNum = 50 ; <nl> void PhysicsContactTest : : resetTest ( ) <nl> label - > setPosition ( Vec2 ( s . width / 2 , s . height - 170 ) ) ; <nl> <nl> auto wall = Node : : create ( ) ; <nl> - addPhysicsComponent ( wall , PhysicsBody : : createEdgeBox ( VisibleRect : : getVisibleRect ( ) . size , PhysicsMaterial ( 0 . 1f , 1 , 0 . 0f ) ) ) ; <nl> + wall - > addComponent ( PhysicsBody : : createEdgeBox ( VisibleRect : : getVisibleRect ( ) . size , PhysicsMaterial ( 0 . 1f , 1 , 0 . 0f ) ) ) ; <nl> wall - > setPosition ( VisibleRect : : center ( ) ) ; <nl> root - > addChild ( wall ) ; <nl> <nl> void PhysicsContactTest : : resetTest ( ) <nl> position . x = position . x * CCRANDOM_0_1 ( ) ; <nl> position . y = position . y * CCRANDOM_0_1 ( ) ; <nl> position = VisibleRect : : leftBottom ( ) + position + Vec2 ( size . width / 2 , size . height / 2 ) ; <nl> - Vect velocity ( ( CCRANDOM_0_1 ( ) - 0 . 5 ) * 200 , ( CCRANDOM_0_1 ( ) - 0 . 5 ) * 200 ) ; <nl> + Vec2 velocity ( ( CCRANDOM_0_1 ( ) - 0 . 5 ) * 200 , ( CCRANDOM_0_1 ( ) - 0 . 5 ) * 200 ) ; <nl> auto box = makeBox ( position , size , 1 , PhysicsMaterial ( 0 . 1f , 1 , 0 . 0f ) ) ; <nl> - box - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) - > setVelocity ( velocity ) ; <nl> - box - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) - > setCategoryBitmask ( 0x01 ) ; / / 0001 <nl> - box - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) - > setContactTestBitmask ( 0x04 ) ; / / 0100 <nl> - box - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) - > setCollisionBitmask ( 0x03 ) ; / / 0011 <nl> + auto boxBody = box - > getPhysicsBody ( ) ; <nl> + boxBody - > setVelocity ( velocity ) ; <nl> + boxBody - > setCategoryBitmask ( 0x01 ) ; / / 0001 <nl> + boxBody - > setContactTestBitmask ( 0x04 ) ; / / 0100 <nl> + boxBody - > setCollisionBitmask ( 0x03 ) ; / / 0011 <nl> root - > addChild ( box ) ; <nl> } <nl> <nl> void PhysicsContactTest : : resetTest ( ) <nl> position . x = position . x * CCRANDOM_0_1 ( ) ; <nl> position . y = position . y * CCRANDOM_0_1 ( ) ; <nl> position = VisibleRect : : leftBottom ( ) + position + Vec2 ( size . width / 2 , size . height / 2 ) ; <nl> - Vect velocity ( ( CCRANDOM_0_1 ( ) - 0 . 5 ) * 200 , ( CCRANDOM_0_1 ( ) - 0 . 5 ) * 200 ) ; <nl> + Vec2 velocity ( ( CCRANDOM_0_1 ( ) - 0 . 5 ) * 200 , ( CCRANDOM_0_1 ( ) - 0 . 5 ) * 200 ) ; <nl> auto box = makeBox ( position , size , 2 , PhysicsMaterial ( 0 . 1f , 1 , 0 . 0f ) ) ; <nl> - box - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) - > setVelocity ( velocity ) ; <nl> - box - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) - > setCategoryBitmask ( 0x02 ) ; / / 0010 <nl> - box - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) - > setContactTestBitmask ( 0x08 ) ; / / 1000 <nl> - box - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) - > setCollisionBitmask ( 0x01 ) ; / / 0001 <nl> + auto boxBody = box - > getPhysicsBody ( ) ; <nl> + boxBody - > setVelocity ( velocity ) ; <nl> + boxBody - > setCategoryBitmask ( 0x02 ) ; / / 0010 <nl> + boxBody - > setContactTestBitmask ( 0x08 ) ; / / 1000 <nl> + boxBody - > setCollisionBitmask ( 0x01 ) ; / / 0001 <nl> root - > addChild ( box ) ; <nl> } <nl> <nl> void PhysicsContactTest : : resetTest ( ) <nl> position . x = position . x * CCRANDOM_0_1 ( ) ; <nl> position . y = position . y * CCRANDOM_0_1 ( ) ; <nl> position = VisibleRect : : leftBottom ( ) + position + Vec2 ( size . width / 2 , size . height / 2 ) ; <nl> - Vect velocity ( ( CCRANDOM_0_1 ( ) - 0 . 5 ) * 300 , ( CCRANDOM_0_1 ( ) - 0 . 5 ) * 300 ) ; <nl> + Vec2 velocity ( ( CCRANDOM_0_1 ( ) - 0 . 5 ) * 300 , ( CCRANDOM_0_1 ( ) - 0 . 5 ) * 300 ) ; <nl> auto triangle = makeTriangle ( position , size , 1 , PhysicsMaterial ( 0 . 1f , 1 , 0 . 0f ) ) ; <nl> - triangle - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) - > setVelocity ( velocity ) ; <nl> - triangle - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) - > setCategoryBitmask ( 0x04 ) ; / / 0100 <nl> - triangle - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) - > setContactTestBitmask ( 0x01 ) ; / / 0001 <nl> - triangle - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) - > setCollisionBitmask ( 0x06 ) ; / / 0110 <nl> + auto triangleBody = triangle - > getPhysicsBody ( ) ; <nl> + triangleBody - > setVelocity ( velocity ) ; <nl> + triangleBody - > setCategoryBitmask ( 0x04 ) ; / / 0100 <nl> + triangleBody - > setContactTestBitmask ( 0x01 ) ; / / 0001 <nl> + triangleBody - > setCollisionBitmask ( 0x06 ) ; / / 0110 <nl> root - > addChild ( triangle ) ; <nl> } <nl> <nl> void PhysicsContactTest : : resetTest ( ) <nl> position . x = position . x * CCRANDOM_0_1 ( ) ; <nl> position . y = position . y * CCRANDOM_0_1 ( ) ; <nl> position = VisibleRect : : leftBottom ( ) + position + Vec2 ( size . width / 2 , size . height / 2 ) ; <nl> - Vect velocity ( ( CCRANDOM_0_1 ( ) - 0 . 5 ) * 300 , ( CCRANDOM_0_1 ( ) - 0 . 5 ) * 300 ) ; <nl> + Vec2 velocity ( ( CCRANDOM_0_1 ( ) - 0 . 5 ) * 300 , ( CCRANDOM_0_1 ( ) - 0 . 5 ) * 300 ) ; <nl> auto triangle = makeTriangle ( position , size , 2 , PhysicsMaterial ( 0 . 1f , 1 , 0 . 0f ) ) ; <nl> - triangle - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) - > setVelocity ( velocity ) ; <nl> - triangle - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) - > setCategoryBitmask ( 0x08 ) ; / / 1000 <nl> - triangle - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) - > setContactTestBitmask ( 0x02 ) ; / / 0010 <nl> - triangle - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) - > setCollisionBitmask ( 0x01 ) ; / / 0001 <nl> + auto triangleBody = triangle - > getPhysicsBody ( ) ; <nl> + triangleBody - > setVelocity ( velocity ) ; <nl> + triangleBody - > setCategoryBitmask ( 0x08 ) ; / / 1000 <nl> + triangleBody - > setContactTestBitmask ( 0x02 ) ; / / 0010 <nl> + triangleBody - > setCollisionBitmask ( 0x01 ) ; / / 0001 <nl> root - > addChild ( triangle ) ; <nl> } <nl> } <nl> void PhysicsPositionRotationTest : : onEnter ( ) <nl> _eventDispatcher - > addEventListenerWithSceneGraphPriority ( touchListener , this ) ; <nl> <nl> auto wall = Node : : create ( ) ; <nl> - addPhysicsComponent ( wall , PhysicsBody : : createEdgeBox ( VisibleRect : : getVisibleRect ( ) . size ) ) ; <nl> + wall - > addComponent ( PhysicsBody : : createEdgeBox ( VisibleRect : : getVisibleRect ( ) . size ) ) ; <nl> wall - > setPosition ( VisibleRect : : center ( ) ) ; <nl> addChild ( wall ) ; <nl> <nl> void PhysicsPositionRotationTest : : onEnter ( ) <nl> / / anchorNode - > setAnchorPoint ( Vec2 ( 0 . 1f , 0 . 9f ) ) ; <nl> anchorNode - > setPosition ( 100 , 100 ) ; <nl> anchorNode - > setScale ( 0 . 25 ) ; <nl> - addPhysicsComponent ( anchorNode , PhysicsBody : : createBox ( anchorNode - > getContentSize ( ) ) ) ; <nl> - anchorNode - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) - > setTag ( DRAG_BODYS_TAG ) ; <nl> + anchorNode - > addComponent ( PhysicsBody : : createBox ( anchorNode - > getContentSize ( ) ) ) ; <nl> + anchorNode - > getPhysicsBody ( ) - > setTag ( DRAG_BODYS_TAG ) ; <nl> addChild ( anchorNode ) ; <nl> <nl> / / parent test <nl> auto parent = Sprite : : create ( " Images / YellowSquare . png " ) ; <nl> parent - > setPosition ( 200 , 100 ) ; <nl> parent - > setScale ( 0 . 25 ) ; <nl> - addPhysicsComponent ( parent , PhysicsBody : : createBox ( parent - > getContentSize ( ) ) ) ; <nl> - parent - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) - > setTag ( DRAG_BODYS_TAG ) ; <nl> + parent - > addComponent ( PhysicsBody : : createBox ( parent - > getContentSize ( ) ) ) ; <nl> + parent - > getPhysicsBody ( ) - > setTag ( DRAG_BODYS_TAG ) ; <nl> addChild ( parent ) ; <nl> <nl> auto leftBall = Sprite : : create ( " Images / ball . png " ) ; <nl> leftBall - > setPosition ( - 30 , 0 ) ; <nl> leftBall - > Node : : setScale ( 2 ) ; <nl> - addPhysicsComponent ( leftBall , PhysicsBody : : createCircle ( leftBall - > getContentSize ( ) . width / 2 ) ) ; <nl> - leftBall - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) - > setTag ( DRAG_BODYS_TAG ) ; <nl> + leftBall - > addComponent ( PhysicsBody : : createCircle ( leftBall - > getContentSize ( ) . width / 2 ) ) ; <nl> + leftBall - > getPhysicsBody ( ) - > setTag ( DRAG_BODYS_TAG ) ; <nl> parent - > addChild ( leftBall ) ; <nl> <nl> / / offset position rotation test <nl> auto offsetPosNode = Sprite : : create ( " Images / YellowSquare . png " ) ; <nl> offsetPosNode - > setPosition ( 100 , 200 ) ; <nl> - addPhysicsComponent ( offsetPosNode , PhysicsBody : : createBox ( offsetPosNode - > getContentSize ( ) / 2 ) ) ; <nl> - offsetPosNode - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) - > setPositionOffset ( - Vec2 ( offsetPosNode - > getContentSize ( ) / 2 ) ) ; <nl> - offsetPosNode - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) - > setRotationOffset ( 45 ) ; <nl> - offsetPosNode - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) - > setTag ( DRAG_BODYS_TAG ) ; <nl> + auto body = PhysicsBody : : createBox ( offsetPosNode - > getContentSize ( ) / 2 ) ; <nl> + offsetPosNode - > addComponent ( body ) ; <nl> + body - > setPositionOffset ( - Vec2 ( offsetPosNode - > getContentSize ( ) / 2 ) ) ; <nl> + body - > setRotationOffset ( 45 ) ; <nl> + body - > setTag ( DRAG_BODYS_TAG ) ; <nl> addChild ( offsetPosNode ) ; <nl> <nl> return ; <nl> void PhysicsSetGravityEnableTest : : onEnter ( ) <nl> <nl> / / wall <nl> auto wall = Node : : create ( ) ; <nl> - addPhysicsComponent ( wall , PhysicsBody : : createEdgeBox ( VisibleRect : : getVisibleRect ( ) . size , PhysicsMaterial ( 0 . 1f , 1 . 0f , 0 . 0f ) ) ) ; <nl> + wall - > addComponent ( PhysicsBody : : createEdgeBox ( VisibleRect : : getVisibleRect ( ) . size , PhysicsMaterial ( 0 . 1f , 1 . 0f , 0 . 0f ) ) ) ; <nl> wall - > setPosition ( VisibleRect : : center ( ) ) ; <nl> addChild ( wall ) ; <nl> <nl> / / common box <nl> auto commonBox = makeBox ( Vec2 ( 100 , 100 ) , Size ( 50 , 50 ) , 1 ) ; <nl> - commonBox - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) - > setTag ( DRAG_BODYS_TAG ) ; <nl> + commonBox - > getPhysicsBody ( ) - > setTag ( DRAG_BODYS_TAG ) ; <nl> addChild ( commonBox ) ; <nl> <nl> auto box = makeBox ( Vec2 ( 200 , 100 ) , Size ( 50 , 50 ) , 2 ) ; <nl> - box - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) - > setMass ( 20 ) ; <nl> - box - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) - > setTag ( DRAG_BODYS_TAG ) ; <nl> - box - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) - > setGravityEnable ( false ) ; <nl> + auto boxBody = box - > getPhysicsBody ( ) ; <nl> + boxBody - > setMass ( 20 ) ; <nl> + boxBody - > setTag ( DRAG_BODYS_TAG ) ; <nl> + boxBody - > setGravityEnable ( false ) ; <nl> addChild ( box ) ; <nl> <nl> auto ball = makeBall ( Vec2 ( 200 , 200 ) , 50 ) ; <nl> ball - > setTag ( 2 ) ; <nl> - ball - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) - > setTag ( DRAG_BODYS_TAG ) ; <nl> - ball - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) - > setGravityEnable ( false ) ; <nl> + auto ballBody = ball - > getPhysicsBody ( ) ; <nl> + ballBody - > setTag ( DRAG_BODYS_TAG ) ; <nl> + ballBody - > setGravityEnable ( false ) ; <nl> + ballBody - > setMass ( 50 ) ; <nl> addChild ( ball ) ; <nl> - ball - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) - > setMass ( 50 ) ; <nl> + <nl> scheduleOnce ( CC_SCHEDULE_SELECTOR ( PhysicsSetGravityEnableTest : : onScheduleOnce ) , 1 . 0 ) ; <nl> } <nl> <nl> void PhysicsSetGravityEnableTest : : onScheduleOnce ( float delta ) <nl> { <nl> auto ball = getChildByTag ( 2 ) ; <nl> - ball - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) - > setMass ( 200 ) ; <nl> + ball - > getPhysicsBody ( ) - > setMass ( 200 ) ; <nl> <nl> - _physicsWorld - > setGravity ( Vect ( 0 , 98 ) ) ; <nl> + _physicsWorld - > setGravity ( Vec2 ( 0 , 98 ) ) ; <nl> } <nl> <nl> std : : string PhysicsSetGravityEnableTest : : title ( ) const <nl> void PhysicsDemoBug5482 : : onEnter ( ) <nl> <nl> / / wall <nl> auto wall = Node : : create ( ) ; <nl> - addPhysicsComponent ( wall , PhysicsBody : : createEdgeBox ( VisibleRect : : getVisibleRect ( ) . size , PhysicsMaterial ( 0 . 1f , 1 . 0f , 0 . 0f ) ) ) ; <nl> + wall - > addComponent ( PhysicsBody : : createEdgeBox ( VisibleRect : : getVisibleRect ( ) . size , PhysicsMaterial ( 0 . 1f , 1 . 0f , 0 . 0f ) ) ) ; <nl> wall - > setPosition ( VisibleRect : : center ( ) ) ; <nl> addChild ( wall ) ; <nl> <nl> void PhysicsDemoBug5482 : : onEnter ( ) <nl> <nl> _nodeA = Sprite : : create ( " Images / YellowSquare . png " ) ; <nl> _nodeA - > setPosition ( VisibleRect : : center ( ) . x - 150 , 100 ) ; <nl> - _nodeA - > addComponent ( ComponentPhysics2d : : create ( ) ) ; <nl> this - > addChild ( _nodeA ) ; <nl> <nl> _nodeB = Sprite : : create ( " Images / YellowSquare . png " ) ; <nl> _nodeB - > setPosition ( VisibleRect : : center ( ) . x + 150 , 100 ) ; <nl> - _nodeB - > addComponent ( ComponentPhysics2d : : create ( ) ) ; <nl> this - > addChild ( _nodeB ) ; <nl> <nl> _body = PhysicsBody : : createBox ( _nodeA - > getContentSize ( ) ) ; <nl> void PhysicsDemoBug5482 : : onExit ( ) <nl> void PhysicsDemoBug5482 : : changeBodyCallback ( Ref * sender ) <nl> { <nl> Sprite * node = _bodyInA ? _nodeB : _nodeA ; <nl> - node - > getComponent < ComponentPhysics2d > ( ) - > setPhysicsBody ( _body ) ; <nl> + if ( _body - > getOwner ( ) ) <nl> + { <nl> + _body - > getOwner ( ) - > removeComponent ( _body ) ; <nl> + } <nl> + node - > addComponent ( _body ) ; <nl> _bodyInA = ! _bodyInA ; <nl> } <nl> <nl> void PhysicsFixedUpdate : : onEnter ( ) <nl> <nl> / / wall <nl> auto wall = Node : : create ( ) ; <nl> - addPhysicsComponent ( wall , PhysicsBody : : createEdgeBox ( VisibleRect : : getVisibleRect ( ) . size , PhysicsMaterial ( 0 . 1f , 1 , 0 . 0f ) ) ) ; <nl> + wall - > addComponent ( PhysicsBody : : createEdgeBox ( VisibleRect : : getVisibleRect ( ) . size , PhysicsMaterial ( 0 . 1f , 1 , 0 . 0f ) ) ) ; <nl> wall - > setPosition ( VisibleRect : : center ( ) ) ; <nl> this - > addChild ( wall ) ; <nl> <nl> void PhysicsFixedUpdate : : addBall ( ) <nl> { <nl> auto ball = Sprite : : create ( " Images / ball . png " ) ; <nl> ball - > setPosition ( 100 , 100 ) ; <nl> - addPhysicsComponent ( ball , PhysicsBody : : createCircle ( ball - > getContentSize ( ) . width / 2 , PhysicsMaterial ( 0 . 1f , 1 , 0 . 0f ) ) ) ; <nl> - ball - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) - > setTag ( DRAG_BODYS_TAG ) ; <nl> - ball - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) - > setVelocity ( Point ( 1000 , 20 ) ) ; <nl> + auto ballBody = PhysicsBody : : createCircle ( ball - > getContentSize ( ) . width / 2 , PhysicsMaterial ( 0 . 1f , 1 , 0 . 0f ) ) ; <nl> + ball - > addComponent ( ballBody ) ; <nl> + ballBody - > setTag ( DRAG_BODYS_TAG ) ; <nl> + ballBody - > setVelocity ( Point ( 1000 , 20 ) ) ; <nl> this - > addChild ( ball ) ; <nl> } <nl> <nl> void PhysicsTransformTest : : onEnter ( ) <nl> addChild ( _rootLayer ) ; <nl> <nl> auto wall = Node : : create ( ) ; <nl> - addPhysicsComponent ( wall , PhysicsBody : : createEdgeBox ( VisibleRect : : getVisibleRect ( ) . size , PhysicsMaterial ( 0 . 1f , 1 . 0f , 0 . 0f ) ) ) ; <nl> + wall - > addComponent ( PhysicsBody : : createEdgeBox ( VisibleRect : : getVisibleRect ( ) . size , PhysicsMaterial ( 0 . 1f , 1 . 0f , 0 . 0f ) ) ) ; <nl> wall - > setPosition ( VisibleRect : : center ( ) ) ; <nl> _rootLayer - > addChild ( wall ) ; <nl> <nl> void PhysicsTransformTest : : onEnter ( ) <nl> _parentSprite = Sprite : : create ( " Images / YellowSquare . png " ) ; <nl> _parentSprite - > setPosition ( 200 , 100 ) ; <nl> _parentSprite - > setScale ( 0 . 25 ) ; <nl> - addPhysicsComponent ( _parentSprite , PhysicsBody : : createBox ( _parentSprite - > getContentSize ( ) , PhysicsMaterial ( 0 . 1f , 1 . 0f , 0 . 0f ) ) ) ; <nl> - _parentSprite - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) - > setTag ( DRAG_BODYS_TAG ) ; <nl> + _parentSprite - > addComponent ( PhysicsBody : : createBox ( _parentSprite - > getContentSize ( ) , PhysicsMaterial ( 0 . 1f , 1 . 0f , 0 . 0f ) ) ) ; <nl> + _parentSprite - > getPhysicsBody ( ) - > setTag ( DRAG_BODYS_TAG ) ; <nl> _parentSprite - > setTag ( 1 ) ; <nl> _rootLayer - > addChild ( _parentSprite ) ; <nl> <nl> auto leftBall = Sprite : : create ( " Images / ball . png " ) ; <nl> leftBall - > setPosition ( - 30 , 0 ) ; <nl> leftBall - > setScale ( 2 ) ; <nl> - addPhysicsComponent ( leftBall , PhysicsBody : : createCircle ( leftBall - > getContentSize ( ) . width / 2 , PhysicsMaterial ( 0 . 1f , 1 . 0f , 0 . 0f ) ) ) ; <nl> - leftBall - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) - > setTag ( DRAG_BODYS_TAG ) ; <nl> + leftBall - > addComponent ( PhysicsBody : : createCircle ( leftBall - > getContentSize ( ) . width / 2 , PhysicsMaterial ( 0 . 1f , 1 . 0f , 0 . 0f ) ) ) ; <nl> + leftBall - > getPhysicsBody ( ) - > setTag ( DRAG_BODYS_TAG ) ; <nl> _parentSprite - > addChild ( leftBall ) ; <nl> <nl> ScaleTo * scaleTo = ScaleTo : : create ( 2 . 0 , 0 . 5 ) ; <nl> void PhysicsTransformTest : : onEnter ( ) <nl> auto normal = Sprite : : create ( " Images / YellowSquare . png " ) ; <nl> normal - > setPosition ( 300 , 100 ) ; <nl> normal - > setScale ( 0 . 25 , 0 . 5 ) ; <nl> - addPhysicsComponent ( normal , PhysicsBody : : createBox ( normal - > getContentSize ( ) , PhysicsMaterial ( 0 . 1f , 1 . 0f , 0 . 0f ) ) ) ; <nl> - normal - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) - > setTag ( DRAG_BODYS_TAG ) ; <nl> + normal - > addComponent ( PhysicsBody : : createBox ( normal - > getContentSize ( ) , PhysicsMaterial ( 0 . 1f , 1 . 0f , 0 . 0f ) ) ) ; <nl> + normal - > getPhysicsBody ( ) - > setTag ( DRAG_BODYS_TAG ) ; <nl> _rootLayer - > addChild ( normal ) ; <nl> <nl> auto bullet = Sprite : : create ( " Images / ball . png " ) ; <nl> bullet - > setPosition ( 200 , 200 ) ; <nl> - addPhysicsComponent ( bullet , PhysicsBody : : createCircle ( bullet - > getContentSize ( ) . width / 2 , PhysicsMaterial ( 0 . 1f , 1 . 0f , 0 . 0f ) ) ) ; <nl> - bullet - > getComponent < ComponentPhysics2d > ( ) - > getPhysicsBody ( ) - > setVelocity ( Vect ( 100 , 100 ) ) ; <nl> + bullet - > addComponent ( PhysicsBody : : createCircle ( bullet - > getContentSize ( ) . width / 2 , PhysicsMaterial ( 0 . 1f , 1 . 0f , 0 . 0f ) ) ) ; <nl> + bullet - > getPhysicsBody ( ) - > setVelocity ( Vec2 ( 100 , 100 ) ) ; <nl> _rootLayer - > addChild ( bullet ) ; <nl> <nl> MoveBy * move = MoveBy : : create ( 2 . 0f , Vec2 ( 100 , 100 ) ) ; <nl> mmm a / tests / cpp - tests / Classes / PhysicsTest / PhysicsTest . h <nl> ppp b / tests / cpp - tests / Classes / PhysicsTest / PhysicsTest . h <nl> class PhysicsDemo : public TestCase <nl> void toggleDebug ( ) ; <nl> <nl> protected : <nl> - void addPhysicsComponent ( cocos2d : : Node * node , cocos2d : : PhysicsBody * physicsBody ) ; <nl> <nl> cocos2d : : Texture2D * _spriteTexture ; <nl> cocos2d : : SpriteBatchNode * _ball ; <nl> mmm a / tests / lua - tests / src / PhysicsTest / PhysicsTest . lua <nl> ppp b / tests / lua - tests / src / PhysicsTest / PhysicsTest . lua <nl> local MATERIAL_DEFAULT = cc . PhysicsMaterial ( 0 . 1 , 0 . 5 , 0 . 5 ) <nl> local curLayer = nil <nl> local STATIC_COLOR = cc . c4f ( 1 . 0 , 0 . 0 , 0 . 0 , 1 . 0 ) <nl> local DRAG_BODYS_TAG = 0x80 <nl> - local PHYSICS_COMPONENT_NAME = " physics_component " <nl> <nl> local function range ( from , to , step ) <nl> step = step or 1 <nl> local function initWithLayer ( layer , callback ) <nl> layer : registerScriptHandler ( onNodeEvent ) <nl> end <nl> <nl> - local function addPhysicsComponent ( node , physicsBody ) <nl> - local component = cc . ComponentPhysics2d : create ( physicsBody ) <nl> - component : setName ( PHYSICS_COMPONENT_NAME ) <nl> - node : addComponent ( component ) <nl> - end <nl> - <nl> local function addGrossiniAtPosition ( layer , p , scale ) <nl> scale = scale or 1 . 0 <nl> <nl> local function addGrossiniAtPosition ( layer , p , scale ) <nl> <nl> local sp = cc . Sprite : createWithTexture ( layer . spriteTexture , cc . rect ( posx , posy , 85 , 121 ) ) <nl> sp : setScale ( scale ) <nl> - - - sp : setPhysicsBody ( cc . PhysicsBody : createBox ( cc . size ( 48 . 0 * scale , 108 . 0 * scale ) ) ) <nl> - addPhysicsComponent ( sp , cc . PhysicsBody : createBox ( cc . size ( 48 . 0 , 108 . 0 ) ) ) <nl> + sp : setPhysicsBody ( cc . PhysicsBody : createBox ( cc . size ( 48 . 0 * scale , 108 . 0 * scale ) ) ) <nl> layer : addChild ( sp ) <nl> sp : setPosition ( p ) <nl> return sp <nl> local function onTouchBegan ( touch , event ) <nl> if body then <nl> local mouse = cc . Node : create ( ) <nl> local physicsBody = cc . PhysicsBody : create ( PHYSICS_INFINITY , PHYSICS_INFINITY ) <nl> - addPhysicsComponent ( mouse , physicsBody ) <nl> + mouse : setPhysicsBody ( physicsBody ) <nl> physicsBody : setDynamic ( false ) <nl> mouse : setPosition ( location ) <nl> curLayer : addChild ( mouse ) <nl> local function makeBall ( layer , point , radius , material ) <nl> ball : setScale ( 0 . 13 * radius ) <nl> <nl> local body = cc . PhysicsBody : createCircle ( ball : getContentSize ( ) . width / 2 , material ) <nl> - - - ball : setPhysicsBody ( body ) <nl> - addPhysicsComponent ( ball , body ) <nl> + ball : setPhysicsBody ( body ) <nl> ball : setPosition ( point ) <nl> <nl> return ball <nl> local function makeBox ( point , size , color , material ) <nl> box : setScaleY ( size . height / 100 . 0 ) <nl> <nl> local body = cc . PhysicsBody : createBox ( box : getContentSize ( ) , material ) <nl> - addPhysicsComponent ( box , body ) <nl> + box : setPhysicsBody ( body ) <nl> box : setPosition ( cc . p ( point . x , point . y ) ) <nl> <nl> return box <nl> local function makeTriangle ( point , size , color , material ) <nl> } <nl> <nl> local body = cc . PhysicsBody : createPolygon ( vers , material ) <nl> - addPhysicsComponent ( triangle , body ) <nl> + triangle : setPhysicsBody ( body ) <nl> triangle : setPosition ( point ) <nl> <nl> return triangle <nl> local function PhysicsDemoClickAdd ( ) <nl> addGrossiniAtPosition ( layer , VisibleRect : center ( ) ) <nl> <nl> local node = cc . Node : create ( ) <nl> - addPhysicsComponent ( node , <nl> - cc . PhysicsBody : createEdgeBox ( cc . size ( VisibleRect : getVisibleRect ( ) . width , <nl> + node : setPhysicsBody ( cc . PhysicsBody : createEdgeBox ( cc . size ( VisibleRect : getVisibleRect ( ) . width , <nl> VisibleRect : getVisibleRect ( ) . height <nl> ) <nl> ) <nl> local function PhysicsDemoLogoSmash ( ) <nl> 2 * ( logo_height - y + y_jitter ) + VisibleRect : getVisibleRect ( ) . height / 2 - logo_height / 2 ) , <nl> 0 . 95 , <nl> cc . PhysicsMaterial ( 0 . 01 , 0 . 0 , 0 . 0 ) ) <nl> - local physicsBody = ball : getComponent ( PHYSICS_COMPONENT_NAME ) : getPhysicsBody ( ) <nl> + local physicsBody = ball : getPhysicsBody ( ) <nl> physicsBody : setMass ( 1 . 0 ) <nl> physicsBody : setMoment ( PHYSICS_INFINITY ) <nl> <nl> local function PhysicsDemoLogoSmash ( ) <nl> <nl> local bullet = makeBall ( layer , cc . p ( 400 , 0 ) , 10 , cc . PhysicsMaterial ( PHYSICS_INFINITY , 0 , 0 ) ) <nl> <nl> - bullet : getComponent ( PHYSICS_COMPONENT_NAME ) : getPhysicsBody ( ) : setVelocity ( cc . p ( 200 , 0 ) ) <nl> + bullet : getPhysicsBody ( ) : setVelocity ( cc . p ( 200 , 0 ) ) <nl> bullet : setPosition ( cc . p ( - 500 , VisibleRect : getVisibleRect ( ) . height / 2 ) ) <nl> layer . ball : addChild ( bullet ) <nl> end <nl> local function PhysicsDemoJoints ( ) <nl> <nl> local node = cc . Node : create ( ) <nl> local box = cc . PhysicsBody : create ( ) <nl> - addPhysicsComponent ( node , box ) <nl> + node : setPhysicsBody ( box ) <nl> box : setDynamic ( false ) <nl> node : setPosition ( cc . p ( 0 , 0 ) ) <nl> layer : addChild ( node ) <nl> local function PhysicsDemoJoints ( ) <nl> <nl> if index = = 0 then <nl> local sp1 = makeBall ( layer , cc . p ( offset . x - 30 , offset . y ) , 10 ) <nl> - local sp1PhysicsBody = sp1 : getComponent ( PHYSICS_COMPONENT_NAME ) : getPhysicsBody ( ) <nl> + local sp1PhysicsBody = sp1 : getPhysicsBody ( ) <nl> sp1PhysicsBody : setTag ( DRAG_BODYS_TAG ) <nl> <nl> local sp2 = makeBall ( layer , cc . p ( offset . x + 30 , offset . y ) , 10 ) <nl> - local sp2PhysicsBody = sp2 : getComponent ( PHYSICS_COMPONENT_NAME ) : getPhysicsBody ( ) <nl> + local sp2PhysicsBody = sp2 : getPhysicsBody ( ) <nl> sp2PhysicsBody : setTag ( DRAG_BODYS_TAG ) <nl> <nl> local joint = cc . PhysicsJointPin : construct ( sp1PhysicsBody , sp2PhysicsBody , offset ) <nl> local function PhysicsDemoJoints ( ) <nl> layer : addChild ( sp2 ) <nl> elseif index = = 1 then <nl> local sp1 = makeBall ( layer , cc . p ( offset . x - 30 , offset . y ) , 10 ) <nl> - local sp1PhysicsBody = sp1 : getComponent ( PHYSICS_COMPONENT_NAME ) : getPhysicsBody ( ) <nl> + local sp1PhysicsBody = sp1 : getPhysicsBody ( ) <nl> sp1PhysicsBody : setTag ( DRAG_BODYS_TAG ) <nl> <nl> local sp2 = makeBox ( cc . p ( offset . x + 30 , offset . y ) , cc . size ( 30 , 10 ) ) <nl> - local sp2PhysicsBody = sp2 : getComponent ( PHYSICS_COMPONENT_NAME ) : getPhysicsBody ( ) <nl> + local sp2PhysicsBody = sp2 : getPhysicsBody ( ) <nl> sp2PhysicsBody : setTag ( DRAG_BODYS_TAG ) <nl> <nl> local joint = cc . PhysicsJointFixed : construct ( sp1PhysicsBody , sp2PhysicsBody , offset ) <nl> local function PhysicsDemoJoints ( ) <nl> layer : addChild ( sp2 ) <nl> elseif index = = 2 then <nl> local sp1 = makeBall ( layer , cc . p ( offset . x - 30 , offset . y ) , 10 ) <nl> - local sp1PhysicsBody = sp1 : getComponent ( PHYSICS_COMPONENT_NAME ) : getPhysicsBody ( ) <nl> + local sp1PhysicsBody = sp1 : getPhysicsBody ( ) <nl> sp1PhysicsBody : setTag ( DRAG_BODYS_TAG ) <nl> <nl> local sp2 = makeBox ( cc . p ( offset . x + 30 , offset . y ) , cc . size ( 30 , 10 ) ) <nl> - local sp2PhysicsBody = sp2 : getComponent ( PHYSICS_COMPONENT_NAME ) : getPhysicsBody ( ) <nl> + local sp2PhysicsBody = sp2 : getPhysicsBody ( ) <nl> sp2PhysicsBody : setTag ( DRAG_BODYS_TAG ) <nl> <nl> local joint = cc . PhysicsJointDistance : construct ( sp1PhysicsBody , <nl> local function PhysicsDemoJoints ( ) <nl> layer : addChild ( sp2 ) <nl> elseif index = = 3 then <nl> local sp1 = makeBall ( layer , cc . p ( offset . x - 30 , offset . y ) , 10 ) <nl> - local sp1PhysicsBody = sp1 : getComponent ( PHYSICS_COMPONENT_NAME ) : getPhysicsBody ( ) <nl> + local sp1PhysicsBody = sp1 : getPhysicsBody ( ) <nl> sp1PhysicsBody : setTag ( DRAG_BODYS_TAG ) <nl> <nl> local sp2 = makeBox ( cc . p ( offset . x + 30 , offset . y ) , cc . size ( 30 , 10 ) ) <nl> - local sp2PhysicsBody = sp2 : getComponent ( PHYSICS_COMPONENT_NAME ) : getPhysicsBody ( ) <nl> + local sp2PhysicsBody = sp2 : getPhysicsBody ( ) <nl> sp2PhysicsBody : setTag ( DRAG_BODYS_TAG ) <nl> <nl> local joint = cc . PhysicsJointLimit : construct ( sp1PhysicsBody , <nl> local function PhysicsDemoJoints ( ) <nl> layer : addChild ( sp2 ) <nl> elseif index = = 4 then <nl> local sp1 = makeBall ( layer , cc . p ( offset . x - 30 , offset . y ) , 10 ) <nl> - local sp1PhysicsBody = sp1 : getComponent ( PHYSICS_COMPONENT_NAME ) : getPhysicsBody ( ) <nl> + local sp1PhysicsBody = sp1 : getPhysicsBody ( ) <nl> sp1PhysicsBody : setTag ( DRAG_BODYS_TAG ) <nl> <nl> local sp2 = makeBox ( cc . p ( offset . x + 30 , offset . y ) , cc . size ( 30 , 10 ) ) <nl> - local sp2PhysicsBody = sp2 : getComponent ( PHYSICS_COMPONENT_NAME ) : getPhysicsBody ( ) <nl> + local sp2PhysicsBody = sp2 : getPhysicsBody ( ) <nl> sp2PhysicsBody : setTag ( DRAG_BODYS_TAG ) <nl> <nl> local joint = cc . PhysicsJointSpring : construct ( sp1PhysicsBody , <nl> local function PhysicsDemoJoints ( ) <nl> layer : addChild ( sp2 ) <nl> elseif index = = 5 then <nl> local sp1 = makeBall ( layer , cc . p ( offset . x - 30 , offset . y ) , 10 ) <nl> - local sp1PhysicsBody = sp1 : getComponent ( PHYSICS_COMPONENT_NAME ) : getPhysicsBody ( ) <nl> + local sp1PhysicsBody = sp1 : getPhysicsBody ( ) <nl> sp1PhysicsBody : setTag ( DRAG_BODYS_TAG ) <nl> <nl> local sp2 = makeBox ( cc . p ( offset . x + 30 , offset . y ) , cc . size ( 30 , 10 ) ) <nl> - local sp2PhysicsBody = sp2 : getComponent ( PHYSICS_COMPONENT_NAME ) : getPhysicsBody ( ) <nl> + local sp2PhysicsBody = sp2 : getPhysicsBody ( ) <nl> sp2PhysicsBody : setTag ( DRAG_BODYS_TAG ) <nl> <nl> local joint = cc . PhysicsJointGroove : construct ( sp1PhysicsBody , <nl> local function PhysicsDemoJoints ( ) <nl> layer : addChild ( sp2 ) <nl> elseif index = = 6 then <nl> local sp1 = makeBox ( cc . p ( offset . x - 30 , offset . y ) , cc . size ( 30 , 10 ) ) <nl> - local sp1PhysicsBody = sp1 : getComponent ( PHYSICS_COMPONENT_NAME ) : getPhysicsBody ( ) <nl> + local sp1PhysicsBody = sp1 : getPhysicsBody ( ) <nl> sp1PhysicsBody : setTag ( DRAG_BODYS_TAG ) <nl> <nl> local sp2 = makeBox ( cc . p ( offset . x + 30 , offset . y ) , cc . size ( 30 , 10 ) ) <nl> - local sp2PhysicsBody = sp2 : getComponent ( PHYSICS_COMPONENT_NAME ) : getPhysicsBody ( ) <nl> + local sp2PhysicsBody = sp2 : getPhysicsBody ( ) <nl> sp2PhysicsBody : setTag ( DRAG_BODYS_TAG ) <nl> <nl> scene : getPhysicsWorld ( ) : addJoint ( cc . PhysicsJointPin : construct ( sp1PhysicsBody , <nl> local function PhysicsDemoJoints ( ) <nl> layer : addChild ( sp2 ) <nl> elseif index = = 7 then <nl> local sp1 = makeBox ( cc . p ( offset . x - 30 , offset . y ) , cc . size ( 30 , 10 ) ) <nl> - local sp1PhysicsBody = sp1 : getComponent ( PHYSICS_COMPONENT_NAME ) : getPhysicsBody ( ) <nl> + local sp1PhysicsBody = sp1 : getPhysicsBody ( ) <nl> sp1PhysicsBody : setTag ( DRAG_BODYS_TAG ) <nl> <nl> local sp2 = makeBox ( cc . p ( offset . x + 30 , offset . y ) , cc . size ( 30 , 10 ) ) <nl> - local sp2PhysicsBody = sp2 : getComponent ( PHYSICS_COMPONENT_NAME ) : getPhysicsBody ( ) <nl> + local sp2PhysicsBody = sp2 : getPhysicsBody ( ) <nl> sp2PhysicsBody : setTag ( DRAG_BODYS_TAG ) <nl> <nl> scene : getPhysicsWorld ( ) : addJoint ( cc . PhysicsJointPin : construct ( sp1PhysicsBody , <nl> local function PhysicsDemoJoints ( ) <nl> layer : addChild ( sp2 ) <nl> elseif index = = 8 then <nl> local sp1 = makeBox ( cc . p ( offset . x - 30 , offset . y ) , cc . size ( 30 , 10 ) ) <nl> - local sp1PhysicsBody = sp1 : getComponent ( PHYSICS_COMPONENT_NAME ) : getPhysicsBody ( ) <nl> + local sp1PhysicsBody = sp1 : getPhysicsBody ( ) <nl> sp1PhysicsBody : setTag ( DRAG_BODYS_TAG ) <nl> <nl> local sp2 = makeBox ( cc . p ( offset . x + 30 , offset . y ) , cc . size ( 30 , 10 ) ) <nl> - local sp2PhysicsBody = sp2 : getComponent ( PHYSICS_COMPONENT_NAME ) : getPhysicsBody ( ) <nl> + local sp2PhysicsBody = sp2 : getPhysicsBody ( ) <nl> sp2PhysicsBody : setTag ( DRAG_BODYS_TAG ) <nl> <nl> scene : getPhysicsWorld ( ) : addJoint ( cc . PhysicsJointPin : construct ( sp1PhysicsBody , <nl> local function PhysicsDemoJoints ( ) <nl> layer : addChild ( sp2 ) <nl> elseif index = = 9 then <nl> local sp1 = makeBox ( cc . p ( offset . x - 30 , offset . y ) , cc . size ( 30 , 10 ) ) <nl> - local sp1PhysicsBody = sp1 : getComponent ( PHYSICS_COMPONENT_NAME ) : getPhysicsBody ( ) <nl> + local sp1PhysicsBody = sp1 : getPhysicsBody ( ) <nl> sp1PhysicsBody : setTag ( DRAG_BODYS_TAG ) <nl> <nl> local sp2 = makeBox ( cc . p ( offset . x + 30 , offset . y ) , cc . size ( 30 , 10 ) ) <nl> - local sp2PhysicsBody = sp2 : getComponent ( PHYSICS_COMPONENT_NAME ) : getPhysicsBody ( ) <nl> + local sp2PhysicsBody = sp2 : getPhysicsBody ( ) <nl> sp2PhysicsBody : setTag ( DRAG_BODYS_TAG ) <nl> <nl> scene : getPhysicsWorld ( ) : addJoint ( cc . PhysicsJointPin : construct ( sp1PhysicsBody , <nl> local function PhysicsDemoJoints ( ) <nl> layer : addChild ( sp2 ) <nl> elseif index = = 10 then <nl> local sp1 = makeBox ( cc . p ( offset . x - 30 , offset . y ) , cc . size ( 30 , 10 ) ) <nl> - local sp1PhysicsBody = sp1 : getComponent ( PHYSICS_COMPONENT_NAME ) : getPhysicsBody ( ) <nl> + local sp1PhysicsBody = sp1 : getPhysicsBody ( ) <nl> sp1PhysicsBody : setTag ( DRAG_BODYS_TAG ) <nl> <nl> local sp2 = makeBox ( cc . p ( offset . x + 30 , offset . y ) , cc . size ( 30 , 10 ) ) <nl> - local sp2PhysicsBody = sp2 : getComponent ( PHYSICS_COMPONENT_NAME ) : getPhysicsBody ( ) <nl> + local sp2PhysicsBody = sp2 : getPhysicsBody ( ) <nl> sp2PhysicsBody : setTag ( DRAG_BODYS_TAG ) <nl> <nl> scene : getPhysicsWorld ( ) : addJoint ( cc . PhysicsJointPin : construct ( sp1PhysicsBody , <nl> local function PhysicsDemoPyramidStack ( ) <nl> eventDispatcher : addEventListenerWithSceneGraphPriority ( touchListener , layer ) <nl> <nl> local node = cc . Node : create ( ) <nl> - addPhysicsComponent ( node , <nl> - cc . PhysicsBody : createEdgeSegment ( cc . p ( VisibleRect : leftBottom ( ) . x , <nl> + node : setPhysicsBody ( cc . PhysicsBody : createEdgeSegment ( cc . p ( VisibleRect : leftBottom ( ) . x , <nl> VisibleRect : leftBottom ( ) . y + 50 ) , <nl> cc . p ( VisibleRect : rightBottom ( ) . x , <nl> VisibleRect : rightBottom ( ) . y + 50 ) ) ) <nl> local function PhysicsDemoPyramidStack ( ) <nl> <nl> local ball = cc . Sprite : create ( " Images / ball . png " ) <nl> ball : setScale ( 1 ) <nl> - addPhysicsComponent ( ball , cc . PhysicsBody : createCircle ( 10 ) ) <nl> - ball : getComponent ( PHYSICS_COMPONENT_NAME ) : getPhysicsBody ( ) : setTag ( DRAG_BODYS_TAG ) <nl> + ball : setPhysicsBody ( cc . PhysicsBody : createCircle ( 10 ) ) <nl> + ball : getPhysicsBody ( ) : setTag ( DRAG_BODYS_TAG ) <nl> ball : setPosition ( cc . p ( VisibleRect : bottom ( ) . x , VisibleRect : bottom ( ) . y + 60 ) ) <nl> layer : addChild ( ball ) <nl> <nl> local function PhysicsDemoPyramidStack ( ) <nl> local x = VisibleRect : bottom ( ) . x + ( i / 2 - j ) * 11 <nl> local y = VisibleRect : bottom ( ) . y + ( 14 - i ) * 23 + 100 <nl> local sp = addGrossiniAtPosition ( layer , cc . p ( x , y ) , 0 . 2 ) <nl> - sp : getComponent ( PHYSICS_COMPONENT_NAME ) : getPhysicsBody ( ) : setTag ( DRAG_BODYS_TAG ) <nl> + sp : getPhysicsBody ( ) : setTag ( DRAG_BODYS_TAG ) <nl> end <nl> end <nl> end <nl> local function PhysicsDemoRayCast ( ) <nl> cc . Director : getInstance ( ) : getRunningScene ( ) : getPhysicsWorld ( ) : setGravity ( cc . p ( 0 , 0 ) ) <nl> <nl> local node = cc . DrawNode : create ( ) <nl> - addPhysicsComponent ( node , <nl> - cc . PhysicsBody : createEdgeSegment ( cc . p ( VisibleRect : leftBottom ( ) . x , <nl> + node : setPhysicsBody ( cc . PhysicsBody : createEdgeSegment ( cc . p ( VisibleRect : leftBottom ( ) . x , <nl> VisibleRect : leftBottom ( ) . y + 50 ) , <nl> cc . p ( VisibleRect : rightBottom ( ) . x , <nl> VisibleRect : rightBottom ( ) . y + 50 ) ) ) <nl> local function PhysicsDemoOneWayPlatform ( ) <nl> eventDispatcher : addEventListenerWithSceneGraphPriority ( touchListener , layer ) <nl> <nl> local ground = cc . Node : create ( ) <nl> - addPhysicsComponent ( ground , <nl> - cc . PhysicsBody : createEdgeSegment ( cc . p ( VisibleRect : leftBottom ( ) . x , <nl> + ground : setPhysicsBody ( cc . PhysicsBody : createEdgeSegment ( cc . p ( VisibleRect : leftBottom ( ) . x , <nl> VisibleRect : leftBottom ( ) . y + 50 ) , <nl> cc . p ( VisibleRect : rightBottom ( ) . x , <nl> VisibleRect : rightBottom ( ) . y + 50 ) ) ) <nl> layer : addChild ( ground ) <nl> <nl> local platform = makeBox ( VisibleRect : center ( ) , cc . size ( 200 , 50 ) ) <nl> - local platformPhysicsBody = platform : getComponent ( PHYSICS_COMPONENT_NAME ) : getPhysicsBody ( ) <nl> + local platformPhysicsBody = platform : getPhysicsBody ( ) <nl> platformPhysicsBody : setDynamic ( false ) <nl> platformPhysicsBody : setContactTestBitmask ( 0xFFFFFFFF ) <nl> layer : addChild ( platform ) <nl> <nl> local ball = makeBall ( layer , cc . p ( VisibleRect : center ( ) . x , VisibleRect : center ( ) . y - 50 ) , 20 ) <nl> - local ballPhysicsBody = ball : getComponent ( PHYSICS_COMPONENT_NAME ) : getPhysicsBody ( ) <nl> + local ballPhysicsBody = ball : getPhysicsBody ( ) <nl> ballPhysicsBody : setVelocity ( cc . p ( 0 , 150 ) ) <nl> ballPhysicsBody : setTag ( DRAG_BODYS_TAG ) <nl> ballPhysicsBody : setMass ( 1 . 0 ) <nl> local function PhysicsDemoActions ( ) <nl> eventDispatcher : addEventListenerWithSceneGraphPriority ( touchListener , layer ) <nl> <nl> local node = cc . Node : create ( ) <nl> - addPhysicsComponent ( node , <nl> - cc . PhysicsBody : createEdgeBox ( cc . size ( VisibleRect : getVisibleRect ( ) . width , <nl> + node : setPhysicsBody ( cc . PhysicsBody : createEdgeBox ( cc . size ( VisibleRect : getVisibleRect ( ) . width , <nl> VisibleRect : getVisibleRect ( ) . height ) ) ) <nl> node : setPosition ( VisibleRect : center ( ) ) <nl> layer : addChild ( node ) <nl> local function PhysicsDemoActions ( ) <nl> local sp2 = addGrossiniAtPosition ( layer , cc . p ( VisibleRect : left ( ) . x + 50 , VisibleRect : left ( ) . y ) ) <nl> local sp3 = addGrossiniAtPosition ( layer , cc . p ( VisibleRect : right ( ) . x - 20 , VisibleRect : right ( ) . y ) ) <nl> local sp4 = addGrossiniAtPosition ( layer , cc . p ( VisibleRect : leftTop ( ) . x + 50 , VisibleRect : leftTop ( ) . y - 50 ) ) <nl> - sp4 : getComponent ( PHYSICS_COMPONENT_NAME ) : getPhysicsBody ( ) : setGravityEnable ( false ) <nl> + sp4 : getPhysicsBody ( ) : setGravityEnable ( false ) <nl> <nl> <nl> local actionTo = cc . JumpTo : create ( 2 , cc . p ( 100 , 100 ) , 50 , 4 ) <nl> local function PhysicsDemoPump ( ) <nl> VisibleRect : leftTop ( ) . y ) , <nl> 22 , <nl> cc . PhysicsMaterial ( 0 . 05 , 0 . 0 , 0 . 1 ) ) <nl> - ball : getComponent ( PHYSICS_COMPONENT_NAME ) : getPhysicsBody ( ) : setTag ( DRAG_BODYS_TAG ) <nl> + ball : getPhysicsBody ( ) : setTag ( DRAG_BODYS_TAG ) <nl> layer : addChild ( ball ) <nl> end <nl> <nl> - addPhysicsComponent ( node , body ) <nl> + node : setPhysicsBody ( body ) <nl> layer : addChild ( node ) <nl> <nl> local vec = <nl> local function PhysicsDemoPump ( ) <nl> - - small gear <nl> local sgear = cc . Node : create ( ) <nl> local sgearB = cc . PhysicsBody : createCircle ( 44 ) <nl> - addPhysicsComponent ( sgear , sgearB ) <nl> + sgear : setPhysicsBody ( sgearB ) <nl> sgear : setPosition ( cc . p ( VisibleRect : leftBottom ( ) . x + 125 , VisibleRect : leftBottom ( ) . y ) ) <nl> layer : addChild ( sgear ) <nl> sgearB : setCategoryBitmask ( 4 ) <nl> local function PhysicsDemoPump ( ) <nl> - - big gear <nl> local bgear = cc . Node : create ( ) <nl> local bgearB = cc . PhysicsBody : createCircle ( 100 ) <nl> - addPhysicsComponent ( bgear , bgearB ) <nl> + bgear : setPhysicsBody ( bgearB ) <nl> bgear : setPosition ( cc . p ( VisibleRect : leftBottom ( ) . x + 275 , VisibleRect : leftBottom ( ) . y ) ) <nl> layer : addChild ( bgear ) <nl> bgearB : setCategoryBitmask ( 4 ) <nl> local function PhysicsDemoPump ( ) <nl> local pumpB = cc . PhysicsBody : createPolygon ( vec , <nl> cc . PHYSICSBODY_MATERIAL_DEFAULT , <nl> cc . p ( - center . x , - center . y ) ) <nl> - addPhysicsComponent ( pump , pumpB ) <nl> + pump : setPhysicsBody ( pumpB ) <nl> layer : addChild ( pump ) <nl> pumpB : setCategoryBitmask ( 2 ) <nl> pumpB : setGravityEnable ( false ) <nl> local function PhysicsDemoPump ( ) <nl> pluggerB : setDynamic ( true ) <nl> pluggerB : setMass ( 30 ) <nl> pluggerB : setMoment ( 100000 ) <nl> - addPhysicsComponent ( plugger , pluggerB ) <nl> + plugger : setPhysicsBody ( pluggerB ) <nl> plugger : setPosition ( segCenter ) <nl> layer : addChild ( plugger ) <nl> pluggerB : setCategoryBitmask ( 2 ) <nl> local function PhysicsDemoSlice ( ) <nl> cc . PHYSICSBODY_MATERIAL_DEFAULT , <nl> cc . p ( - center . x , - center . y ) ) <nl> node : setPosition ( center ) <nl> - addPhysicsComponent ( node , polyon ) <nl> + node : setPhysicsBody ( polyon ) <nl> polyon : setVelocity ( body : getVelocityAtWorldPoint ( center ) ) <nl> polyon : setAngularVelocity ( body : getAngularVelocity ( ) ) <nl> polyon . tag = sliceTag <nl> local function PhysicsDemoSlice ( ) <nl> eventDispatcher : addEventListenerWithSceneGraphPriority ( touchListener , layer ) <nl> <nl> local ground = cc . Node : create ( ) <nl> - addPhysicsComponent ( ground , <nl> - cc . PhysicsBody : createEdgeSegment ( cc . p ( VisibleRect : leftBottom ( ) . x , <nl> + ground : setPhysicsBody ( cc . PhysicsBody : createEdgeSegment ( cc . p ( VisibleRect : leftBottom ( ) . x , <nl> VisibleRect : leftBottom ( ) . y + 50 ) , <nl> cc . p ( VisibleRect : rightBottom ( ) . x , <nl> VisibleRect : rightBottom ( ) . y + 50 ) ) ) <nl> local function PhysicsDemoSlice ( ) <nl> <nl> local box = cc . Node : create ( ) <nl> local points = { cc . p ( - 100 , - 100 ) , cc . p ( - 100 , 100 ) , cc . p ( 100 , 100 ) , cc . p ( 100 , - 100 ) } <nl> - addPhysicsComponent ( box , cc . PhysicsBody : createPolygon ( points ) ) <nl> + box : setPhysicsBody ( cc . PhysicsBody : createPolygon ( points ) ) <nl> box : setPosition ( VisibleRect : center ( ) ) <nl> - box : getComponent ( PHYSICS_COMPONENT_NAME ) : getPhysicsBody ( ) . tag = sliceTag <nl> + box : getPhysicsBody ( ) . tag = sliceTag <nl> layer : addChild ( box ) <nl> end <nl> <nl> local function PhysicsContactTest ( ) <nl> label : setPosition ( cc . p ( s . width / 2 , s . height - 170 ) ) <nl> <nl> local wall = cc . Node : create ( ) <nl> - addPhysicsComponent ( wall , cc . PhysicsBody : createEdgeBox ( s , cc . PhysicsMaterial ( 0 . 1 , 1 , 0 . 0 ) ) ) <nl> + wall : setPhysicsBody ( cc . PhysicsBody : createEdgeBox ( s , cc . PhysicsMaterial ( 0 . 1 , 1 , 0 . 0 ) ) ) <nl> wall : setPosition ( VisibleRect : center ( ) ) <nl> root : addChild ( wall ) <nl> <nl> local function PhysicsContactTest ( ) <nl> VisibleRect : leftBottom ( ) . y + position . y + size . height / 2 ) <nl> local velocity = cc . p ( ( math . random ( ) - 0 . 5 ) * 200 , ( math . random ( ) - 0 . 5 ) * 200 ) <nl> local box = makeBox ( position , size , 1 , cc . PhysicsMaterial ( 0 . 1 , 1 , 0 . 0 ) ) <nl> - local boxPhysicsBody = box : getComponent ( PHYSICS_COMPONENT_NAME ) : getPhysicsBody ( ) <nl> + local boxPhysicsBody = box : getPhysicsBody ( ) <nl> boxPhysicsBody : setVelocity ( velocity ) <nl> boxPhysicsBody : setCategoryBitmask ( 1 ) - - 0001 <nl> boxPhysicsBody : setContactTestBitmask ( 4 ) - - 0100 <nl> local function PhysicsContactTest ( ) <nl> VisibleRect : leftBottom ( ) . y + position . y + size . height / 2 ) <nl> local velocity = cc . p ( ( math . random ( ) - 0 . 5 ) * 200 , ( math . random ( ) - 0 . 5 ) * 200 ) <nl> local box = makeBox ( position , size , 2 , cc . PhysicsMaterial ( 0 . 1 , 1 , 0 . 0 ) ) <nl> - local boxPhysicsBody = box : getComponent ( PHYSICS_COMPONENT_NAME ) : getPhysicsBody ( ) <nl> + local boxPhysicsBody = box : getPhysicsBody ( ) <nl> boxPhysicsBody : setVelocity ( velocity ) <nl> boxPhysicsBody : setCategoryBitmask ( 2 ) - - 0010 <nl> boxPhysicsBody : setContactTestBitmask ( 8 ) - - 1000 <nl> local function PhysicsContactTest ( ) <nl> VisibleRect : leftBottom ( ) . y + position . y + size . height / 2 ) <nl> local velocity = cc . p ( ( math . random ( ) - 0 . 5 ) * 200 , ( math . random ( ) - 0 . 5 ) * 200 ) <nl> local triangle = makeTriangle ( position , size , 1 , cc . PhysicsMaterial ( 0 . 1 , 1 , 0 . 0 ) ) <nl> - local trianglePhysicsBody = triangle : getComponent ( PHYSICS_COMPONENT_NAME ) : getPhysicsBody ( ) <nl> + local trianglePhysicsBody = triangle : getPhysicsBody ( ) <nl> trianglePhysicsBody : setVelocity ( velocity ) <nl> trianglePhysicsBody : setCategoryBitmask ( 4 ) - - 0100 <nl> trianglePhysicsBody : setContactTestBitmask ( 1 ) - - 0001 <nl> local function PhysicsContactTest ( ) <nl> VisibleRect : leftBottom ( ) . y + position . y + size . height / 2 ) <nl> local velocity = cc . p ( ( math . random ( ) - 0 . 5 ) * 200 , ( math . random ( ) - 0 . 5 ) * 200 ) <nl> local triangle = makeTriangle ( position , size , 2 , cc . PhysicsMaterial ( 0 . 1 , 1 , 0 . 0 ) ) <nl> - local trianglePhysicsBody = triangle : getComponent ( PHYSICS_COMPONENT_NAME ) : getPhysicsBody ( ) <nl> + local trianglePhysicsBody = triangle : getPhysicsBody ( ) <nl> trianglePhysicsBody : setVelocity ( velocity ) <nl> trianglePhysicsBody : setCategoryBitmask ( 8 ) - - 1000 <nl> trianglePhysicsBody : setContactTestBitmask ( 2 ) - - 0010 <nl> local function PhysicsPositionRotationTest ( ) <nl> eventDispatcher : addEventListenerWithSceneGraphPriority ( touchListener , layer ) <nl> <nl> local wall = cc . Node : create ( ) <nl> - addPhysicsComponent ( wall , <nl> - cc . PhysicsBody : createEdgeBox ( VisibleRect : getVisibleRect ( ) ) ) <nl> + wall : setPhysicsBody ( cc . PhysicsBody : createEdgeBox ( VisibleRect : getVisibleRect ( ) ) ) <nl> wall : setPosition ( VisibleRect : center ( ) ) <nl> layer : addChild ( wall ) <nl> <nl> local function PhysicsPositionRotationTest ( ) <nl> anchorNode : setAnchorPoint ( cc . p ( 0 . 1 , 0 . 9 ) ) <nl> anchorNode : setPosition ( 100 , 100 ) <nl> anchorNode : setScale ( 0 . 25 ) <nl> - addPhysicsComponent ( anchorNode , <nl> - cc . PhysicsBody : createBox ( anchorNode : getContentSize ( ) ) ) <nl> - anchorNode : getComponent ( PHYSICS_COMPONENT_NAME ) : getPhysicsBody ( ) : setTag ( DRAG_BODYS_TAG ) <nl> + anchorNode : setPhysicsBody ( cc . PhysicsBody : createBox ( anchorNode : getContentSize ( ) ) ) <nl> + anchorNode : getPhysicsBody ( ) : setTag ( DRAG_BODYS_TAG ) <nl> layer : addChild ( anchorNode ) <nl> <nl> - - parent test <nl> local function PhysicsPositionRotationTest ( ) <nl> parent : setPosition ( 200 , 100 ) <nl> parent : setScale ( 0 . 25 ) <nl> local parentPhysicsBody = cc . PhysicsBody : createBox ( anchorNode : getContentSize ( ) ) <nl> - addPhysicsComponent ( parent , parentPhysicsBody ) <nl> + parent : setPhysicsBody ( parentPhysicsBody ) <nl> parentPhysicsBody : setTag ( DRAG_BODYS_TAG ) <nl> layer : addChild ( parent ) <nl> <nl> local leftBall = cc . Sprite : create ( " Images / ball . png " ) <nl> leftBall : setPosition ( - 30 , 0 ) <nl> leftBall : setScale ( 2 ) <nl> - addPhysicsComponent ( leftBall , cc . PhysicsBody : createCircle ( leftBall : getContentSize ( ) . width / 2 ) ) <nl> - leftBall : getComponent ( PHYSICS_COMPONENT_NAME ) : getPhysicsBody ( ) : setTag ( DRAG_BODYS_TAG ) <nl> + leftBall : setPhysicsBody ( cc . PhysicsBody : createCircle ( leftBall : getContentSize ( ) . width / 2 ) ) <nl> + leftBall : getPhysicsBody ( ) : setTag ( DRAG_BODYS_TAG ) <nl> parent : addChild ( leftBall ) <nl> <nl> - - offset position rotation test <nl> local function PhysicsPositionRotationTest ( ) <nl> offsetPosNode : setPosition ( 100 , 200 ) <nl> local offsetPosNodePhysicsBody = cc . PhysicsBody : createBox ( cc . size ( offsetPosNode : getContentSize ( ) . width / 2 , <nl> offsetPosNode : getContentSize ( ) . height / 2 ) ) <nl> - addPhysicsComponent ( offsetPosNode , offsetPosNodePhysicsBody ) <nl> + offsetPosNode : setPhysicsBody ( offsetPosNodePhysicsBody ) <nl> offsetPosNodePhysicsBody : setPositionOffset ( cc . p ( - offsetPosNode : getContentSize ( ) . width / 2 , <nl> - offsetPosNode : getContentSize ( ) . height / 2 ) ) <nl> offsetPosNodePhysicsBody : setRotationOffset ( 45 ) <nl> local function PhysicsSetGravityEnableTest ( ) <nl> eventDispatcher : addEventListenerWithSceneGraphPriority ( touchListener , layer ) <nl> <nl> local wall = cc . Node : create ( ) <nl> - addPhysicsComponent ( wall , <nl> - cc . PhysicsBody : createEdgeBox ( cc . size ( VisibleRect : getVisibleRect ( ) . width , <nl> + wall : setPhysicsBody ( cc . PhysicsBody : createEdgeBox ( cc . size ( VisibleRect : getVisibleRect ( ) . width , <nl> VisibleRect : getVisibleRect ( ) . height ) , <nl> cc . PhysicsMaterial ( 0 . 1 , 1 . 0 , 0 . 0 ) ) ) <nl> wall : setPosition ( VisibleRect : center ( ) ) ; <nl> layer : addChild ( wall ) <nl> <nl> local commonBox = makeBox ( cc . p ( 100 , 100 ) , cc . size ( 50 , 50 ) , 1 ) <nl> - commonBox : getComponent ( PHYSICS_COMPONENT_NAME ) : getPhysicsBody ( ) : setTag ( DRAG_BODYS_TAG ) <nl> + commonBox : getPhysicsBody ( ) : setTag ( DRAG_BODYS_TAG ) <nl> layer : addChild ( commonBox ) <nl> <nl> local box = makeBox ( cc . p ( 200 , 100 ) , cc . size ( 50 , 50 ) , 2 ) <nl> - local boxBody = box : getComponent ( PHYSICS_COMPONENT_NAME ) : getPhysicsBody ( ) <nl> + local boxBody = box : getPhysicsBody ( ) <nl> boxBody : setMass ( 20 ) <nl> boxBody : setTag ( DRAG_BODYS_TAG ) <nl> boxBody : setGravityEnable ( false ) <nl> local function PhysicsSetGravityEnableTest ( ) <nl> <nl> local ball = makeBall ( layer , cc . p ( 200 , 200 ) , 50 ) <nl> ball : setTag ( 2 ) <nl> - local ballBody = ball : getComponent ( PHYSICS_COMPONENT_NAME ) : getPhysicsBody ( ) <nl> + local ballBody = ball : getPhysicsBody ( ) <nl> ballBody : setTag ( DRAG_BODYS_TAG ) <nl> ballBody : setGravityEnable ( false ) <nl> ballBody : setMass ( 50 ) <nl> local function PhysicsSetGravityEnableTest ( ) <nl> local function onScheduleOnce ( ) <nl> cclog ( " onScheduleOnce " ) <nl> local ball = layer : getChildByTag ( 2 ) <nl> - ball : getComponent ( PHYSICS_COMPONENT_NAME ) : getPhysicsBody ( ) : setMass ( 200 ) <nl> + ball : getPhysicsBody ( ) : setMass ( 200 ) <nl> cc . Director : getInstance ( ) : getRunningScene ( ) : getPhysicsWorld ( ) : setGravity ( cc . p ( 0 , 98 ) ) <nl> end <nl> - - layer : scheduleOnce ( onScheduleOnce , 1 . 0 ) <nl> local function PhysicsDemoBug5482 ( ) <nl> <nl> - - wall <nl> local wall = cc . Node : create ( ) <nl> - addPhysicsComponent ( wall , <nl> - cc . PhysicsBody : createEdgeBox ( cc . size ( VisibleRect : getVisibleRect ( ) . width , <nl> + wall : setPhysicsBody ( cc . PhysicsBody : createEdgeBox ( cc . size ( VisibleRect : getVisibleRect ( ) . width , <nl> VisibleRect : getVisibleRect ( ) . height ) , <nl> cc . PhysicsMaterial ( 0 . 1 , 1 . 0 , 0 . 0 ) ) ) <nl> wall : setPosition ( VisibleRect : center ( ) ) ; <nl> local function PhysicsDemoBug5482 ( ) <nl> <nl> local _nodeA = cc . Sprite : create ( " Images / YellowSquare . png " ) <nl> _nodeA : setPosition ( cc . p ( VisibleRect : center ( ) . x - 150 , 100 ) ) <nl> - addPhysicsComponent ( _nodeA , nil ) <nl> + _nodeA : setPhysicsBody ( nil ) <nl> layer : addChild ( _nodeA ) <nl> <nl> local _nodeB = cc . Sprite : create ( " Images / YellowSquare . png " ) <nl> _nodeB : setPosition ( cc . p ( VisibleRect : center ( ) . x + 150 , 100 ) ) <nl> - addPhysicsComponent ( _nodeB , nil ) <nl> + _nodeB : setPhysicsBody ( nil ) <nl> layer : addChild ( _nodeB ) <nl> <nl> local _body = cc . PhysicsBody : createBox ( _nodeA : getContentSize ( ) ) <nl> local function PhysicsDemoBug5482 ( ) <nl> node = _nodeA <nl> cclog ( " _nodeA " ) <nl> end <nl> - node : getComponent ( PHYSICS_COMPONENT_NAME ) : setPhysicsBody ( _body ) <nl> + node : setPhysicsBody ( _body ) <nl> _bodyInA = not _bodyInA <nl> end <nl> <nl> local function PhysicsDemoBug5482 ( ) <nl> local function addBall ( ) <nl> local ball = cc . Sprite : create ( " Images / ball . png " ) <nl> ball : setPosition ( cc . p ( 100 , 100 ) ) <nl> - addPhysicsComponent ( ball , cc . PhysicsBody : createCircle ( ball : getContentSize ( ) . width / 2 , cc . PhysicsMaterial ( 0 . 1 , 1 , 0 . 0 ) ) ) <nl> - ball : getComponent ( PHYSICS_COMPONENT_NAME ) : getPhysicsBody ( ) : setTag ( DRAG_BODYS_TAG ) <nl> - ball : getComponent ( PHYSICS_COMPONENT_NAME ) : getPhysicsBody ( ) : setVelocity ( cc . p ( 1000 , 20 ) ) <nl> + ball : setPhysicsBody ( cc . PhysicsBody : createCircle ( ball : getContentSize ( ) . width / 2 , cc . PhysicsMaterial ( 0 . 1 , 1 , 0 . 0 ) ) ) <nl> + ball : getPhysicsBody ( ) : setTag ( DRAG_BODYS_TAG ) <nl> + ball : getPhysicsBody ( ) : setVelocity ( cc . p ( 1000 , 20 ) ) <nl> layer : addChild ( ball ) <nl> end <nl> <nl> local function PhysicsDemoBug5482 ( ) <nl> <nl> - - wall <nl> local wall = cc . Node : create ( ) <nl> - addPhysicsComponent ( wall , <nl> - cc . PhysicsBody : createEdgeBox ( cc . size ( VisibleRect : getVisibleRect ( ) . width , <nl> + wall : setPhysicsBody ( cc . PhysicsBody : createEdgeBox ( cc . size ( VisibleRect : getVisibleRect ( ) . width , <nl> VisibleRect : getVisibleRect ( ) . height ) , <nl> cc . PhysicsMaterial ( 0 . 1 , 1 . 0 , 0 . 0 ) ) ) <nl> wall : setPosition ( VisibleRect : center ( ) ) ; <nl> local function PhysicsTransformTest ( ) <nl> layer : addChild ( _rootLayer ) <nl> <nl> local wall = cc . Node : create ( ) <nl> - addPhysicsComponent ( wall , <nl> - cc . PhysicsBody : createEdgeBox ( cc . size ( VisibleRect : getVisibleRect ( ) . width , <nl> + wall : setPhysicsBody ( cc . PhysicsBody : createEdgeBox ( cc . size ( VisibleRect : getVisibleRect ( ) . width , <nl> VisibleRect : getVisibleRect ( ) . height ) , <nl> cc . PhysicsMaterial ( 0 . 1 , 1 . 0 , 0 . 0 ) ) ) <nl> wall : setPosition ( VisibleRect : center ( ) ) ; <nl> local function PhysicsTransformTest ( ) <nl> local _parentSprite = cc . Sprite : create ( " Images / YellowSquare . png " ) <nl> _parentSprite : setPosition ( cc . p ( 200 , 100 ) ) <nl> _parentSprite : setScale ( 0 . 25 ) <nl> - addPhysicsComponent ( _parentSprite , cc . PhysicsBody : createBox ( _parentSprite : getContentSize ( ) , cc . PhysicsMaterial ( 0 . 1 , 1 . 0 , 0 . 0 ) ) ) <nl> - _parentSprite : getComponent ( PHYSICS_COMPONENT_NAME ) : getPhysicsBody ( ) : setTag ( DRAG_BODYS_TAG ) <nl> + _parentSprite : setPhysicsBody ( cc . PhysicsBody : createBox ( _parentSprite : getContentSize ( ) , cc . PhysicsMaterial ( 0 . 1 , 1 . 0 , 0 . 0 ) ) ) <nl> + _parentSprite : getPhysicsBody ( ) : setTag ( DRAG_BODYS_TAG ) <nl> _parentSprite : setTag ( 1 ) <nl> _rootLayer : addChild ( _parentSprite ) <nl> <nl> local leftBall = cc . Sprite : create ( " Images / ball . png " ) <nl> leftBall : setPosition ( cc . p ( - 30 , 0 ) ) <nl> leftBall : setScale ( 2 ) <nl> - addPhysicsComponent ( leftBall , cc . PhysicsBody : createCircle ( leftBall : getContentSize ( ) . width / 2 , cc . PhysicsMaterial ( 0 . 1 , 1 . 0 , 0 . 0 ) ) ) <nl> - leftBall : getComponent ( PHYSICS_COMPONENT_NAME ) : getPhysicsBody ( ) : setTag ( DRAG_BODYS_TAG ) <nl> + leftBall : setPhysicsBody ( cc . PhysicsBody : createCircle ( leftBall : getContentSize ( ) . width / 2 , cc . PhysicsMaterial ( 0 . 1 , 1 . 0 , 0 . 0 ) ) ) <nl> + leftBall : getPhysicsBody ( ) : setTag ( DRAG_BODYS_TAG ) <nl> _parentSprite : addChild ( leftBall ) <nl> <nl> local scaleTo = cc . ScaleTo : create ( 2 . 0 , 0 . 5 ) <nl> local function PhysicsTransformTest ( ) <nl> local normal = cc . Sprite : create ( " Images / YellowSquare . png " ) <nl> normal : setPosition ( cc . p ( 300 , 100 ) ) <nl> normal : setScale ( 0 . 25 , 0 . 5 ) <nl> - addPhysicsComponent ( normal , cc . PhysicsBody : createBox ( normal : getContentSize ( ) ) , cc . PhysicsMaterial ( 0 . 1 , 1 . 0 , 0 . 0 ) ) <nl> - normal : getComponent ( PHYSICS_COMPONENT_NAME ) : getPhysicsBody ( ) : setTag ( DRAG_BODYS_TAG ) <nl> + normal : setPhysicsBody ( cc . PhysicsBody : createBox ( normal : getContentSize ( ) ) , cc . PhysicsMaterial ( 0 . 1 , 1 . 0 , 0 . 0 ) ) <nl> + normal : getPhysicsBody ( ) : setTag ( DRAG_BODYS_TAG ) <nl> _rootLayer : addChild ( normal ) <nl> <nl> local bullet = cc . Sprite : create ( " Images / ball . png " ) <nl> bullet : setPosition ( cc . p ( 200 , 200 ) ) <nl> - addPhysicsComponent ( bullet , cc . PhysicsBody : createCircle ( bullet : getContentSize ( ) . width / 2 , cc . PhysicsMaterial ( 0 . 1 , 1 . 0 , 0 . 0 ) ) ) <nl> - bullet : getComponent ( PHYSICS_COMPONENT_NAME ) : getPhysicsBody ( ) : setVelocity ( cc . p ( 100 , 100 ) ) <nl> + bullet : setPhysicsBody ( cc . PhysicsBody : createCircle ( bullet : getContentSize ( ) . width / 2 , cc . PhysicsMaterial ( 0 . 1 , 1 . 0 , 0 . 0 ) ) ) <nl> + bullet : getPhysicsBody ( ) : setVelocity ( cc . p ( 100 , 100 ) ) <nl> _rootLayer : addChild ( bullet ) <nl> <nl> local move = cc . MoveBy : create ( 2 . 0 , cc . p ( 100 , 100 ) ) <nl> mmm a / tools / tolua / cocos2dx . ini <nl> ppp b / tools / tolua / cocos2dx . ini <nl> classes = New . * Sprite . * Scene Node . * Director Layer . * Menu . * Touch . * Action . * M <nl> # will apply to all class names . This is a convenience wildcard to be able to skip similar named <nl> # functions from all classes . <nl> <nl> - skip = Node : : [ setGLServerState description getUserObject . * UserData getGLServerState . * schedule getPosition $ setContentSize setAnchorPoint enumerateChildren getonEnterTransitionDidFinishCallback getOnEnterCallback getOnExitCallback getonExitTransitionDidStartCallback setAdditionalTransform setRotationQuat getRotationQuat . * ( Physics ) . * ] , <nl> + skip = Node : : [ setGLServerState description getUserObject . * UserData getGLServerState . * schedule getPosition $ setContentSize setAnchorPoint enumerateChildren getonEnterTransitionDidFinishCallback getOnEnterCallback getOnExitCallback getonExitTransitionDidStartCallback setAdditionalTransform setRotationQuat getRotationQuat ] , <nl> Sprite : : [ getQuad ^ setPosition $ ^ create $ setPolygonInfo initWithPolygon getPolygonInfo ] , <nl> SpriteBatchNode : : [ getDescendants ] , <nl> MotionStreak : : [ draw update ] , <nl> mmm a / tools / tolua / cocos2dx_physics . ini <nl> ppp b / tools / tolua / cocos2dx_physics . ini <nl> headers = % ( cocosdir ) s / cocos / cocos2d . h <nl> <nl> # what classes to produce code for . You can use regular expressions here . When testing the regular <nl> # expression , it will be enclosed in " ^ $ " , like this : " ^ Menu * $ " . <nl> - classes = Event ( . * ( Physics ) . * ) Physics . * ComponentPhysics2d <nl> + classes = Event ( . * ( Physics ) . * ) Physics . * <nl> <nl> # what should we skip ? in the format ClassName : : [ function function ] <nl> # ClassName is a regular expression , but will be used like this : " ^ ClassName $ " functions are also <nl> skip = PhysicsBody : : [ getJoints createPolygon createEdgeChain createEdgePolygon ] , <nl> PhysicsShapeEdgePolygon : : [ create ^ getPoints $ ] , <nl> PhysicsShapeEdgeChain : : [ create ^ getPoints $ ] , <nl> PhysicsWorld : : [ getScene queryPoint queryRect rayCast ] , <nl> - PhysicsContact : : [ getData setData ] , <nl> - PhysicsManager : : [ PhysicsManager update ] , <nl> - ComponentPhysics2d : : [ beforeSimulation afterSimulation ] <nl> + PhysicsContact : : [ getData setData ] <nl> <nl> <nl> rename_functions = <nl>
|
Merge pull request from WenhaiLin / v3 - physics - refine
|
cocos2d/cocos2d-x
|
0cbc1e5f40c0f4364de027efaa47d344b4e46107
|
2015-09-18T13:56:36Z
|
mmm a / src / core / core . cpp <nl> ppp b / src / core / core . cpp <nl> FileSys : : VirtualFile GetGameFileFromPath ( const FileSys : : VirtualFilesystem & vfs , <nl> } <nl> struct System : : Impl { <nl> explicit Impl ( System & system ) <nl> - : kernel { system } , cpu_core_manager { system } , applet_manager { system } , reporter { system } { } <nl> + : kernel { system } , fs_controller { system } , cpu_core_manager { system } , <nl> + applet_manager { system } , reporter { system } { } <nl> <nl> Cpu & CurrentCpuCore ( ) { <nl> return cpu_core_manager . GetCurrentCore ( ) ; <nl> bool System : : GetExitLock ( ) const { <nl> return impl - > exit_lock ; <nl> } <nl> <nl> - void System : : SetCurrentProcessBuildID ( std : : array < u8 , 32 > id ) { <nl> + void System : : SetCurrentProcessBuildID ( const CurrentBuildProcessID & id ) { <nl> impl - > build_id = id ; <nl> } <nl> <nl> - const std : : array < u8 , 32 > & System : : GetCurrentProcessBuildID ( ) const { <nl> + const System : : CurrentBuildProcessID & System : : GetCurrentProcessBuildID ( ) const { <nl> return impl - > build_id ; <nl> } <nl> <nl> mmm a / src / core / core . h <nl> ppp b / src / core / core . h <nl> FileSys : : VirtualFile GetGameFileFromPath ( const FileSys : : VirtualFilesystem & vfs , <nl> <nl> class System { <nl> public : <nl> + using CurrentBuildProcessID = std : : array < u8 , 0x20 > ; <nl> + <nl> System ( const System & ) = delete ; <nl> System & operator = ( const System & ) = delete ; <nl> <nl> class System { <nl> <nl> bool GetExitLock ( ) const ; <nl> <nl> - void SetCurrentProcessBuildID ( std : : array < u8 , 0x20 > id ) ; <nl> + void SetCurrentProcessBuildID ( const CurrentBuildProcessID & id ) ; <nl> <nl> - const std : : array < u8 , 0x20 > & GetCurrentProcessBuildID ( ) const ; <nl> + const CurrentBuildProcessID & GetCurrentProcessBuildID ( ) const ; <nl> <nl> private : <nl> System ( ) ; <nl> mmm a / src / core / file_sys / romfs_factory . cpp <nl> ppp b / src / core / file_sys / romfs_factory . cpp <nl> void RomFSFactory : : SetPackedUpdate ( VirtualFile update_raw ) { <nl> this - > update_raw = std : : move ( update_raw ) ; <nl> } <nl> <nl> - ResultVal < VirtualFile > RomFSFactory : : OpenCurrentProcess ( ) const { <nl> + ResultVal < VirtualFile > RomFSFactory : : OpenCurrentProcess ( u64 current_process_title_id ) const { <nl> if ( ! updatable ) <nl> return MakeResult < VirtualFile > ( file ) ; <nl> <nl> - const PatchManager patch_manager ( Core : : CurrentProcess ( ) - > GetTitleID ( ) ) ; <nl> + const PatchManager patch_manager ( current_process_title_id ) ; <nl> return MakeResult < VirtualFile > ( <nl> patch_manager . PatchRomFS ( file , ivfc_offset , ContentRecordType : : Program , update_raw ) ) ; <nl> } <nl> mmm a / src / core / file_sys / romfs_factory . h <nl> ppp b / src / core / file_sys / romfs_factory . h <nl> class RomFSFactory { <nl> ~ RomFSFactory ( ) ; <nl> <nl> void SetPackedUpdate ( VirtualFile update_raw ) ; <nl> - ResultVal < VirtualFile > OpenCurrentProcess ( ) const ; <nl> + ResultVal < VirtualFile > OpenCurrentProcess ( u64 current_process_title_id ) const ; <nl> ResultVal < VirtualFile > Open ( u64 title_id , StorageId storage , ContentRecordType type ) const ; <nl> <nl> private : <nl> mmm a / src / core / hle / service / am / am . cpp <nl> ppp b / src / core / hle / service / am / am . cpp <nl> void IApplicationFunctions : : PopLaunchParameter ( Kernel : : HLERequestContext & ctx ) { <nl> if ( kind = = LaunchParameterKind : : ApplicationSpecific & & ! launch_popped_application_specific ) { <nl> const auto backend = BCAT : : CreateBackendFromSettings ( <nl> [ this ] ( u64 tid ) { return system . GetFileSystemController ( ) . GetBCATDirectory ( tid ) ; } ) ; <nl> - const auto build_id_full = Core : : System : : GetInstance ( ) . GetCurrentProcessBuildID ( ) ; <nl> + const auto build_id_full = system . GetCurrentProcessBuildID ( ) ; <nl> u64 build_id { } ; <nl> std : : memcpy ( & build_id , build_id_full . data ( ) , sizeof ( u64 ) ) ; <nl> <nl> const auto data = <nl> - backend - > GetLaunchParameter ( { Core : : CurrentProcess ( ) - > GetTitleID ( ) , build_id } ) ; <nl> + backend - > GetLaunchParameter ( { system . CurrentProcess ( ) - > GetTitleID ( ) , build_id } ) ; <nl> <nl> if ( data . has_value ( ) ) { <nl> IPC : : ResponseBuilder rb { ctx , 2 , 0 , 1 } ; <nl> void IApplicationFunctions : : EnsureSaveData ( Kernel : : HLERequestContext & ctx ) { <nl> LOG_DEBUG ( Service_AM , " called , uid = { : 016X } { : 016X } " , user_id [ 1 ] , user_id [ 0 ] ) ; <nl> <nl> FileSys : : SaveDataDescriptor descriptor { } ; <nl> - descriptor . title_id = Core : : CurrentProcess ( ) - > GetTitleID ( ) ; <nl> + descriptor . title_id = system . CurrentProcess ( ) - > GetTitleID ( ) ; <nl> descriptor . user_id = user_id ; <nl> descriptor . type = FileSys : : SaveDataType : : SaveData ; <nl> const auto res = system . GetFileSystemController ( ) . CreateSaveData ( <nl> mmm a / src / core / hle / service / bcat / bcat . cpp <nl> ppp b / src / core / hle / service / bcat / bcat . cpp <nl> <nl> <nl> namespace Service : : BCAT { <nl> <nl> - BCAT : : BCAT ( std : : shared_ptr < Module > module , FileSystem : : FileSystemController & fsc , const char * name ) <nl> - : Module : : Interface ( std : : move ( module ) , fsc , name ) { <nl> + BCAT : : BCAT ( Core : : System & system , std : : shared_ptr < Module > module , <nl> + FileSystem : : FileSystemController & fsc , const char * name ) <nl> + : Interface ( system , std : : move ( module ) , fsc , name ) { <nl> / / clang - format off <nl> static const FunctionInfo functions [ ] = { <nl> { 0 , & BCAT : : CreateBcatService , " CreateBcatService " } , <nl> mmm a / src / core / hle / service / bcat / bcat . h <nl> ppp b / src / core / hle / service / bcat / bcat . h <nl> <nl> <nl> # include " core / hle / service / bcat / module . h " <nl> <nl> + namespace Core { <nl> + class System ; <nl> + } <nl> + <nl> namespace Service : : BCAT { <nl> <nl> class BCAT final : public Module : : Interface { <nl> public : <nl> - explicit BCAT ( std : : shared_ptr < Module > module , FileSystem : : FileSystemController & fsc , <nl> - const char * name ) ; <nl> + explicit BCAT ( Core : : System & system , std : : shared_ptr < Module > module , <nl> + FileSystem : : FileSystemController & fsc , const char * name ) ; <nl> ~ BCAT ( ) override ; <nl> } ; <nl> <nl> mmm a / src / core / hle / service / bcat / module . cpp <nl> ppp b / src / core / hle / service / bcat / module . cpp <nl> using BCATDigest = std : : array < u8 , 0x10 > ; <nl> <nl> namespace { <nl> <nl> - u64 GetCurrentBuildID ( ) { <nl> - const auto & id = Core : : System : : GetInstance ( ) . GetCurrentProcessBuildID ( ) ; <nl> + u64 GetCurrentBuildID ( const Core : : System : : CurrentBuildProcessID & id ) { <nl> u64 out { } ; <nl> std : : memcpy ( & out , id . data ( ) , sizeof ( u64 ) ) ; <nl> return out ; <nl> class IDeliveryCacheProgressService final : public ServiceFramework < IDeliveryCac <nl> <nl> class IBcatService final : public ServiceFramework < IBcatService > { <nl> public : <nl> - IBcatService ( Backend & backend ) : ServiceFramework ( " IBcatService " ) , backend ( backend ) { <nl> + explicit IBcatService ( Core : : System & system_ , Backend & backend_ ) <nl> + : ServiceFramework ( " IBcatService " ) , system { system_ } , backend { backend_ } { <nl> / / clang - format off <nl> static const FunctionInfo functions [ ] = { <nl> { 10100 , & IBcatService : : RequestSyncDeliveryCache , " RequestSyncDeliveryCache " } , <nl> class IBcatService final : public ServiceFramework < IBcatService > { <nl> void RequestSyncDeliveryCache ( Kernel : : HLERequestContext & ctx ) { <nl> LOG_DEBUG ( Service_BCAT , " called " ) ; <nl> <nl> - backend . Synchronize ( { Core : : CurrentProcess ( ) - > GetTitleID ( ) , GetCurrentBuildID ( ) } , <nl> + backend . Synchronize ( { system . CurrentProcess ( ) - > GetTitleID ( ) , <nl> + GetCurrentBuildID ( system . GetCurrentProcessBuildID ( ) ) } , <nl> progress . at ( static_cast < std : : size_t > ( SyncType : : Normal ) ) ) ; <nl> <nl> IPC : : ResponseBuilder rb { ctx , 2 , 0 , 1 } ; <nl> class IBcatService final : public ServiceFramework < IBcatService > { <nl> <nl> LOG_DEBUG ( Service_BCAT , " called , name = { } " , name ) ; <nl> <nl> - backend . SynchronizeDirectory ( { Core : : CurrentProcess ( ) - > GetTitleID ( ) , GetCurrentBuildID ( ) } , <nl> + backend . SynchronizeDirectory ( { system . CurrentProcess ( ) - > GetTitleID ( ) , <nl> + GetCurrentBuildID ( system . GetCurrentProcessBuildID ( ) ) } , <nl> name , <nl> progress . at ( static_cast < std : : size_t > ( SyncType : : Directory ) ) ) ; <nl> <nl> class IBcatService final : public ServiceFramework < IBcatService > { <nl> rb . Push ( RESULT_SUCCESS ) ; <nl> } <nl> <nl> + Core : : System & system ; <nl> Backend & backend ; <nl> <nl> std : : array < ProgressServiceBackend , static_cast < std : : size_t > ( SyncType : : Count ) > progress { <nl> void Module : : Interface : : CreateBcatService ( Kernel : : HLERequestContext & ctx ) { <nl> <nl> IPC : : ResponseBuilder rb { ctx , 2 , 0 , 1 } ; <nl> rb . Push ( RESULT_SUCCESS ) ; <nl> - rb . PushIpcInterface < IBcatService > ( * backend ) ; <nl> + rb . PushIpcInterface < IBcatService > ( system , * backend ) ; <nl> } <nl> <nl> class IDeliveryCacheFileService final : public ServiceFramework < IDeliveryCacheFileService > { <nl> void Module : : Interface : : CreateDeliveryCacheStorageService ( Kernel : : HLERequestCont <nl> IPC : : ResponseBuilder rb { ctx , 2 , 0 , 1 } ; <nl> rb . Push ( RESULT_SUCCESS ) ; <nl> rb . PushIpcInterface < IDeliveryCacheStorageService > ( <nl> - fsc . GetBCATDirectory ( Core : : CurrentProcess ( ) - > GetTitleID ( ) ) ) ; <nl> + fsc . GetBCATDirectory ( system . CurrentProcess ( ) - > GetTitleID ( ) ) ) ; <nl> } <nl> <nl> void Module : : Interface : : CreateDeliveryCacheStorageServiceWithApplicationId ( <nl> std : : unique_ptr < Backend > CreateBackendFromSettings ( DirectoryGetter getter ) { <nl> return std : : make_unique < NullBackend > ( std : : move ( getter ) ) ; <nl> } <nl> <nl> - Module : : Interface : : Interface ( std : : shared_ptr < Module > module , FileSystem : : FileSystemController & fsc , <nl> - const char * name ) <nl> - : ServiceFramework ( name ) , fsc ( fsc ) , module ( std : : move ( module ) ) , <nl> - backend ( CreateBackendFromSettings ( [ & fsc ] ( u64 tid ) { return fsc . GetBCATDirectory ( tid ) ; } ) ) { } <nl> + Module : : Interface : : Interface ( Core : : System & system_ , std : : shared_ptr < Module > module_ , <nl> + FileSystem : : FileSystemController & fsc_ , const char * name ) <nl> + : ServiceFramework ( name ) , fsc { fsc_ } , module { std : : move ( module_ ) } , <nl> + backend { CreateBackendFromSettings ( [ & fsc_ ] ( u64 tid ) { return fsc_ . GetBCATDirectory ( tid ) ; } ) } , <nl> + system { system_ } { } <nl> <nl> Module : : Interface : : ~ Interface ( ) = default ; <nl> <nl> void InstallInterfaces ( Core : : System & system ) { <nl> auto module = std : : make_shared < Module > ( ) ; <nl> - std : : make_shared < BCAT > ( module , system . GetFileSystemController ( ) , " bcat : a " ) <nl> + std : : make_shared < BCAT > ( system , module , system . GetFileSystemController ( ) , " bcat : a " ) <nl> - > InstallAsService ( system . ServiceManager ( ) ) ; <nl> - std : : make_shared < BCAT > ( module , system . GetFileSystemController ( ) , " bcat : m " ) <nl> + std : : make_shared < BCAT > ( system , module , system . GetFileSystemController ( ) , " bcat : m " ) <nl> - > InstallAsService ( system . ServiceManager ( ) ) ; <nl> - std : : make_shared < BCAT > ( module , system . GetFileSystemController ( ) , " bcat : u " ) <nl> + std : : make_shared < BCAT > ( system , module , system . GetFileSystemController ( ) , " bcat : u " ) <nl> - > InstallAsService ( system . ServiceManager ( ) ) ; <nl> - std : : make_shared < BCAT > ( module , system . GetFileSystemController ( ) , " bcat : s " ) <nl> + std : : make_shared < BCAT > ( system , module , system . GetFileSystemController ( ) , " bcat : s " ) <nl> - > InstallAsService ( system . ServiceManager ( ) ) ; <nl> } <nl> <nl> mmm a / src / core / hle / service / bcat / module . h <nl> ppp b / src / core / hle / service / bcat / module . h <nl> <nl> <nl> # include " core / hle / service / service . h " <nl> <nl> + namespace Core { <nl> + class System ; <nl> + } <nl> + <nl> namespace Service { <nl> <nl> namespace FileSystem { <nl> class Module final { <nl> public : <nl> class Interface : public ServiceFramework < Interface > { <nl> public : <nl> - explicit Interface ( std : : shared_ptr < Module > module , FileSystem : : FileSystemController & fsc , <nl> - const char * name ) ; <nl> + explicit Interface ( Core : : System & system_ , std : : shared_ptr < Module > module_ , <nl> + FileSystem : : FileSystemController & fsc_ , const char * name ) ; <nl> ~ Interface ( ) override ; <nl> <nl> void CreateBcatService ( Kernel : : HLERequestContext & ctx ) ; <nl> class Module final { <nl> <nl> std : : shared_ptr < Module > module ; <nl> std : : unique_ptr < Backend > backend ; <nl> + <nl> + private : <nl> + Core : : System & system ; <nl> } ; <nl> } ; <nl> <nl> mmm a / src / core / hle / service / fatal / fatal . cpp <nl> ppp b / src / core / hle / service / fatal / fatal . cpp <nl> enum class FatalType : u32 { <nl> <nl> static void GenerateErrorReport ( Core : : System & system , ResultCode error_code , <nl> const FatalInfo & info ) { <nl> - const auto title_id = Core : : CurrentProcess ( ) - > GetTitleID ( ) ; <nl> + const auto title_id = system . CurrentProcess ( ) - > GetTitleID ( ) ; <nl> std : : string crash_report = fmt : : format ( <nl> " Yuzu { } - { } crash report \ n " <nl> " Title ID : { : 016x } \ n " <nl> mmm a / src / core / hle / service / filesystem / filesystem . cpp <nl> ppp b / src / core / hle / service / filesystem / filesystem . cpp <nl> ResultVal < FileSys : : EntryType > VfsDirectoryServiceWrapper : : GetEntryType ( <nl> return FileSys : : ERROR_PATH_NOT_FOUND ; <nl> } <nl> <nl> - FileSystemController : : FileSystemController ( ) = default ; <nl> + FileSystemController : : FileSystemController ( Core : : System & system_ ) : system { system_ } { } <nl> <nl> FileSystemController : : ~ FileSystemController ( ) = default ; <nl> <nl> ResultVal < FileSys : : VirtualFile > FileSystemController : : OpenRomFSCurrentProcess ( ) <nl> return ResultCode ( - 1 ) ; <nl> } <nl> <nl> - return romfs_factory - > OpenCurrentProcess ( ) ; <nl> + return romfs_factory - > OpenCurrentProcess ( system . CurrentProcess ( ) - > GetTitleID ( ) ) ; <nl> } <nl> <nl> ResultVal < FileSys : : VirtualFile > FileSystemController : : OpenRomFS ( <nl> FileSys : : SaveDataSize FileSystemController : : ReadSaveDataSize ( FileSys : : SaveDataTy <nl> FileSys : : SaveDataSize new_size { SUFFICIENT_SAVE_DATA_SIZE , SUFFICIENT_SAVE_DATA_SIZE } ; <nl> <nl> FileSys : : NACP nacp ; <nl> - const auto res = Core : : System : : GetInstance ( ) . GetAppLoader ( ) . ReadControlData ( nacp ) ; <nl> + const auto res = system . GetAppLoader ( ) . ReadControlData ( nacp ) ; <nl> <nl> if ( res ! = Loader : : ResultStatus : : Success ) { <nl> - FileSys : : PatchManager pm { Core : : CurrentProcess ( ) - > GetTitleID ( ) } ; <nl> + FileSys : : PatchManager pm { system . CurrentProcess ( ) - > GetTitleID ( ) } ; <nl> auto [ nacp_unique , discard ] = pm . GetControlMetadata ( ) ; <nl> <nl> if ( nacp_unique ! = nullptr ) { <nl> void FileSystemController : : CreateFactories ( FileSys : : VfsFilesystem & vfs , bool ove <nl> if ( bis_factory = = nullptr ) { <nl> bis_factory = <nl> std : : make_unique < FileSys : : BISFactory > ( nand_directory , load_directory , dump_directory ) ; <nl> - Core : : System : : GetInstance ( ) . RegisterContentProvider ( <nl> - FileSys : : ContentProviderUnionSlot : : SysNAND , bis_factory - > GetSystemNANDContents ( ) ) ; <nl> - Core : : System : : GetInstance ( ) . RegisterContentProvider ( <nl> - FileSys : : ContentProviderUnionSlot : : UserNAND , bis_factory - > GetUserNANDContents ( ) ) ; <nl> + system . RegisterContentProvider ( FileSys : : ContentProviderUnionSlot : : SysNAND , <nl> + bis_factory - > GetSystemNANDContents ( ) ) ; <nl> + system . RegisterContentProvider ( FileSys : : ContentProviderUnionSlot : : UserNAND , <nl> + bis_factory - > GetUserNANDContents ( ) ) ; <nl> } <nl> <nl> if ( save_data_factory = = nullptr ) { <nl> void FileSystemController : : CreateFactories ( FileSys : : VfsFilesystem & vfs , bool ove <nl> <nl> if ( sdmc_factory = = nullptr ) { <nl> sdmc_factory = std : : make_unique < FileSys : : SDMCFactory > ( std : : move ( sd_directory ) ) ; <nl> - Core : : System : : GetInstance ( ) . RegisterContentProvider ( FileSys : : ContentProviderUnionSlot : : SDMC , <nl> - sdmc_factory - > GetSDMCContents ( ) ) ; <nl> + system . RegisterContentProvider ( FileSys : : ContentProviderUnionSlot : : SDMC , <nl> + sdmc_factory - > GetSDMCContents ( ) ) ; <nl> } <nl> } <nl> <nl> mmm a / src / core / hle / service / filesystem / filesystem . h <nl> ppp b / src / core / hle / service / filesystem / filesystem . h <nl> <nl> # include " core / file_sys / vfs . h " <nl> # include " core / hle / result . h " <nl> <nl> + namespace Core { <nl> + class System ; <nl> + } <nl> + <nl> namespace FileSys { <nl> class BISFactory ; <nl> class RegisteredCache ; <nl> enum class ImageDirectoryId : u32 { <nl> <nl> class FileSystemController { <nl> public : <nl> - FileSystemController ( ) ; <nl> + explicit FileSystemController ( Core : : System & system_ ) ; <nl> ~ FileSystemController ( ) ; <nl> <nl> ResultCode RegisterRomFS ( std : : unique_ptr < FileSys : : RomFSFactory > & & factory ) ; <nl> class FileSystemController { <nl> std : : unique_ptr < FileSys : : XCI > gamecard ; <nl> std : : unique_ptr < FileSys : : RegisteredCache > gamecard_registered ; <nl> std : : unique_ptr < FileSys : : PlaceholderCache > gamecard_placeholder ; <nl> + <nl> + Core : : System & system ; <nl> } ; <nl> <nl> void InstallInterfaces ( Core : : System & system ) ; <nl> mmm a / src / core / hle / service / ldr / ldr . cpp <nl> ppp b / src / core / hle / service / ldr / ldr . cpp <nl> class RelocatableObject final : public ServiceFramework < RelocatableObject > { <nl> return ; <nl> } <nl> <nl> - if ( Core : : CurrentProcess ( ) - > GetTitleID ( ) ! = header . title_id ) { <nl> + if ( system . CurrentProcess ( ) - > GetTitleID ( ) ! = header . title_id ) { <nl> LOG_ERROR ( Service_LDR , <nl> " Attempting to load NRR with title ID other than current process . ( actual " <nl> " { : 016X } ) ! " , <nl> class RelocatableObject final : public ServiceFramework < RelocatableObject > { <nl> } <nl> <nl> / / Load NRO as new executable module <nl> - auto * process = Core : : CurrentProcess ( ) ; <nl> + auto * process = system . CurrentProcess ( ) ; <nl> auto & vm_manager = process - > VMManager ( ) ; <nl> auto map_address = vm_manager . FindFreeRegion ( nro_size + bss_size ) ; <nl> <nl> class RelocatableObject final : public ServiceFramework < RelocatableObject > { <nl> return ; <nl> } <nl> <nl> - auto & vm_manager = Core : : CurrentProcess ( ) - > VMManager ( ) ; <nl> + auto & vm_manager = system . CurrentProcess ( ) - > VMManager ( ) ; <nl> const auto & nro_info = iter - > second ; <nl> <nl> / / Unmap the mirrored memory <nl> mmm a / src / core / hle / service / ns / pl_u . cpp <nl> ppp b / src / core / hle / service / ns / pl_u . cpp <nl> void PL_U : : GetSharedMemoryAddressOffset ( Kernel : : HLERequestContext & ctx ) { <nl> void PL_U : : GetSharedMemoryNativeHandle ( Kernel : : HLERequestContext & ctx ) { <nl> / / Map backing memory for the font data <nl> LOG_DEBUG ( Service_NS , " called " ) ; <nl> - Core : : CurrentProcess ( ) - > VMManager ( ) . MapMemoryBlock ( SHARED_FONT_MEM_VADDR , impl - > shared_font , 0 , <nl> - SHARED_FONT_MEM_SIZE , <nl> - Kernel : : MemoryState : : Shared ) ; <nl> + system . CurrentProcess ( ) - > VMManager ( ) . MapMemoryBlock ( SHARED_FONT_MEM_VADDR , impl - > shared_font , 0 , <nl> + SHARED_FONT_MEM_SIZE , <nl> + Kernel : : MemoryState : : Shared ) ; <nl> <nl> / / Create shared font memory object <nl> auto & kernel = system . Kernel ( ) ; <nl> impl - > shared_font_mem = Kernel : : SharedMemory : : Create ( <nl> - kernel , Core : : CurrentProcess ( ) , SHARED_FONT_MEM_SIZE , Kernel : : MemoryPermission : : ReadWrite , <nl> + kernel , system . CurrentProcess ( ) , SHARED_FONT_MEM_SIZE , Kernel : : MemoryPermission : : ReadWrite , <nl> Kernel : : MemoryPermission : : Read , SHARED_FONT_MEM_VADDR , Kernel : : MemoryRegion : : BASE , <nl> " PL_U : shared_font_mem " ) ; <nl> <nl>
|
hle / service : Replace global system instance calls with instance - based ones
|
yuzu-emu/yuzu
|
69f16ba50e3c52a17405670b976ac4ba63f58021
|
2019-10-06T17:42:23Z
|
mmm a / src / objective - c / tests / run_plugin_tests . sh <nl> ppp b / src / objective - c / tests / run_plugin_tests . sh <nl> cd $ ( dirname $ 0 ) <nl> <nl> ROOT_DIR = . . / . . / . . <nl> BAZEL = $ ROOT_DIR / tools / bazel <nl> - PROTOC = bazel - bin / external / com_google_protobuf / protoc <nl> - PLUGIN = bazel - bin / src / compiler / grpc_objective_c_plugin <nl> + PROTOC = $ ROOT_DIR / bazel - bin / external / com_google_protobuf / protoc <nl> + PLUGIN = $ ROOT_DIR / bazel - bin / src / compiler / grpc_objective_c_plugin <nl> <nl> [ - f $ PROTOC ] & & [ - f $ PLUGIN ] | | { <nl> BAZEL build @ com_google_protobuf / / : protoc / / src / compiler : grpc_objective_c_plugin <nl>
|
address review comments
|
grpc/grpc
|
30b6b1f0f4655fb0bf242200f458cc3d78610bb6
|
2020-04-17T17:16:21Z
|
mmm a / tensorflow / contrib / tensorrt / convert / convert_nodes . cc <nl> ppp b / tensorflow / contrib / tensorrt / convert / convert_nodes . cc <nl> tensorflow : : Status ConvertConst ( Converter & ctx , <nl> } else if ( ! weights_tensor . tensor_content ( ) . empty ( ) ) { <nl> VLOG ( 2 ) < < " TENSOR ! ! ! " < < node_def . name ( ) ; <nl> const auto & content = weights_tensor . tensor_content ( ) ; <nl> - weights = TRT_ShapedWeights ( dtype , weights_tensor . tensor_content ( ) . data ( ) , <nl> - GetTensorShape ( tensor ) ) ; <nl> + <nl> + weights = ctx . get_temp_weights ( dtype , GetTensorShape ( tensor ) ) ; <nl> + if ( content . size ( ) > 0 ) { <nl> + const int dtype_size = tensorflow : : DataTypeSize ( dtype ) ; <nl> + CHECK_EQ ( 0 , content . size ( ) % dtype_size ) <nl> + < < " Tensor content size ( " < < content . size ( ) <nl> + < < " ) is not a multiple of " < < dtype_size ; <nl> + port : : CopyToArray ( content , static_cast < char * > ( const_cast < void * > ( weights . GetValues ( ) ) ) ) ; <nl> + } <nl> } else { <nl> return tensorflow : : errors : : Unimplemented ( <nl> " Not supported constant type , at " + node_def . name ( ) ) ; <nl>
|
[ update ]
|
tensorflow/tensorflow
|
e65a6202dbfd034233a9a0b453461f1e3b7fce8d
|
2018-02-08T19:09:53Z
|
mmm a / README . linux <nl> ppp b / README . linux <nl> Build - Depends : debhelper ( > = 7 . 0 . 50 ~ ) , python - support , cmake , <nl> libavformat - dev , libavutil - dev , libpostproc - dev , libswscale - dev , <nl> libmpeg2 - 4 - dev , libass - dev ( > = 0 . 9 . 8 ) , libmpcdec - dev , libflac - dev , <nl> libwavpack - dev , python - dev , gawk , gperf , nasm [ ! amd64 ] , libcwiid1 - dev , <nl> - libbluetooth - dev , zlib1g - dev , libmms - dev ( > = 0 . 4 ) , libsmbclient - dev , <nl> + libbluetooth - dev , zlib1g - dev , libsmbclient - dev , <nl> libfaad - dev , libiso9660 - dev , libssl - dev , lsb - release , libvdpau - dev , libmicrohttpd - dev , <nl> libmodplug - dev , librtmp - dev , libcrystalhd - dev , curl <nl> <nl> mmm a / README . osx <nl> ppp b / README . osx <nl> Then install the following port packages ( order is very important ) : <nl> $ sudo port install libvorbis + universal <nl> $ sudo port install libmad macosx_deployment_target = 10 . 4 <nl> $ sudo port install fribidi + universal <nl> - $ sudo port install libmms + universal <nl> $ sudo port install wavpack + universal <nl> $ sudo port install libmpeg2 + no_sdl + no_x11 + universal <nl> <nl> mmm a / README . ubuntu <nl> ppp b / README . ubuntu <nl> Two methods exist to install the required Ubuntu packages : <nl> <nl> For Ubuntu ( all versions > = 7 . 04 ) : <nl> <nl> - # sudo apt - get install subversion make g + + gcc gawk pmount libtool nasm yasm automake cmake gperf zip unzip bison libsdl - dev libsdl - image1 . 2 - dev libsdl - gfx1 . 2 - dev libsdl - mixer1 . 2 - dev libfribidi - dev liblzo2 - dev libfreetype6 - dev libsqlite3 - dev libogg - dev libasound - dev python - sqlite libglew - dev libcurl3 libcurl4 - gnutls - dev libxrandr - dev libxrender - dev libmad0 - dev libogg - dev libvorbisenc2 libsmbclient - dev libmysqlclient - dev libpcre3 - dev libdbus - 1 - dev libhal - dev libhal - storage - dev libjasper - dev libfontconfig - dev libbz2 - dev libboost - dev libenca - dev libxt - dev libxtst - dev libxmu - dev libpng - dev libjpeg - dev libpulse - dev mesa - utils libcdio - dev libsamplerate - dev libmms - dev libmpeg3 - dev libfaad - dev libflac - dev libiso9660 - dev libass - dev libssl - dev fp - compiler gdc libwavpack - dev libmpeg2 - 4 - dev libmicrohttpd - dev libmodplug - dev libssh - dev gettext cvs <nl> + # sudo apt - get install subversion make g + + gcc gawk pmount libtool nasm yasm automake cmake gperf zip unzip bison libsdl - dev libsdl - image1 . 2 - dev libsdl - gfx1 . 2 - dev libsdl - mixer1 . 2 - dev libfribidi - dev liblzo2 - dev libfreetype6 - dev libsqlite3 - dev libogg - dev libasound - dev python - sqlite libglew - dev libcurl3 libcurl4 - gnutls - dev libxrandr - dev libxrender - dev libmad0 - dev libogg - dev libvorbisenc2 libsmbclient - dev libmysqlclient - dev libpcre3 - dev libdbus - 1 - dev libhal - dev libhal - storage - dev libjasper - dev libfontconfig - dev libbz2 - dev libboost - dev libenca - dev libxt - dev libxtst - dev libxmu - dev libpng - dev libjpeg - dev libpulse - dev mesa - utils libcdio - dev libsamplerate - dev libmpeg3 - dev libfaad - dev libflac - dev libiso9660 - dev libass - dev libssl - dev fp - compiler gdc libwavpack - dev libmpeg2 - 4 - dev libmicrohttpd - dev libmodplug - dev libssh - dev gettext cvs <nl> <nl> For Ubuntu Maverick ( 10 . 10 ) : <nl> # sudo apt - get install autopoint <nl> In this case you will have to manually compile the latest version . <nl> # make <nl> # sudo make install <nl> <nl> - On 8 . 04 and older versions , libmms is outdated and thus XBMC will not compile properly . <nl> - In this case you will have to manually compile the latest version . See the previous [ NOTICE ] . <nl> - # wget " http : / / launchpad . net / libmms / trunk / 0 . 5 / + download / libmms - 0 . 5 . tar . gz " <nl> - # tar zxvf libmms - 0 . 5 . tar . gz <nl> - # cd libmms - 0 . 5 <nl> - # . / configure - - prefix = / usr <nl> - # make <nl> - # sudo make install <nl> - <nl> mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> 3 . 2 . Use a single command to get all build dependencies <nl> mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> mmm a / configure . in <nl> ppp b / configure . in <nl> PKG_CHECK_MODULES ( [ CDIO ] , [ libcdio ] , <nl> PKG_CHECK_MODULES ( [ SAMPLERATE ] , [ samplerate ] , <nl> [ INCLUDES = " $ INCLUDES $ SAMPLERATE_CFLAGS " ; LIBS = " $ LIBS $ SAMPLERATE_LIBS " ] , <nl> AC_MSG_ERROR ( $ missing_library ) ) <nl> - PKG_CHECK_MODULES ( [ MMS ] , [ libmms ] , <nl> - [ INCLUDES = " $ INCLUDES $ MMS_CFLAGS " ; LIBS = " $ LIBS $ MMS_LIBS " ] , <nl> - AC_MSG_ERROR ( $ missing_library ) ) <nl> PKG_CHECK_MODULES ( [ FREETYPE2 ] , [ freetype2 ] , <nl> [ INCLUDES = " $ INCLUDES $ FREETYPE2_CFLAGS " ; LIBS = " $ LIBS $ FREETYPE2_LIBS " ] , <nl> AC_MSG_ERROR ( $ missing_library ) ) <nl> mmm a / xbmc / cores / dvdplayer / DVDInputStreams / DVDFactoryInputStream . cpp <nl> ppp b / xbmc / cores / dvdplayer / DVDInputStreams / DVDFactoryInputStream . cpp <nl> <nl> # ifdef ENABLE_DVDINPUTSTREAM_STACK <nl> # include " DVDInputStreamStack . h " <nl> # endif <nl> - # ifdef HAS_FILESYSTEM_MMS <nl> - # include " DVDInputStreamMMS . h " <nl> - # endif <nl> # include " FileItem . h " <nl> # include " storage / MediaManager . h " <nl> <nl> CDVDInputStream * CDVDFactoryInputStream : : CreateInputStream ( IDVDPlayer * pPlayer , <nl> else if ( file . substr ( 0 , 7 ) = = " htsp : / / " ) <nl> return new CDVDInputStreamHTSP ( ) ; <nl> # endif <nl> - # ifdef HAS_FILESYSTEM_MMS <nl> - else if ( file . substr ( 0 , 6 ) = = " mms : / / " | | file . substr ( 0 , 7 ) = = " mmsh : / / " ) <nl> - return new CDVDInputStreamMMS ( ) ; <nl> - # endif <nl> <nl> / / our file interface handles all these types of streams <nl> return ( new CDVDInputStreamFile ( ) ) ; <nl> deleted file mode 100644 <nl> index b33636597cb5 . . 000000000000 <nl> mmm a / xbmc / cores / dvdplayer / DVDInputStreams / DVDInputStreamMMS . cpp <nl> ppp / dev / null <nl> <nl> - / * <nl> - * Copyright ( C ) 2005 - 2008 Team XBMC <nl> - * http : / / www . xbmc . org <nl> - * <nl> - * This Program is free software ; you can redistribute it and / or modify <nl> - * it under the terms of the GNU General Public License as published by <nl> - * the Free Software Foundation ; either version 2 , or ( at your option ) <nl> - * any later version . <nl> - * <nl> - * This Program is distributed in the hope that it will be useful , <nl> - * but WITHOUT ANY WARRANTY ; without even the implied warranty of <nl> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the <nl> - * GNU General Public License for more details . <nl> - * <nl> - * You should have received a copy of the GNU General Public License <nl> - * along with XBMC ; see the file COPYING . If not , write to <nl> - * the Free Software Foundation , 675 Mass Ave , Cambridge , MA 02139 , USA . <nl> - * http : / / www . gnu . org / copyleft / gpl . html <nl> - * <nl> - * / <nl> - <nl> - # include " system . h " <nl> - <nl> - # ifdef HAS_FILESYSTEM_MMS <nl> - <nl> - # include " FileItem . h " <nl> - # include " DVDInputStreamMMS . h " <nl> - # include " filesystem / IFile . h " <nl> - # include " settings / GUISettings . h " <nl> - <nl> - # ifndef _WIN32 <nl> - / / work around for braindead usage of " this " keyword as parameter name in libmms headers <nl> - / / some distros have already patched this but upstream @ https : / / launchpad . net / libmms <nl> - / / does still has the " this " usage . <nl> - # define this instance <nl> - # undef byte <nl> - # include < libmms / mmsio . h > / / FIXME : remove this header once the ubuntu headers is fixed ( variable named this ) <nl> - # include < libmms / mms . h > <nl> - # include < libmms / mmsh . h > <nl> - # include < libmms / mmsx . h > <nl> - # undef this <nl> - # else <nl> - # include " win32 / libmms_win32 / src / mmsx . h " <nl> - # endif <nl> - <nl> - using namespace XFILE ; <nl> - <nl> - CDVDInputStreamMMS : : CDVDInputStreamMMS ( ) : CDVDInputStream ( DVDSTREAM_TYPE_MMS ) <nl> - { <nl> - m_mms = NULL ; <nl> - } <nl> - <nl> - CDVDInputStreamMMS : : ~ CDVDInputStreamMMS ( ) <nl> - { <nl> - Close ( ) ; <nl> - } <nl> - <nl> - bool CDVDInputStreamMMS : : IsEOF ( ) <nl> - { <nl> - return false ; <nl> - } <nl> - <nl> - # ifndef _WIN32 <nl> - struct mmsx_s { <nl> - mms_t * connection ; <nl> - mmsh_t * connection_h ; <nl> - } ; <nl> - # endif <nl> - <nl> - bool CDVDInputStreamMMS : : Open ( const char * strFile , const std : : string & content ) <nl> - { <nl> - int bandwidth = g_guiSettings . GetInt ( " network . bandwidth " ) * 1024 ; <nl> - if ( bandwidth = = 0 ) <nl> - bandwidth = 2000 * 1000 ; <nl> - <nl> - / / TODO : remove this code if upstream accepts my patch <nl> - / / tracked at https : / / bugs . launchpad . net / libmms / + bug / 512089 <nl> - / / also see the struct definition further up ( needed due to opaqueness ) <nl> - # ifndef _WIN32 <nl> - m_mms = ( mmsx_t * ) calloc ( 1 , sizeof ( mmsx_t ) ) ; <nl> - <nl> - if ( ! m_mms ) <nl> - return false ; <nl> - <nl> - m_mms - > connection_h = mmsh_connect ( ( mms_io_t * ) mms_get_default_io_impl ( ) , <nl> - NULL , strFile , bandwidth ) ; <nl> - if ( m_mms - > connection_h ) <nl> - return true ; <nl> - <nl> - m_mms - > connection = mms_connect ( ( mms_io_t * ) mms_get_default_io_impl ( ) , <nl> - NULL , strFile , bandwidth ) ; <nl> - if ( m_mms - > connection ) <nl> - return true ; <nl> - <nl> - free ( m_mms ) ; <nl> - m_mms = NULL ; <nl> - return false ; <nl> - # else <nl> - m_mms = mmsx_connect ( ( mms_io_t * ) mms_get_default_io_impl ( ) , NULL , strFile , bandwidth ) ; / / TODO : what to do with bandwidth ? <nl> - return ( m_mms ! = NULL ) ; <nl> - # endif <nl> - } <nl> - <nl> - / / close file and reset everyting <nl> - void CDVDInputStreamMMS : : Close ( ) <nl> - { <nl> - CDVDInputStream : : Close ( ) ; <nl> - if ( m_mms ) <nl> - mmsx_close ( m_mms ) ; <nl> - } <nl> - <nl> - int CDVDInputStreamMMS : : Read ( BYTE * buf , int buf_size ) <nl> - { <nl> - return mmsx_read ( ( mms_io_t * ) mms_get_default_io_impl ( ) , m_mms , ( char * ) buf , buf_size ) ; <nl> - } <nl> - <nl> - __int64 CDVDInputStreamMMS : : Seek ( __int64 offset , int whence ) <nl> - { <nl> - if ( whence = = SEEK_POSSIBLE ) <nl> - return 0 ; <nl> - else <nl> - return - 1 ; / / TODO : implement offset based seeks <nl> - } <nl> - <nl> - bool CDVDInputStreamMMS : : SeekTime ( int iTimeInMsec ) <nl> - { <nl> - if ( mmsx_get_seekable ( m_mms ) ) <nl> - return ( mmsx_time_seek ( NULL , m_mms , double ( iTimeInMsec ) / 1000 ) ! = - 1 ) ; <nl> - <nl> - return false ; <nl> - } <nl> - <nl> - __int64 CDVDInputStreamMMS : : GetLength ( ) <nl> - { <nl> - return ( __int64 ) mmsx_get_time_length ( m_mms ) ; <nl> - } <nl> - <nl> - bool CDVDInputStreamMMS : : NextStream ( ) <nl> - { <nl> - return false ; <nl> - } <nl> - <nl> - # endif <nl> deleted file mode 100644 <nl> index 8a90e277835f . . 000000000000 <nl> mmm a / xbmc / cores / dvdplayer / DVDInputStreams / DVDInputStreamMMS . h <nl> ppp / dev / null <nl> <nl> - # pragma once <nl> - / * <nl> - * Copyright ( C ) 2005 - 2008 Team XBMC <nl> - * http : / / www . xbmc . org <nl> - * <nl> - * This Program is free software ; you can redistribute it and / or modify <nl> - * it under the terms of the GNU General Public License as published by <nl> - * the Free Software Foundation ; either version 2 , or ( at your option ) <nl> - * any later version . <nl> - * <nl> - * This Program is distributed in the hope that it will be useful , <nl> - * but WITHOUT ANY WARRANTY ; without even the implied warranty of <nl> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the <nl> - * GNU General Public License for more details . <nl> - * <nl> - * You should have received a copy of the GNU General Public License <nl> - * along with XBMC ; see the file COPYING . If not , write to <nl> - * the Free Software Foundation , 675 Mass Ave , Cambridge , MA 02139 , USA . <nl> - * http : / / www . gnu . org / copyleft / gpl . html <nl> - * <nl> - * / <nl> - <nl> - # include " system . h " <nl> - <nl> - # ifdef HAS_FILESYSTEM_MMS <nl> - <nl> - # include " DVDInputStream . h " <nl> - <nl> - / / forward declare this so we avoid including mmsx . h <nl> - typedef struct mmsx_s mmsx_t ; <nl> - <nl> - class CDVDInputStreamMMS <nl> - : public CDVDInputStream <nl> - , public CDVDInputStream : : ISeekTime <nl> - { <nl> - public : <nl> - CDVDInputStreamMMS ( ) ; <nl> - virtual ~ CDVDInputStreamMMS ( ) ; <nl> - virtual bool Open ( const char * strFile , const std : : string & content ) ; <nl> - virtual bool Pause ( double ) { return true ; } <nl> - virtual void Close ( ) ; <nl> - virtual int Read ( BYTE * buf , int buf_size ) ; <nl> - virtual __int64 Seek ( __int64 offset , int whence ) ; <nl> - bool SeekTime ( int iTimeInMsec ) ; <nl> - virtual bool IsEOF ( ) ; <nl> - virtual __int64 GetLength ( ) ; <nl> - virtual bool NextStream ( ) ; <nl> - protected : <nl> - mmsx_t * m_mms ; <nl> - } ; <nl> - <nl> - # endif <nl> mmm a / xbmc / cores / dvdplayer / DVDInputStreams / Makefile <nl> ppp b / xbmc / cores / dvdplayer / DVDInputStreams / Makefile <nl> SRCS = DVDFactoryInputStream . cpp \ <nl> DVDInputStreamHTSP . cpp \ <nl> DVDInputStreamHttp . cpp \ <nl> DVDInputStreamMemory . cpp \ <nl> - DVDInputStreamMMS . cpp \ <nl> DVDInputStreamNavigator . cpp \ <nl> DVDInputStreamRTMP . cpp \ <nl> DVDInputStreamStack . cpp \ <nl> mmm a / xbmc / system . h <nl> ppp b / xbmc / system . h <nl> <nl> # define HAS_FILESYSTEM_SAP <nl> # define HAS_FILESYSTEM_VTP <nl> # define HAS_FILESYSTEM_HTSP <nl> - # define HAS_FILESYSTEM_MMS <nl> <nl> / * * * * * * * * * * * * * * * * * * * * * * <nl> * Non - free Components <nl>
|
changed : remove libmms support
|
xbmc/xbmc
|
7a23480b5758f74a896f9c00fbd9c846d1c8a65e
|
2011-02-06T21:57:01Z
|
mmm a / tools / run_tests / generated / tests . json <nl> ppp b / tools / run_tests / generated / tests . json <nl> <nl> " language " : " c " , <nl> " name " : " hpack_parser_fuzzer_test_one_entry " , <nl> " platforms " : [ <nl> + " mac " , <nl> " linux " <nl> ] , <nl> " uses_polling " : false <nl>
|
Ran generate_projects . sh .
|
grpc/grpc
|
f7c2cd274efc143549028b40e2b6e6be8d260b76
|
2017-03-21T20:10:20Z
|
mmm a / tensorflow / contrib / distributions / BUILD <nl> ppp b / tensorflow / contrib / distributions / BUILD <nl> cuda_py_tests ( <nl> ] , <nl> ) <nl> <nl> + cuda_py_tests ( <nl> + name = " transformed_distribution_test " , <nl> + size = " small " , <nl> + srcs = [ " python / kernel_tests / transformed_distribution_test . py " ] , <nl> + additional_deps = [ <nl> + " : distributions_py " , <nl> + " / / tensorflow / python : platform_test " , <nl> + ] , <nl> + ) <nl> + <nl> filegroup ( <nl> name = " all_files " , <nl> srcs = glob ( <nl> mmm a / tensorflow / contrib / distributions / __init__ . py <nl> ppp b / tensorflow / contrib / distributions / __init__ . py <nl> <nl> <nl> @ @ DirichletMultinomial <nl> <nl> + # # # Transformed distributions <nl> + <nl> + @ @ ContinuousTransformedDistribution <nl> + <nl> # # Operators allowing for matrix - free methods <nl> <nl> # # # Positive definite operators <nl> <nl> from tensorflow . contrib . distributions . python . ops . operator_pd_cholesky import * <nl> from tensorflow . contrib . distributions . python . ops . operator_pd_full import * <nl> from tensorflow . contrib . distributions . python . ops . student_t import * <nl> + from tensorflow . contrib . distributions . python . ops . transformed_distribution import * <nl> from tensorflow . contrib . distributions . python . ops . uniform import * <nl> new file mode 100644 <nl> index 0000000000000 . . d78f4a9216168 <nl> mmm / dev / null <nl> ppp b / tensorflow / contrib / distributions / python / kernel_tests / transformed_distribution_test . py <nl> <nl> + # Copyright 2015 The TensorFlow Authors . All Rights Reserved . <nl> + # <nl> + # Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + # you may not use this file except in compliance with the License . <nl> + # You may obtain a copy of the License at <nl> + # <nl> + # http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + # <nl> + # Unless required by applicable law or agreed to in writing , software <nl> + # distributed under the License is distributed on an " AS IS " BASIS , <nl> + # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + # See the License for the specific language governing permissions and <nl> + # limitations under the License . <nl> + # = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> + " " " Tests for ContinuousTransformedDistribution . " " " <nl> + <nl> + from __future__ import absolute_import <nl> + from __future__ import division <nl> + from __future__ import print_function <nl> + <nl> + import numpy as np <nl> + from scipy import stats <nl> + import tensorflow as tf <nl> + <nl> + <nl> + class ContinuousTransformedDistributionTest ( tf . test . TestCase ) : <nl> + <nl> + def testContinuousTransformedDistribution ( self ) : <nl> + with self . test_session ( ) : <nl> + mu = 3 . 0 <nl> + sigma = 0 . 02 <nl> + log_normal = tf . contrib . distributions . ContinuousTransformedDistribution ( <nl> + base_dist_cls = tf . contrib . distributions . Normal , <nl> + mu = mu , <nl> + sigma = sigma , <nl> + transform = lambda x : tf . exp ( x ) , <nl> + inverse = lambda y : tf . log ( y ) , <nl> + log_det_jacobian = ( lambda x : tf . reduce_sum ( x ) ) ) <nl> + <nl> + # sample <nl> + self . assertAllClose ( [ stats . lognorm . mean ( s = sigma , scale = np . exp ( mu ) ) ] , <nl> + [ np . mean ( log_normal . sample ( 100000 , seed = 235 ) . eval ( ) ) ] , <nl> + atol = 1e - 2 ) <nl> + <nl> + # pdf , log_pdf <nl> + test_vals = np . linspace ( 0 . 00001 , 10 . ) . astype ( np . float32 ) <nl> + for test_val in test_vals : <nl> + expected = stats . lognorm . logpdf ( test_val , s = sigma , scale = np . exp ( mu ) ) <nl> + self . assertAllClose ( [ expected ] , [ log_normal . log_pdf ( test_val ) . eval ( ) ] ) <nl> + self . assertAllClose ( [ np . exp ( expected ) ] , <nl> + [ log_normal . pdf ( test_val ) . eval ( ) ] ) <nl> + <nl> + def testCachedSamplesWithoutInverse ( self ) : <nl> + with self . test_session ( ) as sess : <nl> + mu = 3 . 0 <nl> + sigma = 0 . 02 <nl> + log_normal = tf . contrib . distributions . ContinuousTransformedDistribution ( <nl> + base_dist_cls = tf . contrib . distributions . Normal , <nl> + mu = mu , <nl> + sigma = sigma , <nl> + transform = lambda x : tf . exp ( x ) , <nl> + inverse = None , <nl> + log_det_jacobian = ( lambda x : tf . reduce_sum ( x ) ) ) <nl> + <nl> + sample = log_normal . sample ( 1 ) <nl> + sample_val , log_pdf_val = sess . run ( [ sample , log_normal . log_pdf ( sample ) ] ) <nl> + self . assertAllClose ( <nl> + stats . lognorm . logpdf ( sample_val , s = sigma , <nl> + scale = np . exp ( mu ) ) , <nl> + log_pdf_val , <nl> + atol = 1e - 2 ) <nl> + <nl> + with self . assertRaisesRegexp ( ValueError , <nl> + " was not returned from ` sample ` " ) : <nl> + log_normal . log_pdf ( tf . constant ( 3 . 0 ) ) <nl> + <nl> + <nl> + if __name__ = = " __main__ " : <nl> + tf . test . main ( ) <nl> new file mode 100644 <nl> index 0000000000000 . . 8899d7a59f7a9 <nl> mmm / dev / null <nl> ppp b / tensorflow / contrib / distributions / python / ops / transformed_distribution . py <nl> <nl> + # Copyright 2016 The TensorFlow Authors . All Rights Reserved . <nl> + # <nl> + # Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + # you may not use this file except in compliance with the License . <nl> + # You may obtain a copy of the License at <nl> + # <nl> + # http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + # <nl> + # Unless required by applicable law or agreed to in writing , software <nl> + # distributed under the License is distributed on an " AS IS " BASIS , <nl> + # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + # See the License for the specific language governing permissions and <nl> + # limitations under the License . <nl> + # = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> + " " " A Transformed Distribution class . " " " <nl> + from __future__ import absolute_import <nl> + from __future__ import division <nl> + from __future__ import print_function <nl> + <nl> + from tensorflow . contrib . distributions . python . ops import distribution # pylint : disable = line - too - long <nl> + from tensorflow . python . framework import ops <nl> + <nl> + <nl> + class ContinuousTransformedDistribution ( distribution . ContinuousDistribution ) : <nl> + " " " A Transformed Distribution . <nl> + <nl> + A Transformed Distribution models ` p ( y ) ` given a base distribution ` p ( x ) ` , <nl> + an invertible transform , ` y = f ( x ) ` , and the determinant of the Jacobian of <nl> + ` f ( x ) ` . <nl> + <nl> + Shapes , type , and reparameterization are taken from the base distribution . <nl> + <nl> + # # # # Mathematical details <nl> + <nl> + * ` p ( x ) ` - probability distribution for random variable X <nl> + * ` p ( y ) ` - probability distribution for random variable Y <nl> + * ` f ` - transform <nl> + * ` g ` - inverse transform , ` f ( g ( x ) ) = x ` <nl> + * ` J ( x ) ` - Jacobian of f ( x ) <nl> + <nl> + A Transformed Distribution exposes ` sample ` and ` pdf ` : <nl> + <nl> + * ` sample ` : ` y = f ( x ) ` , after drawing a sample of X . <nl> + * ` pdf ` : ` p ( y ) = p ( x ) / det | J ( x ) | = p ( g ( y ) ) / det | J ( g ( y ) ) | ` <nl> + <nl> + A simple example constructing a Log - Normal distribution from a Normal <nl> + distribution : <nl> + <nl> + ` ` ` <nl> + logit_normal = ContinuousTransformedDistribution ( <nl> + base_dist = Normal ( mu , sigma ) , <nl> + transform = lambda x : tf . sigmoid ( x ) , <nl> + inverse = lambda y : tf . log ( y ) - tf . log ( 1 . - y ) , <nl> + log_det_jacobian = ( lambda x : <nl> + tf . reduce_sum ( tf . log ( tf . sigmoid ( x ) ) + tf . log ( 1 . - tf . sigmoid ( x ) ) , <nl> + reduction_indices = [ - 1 ] ) ) ) <nl> + name = " LogitNormalTransformedDistribution " <nl> + ) <nl> + ` ` ` <nl> + " " " <nl> + <nl> + def __init__ ( self , <nl> + base_dist_cls , <nl> + transform , <nl> + inverse , <nl> + log_det_jacobian , <nl> + name = " ContinuousTransformedDistribution " , <nl> + * * base_dist_args ) : <nl> + " " " Construct a Transformed Distribution . <nl> + <nl> + Args : <nl> + base_dist_cls : the base distribution class to transform . Must be a <nl> + subclass of ` ContinuousDistribution ` . <nl> + transform : a callable that takes a ` Tensor ` sample from ` base_dist ` and <nl> + returns a ` Tensor ` of the same shape and type . ` x = > y ` . <nl> + inverse : a callable that computes the inverse of transform . ` y = > x ` . If <nl> + None , users can only call ` log_pdf ` on values returned by ` sample ` . <nl> + log_det_jacobian : a callable that takes a ` Tensor ` sample from ` base_dist ` <nl> + and returns the log of the determinant of the Jacobian of ` transform ` . <nl> + name : The name for the distribution . <nl> + * * base_dist_args : kwargs to pass on to dist_cls on construction . <nl> + <nl> + Raises : <nl> + TypeError : if ` base_dist_cls ` is not a subclass of <nl> + ` ContinuousDistribution ` . <nl> + " " " <nl> + if not issubclass ( base_dist_cls , distribution . ContinuousDistribution ) : <nl> + raise TypeError ( " base_dist_cls must be a subclass of " <nl> + " ContinuousDistribution . " ) <nl> + with ops . op_scope ( base_dist_args . values ( ) , name ) as scope : <nl> + self . _name = scope <nl> + self . _base_dist = base_dist_cls ( * * base_dist_args ) <nl> + self . _transform = transform <nl> + self . _inverse = inverse <nl> + self . _log_det_jacobian = log_det_jacobian <nl> + self . _inverse_cache = { } <nl> + <nl> + @ property <nl> + def name ( self ) : <nl> + return self . _name <nl> + <nl> + @ property <nl> + def dtype ( self ) : <nl> + return self . _base_dist . dtype <nl> + <nl> + def batch_shape ( self , name = " batch_shape " ) : <nl> + " " " Batch dimensions of this instance as a 1 - D int32 ` Tensor ` . <nl> + <nl> + The product of the dimensions of the ` batch_shape ` is the number of <nl> + independent distributions of this kind the instance represents . <nl> + <nl> + Args : <nl> + name : name to give to the op . <nl> + <nl> + Returns : <nl> + ` Tensor ` ` batch_shape ` <nl> + " " " <nl> + with ops . name_scope ( self . name ) : <nl> + return self . _base_dist . batch_shape ( name ) <nl> + <nl> + def get_batch_shape ( self ) : <nl> + " " " ` TensorShape ` available at graph construction time . <nl> + <nl> + Same meaning as ` batch_shape ` . May be only partially defined . <nl> + <nl> + Returns : <nl> + batch shape <nl> + " " " <nl> + return self . _base_dist . get_batch_shape ( ) <nl> + <nl> + def event_shape ( self , name = " event_shape " ) : <nl> + " " " Shape of a sample from a single distribution as a 1 - D int32 ` Tensor ` . <nl> + <nl> + Args : <nl> + name : name to give to the op . <nl> + <nl> + Returns : <nl> + ` Tensor ` ` event_shape ` <nl> + " " " <nl> + with ops . name_scope ( self . name ) : <nl> + return self . _base_dist . event_shape ( name ) <nl> + <nl> + def get_event_shape ( self ) : <nl> + " " " ` TensorShape ` available at graph construction time . <nl> + <nl> + Same meaning as ` event_shape ` . May be only partially defined . <nl> + <nl> + Returns : <nl> + event shape <nl> + " " " <nl> + return self . _base_dist . get_event_shape ( ) <nl> + <nl> + @ property <nl> + def base_distribution ( self ) : <nl> + " " " Base distribution , p ( x ) . " " " <nl> + return self . _base_dist <nl> + <nl> + @ property <nl> + def transform ( self ) : <nl> + " " " Function transforming x = > y . " " " <nl> + return self . _transform <nl> + <nl> + @ property <nl> + def inverse ( self ) : <nl> + " " " Inverse function of transform , y = > x . " " " <nl> + return self . _inverse <nl> + <nl> + @ property <nl> + def log_det_jacobian ( self ) : <nl> + " " " Function computing the log determinant of the Jacobian of transform . " " " <nl> + return self . _log_det_jacobian <nl> + <nl> + def log_pdf ( self , y , name = " log_pdf " ) : <nl> + " " " Log pdf of observations in ` y ` . <nl> + <nl> + ` log ( p ( g ( y ) ) / det | J ( g ( y ) ) | ) ` , where ` g ` is the inverse of ` transform ` . <nl> + <nl> + Args : <nl> + y : tensor of dtype ` dtype ` . <nl> + name : The name to give this op . <nl> + <nl> + Returns : <nl> + log_pdf : tensor of dtype ` dtype ` , the log - PDFs of ` y ` . <nl> + <nl> + Raises : <nl> + ValueError : if ` inverse ` was not provided to the distribution and ` y ` was <nl> + not returned from ` sample ` . <nl> + " " " <nl> + with ops . name_scope ( self . name ) : <nl> + with ops . op_scope ( [ y ] , name ) : <nl> + y = ops . convert_to_tensor ( y ) <nl> + if y . dtype ! = self . dtype : <nl> + raise TypeError ( " Input x dtype does not match dtype : % s vs . % s " % <nl> + ( y . dtype , self . dtype ) ) <nl> + with ops . name_scope ( " inverse " ) : <nl> + if y in self . _inverse_cache : <nl> + x = self . _inverse_cache [ y ] <nl> + elif self . _inverse : <nl> + x = self . _inverse ( y ) <nl> + else : <nl> + raise ValueError ( " No inverse function exists and input ` y ` was not " <nl> + " returned from ` sample ` . " ) <nl> + with ops . name_scope ( " log_det_jacobian " ) : <nl> + log_det_jacobian = self . _log_det_jacobian ( x ) <nl> + return self . _base_dist . log_likelihood ( x ) - log_det_jacobian <nl> + <nl> + def pdf ( self , y , name = " pdf " ) : <nl> + " " " The PDF of observations in ` y ` . <nl> + <nl> + ` p ( g ( y ) ) / det | J ( g ( y ) ) | ` , where ` g ` is the inverse of ` transform ` . <nl> + <nl> + Args : <nl> + y : ` Tensor ` of dtype ` dtype ` . <nl> + name : The name to give this op . <nl> + <nl> + Returns : <nl> + pdf : ` Tensor ` of dtype ` dtype ` , the pdf values of ` y ` . <nl> + " " " <nl> + return super ( ContinuousTransformedDistribution , self ) . pdf ( y , name = name ) <nl> + <nl> + def sample ( self , n , seed = None , name = " sample " ) : <nl> + " " " Sample ` n ` observations . <nl> + <nl> + Samples from the base distribution and then passes through the transform . <nl> + <nl> + Args : <nl> + n : scalar , type int32 , the number of observations to sample . <nl> + seed : Python integer , the random seed . <nl> + name : The name to give this op . <nl> + <nl> + Returns : <nl> + samples : ` [ n , . . . ] ` , a ` Tensor ` of ` n ` samples . <nl> + " " " <nl> + with ops . name_scope ( self . name ) : <nl> + with ops . name_scope ( name ) : <nl> + samples = self . _base_dist . sample ( n = n , seed = seed ) <nl> + with ops . name_scope ( " transform " ) : <nl> + transformed = self . _transform ( samples ) <nl> + self . _inverse_cache [ transformed ] = samples <nl> + return transformed <nl> + <nl> + @ property <nl> + def is_reparameterized ( self ) : <nl> + return self . _base_dist . is_reparameterized <nl> + <nl> + @ property <nl> + def strict_statistics ( self ) : <nl> + return self . _base_dist . strict_statistics <nl> + <nl> + @ property <nl> + def strict ( self ) : <nl> + return self . _base_dist . strict <nl>
|
Transformed Distribution
|
tensorflow/tensorflow
|
e2587a04769af616cd8a50133792071685cedd5d
|
2016-07-01T00:18:21Z
|
mmm a / cocos2dx / platform / third_party / win32 / OGLES / EGL / eglplatform . h <nl> ppp b / cocos2dx / platform / third_party / win32 / OGLES / EGL / eglplatform . h <nl> typedef Pixmap EGLNativePixmapType ; <nl> typedef Window EGLNativeWindowType ; <nl> <nl> <nl> - # elif defined ( __ANDROID__ ) | | defined ( ANDROID ) <nl> - <nl> - # include < android / native_window . h > <nl> + # elif defined ( ANDROID ) <nl> <nl> + struct android_native_window_t ; <nl> struct egl_native_pixmap_t ; <nl> <nl> - typedef struct ANativeWindow * EGLNativeWindowType ; <nl> + typedef struct android_native_window_t * EGLNativeWindowType ; <nl> typedef struct egl_native_pixmap_t * EGLNativePixmapType ; <nl> typedef void * EGLNativeDisplayType ; <nl> <nl> typedef EGLNativeWindowType NativeWindowType ; <nl> * handles are 64 bit types , then EGLint should be defined as a signed 64 - bit <nl> * integer type . <nl> * / <nl> - # if defined ( _WIN64 ) | | __WORDSIZE = = 64 <nl> + # if defined ( _WIN64 ) | | __WORDSIZE = = 64 <nl> typedef khronos_int64_t EGLint ; <nl> # else <nl> typedef khronos_int32_t EGLint ; <nl> mmm a / cocos2dx / platform / third_party / win32 / OGLES / GLES2 / gl2 . h <nl> ppp b / cocos2dx / platform / third_party / win32 / OGLES / GLES2 / gl2 . h <nl> <nl> - # ifndef __gl2_h_ <nl> - # define __gl2_h_ <nl> - <nl> - # include < GLES2 / gl2platform . h > <nl> - <nl> - # ifdef __cplusplus <nl> - extern " C " { <nl> - # endif <nl> - <nl> - / * <nl> - * This document is licensed under the SGI Free Software B License Version <nl> - * 2 . 0 . For details , see http : / / oss . sgi . com / projects / FreeB / . <nl> - * / <nl> - <nl> - / * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> - * Data type definitions <nl> - * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - * / <nl> - <nl> - typedef void GLvoid ; <nl> - typedef char GLchar ; <nl> - typedef unsigned int GLenum ; <nl> - typedef unsigned char GLboolean ; <nl> - typedef unsigned int GLbitfield ; <nl> - typedef khronos_int8_t GLbyte ; <nl> - typedef short GLshort ; <nl> - typedef int GLint ; <nl> - typedef int GLsizei ; <nl> - typedef khronos_uint8_t GLubyte ; <nl> - typedef unsigned short GLushort ; <nl> - typedef unsigned int GLuint ; <nl> - typedef khronos_float_t GLfloat ; <nl> - typedef khronos_float_t GLclampf ; <nl> - typedef khronos_int32_t GLfixed ; <nl> - <nl> - / * GL types for handling large vertex buffer objects * / <nl> - typedef khronos_intptr_t GLintptr ; <nl> - typedef khronos_ssize_t GLsizeiptr ; <nl> - <nl> - / * OpenGL ES core versions * / <nl> - # define GL_ES_VERSION_2_0 1 <nl> - <nl> - / * ClearBufferMask * / <nl> - # define GL_DEPTH_BUFFER_BIT 0x00000100 <nl> - # define GL_STENCIL_BUFFER_BIT 0x00000400 <nl> - # define GL_COLOR_BUFFER_BIT 0x00004000 <nl> - <nl> - / * Boolean * / <nl> - # define GL_FALSE 0 <nl> - # define GL_TRUE 1 <nl> - <nl> - / * BeginMode * / <nl> - # define GL_POINTS 0x0000 <nl> - # define GL_LINES 0x0001 <nl> - # define GL_LINE_LOOP 0x0002 <nl> - # define GL_LINE_STRIP 0x0003 <nl> - # define GL_TRIANGLES 0x0004 <nl> - # define GL_TRIANGLE_STRIP 0x0005 <nl> - # define GL_TRIANGLE_FAN 0x0006 <nl> - <nl> - / * AlphaFunction ( not supported in ES20 ) * / <nl> - / * GL_NEVER * / <nl> - / * GL_LESS * / <nl> - / * GL_EQUAL * / <nl> - / * GL_LEQUAL * / <nl> - / * GL_GREATER * / <nl> - / * GL_NOTEQUAL * / <nl> - / * GL_GEQUAL * / <nl> - / * GL_ALWAYS * / <nl> - <nl> - / * BlendingFactorDest * / <nl> - # define GL_ZERO 0 <nl> - # define GL_ONE 1 <nl> - # define GL_SRC_COLOR 0x0300 <nl> - # define GL_ONE_MINUS_SRC_COLOR 0x0301 <nl> - # define GL_SRC_ALPHA 0x0302 <nl> - # define GL_ONE_MINUS_SRC_ALPHA 0x0303 <nl> - # define GL_DST_ALPHA 0x0304 <nl> - # define GL_ONE_MINUS_DST_ALPHA 0x0305 <nl> - <nl> - / * BlendingFactorSrc * / <nl> - / * GL_ZERO * / <nl> - / * GL_ONE * / <nl> - # define GL_DST_COLOR 0x0306 <nl> - # define GL_ONE_MINUS_DST_COLOR 0x0307 <nl> - # define GL_SRC_ALPHA_SATURATE 0x0308 <nl> - / * GL_SRC_ALPHA * / <nl> - / * GL_ONE_MINUS_SRC_ALPHA * / <nl> - / * GL_DST_ALPHA * / <nl> - / * GL_ONE_MINUS_DST_ALPHA * / <nl> - <nl> - / * BlendEquationSeparate * / <nl> - # define GL_FUNC_ADD 0x8006 <nl> - # define GL_BLEND_EQUATION 0x8009 <nl> - # define GL_BLEND_EQUATION_RGB 0x8009 / * same as BLEND_EQUATION * / <nl> - # define GL_BLEND_EQUATION_ALPHA 0x883D <nl> - <nl> - / * BlendSubtract * / <nl> - # define GL_FUNC_SUBTRACT 0x800A <nl> - # define GL_FUNC_REVERSE_SUBTRACT 0x800B <nl> - <nl> - / * Separate Blend Functions * / <nl> - # define GL_BLEND_DST_RGB 0x80C8 <nl> - # define GL_BLEND_SRC_RGB 0x80C9 <nl> - # define GL_BLEND_DST_ALPHA 0x80CA <nl> - # define GL_BLEND_SRC_ALPHA 0x80CB <nl> - # define GL_CONSTANT_COLOR 0x8001 <nl> - # define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 <nl> - # define GL_CONSTANT_ALPHA 0x8003 <nl> - # define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 <nl> - # define GL_BLEND_COLOR 0x8005 <nl> - <nl> - / * Buffer Objects * / <nl> - # define GL_ARRAY_BUFFER 0x8892 <nl> - # define GL_ELEMENT_ARRAY_BUFFER 0x8893 <nl> - # define GL_ARRAY_BUFFER_BINDING 0x8894 <nl> - # define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 <nl> - <nl> - # define GL_STREAM_DRAW 0x88E0 <nl> - # define GL_STATIC_DRAW 0x88E4 <nl> - # define GL_DYNAMIC_DRAW 0x88E8 <nl> - <nl> - # define GL_BUFFER_SIZE 0x8764 <nl> - # define GL_BUFFER_USAGE 0x8765 <nl> - <nl> - # define GL_CURRENT_VERTEX_ATTRIB 0x8626 <nl> - <nl> - / * CullFaceMode * / <nl> - # define GL_FRONT 0x0404 <nl> - # define GL_BACK 0x0405 <nl> - # define GL_FRONT_AND_BACK 0x0408 <nl> - <nl> - / * DepthFunction * / <nl> - / * GL_NEVER * / <nl> - / * GL_LESS * / <nl> - / * GL_EQUAL * / <nl> - / * GL_LEQUAL * / <nl> - / * GL_GREATER * / <nl> - / * GL_NOTEQUAL * / <nl> - / * GL_GEQUAL * / <nl> - / * GL_ALWAYS * / <nl> - <nl> - / * EnableCap * / <nl> - # define GL_TEXTURE_2D 0x0DE1 <nl> - # define GL_CULL_FACE 0x0B44 <nl> - # define GL_BLEND 0x0BE2 <nl> - # define GL_DITHER 0x0BD0 <nl> - # define GL_STENCIL_TEST 0x0B90 <nl> - # define GL_DEPTH_TEST 0x0B71 <nl> - # define GL_SCISSOR_TEST 0x0C11 <nl> - # define GL_POLYGON_OFFSET_FILL 0x8037 <nl> - # define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E <nl> - # define GL_SAMPLE_COVERAGE 0x80A0 <nl> - <nl> - / * ErrorCode * / <nl> - # define GL_NO_ERROR 0 <nl> - # define GL_INVALID_ENUM 0x0500 <nl> - # define GL_INVALID_VALUE 0x0501 <nl> - # define GL_INVALID_OPERATION 0x0502 <nl> - # define GL_OUT_OF_MEMORY 0x0505 <nl> - <nl> - / * FrontFaceDirection * / <nl> - # define GL_CW 0x0900 <nl> - # define GL_CCW 0x0901 <nl> - <nl> - / * GetPName * / <nl> - # define GL_LINE_WIDTH 0x0B21 <nl> - # define GL_ALIASED_POINT_SIZE_RANGE 0x846D <nl> - # define GL_ALIASED_LINE_WIDTH_RANGE 0x846E <nl> - # define GL_CULL_FACE_MODE 0x0B45 <nl> - # define GL_FRONT_FACE 0x0B46 <nl> - # define GL_DEPTH_RANGE 0x0B70 <nl> - # define GL_DEPTH_WRITEMASK 0x0B72 <nl> - # define GL_DEPTH_CLEAR_VALUE 0x0B73 <nl> - # define GL_DEPTH_FUNC 0x0B74 <nl> - # define GL_STENCIL_CLEAR_VALUE 0x0B91 <nl> - # define GL_STENCIL_FUNC 0x0B92 <nl> - # define GL_STENCIL_FAIL 0x0B94 <nl> - # define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95 <nl> - # define GL_STENCIL_PASS_DEPTH_PASS 0x0B96 <nl> - # define GL_STENCIL_REF 0x0B97 <nl> - # define GL_STENCIL_VALUE_MASK 0x0B93 <nl> - # define GL_STENCIL_WRITEMASK 0x0B98 <nl> - # define GL_STENCIL_BACK_FUNC 0x8800 <nl> - # define GL_STENCIL_BACK_FAIL 0x8801 <nl> - # define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 <nl> - # define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 <nl> - # define GL_STENCIL_BACK_REF 0x8CA3 <nl> - # define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 <nl> - # define GL_STENCIL_BACK_WRITEMASK 0x8CA5 <nl> - # define GL_VIEWPORT 0x0BA2 <nl> - # define GL_SCISSOR_BOX 0x0C10 <nl> - / * GL_SCISSOR_TEST * / <nl> - # define GL_COLOR_CLEAR_VALUE 0x0C22 <nl> - # define GL_COLOR_WRITEMASK 0x0C23 <nl> - # define GL_UNPACK_ALIGNMENT 0x0CF5 <nl> - # define GL_PACK_ALIGNMENT 0x0D05 <nl> - # define GL_MAX_TEXTURE_SIZE 0x0D33 <nl> - # define GL_MAX_VIEWPORT_DIMS 0x0D3A <nl> - # define GL_SUBPIXEL_BITS 0x0D50 <nl> - # define GL_RED_BITS 0x0D52 <nl> - # define GL_GREEN_BITS 0x0D53 <nl> - # define GL_BLUE_BITS 0x0D54 <nl> - # define GL_ALPHA_BITS 0x0D55 <nl> - # define GL_DEPTH_BITS 0x0D56 <nl> - # define GL_STENCIL_BITS 0x0D57 <nl> - # define GL_POLYGON_OFFSET_UNITS 0x2A00 <nl> - / * GL_POLYGON_OFFSET_FILL * / <nl> - # define GL_POLYGON_OFFSET_FACTOR 0x8038 <nl> - # define GL_TEXTURE_BINDING_2D 0x8069 <nl> - # define GL_SAMPLE_BUFFERS 0x80A8 <nl> - # define GL_SAMPLES 0x80A9 <nl> - # define GL_SAMPLE_COVERAGE_VALUE 0x80AA <nl> - # define GL_SAMPLE_COVERAGE_INVERT 0x80AB <nl> - <nl> - / * GetTextureParameter * / <nl> - / * GL_TEXTURE_MAG_FILTER * / <nl> - / * GL_TEXTURE_MIN_FILTER * / <nl> - / * GL_TEXTURE_WRAP_S * / <nl> - / * GL_TEXTURE_WRAP_T * / <nl> - <nl> - # define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 <nl> - # define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 <nl> - <nl> - / * HintMode * / <nl> - # define GL_DONT_CARE 0x1100 <nl> - # define GL_FASTEST 0x1101 <nl> - # define GL_NICEST 0x1102 <nl> - <nl> - / * HintTarget * / <nl> - # define GL_GENERATE_MIPMAP_HINT 0x8192 <nl> - <nl> - / * DataType * / <nl> - # define GL_BYTE 0x1400 <nl> - # define GL_UNSIGNED_BYTE 0x1401 <nl> - # define GL_SHORT 0x1402 <nl> - # define GL_UNSIGNED_SHORT 0x1403 <nl> - # define GL_INT 0x1404 <nl> - # define GL_UNSIGNED_INT 0x1405 <nl> - # define GL_FLOAT 0x1406 <nl> - # define GL_FIXED 0x140C <nl> - <nl> - / * PixelFormat * / <nl> - # define GL_DEPTH_COMPONENT 0x1902 <nl> - # define GL_ALPHA 0x1906 <nl> - # define GL_RGB 0x1907 <nl> - # define GL_RGBA 0x1908 <nl> - # define GL_LUMINANCE 0x1909 <nl> - # define GL_LUMINANCE_ALPHA 0x190A <nl> - <nl> - / * PixelType * / <nl> - / * GL_UNSIGNED_BYTE * / <nl> - # define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 <nl> - # define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 <nl> - # define GL_UNSIGNED_SHORT_5_6_5 0x8363 <nl> - <nl> - / * Shaders * / <nl> - # define GL_FRAGMENT_SHADER 0x8B30 <nl> - # define GL_VERTEX_SHADER 0x8B31 <nl> - # define GL_MAX_VERTEX_ATTRIBS 0x8869 <nl> - # define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB <nl> - # define GL_MAX_VARYING_VECTORS 0x8DFC <nl> - # define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D <nl> - # define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C <nl> - # define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 <nl> - # define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD <nl> - # define GL_SHADER_TYPE 0x8B4F <nl> - # define GL_DELETE_STATUS 0x8B80 <nl> - # define GL_LINK_STATUS 0x8B82 <nl> - # define GL_VALIDATE_STATUS 0x8B83 <nl> - # define GL_ATTACHED_SHADERS 0x8B85 <nl> - # define GL_ACTIVE_UNIFORMS 0x8B86 <nl> - # define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 <nl> - # define GL_ACTIVE_ATTRIBUTES 0x8B89 <nl> - # define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A <nl> - # define GL_SHADING_LANGUAGE_VERSION 0x8B8C <nl> - # define GL_CURRENT_PROGRAM 0x8B8D <nl> - <nl> - / * StencilFunction * / <nl> - # define GL_NEVER 0x0200 <nl> - # define GL_LESS 0x0201 <nl> - # define GL_EQUAL 0x0202 <nl> - # define GL_LEQUAL 0x0203 <nl> - # define GL_GREATER 0x0204 <nl> - # define GL_NOTEQUAL 0x0205 <nl> - # define GL_GEQUAL 0x0206 <nl> - # define GL_ALWAYS 0x0207 <nl> - <nl> - / * StencilOp * / <nl> - / * GL_ZERO * / <nl> - # define GL_KEEP 0x1E00 <nl> - # define GL_REPLACE 0x1E01 <nl> - # define GL_INCR 0x1E02 <nl> - # define GL_DECR 0x1E03 <nl> - # define GL_INVERT 0x150A <nl> - # define GL_INCR_WRAP 0x8507 <nl> - # define GL_DECR_WRAP 0x8508 <nl> - <nl> - / * StringName * / <nl> - # define GL_VENDOR 0x1F00 <nl> - # define GL_RENDERER 0x1F01 <nl> - # define GL_VERSION 0x1F02 <nl> - # define GL_EXTENSIONS 0x1F03 <nl> - <nl> - / * TextureMagFilter * / <nl> - # define GL_NEAREST 0x2600 <nl> - # define GL_LINEAR 0x2601 <nl> - <nl> - / * TextureMinFilter * / <nl> - / * GL_NEAREST * / <nl> - / * GL_LINEAR * / <nl> - # define GL_NEAREST_MIPMAP_NEAREST 0x2700 <nl> - # define GL_LINEAR_MIPMAP_NEAREST 0x2701 <nl> - # define GL_NEAREST_MIPMAP_LINEAR 0x2702 <nl> - # define GL_LINEAR_MIPMAP_LINEAR 0x2703 <nl> - <nl> - / * TextureParameterName * / <nl> - # define GL_TEXTURE_MAG_FILTER 0x2800 <nl> - # define GL_TEXTURE_MIN_FILTER 0x2801 <nl> - # define GL_TEXTURE_WRAP_S 0x2802 <nl> - # define GL_TEXTURE_WRAP_T 0x2803 <nl> - <nl> - / * TextureTarget * / <nl> - / * GL_TEXTURE_2D * / <nl> - # define GL_TEXTURE 0x1702 <nl> - <nl> - # define GL_TEXTURE_CUBE_MAP 0x8513 <nl> - # define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 <nl> - # define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 <nl> - # define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 <nl> - # define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 <nl> - # define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 <nl> - # define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 <nl> - # define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A <nl> - # define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C <nl> - <nl> - / * TextureUnit * / <nl> - # define GL_TEXTURE0 0x84C0 <nl> - # define GL_TEXTURE1 0x84C1 <nl> - # define GL_TEXTURE2 0x84C2 <nl> - # define GL_TEXTURE3 0x84C3 <nl> - # define GL_TEXTURE4 0x84C4 <nl> - # define GL_TEXTURE5 0x84C5 <nl> - # define GL_TEXTURE6 0x84C6 <nl> - # define GL_TEXTURE7 0x84C7 <nl> - # define GL_TEXTURE8 0x84C8 <nl> - # define GL_TEXTURE9 0x84C9 <nl> - # define GL_TEXTURE10 0x84CA <nl> - # define GL_TEXTURE11 0x84CB <nl> - # define GL_TEXTURE12 0x84CC <nl> - # define GL_TEXTURE13 0x84CD <nl> - # define GL_TEXTURE14 0x84CE <nl> - # define GL_TEXTURE15 0x84CF <nl> - # define GL_TEXTURE16 0x84D0 <nl> - # define GL_TEXTURE17 0x84D1 <nl> - # define GL_TEXTURE18 0x84D2 <nl> - # define GL_TEXTURE19 0x84D3 <nl> - # define GL_TEXTURE20 0x84D4 <nl> - # define GL_TEXTURE21 0x84D5 <nl> - # define GL_TEXTURE22 0x84D6 <nl> - # define GL_TEXTURE23 0x84D7 <nl> - # define GL_TEXTURE24 0x84D8 <nl> - # define GL_TEXTURE25 0x84D9 <nl> - # define GL_TEXTURE26 0x84DA <nl> - # define GL_TEXTURE27 0x84DB <nl> - # define GL_TEXTURE28 0x84DC <nl> - # define GL_TEXTURE29 0x84DD <nl> - # define GL_TEXTURE30 0x84DE <nl> - # define GL_TEXTURE31 0x84DF <nl> - # define GL_ACTIVE_TEXTURE 0x84E0 <nl> - <nl> - / * TextureWrapMode * / <nl> - # define GL_REPEAT 0x2901 <nl> - # define GL_CLAMP_TO_EDGE 0x812F <nl> - # define GL_MIRRORED_REPEAT 0x8370 <nl> - <nl> - / * Uniform Types * / <nl> - # define GL_FLOAT_VEC2 0x8B50 <nl> - # define GL_FLOAT_VEC3 0x8B51 <nl> - # define GL_FLOAT_VEC4 0x8B52 <nl> - # define GL_INT_VEC2 0x8B53 <nl> - # define GL_INT_VEC3 0x8B54 <nl> - # define GL_INT_VEC4 0x8B55 <nl> - # define GL_BOOL 0x8B56 <nl> - # define GL_BOOL_VEC2 0x8B57 <nl> - # define GL_BOOL_VEC3 0x8B58 <nl> - # define GL_BOOL_VEC4 0x8B59 <nl> - # define GL_FLOAT_MAT2 0x8B5A <nl> - # define GL_FLOAT_MAT3 0x8B5B <nl> - # define GL_FLOAT_MAT4 0x8B5C <nl> - # define GL_SAMPLER_2D 0x8B5E <nl> - # define GL_SAMPLER_CUBE 0x8B60 <nl> - <nl> - / * Vertex Arrays * / <nl> - # define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 <nl> - # define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 <nl> - # define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 <nl> - # define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 <nl> - # define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A <nl> - # define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 <nl> - # define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F <nl> - <nl> - / * Read Format * / <nl> - # define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A <nl> - # define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B <nl> - <nl> - / * Shader Source * / <nl> - # define GL_COMPILE_STATUS 0x8B81 <nl> - # define GL_INFO_LOG_LENGTH 0x8B84 <nl> - # define GL_SHADER_SOURCE_LENGTH 0x8B88 <nl> - # define GL_SHADER_COMPILER 0x8DFA <nl> - <nl> - / * Shader Binary * / <nl> - # define GL_SHADER_BINARY_FORMATS 0x8DF8 <nl> - # define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 <nl> - <nl> - / * Shader Precision - Specified Types * / <nl> - # define GL_LOW_FLOAT 0x8DF0 <nl> - # define GL_MEDIUM_FLOAT 0x8DF1 <nl> - # define GL_HIGH_FLOAT 0x8DF2 <nl> - # define GL_LOW_INT 0x8DF3 <nl> - # define GL_MEDIUM_INT 0x8DF4 <nl> - # define GL_HIGH_INT 0x8DF5 <nl> - <nl> - / * Framebuffer Object . * / <nl> - # define GL_FRAMEBUFFER 0x8D40 <nl> - # define GL_RENDERBUFFER 0x8D41 <nl> - <nl> - # define GL_RGBA4 0x8056 <nl> - # define GL_RGB5_A1 0x8057 <nl> - # define GL_RGB565 0x8D62 <nl> - # define GL_DEPTH_COMPONENT16 0x81A5 <nl> - # define GL_STENCIL_INDEX 0x1901 <nl> - # define GL_STENCIL_INDEX8 0x8D48 <nl> - <nl> - # define GL_RENDERBUFFER_WIDTH 0x8D42 <nl> - # define GL_RENDERBUFFER_HEIGHT 0x8D43 <nl> - # define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44 <nl> - # define GL_RENDERBUFFER_RED_SIZE 0x8D50 <nl> - # define GL_RENDERBUFFER_GREEN_SIZE 0x8D51 <nl> - # define GL_RENDERBUFFER_BLUE_SIZE 0x8D52 <nl> - # define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53 <nl> - # define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54 <nl> - # define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55 <nl> - <nl> - # define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0 <nl> - # define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1 <nl> - # define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2 <nl> - # define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3 <nl> - <nl> - # define GL_COLOR_ATTACHMENT0 0x8CE0 <nl> - # define GL_DEPTH_ATTACHMENT 0x8D00 <nl> - # define GL_STENCIL_ATTACHMENT 0x8D20 <nl> - <nl> - # define GL_NONE 0 <nl> - <nl> - # define GL_FRAMEBUFFER_COMPLETE 0x8CD5 <nl> - # define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6 <nl> - # define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7 <nl> - # define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS 0x8CD9 <nl> - # define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD <nl> - <nl> - # define GL_FRAMEBUFFER_BINDING 0x8CA6 <nl> - # define GL_RENDERBUFFER_BINDING 0x8CA7 <nl> - # define GL_MAX_RENDERBUFFER_SIZE 0x84E8 <nl> - <nl> - # define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 <nl> - <nl> - / * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> - * GL core functions . <nl> - * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - * / <nl> - <nl> - GL_APICALL void GL_APIENTRY glActiveTexture ( GLenum texture ) ; <nl> - GL_APICALL void GL_APIENTRY glAttachShader ( GLuint program , GLuint shader ) ; <nl> - GL_APICALL void GL_APIENTRY glBindAttribLocation ( GLuint program , GLuint index , const GLchar * name ) ; <nl> - GL_APICALL void GL_APIENTRY glBindBuffer ( GLenum target , GLuint buffer ) ; <nl> - GL_APICALL void GL_APIENTRY glBindFramebuffer ( GLenum target , GLuint framebuffer ) ; <nl> - GL_APICALL void GL_APIENTRY glBindRenderbuffer ( GLenum target , GLuint renderbuffer ) ; <nl> - GL_APICALL void GL_APIENTRY glBindTexture ( GLenum target , GLuint texture ) ; <nl> - GL_APICALL void GL_APIENTRY glBlendColor ( GLclampf red , GLclampf green , GLclampf blue , GLclampf alpha ) ; <nl> - GL_APICALL void GL_APIENTRY glBlendEquation ( GLenum mode ) ; <nl> - GL_APICALL void GL_APIENTRY glBlendEquationSeparate ( GLenum modeRGB , GLenum modeAlpha ) ; <nl> - GL_APICALL void GL_APIENTRY glBlendFunc ( GLenum sfactor , GLenum dfactor ) ; <nl> - GL_APICALL void GL_APIENTRY glBlendFuncSeparate ( GLenum srcRGB , GLenum dstRGB , GLenum srcAlpha , GLenum dstAlpha ) ; <nl> - GL_APICALL void GL_APIENTRY glBufferData ( GLenum target , GLsizeiptr size , const GLvoid * data , GLenum usage ) ; <nl> - GL_APICALL void GL_APIENTRY glBufferSubData ( GLenum target , GLintptr offset , GLsizeiptr size , const GLvoid * data ) ; <nl> - GL_APICALL GLenum GL_APIENTRY glCheckFramebufferStatus ( GLenum target ) ; <nl> - GL_APICALL void GL_APIENTRY glClear ( GLbitfield mask ) ; <nl> - GL_APICALL void GL_APIENTRY glClearColor ( GLclampf red , GLclampf green , GLclampf blue , GLclampf alpha ) ; <nl> - GL_APICALL void GL_APIENTRY glClearDepthf ( GLclampf depth ) ; <nl> - GL_APICALL void GL_APIENTRY glClearStencil ( GLint s ) ; <nl> - GL_APICALL void GL_APIENTRY glColorMask ( GLboolean red , GLboolean green , GLboolean blue , GLboolean alpha ) ; <nl> - GL_APICALL void GL_APIENTRY glCompileShader ( GLuint shader ) ; <nl> - GL_APICALL void GL_APIENTRY glCompressedTexImage2D ( GLenum target , GLint level , GLenum internalformat , GLsizei width , GLsizei height , GLint border , GLsizei imageSize , const GLvoid * data ) ; <nl> - GL_APICALL void GL_APIENTRY glCompressedTexSubImage2D ( GLenum target , GLint level , GLint xoffset , GLint yoffset , GLsizei width , GLsizei height , GLenum format , GLsizei imageSize , const GLvoid * data ) ; <nl> - GL_APICALL void GL_APIENTRY glCopyTexImage2D ( GLenum target , GLint level , GLenum internalformat , GLint x , GLint y , GLsizei width , GLsizei height , GLint border ) ; <nl> - GL_APICALL void GL_APIENTRY glCopyTexSubImage2D ( GLenum target , GLint level , GLint xoffset , GLint yoffset , GLint x , GLint y , GLsizei width , GLsizei height ) ; <nl> - GL_APICALL GLuint GL_APIENTRY glCreateProgram ( void ) ; <nl> - GL_APICALL GLuint GL_APIENTRY glCreateShader ( GLenum type ) ; <nl> - GL_APICALL void GL_APIENTRY glCullFace ( GLenum mode ) ; <nl> - GL_APICALL void GL_APIENTRY glDeleteBuffers ( GLsizei n , const GLuint * buffers ) ; <nl> - GL_APICALL void GL_APIENTRY glDeleteFramebuffers ( GLsizei n , const GLuint * framebuffers ) ; <nl> - GL_APICALL void GL_APIENTRY glDeleteProgram ( GLuint program ) ; <nl> - GL_APICALL void GL_APIENTRY glDeleteRenderbuffers ( GLsizei n , const GLuint * renderbuffers ) ; <nl> - GL_APICALL void GL_APIENTRY glDeleteShader ( GLuint shader ) ; <nl> - GL_APICALL void GL_APIENTRY glDeleteTextures ( GLsizei n , const GLuint * textures ) ; <nl> - GL_APICALL void GL_APIENTRY glDepthFunc ( GLenum func ) ; <nl> - GL_APICALL void GL_APIENTRY glDepthMask ( GLboolean flag ) ; <nl> - GL_APICALL void GL_APIENTRY glDepthRangef ( GLclampf zNear , GLclampf zFar ) ; <nl> - GL_APICALL void GL_APIENTRY glDetachShader ( GLuint program , GLuint shader ) ; <nl> - GL_APICALL void GL_APIENTRY glDisable ( GLenum cap ) ; <nl> - GL_APICALL void GL_APIENTRY glDisableVertexAttribArray ( GLuint index ) ; <nl> - GL_APICALL void GL_APIENTRY glDrawArrays ( GLenum mode , GLint first , GLsizei count ) ; <nl> - GL_APICALL void GL_APIENTRY glDrawElements ( GLenum mode , GLsizei count , GLenum type , const GLvoid * indices ) ; <nl> - GL_APICALL void GL_APIENTRY glEnable ( GLenum cap ) ; <nl> - GL_APICALL void GL_APIENTRY glEnableVertexAttribArray ( GLuint index ) ; <nl> - GL_APICALL void GL_APIENTRY glFinish ( void ) ; <nl> - GL_APICALL void GL_APIENTRY glFlush ( void ) ; <nl> - GL_APICALL void GL_APIENTRY glFramebufferRenderbuffer ( GLenum target , GLenum attachment , GLenum renderbuffertarget , GLuint renderbuffer ) ; <nl> - GL_APICALL void GL_APIENTRY glFramebufferTexture2D ( GLenum target , GLenum attachment , GLenum textarget , GLuint texture , GLint level ) ; <nl> - GL_APICALL void GL_APIENTRY glFrontFace ( GLenum mode ) ; <nl> - GL_APICALL void GL_APIENTRY glGenBuffers ( GLsizei n , GLuint * buffers ) ; <nl> - GL_APICALL void GL_APIENTRY glGenerateMipmap ( GLenum target ) ; <nl> - GL_APICALL void GL_APIENTRY glGenFramebuffers ( GLsizei n , GLuint * framebuffers ) ; <nl> - GL_APICALL void GL_APIENTRY glGenRenderbuffers ( GLsizei n , GLuint * renderbuffers ) ; <nl> - GL_APICALL void GL_APIENTRY glGenTextures ( GLsizei n , GLuint * textures ) ; <nl> - GL_APICALL void GL_APIENTRY glGetActiveAttrib ( GLuint program , GLuint index , GLsizei bufsize , GLsizei * length , GLint * size , GLenum * type , GLchar * name ) ; <nl> - GL_APICALL void GL_APIENTRY glGetActiveUniform ( GLuint program , GLuint index , GLsizei bufsize , GLsizei * length , GLint * size , GLenum * type , GLchar * name ) ; <nl> - GL_APICALL void GL_APIENTRY glGetAttachedShaders ( GLuint program , GLsizei maxcount , GLsizei * count , GLuint * shaders ) ; <nl> - GL_APICALL int GL_APIENTRY glGetAttribLocation ( GLuint program , const GLchar * name ) ; <nl> - GL_APICALL void GL_APIENTRY glGetBooleanv ( GLenum pname , GLboolean * params ) ; <nl> - GL_APICALL void GL_APIENTRY glGetBufferParameteriv ( GLenum target , GLenum pname , GLint * params ) ; <nl> - GL_APICALL GLenum GL_APIENTRY glGetError ( void ) ; <nl> - GL_APICALL void GL_APIENTRY glGetFloatv ( GLenum pname , GLfloat * params ) ; <nl> - GL_APICALL void GL_APIENTRY glGetFramebufferAttachmentParameteriv ( GLenum target , GLenum attachment , GLenum pname , GLint * params ) ; <nl> - GL_APICALL void GL_APIENTRY glGetIntegerv ( GLenum pname , GLint * params ) ; <nl> - GL_APICALL void GL_APIENTRY glGetProgramiv ( GLuint program , GLenum pname , GLint * params ) ; <nl> - GL_APICALL void GL_APIENTRY glGetProgramInfoLog ( GLuint program , GLsizei bufsize , GLsizei * length , GLchar * infolog ) ; <nl> - GL_APICALL void GL_APIENTRY glGetRenderbufferParameteriv ( GLenum target , GLenum pname , GLint * params ) ; <nl> - GL_APICALL void GL_APIENTRY glGetShaderiv ( GLuint shader , GLenum pname , GLint * params ) ; <nl> - GL_APICALL void GL_APIENTRY glGetShaderInfoLog ( GLuint shader , GLsizei bufsize , GLsizei * length , GLchar * infolog ) ; <nl> - GL_APICALL void GL_APIENTRY glGetShaderPrecisionFormat ( GLenum shadertype , GLenum precisiontype , GLint * range , GLint * precision ) ; <nl> - GL_APICALL void GL_APIENTRY glGetShaderSource ( GLuint shader , GLsizei bufsize , GLsizei * length , GLchar * source ) ; <nl> - GL_APICALL const GLubyte * GL_APIENTRY glGetString ( GLenum name ) ; <nl> - GL_APICALL void GL_APIENTRY glGetTexParameterfv ( GLenum target , GLenum pname , GLfloat * params ) ; <nl> - GL_APICALL void GL_APIENTRY glGetTexParameteriv ( GLenum target , GLenum pname , GLint * params ) ; <nl> - GL_APICALL void GL_APIENTRY glGetUniformfv ( GLuint program , GLint location , GLfloat * params ) ; <nl> - GL_APICALL void GL_APIENTRY glGetUniformiv ( GLuint program , GLint location , GLint * params ) ; <nl> - GL_APICALL int GL_APIENTRY glGetUniformLocation ( GLuint program , const GLchar * name ) ; <nl> - GL_APICALL void GL_APIENTRY glGetVertexAttribfv ( GLuint index , GLenum pname , GLfloat * params ) ; <nl> - GL_APICALL void GL_APIENTRY glGetVertexAttribiv ( GLuint index , GLenum pname , GLint * params ) ; <nl> - GL_APICALL void GL_APIENTRY glGetVertexAttribPointerv ( GLuint index , GLenum pname , GLvoid * * pointer ) ; <nl> - GL_APICALL void GL_APIENTRY glHint ( GLenum target , GLenum mode ) ; <nl> - GL_APICALL GLboolean GL_APIENTRY glIsBuffer ( GLuint buffer ) ; <nl> - GL_APICALL GLboolean GL_APIENTRY glIsEnabled ( GLenum cap ) ; <nl> - GL_APICALL GLboolean GL_APIENTRY glIsFramebuffer ( GLuint framebuffer ) ; <nl> - GL_APICALL GLboolean GL_APIENTRY glIsProgram ( GLuint program ) ; <nl> - GL_APICALL GLboolean GL_APIENTRY glIsRenderbuffer ( GLuint renderbuffer ) ; <nl> - GL_APICALL GLboolean GL_APIENTRY glIsShader ( GLuint shader ) ; <nl> - GL_APICALL GLboolean GL_APIENTRY glIsTexture ( GLuint texture ) ; <nl> - GL_APICALL void GL_APIENTRY glLineWidth ( GLfloat width ) ; <nl> - GL_APICALL void GL_APIENTRY glLinkProgram ( GLuint program ) ; <nl> - GL_APICALL void GL_APIENTRY glPixelStorei ( GLenum pname , GLint param ) ; <nl> - GL_APICALL void GL_APIENTRY glPolygonOffset ( GLfloat factor , GLfloat units ) ; <nl> - GL_APICALL void GL_APIENTRY glReadPixels ( GLint x , GLint y , GLsizei width , GLsizei height , GLenum format , GLenum type , GLvoid * pixels ) ; <nl> - GL_APICALL void GL_APIENTRY glReleaseShaderCompiler ( void ) ; <nl> - GL_APICALL void GL_APIENTRY glRenderbufferStorage ( GLenum target , GLenum internalformat , GLsizei width , GLsizei height ) ; <nl> - GL_APICALL void GL_APIENTRY glSampleCoverage ( GLclampf value , GLboolean invert ) ; <nl> - GL_APICALL void GL_APIENTRY glScissor ( GLint x , GLint y , GLsizei width , GLsizei height ) ; <nl> - GL_APICALL void GL_APIENTRY glShaderBinary ( GLsizei n , const GLuint * shaders , GLenum binaryformat , const GLvoid * binary , GLsizei length ) ; <nl> - GL_APICALL void GL_APIENTRY glShaderSource ( GLuint shader , GLsizei count , const GLchar * * string , const GLint * length ) ; <nl> - GL_APICALL void GL_APIENTRY glStencilFunc ( GLenum func , GLint ref , GLuint mask ) ; <nl> - GL_APICALL void GL_APIENTRY glStencilFuncSeparate ( GLenum face , GLenum func , GLint ref , GLuint mask ) ; <nl> - GL_APICALL void GL_APIENTRY glStencilMask ( GLuint mask ) ; <nl> - GL_APICALL void GL_APIENTRY glStencilMaskSeparate ( GLenum face , GLuint mask ) ; <nl> - GL_APICALL void GL_APIENTRY glStencilOp ( GLenum fail , GLenum zfail , GLenum zpass ) ; <nl> - GL_APICALL void GL_APIENTRY glStencilOpSeparate ( GLenum face , GLenum fail , GLenum zfail , GLenum zpass ) ; <nl> - GL_APICALL void GL_APIENTRY glTexImage2D ( GLenum target , GLint level , GLint internalformat , GLsizei width , GLsizei height , GLint border , GLenum format , GLenum type , const GLvoid * pixels ) ; <nl> - GL_APICALL void GL_APIENTRY glTexParameterf ( GLenum target , GLenum pname , GLfloat param ) ; <nl> - GL_APICALL void GL_APIENTRY glTexParameterfv ( GLenum target , GLenum pname , const GLfloat * params ) ; <nl> - GL_APICALL void GL_APIENTRY glTexParameteri ( GLenum target , GLenum pname , GLint param ) ; <nl> - GL_APICALL void GL_APIENTRY glTexParameteriv ( GLenum target , GLenum pname , const GLint * params ) ; <nl> - GL_APICALL void GL_APIENTRY glTexSubImage2D ( GLenum target , GLint level , GLint xoffset , GLint yoffset , GLsizei width , GLsizei height , GLenum format , GLenum type , const GLvoid * pixels ) ; <nl> - GL_APICALL void GL_APIENTRY glUniform1f ( GLint location , GLfloat x ) ; <nl> - GL_APICALL void GL_APIENTRY glUniform1fv ( GLint location , GLsizei count , const GLfloat * v ) ; <nl> - GL_APICALL void GL_APIENTRY glUniform1i ( GLint location , GLint x ) ; <nl> - GL_APICALL void GL_APIENTRY glUniform1iv ( GLint location , GLsizei count , const GLint * v ) ; <nl> - GL_APICALL void GL_APIENTRY glUniform2f ( GLint location , GLfloat x , GLfloat y ) ; <nl> - GL_APICALL void GL_APIENTRY glUniform2fv ( GLint location , GLsizei count , const GLfloat * v ) ; <nl> - GL_APICALL void GL_APIENTRY glUniform2i ( GLint location , GLint x , GLint y ) ; <nl> - GL_APICALL void GL_APIENTRY glUniform2iv ( GLint location , GLsizei count , const GLint * v ) ; <nl> - GL_APICALL void GL_APIENTRY glUniform3f ( GLint location , GLfloat x , GLfloat y , GLfloat z ) ; <nl> - GL_APICALL void GL_APIENTRY glUniform3fv ( GLint location , GLsizei count , const GLfloat * v ) ; <nl> - GL_APICALL void GL_APIENTRY glUniform3i ( GLint location , GLint x , GLint y , GLint z ) ; <nl> - GL_APICALL void GL_APIENTRY glUniform3iv ( GLint location , GLsizei count , const GLint * v ) ; <nl> - GL_APICALL void GL_APIENTRY glUniform4f ( GLint location , GLfloat x , GLfloat y , GLfloat z , GLfloat w ) ; <nl> - GL_APICALL void GL_APIENTRY glUniform4fv ( GLint location , GLsizei count , const GLfloat * v ) ; <nl> - GL_APICALL void GL_APIENTRY glUniform4i ( GLint location , GLint x , GLint y , GLint z , GLint w ) ; <nl> - GL_APICALL void GL_APIENTRY glUniform4iv ( GLint location , GLsizei count , const GLint * v ) ; <nl> - GL_APICALL void GL_APIENTRY glUniformMatrix2fv ( GLint location , GLsizei count , GLboolean transpose , const GLfloat * value ) ; <nl> - GL_APICALL void GL_APIENTRY glUniformMatrix3fv ( GLint location , GLsizei count , GLboolean transpose , const GLfloat * value ) ; <nl> - GL_APICALL void GL_APIENTRY glUniformMatrix4fv ( GLint location , GLsizei count , GLboolean transpose , const GLfloat * value ) ; <nl> - GL_APICALL void GL_APIENTRY glUseProgram ( GLuint program ) ; <nl> - GL_APICALL void GL_APIENTRY glValidateProgram ( GLuint program ) ; <nl> - GL_APICALL void GL_APIENTRY glVertexAttrib1f ( GLuint indx , GLfloat x ) ; <nl> - GL_APICALL void GL_APIENTRY glVertexAttrib1fv ( GLuint indx , const GLfloat * values ) ; <nl> - GL_APICALL void GL_APIENTRY glVertexAttrib2f ( GLuint indx , GLfloat x , GLfloat y ) ; <nl> - GL_APICALL void GL_APIENTRY glVertexAttrib2fv ( GLuint indx , const GLfloat * values ) ; <nl> - GL_APICALL void GL_APIENTRY glVertexAttrib3f ( GLuint indx , GLfloat x , GLfloat y , GLfloat z ) ; <nl> - GL_APICALL void GL_APIENTRY glVertexAttrib3fv ( GLuint indx , const GLfloat * values ) ; <nl> - GL_APICALL void GL_APIENTRY glVertexAttrib4f ( GLuint indx , GLfloat x , GLfloat y , GLfloat z , GLfloat w ) ; <nl> - GL_APICALL void GL_APIENTRY glVertexAttrib4fv ( GLuint indx , const GLfloat * values ) ; <nl> - GL_APICALL void GL_APIENTRY glVertexAttribPointer ( GLuint indx , GLint size , GLenum type , GLboolean normalized , GLsizei stride , const GLvoid * ptr ) ; <nl> - GL_APICALL void GL_APIENTRY glViewport ( GLint x , GLint y , GLsizei width , GLsizei height ) ; <nl> - <nl> - # ifdef __cplusplus <nl> - } <nl> - # endif <nl> - <nl> - # endif / * __gl2_h_ * / <nl> + # ifndef __gl2_h_ <nl> + # define __gl2_h_ <nl> + <nl> + # include < GLES2 / gl2platform . h > <nl> + <nl> + # ifdef __cplusplus <nl> + extern " C " { <nl> + # endif <nl> + <nl> + / * <nl> + * This document is licensed under the SGI Free Software B License Version <nl> + * 2 . 0 . For details , see http : / / oss . sgi . com / projects / FreeB / . <nl> + * / <nl> + <nl> + / * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> + * Data type definitions <nl> + * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - * / <nl> + <nl> + typedef void GLvoid ; <nl> + typedef char GLchar ; <nl> + typedef unsigned int GLenum ; <nl> + typedef unsigned char GLboolean ; <nl> + typedef unsigned int GLbitfield ; <nl> + typedef khronos_int8_t GLbyte ; <nl> + typedef short GLshort ; <nl> + typedef int GLint ; <nl> + typedef int GLsizei ; <nl> + typedef khronos_uint8_t GLubyte ; <nl> + typedef unsigned short GLushort ; <nl> + typedef unsigned int GLuint ; <nl> + typedef khronos_float_t GLfloat ; <nl> + typedef khronos_float_t GLclampf ; <nl> + typedef khronos_int32_t GLfixed ; <nl> + <nl> + / * GL types for handling large vertex buffer objects * / <nl> + typedef khronos_intptr_t GLintptr ; <nl> + typedef khronos_ssize_t GLsizeiptr ; <nl> + <nl> + / * OpenGL ES core versions * / <nl> + # define GL_ES_VERSION_2_0 1 <nl> + <nl> + / * ClearBufferMask * / <nl> + # define GL_DEPTH_BUFFER_BIT 0x00000100 <nl> + # define GL_STENCIL_BUFFER_BIT 0x00000400 <nl> + # define GL_COLOR_BUFFER_BIT 0x00004000 <nl> + <nl> + / * Boolean * / <nl> + # define GL_FALSE 0 <nl> + # define GL_TRUE 1 <nl> + <nl> + / * BeginMode * / <nl> + # define GL_POINTS 0x0000 <nl> + # define GL_LINES 0x0001 <nl> + # define GL_LINE_LOOP 0x0002 <nl> + # define GL_LINE_STRIP 0x0003 <nl> + # define GL_TRIANGLES 0x0004 <nl> + # define GL_TRIANGLE_STRIP 0x0005 <nl> + # define GL_TRIANGLE_FAN 0x0006 <nl> + <nl> + / * AlphaFunction ( not supported in ES20 ) * / <nl> + / * GL_NEVER * / <nl> + / * GL_LESS * / <nl> + / * GL_EQUAL * / <nl> + / * GL_LEQUAL * / <nl> + / * GL_GREATER * / <nl> + / * GL_NOTEQUAL * / <nl> + / * GL_GEQUAL * / <nl> + / * GL_ALWAYS * / <nl> + <nl> + / * BlendingFactorDest * / <nl> + # define GL_ZERO 0 <nl> + # define GL_ONE 1 <nl> + # define GL_SRC_COLOR 0x0300 <nl> + # define GL_ONE_MINUS_SRC_COLOR 0x0301 <nl> + # define GL_SRC_ALPHA 0x0302 <nl> + # define GL_ONE_MINUS_SRC_ALPHA 0x0303 <nl> + # define GL_DST_ALPHA 0x0304 <nl> + # define GL_ONE_MINUS_DST_ALPHA 0x0305 <nl> + <nl> + / * BlendingFactorSrc * / <nl> + / * GL_ZERO * / <nl> + / * GL_ONE * / <nl> + # define GL_DST_COLOR 0x0306 <nl> + # define GL_ONE_MINUS_DST_COLOR 0x0307 <nl> + # define GL_SRC_ALPHA_SATURATE 0x0308 <nl> + / * GL_SRC_ALPHA * / <nl> + / * GL_ONE_MINUS_SRC_ALPHA * / <nl> + / * GL_DST_ALPHA * / <nl> + / * GL_ONE_MINUS_DST_ALPHA * / <nl> + <nl> + / * BlendEquationSeparate * / <nl> + # define GL_FUNC_ADD 0x8006 <nl> + # define GL_BLEND_EQUATION 0x8009 <nl> + # define GL_BLEND_EQUATION_RGB 0x8009 / * same as BLEND_EQUATION * / <nl> + # define GL_BLEND_EQUATION_ALPHA 0x883D <nl> + <nl> + / * BlendSubtract * / <nl> + # define GL_FUNC_SUBTRACT 0x800A <nl> + # define GL_FUNC_REVERSE_SUBTRACT 0x800B <nl> + <nl> + / * Separate Blend Functions * / <nl> + # define GL_BLEND_DST_RGB 0x80C8 <nl> + # define GL_BLEND_SRC_RGB 0x80C9 <nl> + # define GL_BLEND_DST_ALPHA 0x80CA <nl> + # define GL_BLEND_SRC_ALPHA 0x80CB <nl> + # define GL_CONSTANT_COLOR 0x8001 <nl> + # define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 <nl> + # define GL_CONSTANT_ALPHA 0x8003 <nl> + # define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 <nl> + # define GL_BLEND_COLOR 0x8005 <nl> + <nl> + / * Buffer Objects * / <nl> + # define GL_ARRAY_BUFFER 0x8892 <nl> + # define GL_ELEMENT_ARRAY_BUFFER 0x8893 <nl> + # define GL_ARRAY_BUFFER_BINDING 0x8894 <nl> + # define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 <nl> + <nl> + # define GL_STREAM_DRAW 0x88E0 <nl> + # define GL_STATIC_DRAW 0x88E4 <nl> + # define GL_DYNAMIC_DRAW 0x88E8 <nl> + <nl> + # define GL_BUFFER_SIZE 0x8764 <nl> + # define GL_BUFFER_USAGE 0x8765 <nl> + <nl> + # define GL_CURRENT_VERTEX_ATTRIB 0x8626 <nl> + <nl> + / * CullFaceMode * / <nl> + # define GL_FRONT 0x0404 <nl> + # define GL_BACK 0x0405 <nl> + # define GL_FRONT_AND_BACK 0x0408 <nl> + <nl> + / * DepthFunction * / <nl> + / * GL_NEVER * / <nl> + / * GL_LESS * / <nl> + / * GL_EQUAL * / <nl> + / * GL_LEQUAL * / <nl> + / * GL_GREATER * / <nl> + / * GL_NOTEQUAL * / <nl> + / * GL_GEQUAL * / <nl> + / * GL_ALWAYS * / <nl> + <nl> + / * EnableCap * / <nl> + # define GL_TEXTURE_2D 0x0DE1 <nl> + # define GL_CULL_FACE 0x0B44 <nl> + # define GL_BLEND 0x0BE2 <nl> + # define GL_DITHER 0x0BD0 <nl> + # define GL_STENCIL_TEST 0x0B90 <nl> + # define GL_DEPTH_TEST 0x0B71 <nl> + # define GL_SCISSOR_TEST 0x0C11 <nl> + # define GL_POLYGON_OFFSET_FILL 0x8037 <nl> + # define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E <nl> + # define GL_SAMPLE_COVERAGE 0x80A0 <nl> + <nl> + / * ErrorCode * / <nl> + # define GL_NO_ERROR 0 <nl> + # define GL_INVALID_ENUM 0x0500 <nl> + # define GL_INVALID_VALUE 0x0501 <nl> + # define GL_INVALID_OPERATION 0x0502 <nl> + # define GL_OUT_OF_MEMORY 0x0505 <nl> + <nl> + / * FrontFaceDirection * / <nl> + # define GL_CW 0x0900 <nl> + # define GL_CCW 0x0901 <nl> + <nl> + / * GetPName * / <nl> + # define GL_LINE_WIDTH 0x0B21 <nl> + # define GL_ALIASED_POINT_SIZE_RANGE 0x846D <nl> + # define GL_ALIASED_LINE_WIDTH_RANGE 0x846E <nl> + # define GL_CULL_FACE_MODE 0x0B45 <nl> + # define GL_FRONT_FACE 0x0B46 <nl> + # define GL_DEPTH_RANGE 0x0B70 <nl> + # define GL_DEPTH_WRITEMASK 0x0B72 <nl> + # define GL_DEPTH_CLEAR_VALUE 0x0B73 <nl> + # define GL_DEPTH_FUNC 0x0B74 <nl> + # define GL_STENCIL_CLEAR_VALUE 0x0B91 <nl> + # define GL_STENCIL_FUNC 0x0B92 <nl> + # define GL_STENCIL_FAIL 0x0B94 <nl> + # define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95 <nl> + # define GL_STENCIL_PASS_DEPTH_PASS 0x0B96 <nl> + # define GL_STENCIL_REF 0x0B97 <nl> + # define GL_STENCIL_VALUE_MASK 0x0B93 <nl> + # define GL_STENCIL_WRITEMASK 0x0B98 <nl> + # define GL_STENCIL_BACK_FUNC 0x8800 <nl> + # define GL_STENCIL_BACK_FAIL 0x8801 <nl> + # define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 <nl> + # define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 <nl> + # define GL_STENCIL_BACK_REF 0x8CA3 <nl> + # define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 <nl> + # define GL_STENCIL_BACK_WRITEMASK 0x8CA5 <nl> + # define GL_VIEWPORT 0x0BA2 <nl> + # define GL_SCISSOR_BOX 0x0C10 <nl> + / * GL_SCISSOR_TEST * / <nl> + # define GL_COLOR_CLEAR_VALUE 0x0C22 <nl> + # define GL_COLOR_WRITEMASK 0x0C23 <nl> + # define GL_UNPACK_ALIGNMENT 0x0CF5 <nl> + # define GL_PACK_ALIGNMENT 0x0D05 <nl> + # define GL_MAX_TEXTURE_SIZE 0x0D33 <nl> + # define GL_MAX_VIEWPORT_DIMS 0x0D3A <nl> + # define GL_SUBPIXEL_BITS 0x0D50 <nl> + # define GL_RED_BITS 0x0D52 <nl> + # define GL_GREEN_BITS 0x0D53 <nl> + # define GL_BLUE_BITS 0x0D54 <nl> + # define GL_ALPHA_BITS 0x0D55 <nl> + # define GL_DEPTH_BITS 0x0D56 <nl> + # define GL_STENCIL_BITS 0x0D57 <nl> + # define GL_POLYGON_OFFSET_UNITS 0x2A00 <nl> + / * GL_POLYGON_OFFSET_FILL * / <nl> + # define GL_POLYGON_OFFSET_FACTOR 0x8038 <nl> + # define GL_TEXTURE_BINDING_2D 0x8069 <nl> + # define GL_SAMPLE_BUFFERS 0x80A8 <nl> + # define GL_SAMPLES 0x80A9 <nl> + # define GL_SAMPLE_COVERAGE_VALUE 0x80AA <nl> + # define GL_SAMPLE_COVERAGE_INVERT 0x80AB <nl> + <nl> + / * GetTextureParameter * / <nl> + / * GL_TEXTURE_MAG_FILTER * / <nl> + / * GL_TEXTURE_MIN_FILTER * / <nl> + / * GL_TEXTURE_WRAP_S * / <nl> + / * GL_TEXTURE_WRAP_T * / <nl> + <nl> + # define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 <nl> + # define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 <nl> + <nl> + / * HintMode * / <nl> + # define GL_DONT_CARE 0x1100 <nl> + # define GL_FASTEST 0x1101 <nl> + # define GL_NICEST 0x1102 <nl> + <nl> + / * HintTarget * / <nl> + # define GL_GENERATE_MIPMAP_HINT 0x8192 <nl> + <nl> + / * DataType * / <nl> + # define GL_BYTE 0x1400 <nl> + # define GL_UNSIGNED_BYTE 0x1401 <nl> + # define GL_SHORT 0x1402 <nl> + # define GL_UNSIGNED_SHORT 0x1403 <nl> + # define GL_INT 0x1404 <nl> + # define GL_UNSIGNED_INT 0x1405 <nl> + # define GL_FLOAT 0x1406 <nl> + # define GL_FIXED 0x140C <nl> + <nl> + / * PixelFormat * / <nl> + # define GL_DEPTH_COMPONENT 0x1902 <nl> + # define GL_ALPHA 0x1906 <nl> + # define GL_RGB 0x1907 <nl> + # define GL_RGBA 0x1908 <nl> + # define GL_LUMINANCE 0x1909 <nl> + # define GL_LUMINANCE_ALPHA 0x190A <nl> + <nl> + / * PixelType * / <nl> + / * GL_UNSIGNED_BYTE * / <nl> + # define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 <nl> + # define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 <nl> + # define GL_UNSIGNED_SHORT_5_6_5 0x8363 <nl> + <nl> + / * Shaders * / <nl> + # define GL_FRAGMENT_SHADER 0x8B30 <nl> + # define GL_VERTEX_SHADER 0x8B31 <nl> + # define GL_MAX_VERTEX_ATTRIBS 0x8869 <nl> + # define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB <nl> + # define GL_MAX_VARYING_VECTORS 0x8DFC <nl> + # define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D <nl> + # define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C <nl> + # define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 <nl> + # define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD <nl> + # define GL_SHADER_TYPE 0x8B4F <nl> + # define GL_DELETE_STATUS 0x8B80 <nl> + # define GL_LINK_STATUS 0x8B82 <nl> + # define GL_VALIDATE_STATUS 0x8B83 <nl> + # define GL_ATTACHED_SHADERS 0x8B85 <nl> + # define GL_ACTIVE_UNIFORMS 0x8B86 <nl> + # define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 <nl> + # define GL_ACTIVE_ATTRIBUTES 0x8B89 <nl> + # define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A <nl> + # define GL_SHADING_LANGUAGE_VERSION 0x8B8C <nl> + # define GL_CURRENT_PROGRAM 0x8B8D <nl> + <nl> + / * StencilFunction * / <nl> + # define GL_NEVER 0x0200 <nl> + # define GL_LESS 0x0201 <nl> + # define GL_EQUAL 0x0202 <nl> + # define GL_LEQUAL 0x0203 <nl> + # define GL_GREATER 0x0204 <nl> + # define GL_NOTEQUAL 0x0205 <nl> + # define GL_GEQUAL 0x0206 <nl> + # define GL_ALWAYS 0x0207 <nl> + <nl> + / * StencilOp * / <nl> + / * GL_ZERO * / <nl> + # define GL_KEEP 0x1E00 <nl> + # define GL_REPLACE 0x1E01 <nl> + # define GL_INCR 0x1E02 <nl> + # define GL_DECR 0x1E03 <nl> + # define GL_INVERT 0x150A <nl> + # define GL_INCR_WRAP 0x8507 <nl> + # define GL_DECR_WRAP 0x8508 <nl> + <nl> + / * StringName * / <nl> + # define GL_VENDOR 0x1F00 <nl> + # define GL_RENDERER 0x1F01 <nl> + # define GL_VERSION 0x1F02 <nl> + # define GL_EXTENSIONS 0x1F03 <nl> + <nl> + / * TextureMagFilter * / <nl> + # define GL_NEAREST 0x2600 <nl> + # define GL_LINEAR 0x2601 <nl> + <nl> + / * TextureMinFilter * / <nl> + / * GL_NEAREST * / <nl> + / * GL_LINEAR * / <nl> + # define GL_NEAREST_MIPMAP_NEAREST 0x2700 <nl> + # define GL_LINEAR_MIPMAP_NEAREST 0x2701 <nl> + # define GL_NEAREST_MIPMAP_LINEAR 0x2702 <nl> + # define GL_LINEAR_MIPMAP_LINEAR 0x2703 <nl> + <nl> + / * TextureParameterName * / <nl> + # define GL_TEXTURE_MAG_FILTER 0x2800 <nl> + # define GL_TEXTURE_MIN_FILTER 0x2801 <nl> + # define GL_TEXTURE_WRAP_S 0x2802 <nl> + # define GL_TEXTURE_WRAP_T 0x2803 <nl> + <nl> + / * TextureTarget * / <nl> + / * GL_TEXTURE_2D * / <nl> + # define GL_TEXTURE 0x1702 <nl> + <nl> + # define GL_TEXTURE_CUBE_MAP 0x8513 <nl> + # define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 <nl> + # define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 <nl> + # define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 <nl> + # define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 <nl> + # define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 <nl> + # define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 <nl> + # define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A <nl> + # define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C <nl> + <nl> + / * TextureUnit * / <nl> + # define GL_TEXTURE0 0x84C0 <nl> + # define GL_TEXTURE1 0x84C1 <nl> + # define GL_TEXTURE2 0x84C2 <nl> + # define GL_TEXTURE3 0x84C3 <nl> + # define GL_TEXTURE4 0x84C4 <nl> + # define GL_TEXTURE5 0x84C5 <nl> + # define GL_TEXTURE6 0x84C6 <nl> + # define GL_TEXTURE7 0x84C7 <nl> + # define GL_TEXTURE8 0x84C8 <nl> + # define GL_TEXTURE9 0x84C9 <nl> + # define GL_TEXTURE10 0x84CA <nl> + # define GL_TEXTURE11 0x84CB <nl> + # define GL_TEXTURE12 0x84CC <nl> + # define GL_TEXTURE13 0x84CD <nl> + # define GL_TEXTURE14 0x84CE <nl> + # define GL_TEXTURE15 0x84CF <nl> + # define GL_TEXTURE16 0x84D0 <nl> + # define GL_TEXTURE17 0x84D1 <nl> + # define GL_TEXTURE18 0x84D2 <nl> + # define GL_TEXTURE19 0x84D3 <nl> + # define GL_TEXTURE20 0x84D4 <nl> + # define GL_TEXTURE21 0x84D5 <nl> + # define GL_TEXTURE22 0x84D6 <nl> + # define GL_TEXTURE23 0x84D7 <nl> + # define GL_TEXTURE24 0x84D8 <nl> + # define GL_TEXTURE25 0x84D9 <nl> + # define GL_TEXTURE26 0x84DA <nl> + # define GL_TEXTURE27 0x84DB <nl> + # define GL_TEXTURE28 0x84DC <nl> + # define GL_TEXTURE29 0x84DD <nl> + # define GL_TEXTURE30 0x84DE <nl> + # define GL_TEXTURE31 0x84DF <nl> + # define GL_ACTIVE_TEXTURE 0x84E0 <nl> + <nl> + / * TextureWrapMode * / <nl> + # define GL_REPEAT 0x2901 <nl> + # define GL_CLAMP_TO_EDGE 0x812F <nl> + # define GL_MIRRORED_REPEAT 0x8370 <nl> + <nl> + / * Uniform Types * / <nl> + # define GL_FLOAT_VEC2 0x8B50 <nl> + # define GL_FLOAT_VEC3 0x8B51 <nl> + # define GL_FLOAT_VEC4 0x8B52 <nl> + # define GL_INT_VEC2 0x8B53 <nl> + # define GL_INT_VEC3 0x8B54 <nl> + # define GL_INT_VEC4 0x8B55 <nl> + # define GL_BOOL 0x8B56 <nl> + # define GL_BOOL_VEC2 0x8B57 <nl> + # define GL_BOOL_VEC3 0x8B58 <nl> + # define GL_BOOL_VEC4 0x8B59 <nl> + # define GL_FLOAT_MAT2 0x8B5A <nl> + # define GL_FLOAT_MAT3 0x8B5B <nl> + # define GL_FLOAT_MAT4 0x8B5C <nl> + # define GL_SAMPLER_2D 0x8B5E <nl> + # define GL_SAMPLER_CUBE 0x8B60 <nl> + <nl> + / * Vertex Arrays * / <nl> + # define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 <nl> + # define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 <nl> + # define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 <nl> + # define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 <nl> + # define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A <nl> + # define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 <nl> + # define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F <nl> + <nl> + / * Read Format * / <nl> + # define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A <nl> + # define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B <nl> + <nl> + / * Shader Source * / <nl> + # define GL_COMPILE_STATUS 0x8B81 <nl> + # define GL_INFO_LOG_LENGTH 0x8B84 <nl> + # define GL_SHADER_SOURCE_LENGTH 0x8B88 <nl> + # define GL_SHADER_COMPILER 0x8DFA <nl> + <nl> + / * Shader Binary * / <nl> + # define GL_SHADER_BINARY_FORMATS 0x8DF8 <nl> + # define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 <nl> + <nl> + / * Shader Precision - Specified Types * / <nl> + # define GL_LOW_FLOAT 0x8DF0 <nl> + # define GL_MEDIUM_FLOAT 0x8DF1 <nl> + # define GL_HIGH_FLOAT 0x8DF2 <nl> + # define GL_LOW_INT 0x8DF3 <nl> + # define GL_MEDIUM_INT 0x8DF4 <nl> + # define GL_HIGH_INT 0x8DF5 <nl> + <nl> + / * Framebuffer Object . * / <nl> + # define GL_FRAMEBUFFER 0x8D40 <nl> + # define GL_RENDERBUFFER 0x8D41 <nl> + <nl> + # define GL_RGBA4 0x8056 <nl> + # define GL_RGB5_A1 0x8057 <nl> + # define GL_RGB565 0x8D62 <nl> + # define GL_DEPTH_COMPONENT16 0x81A5 <nl> + # define GL_STENCIL_INDEX 0x1901 <nl> + # define GL_STENCIL_INDEX8 0x8D48 <nl> + <nl> + # define GL_RENDERBUFFER_WIDTH 0x8D42 <nl> + # define GL_RENDERBUFFER_HEIGHT 0x8D43 <nl> + # define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44 <nl> + # define GL_RENDERBUFFER_RED_SIZE 0x8D50 <nl> + # define GL_RENDERBUFFER_GREEN_SIZE 0x8D51 <nl> + # define GL_RENDERBUFFER_BLUE_SIZE 0x8D52 <nl> + # define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53 <nl> + # define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54 <nl> + # define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55 <nl> + <nl> + # define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0 <nl> + # define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1 <nl> + # define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2 <nl> + # define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3 <nl> + <nl> + # define GL_COLOR_ATTACHMENT0 0x8CE0 <nl> + # define GL_DEPTH_ATTACHMENT 0x8D00 <nl> + # define GL_STENCIL_ATTACHMENT 0x8D20 <nl> + <nl> + # define GL_NONE 0 <nl> + <nl> + # define GL_FRAMEBUFFER_COMPLETE 0x8CD5 <nl> + # define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6 <nl> + # define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7 <nl> + # define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS 0x8CD9 <nl> + # define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD <nl> + <nl> + # define GL_FRAMEBUFFER_BINDING 0x8CA6 <nl> + # define GL_RENDERBUFFER_BINDING 0x8CA7 <nl> + # define GL_MAX_RENDERBUFFER_SIZE 0x84E8 <nl> + <nl> + # define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 <nl> + <nl> + / * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> + * GL core functions . <nl> + * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - * / <nl> + <nl> + GL_APICALL void GL_APIENTRY glActiveTexture ( GLenum texture ) ; <nl> + GL_APICALL void GL_APIENTRY glAttachShader ( GLuint program , GLuint shader ) ; <nl> + GL_APICALL void GL_APIENTRY glBindAttribLocation ( GLuint program , GLuint index , const GLchar * name ) ; <nl> + GL_APICALL void GL_APIENTRY glBindBuffer ( GLenum target , GLuint buffer ) ; <nl> + GL_APICALL void GL_APIENTRY glBindFramebuffer ( GLenum target , GLuint framebuffer ) ; <nl> + GL_APICALL void GL_APIENTRY glBindRenderbuffer ( GLenum target , GLuint renderbuffer ) ; <nl> + GL_APICALL void GL_APIENTRY glBindTexture ( GLenum target , GLuint texture ) ; <nl> + GL_APICALL void GL_APIENTRY glBlendColor ( GLclampf red , GLclampf green , GLclampf blue , GLclampf alpha ) ; <nl> + GL_APICALL void GL_APIENTRY glBlendEquation ( GLenum mode ) ; <nl> + GL_APICALL void GL_APIENTRY glBlendEquationSeparate ( GLenum modeRGB , GLenum modeAlpha ) ; <nl> + GL_APICALL void GL_APIENTRY glBlendFunc ( GLenum sfactor , GLenum dfactor ) ; <nl> + GL_APICALL void GL_APIENTRY glBlendFuncSeparate ( GLenum srcRGB , GLenum dstRGB , GLenum srcAlpha , GLenum dstAlpha ) ; <nl> + GL_APICALL void GL_APIENTRY glBufferData ( GLenum target , GLsizeiptr size , const GLvoid * data , GLenum usage ) ; <nl> + GL_APICALL void GL_APIENTRY glBufferSubData ( GLenum target , GLintptr offset , GLsizeiptr size , const GLvoid * data ) ; <nl> + GL_APICALL GLenum GL_APIENTRY glCheckFramebufferStatus ( GLenum target ) ; <nl> + GL_APICALL void GL_APIENTRY glClear ( GLbitfield mask ) ; <nl> + GL_APICALL void GL_APIENTRY glClearColor ( GLclampf red , GLclampf green , GLclampf blue , GLclampf alpha ) ; <nl> + GL_APICALL void GL_APIENTRY glClearDepthf ( GLclampf depth ) ; <nl> + GL_APICALL void GL_APIENTRY glClearStencil ( GLint s ) ; <nl> + GL_APICALL void GL_APIENTRY glColorMask ( GLboolean red , GLboolean green , GLboolean blue , GLboolean alpha ) ; <nl> + GL_APICALL void GL_APIENTRY glCompileShader ( GLuint shader ) ; <nl> + GL_APICALL void GL_APIENTRY glCompressedTexImage2D ( GLenum target , GLint level , GLenum internalformat , GLsizei width , GLsizei height , GLint border , GLsizei imageSize , const GLvoid * data ) ; <nl> + GL_APICALL void GL_APIENTRY glCompressedTexSubImage2D ( GLenum target , GLint level , GLint xoffset , GLint yoffset , GLsizei width , GLsizei height , GLenum format , GLsizei imageSize , const GLvoid * data ) ; <nl> + GL_APICALL void GL_APIENTRY glCopyTexImage2D ( GLenum target , GLint level , GLenum internalformat , GLint x , GLint y , GLsizei width , GLsizei height , GLint border ) ; <nl> + GL_APICALL void GL_APIENTRY glCopyTexSubImage2D ( GLenum target , GLint level , GLint xoffset , GLint yoffset , GLint x , GLint y , GLsizei width , GLsizei height ) ; <nl> + GL_APICALL GLuint GL_APIENTRY glCreateProgram ( void ) ; <nl> + GL_APICALL GLuint GL_APIENTRY glCreateShader ( GLenum type ) ; <nl> + GL_APICALL void GL_APIENTRY glCullFace ( GLenum mode ) ; <nl> + GL_APICALL void GL_APIENTRY glDeleteBuffers ( GLsizei n , const GLuint * buffers ) ; <nl> + GL_APICALL void GL_APIENTRY glDeleteFramebuffers ( GLsizei n , const GLuint * framebuffers ) ; <nl> + GL_APICALL void GL_APIENTRY glDeleteProgram ( GLuint program ) ; <nl> + GL_APICALL void GL_APIENTRY glDeleteRenderbuffers ( GLsizei n , const GLuint * renderbuffers ) ; <nl> + GL_APICALL void GL_APIENTRY glDeleteShader ( GLuint shader ) ; <nl> + GL_APICALL void GL_APIENTRY glDeleteTextures ( GLsizei n , const GLuint * textures ) ; <nl> + GL_APICALL void GL_APIENTRY glDepthFunc ( GLenum func ) ; <nl> + GL_APICALL void GL_APIENTRY glDepthMask ( GLboolean flag ) ; <nl> + GL_APICALL void GL_APIENTRY glDepthRangef ( GLclampf zNear , GLclampf zFar ) ; <nl> + GL_APICALL void GL_APIENTRY glDetachShader ( GLuint program , GLuint shader ) ; <nl> + GL_APICALL void GL_APIENTRY glDisable ( GLenum cap ) ; <nl> + GL_APICALL void GL_APIENTRY glDisableVertexAttribArray ( GLuint index ) ; <nl> + GL_APICALL void GL_APIENTRY glDrawArrays ( GLenum mode , GLint first , GLsizei count ) ; <nl> + GL_APICALL void GL_APIENTRY glDrawElements ( GLenum mode , GLsizei count , GLenum type , const GLvoid * indices ) ; <nl> + GL_APICALL void GL_APIENTRY glEnable ( GLenum cap ) ; <nl> + GL_APICALL void GL_APIENTRY glEnableVertexAttribArray ( GLuint index ) ; <nl> + GL_APICALL void GL_APIENTRY glFinish ( void ) ; <nl> + GL_APICALL void GL_APIENTRY glFlush ( void ) ; <nl> + GL_APICALL void GL_APIENTRY glFramebufferRenderbuffer ( GLenum target , GLenum attachment , GLenum renderbuffertarget , GLuint renderbuffer ) ; <nl> + GL_APICALL void GL_APIENTRY glFramebufferTexture2D ( GLenum target , GLenum attachment , GLenum textarget , GLuint texture , GLint level ) ; <nl> + GL_APICALL void GL_APIENTRY glFrontFace ( GLenum mode ) ; <nl> + GL_APICALL void GL_APIENTRY glGenBuffers ( GLsizei n , GLuint * buffers ) ; <nl> + GL_APICALL void GL_APIENTRY glGenerateMipmap ( GLenum target ) ; <nl> + GL_APICALL void GL_APIENTRY glGenFramebuffers ( GLsizei n , GLuint * framebuffers ) ; <nl> + GL_APICALL void GL_APIENTRY glGenRenderbuffers ( GLsizei n , GLuint * renderbuffers ) ; <nl> + GL_APICALL void GL_APIENTRY glGenTextures ( GLsizei n , GLuint * textures ) ; <nl> + GL_APICALL void GL_APIENTRY glGetActiveAttrib ( GLuint program , GLuint index , GLsizei bufsize , GLsizei * length , GLint * size , GLenum * type , GLchar * name ) ; <nl> + GL_APICALL void GL_APIENTRY glGetActiveUniform ( GLuint program , GLuint index , GLsizei bufsize , GLsizei * length , GLint * size , GLenum * type , GLchar * name ) ; <nl> + GL_APICALL void GL_APIENTRY glGetAttachedShaders ( GLuint program , GLsizei maxcount , GLsizei * count , GLuint * shaders ) ; <nl> + GL_APICALL int GL_APIENTRY glGetAttribLocation ( GLuint program , const GLchar * name ) ; <nl> + GL_APICALL void GL_APIENTRY glGetBooleanv ( GLenum pname , GLboolean * params ) ; <nl> + GL_APICALL void GL_APIENTRY glGetBufferParameteriv ( GLenum target , GLenum pname , GLint * params ) ; <nl> + GL_APICALL GLenum GL_APIENTRY glGetError ( void ) ; <nl> + GL_APICALL void GL_APIENTRY glGetFloatv ( GLenum pname , GLfloat * params ) ; <nl> + GL_APICALL void GL_APIENTRY glGetFramebufferAttachmentParameteriv ( GLenum target , GLenum attachment , GLenum pname , GLint * params ) ; <nl> + GL_APICALL void GL_APIENTRY glGetIntegerv ( GLenum pname , GLint * params ) ; <nl> + GL_APICALL void GL_APIENTRY glGetProgramiv ( GLuint program , GLenum pname , GLint * params ) ; <nl> + GL_APICALL void GL_APIENTRY glGetProgramInfoLog ( GLuint program , GLsizei bufsize , GLsizei * length , GLchar * infolog ) ; <nl> + GL_APICALL void GL_APIENTRY glGetRenderbufferParameteriv ( GLenum target , GLenum pname , GLint * params ) ; <nl> + GL_APICALL void GL_APIENTRY glGetShaderiv ( GLuint shader , GLenum pname , GLint * params ) ; <nl> + GL_APICALL void GL_APIENTRY glGetShaderInfoLog ( GLuint shader , GLsizei bufsize , GLsizei * length , GLchar * infolog ) ; <nl> + GL_APICALL void GL_APIENTRY glGetShaderPrecisionFormat ( GLenum shadertype , GLenum precisiontype , GLint * range , GLint * precision ) ; <nl> + GL_APICALL void GL_APIENTRY glGetShaderSource ( GLuint shader , GLsizei bufsize , GLsizei * length , GLchar * source ) ; <nl> + GL_APICALL const GLubyte * GL_APIENTRY glGetString ( GLenum name ) ; <nl> + GL_APICALL void GL_APIENTRY glGetTexParameterfv ( GLenum target , GLenum pname , GLfloat * params ) ; <nl> + GL_APICALL void GL_APIENTRY glGetTexParameteriv ( GLenum target , GLenum pname , GLint * params ) ; <nl> + GL_APICALL void GL_APIENTRY glGetUniformfv ( GLuint program , GLint location , GLfloat * params ) ; <nl> + GL_APICALL void GL_APIENTRY glGetUniformiv ( GLuint program , GLint location , GLint * params ) ; <nl> + GL_APICALL int GL_APIENTRY glGetUniformLocation ( GLuint program , const GLchar * name ) ; <nl> + GL_APICALL void GL_APIENTRY glGetVertexAttribfv ( GLuint index , GLenum pname , GLfloat * params ) ; <nl> + GL_APICALL void GL_APIENTRY glGetVertexAttribiv ( GLuint index , GLenum pname , GLint * params ) ; <nl> + GL_APICALL void GL_APIENTRY glGetVertexAttribPointerv ( GLuint index , GLenum pname , GLvoid * * pointer ) ; <nl> + GL_APICALL void GL_APIENTRY glHint ( GLenum target , GLenum mode ) ; <nl> + GL_APICALL GLboolean GL_APIENTRY glIsBuffer ( GLuint buffer ) ; <nl> + GL_APICALL GLboolean GL_APIENTRY glIsEnabled ( GLenum cap ) ; <nl> + GL_APICALL GLboolean GL_APIENTRY glIsFramebuffer ( GLuint framebuffer ) ; <nl> + GL_APICALL GLboolean GL_APIENTRY glIsProgram ( GLuint program ) ; <nl> + GL_APICALL GLboolean GL_APIENTRY glIsRenderbuffer ( GLuint renderbuffer ) ; <nl> + GL_APICALL GLboolean GL_APIENTRY glIsShader ( GLuint shader ) ; <nl> + GL_APICALL GLboolean GL_APIENTRY glIsTexture ( GLuint texture ) ; <nl> + GL_APICALL void GL_APIENTRY glLineWidth ( GLfloat width ) ; <nl> + GL_APICALL void GL_APIENTRY glLinkProgram ( GLuint program ) ; <nl> + GL_APICALL void GL_APIENTRY glPixelStorei ( GLenum pname , GLint param ) ; <nl> + GL_APICALL void GL_APIENTRY glPolygonOffset ( GLfloat factor , GLfloat units ) ; <nl> + GL_APICALL void GL_APIENTRY glReadPixels ( GLint x , GLint y , GLsizei width , GLsizei height , GLenum format , GLenum type , GLvoid * pixels ) ; <nl> + GL_APICALL void GL_APIENTRY glReleaseShaderCompiler ( void ) ; <nl> + GL_APICALL void GL_APIENTRY glRenderbufferStorage ( GLenum target , GLenum internalformat , GLsizei width , GLsizei height ) ; <nl> + GL_APICALL void GL_APIENTRY glSampleCoverage ( GLclampf value , GLboolean invert ) ; <nl> + GL_APICALL void GL_APIENTRY glScissor ( GLint x , GLint y , GLsizei width , GLsizei height ) ; <nl> + GL_APICALL void GL_APIENTRY glShaderBinary ( GLsizei n , const GLuint * shaders , GLenum binaryformat , const GLvoid * binary , GLsizei length ) ; <nl> + GL_APICALL void GL_APIENTRY glShaderSource ( GLuint shader , GLsizei count , const GLchar * * string , const GLint * length ) ; <nl> + GL_APICALL void GL_APIENTRY glStencilFunc ( GLenum func , GLint ref , GLuint mask ) ; <nl> + GL_APICALL void GL_APIENTRY glStencilFuncSeparate ( GLenum face , GLenum func , GLint ref , GLuint mask ) ; <nl> + GL_APICALL void GL_APIENTRY glStencilMask ( GLuint mask ) ; <nl> + GL_APICALL void GL_APIENTRY glStencilMaskSeparate ( GLenum face , GLuint mask ) ; <nl> + GL_APICALL void GL_APIENTRY glStencilOp ( GLenum fail , GLenum zfail , GLenum zpass ) ; <nl> + GL_APICALL void GL_APIENTRY glStencilOpSeparate ( GLenum face , GLenum fail , GLenum zfail , GLenum zpass ) ; <nl> + GL_APICALL void GL_APIENTRY glTexImage2D ( GLenum target , GLint level , GLint internalformat , GLsizei width , GLsizei height , GLint border , GLenum format , GLenum type , const GLvoid * pixels ) ; <nl> + GL_APICALL void GL_APIENTRY glTexParameterf ( GLenum target , GLenum pname , GLfloat param ) ; <nl> + GL_APICALL void GL_APIENTRY glTexParameterfv ( GLenum target , GLenum pname , const GLfloat * params ) ; <nl> + GL_APICALL void GL_APIENTRY glTexParameteri ( GLenum target , GLenum pname , GLint param ) ; <nl> + GL_APICALL void GL_APIENTRY glTexParameteriv ( GLenum target , GLenum pname , const GLint * params ) ; <nl> + GL_APICALL void GL_APIENTRY glTexSubImage2D ( GLenum target , GLint level , GLint xoffset , GLint yoffset , GLsizei width , GLsizei height , GLenum format , GLenum type , const GLvoid * pixels ) ; <nl> + GL_APICALL void GL_APIENTRY glUniform1f ( GLint location , GLfloat x ) ; <nl> + GL_APICALL void GL_APIENTRY glUniform1fv ( GLint location , GLsizei count , const GLfloat * v ) ; <nl> + GL_APICALL void GL_APIENTRY glUniform1i ( GLint location , GLint x ) ; <nl> + GL_APICALL void GL_APIENTRY glUniform1iv ( GLint location , GLsizei count , const GLint * v ) ; <nl> + GL_APICALL void GL_APIENTRY glUniform2f ( GLint location , GLfloat x , GLfloat y ) ; <nl> + GL_APICALL void GL_APIENTRY glUniform2fv ( GLint location , GLsizei count , const GLfloat * v ) ; <nl> + GL_APICALL void GL_APIENTRY glUniform2i ( GLint location , GLint x , GLint y ) ; <nl> + GL_APICALL void GL_APIENTRY glUniform2iv ( GLint location , GLsizei count , const GLint * v ) ; <nl> + GL_APICALL void GL_APIENTRY glUniform3f ( GLint location , GLfloat x , GLfloat y , GLfloat z ) ; <nl> + GL_APICALL void GL_APIENTRY glUniform3fv ( GLint location , GLsizei count , const GLfloat * v ) ; <nl> + GL_APICALL void GL_APIENTRY glUniform3i ( GLint location , GLint x , GLint y , GLint z ) ; <nl> + GL_APICALL void GL_APIENTRY glUniform3iv ( GLint location , GLsizei count , const GLint * v ) ; <nl> + GL_APICALL void GL_APIENTRY glUniform4f ( GLint location , GLfloat x , GLfloat y , GLfloat z , GLfloat w ) ; <nl> + GL_APICALL void GL_APIENTRY glUniform4fv ( GLint location , GLsizei count , const GLfloat * v ) ; <nl> + GL_APICALL void GL_APIENTRY glUniform4i ( GLint location , GLint x , GLint y , GLint z , GLint w ) ; <nl> + GL_APICALL void GL_APIENTRY glUniform4iv ( GLint location , GLsizei count , const GLint * v ) ; <nl> + GL_APICALL void GL_APIENTRY glUniformMatrix2fv ( GLint location , GLsizei count , GLboolean transpose , const GLfloat * value ) ; <nl> + GL_APICALL void GL_APIENTRY glUniformMatrix3fv ( GLint location , GLsizei count , GLboolean transpose , const GLfloat * value ) ; <nl> + GL_APICALL void GL_APIENTRY glUniformMatrix4fv ( GLint location , GLsizei count , GLboolean transpose , const GLfloat * value ) ; <nl> + GL_APICALL void GL_APIENTRY glUseProgram ( GLuint program ) ; <nl> + GL_APICALL void GL_APIENTRY glValidateProgram ( GLuint program ) ; <nl> + GL_APICALL void GL_APIENTRY glVertexAttrib1f ( GLuint indx , GLfloat x ) ; <nl> + GL_APICALL void GL_APIENTRY glVertexAttrib1fv ( GLuint indx , const GLfloat * values ) ; <nl> + GL_APICALL void GL_APIENTRY glVertexAttrib2f ( GLuint indx , GLfloat x , GLfloat y ) ; <nl> + GL_APICALL void GL_APIENTRY glVertexAttrib2fv ( GLuint indx , const GLfloat * values ) ; <nl> + GL_APICALL void GL_APIENTRY glVertexAttrib3f ( GLuint indx , GLfloat x , GLfloat y , GLfloat z ) ; <nl> + GL_APICALL void GL_APIENTRY glVertexAttrib3fv ( GLuint indx , const GLfloat * values ) ; <nl> + GL_APICALL void GL_APIENTRY glVertexAttrib4f ( GLuint indx , GLfloat x , GLfloat y , GLfloat z , GLfloat w ) ; <nl> + GL_APICALL void GL_APIENTRY glVertexAttrib4fv ( GLuint indx , const GLfloat * values ) ; <nl> + GL_APICALL void GL_APIENTRY glVertexAttribPointer ( GLuint indx , GLint size , GLenum type , GLboolean normalized , GLsizei stride , const GLvoid * ptr ) ; <nl> + GL_APICALL void GL_APIENTRY glViewport ( GLint x , GLint y , GLsizei width , GLsizei height ) ; <nl> + <nl> + # ifdef __cplusplus <nl> + } <nl> + # endif <nl> + <nl> + # endif / * __gl2_h_ * / <nl> mmm a / cocos2dx / platform / third_party / win32 / OGLES / GLES2 / gl2ext . h <nl> ppp b / cocos2dx / platform / third_party / win32 / OGLES / GLES2 / gl2ext . h <nl> <nl> - # ifndef __gl2ext_h_ <nl> - # define __gl2ext_h_ <nl> - <nl> - # ifdef __cplusplus <nl> - extern " C " { <nl> - # endif <nl> - <nl> - / * <nl> - * This document is licensed under the SGI Free Software B License Version <nl> - * 2 . 0 . For details , see http : / / oss . sgi . com / projects / FreeB / . <nl> - * / <nl> - <nl> - # ifndef GL_APIENTRYP <nl> - # define GL_APIENTRYP GL_APIENTRY * <nl> - # endif <nl> - <nl> - / * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * <nl> - * OES extension tokens <nl> - * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * / <nl> - <nl> - / * GL_OES_compressed_ETC1_RGB8_texture * / <nl> - # ifndef GL_OES_compressed_ETC1_RGB8_texture <nl> - # define GL_ETC1_RGB8_OES 0x8D64 <nl> - # endif <nl> - <nl> - / * GL_OES_compressed_paletted_texture * / <nl> - # ifndef GL_OES_compressed_paletted_texture <nl> - # define GL_PALETTE4_RGB8_OES 0x8B90 <nl> - # define GL_PALETTE4_RGBA8_OES 0x8B91 <nl> - # define GL_PALETTE4_R5_G6_B5_OES 0x8B92 <nl> - # define GL_PALETTE4_RGBA4_OES 0x8B93 <nl> - # define GL_PALETTE4_RGB5_A1_OES 0x8B94 <nl> - # define GL_PALETTE8_RGB8_OES 0x8B95 <nl> - # define GL_PALETTE8_RGBA8_OES 0x8B96 <nl> - # define GL_PALETTE8_R5_G6_B5_OES 0x8B97 <nl> - # define GL_PALETTE8_RGBA4_OES 0x8B98 <nl> - # define GL_PALETTE8_RGB5_A1_OES 0x8B99 <nl> - # endif <nl> - <nl> - / * GL_OES_depth24 * / <nl> - # ifndef GL_OES_depth24 <nl> - # define GL_DEPTH_COMPONENT24_OES 0x81A6 <nl> - # endif <nl> - <nl> - / * GL_OES_depth32 * / <nl> - # ifndef GL_OES_depth32 <nl> - # define GL_DEPTH_COMPONENT32_OES 0x81A7 <nl> - # endif <nl> - <nl> - / * GL_OES_depth_texture * / <nl> - / * No new tokens introduced by this extension . * / <nl> - <nl> - / * GL_OES_EGL_image * / <nl> - # ifndef GL_OES_EGL_image <nl> - typedef void * GLeglImageOES ; <nl> - # endif <nl> - <nl> - / * GL_OES_EGL_image_external * / <nl> - # ifndef GL_OES_EGL_image_external <nl> - / * GLeglImageOES defined in GL_OES_EGL_image already . * / <nl> - # define GL_TEXTURE_EXTERNAL_OES 0x8D65 <nl> - # define GL_SAMPLER_EXTERNAL_OES 0x8D66 <nl> - # define GL_TEXTURE_BINDING_EXTERNAL_OES 0x8D67 <nl> - # define GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES 0x8D68 <nl> - # endif <nl> - <nl> - / * GL_OES_element_index_uint * / <nl> - # ifndef GL_OES_element_index_uint <nl> - # define GL_UNSIGNED_INT 0x1405 <nl> - # endif <nl> - <nl> - / * GL_OES_get_program_binary * / <nl> - # ifndef GL_OES_get_program_binary <nl> - # define GL_PROGRAM_BINARY_LENGTH_OES 0x8741 <nl> - # define GL_NUM_PROGRAM_BINARY_FORMATS_OES 0x87FE <nl> - # define GL_PROGRAM_BINARY_FORMATS_OES 0x87FF <nl> - # endif <nl> - <nl> - / * GL_OES_mapbuffer * / <nl> - # ifndef GL_OES_mapbuffer <nl> - # define GL_WRITE_ONLY_OES 0x88B9 <nl> - # define GL_BUFFER_ACCESS_OES 0x88BB <nl> - # define GL_BUFFER_MAPPED_OES 0x88BC <nl> - # define GL_BUFFER_MAP_POINTER_OES 0x88BD <nl> - # endif <nl> - <nl> - / * GL_OES_packed_depth_stencil * / <nl> - # ifndef GL_OES_packed_depth_stencil <nl> - # define GL_DEPTH_STENCIL_OES 0x84F9 <nl> - # define GL_UNSIGNED_INT_24_8_OES 0x84FA <nl> - # define GL_DEPTH24_STENCIL8_OES 0x88F0 <nl> - # endif <nl> - <nl> - / * GL_OES_rgb8_rgba8 * / <nl> - # ifndef GL_OES_rgb8_rgba8 <nl> - # define GL_RGB8_OES 0x8051 <nl> - # define GL_RGBA8_OES 0x8058 <nl> - # endif <nl> - <nl> - / * GL_OES_standard_derivatives * / <nl> - # ifndef GL_OES_standard_derivatives <nl> - # define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES 0x8B8B <nl> - # endif <nl> - <nl> - / * GL_OES_stencil1 * / <nl> - # ifndef GL_OES_stencil1 <nl> - # define GL_STENCIL_INDEX1_OES 0x8D46 <nl> - # endif <nl> - <nl> - / * GL_OES_stencil4 * / <nl> - # ifndef GL_OES_stencil4 <nl> - # define GL_STENCIL_INDEX4_OES 0x8D47 <nl> - # endif <nl> - <nl> - / * GL_OES_texture_3D * / <nl> - # ifndef GL_OES_texture_3D <nl> - # define GL_TEXTURE_WRAP_R_OES 0x8072 <nl> - # define GL_TEXTURE_3D_OES 0x806F <nl> - # define GL_TEXTURE_BINDING_3D_OES 0x806A <nl> - # define GL_MAX_3D_TEXTURE_SIZE_OES 0x8073 <nl> - # define GL_SAMPLER_3D_OES 0x8B5F <nl> - # define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_OES 0x8CD4 <nl> - # endif <nl> - <nl> - / * GL_OES_texture_float * / <nl> - / * No new tokens introduced by this extension . * / <nl> - <nl> - / * GL_OES_texture_float_linear * / <nl> - / * No new tokens introduced by this extension . * / <nl> - <nl> - / * GL_OES_texture_half_float * / <nl> - # ifndef GL_OES_texture_half_float <nl> - # define GL_HALF_FLOAT_OES 0x8D61 <nl> - # endif <nl> - <nl> - / * GL_OES_texture_half_float_linear * / <nl> - / * No new tokens introduced by this extension . * / <nl> - <nl> - / * GL_OES_texture_npot * / <nl> - / * No new tokens introduced by this extension . * / <nl> - <nl> - / * GL_OES_vertex_array_object * / <nl> - # ifndef GL_OES_vertex_array_object <nl> - # define GL_VERTEX_ARRAY_BINDING_OES 0x85B5 <nl> - # endif <nl> - <nl> - / * GL_OES_vertex_half_float * / <nl> - / * GL_HALF_FLOAT_OES defined in GL_OES_texture_half_float already . * / <nl> - <nl> - / * GL_OES_vertex_type_10_10_10_2 * / <nl> - # ifndef GL_OES_vertex_type_10_10_10_2 <nl> - # define GL_UNSIGNED_INT_10_10_10_2_OES 0x8DF6 <nl> - # define GL_INT_10_10_10_2_OES 0x8DF7 <nl> - # endif <nl> - <nl> - / * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * <nl> - * AMD extension tokens <nl> - * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * / <nl> - <nl> - / * GL_AMD_compressed_3DC_texture * / <nl> - # ifndef GL_AMD_compressed_3DC_texture <nl> - # define GL_3DC_X_AMD 0x87F9 <nl> - # define GL_3DC_XY_AMD 0x87FA <nl> - # endif <nl> - <nl> - / * GL_AMD_compressed_ATC_texture * / <nl> - # ifndef GL_AMD_compressed_ATC_texture <nl> - # define GL_ATC_RGB_AMD 0x8C92 <nl> - # define GL_ATC_RGBA_EXPLICIT_ALPHA_AMD 0x8C93 <nl> - # define GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD 0x87EE <nl> - # endif <nl> - <nl> - / * GL_AMD_performance_monitor * / <nl> - # ifndef GL_AMD_performance_monitor <nl> - # define GL_COUNTER_TYPE_AMD 0x8BC0 <nl> - # define GL_COUNTER_RANGE_AMD 0x8BC1 <nl> - # define GL_UNSIGNED_INT64_AMD 0x8BC2 <nl> - # define GL_PERCENTAGE_AMD 0x8BC3 <nl> - # define GL_PERFMON_RESULT_AVAILABLE_AMD 0x8BC4 <nl> - # define GL_PERFMON_RESULT_SIZE_AMD 0x8BC5 <nl> - # define GL_PERFMON_RESULT_AMD 0x8BC6 <nl> - # endif <nl> - <nl> - / * GL_AMD_program_binary_Z400 * / <nl> - # ifndef GL_AMD_program_binary_Z400 <nl> - # define GL_Z400_BINARY_AMD 0x8740 <nl> - # endif <nl> - <nl> - / * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * <nl> - * ANGLE extension tokens <nl> - * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * / <nl> - <nl> - / * GL_ANGLE_framebuffer_blit * / <nl> - # ifndef GL_ANGLE_framebuffer_blit <nl> - # define GL_READ_FRAMEBUFFER_ANGLE 0x8CA8 <nl> - # define GL_DRAW_FRAMEBUFFER_ANGLE 0x8CA9 <nl> - # define GL_DRAW_FRAMEBUFFER_BINDING_ANGLE 0x8CA6 <nl> - # define GL_READ_FRAMEBUFFER_BINDING_ANGLE 0x8CAA <nl> - # endif <nl> - <nl> - / * GL_ANGLE_framebuffer_multisample * / <nl> - # ifndef GL_ANGLE_framebuffer_multisample <nl> - # define GL_RENDERBUFFER_SAMPLES_ANGLE 0x8CAB <nl> - # define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_ANGLE 0x8D56 <nl> - # define GL_MAX_SAMPLES_ANGLE 0x8D57 <nl> - # endif <nl> - <nl> - / * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * <nl> - * APPLE extension tokens <nl> - * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * / <nl> - <nl> - / * GL_APPLE_rgb_422 * / <nl> - # ifndef GL_APPLE_rgb_422 <nl> - # define GL_RGB_422_APPLE 0x8A1F <nl> - # define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA <nl> - # define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB <nl> - # endif <nl> - <nl> - / * GL_APPLE_framebuffer_multisample * / <nl> - # ifndef GL_APPLE_framebuffer_multisample <nl> - # define GL_RENDERBUFFER_SAMPLES_APPLE 0x8CAB <nl> - # define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_APPLE 0x8D56 <nl> - # define GL_MAX_SAMPLES_APPLE 0x8D57 <nl> - # define GL_READ_FRAMEBUFFER_APPLE 0x8CA8 <nl> - # define GL_DRAW_FRAMEBUFFER_APPLE 0x8CA9 <nl> - # define GL_DRAW_FRAMEBUFFER_BINDING_APPLE 0x8CA6 <nl> - # define GL_READ_FRAMEBUFFER_BINDING_APPLE 0x8CAA <nl> - # endif <nl> - <nl> - / * GL_APPLE_texture_format_BGRA8888 * / <nl> - # ifndef GL_APPLE_texture_format_BGRA8888 <nl> - # define GL_BGRA_EXT 0x80E1 <nl> - # endif <nl> - <nl> - / * GL_APPLE_texture_max_level * / <nl> - # ifndef GL_APPLE_texture_max_level <nl> - # define GL_TEXTURE_MAX_LEVEL_APPLE 0x813D <nl> - # endif <nl> - <nl> - / * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * <nl> - * ARM extension tokens <nl> - * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * / <nl> - <nl> - / * GL_ARM_mali_shader_binary * / <nl> - # ifndef GL_ARM_mali_shader_binary <nl> - # define GL_MALI_SHADER_BINARY_ARM 0x8F60 <nl> - # endif <nl> - <nl> - / * GL_ARM_rgba8 * / <nl> - / * No new tokens introduced by this extension . * / <nl> - <nl> - / * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * <nl> - * EXT extension tokens <nl> - * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * / <nl> - <nl> - / * GL_EXT_blend_minmax * / <nl> - # ifndef GL_EXT_blend_minmax <nl> - # define GL_MIN_EXT 0x8007 <nl> - # define GL_MAX_EXT 0x8008 <nl> - # endif <nl> - <nl> - / * GL_EXT_discard_framebuffer * / <nl> - # ifndef GL_EXT_discard_framebuffer <nl> - # define GL_COLOR_EXT 0x1800 <nl> - # define GL_DEPTH_EXT 0x1801 <nl> - # define GL_STENCIL_EXT 0x1802 <nl> - # endif <nl> - <nl> - / * GL_EXT_multi_draw_arrays * / <nl> - / * No new tokens introduced by this extension . * / <nl> - <nl> - / * GL_EXT_read_format_bgra * / <nl> - # ifndef GL_EXT_read_format_bgra <nl> - # define GL_BGRA_EXT 0x80E1 <nl> - # define GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT 0x8365 <nl> - # define GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT 0x8366 <nl> - # endif <nl> - <nl> - / * GL_EXT_texture_filter_anisotropic * / <nl> - # ifndef GL_EXT_texture_filter_anisotropic <nl> - # define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE <nl> - # define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF <nl> - # endif <nl> - <nl> - / * GL_EXT_texture_format_BGRA8888 * / <nl> - # ifndef GL_EXT_texture_format_BGRA8888 <nl> - # define GL_BGRA_EXT 0x80E1 <nl> - # endif <nl> - <nl> - / * GL_EXT_texture_type_2_10_10_10_REV * / <nl> - # ifndef GL_EXT_texture_type_2_10_10_10_REV <nl> - # define GL_UNSIGNED_INT_2_10_10_10_REV_EXT 0x8368 <nl> - # endif <nl> - <nl> - / * GL_EXT_texture_compression_dxt1 * / <nl> - # ifndef GL_EXT_texture_compression_dxt1 <nl> - # define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 <nl> - # define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 <nl> - # endif <nl> - <nl> - / * GL_EXT_shader_texture_lod * / <nl> - / * No new tokens introduced by this extension . * / <nl> - <nl> - / * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * <nl> - * IMG extension tokens <nl> - * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * / <nl> - <nl> - / * GL_IMG_program_binary * / <nl> - # ifndef GL_IMG_program_binary <nl> - # define GL_SGX_PROGRAM_BINARY_IMG 0x9130 <nl> - # endif <nl> - <nl> - / * GL_IMG_read_format * / <nl> - # ifndef GL_IMG_read_format <nl> - # define GL_BGRA_IMG 0x80E1 <nl> - # define GL_UNSIGNED_SHORT_4_4_4_4_REV_IMG 0x8365 <nl> - # endif <nl> - <nl> - / * GL_IMG_shader_binary * / <nl> - # ifndef GL_IMG_shader_binary <nl> - # define GL_SGX_BINARY_IMG 0x8C0A <nl> - # endif <nl> - <nl> - / * GL_IMG_texture_compression_pvrtc * / <nl> - # ifndef GL_IMG_texture_compression_pvrtc <nl> - # define GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG 0x8C00 <nl> - # define GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG 0x8C01 <nl> - # define GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG 0x8C02 <nl> - # define GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG 0x8C03 <nl> - # endif <nl> - <nl> - / * GL_IMG_multisampled_render_to_texture * / <nl> - # ifndef GL_IMG_multisampled_render_to_texture <nl> - # define GL_RENDERBUFFER_SAMPLES_IMG 0x9133 <nl> - # define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_IMG 0x9134 <nl> - # define GL_MAX_SAMPLES_IMG 0x9135 <nl> - # define GL_TEXTURE_SAMPLES_IMG 0x9136 <nl> - # endif <nl> - <nl> - / * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * <nl> - * NV extension tokens <nl> - * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * / <nl> - <nl> - / * GL_NV_fence * / <nl> - # ifndef GL_NV_fence <nl> - # define GL_ALL_COMPLETED_NV 0x84F2 <nl> - # define GL_FENCE_STATUS_NV 0x84F3 <nl> - # define GL_FENCE_CONDITION_NV 0x84F4 <nl> - # endif <nl> - <nl> - / * GL_NV_coverage_sample * / <nl> - # ifndef GL_NV_coverage_sample <nl> - # define GL_COVERAGE_COMPONENT_NV 0x8ED0 <nl> - # define GL_COVERAGE_COMPONENT4_NV 0x8ED1 <nl> - # define GL_COVERAGE_ATTACHMENT_NV 0x8ED2 <nl> - # define GL_COVERAGE_BUFFERS_NV 0x8ED3 <nl> - # define GL_COVERAGE_SAMPLES_NV 0x8ED4 <nl> - # define GL_COVERAGE_ALL_FRAGMENTS_NV 0x8ED5 <nl> - # define GL_COVERAGE_EDGE_FRAGMENTS_NV 0x8ED6 <nl> - # define GL_COVERAGE_AUTOMATIC_NV 0x8ED7 <nl> - # define GL_COVERAGE_BUFFER_BIT_NV 0x8000 <nl> - # endif <nl> - <nl> - / * GL_NV_depth_nonlinear * / <nl> - # ifndef GL_NV_depth_nonlinear <nl> - # define GL_DEPTH_COMPONENT16_NONLINEAR_NV 0x8E2C <nl> - # endif <nl> - <nl> - / * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * <nl> - * QCOM extension tokens <nl> - * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * / <nl> - <nl> - / * GL_QCOM_driver_control * / <nl> - / * No new tokens introduced by this extension . * / <nl> - <nl> - / * GL_QCOM_extended_get * / <nl> - # ifndef GL_QCOM_extended_get <nl> - # define GL_TEXTURE_WIDTH_QCOM 0x8BD2 <nl> - # define GL_TEXTURE_HEIGHT_QCOM 0x8BD3 <nl> - # define GL_TEXTURE_DEPTH_QCOM 0x8BD4 <nl> - # define GL_TEXTURE_INTERNAL_FORMAT_QCOM 0x8BD5 <nl> - # define GL_TEXTURE_FORMAT_QCOM 0x8BD6 <nl> - # define GL_TEXTURE_TYPE_QCOM 0x8BD7 <nl> - # define GL_TEXTURE_IMAGE_VALID_QCOM 0x8BD8 <nl> - # define GL_TEXTURE_NUM_LEVELS_QCOM 0x8BD9 <nl> - # define GL_TEXTURE_TARGET_QCOM 0x8BDA <nl> - # define GL_TEXTURE_OBJECT_VALID_QCOM 0x8BDB <nl> - # define GL_STATE_RESTORE 0x8BDC <nl> - # endif <nl> - <nl> - / * GL_QCOM_extended_get2 * / <nl> - / * No new tokens introduced by this extension . * / <nl> - <nl> - / * GL_QCOM_perfmon_global_mode * / <nl> - # ifndef GL_QCOM_perfmon_global_mode <nl> - # define GL_PERFMON_GLOBAL_MODE_QCOM 0x8FA0 <nl> - # endif <nl> - <nl> - / * GL_QCOM_writeonly_rendering * / <nl> - # ifndef GL_QCOM_writeonly_rendering <nl> - # define GL_WRITEONLY_RENDERING_QCOM 0x8823 <nl> - # endif <nl> - <nl> - / * GL_QCOM_tiled_rendering * / <nl> - # ifndef GL_QCOM_tiled_rendering <nl> - # define GL_COLOR_BUFFER_BIT0_QCOM 0x00000001 <nl> - # define GL_COLOR_BUFFER_BIT1_QCOM 0x00000002 <nl> - # define GL_COLOR_BUFFER_BIT2_QCOM 0x00000004 <nl> - # define GL_COLOR_BUFFER_BIT3_QCOM 0x00000008 <nl> - # define GL_COLOR_BUFFER_BIT4_QCOM 0x00000010 <nl> - # define GL_COLOR_BUFFER_BIT5_QCOM 0x00000020 <nl> - # define GL_COLOR_BUFFER_BIT6_QCOM 0x00000040 <nl> - # define GL_COLOR_BUFFER_BIT7_QCOM 0x00000080 <nl> - # define GL_DEPTH_BUFFER_BIT0_QCOM 0x00000100 <nl> - # define GL_DEPTH_BUFFER_BIT1_QCOM 0x00000200 <nl> - # define GL_DEPTH_BUFFER_BIT2_QCOM 0x00000400 <nl> - # define GL_DEPTH_BUFFER_BIT3_QCOM 0x00000800 <nl> - # define GL_DEPTH_BUFFER_BIT4_QCOM 0x00001000 <nl> - # define GL_DEPTH_BUFFER_BIT5_QCOM 0x00002000 <nl> - # define GL_DEPTH_BUFFER_BIT6_QCOM 0x00004000 <nl> - # define GL_DEPTH_BUFFER_BIT7_QCOM 0x00008000 <nl> - # define GL_STENCIL_BUFFER_BIT0_QCOM 0x00010000 <nl> - # define GL_STENCIL_BUFFER_BIT1_QCOM 0x00020000 <nl> - # define GL_STENCIL_BUFFER_BIT2_QCOM 0x00040000 <nl> - # define GL_STENCIL_BUFFER_BIT3_QCOM 0x00080000 <nl> - # define GL_STENCIL_BUFFER_BIT4_QCOM 0x00100000 <nl> - # define GL_STENCIL_BUFFER_BIT5_QCOM 0x00200000 <nl> - # define GL_STENCIL_BUFFER_BIT6_QCOM 0x00400000 <nl> - # define GL_STENCIL_BUFFER_BIT7_QCOM 0x00800000 <nl> - # define GL_MULTISAMPLE_BUFFER_BIT0_QCOM 0x01000000 <nl> - # define GL_MULTISAMPLE_BUFFER_BIT1_QCOM 0x02000000 <nl> - # define GL_MULTISAMPLE_BUFFER_BIT2_QCOM 0x04000000 <nl> - # define GL_MULTISAMPLE_BUFFER_BIT3_QCOM 0x08000000 <nl> - # define GL_MULTISAMPLE_BUFFER_BIT4_QCOM 0x10000000 <nl> - # define GL_MULTISAMPLE_BUFFER_BIT5_QCOM 0x20000000 <nl> - # define GL_MULTISAMPLE_BUFFER_BIT6_QCOM 0x40000000 <nl> - # define GL_MULTISAMPLE_BUFFER_BIT7_QCOM 0x80000000 <nl> - # endif <nl> - <nl> - / * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * <nl> - * VIV extension tokens <nl> - * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * / <nl> - <nl> - / * GL_VIV_shader_binary * / <nl> - # ifndef GL_VIV_shader_binary <nl> - # define GL_SHADER_BINARY_VIV 0x8FC4 <nl> - # endif <nl> - <nl> - / * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * <nl> - * End of extension tokens , start of corresponding extension functions <nl> - * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * / <nl> - <nl> - / * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * <nl> - * OES extension functions <nl> - * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * / <nl> - <nl> - / * GL_OES_compressed_ETC1_RGB8_texture * / <nl> - # ifndef GL_OES_compressed_ETC1_RGB8_texture <nl> - # define GL_OES_compressed_ETC1_RGB8_texture 1 <nl> - # endif <nl> - <nl> - / * GL_OES_compressed_paletted_texture * / <nl> - # ifndef GL_OES_compressed_paletted_texture <nl> - # define GL_OES_compressed_paletted_texture 1 <nl> - # endif <nl> - <nl> - / * GL_OES_depth24 * / <nl> - # ifndef GL_OES_depth24 <nl> - # define GL_OES_depth24 1 <nl> - # endif <nl> - <nl> - / * GL_OES_depth32 * / <nl> - # ifndef GL_OES_depth32 <nl> - # define GL_OES_depth32 1 <nl> - # endif <nl> - <nl> - / * GL_OES_depth_texture * / <nl> - # ifndef GL_OES_depth_texture <nl> - # define GL_OES_depth_texture 1 <nl> - # endif <nl> - <nl> - / * GL_OES_EGL_image * / <nl> - # ifndef GL_OES_EGL_image <nl> - # define GL_OES_EGL_image 1 <nl> - # ifdef GL_GLEXT_PROTOTYPES <nl> - GL_APICALL void GL_APIENTRY glEGLImageTargetTexture2DOES ( GLenum target , GLeglImageOES image ) ; <nl> - GL_APICALL void GL_APIENTRY glEGLImageTargetRenderbufferStorageOES ( GLenum target , GLeglImageOES image ) ; <nl> - # endif <nl> - typedef void ( GL_APIENTRYP PFNGLEGLIMAGETARGETTEXTURE2DOESPROC ) ( GLenum target , GLeglImageOES image ) ; <nl> - typedef void ( GL_APIENTRYP PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC ) ( GLenum target , GLeglImageOES image ) ; <nl> - # endif <nl> - <nl> - / * GL_OES_EGL_image_external * / <nl> - # ifndef GL_OES_EGL_image_external <nl> - # define GL_OES_EGL_image_external 1 <nl> - / * glEGLImageTargetTexture2DOES defined in GL_OES_EGL_image already . * / <nl> - # endif <nl> - <nl> - / * GL_OES_element_index_uint * / <nl> - # ifndef GL_OES_element_index_uint <nl> - # define GL_OES_element_index_uint 1 <nl> - # endif <nl> - <nl> - / * GL_OES_fbo_render_mipmap * / <nl> - # ifndef GL_OES_fbo_render_mipmap <nl> - # define GL_OES_fbo_render_mipmap 1 <nl> - # endif <nl> - <nl> - / * GL_OES_fragment_precision_high * / <nl> - # ifndef GL_OES_fragment_precision_high <nl> - # define GL_OES_fragment_precision_high 1 <nl> - # endif <nl> - <nl> - / * GL_OES_get_program_binary * / <nl> - # ifndef GL_OES_get_program_binary <nl> - # define GL_OES_get_program_binary 1 <nl> - # ifdef GL_GLEXT_PROTOTYPES <nl> - GL_APICALL void GL_APIENTRY glGetProgramBinaryOES ( GLuint program , GLsizei bufSize , GLsizei * length , GLenum * binaryFormat , GLvoid * binary ) ; <nl> - GL_APICALL void GL_APIENTRY glProgramBinaryOES ( GLuint program , GLenum binaryFormat , const GLvoid * binary , GLint length ) ; <nl> - # endif <nl> - typedef void ( GL_APIENTRYP PFNGLGETPROGRAMBINARYOESPROC ) ( GLuint program , GLsizei bufSize , GLsizei * length , GLenum * binaryFormat , GLvoid * binary ) ; <nl> - typedef void ( GL_APIENTRYP PFNGLPROGRAMBINARYOESPROC ) ( GLuint program , GLenum binaryFormat , const GLvoid * binary , GLint length ) ; <nl> - # endif <nl> - <nl> - / * GL_OES_mapbuffer * / <nl> - # ifndef GL_OES_mapbuffer <nl> - # define GL_OES_mapbuffer 1 <nl> - # ifdef GL_GLEXT_PROTOTYPES <nl> - GL_APICALL void * GL_APIENTRY glMapBufferOES ( GLenum target , GLenum access ) ; <nl> - GL_APICALL GLboolean GL_APIENTRY glUnmapBufferOES ( GLenum target ) ; <nl> - GL_APICALL void GL_APIENTRY glGetBufferPointervOES ( GLenum target , GLenum pname , GLvoid * * params ) ; <nl> - # endif <nl> - typedef void * ( GL_APIENTRYP PFNGLMAPBUFFEROESPROC ) ( GLenum target , GLenum access ) ; <nl> - typedef GLboolean ( GL_APIENTRYP PFNGLUNMAPBUFFEROESPROC ) ( GLenum target ) ; <nl> - typedef void ( GL_APIENTRYP PFNGLGETBUFFERPOINTERVOESPROC ) ( GLenum target , GLenum pname , GLvoid * * params ) ; <nl> - # endif <nl> - <nl> - / * GL_OES_packed_depth_stencil * / <nl> - # ifndef GL_OES_packed_depth_stencil <nl> - # define GL_OES_packed_depth_stencil 1 <nl> - # endif <nl> - <nl> - / * GL_OES_rgb8_rgba8 * / <nl> - # ifndef GL_OES_rgb8_rgba8 <nl> - # define GL_OES_rgb8_rgba8 1 <nl> - # endif <nl> - <nl> - / * GL_OES_standard_derivatives * / <nl> - # ifndef GL_OES_standard_derivatives <nl> - # define GL_OES_standard_derivatives 1 <nl> - # endif <nl> - <nl> - / * GL_OES_stencil1 * / <nl> - # ifndef GL_OES_stencil1 <nl> - # define GL_OES_stencil1 1 <nl> - # endif <nl> - <nl> - / * GL_OES_stencil4 * / <nl> - # ifndef GL_OES_stencil4 <nl> - # define GL_OES_stencil4 1 <nl> - # endif <nl> - <nl> - / * GL_OES_texture_3D * / <nl> - # ifndef GL_OES_texture_3D <nl> - # define GL_OES_texture_3D 1 <nl> - # ifdef GL_GLEXT_PROTOTYPES <nl> - GL_APICALL void GL_APIENTRY glTexImage3DOES ( GLenum target , GLint level , GLenum internalformat , GLsizei width , GLsizei height , GLsizei depth , GLint border , GLenum format , GLenum type , const GLvoid * pixels ) ; <nl> - GL_APICALL void GL_APIENTRY glTexSubImage3DOES ( GLenum target , GLint level , GLint xoffset , GLint yoffset , GLint zoffset , GLsizei width , GLsizei height , GLsizei depth , GLenum format , GLenum type , const GLvoid * pixels ) ; <nl> - GL_APICALL void GL_APIENTRY glCopyTexSubImage3DOES ( GLenum target , GLint level , GLint xoffset , GLint yoffset , GLint zoffset , GLint x , GLint y , GLsizei width , GLsizei height ) ; <nl> - GL_APICALL void GL_APIENTRY glCompressedTexImage3DOES ( GLenum target , GLint level , GLenum internalformat , GLsizei width , GLsizei height , GLsizei depth , GLint border , GLsizei imageSize , const GLvoid * data ) ; <nl> - GL_APICALL void GL_APIENTRY glCompressedTexSubImage3DOES ( GLenum target , GLint level , GLint xoffset , GLint yoffset , GLint zoffset , GLsizei width , GLsizei height , GLsizei depth , GLenum format , GLsizei imageSize , const GLvoid * data ) ; <nl> - GL_APICALL void GL_APIENTRY glFramebufferTexture3DOES ( GLenum target , GLenum attachment , GLenum textarget , GLuint texture , GLint level , GLint zoffset ) ; <nl> - # endif <nl> - typedef void ( GL_APIENTRYP PFNGLTEXIMAGE3DOESPROC ) ( GLenum target , GLint level , GLenum internalformat , GLsizei width , GLsizei height , GLsizei depth , GLint border , GLenum format , GLenum type , const GLvoid * pixels ) ; <nl> - typedef void ( GL_APIENTRYP PFNGLTEXSUBIMAGE3DOESPROC ) ( GLenum target , GLint level , GLint xoffset , GLint yoffset , GLint zoffset , GLsizei width , GLsizei height , GLsizei depth , GLenum format , GLenum type , const GLvoid * pixels ) ; <nl> - typedef void ( GL_APIENTRYP PFNGLCOPYTEXSUBIMAGE3DOESPROC ) ( GLenum target , GLint level , GLint xoffset , GLint yoffset , GLint zoffset , GLint x , GLint y , GLsizei width , GLsizei height ) ; <nl> - typedef void ( GL_APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DOESPROC ) ( GLenum target , GLint level , GLenum internalformat , GLsizei width , GLsizei height , GLsizei depth , GLint border , GLsizei imageSize , const GLvoid * data ) ; <nl> - typedef void ( GL_APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DOESPROC ) ( GLenum target , GLint level , GLint xoffset , GLint yoffset , GLint zoffset , GLsizei width , GLsizei height , GLsizei depth , GLenum format , GLsizei imageSize , const GLvoid * data ) ; <nl> - typedef void ( GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DOES ) ( GLenum target , GLenum attachment , GLenum textarget , GLuint texture , GLint level , GLint zoffset ) ; <nl> - # endif <nl> - <nl> - / * GL_OES_texture_float * / <nl> - # ifndef GL_OES_texture_float <nl> - # define GL_OES_texture_float 1 <nl> - # endif <nl> - <nl> - / * GL_OES_texture_float_linear * / <nl> - # ifndef GL_OES_texture_float_linear <nl> - # define GL_OES_texture_float_linear 1 <nl> - # endif <nl> - <nl> - / * GL_OES_texture_half_float * / <nl> - # ifndef GL_OES_texture_half_float <nl> - # define GL_OES_texture_half_float 1 <nl> - # endif <nl> - <nl> - / * GL_OES_texture_half_float_linear * / <nl> - # ifndef GL_OES_texture_half_float_linear <nl> - # define GL_OES_texture_half_float_linear 1 <nl> - # endif <nl> - <nl> - / * GL_OES_texture_npot * / <nl> - # ifndef GL_OES_texture_npot <nl> - # define GL_OES_texture_npot 1 <nl> - # endif <nl> - <nl> - / * GL_OES_vertex_array_object * / <nl> - # ifndef GL_OES_vertex_array_object <nl> - # define GL_OES_vertex_array_object 1 <nl> - # ifdef GL_GLEXT_PROTOTYPES <nl> - GL_APICALL void GL_APIENTRY glBindVertexArrayOES ( GLuint array ) ; <nl> - GL_APICALL void GL_APIENTRY glDeleteVertexArraysOES ( GLsizei n , const GLuint * arrays ) ; <nl> - GL_APICALL void GL_APIENTRY glGenVertexArraysOES ( GLsizei n , GLuint * arrays ) ; <nl> - GL_APICALL GLboolean GL_APIENTRY glIsVertexArrayOES ( GLuint array ) ; <nl> - # endif <nl> - typedef void ( GL_APIENTRYP PFNGLBINDVERTEXARRAYOESPROC ) ( GLuint array ) ; <nl> - typedef void ( GL_APIENTRYP PFNGLDELETEVERTEXARRAYSOESPROC ) ( GLsizei n , const GLuint * arrays ) ; <nl> - typedef void ( GL_APIENTRYP PFNGLGENVERTEXARRAYSOESPROC ) ( GLsizei n , GLuint * arrays ) ; <nl> - typedef GLboolean ( GL_APIENTRYP PFNGLISVERTEXARRAYOESPROC ) ( GLuint array ) ; <nl> - # endif <nl> - <nl> - / * GL_OES_vertex_half_float * / <nl> - # ifndef GL_OES_vertex_half_float <nl> - # define GL_OES_vertex_half_float 1 <nl> - # endif <nl> - <nl> - / * GL_OES_vertex_type_10_10_10_2 * / <nl> - # ifndef GL_OES_vertex_type_10_10_10_2 <nl> - # define GL_OES_vertex_type_10_10_10_2 1 <nl> - # endif <nl> - <nl> - / * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * <nl> - * AMD extension functions <nl> - * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * / <nl> - <nl> - / * GL_AMD_compressed_3DC_texture * / <nl> - # ifndef GL_AMD_compressed_3DC_texture <nl> - # define GL_AMD_compressed_3DC_texture 1 <nl> - # endif <nl> - <nl> - / * GL_AMD_compressed_ATC_texture * / <nl> - # ifndef GL_AMD_compressed_ATC_texture <nl> - # define GL_AMD_compressed_ATC_texture 1 <nl> - # endif <nl> - <nl> - / * AMD_performance_monitor * / <nl> - # ifndef GL_AMD_performance_monitor <nl> - # define GL_AMD_performance_monitor 1 <nl> - # ifdef GL_GLEXT_PROTOTYPES <nl> - GL_APICALL void GL_APIENTRY glGetPerfMonitorGroupsAMD ( GLint * numGroups , GLsizei groupsSize , GLuint * groups ) ; <nl> - GL_APICALL void GL_APIENTRY glGetPerfMonitorCountersAMD ( GLuint group , GLint * numCounters , GLint * maxActiveCounters , GLsizei counterSize , GLuint * counters ) ; <nl> - GL_APICALL void GL_APIENTRY glGetPerfMonitorGroupStringAMD ( GLuint group , GLsizei bufSize , GLsizei * length , char * groupString ) ; <nl> - GL_APICALL void GL_APIENTRY glGetPerfMonitorCounterStringAMD ( GLuint group , GLuint counter , GLsizei bufSize , GLsizei * length , char * counterString ) ; <nl> - GL_APICALL void GL_APIENTRY glGetPerfMonitorCounterInfoAMD ( GLuint group , GLuint counter , GLenum pname , GLvoid * data ) ; <nl> - GL_APICALL void GL_APIENTRY glGenPerfMonitorsAMD ( GLsizei n , GLuint * monitors ) ; <nl> - GL_APICALL void GL_APIENTRY glDeletePerfMonitorsAMD ( GLsizei n , GLuint * monitors ) ; <nl> - GL_APICALL void GL_APIENTRY glSelectPerfMonitorCountersAMD ( GLuint monitor , GLboolean enable , GLuint group , GLint numCounters , GLuint * countersList ) ; <nl> - GL_APICALL void GL_APIENTRY glBeginPerfMonitorAMD ( GLuint monitor ) ; <nl> - GL_APICALL void GL_APIENTRY glEndPerfMonitorAMD ( GLuint monitor ) ; <nl> - GL_APICALL void GL_APIENTRY glGetPerfMonitorCounterDataAMD ( GLuint monitor , GLenum pname , GLsizei dataSize , GLuint * data , GLint * bytesWritten ) ; <nl> - # endif <nl> - typedef void ( GL_APIENTRYP PFNGLGETPERFMONITORGROUPSAMDPROC ) ( GLint * numGroups , GLsizei groupsSize , GLuint * groups ) ; <nl> - typedef void ( GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERSAMDPROC ) ( GLuint group , GLint * numCounters , GLint * maxActiveCounters , GLsizei counterSize , GLuint * counters ) ; <nl> - typedef void ( GL_APIENTRYP PFNGLGETPERFMONITORGROUPSTRINGAMDPROC ) ( GLuint group , GLsizei bufSize , GLsizei * length , char * groupString ) ; <nl> - typedef void ( GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERSTRINGAMDPROC ) ( GLuint group , GLuint counter , GLsizei bufSize , GLsizei * length , char * counterString ) ; <nl> - typedef void ( GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERINFOAMDPROC ) ( GLuint group , GLuint counter , GLenum pname , GLvoid * data ) ; <nl> - typedef void ( GL_APIENTRYP PFNGLGENPERFMONITORSAMDPROC ) ( GLsizei n , GLuint * monitors ) ; <nl> - typedef void ( GL_APIENTRYP PFNGLDELETEPERFMONITORSAMDPROC ) ( GLsizei n , GLuint * monitors ) ; <nl> - typedef void ( GL_APIENTRYP PFNGLSELECTPERFMONITORCOUNTERSAMDPROC ) ( GLuint monitor , GLboolean enable , GLuint group , GLint numCounters , GLuint * countersList ) ; <nl> - typedef void ( GL_APIENTRYP PFNGLBEGINPERFMONITORAMDPROC ) ( GLuint monitor ) ; <nl> - typedef void ( GL_APIENTRYP PFNGLENDPERFMONITORAMDPROC ) ( GLuint monitor ) ; <nl> - typedef void ( GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERDATAAMDPROC ) ( GLuint monitor , GLenum pname , GLsizei dataSize , GLuint * data , GLint * bytesWritten ) ; <nl> - # endif <nl> - <nl> - / * GL_AMD_program_binary_Z400 * / <nl> - # ifndef GL_AMD_program_binary_Z400 <nl> - # define GL_AMD_program_binary_Z400 1 <nl> - # endif <nl> - <nl> - / * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * <nl> - * ANGLE extension functions <nl> - * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * / <nl> - <nl> - / * GL_ANGLE_framebuffer_blit * / <nl> - # ifndef GL_ANGLE_framebuffer_blit <nl> - # define GL_ANGLE_framebuffer_blit 1 <nl> - # ifdef GL_GLEXT_PROTOTYPES <nl> - GL_APICALL void GL_APIENTRY glBlitFramebufferANGLE ( GLint srcX0 , GLint srcY0 , GLint srcX1 , GLint srcY1 , GLint dstX0 , GLint dstY0 , GLint dstX1 , GLint dstY1 , GLbitfield mask , GLenum filter ) ; <nl> - # endif <nl> - typedef void ( GL_APIENTRYP PFNGLBLITFRAMEBUFFERANGLEPROC ) ( GLint srcX0 , GLint srcY0 , GLint srcX1 , GLint srcY1 , GLint dstX0 , GLint dstY0 , GLint dstX1 , GLint dstY1 , GLbitfield mask , GLenum filter ) ; <nl> - # endif <nl> - <nl> - / * GL_ANGLE_framebuffer_multisample * / <nl> - # ifndef GL_ANGLE_framebuffer_multisample <nl> - # define GL_ANGLE_framebuffer_multisample 1 <nl> - # ifdef GL_GLEXT_PROTOTYPES <nl> - GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleANGLE ( GLenum target , GLsizei samples , GLenum internalformat , GLsizei width , GLsizei height ) ; <nl> - # endif <nl> - typedef void ( GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEANGLEPROC ) ( GLenum target , GLsizei samples , GLenum internalformat , GLsizei width , GLsizei height ) ; <nl> - # endif <nl> - <nl> - / * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * <nl> - * APPLE extension functions <nl> - * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * / <nl> - <nl> - / * GL_APPLE_rgb_422 * / <nl> - # ifndef GL_APPLE_rgb_422 <nl> - # define GL_APPLE_rgb_422 1 <nl> - # endif <nl> - <nl> - / * GL_APPLE_framebuffer_multisample * / <nl> - # ifndef GL_APPLE_framebuffer_multisample <nl> - # define GL_APPLE_framebuffer_multisample 1 <nl> - # ifdef GL_GLEXT_PROTOTYPES <nl> - GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleAPPLE ( GLenum , GLsizei , GLenum , GLsizei , GLsizei ) ; <nl> - GL_APICALL void GL_APIENTRY glResolveMultisampleFramebufferAPPLE ( void ) ; <nl> - # endif / * GL_GLEXT_PROTOTYPES * / <nl> - typedef void ( GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEAPPLEPROC ) ( GLenum target , GLsizei samples , GLenum internalformat , GLsizei width , GLsizei height ) ; <nl> - typedef void ( GL_APIENTRYP PFNGLRESOLVEMULTISAMPLEFRAMEBUFFERAPPLEPROC ) ( void ) ; <nl> - # endif <nl> - <nl> - / * GL_APPLE_texture_format_BGRA8888 * / <nl> - # ifndef GL_APPLE_texture_format_BGRA8888 <nl> - # define GL_APPLE_texture_format_BGRA8888 1 <nl> - # endif <nl> - <nl> - / * GL_APPLE_texture_max_level * / <nl> - # ifndef GL_APPLE_texture_max_level <nl> - # define GL_APPLE_texture_max_level 1 <nl> - # endif <nl> - <nl> - / * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * <nl> - * ARM extension functions <nl> - * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * / <nl> - <nl> - / * GL_ARM_mali_shader_binary * / <nl> - # ifndef GL_ARM_mali_shader_binary <nl> - # define GL_ARM_mali_shader_binary 1 <nl> - # endif <nl> - <nl> - / * GL_ARM_rgba8 * / <nl> - # ifndef GL_ARM_rgba8 <nl> - # define GL_ARM_rgba8 1 <nl> - # endif <nl> - <nl> - / * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * <nl> - * EXT extension functions <nl> - * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * / <nl> - <nl> - / * GL_EXT_blend_minmax * / <nl> - # ifndef GL_EXT_blend_minmax <nl> - # define GL_EXT_blend_minmax 1 <nl> - # endif <nl> - <nl> - / * GL_EXT_discard_framebuffer * / <nl> - # ifndef GL_EXT_discard_framebuffer <nl> - # define GL_EXT_discard_framebuffer 1 <nl> - # ifdef GL_GLEXT_PROTOTYPES <nl> - GL_APICALL void GL_APIENTRY glDiscardFramebufferEXT ( GLenum target , GLsizei numAttachments , const GLenum * attachments ) ; <nl> - # endif <nl> - typedef void ( GL_APIENTRYP PFNGLDISCARDFRAMEBUFFEREXTPROC ) ( GLenum target , GLsizei numAttachments , const GLenum * attachments ) ; <nl> - # endif <nl> - <nl> - # ifndef GL_EXT_multi_draw_arrays <nl> - # define GL_EXT_multi_draw_arrays 1 <nl> - # ifdef GL_GLEXT_PROTOTYPES <nl> - GL_APICALL void GL_APIENTRY glMultiDrawArraysEXT ( GLenum , GLint * , GLsizei * , GLsizei ) ; <nl> - GL_APICALL void GL_APIENTRY glMultiDrawElementsEXT ( GLenum , const GLsizei * , GLenum , const GLvoid * * , GLsizei ) ; <nl> - # endif / * GL_GLEXT_PROTOTYPES * / <nl> - typedef void ( GL_APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC ) ( GLenum mode , GLint * first , GLsizei * count , GLsizei primcount ) ; <nl> - typedef void ( GL_APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC ) ( GLenum mode , const GLsizei * count , GLenum type , const GLvoid * * indices , GLsizei primcount ) ; <nl> - # endif <nl> - <nl> - / * GL_EXT_read_format_bgra * / <nl> - # ifndef GL_EXT_read_format_bgra <nl> - # define GL_EXT_read_format_bgra 1 <nl> - # endif <nl> - <nl> - / * GL_EXT_texture_filter_anisotropic * / <nl> - # ifndef GL_EXT_texture_filter_anisotropic <nl> - # define GL_EXT_texture_filter_anisotropic 1 <nl> - # endif <nl> - <nl> - / * GL_EXT_texture_format_BGRA8888 * / <nl> - # ifndef GL_EXT_texture_format_BGRA8888 <nl> - # define GL_EXT_texture_format_BGRA8888 1 <nl> - # endif <nl> - <nl> - / * GL_EXT_texture_type_2_10_10_10_REV * / <nl> - # ifndef GL_EXT_texture_type_2_10_10_10_REV <nl> - # define GL_EXT_texture_type_2_10_10_10_REV 1 <nl> - # endif <nl> - <nl> - / * GL_EXT_texture_compression_dxt1 * / <nl> - # ifndef GL_EXT_texture_compression_dxt1 <nl> - # define GL_EXT_texture_compression_dxt1 1 <nl> - # endif <nl> - <nl> - / * GL_EXT_shader_texture_lod * / <nl> - # ifndef GL_EXT_shader_texture_lod <nl> - # define GL_EXT_shader_texture_lod 1 <nl> - # endif <nl> - <nl> - / * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * <nl> - * IMG extension functions <nl> - * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * / <nl> - <nl> - / * GL_IMG_program_binary * / <nl> - # ifndef GL_IMG_program_binary <nl> - # define GL_IMG_program_binary 1 <nl> - # endif <nl> - <nl> - / * GL_IMG_read_format * / <nl> - # ifndef GL_IMG_read_format <nl> - # define GL_IMG_read_format 1 <nl> - # endif <nl> - <nl> - / * GL_IMG_shader_binary * / <nl> - # ifndef GL_IMG_shader_binary <nl> - # define GL_IMG_shader_binary 1 <nl> - # endif <nl> - <nl> - / * GL_IMG_texture_compression_pvrtc * / <nl> - # ifndef GL_IMG_texture_compression_pvrtc <nl> - # define GL_IMG_texture_compression_pvrtc 1 <nl> - # endif <nl> - <nl> - / * GL_IMG_multisampled_render_to_texture * / <nl> - # ifndef GL_IMG_multisampled_render_to_texture <nl> - # define GL_IMG_multisampled_render_to_texture 1 <nl> - # ifdef GL_GLEXT_PROTOTYPES <nl> - GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleIMG ( GLenum , GLsizei , GLenum , GLsizei , GLsizei ) ; <nl> - GL_APICALL void GL_APIENTRY glFramebufferTexture2DMultisampleIMG ( GLenum , GLenum , GLenum , GLuint , GLint , GLsizei ) ; <nl> - # endif <nl> - typedef void ( GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEIMG ) ( GLenum target , GLsizei samples , GLenum internalformat , GLsizei width , GLsizei height ) ; <nl> - typedef void ( GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEIMG ) ( GLenum target , GLenum attachment , GLenum textarget , GLuint texture , GLint level , GLsizei samples ) ; <nl> - # endif <nl> - <nl> - / * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * <nl> - * NV extension functions <nl> - * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * / <nl> - <nl> - / * GL_NV_fence * / <nl> - # ifndef GL_NV_fence <nl> - # define GL_NV_fence 1 <nl> - # ifdef GL_GLEXT_PROTOTYPES <nl> - GL_APICALL void GL_APIENTRY glDeleteFencesNV ( GLsizei , const GLuint * ) ; <nl> - GL_APICALL void GL_APIENTRY glGenFencesNV ( GLsizei , GLuint * ) ; <nl> - GL_APICALL GLboolean GL_APIENTRY glIsFenceNV ( GLuint ) ; <nl> - GL_APICALL GLboolean GL_APIENTRY glTestFenceNV ( GLuint ) ; <nl> - GL_APICALL void GL_APIENTRY glGetFenceivNV ( GLuint , GLenum , GLint * ) ; <nl> - GL_APICALL void GL_APIENTRY glFinishFenceNV ( GLuint ) ; <nl> - GL_APICALL void GL_APIENTRY glSetFenceNV ( GLuint , GLenum ) ; <nl> - # endif <nl> - typedef void ( GL_APIENTRYP PFNGLDELETEFENCESNVPROC ) ( GLsizei n , const GLuint * fences ) ; <nl> - typedef void ( GL_APIENTRYP PFNGLGENFENCESNVPROC ) ( GLsizei n , GLuint * fences ) ; <nl> - typedef GLboolean ( GL_APIENTRYP PFNGLISFENCENVPROC ) ( GLuint fence ) ; <nl> - typedef GLboolean ( GL_APIENTRYP PFNGLTESTFENCENVPROC ) ( GLuint fence ) ; <nl> - typedef void ( GL_APIENTRYP PFNGLGETFENCEIVNVPROC ) ( GLuint fence , GLenum pname , GLint * params ) ; <nl> - typedef void ( GL_APIENTRYP PFNGLFINISHFENCENVPROC ) ( GLuint fence ) ; <nl> - typedef void ( GL_APIENTRYP PFNGLSETFENCENVPROC ) ( GLuint fence , GLenum condition ) ; <nl> - # endif <nl> - <nl> - / * GL_NV_coverage_sample * / <nl> - # ifndef GL_NV_coverage_sample <nl> - # define GL_NV_coverage_sample 1 <nl> - # ifdef GL_GLEXT_PROTOTYPES <nl> - GL_APICALL void GL_APIENTRY glCoverageMaskNV ( GLboolean mask ) ; <nl> - GL_APICALL void GL_APIENTRY glCoverageOperationNV ( GLenum operation ) ; <nl> - # endif <nl> - typedef void ( GL_APIENTRYP PFNGLCOVERAGEMASKNVPROC ) ( GLboolean mask ) ; <nl> - typedef void ( GL_APIENTRYP PFNGLCOVERAGEOPERATIONNVPROC ) ( GLenum operation ) ; <nl> - # endif <nl> - <nl> - / * GL_NV_depth_nonlinear * / <nl> - # ifndef GL_NV_depth_nonlinear <nl> - # define GL_NV_depth_nonlinear 1 <nl> - # endif <nl> - <nl> - / * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * <nl> - * QCOM extension functions <nl> - * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * / <nl> - <nl> - / * GL_QCOM_driver_control * / <nl> - # ifndef GL_QCOM_driver_control <nl> - # define GL_QCOM_driver_control 1 <nl> - # ifdef GL_GLEXT_PROTOTYPES <nl> - GL_APICALL void GL_APIENTRY glGetDriverControlsQCOM ( GLint * num , GLsizei size , GLuint * driverControls ) ; <nl> - GL_APICALL void GL_APIENTRY glGetDriverControlStringQCOM ( GLuint driverControl , GLsizei bufSize , GLsizei * length , char * driverControlString ) ; <nl> - GL_APICALL void GL_APIENTRY glEnableDriverControlQCOM ( GLuint driverControl ) ; <nl> - GL_APICALL void GL_APIENTRY glDisableDriverControlQCOM ( GLuint driverControl ) ; <nl> - # endif <nl> - typedef void ( GL_APIENTRYP PFNGLGETDRIVERCONTROLSQCOMPROC ) ( GLint * num , GLsizei size , GLuint * driverControls ) ; <nl> - typedef void ( GL_APIENTRYP PFNGLGETDRIVERCONTROLSTRINGQCOMPROC ) ( GLuint driverControl , GLsizei bufSize , GLsizei * length , char * driverControlString ) ; <nl> - typedef void ( GL_APIENTRYP PFNGLENABLEDRIVERCONTROLQCOMPROC ) ( GLuint driverControl ) ; <nl> - typedef void ( GL_APIENTRYP PFNGLDISABLEDRIVERCONTROLQCOMPROC ) ( GLuint driverControl ) ; <nl> - # endif <nl> - <nl> - / * GL_QCOM_extended_get * / <nl> - # ifndef GL_QCOM_extended_get <nl> - # define GL_QCOM_extended_get 1 <nl> - # ifdef GL_GLEXT_PROTOTYPES <nl> - GL_APICALL void GL_APIENTRY glExtGetTexturesQCOM ( GLuint * textures , GLint maxTextures , GLint * numTextures ) ; <nl> - GL_APICALL void GL_APIENTRY glExtGetBuffersQCOM ( GLuint * buffers , GLint maxBuffers , GLint * numBuffers ) ; <nl> - GL_APICALL void GL_APIENTRY glExtGetRenderbuffersQCOM ( GLuint * renderbuffers , GLint maxRenderbuffers , GLint * numRenderbuffers ) ; <nl> - GL_APICALL void GL_APIENTRY glExtGetFramebuffersQCOM ( GLuint * framebuffers , GLint maxFramebuffers , GLint * numFramebuffers ) ; <nl> - GL_APICALL void GL_APIENTRY glExtGetTexLevelParameterivQCOM ( GLuint texture , GLenum face , GLint level , GLenum pname , GLint * params ) ; <nl> - GL_APICALL void GL_APIENTRY glExtTexObjectStateOverrideiQCOM ( GLenum target , GLenum pname , GLint param ) ; <nl> - GL_APICALL void GL_APIENTRY glExtGetTexSubImageQCOM ( GLenum target , GLint level , GLint xoffset , GLint yoffset , GLint zoffset , GLsizei width , GLsizei height , GLsizei depth , GLenum format , GLenum type , GLvoid * texels ) ; <nl> - GL_APICALL void GL_APIENTRY glExtGetBufferPointervQCOM ( GLenum target , GLvoid * * params ) ; <nl> - # endif <nl> - typedef void ( GL_APIENTRYP PFNGLEXTGETTEXTURESQCOMPROC ) ( GLuint * textures , GLint maxTextures , GLint * numTextures ) ; <nl> - typedef void ( GL_APIENTRYP PFNGLEXTGETBUFFERSQCOMPROC ) ( GLuint * buffers , GLint maxBuffers , GLint * numBuffers ) ; <nl> - typedef void ( GL_APIENTRYP PFNGLEXTGETRENDERBUFFERSQCOMPROC ) ( GLuint * renderbuffers , GLint maxRenderbuffers , GLint * numRenderbuffers ) ; <nl> - typedef void ( GL_APIENTRYP PFNGLEXTGETFRAMEBUFFERSQCOMPROC ) ( GLuint * framebuffers , GLint maxFramebuffers , GLint * numFramebuffers ) ; <nl> - typedef void ( GL_APIENTRYP PFNGLEXTGETTEXLEVELPARAMETERIVQCOMPROC ) ( GLuint texture , GLenum face , GLint level , GLenum pname , GLint * params ) ; <nl> - typedef void ( GL_APIENTRYP PFNGLEXTTEXOBJECTSTATEOVERRIDEIQCOMPROC ) ( GLenum target , GLenum pname , GLint param ) ; <nl> - typedef void ( GL_APIENTRYP PFNGLEXTGETTEXSUBIMAGEQCOMPROC ) ( GLenum target , GLint level , GLint xoffset , GLint yoffset , GLint zoffset , GLsizei width , GLsizei height , GLsizei depth , GLenum format , GLenum type , GLvoid * texels ) ; <nl> - typedef void ( GL_APIENTRYP PFNGLEXTGETBUFFERPOINTERVQCOMPROC ) ( GLenum target , GLvoid * * params ) ; <nl> - # endif <nl> - <nl> - / * GL_QCOM_extended_get2 * / <nl> - # ifndef GL_QCOM_extended_get2 <nl> - # define GL_QCOM_extended_get2 1 <nl> - # ifdef GL_GLEXT_PROTOTYPES <nl> - GL_APICALL void GL_APIENTRY glExtGetShadersQCOM ( GLuint * shaders , GLint maxShaders , GLint * numShaders ) ; <nl> - GL_APICALL void GL_APIENTRY glExtGetProgramsQCOM ( GLuint * programs , GLint maxPrograms , GLint * numPrograms ) ; <nl> - GL_APICALL GLboolean GL_APIENTRY glExtIsProgramBinaryQCOM ( GLuint program ) ; <nl> - GL_APICALL void GL_APIENTRY glExtGetProgramBinarySourceQCOM ( GLuint program , GLenum shadertype , char * source , GLint * length ) ; <nl> - # endif <nl> - typedef void ( GL_APIENTRYP PFNGLEXTGETSHADERSQCOMPROC ) ( GLuint * shaders , GLint maxShaders , GLint * numShaders ) ; <nl> - typedef void ( GL_APIENTRYP PFNGLEXTGETPROGRAMSQCOMPROC ) ( GLuint * programs , GLint maxPrograms , GLint * numPrograms ) ; <nl> - typedef GLboolean ( GL_APIENTRYP PFNGLEXTISPROGRAMBINARYQCOMPROC ) ( GLuint program ) ; <nl> - typedef void ( GL_APIENTRYP PFNGLEXTGETPROGRAMBINARYSOURCEQCOMPROC ) ( GLuint program , GLenum shadertype , char * source , GLint * length ) ; <nl> - # endif <nl> - <nl> - / * GL_QCOM_perfmon_global_mode * / <nl> - # ifndef GL_QCOM_perfmon_global_mode <nl> - # define GL_QCOM_perfmon_global_mode 1 <nl> - # endif <nl> - <nl> - / * GL_QCOM_writeonly_rendering * / <nl> - # ifndef GL_QCOM_writeonly_rendering <nl> - # define GL_QCOM_writeonly_rendering 1 <nl> - # endif <nl> - <nl> - / * GL_QCOM_tiled_rendering * / <nl> - # ifndef GL_QCOM_tiled_rendering <nl> - # define GL_QCOM_tiled_rendering 1 <nl> - # ifdef GL_GLEXT_PROTOTYPES <nl> - GL_APICALL void GL_APIENTRY glStartTilingQCOM ( GLuint x , GLuint y , GLuint width , GLuint height , GLbitfield preserveMask ) ; <nl> - GL_APICALL void GL_APIENTRY glEndTilingQCOM ( GLbitfield preserveMask ) ; <nl> - # endif <nl> - typedef void ( GL_APIENTRYP PFNGLSTARTTILINGQCOMPROC ) ( GLuint x , GLuint y , GLuint width , GLuint height , GLbitfield preserveMask ) ; <nl> - typedef void ( GL_APIENTRYP PFNGLENDTILINGQCOMPROC ) ( GLbitfield preserveMask ) ; <nl> - # endif <nl> - <nl> - / * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * <nl> - * VIV extension tokens <nl> - * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * / <nl> - <nl> - / * GL_VIV_shader_binary * / <nl> - # ifndef GL_VIV_shader_binary <nl> - # define GL_VIV_shader_binary 1 <nl> - # endif <nl> - <nl> - # ifdef __cplusplus <nl> - } <nl> - # endif <nl> - <nl> - # endif / * __gl2ext_h_ * / <nl> + # ifndef __gl2ext_h_ <nl> + # define __gl2ext_h_ <nl> + <nl> + # ifdef __cplusplus <nl> + extern " C " { <nl> + # endif <nl> + <nl> + / * <nl> + * This document is licensed under the SGI Free Software B License Version <nl> + * 2 . 0 . For details , see http : / / oss . sgi . com / projects / FreeB / . <nl> + * / <nl> + <nl> + # ifndef GL_APIENTRYP <nl> + # define GL_APIENTRYP GL_APIENTRY * <nl> + # endif <nl> + <nl> + / * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * <nl> + * OES extension tokens <nl> + * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * / <nl> + <nl> + / * GL_OES_compressed_ETC1_RGB8_texture * / <nl> + # ifndef GL_OES_compressed_ETC1_RGB8_texture <nl> + # define GL_ETC1_RGB8_OES 0x8D64 <nl> + # endif <nl> + <nl> + / * GL_OES_compressed_paletted_texture * / <nl> + # ifndef GL_OES_compressed_paletted_texture <nl> + # define GL_PALETTE4_RGB8_OES 0x8B90 <nl> + # define GL_PALETTE4_RGBA8_OES 0x8B91 <nl> + # define GL_PALETTE4_R5_G6_B5_OES 0x8B92 <nl> + # define GL_PALETTE4_RGBA4_OES 0x8B93 <nl> + # define GL_PALETTE4_RGB5_A1_OES 0x8B94 <nl> + # define GL_PALETTE8_RGB8_OES 0x8B95 <nl> + # define GL_PALETTE8_RGBA8_OES 0x8B96 <nl> + # define GL_PALETTE8_R5_G6_B5_OES 0x8B97 <nl> + # define GL_PALETTE8_RGBA4_OES 0x8B98 <nl> + # define GL_PALETTE8_RGB5_A1_OES 0x8B99 <nl> + # endif <nl> + <nl> + / * GL_OES_depth24 * / <nl> + # ifndef GL_OES_depth24 <nl> + # define GL_DEPTH_COMPONENT24_OES 0x81A6 <nl> + # endif <nl> + <nl> + / * GL_OES_depth32 * / <nl> + # ifndef GL_OES_depth32 <nl> + # define GL_DEPTH_COMPONENT32_OES 0x81A7 <nl> + # endif <nl> + <nl> + / * GL_OES_depth_texture * / <nl> + / * No new tokens introduced by this extension . * / <nl> + <nl> + / * GL_OES_EGL_image * / <nl> + # ifndef GL_OES_EGL_image <nl> + typedef void * GLeglImageOES ; <nl> + # endif <nl> + <nl> + / * GL_OES_EGL_image_external * / <nl> + # ifndef GL_OES_EGL_image_external <nl> + / * GLeglImageOES defined in GL_OES_EGL_image already . * / <nl> + # define GL_TEXTURE_EXTERNAL_OES 0x8D65 <nl> + # define GL_SAMPLER_EXTERNAL_OES 0x8D66 <nl> + # define GL_TEXTURE_BINDING_EXTERNAL_OES 0x8D67 <nl> + # define GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES 0x8D68 <nl> + # endif <nl> + <nl> + / * GL_OES_element_index_uint * / <nl> + # ifndef GL_OES_element_index_uint <nl> + # define GL_UNSIGNED_INT 0x1405 <nl> + # endif <nl> + <nl> + / * GL_OES_get_program_binary * / <nl> + # ifndef GL_OES_get_program_binary <nl> + # define GL_PROGRAM_BINARY_LENGTH_OES 0x8741 <nl> + # define GL_NUM_PROGRAM_BINARY_FORMATS_OES 0x87FE <nl> + # define GL_PROGRAM_BINARY_FORMATS_OES 0x87FF <nl> + # endif <nl> + <nl> + / * GL_OES_mapbuffer * / <nl> + # ifndef GL_OES_mapbuffer <nl> + # define GL_WRITE_ONLY_OES 0x88B9 <nl> + # define GL_BUFFER_ACCESS_OES 0x88BB <nl> + # define GL_BUFFER_MAPPED_OES 0x88BC <nl> + # define GL_BUFFER_MAP_POINTER_OES 0x88BD <nl> + # endif <nl> + <nl> + / * GL_OES_packed_depth_stencil * / <nl> + # ifndef GL_OES_packed_depth_stencil <nl> + # define GL_DEPTH_STENCIL_OES 0x84F9 <nl> + # define GL_UNSIGNED_INT_24_8_OES 0x84FA <nl> + # define GL_DEPTH24_STENCIL8_OES 0x88F0 <nl> + # endif <nl> + <nl> + / * GL_OES_rgb8_rgba8 * / <nl> + # ifndef GL_OES_rgb8_rgba8 <nl> + # define GL_RGB8_OES 0x8051 <nl> + # define GL_RGBA8_OES 0x8058 <nl> + # endif <nl> + <nl> + / * GL_OES_standard_derivatives * / <nl> + # ifndef GL_OES_standard_derivatives <nl> + # define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES 0x8B8B <nl> + # endif <nl> + <nl> + / * GL_OES_stencil1 * / <nl> + # ifndef GL_OES_stencil1 <nl> + # define GL_STENCIL_INDEX1_OES 0x8D46 <nl> + # endif <nl> + <nl> + / * GL_OES_stencil4 * / <nl> + # ifndef GL_OES_stencil4 <nl> + # define GL_STENCIL_INDEX4_OES 0x8D47 <nl> + # endif <nl> + <nl> + / * GL_OES_texture_3D * / <nl> + # ifndef GL_OES_texture_3D <nl> + # define GL_TEXTURE_WRAP_R_OES 0x8072 <nl> + # define GL_TEXTURE_3D_OES 0x806F <nl> + # define GL_TEXTURE_BINDING_3D_OES 0x806A <nl> + # define GL_MAX_3D_TEXTURE_SIZE_OES 0x8073 <nl> + # define GL_SAMPLER_3D_OES 0x8B5F <nl> + # define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_OES 0x8CD4 <nl> + # endif <nl> + <nl> + / * GL_OES_texture_float * / <nl> + / * No new tokens introduced by this extension . * / <nl> + <nl> + / * GL_OES_texture_float_linear * / <nl> + / * No new tokens introduced by this extension . * / <nl> + <nl> + / * GL_OES_texture_half_float * / <nl> + # ifndef GL_OES_texture_half_float <nl> + # define GL_HALF_FLOAT_OES 0x8D61 <nl> + # endif <nl> + <nl> + / * GL_OES_texture_half_float_linear * / <nl> + / * No new tokens introduced by this extension . * / <nl> + <nl> + / * GL_OES_texture_npot * / <nl> + / * No new tokens introduced by this extension . * / <nl> + <nl> + / * GL_OES_vertex_array_object * / <nl> + # ifndef GL_OES_vertex_array_object <nl> + # define GL_VERTEX_ARRAY_BINDING_OES 0x85B5 <nl> + # endif <nl> + <nl> + / * GL_OES_vertex_half_float * / <nl> + / * GL_HALF_FLOAT_OES defined in GL_OES_texture_half_float already . * / <nl> + <nl> + / * GL_OES_vertex_type_10_10_10_2 * / <nl> + # ifndef GL_OES_vertex_type_10_10_10_2 <nl> + # define GL_UNSIGNED_INT_10_10_10_2_OES 0x8DF6 <nl> + # define GL_INT_10_10_10_2_OES 0x8DF7 <nl> + # endif <nl> + <nl> + / * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * <nl> + * AMD extension tokens <nl> + * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * / <nl> + <nl> + / * GL_AMD_compressed_3DC_texture * / <nl> + # ifndef GL_AMD_compressed_3DC_texture <nl> + # define GL_3DC_X_AMD 0x87F9 <nl> + # define GL_3DC_XY_AMD 0x87FA <nl> + # endif <nl> + <nl> + / * GL_AMD_compressed_ATC_texture * / <nl> + # ifndef GL_AMD_compressed_ATC_texture <nl> + # define GL_ATC_RGB_AMD 0x8C92 <nl> + # define GL_ATC_RGBA_EXPLICIT_ALPHA_AMD 0x8C93 <nl> + # define GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD 0x87EE <nl> + # endif <nl> + <nl> + / * GL_AMD_performance_monitor * / <nl> + # ifndef GL_AMD_performance_monitor <nl> + # define GL_COUNTER_TYPE_AMD 0x8BC0 <nl> + # define GL_COUNTER_RANGE_AMD 0x8BC1 <nl> + # define GL_UNSIGNED_INT64_AMD 0x8BC2 <nl> + # define GL_PERCENTAGE_AMD 0x8BC3 <nl> + # define GL_PERFMON_RESULT_AVAILABLE_AMD 0x8BC4 <nl> + # define GL_PERFMON_RESULT_SIZE_AMD 0x8BC5 <nl> + # define GL_PERFMON_RESULT_AMD 0x8BC6 <nl> + # endif <nl> + <nl> + / * GL_AMD_program_binary_Z400 * / <nl> + # ifndef GL_AMD_program_binary_Z400 <nl> + # define GL_Z400_BINARY_AMD 0x8740 <nl> + # endif <nl> + <nl> + / * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * <nl> + * ANGLE extension tokens <nl> + * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * / <nl> + <nl> + / * GL_ANGLE_framebuffer_blit * / <nl> + # ifndef GL_ANGLE_framebuffer_blit <nl> + # define GL_READ_FRAMEBUFFER_ANGLE 0x8CA8 <nl> + # define GL_DRAW_FRAMEBUFFER_ANGLE 0x8CA9 <nl> + # define GL_DRAW_FRAMEBUFFER_BINDING_ANGLE 0x8CA6 <nl> + # define GL_READ_FRAMEBUFFER_BINDING_ANGLE 0x8CAA <nl> + # endif <nl> + <nl> + / * GL_ANGLE_framebuffer_multisample * / <nl> + # ifndef GL_ANGLE_framebuffer_multisample <nl> + # define GL_RENDERBUFFER_SAMPLES_ANGLE 0x8CAB <nl> + # define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_ANGLE 0x8D56 <nl> + # define GL_MAX_SAMPLES_ANGLE 0x8D57 <nl> + # endif <nl> + <nl> + / * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * <nl> + * APPLE extension tokens <nl> + * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * / <nl> + <nl> + / * GL_APPLE_rgb_422 * / <nl> + # ifndef GL_APPLE_rgb_422 <nl> + # define GL_RGB_422_APPLE 0x8A1F <nl> + # define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA <nl> + # define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB <nl> + # endif <nl> + <nl> + / * GL_APPLE_framebuffer_multisample * / <nl> + # ifndef GL_APPLE_framebuffer_multisample <nl> + # define GL_RENDERBUFFER_SAMPLES_APPLE 0x8CAB <nl> + # define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_APPLE 0x8D56 <nl> + # define GL_MAX_SAMPLES_APPLE 0x8D57 <nl> + # define GL_READ_FRAMEBUFFER_APPLE 0x8CA8 <nl> + # define GL_DRAW_FRAMEBUFFER_APPLE 0x8CA9 <nl> + # define GL_DRAW_FRAMEBUFFER_BINDING_APPLE 0x8CA6 <nl> + # define GL_READ_FRAMEBUFFER_BINDING_APPLE 0x8CAA <nl> + # endif <nl> + <nl> + / * GL_APPLE_texture_format_BGRA8888 * / <nl> + # ifndef GL_APPLE_texture_format_BGRA8888 <nl> + # define GL_BGRA_EXT 0x80E1 <nl> + # endif <nl> + <nl> + / * GL_APPLE_texture_max_level * / <nl> + # ifndef GL_APPLE_texture_max_level <nl> + # define GL_TEXTURE_MAX_LEVEL_APPLE 0x813D <nl> + # endif <nl> + <nl> + / * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * <nl> + * ARM extension tokens <nl> + * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * / <nl> + <nl> + / * GL_ARM_mali_shader_binary * / <nl> + # ifndef GL_ARM_mali_shader_binary <nl> + # define GL_MALI_SHADER_BINARY_ARM 0x8F60 <nl> + # endif <nl> + <nl> + / * GL_ARM_rgba8 * / <nl> + / * No new tokens introduced by this extension . * / <nl> + <nl> + / * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * <nl> + * EXT extension tokens <nl> + * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * / <nl> + <nl> + / * GL_EXT_blend_minmax * / <nl> + # ifndef GL_EXT_blend_minmax <nl> + # define GL_MIN_EXT 0x8007 <nl> + # define GL_MAX_EXT 0x8008 <nl> + # endif <nl> + <nl> + / * GL_EXT_discard_framebuffer * / <nl> + # ifndef GL_EXT_discard_framebuffer <nl> + # define GL_COLOR_EXT 0x1800 <nl> + # define GL_DEPTH_EXT 0x1801 <nl> + # define GL_STENCIL_EXT 0x1802 <nl> + # endif <nl> + <nl> + / * GL_EXT_multi_draw_arrays * / <nl> + / * No new tokens introduced by this extension . * / <nl> + <nl> + / * GL_EXT_read_format_bgra * / <nl> + # ifndef GL_EXT_read_format_bgra <nl> + # define GL_BGRA_EXT 0x80E1 <nl> + # define GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT 0x8365 <nl> + # define GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT 0x8366 <nl> + # endif <nl> + <nl> + / * GL_EXT_texture_filter_anisotropic * / <nl> + # ifndef GL_EXT_texture_filter_anisotropic <nl> + # define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE <nl> + # define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF <nl> + # endif <nl> + <nl> + / * GL_EXT_texture_format_BGRA8888 * / <nl> + # ifndef GL_EXT_texture_format_BGRA8888 <nl> + # define GL_BGRA_EXT 0x80E1 <nl> + # endif <nl> + <nl> + / * GL_EXT_texture_type_2_10_10_10_REV * / <nl> + # ifndef GL_EXT_texture_type_2_10_10_10_REV <nl> + # define GL_UNSIGNED_INT_2_10_10_10_REV_EXT 0x8368 <nl> + # endif <nl> + <nl> + / * GL_EXT_texture_compression_dxt1 * / <nl> + # ifndef GL_EXT_texture_compression_dxt1 <nl> + # define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 <nl> + # define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 <nl> + # endif <nl> + <nl> + / * GL_EXT_shader_texture_lod * / <nl> + / * No new tokens introduced by this extension . * / <nl> + <nl> + / * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * <nl> + * IMG extension tokens <nl> + * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * / <nl> + <nl> + / * GL_IMG_program_binary * / <nl> + # ifndef GL_IMG_program_binary <nl> + # define GL_SGX_PROGRAM_BINARY_IMG 0x9130 <nl> + # endif <nl> + <nl> + / * GL_IMG_read_format * / <nl> + # ifndef GL_IMG_read_format <nl> + # define GL_BGRA_IMG 0x80E1 <nl> + # define GL_UNSIGNED_SHORT_4_4_4_4_REV_IMG 0x8365 <nl> + # endif <nl> + <nl> + / * GL_IMG_shader_binary * / <nl> + # ifndef GL_IMG_shader_binary <nl> + # define GL_SGX_BINARY_IMG 0x8C0A <nl> + # endif <nl> + <nl> + / * GL_IMG_texture_compression_pvrtc * / <nl> + # ifndef GL_IMG_texture_compression_pvrtc <nl> + # define GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG 0x8C00 <nl> + # define GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG 0x8C01 <nl> + # define GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG 0x8C02 <nl> + # define GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG 0x8C03 <nl> + # endif <nl> + <nl> + / * GL_IMG_multisampled_render_to_texture * / <nl> + # ifndef GL_IMG_multisampled_render_to_texture <nl> + # define GL_RENDERBUFFER_SAMPLES_IMG 0x9133 <nl> + # define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_IMG 0x9134 <nl> + # define GL_MAX_SAMPLES_IMG 0x9135 <nl> + # define GL_TEXTURE_SAMPLES_IMG 0x9136 <nl> + # endif <nl> + <nl> + / * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * <nl> + * NV extension tokens <nl> + * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * / <nl> + <nl> + / * GL_NV_fence * / <nl> + # ifndef GL_NV_fence <nl> + # define GL_ALL_COMPLETED_NV 0x84F2 <nl> + # define GL_FENCE_STATUS_NV 0x84F3 <nl> + # define GL_FENCE_CONDITION_NV 0x84F4 <nl> + # endif <nl> + <nl> + / * GL_NV_coverage_sample * / <nl> + # ifndef GL_NV_coverage_sample <nl> + # define GL_COVERAGE_COMPONENT_NV 0x8ED0 <nl> + # define GL_COVERAGE_COMPONENT4_NV 0x8ED1 <nl> + # define GL_COVERAGE_ATTACHMENT_NV 0x8ED2 <nl> + # define GL_COVERAGE_BUFFERS_NV 0x8ED3 <nl> + # define GL_COVERAGE_SAMPLES_NV 0x8ED4 <nl> + # define GL_COVERAGE_ALL_FRAGMENTS_NV 0x8ED5 <nl> + # define GL_COVERAGE_EDGE_FRAGMENTS_NV 0x8ED6 <nl> + # define GL_COVERAGE_AUTOMATIC_NV 0x8ED7 <nl> + # define GL_COVERAGE_BUFFER_BIT_NV 0x8000 <nl> + # endif <nl> + <nl> + / * GL_NV_depth_nonlinear * / <nl> + # ifndef GL_NV_depth_nonlinear <nl> + # define GL_DEPTH_COMPONENT16_NONLINEAR_NV 0x8E2C <nl> + # endif <nl> + <nl> + / * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * <nl> + * QCOM extension tokens <nl> + * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * / <nl> + <nl> + / * GL_QCOM_driver_control * / <nl> + / * No new tokens introduced by this extension . * / <nl> + <nl> + / * GL_QCOM_extended_get * / <nl> + # ifndef GL_QCOM_extended_get <nl> + # define GL_TEXTURE_WIDTH_QCOM 0x8BD2 <nl> + # define GL_TEXTURE_HEIGHT_QCOM 0x8BD3 <nl> + # define GL_TEXTURE_DEPTH_QCOM 0x8BD4 <nl> + # define GL_TEXTURE_INTERNAL_FORMAT_QCOM 0x8BD5 <nl> + # define GL_TEXTURE_FORMAT_QCOM 0x8BD6 <nl> + # define GL_TEXTURE_TYPE_QCOM 0x8BD7 <nl> + # define GL_TEXTURE_IMAGE_VALID_QCOM 0x8BD8 <nl> + # define GL_TEXTURE_NUM_LEVELS_QCOM 0x8BD9 <nl> + # define GL_TEXTURE_TARGET_QCOM 0x8BDA <nl> + # define GL_TEXTURE_OBJECT_VALID_QCOM 0x8BDB <nl> + # define GL_STATE_RESTORE 0x8BDC <nl> + # endif <nl> + <nl> + / * GL_QCOM_extended_get2 * / <nl> + / * No new tokens introduced by this extension . * / <nl> + <nl> + / * GL_QCOM_perfmon_global_mode * / <nl> + # ifndef GL_QCOM_perfmon_global_mode <nl> + # define GL_PERFMON_GLOBAL_MODE_QCOM 0x8FA0 <nl> + # endif <nl> + <nl> + / * GL_QCOM_writeonly_rendering * / <nl> + # ifndef GL_QCOM_writeonly_rendering <nl> + # define GL_WRITEONLY_RENDERING_QCOM 0x8823 <nl> + # endif <nl> + <nl> + / * GL_QCOM_tiled_rendering * / <nl> + # ifndef GL_QCOM_tiled_rendering <nl> + # define GL_COLOR_BUFFER_BIT0_QCOM 0x00000001 <nl> + # define GL_COLOR_BUFFER_BIT1_QCOM 0x00000002 <nl> + # define GL_COLOR_BUFFER_BIT2_QCOM 0x00000004 <nl> + # define GL_COLOR_BUFFER_BIT3_QCOM 0x00000008 <nl> + # define GL_COLOR_BUFFER_BIT4_QCOM 0x00000010 <nl> + # define GL_COLOR_BUFFER_BIT5_QCOM 0x00000020 <nl> + # define GL_COLOR_BUFFER_BIT6_QCOM 0x00000040 <nl> + # define GL_COLOR_BUFFER_BIT7_QCOM 0x00000080 <nl> + # define GL_DEPTH_BUFFER_BIT0_QCOM 0x00000100 <nl> + # define GL_DEPTH_BUFFER_BIT1_QCOM 0x00000200 <nl> + # define GL_DEPTH_BUFFER_BIT2_QCOM 0x00000400 <nl> + # define GL_DEPTH_BUFFER_BIT3_QCOM 0x00000800 <nl> + # define GL_DEPTH_BUFFER_BIT4_QCOM 0x00001000 <nl> + # define GL_DEPTH_BUFFER_BIT5_QCOM 0x00002000 <nl> + # define GL_DEPTH_BUFFER_BIT6_QCOM 0x00004000 <nl> + # define GL_DEPTH_BUFFER_BIT7_QCOM 0x00008000 <nl> + # define GL_STENCIL_BUFFER_BIT0_QCOM 0x00010000 <nl> + # define GL_STENCIL_BUFFER_BIT1_QCOM 0x00020000 <nl> + # define GL_STENCIL_BUFFER_BIT2_QCOM 0x00040000 <nl> + # define GL_STENCIL_BUFFER_BIT3_QCOM 0x00080000 <nl> + # define GL_STENCIL_BUFFER_BIT4_QCOM 0x00100000 <nl> + # define GL_STENCIL_BUFFER_BIT5_QCOM 0x00200000 <nl> + # define GL_STENCIL_BUFFER_BIT6_QCOM 0x00400000 <nl> + # define GL_STENCIL_BUFFER_BIT7_QCOM 0x00800000 <nl> + # define GL_MULTISAMPLE_BUFFER_BIT0_QCOM 0x01000000 <nl> + # define GL_MULTISAMPLE_BUFFER_BIT1_QCOM 0x02000000 <nl> + # define GL_MULTISAMPLE_BUFFER_BIT2_QCOM 0x04000000 <nl> + # define GL_MULTISAMPLE_BUFFER_BIT3_QCOM 0x08000000 <nl> + # define GL_MULTISAMPLE_BUFFER_BIT4_QCOM 0x10000000 <nl> + # define GL_MULTISAMPLE_BUFFER_BIT5_QCOM 0x20000000 <nl> + # define GL_MULTISAMPLE_BUFFER_BIT6_QCOM 0x40000000 <nl> + # define GL_MULTISAMPLE_BUFFER_BIT7_QCOM 0x80000000 <nl> + # endif <nl> + <nl> + / * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * <nl> + * VIV extension tokens <nl> + * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * / <nl> + <nl> + / * GL_VIV_shader_binary * / <nl> + # ifndef GL_VIV_shader_binary <nl> + # define GL_SHADER_BINARY_VIV 0x8FC4 <nl> + # endif <nl> + <nl> + / * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * <nl> + * End of extension tokens , start of corresponding extension functions <nl> + * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * / <nl> + <nl> + / * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * <nl> + * OES extension functions <nl> + * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * / <nl> + <nl> + / * GL_OES_compressed_ETC1_RGB8_texture * / <nl> + # ifndef GL_OES_compressed_ETC1_RGB8_texture <nl> + # define GL_OES_compressed_ETC1_RGB8_texture 1 <nl> + # endif <nl> + <nl> + / * GL_OES_compressed_paletted_texture * / <nl> + # ifndef GL_OES_compressed_paletted_texture <nl> + # define GL_OES_compressed_paletted_texture 1 <nl> + # endif <nl> + <nl> + / * GL_OES_depth24 * / <nl> + # ifndef GL_OES_depth24 <nl> + # define GL_OES_depth24 1 <nl> + # endif <nl> + <nl> + / * GL_OES_depth32 * / <nl> + # ifndef GL_OES_depth32 <nl> + # define GL_OES_depth32 1 <nl> + # endif <nl> + <nl> + / * GL_OES_depth_texture * / <nl> + # ifndef GL_OES_depth_texture <nl> + # define GL_OES_depth_texture 1 <nl> + # endif <nl> + <nl> + / * GL_OES_EGL_image * / <nl> + # ifndef GL_OES_EGL_image <nl> + # define GL_OES_EGL_image 1 <nl> + # ifdef GL_GLEXT_PROTOTYPES <nl> + GL_APICALL void GL_APIENTRY glEGLImageTargetTexture2DOES ( GLenum target , GLeglImageOES image ) ; <nl> + GL_APICALL void GL_APIENTRY glEGLImageTargetRenderbufferStorageOES ( GLenum target , GLeglImageOES image ) ; <nl> + # endif <nl> + typedef void ( GL_APIENTRYP PFNGLEGLIMAGETARGETTEXTURE2DOESPROC ) ( GLenum target , GLeglImageOES image ) ; <nl> + typedef void ( GL_APIENTRYP PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC ) ( GLenum target , GLeglImageOES image ) ; <nl> + # endif <nl> + <nl> + / * GL_OES_EGL_image_external * / <nl> + # ifndef GL_OES_EGL_image_external <nl> + # define GL_OES_EGL_image_external 1 <nl> + / * glEGLImageTargetTexture2DOES defined in GL_OES_EGL_image already . * / <nl> + # endif <nl> + <nl> + / * GL_OES_element_index_uint * / <nl> + # ifndef GL_OES_element_index_uint <nl> + # define GL_OES_element_index_uint 1 <nl> + # endif <nl> + <nl> + / * GL_OES_fbo_render_mipmap * / <nl> + # ifndef GL_OES_fbo_render_mipmap <nl> + # define GL_OES_fbo_render_mipmap 1 <nl> + # endif <nl> + <nl> + / * GL_OES_fragment_precision_high * / <nl> + # ifndef GL_OES_fragment_precision_high <nl> + # define GL_OES_fragment_precision_high 1 <nl> + # endif <nl> + <nl> + / * GL_OES_get_program_binary * / <nl> + # ifndef GL_OES_get_program_binary <nl> + # define GL_OES_get_program_binary 1 <nl> + # ifdef GL_GLEXT_PROTOTYPES <nl> + GL_APICALL void GL_APIENTRY glGetProgramBinaryOES ( GLuint program , GLsizei bufSize , GLsizei * length , GLenum * binaryFormat , GLvoid * binary ) ; <nl> + GL_APICALL void GL_APIENTRY glProgramBinaryOES ( GLuint program , GLenum binaryFormat , const GLvoid * binary , GLint length ) ; <nl> + # endif <nl> + typedef void ( GL_APIENTRYP PFNGLGETPROGRAMBINARYOESPROC ) ( GLuint program , GLsizei bufSize , GLsizei * length , GLenum * binaryFormat , GLvoid * binary ) ; <nl> + typedef void ( GL_APIENTRYP PFNGLPROGRAMBINARYOESPROC ) ( GLuint program , GLenum binaryFormat , const GLvoid * binary , GLint length ) ; <nl> + # endif <nl> + <nl> + / * GL_OES_mapbuffer * / <nl> + # ifndef GL_OES_mapbuffer <nl> + # define GL_OES_mapbuffer 1 <nl> + # ifdef GL_GLEXT_PROTOTYPES <nl> + GL_APICALL void * GL_APIENTRY glMapBufferOES ( GLenum target , GLenum access ) ; <nl> + GL_APICALL GLboolean GL_APIENTRY glUnmapBufferOES ( GLenum target ) ; <nl> + GL_APICALL void GL_APIENTRY glGetBufferPointervOES ( GLenum target , GLenum pname , GLvoid * * params ) ; <nl> + # endif <nl> + typedef void * ( GL_APIENTRYP PFNGLMAPBUFFEROESPROC ) ( GLenum target , GLenum access ) ; <nl> + typedef GLboolean ( GL_APIENTRYP PFNGLUNMAPBUFFEROESPROC ) ( GLenum target ) ; <nl> + typedef void ( GL_APIENTRYP PFNGLGETBUFFERPOINTERVOESPROC ) ( GLenum target , GLenum pname , GLvoid * * params ) ; <nl> + # endif <nl> + <nl> + / * GL_OES_packed_depth_stencil * / <nl> + # ifndef GL_OES_packed_depth_stencil <nl> + # define GL_OES_packed_depth_stencil 1 <nl> + # endif <nl> + <nl> + / * GL_OES_rgb8_rgba8 * / <nl> + # ifndef GL_OES_rgb8_rgba8 <nl> + # define GL_OES_rgb8_rgba8 1 <nl> + # endif <nl> + <nl> + / * GL_OES_standard_derivatives * / <nl> + # ifndef GL_OES_standard_derivatives <nl> + # define GL_OES_standard_derivatives 1 <nl> + # endif <nl> + <nl> + / * GL_OES_stencil1 * / <nl> + # ifndef GL_OES_stencil1 <nl> + # define GL_OES_stencil1 1 <nl> + # endif <nl> + <nl> + / * GL_OES_stencil4 * / <nl> + # ifndef GL_OES_stencil4 <nl> + # define GL_OES_stencil4 1 <nl> + # endif <nl> + <nl> + / * GL_OES_texture_3D * / <nl> + # ifndef GL_OES_texture_3D <nl> + # define GL_OES_texture_3D 1 <nl> + # ifdef GL_GLEXT_PROTOTYPES <nl> + GL_APICALL void GL_APIENTRY glTexImage3DOES ( GLenum target , GLint level , GLenum internalformat , GLsizei width , GLsizei height , GLsizei depth , GLint border , GLenum format , GLenum type , const GLvoid * pixels ) ; <nl> + GL_APICALL void GL_APIENTRY glTexSubImage3DOES ( GLenum target , GLint level , GLint xoffset , GLint yoffset , GLint zoffset , GLsizei width , GLsizei height , GLsizei depth , GLenum format , GLenum type , const GLvoid * pixels ) ; <nl> + GL_APICALL void GL_APIENTRY glCopyTexSubImage3DOES ( GLenum target , GLint level , GLint xoffset , GLint yoffset , GLint zoffset , GLint x , GLint y , GLsizei width , GLsizei height ) ; <nl> + GL_APICALL void GL_APIENTRY glCompressedTexImage3DOES ( GLenum target , GLint level , GLenum internalformat , GLsizei width , GLsizei height , GLsizei depth , GLint border , GLsizei imageSize , const GLvoid * data ) ; <nl> + GL_APICALL void GL_APIENTRY glCompressedTexSubImage3DOES ( GLenum target , GLint level , GLint xoffset , GLint yoffset , GLint zoffset , GLsizei width , GLsizei height , GLsizei depth , GLenum format , GLsizei imageSize , const GLvoid * data ) ; <nl> + GL_APICALL void GL_APIENTRY glFramebufferTexture3DOES ( GLenum target , GLenum attachment , GLenum textarget , GLuint texture , GLint level , GLint zoffset ) ; <nl> + # endif <nl> + typedef void ( GL_APIENTRYP PFNGLTEXIMAGE3DOESPROC ) ( GLenum target , GLint level , GLenum internalformat , GLsizei width , GLsizei height , GLsizei depth , GLint border , GLenum format , GLenum type , const GLvoid * pixels ) ; <nl> + typedef void ( GL_APIENTRYP PFNGLTEXSUBIMAGE3DOESPROC ) ( GLenum target , GLint level , GLint xoffset , GLint yoffset , GLint zoffset , GLsizei width , GLsizei height , GLsizei depth , GLenum format , GLenum type , const GLvoid * pixels ) ; <nl> + typedef void ( GL_APIENTRYP PFNGLCOPYTEXSUBIMAGE3DOESPROC ) ( GLenum target , GLint level , GLint xoffset , GLint yoffset , GLint zoffset , GLint x , GLint y , GLsizei width , GLsizei height ) ; <nl> + typedef void ( GL_APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DOESPROC ) ( GLenum target , GLint level , GLenum internalformat , GLsizei width , GLsizei height , GLsizei depth , GLint border , GLsizei imageSize , const GLvoid * data ) ; <nl> + typedef void ( GL_APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DOESPROC ) ( GLenum target , GLint level , GLint xoffset , GLint yoffset , GLint zoffset , GLsizei width , GLsizei height , GLsizei depth , GLenum format , GLsizei imageSize , const GLvoid * data ) ; <nl> + typedef void ( GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DOES ) ( GLenum target , GLenum attachment , GLenum textarget , GLuint texture , GLint level , GLint zoffset ) ; <nl> + # endif <nl> + <nl> + / * GL_OES_texture_float * / <nl> + # ifndef GL_OES_texture_float <nl> + # define GL_OES_texture_float 1 <nl> + # endif <nl> + <nl> + / * GL_OES_texture_float_linear * / <nl> + # ifndef GL_OES_texture_float_linear <nl> + # define GL_OES_texture_float_linear 1 <nl> + # endif <nl> + <nl> + / * GL_OES_texture_half_float * / <nl> + # ifndef GL_OES_texture_half_float <nl> + # define GL_OES_texture_half_float 1 <nl> + # endif <nl> + <nl> + / * GL_OES_texture_half_float_linear * / <nl> + # ifndef GL_OES_texture_half_float_linear <nl> + # define GL_OES_texture_half_float_linear 1 <nl> + # endif <nl> + <nl> + / * GL_OES_texture_npot * / <nl> + # ifndef GL_OES_texture_npot <nl> + # define GL_OES_texture_npot 1 <nl> + # endif <nl> + <nl> + / * GL_OES_vertex_array_object * / <nl> + # ifndef GL_OES_vertex_array_object <nl> + # define GL_OES_vertex_array_object 1 <nl> + # ifdef GL_GLEXT_PROTOTYPES <nl> + GL_APICALL void GL_APIENTRY glBindVertexArrayOES ( GLuint array ) ; <nl> + GL_APICALL void GL_APIENTRY glDeleteVertexArraysOES ( GLsizei n , const GLuint * arrays ) ; <nl> + GL_APICALL void GL_APIENTRY glGenVertexArraysOES ( GLsizei n , GLuint * arrays ) ; <nl> + GL_APICALL GLboolean GL_APIENTRY glIsVertexArrayOES ( GLuint array ) ; <nl> + # endif <nl> + typedef void ( GL_APIENTRYP PFNGLBINDVERTEXARRAYOESPROC ) ( GLuint array ) ; <nl> + typedef void ( GL_APIENTRYP PFNGLDELETEVERTEXARRAYSOESPROC ) ( GLsizei n , const GLuint * arrays ) ; <nl> + typedef void ( GL_APIENTRYP PFNGLGENVERTEXARRAYSOESPROC ) ( GLsizei n , GLuint * arrays ) ; <nl> + typedef GLboolean ( GL_APIENTRYP PFNGLISVERTEXARRAYOESPROC ) ( GLuint array ) ; <nl> + # endif <nl> + <nl> + / * GL_OES_vertex_half_float * / <nl> + # ifndef GL_OES_vertex_half_float <nl> + # define GL_OES_vertex_half_float 1 <nl> + # endif <nl> + <nl> + / * GL_OES_vertex_type_10_10_10_2 * / <nl> + # ifndef GL_OES_vertex_type_10_10_10_2 <nl> + # define GL_OES_vertex_type_10_10_10_2 1 <nl> + # endif <nl> + <nl> + / * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * <nl> + * AMD extension functions <nl> + * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * / <nl> + <nl> + / * GL_AMD_compressed_3DC_texture * / <nl> + # ifndef GL_AMD_compressed_3DC_texture <nl> + # define GL_AMD_compressed_3DC_texture 1 <nl> + # endif <nl> + <nl> + / * GL_AMD_compressed_ATC_texture * / <nl> + # ifndef GL_AMD_compressed_ATC_texture <nl> + # define GL_AMD_compressed_ATC_texture 1 <nl> + # endif <nl> + <nl> + / * AMD_performance_monitor * / <nl> + # ifndef GL_AMD_performance_monitor <nl> + # define GL_AMD_performance_monitor 1 <nl> + # ifdef GL_GLEXT_PROTOTYPES <nl> + GL_APICALL void GL_APIENTRY glGetPerfMonitorGroupsAMD ( GLint * numGroups , GLsizei groupsSize , GLuint * groups ) ; <nl> + GL_APICALL void GL_APIENTRY glGetPerfMonitorCountersAMD ( GLuint group , GLint * numCounters , GLint * maxActiveCounters , GLsizei counterSize , GLuint * counters ) ; <nl> + GL_APICALL void GL_APIENTRY glGetPerfMonitorGroupStringAMD ( GLuint group , GLsizei bufSize , GLsizei * length , char * groupString ) ; <nl> + GL_APICALL void GL_APIENTRY glGetPerfMonitorCounterStringAMD ( GLuint group , GLuint counter , GLsizei bufSize , GLsizei * length , char * counterString ) ; <nl> + GL_APICALL void GL_APIENTRY glGetPerfMonitorCounterInfoAMD ( GLuint group , GLuint counter , GLenum pname , GLvoid * data ) ; <nl> + GL_APICALL void GL_APIENTRY glGenPerfMonitorsAMD ( GLsizei n , GLuint * monitors ) ; <nl> + GL_APICALL void GL_APIENTRY glDeletePerfMonitorsAMD ( GLsizei n , GLuint * monitors ) ; <nl> + GL_APICALL void GL_APIENTRY glSelectPerfMonitorCountersAMD ( GLuint monitor , GLboolean enable , GLuint group , GLint numCounters , GLuint * countersList ) ; <nl> + GL_APICALL void GL_APIENTRY glBeginPerfMonitorAMD ( GLuint monitor ) ; <nl> + GL_APICALL void GL_APIENTRY glEndPerfMonitorAMD ( GLuint monitor ) ; <nl> + GL_APICALL void GL_APIENTRY glGetPerfMonitorCounterDataAMD ( GLuint monitor , GLenum pname , GLsizei dataSize , GLuint * data , GLint * bytesWritten ) ; <nl> + # endif <nl> + typedef void ( GL_APIENTRYP PFNGLGETPERFMONITORGROUPSAMDPROC ) ( GLint * numGroups , GLsizei groupsSize , GLuint * groups ) ; <nl> + typedef void ( GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERSAMDPROC ) ( GLuint group , GLint * numCounters , GLint * maxActiveCounters , GLsizei counterSize , GLuint * counters ) ; <nl> + typedef void ( GL_APIENTRYP PFNGLGETPERFMONITORGROUPSTRINGAMDPROC ) ( GLuint group , GLsizei bufSize , GLsizei * length , char * groupString ) ; <nl> + typedef void ( GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERSTRINGAMDPROC ) ( GLuint group , GLuint counter , GLsizei bufSize , GLsizei * length , char * counterString ) ; <nl> + typedef void ( GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERINFOAMDPROC ) ( GLuint group , GLuint counter , GLenum pname , GLvoid * data ) ; <nl> + typedef void ( GL_APIENTRYP PFNGLGENPERFMONITORSAMDPROC ) ( GLsizei n , GLuint * monitors ) ; <nl> + typedef void ( GL_APIENTRYP PFNGLDELETEPERFMONITORSAMDPROC ) ( GLsizei n , GLuint * monitors ) ; <nl> + typedef void ( GL_APIENTRYP PFNGLSELECTPERFMONITORCOUNTERSAMDPROC ) ( GLuint monitor , GLboolean enable , GLuint group , GLint numCounters , GLuint * countersList ) ; <nl> + typedef void ( GL_APIENTRYP PFNGLBEGINPERFMONITORAMDPROC ) ( GLuint monitor ) ; <nl> + typedef void ( GL_APIENTRYP PFNGLENDPERFMONITORAMDPROC ) ( GLuint monitor ) ; <nl> + typedef void ( GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERDATAAMDPROC ) ( GLuint monitor , GLenum pname , GLsizei dataSize , GLuint * data , GLint * bytesWritten ) ; <nl> + # endif <nl> + <nl> + / * GL_AMD_program_binary_Z400 * / <nl> + # ifndef GL_AMD_program_binary_Z400 <nl> + # define GL_AMD_program_binary_Z400 1 <nl> + # endif <nl> + <nl> + / * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * <nl> + * ANGLE extension functions <nl> + * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * / <nl> + <nl> + / * GL_ANGLE_framebuffer_blit * / <nl> + # ifndef GL_ANGLE_framebuffer_blit <nl> + # define GL_ANGLE_framebuffer_blit 1 <nl> + # ifdef GL_GLEXT_PROTOTYPES <nl> + GL_APICALL void GL_APIENTRY glBlitFramebufferANGLE ( GLint srcX0 , GLint srcY0 , GLint srcX1 , GLint srcY1 , GLint dstX0 , GLint dstY0 , GLint dstX1 , GLint dstY1 , GLbitfield mask , GLenum filter ) ; <nl> + # endif <nl> + typedef void ( GL_APIENTRYP PFNGLBLITFRAMEBUFFERANGLEPROC ) ( GLint srcX0 , GLint srcY0 , GLint srcX1 , GLint srcY1 , GLint dstX0 , GLint dstY0 , GLint dstX1 , GLint dstY1 , GLbitfield mask , GLenum filter ) ; <nl> + # endif <nl> + <nl> + / * GL_ANGLE_framebuffer_multisample * / <nl> + # ifndef GL_ANGLE_framebuffer_multisample <nl> + # define GL_ANGLE_framebuffer_multisample 1 <nl> + # ifdef GL_GLEXT_PROTOTYPES <nl> + GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleANGLE ( GLenum target , GLsizei samples , GLenum internalformat , GLsizei width , GLsizei height ) ; <nl> + # endif <nl> + typedef void ( GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEANGLEPROC ) ( GLenum target , GLsizei samples , GLenum internalformat , GLsizei width , GLsizei height ) ; <nl> + # endif <nl> + <nl> + / * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * <nl> + * APPLE extension functions <nl> + * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * / <nl> + <nl> + / * GL_APPLE_rgb_422 * / <nl> + # ifndef GL_APPLE_rgb_422 <nl> + # define GL_APPLE_rgb_422 1 <nl> + # endif <nl> + <nl> + / * GL_APPLE_framebuffer_multisample * / <nl> + # ifndef GL_APPLE_framebuffer_multisample <nl> + # define GL_APPLE_framebuffer_multisample 1 <nl> + # ifdef GL_GLEXT_PROTOTYPES <nl> + GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleAPPLE ( GLenum , GLsizei , GLenum , GLsizei , GLsizei ) ; <nl> + GL_APICALL void GL_APIENTRY glResolveMultisampleFramebufferAPPLE ( void ) ; <nl> + # endif / * GL_GLEXT_PROTOTYPES * / <nl> + typedef void ( GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEAPPLEPROC ) ( GLenum target , GLsizei samples , GLenum internalformat , GLsizei width , GLsizei height ) ; <nl> + typedef void ( GL_APIENTRYP PFNGLRESOLVEMULTISAMPLEFRAMEBUFFERAPPLEPROC ) ( void ) ; <nl> + # endif <nl> + <nl> + / * GL_APPLE_texture_format_BGRA8888 * / <nl> + # ifndef GL_APPLE_texture_format_BGRA8888 <nl> + # define GL_APPLE_texture_format_BGRA8888 1 <nl> + # endif <nl> + <nl> + / * GL_APPLE_texture_max_level * / <nl> + # ifndef GL_APPLE_texture_max_level <nl> + # define GL_APPLE_texture_max_level 1 <nl> + # endif <nl> + <nl> + / * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * <nl> + * ARM extension functions <nl> + * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * / <nl> + <nl> + / * GL_ARM_mali_shader_binary * / <nl> + # ifndef GL_ARM_mali_shader_binary <nl> + # define GL_ARM_mali_shader_binary 1 <nl> + # endif <nl> + <nl> + / * GL_ARM_rgba8 * / <nl> + # ifndef GL_ARM_rgba8 <nl> + # define GL_ARM_rgba8 1 <nl> + # endif <nl> + <nl> + / * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * <nl> + * EXT extension functions <nl> + * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * / <nl> + <nl> + / * GL_EXT_blend_minmax * / <nl> + # ifndef GL_EXT_blend_minmax <nl> + # define GL_EXT_blend_minmax 1 <nl> + # endif <nl> + <nl> + / * GL_EXT_discard_framebuffer * / <nl> + # ifndef GL_EXT_discard_framebuffer <nl> + # define GL_EXT_discard_framebuffer 1 <nl> + # ifdef GL_GLEXT_PROTOTYPES <nl> + GL_APICALL void GL_APIENTRY glDiscardFramebufferEXT ( GLenum target , GLsizei numAttachments , const GLenum * attachments ) ; <nl> + # endif <nl> + typedef void ( GL_APIENTRYP PFNGLDISCARDFRAMEBUFFEREXTPROC ) ( GLenum target , GLsizei numAttachments , const GLenum * attachments ) ; <nl> + # endif <nl> + <nl> + # ifndef GL_EXT_multi_draw_arrays <nl> + # define GL_EXT_multi_draw_arrays 1 <nl> + # ifdef GL_GLEXT_PROTOTYPES <nl> + GL_APICALL void GL_APIENTRY glMultiDrawArraysEXT ( GLenum , GLint * , GLsizei * , GLsizei ) ; <nl> + GL_APICALL void GL_APIENTRY glMultiDrawElementsEXT ( GLenum , const GLsizei * , GLenum , const GLvoid * * , GLsizei ) ; <nl> + # endif / * GL_GLEXT_PROTOTYPES * / <nl> + typedef void ( GL_APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC ) ( GLenum mode , GLint * first , GLsizei * count , GLsizei primcount ) ; <nl> + typedef void ( GL_APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC ) ( GLenum mode , const GLsizei * count , GLenum type , const GLvoid * * indices , GLsizei primcount ) ; <nl> + # endif <nl> + <nl> + / * GL_EXT_read_format_bgra * / <nl> + # ifndef GL_EXT_read_format_bgra <nl> + # define GL_EXT_read_format_bgra 1 <nl> + # endif <nl> + <nl> + / * GL_EXT_texture_filter_anisotropic * / <nl> + # ifndef GL_EXT_texture_filter_anisotropic <nl> + # define GL_EXT_texture_filter_anisotropic 1 <nl> + # endif <nl> + <nl> + / * GL_EXT_texture_format_BGRA8888 * / <nl> + # ifndef GL_EXT_texture_format_BGRA8888 <nl> + # define GL_EXT_texture_format_BGRA8888 1 <nl> + # endif <nl> + <nl> + / * GL_EXT_texture_type_2_10_10_10_REV * / <nl> + # ifndef GL_EXT_texture_type_2_10_10_10_REV <nl> + # define GL_EXT_texture_type_2_10_10_10_REV 1 <nl> + # endif <nl> + <nl> + / * GL_EXT_texture_compression_dxt1 * / <nl> + # ifndef GL_EXT_texture_compression_dxt1 <nl> + # define GL_EXT_texture_compression_dxt1 1 <nl> + # endif <nl> + <nl> + / * GL_EXT_shader_texture_lod * / <nl> + # ifndef GL_EXT_shader_texture_lod <nl> + # define GL_EXT_shader_texture_lod 1 <nl> + # endif <nl> + <nl> + / * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * <nl> + * IMG extension functions <nl> + * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * / <nl> + <nl> + / * GL_IMG_program_binary * / <nl> + # ifndef GL_IMG_program_binary <nl> + # define GL_IMG_program_binary 1 <nl> + # endif <nl> + <nl> + / * GL_IMG_read_format * / <nl> + # ifndef GL_IMG_read_format <nl> + # define GL_IMG_read_format 1 <nl> + # endif <nl> + <nl> + / * GL_IMG_shader_binary * / <nl> + # ifndef GL_IMG_shader_binary <nl> + # define GL_IMG_shader_binary 1 <nl> + # endif <nl> + <nl> + / * GL_IMG_texture_compression_pvrtc * / <nl> + # ifndef GL_IMG_texture_compression_pvrtc <nl> + # define GL_IMG_texture_compression_pvrtc 1 <nl> + # endif <nl> + <nl> + / * GL_IMG_multisampled_render_to_texture * / <nl> + # ifndef GL_IMG_multisampled_render_to_texture <nl> + # define GL_IMG_multisampled_render_to_texture 1 <nl> + # ifdef GL_GLEXT_PROTOTYPES <nl> + GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleIMG ( GLenum , GLsizei , GLenum , GLsizei , GLsizei ) ; <nl> + GL_APICALL void GL_APIENTRY glFramebufferTexture2DMultisampleIMG ( GLenum , GLenum , GLenum , GLuint , GLint , GLsizei ) ; <nl> + # endif <nl> + typedef void ( GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEIMG ) ( GLenum target , GLsizei samples , GLenum internalformat , GLsizei width , GLsizei height ) ; <nl> + typedef void ( GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEIMG ) ( GLenum target , GLenum attachment , GLenum textarget , GLuint texture , GLint level , GLsizei samples ) ; <nl> + # endif <nl> + <nl> + / * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * <nl> + * NV extension functions <nl> + * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * / <nl> + <nl> + / * GL_NV_fence * / <nl> + # ifndef GL_NV_fence <nl> + # define GL_NV_fence 1 <nl> + # ifdef GL_GLEXT_PROTOTYPES <nl> + GL_APICALL void GL_APIENTRY glDeleteFencesNV ( GLsizei , const GLuint * ) ; <nl> + GL_APICALL void GL_APIENTRY glGenFencesNV ( GLsizei , GLuint * ) ; <nl> + GL_APICALL GLboolean GL_APIENTRY glIsFenceNV ( GLuint ) ; <nl> + GL_APICALL GLboolean GL_APIENTRY glTestFenceNV ( GLuint ) ; <nl> + GL_APICALL void GL_APIENTRY glGetFenceivNV ( GLuint , GLenum , GLint * ) ; <nl> + GL_APICALL void GL_APIENTRY glFinishFenceNV ( GLuint ) ; <nl> + GL_APICALL void GL_APIENTRY glSetFenceNV ( GLuint , GLenum ) ; <nl> + # endif <nl> + typedef void ( GL_APIENTRYP PFNGLDELETEFENCESNVPROC ) ( GLsizei n , const GLuint * fences ) ; <nl> + typedef void ( GL_APIENTRYP PFNGLGENFENCESNVPROC ) ( GLsizei n , GLuint * fences ) ; <nl> + typedef GLboolean ( GL_APIENTRYP PFNGLISFENCENVPROC ) ( GLuint fence ) ; <nl> + typedef GLboolean ( GL_APIENTRYP PFNGLTESTFENCENVPROC ) ( GLuint fence ) ; <nl> + typedef void ( GL_APIENTRYP PFNGLGETFENCEIVNVPROC ) ( GLuint fence , GLenum pname , GLint * params ) ; <nl> + typedef void ( GL_APIENTRYP PFNGLFINISHFENCENVPROC ) ( GLuint fence ) ; <nl> + typedef void ( GL_APIENTRYP PFNGLSETFENCENVPROC ) ( GLuint fence , GLenum condition ) ; <nl> + # endif <nl> + <nl> + / * GL_NV_coverage_sample * / <nl> + # ifndef GL_NV_coverage_sample <nl> + # define GL_NV_coverage_sample 1 <nl> + # ifdef GL_GLEXT_PROTOTYPES <nl> + GL_APICALL void GL_APIENTRY glCoverageMaskNV ( GLboolean mask ) ; <nl> + GL_APICALL void GL_APIENTRY glCoverageOperationNV ( GLenum operation ) ; <nl> + # endif <nl> + typedef void ( GL_APIENTRYP PFNGLCOVERAGEMASKNVPROC ) ( GLboolean mask ) ; <nl> + typedef void ( GL_APIENTRYP PFNGLCOVERAGEOPERATIONNVPROC ) ( GLenum operation ) ; <nl> + # endif <nl> + <nl> + / * GL_NV_depth_nonlinear * / <nl> + # ifndef GL_NV_depth_nonlinear <nl> + # define GL_NV_depth_nonlinear 1 <nl> + # endif <nl> + <nl> + / * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * <nl> + * QCOM extension functions <nl> + * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * / <nl> + <nl> + / * GL_QCOM_driver_control * / <nl> + # ifndef GL_QCOM_driver_control <nl> + # define GL_QCOM_driver_control 1 <nl> + # ifdef GL_GLEXT_PROTOTYPES <nl> + GL_APICALL void GL_APIENTRY glGetDriverControlsQCOM ( GLint * num , GLsizei size , GLuint * driverControls ) ; <nl> + GL_APICALL void GL_APIENTRY glGetDriverControlStringQCOM ( GLuint driverControl , GLsizei bufSize , GLsizei * length , char * driverControlString ) ; <nl> + GL_APICALL void GL_APIENTRY glEnableDriverControlQCOM ( GLuint driverControl ) ; <nl> + GL_APICALL void GL_APIENTRY glDisableDriverControlQCOM ( GLuint driverControl ) ; <nl> + # endif <nl> + typedef void ( GL_APIENTRYP PFNGLGETDRIVERCONTROLSQCOMPROC ) ( GLint * num , GLsizei size , GLuint * driverControls ) ; <nl> + typedef void ( GL_APIENTRYP PFNGLGETDRIVERCONTROLSTRINGQCOMPROC ) ( GLuint driverControl , GLsizei bufSize , GLsizei * length , char * driverControlString ) ; <nl> + typedef void ( GL_APIENTRYP PFNGLENABLEDRIVERCONTROLQCOMPROC ) ( GLuint driverControl ) ; <nl> + typedef void ( GL_APIENTRYP PFNGLDISABLEDRIVERCONTROLQCOMPROC ) ( GLuint driverControl ) ; <nl> + # endif <nl> + <nl> + / * GL_QCOM_extended_get * / <nl> + # ifndef GL_QCOM_extended_get <nl> + # define GL_QCOM_extended_get 1 <nl> + # ifdef GL_GLEXT_PROTOTYPES <nl> + GL_APICALL void GL_APIENTRY glExtGetTexturesQCOM ( GLuint * textures , GLint maxTextures , GLint * numTextures ) ; <nl> + GL_APICALL void GL_APIENTRY glExtGetBuffersQCOM ( GLuint * buffers , GLint maxBuffers , GLint * numBuffers ) ; <nl> + GL_APICALL void GL_APIENTRY glExtGetRenderbuffersQCOM ( GLuint * renderbuffers , GLint maxRenderbuffers , GLint * numRenderbuffers ) ; <nl> + GL_APICALL void GL_APIENTRY glExtGetFramebuffersQCOM ( GLuint * framebuffers , GLint maxFramebuffers , GLint * numFramebuffers ) ; <nl> + GL_APICALL void GL_APIENTRY glExtGetTexLevelParameterivQCOM ( GLuint texture , GLenum face , GLint level , GLenum pname , GLint * params ) ; <nl> + GL_APICALL void GL_APIENTRY glExtTexObjectStateOverrideiQCOM ( GLenum target , GLenum pname , GLint param ) ; <nl> + GL_APICALL void GL_APIENTRY glExtGetTexSubImageQCOM ( GLenum target , GLint level , GLint xoffset , GLint yoffset , GLint zoffset , GLsizei width , GLsizei height , GLsizei depth , GLenum format , GLenum type , GLvoid * texels ) ; <nl> + GL_APICALL void GL_APIENTRY glExtGetBufferPointervQCOM ( GLenum target , GLvoid * * params ) ; <nl> + # endif <nl> + typedef void ( GL_APIENTRYP PFNGLEXTGETTEXTURESQCOMPROC ) ( GLuint * textures , GLint maxTextures , GLint * numTextures ) ; <nl> + typedef void ( GL_APIENTRYP PFNGLEXTGETBUFFERSQCOMPROC ) ( GLuint * buffers , GLint maxBuffers , GLint * numBuffers ) ; <nl> + typedef void ( GL_APIENTRYP PFNGLEXTGETRENDERBUFFERSQCOMPROC ) ( GLuint * renderbuffers , GLint maxRenderbuffers , GLint * numRenderbuffers ) ; <nl> + typedef void ( GL_APIENTRYP PFNGLEXTGETFRAMEBUFFERSQCOMPROC ) ( GLuint * framebuffers , GLint maxFramebuffers , GLint * numFramebuffers ) ; <nl> + typedef void ( GL_APIENTRYP PFNGLEXTGETTEXLEVELPARAMETERIVQCOMPROC ) ( GLuint texture , GLenum face , GLint level , GLenum pname , GLint * params ) ; <nl> + typedef void ( GL_APIENTRYP PFNGLEXTTEXOBJECTSTATEOVERRIDEIQCOMPROC ) ( GLenum target , GLenum pname , GLint param ) ; <nl> + typedef void ( GL_APIENTRYP PFNGLEXTGETTEXSUBIMAGEQCOMPROC ) ( GLenum target , GLint level , GLint xoffset , GLint yoffset , GLint zoffset , GLsizei width , GLsizei height , GLsizei depth , GLenum format , GLenum type , GLvoid * texels ) ; <nl> + typedef void ( GL_APIENTRYP PFNGLEXTGETBUFFERPOINTERVQCOMPROC ) ( GLenum target , GLvoid * * params ) ; <nl> + # endif <nl> + <nl> + / * GL_QCOM_extended_get2 * / <nl> + # ifndef GL_QCOM_extended_get2 <nl> + # define GL_QCOM_extended_get2 1 <nl> + # ifdef GL_GLEXT_PROTOTYPES <nl> + GL_APICALL void GL_APIENTRY glExtGetShadersQCOM ( GLuint * shaders , GLint maxShaders , GLint * numShaders ) ; <nl> + GL_APICALL void GL_APIENTRY glExtGetProgramsQCOM ( GLuint * programs , GLint maxPrograms , GLint * numPrograms ) ; <nl> + GL_APICALL GLboolean GL_APIENTRY glExtIsProgramBinaryQCOM ( GLuint program ) ; <nl> + GL_APICALL void GL_APIENTRY glExtGetProgramBinarySourceQCOM ( GLuint program , GLenum shadertype , char * source , GLint * length ) ; <nl> + # endif <nl> + typedef void ( GL_APIENTRYP PFNGLEXTGETSHADERSQCOMPROC ) ( GLuint * shaders , GLint maxShaders , GLint * numShaders ) ; <nl> + typedef void ( GL_APIENTRYP PFNGLEXTGETPROGRAMSQCOMPROC ) ( GLuint * programs , GLint maxPrograms , GLint * numPrograms ) ; <nl> + typedef GLboolean ( GL_APIENTRYP PFNGLEXTISPROGRAMBINARYQCOMPROC ) ( GLuint program ) ; <nl> + typedef void ( GL_APIENTRYP PFNGLEXTGETPROGRAMBINARYSOURCEQCOMPROC ) ( GLuint program , GLenum shadertype , char * source , GLint * length ) ; <nl> + # endif <nl> + <nl> + / * GL_QCOM_perfmon_global_mode * / <nl> + # ifndef GL_QCOM_perfmon_global_mode <nl> + # define GL_QCOM_perfmon_global_mode 1 <nl> + # endif <nl> + <nl> + / * GL_QCOM_writeonly_rendering * / <nl> + # ifndef GL_QCOM_writeonly_rendering <nl> + # define GL_QCOM_writeonly_rendering 1 <nl> + # endif <nl> + <nl> + / * GL_QCOM_tiled_rendering * / <nl> + # ifndef GL_QCOM_tiled_rendering <nl> + # define GL_QCOM_tiled_rendering 1 <nl> + # ifdef GL_GLEXT_PROTOTYPES <nl> + GL_APICALL void GL_APIENTRY glStartTilingQCOM ( GLuint x , GLuint y , GLuint width , GLuint height , GLbitfield preserveMask ) ; <nl> + GL_APICALL void GL_APIENTRY glEndTilingQCOM ( GLbitfield preserveMask ) ; <nl> + # endif <nl> + typedef void ( GL_APIENTRYP PFNGLSTARTTILINGQCOMPROC ) ( GLuint x , GLuint y , GLuint width , GLuint height , GLbitfield preserveMask ) ; <nl> + typedef void ( GL_APIENTRYP PFNGLENDTILINGQCOMPROC ) ( GLbitfield preserveMask ) ; <nl> + # endif <nl> + <nl> + / * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * <nl> + * VIV extension tokens <nl> + * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * / <nl> + <nl> + / * GL_VIV_shader_binary * / <nl> + # ifndef GL_VIV_shader_binary <nl> + # define GL_VIV_shader_binary 1 <nl> + # endif <nl> + <nl> + # ifdef __cplusplus <nl> + } <nl> + # endif <nl> + <nl> + # endif / * __gl2ext_h_ * / <nl> mmm a / cocos2dx / platform / third_party / win32 / OGLES / GLES2 / gl2extimg . h <nl> ppp b / cocos2dx / platform / third_party / win32 / OGLES / GLES2 / gl2extimg . h <nl> <nl> - # ifndef __gl2extimg_h_ <nl> - # define __gl2extimg_h_ <nl> - <nl> - # ifdef __cplusplus <nl> - extern " C " { <nl> - # endif <nl> - <nl> - / * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * <nl> - * IMG extension tokens <nl> - * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * / <nl> - <nl> - / * GL_IMG_binary_shader * / <nl> - # ifndef GL_IMG_binary_shader <nl> - # define GL_SGX_BINARY_IMG 0x8C0A <nl> - # endif <nl> - <nl> - / * GL_IMG_texture_compression_pvrtc * / <nl> - # ifndef GL_IMG_texture_compression_pvrtc <nl> - # define GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG 0x8C00 <nl> - # define GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG 0x8C01 <nl> - # define GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG 0x8C02 <nl> - # define GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG 0x8C03 <nl> - # endif <nl> - <nl> - <nl> - / * GL_IMG_texture_format_BGRA8888 * / <nl> - # define GL_BGRA 0x80E1 <nl> - <nl> - / * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * <nl> - * IMG extension functions <nl> - * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * / <nl> - <nl> - / * GL_IMG_binary_shader * / <nl> - # ifndef GL_IMG_binary_shader <nl> - # define GL_IMG_binary_shader 1 <nl> - # endif <nl> - <nl> - / * GL_IMG_texture_compression_pvrtc * / <nl> - # ifndef GL_IMG_texture_compression_pvrtc <nl> - # define GL_IMG_texture_compression_pvrtc 1 <nl> - # endif <nl> - <nl> - # ifdef __cplusplus <nl> - } <nl> - # endif <nl> - <nl> - # endif / * __gl2extimg_h_ * / <nl> + # ifndef __gl2extimg_h_ <nl> + # define __gl2extimg_h_ <nl> + <nl> + # ifdef __cplusplus <nl> + extern " C " { <nl> + # endif <nl> + <nl> + / * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * <nl> + * IMG extension tokens <nl> + * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * / <nl> + <nl> + / * GL_IMG_binary_shader * / <nl> + # ifndef GL_IMG_binary_shader <nl> + # define GL_SGX_BINARY_IMG 0x8C0A <nl> + # endif <nl> + <nl> + / * GL_IMG_texture_compression_pvrtc * / <nl> + # ifndef GL_IMG_texture_compression_pvrtc <nl> + # define GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG 0x8C00 <nl> + # define GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG 0x8C01 <nl> + # define GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG 0x8C02 <nl> + # define GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG 0x8C03 <nl> + # endif <nl> + <nl> + <nl> + / * GL_IMG_texture_format_BGRA8888 * / <nl> + # define GL_BGRA 0x80E1 <nl> + <nl> + / * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * <nl> + * IMG extension functions <nl> + * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * / <nl> + <nl> + / * GL_IMG_binary_shader * / <nl> + # ifndef GL_IMG_binary_shader <nl> + # define GL_IMG_binary_shader 1 <nl> + # endif <nl> + <nl> + / * GL_IMG_texture_compression_pvrtc * / <nl> + # ifndef GL_IMG_texture_compression_pvrtc <nl> + # define GL_IMG_texture_compression_pvrtc 1 <nl> + # endif <nl> + <nl> + # ifdef __cplusplus <nl> + } <nl> + # endif <nl> + <nl> + # endif / * __gl2extimg_h_ * / <nl> mmm a / cocos2dx / platform / third_party / win32 / OGLES / GLES2 / gl2platform . h <nl> ppp b / cocos2dx / platform / third_party / win32 / OGLES / GLES2 / gl2platform . h <nl> <nl> - # ifndef __gl2platform_h_ <nl> - # define __gl2platform_h_ <nl> - <nl> - / * <nl> - * This document is licensed under the SGI Free Software B License Version <nl> - * 2 . 0 . For details , see http : / / oss . sgi . com / projects / FreeB / . <nl> - * / <nl> - <nl> - / * Platform - specific types and definitions for OpenGL ES 2 . X gl2 . h <nl> - * <nl> - * Adopters may modify khrplatform . h and this file to suit their platform . <nl> - * You are encouraged to submit all modifications to the Khronos group so that <nl> - * they can be included in future versions of this file . Please submit changes <nl> - * by sending them to the public Khronos Bugzilla ( http : / / khronos . org / bugzilla ) <nl> - * by filing a bug against product " OpenGL - ES " component " Registry " . <nl> - * / <nl> - <nl> - # include < KHR / khrplatform . h > <nl> - <nl> - # ifndef GL_APICALL <nl> - # define GL_APICALL KHRONOS_APICALL <nl> - # endif <nl> - <nl> - # ifndef GL_APIENTRY <nl> - # define GL_APIENTRY KHRONOS_APIENTRY <nl> - # endif <nl> - <nl> - # endif / * __gl2platform_h_ * / <nl> + # ifndef __gl2platform_h_ <nl> + # define __gl2platform_h_ <nl> + <nl> + / * <nl> + * This document is licensed under the SGI Free Software B License Version <nl> + * 2 . 0 . For details , see http : / / oss . sgi . com / projects / FreeB / . <nl> + * / <nl> + <nl> + / * Platform - specific types and definitions for OpenGL ES 2 . X gl2 . h <nl> + * <nl> + * Adopters may modify khrplatform . h and this file to suit their platform . <nl> + * You are encouraged to submit all modifications to the Khronos group so that <nl> + * they can be included in future versions of this file . Please submit changes <nl> + * by sending them to the public Khronos Bugzilla ( http : / / khronos . org / bugzilla ) <nl> + * by filing a bug against product " OpenGL - ES " component " Registry " . <nl> + * / <nl> + <nl> + # include < KHR / khrplatform . h > <nl> + <nl> + # ifndef GL_APICALL <nl> + # define GL_APICALL KHRONOS_APICALL <nl> + # endif <nl> + <nl> + # ifndef GL_APIENTRY <nl> + # define GL_APIENTRY KHRONOS_APIENTRY <nl> + # endif <nl> + <nl> + # endif / * __gl2platform_h_ * / <nl> mmm a / cocos2dx / platform / third_party / win32 / OGLES / KHR / khrplatform . h <nl> ppp b / cocos2dx / platform / third_party / win32 / OGLES / KHR / khrplatform . h <nl> <nl> <nl> / * Khronos platform - specific types and definitions . <nl> * <nl> - * $ Revision : 1 . 5 $ on $ Date : 2011 / 05 / 31 15 : 09 : 03 $ <nl> + * $ Revision : 1 . 5 $ on $ Date : 2010 / 06 / 03 16 : 51 : 55 $ <nl> * <nl> * Adopters may modify this file to suit their platform . Adopters are <nl> * encouraged to submit platform specific modifications to the Khronos <nl> <nl> * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> * This precedes the return type of the function in the function prototype . <nl> * / <nl> - <nl> - # if ( defined ( _WIN32 ) | | defined ( __VC32__ ) ) & & ! defined ( __SCITECH_SNAP__ ) <nl> + <nl> + # if ( defined ( _WIN32 ) | | defined ( __VC32__ ) ) & & ! defined ( __SCITECH_SNAP__ ) & & ! defined ( __WINSCW__ ) <nl> # if defined ( _DLL_EXPORTS ) <nl> # define KHRONOS_APICALL __declspec ( dllexport ) <nl> # else <nl> <nl> * This follows the return type of the function and precedes the function <nl> * name in the function prototype . <nl> * / <nl> - # if defined ( _WIN32 ) & & ! defined ( _WIN32_WCE ) & & ! defined ( __SCITECH_SNAP__ ) <nl> + # if defined ( _WIN32 ) & & ! defined ( _WIN32_WCE ) & & ! defined ( __SCITECH_SNAP__ ) & & ! defined ( __WINSCW__ ) <nl> / * Win32 but not WinCE * / <nl> # define KHRONOS_APIENTRY __stdcall <nl> # else <nl> mmm a / cocos2dx / platform / third_party / win32 / libraries / libEGL . dll . REMOVED . git - id <nl> ppp b / cocos2dx / platform / third_party / win32 / libraries / libEGL . dll . REMOVED . git - id <nl> @ @ - 1 + 1 @ @ <nl> - e6bbe23eb4a9c399bfc682646f3060b0b11d9b15 <nl> \ No newline at end of file <nl> + 94cfb991773a35b467f19af4bde43d039ad534e7 <nl> \ No newline at end of file <nl> mmm a / cocos2dx / platform / third_party / win32 / libraries / libGLESv2 . dll . REMOVED . git - id <nl> ppp b / cocos2dx / platform / third_party / win32 / libraries / libGLESv2 . dll . REMOVED . git - id <nl> @ @ - 1 + 1 @ @ <nl> - 71aae6253a4c404102c1081a6a1f2df428a12d0d <nl> \ No newline at end of file <nl> + ebda058de3bf9518d8a4381f87b6796169f38538 <nl> \ No newline at end of file <nl>
|
issue : Reverted opengles emulator version to 2 . 09 , because there are some issues in v2 . 10 .
|
cocos2d/cocos2d-x
|
394bb24cf55fda0fe3146d73f4b9c16499749288
|
2012-03-27T06:11:28Z
|
mmm a / src / mongo / db / repl / SConscript <nl> ppp b / src / mongo / db / repl / SConscript <nl> env . Library ( target = ' optime ' , <nl> LIBDEPS = [ <nl> ' $ BUILD_DIR / mongo / bson / bson ' , <nl> ] ) <nl> + <nl> + env . Library ( <nl> + target = ' applier ' , <nl> + source = [ <nl> + ' applier . cpp ' , <nl> + ] , <nl> + LIBDEPS = [ <nl> + ] , <nl> + ) <nl> + <nl> + env . CppUnitTest ( <nl> + target = ' applier_test ' , <nl> + source = ' applier_test . cpp ' , <nl> + LIBDEPS = [ <nl> + ' applier ' , <nl> + ' replication_executor_test_fixture ' , <nl> + ] , <nl> + ) <nl> new file mode 100644 <nl> index 000000000000 . . fd136d8a4155 <nl> mmm / dev / null <nl> ppp b / src / mongo / db / repl / applier . cpp <nl> <nl> + / * * <nl> + * Copyright ( C ) 2015 MongoDB Inc . <nl> + * <nl> + * This program is free software : you can redistribute it and / or modify <nl> + * it under the terms of the GNU Affero General Public License , version 3 , <nl> + * as published by the Free Software Foundation . <nl> + * <nl> + * This program is distributed in the hope that it will be useful , <nl> + * but WITHOUT ANY WARRANTY ; without even the implied warranty of <nl> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the <nl> + * GNU Affero General Public License for more details . <nl> + * <nl> + * You should have received a copy of the GNU Affero General Public License <nl> + * along with this program . If not , see < http : / / www . gnu . org / licenses / > . <nl> + * <nl> + * As a special exception , the copyright holders give permission to link the <nl> + * code of portions of this program with the OpenSSL library under certain <nl> + * conditions as described in each individual source file and distribute <nl> + * linked combinations including the program with the OpenSSL library . You <nl> + * must comply with the GNU Affero General Public License in all respects for <nl> + * all of the code used other than as permitted herein . If you modify file ( s ) <nl> + * with this exception , you may extend this exception to your version of the <nl> + * file ( s ) , but you are not obligated to do so . If you do not wish to do so , <nl> + * delete this exception statement from your version . If you delete this <nl> + * exception statement from all source files in the program , then also delete <nl> + * it in the license file . <nl> + * / <nl> + <nl> + # include " mongo / platform / basic . h " <nl> + <nl> + # include " mongo / db / repl / applier . h " <nl> + <nl> + # include < boost / thread / lock_guard . hpp > <nl> + # include < boost / thread / lock_types . hpp > <nl> + <nl> + # include " mongo / db / operation_context . h " <nl> + # include " mongo / db / repl / replication_executor . h " <nl> + # include " mongo / util / assert_util . h " <nl> + # include " mongo / util / mongoutils / str . h " <nl> + <nl> + namespace mongo { <nl> + namespace repl { <nl> + <nl> + Applier : : Applier ( ReplicationExecutor * executor , <nl> + const Operations & operations , <nl> + const ApplyOperationFn & applyOperation , <nl> + const CallbackFn & onCompletion ) <nl> + : _executor ( executor ) , <nl> + _operations ( operations ) , <nl> + _applyOperation ( applyOperation ) , <nl> + _onCompletion ( onCompletion ) , <nl> + _active ( false ) { <nl> + <nl> + uassert ( ErrorCodes : : BadValue , " null replication executor " , executor ) ; <nl> + uassert ( ErrorCodes : : BadValue , " empty list of operations " , ! operations . empty ( ) ) ; <nl> + uassert ( ErrorCodes : : FailedToParse , <nl> + str : : stream ( ) < < " last operation missing ' ts ' field : " < < operations . back ( ) , <nl> + operations . back ( ) . hasField ( " ts " ) ) ; <nl> + uassert ( ErrorCodes : : TypeMismatch , <nl> + str : : stream ( ) < < " ' ts ' in last operation not a timestamp : " < < operations . back ( ) , <nl> + BSONType : : bsonTimestamp = = operations . back ( ) . getField ( " ts " ) . type ( ) ) ; <nl> + uassert ( ErrorCodes : : BadValue , " apply operation function cannot be null " , applyOperation ) ; <nl> + uassert ( ErrorCodes : : BadValue , " callback function cannot be null " , onCompletion ) ; <nl> + } <nl> + <nl> + Applier : : ~ Applier ( ) { <nl> + DESTRUCTOR_GUARD ( <nl> + cancel ( ) ; <nl> + wait ( ) ; <nl> + ) ; <nl> + } <nl> + <nl> + std : : string Applier : : getDiagnosticString ( ) const { <nl> + boost : : lock_guard < boost : : mutex > lk ( _mutex ) ; <nl> + str : : stream output ; <nl> + output < < " Applier " ; <nl> + output < < " executor : " < < _executor - > getDiagnosticString ( ) ; <nl> + output < < " active : " < < _active ; <nl> + return output ; <nl> + } <nl> + <nl> + bool Applier : : isActive ( ) const { <nl> + boost : : lock_guard < boost : : mutex > lk ( _mutex ) ; <nl> + return _active ; <nl> + } <nl> + <nl> + Status Applier : : start ( ) { <nl> + boost : : lock_guard < boost : : mutex > lk ( _mutex ) ; <nl> + <nl> + if ( _active ) { <nl> + return Status ( ErrorCodes : : IllegalOperation , " applier already started " ) ; <nl> + } <nl> + <nl> + auto scheduleResult = _executor - > scheduleDBWork ( <nl> + stdx : : bind ( & Applier : : _callback , this , stdx : : placeholders : : _1 ) ) ; <nl> + if ( ! scheduleResult . isOK ( ) ) { <nl> + return scheduleResult . getStatus ( ) ; <nl> + } <nl> + <nl> + _active = true ; <nl> + _dbWorkCallbackHandle = scheduleResult . getValue ( ) ; <nl> + <nl> + return Status : : OK ( ) ; <nl> + } <nl> + <nl> + void Applier : : cancel ( ) { <nl> + ReplicationExecutor : : CallbackHandle dbWorkCallbackHandle ; <nl> + { <nl> + boost : : lock_guard < boost : : mutex > lk ( _mutex ) ; <nl> + <nl> + if ( ! _active ) { <nl> + return ; <nl> + } <nl> + <nl> + dbWorkCallbackHandle = _dbWorkCallbackHandle ; <nl> + } <nl> + <nl> + if ( dbWorkCallbackHandle . isValid ( ) ) { <nl> + _executor - > cancel ( dbWorkCallbackHandle ) ; <nl> + } <nl> + } <nl> + <nl> + void Applier : : wait ( ) { <nl> + boost : : unique_lock < boost : : mutex > lk ( _mutex ) ; <nl> + <nl> + while ( _active ) { <nl> + _condition . wait ( lk ) ; <nl> + } <nl> + } <nl> + <nl> + void Applier : : _callback ( const ReplicationExecutor : : CallbackData & cbd ) { <nl> + boost : : lock_guard < boost : : mutex > lk ( _mutex ) ; <nl> + <nl> + _active = false ; <nl> + <nl> + if ( ! cbd . status . isOK ( ) ) { <nl> + _onCompletion ( cbd . status , _operations ) ; <nl> + _condition . notify_all ( ) ; <nl> + return ; <nl> + } <nl> + <nl> + invariant ( cbd . txn ) ; <nl> + <nl> + / / Refer to multiSyncApply ( ) and multiInitialSyncApply ( ) in sync_tail . cpp . <nl> + cbd . txn - > setReplicatedWrites ( false ) ; <nl> + <nl> + / / allow us to get through the magic barrier <nl> + cbd . txn - > lockState ( ) - > setIsBatchWriter ( true ) ; <nl> + <nl> + Status applyStatus ( ErrorCodes : : InternalError , " not mutated " ) ; <nl> + auto i = _operations . cbegin ( ) ; <nl> + invariant ( i ! = _operations . cend ( ) ) ; <nl> + for ( ; i ! = _operations . cend ( ) ; + + i ) { <nl> + try { <nl> + applyStatus = _applyOperation ( cbd . txn , * i ) ; <nl> + } <nl> + catch ( . . . ) { <nl> + applyStatus = exceptionToStatus ( ) ; <nl> + } <nl> + if ( ! applyStatus . isOK ( ) ) { <nl> + break ; <nl> + } <nl> + } <nl> + / / ' i ' points to last operation that was not applied ; or cend ( ) if all operations were <nl> + / / applied successfully . <nl> + if ( ! applyStatus . isOK ( ) ) { <nl> + _onCompletion ( applyStatus , Operations ( i , _operations . cend ( ) ) ) ; <nl> + } <nl> + else { <nl> + _onCompletion ( _operations . back ( ) . getField ( " ts " ) . timestamp ( ) , Operations ( ) ) ; <nl> + } <nl> + _condition . notify_all ( ) ; <nl> + } <nl> + <nl> + } / / namespace repl <nl> + } / / namespace mongo <nl> new file mode 100644 <nl> index 000000000000 . . 204d9af2547c <nl> mmm / dev / null <nl> ppp b / src / mongo / db / repl / applier . h <nl> <nl> + / * * <nl> + * Copyright ( C ) 2015 MongoDB Inc . <nl> + * <nl> + * This program is free software : you can redistribute it and / or modify <nl> + * it under the terms of the GNU Affero General Public License , version 3 , <nl> + * as published by the Free Software Foundation . <nl> + * <nl> + * This program is distributed in the hope that it will be useful , <nl> + * but WITHOUT ANY WARRANTY ; without even the implied warranty of <nl> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the <nl> + * GNU Affero General Public License for more details . <nl> + * <nl> + * You should have received a copy of the GNU Affero General Public License <nl> + * along with this program . If not , see < http : / / www . gnu . org / licenses / > . <nl> + * <nl> + * As a special exception , the copyright holders give permission to link the <nl> + * code of portions of this program with the OpenSSL library under certain <nl> + * conditions as described in each individual source file and distribute <nl> + * linked combinations including the program with the OpenSSL library . You <nl> + * must comply with the GNU Affero General Public License in all respects for <nl> + * all of the code used other than as permitted herein . If you modify file ( s ) <nl> + * with this exception , you may extend this exception to your version of the <nl> + * file ( s ) , but you are not obligated to do so . If you do not wish to do so , <nl> + * delete this exception statement from your version . If you delete this <nl> + * exception statement from all source files in the program , then also delete <nl> + * it in the license file . <nl> + * / <nl> + <nl> + # pragma once <nl> + <nl> + # include < boost / thread / condition . hpp > <nl> + # include < boost / thread / mutex . hpp > <nl> + # include < string > <nl> + # include < vector > <nl> + <nl> + # include " mongo / base / disallow_copying . h " <nl> + # include " mongo / base / status . h " <nl> + # include " mongo / base / status_with . h " <nl> + # include " mongo / bson / bsonobj . h " <nl> + # include " mongo / db / repl / replication_executor . h " <nl> + # include " mongo / stdx / functional . h " <nl> + <nl> + namespace mongo { <nl> + namespace repl { <nl> + <nl> + class Applier { <nl> + MONGO_DISALLOW_COPYING ( Applier ) ; <nl> + public : <nl> + <nl> + using Operations = std : : vector < BSONObj > ; <nl> + <nl> + / * * <nl> + * Callback function to report final status of applying operations along with <nl> + * list of operations ( if applicable ) that were not successfully applied . <nl> + * On success , returns the timestamp of the last operation applied together with an empty <nl> + * list of operations . <nl> + * / <nl> + using CallbackFn = stdx : : function < void ( const StatusWith < Timestamp > & , const Operations & ) > ; <nl> + <nl> + / * * <nl> + * Type of function to to apply a single operation . In production , this function <nl> + * would have the same outcome as calling SyncTail : : syncApply ( ) ( ' convertUpdatesToUpserts ' <nl> + * value will be embedded in the function implementation ) . <nl> + * / <nl> + using ApplyOperationFn = stdx : : function < Status ( OperationContext * , const BSONObj & ) > ; <nl> + <nl> + / * * <nl> + * Creates Applier in inactive state . <nl> + * <nl> + * Accepts list of oplog entries to apply in ' operations ' . <nl> + * <nl> + * The callback function will be invoked ( after schedule ( ) ) when the applied has <nl> + * successfully applied all the operations or encountered a failure . Failures may occur if <nl> + * we failed to apply an operation ; or if the underlying scheduled work item <nl> + * on the replication executor was canceled . <nl> + * <nl> + * It is an error for ' operations ' to be empty but individual oplog entries <nl> + * contained in ' operations ' are not validated . <nl> + * / <nl> + Applier ( ReplicationExecutor * executor , <nl> + const Operations & operations , <nl> + const ApplyOperationFn & applyOperation , <nl> + const CallbackFn & onCompletion ) ; <nl> + <nl> + / * * <nl> + * Blocks while applier is active . <nl> + * / <nl> + virtual ~ Applier ( ) ; <nl> + <nl> + / * * <nl> + * Returns diagnostic information . <nl> + * / <nl> + std : : string getDiagnosticString ( ) const ; <nl> + <nl> + / * * <nl> + * Returns true if the applier has been started ( but has not completed ) . <nl> + * / <nl> + bool isActive ( ) const ; <nl> + <nl> + / * * <nl> + * Starts applier by scheduling initial db work to be run by the executor . <nl> + * / <nl> + Status start ( ) ; <nl> + <nl> + / * * <nl> + * Cancels current db work request . <nl> + * Returns immediately if applier is not active . <nl> + * <nl> + * Callback function may be invoked with an ErrorCodes : : CallbackCanceled status . <nl> + * / <nl> + void cancel ( ) ; <nl> + <nl> + / * * <nl> + * Waits for active database worker to complete . <nl> + * Returns immediately if applier is not active . <nl> + * / <nl> + void wait ( ) ; <nl> + <nl> + private : <nl> + <nl> + / * * <nl> + * DB worker callback function - applies all operations . <nl> + * / <nl> + void _callback ( const ReplicationExecutor : : CallbackData & cbd ) ; <nl> + <nl> + / / Not owned by us . <nl> + ReplicationExecutor * _executor ; <nl> + <nl> + Operations _operations ; <nl> + ApplyOperationFn _applyOperation ; <nl> + CallbackFn _onCompletion ; <nl> + <nl> + / / Protects member data of this Applier . <nl> + mutable boost : : mutex _mutex ; <nl> + <nl> + boost : : condition _condition ; <nl> + <nl> + / / _active is true when Applier is scheduled to be run by the executor . <nl> + bool _active ; <nl> + <nl> + ReplicationExecutor : : CallbackHandle _dbWorkCallbackHandle ; <nl> + } ; <nl> + <nl> + } / / namespace repl <nl> + } / / namespace mongo <nl> new file mode 100644 <nl> index 000000000000 . . b4c2a09f97b8 <nl> mmm / dev / null <nl> ppp b / src / mongo / db / repl / applier_test . cpp <nl> <nl> + / * * <nl> + * Copyright 2015 MongoDB Inc . <nl> + * <nl> + * This program is free software : you can redistribute it and / or modify <nl> + * it under the terms of the GNU Affero General Public License , version 3 , <nl> + * as published by the Free Software Foundation . <nl> + * <nl> + * This program is distributed in the hope that it will be useful , <nl> + * but WITHOUT ANY WARRANTY ; without even the implied warranty of <nl> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the <nl> + * GNU Affero General Public License for more details . <nl> + * <nl> + * You should have received a copy of the GNU Affero General Public License <nl> + * along with this program . If not , see < http : / / www . gnu . org / licenses / > . <nl> + * <nl> + * As a special exception , the copyright holders give permission to link the <nl> + * code of portions of this program with the OpenSSL library under certain <nl> + * conditions as described in each individual source file and distribute <nl> + * linked combinations including the program with the OpenSSL library . You <nl> + * must comply with the GNU Affero General Public License in all respects for <nl> + * all of the code used other than as permitted herein . If you modify file ( s ) <nl> + * with this exception , you may extend this exception to your version of the <nl> + * file ( s ) , but you are not obligated to do so . If you do not wish to do so , <nl> + * delete this exception statement from your version . If you delete this <nl> + * exception statement from all source files in the program , then also delete <nl> + * it in the license file . <nl> + * / <nl> + <nl> + # include " mongo / platform / basic . h " <nl> + <nl> + # include < boost / thread / barrier . hpp > <nl> + # include < boost / thread / condition . hpp > <nl> + # include < boost / thread / lock_guard . hpp > <nl> + # include < boost / thread / lock_types . hpp > <nl> + # include < boost / thread / mutex . hpp > <nl> + # include < memory > <nl> + <nl> + # include " mongo / db / jsobj . h " <nl> + # include " mongo / db / operation_context . h " <nl> + # include " mongo / db / repl / applier . h " <nl> + # include " mongo / db / repl / replication_executor . h " <nl> + # include " mongo / db / repl / replication_executor_test_fixture . h " <nl> + # include " mongo / platform / compiler . h " <nl> + <nl> + namespace { <nl> + <nl> + using namespace mongo ; <nl> + using namespace mongo : : repl ; <nl> + <nl> + using Operations = Applier : : Operations ; <nl> + <nl> + class ApplierTest : public ReplicationExecutorTest { <nl> + public : <nl> + / * * <nl> + * Creates an initial error status suitable for checking if <nl> + * applier has modified the ' status ' field in test fixture . <nl> + * / <nl> + static Status getDetectableErrorStatus ( ) ; <nl> + <nl> + void setUp ( ) override ; <nl> + void tearDown ( ) override ; <nl> + Applier * getApplier ( ) const ; <nl> + <nl> + protected : <nl> + / * * <nl> + * Test function to check behavior when we fail to apply one of the operations . <nl> + * / <nl> + void _testApplyOperationFailed ( size_t opIndex , stdx : : function < Status ( ) > fail ) ; <nl> + <nl> + std : : unique_ptr < Applier > _applier ; <nl> + } ; <nl> + <nl> + Status ApplierTest : : getDetectableErrorStatus ( ) { <nl> + return Status ( ErrorCodes : : InternalError , " Not mutated " ) ; <nl> + } <nl> + <nl> + void ApplierTest : : setUp ( ) { <nl> + ReplicationExecutorTest : : setUp ( ) ; <nl> + launchExecutorThread ( ) ; <nl> + auto apply = [ ] ( OperationContext * txn , const BSONObj & operation ) { return Status : : OK ( ) ; } ; <nl> + _applier . reset ( new Applier ( & getExecutor ( ) , <nl> + { BSON ( " ts " < < Timestamp ( Seconds ( 123 ) , 0 ) ) } , <nl> + apply , <nl> + [ ] ( const StatusWith < Timestamp > & , const Operations & ) { } ) ) ; <nl> + } <nl> + <nl> + void ApplierTest : : tearDown ( ) { <nl> + ReplicationExecutorTest : : tearDown ( ) ; <nl> + _applier . reset ( ) ; <nl> + } <nl> + <nl> + Applier * ApplierTest : : getApplier ( ) const { <nl> + return _applier . get ( ) ; <nl> + } <nl> + <nl> + TEST_F ( ApplierTest , InvalidConstruction ) { <nl> + const Operations operations { BSON ( " ts " < < Timestamp ( Seconds ( 123 ) , 0 ) ) } ; <nl> + auto apply = [ ] ( OperationContext * txn , const BSONObj & operation ) { return Status : : OK ( ) ; } ; <nl> + auto callback = [ ] ( const StatusWith < Timestamp > & status , const Operations & operations ) { } ; <nl> + <nl> + / / Null executor . <nl> + ASSERT_THROWS ( Applier ( nullptr , operations , apply , callback ) , UserException ) ; <nl> + <nl> + / / Empty list of operations . <nl> + ASSERT_THROWS ( Applier ( & getExecutor ( ) , { } , apply , callback ) , UserException ) ; <nl> + <nl> + / / Last operation missing timestamp field . <nl> + ASSERT_THROWS ( Applier ( & getExecutor ( ) , { BSONObj ( ) } , apply , callback ) , UserException ) ; <nl> + <nl> + / / " ts " field in last operation not a timestamp . <nl> + ASSERT_THROWS ( Applier ( & getExecutor ( ) , { BSON ( " ts " < < 99 ) } , apply , callback ) , UserException ) ; <nl> + <nl> + / / Invalid apply operation function . <nl> + ASSERT_THROWS ( Applier ( & getExecutor ( ) , operations , Applier : : ApplyOperationFn ( ) , callback ) , <nl> + UserException ) ; <nl> + <nl> + / / Invalid callback function . <nl> + ASSERT_THROWS ( Applier ( & getExecutor ( ) , operations , apply , Applier : : CallbackFn ( ) ) , <nl> + UserException ) ; <nl> + } <nl> + <nl> + TEST_F ( ApplierTest , GetDiagnosticString ) { <nl> + ASSERT_FALSE ( getApplier ( ) - > getDiagnosticString ( ) . empty ( ) ) ; <nl> + } <nl> + <nl> + TEST_F ( ApplierTest , IsActiveAfterStart ) { <nl> + ASSERT_FALSE ( getApplier ( ) - > isActive ( ) ) ; <nl> + ASSERT_OK ( getApplier ( ) - > start ( ) ) ; <nl> + ASSERT_TRUE ( getApplier ( ) - > isActive ( ) ) ; <nl> + } <nl> + <nl> + TEST_F ( ApplierTest , StartWhenActive ) { <nl> + ASSERT_OK ( getApplier ( ) - > start ( ) ) ; <nl> + ASSERT_TRUE ( getApplier ( ) - > isActive ( ) ) ; <nl> + ASSERT_NOT_OK ( getApplier ( ) - > start ( ) ) ; <nl> + ASSERT_TRUE ( getApplier ( ) - > isActive ( ) ) ; <nl> + } <nl> + <nl> + TEST_F ( ApplierTest , CancelWithoutStart ) { <nl> + ASSERT_FALSE ( getApplier ( ) - > isActive ( ) ) ; <nl> + getApplier ( ) - > cancel ( ) ; <nl> + ASSERT_FALSE ( getApplier ( ) - > isActive ( ) ) ; <nl> + } <nl> + <nl> + TEST_F ( ApplierTest , WaitWithoutStart ) { <nl> + ASSERT_FALSE ( getApplier ( ) - > isActive ( ) ) ; <nl> + getApplier ( ) - > wait ( ) ; <nl> + ASSERT_FALSE ( getApplier ( ) - > isActive ( ) ) ; <nl> + } <nl> + <nl> + TEST_F ( ApplierTest , ShutdownBeforeStart ) { <nl> + getExecutor ( ) . shutdown ( ) ; <nl> + ASSERT_NOT_OK ( getApplier ( ) - > start ( ) ) ; <nl> + ASSERT_FALSE ( getApplier ( ) - > isActive ( ) ) ; <nl> + } <nl> + <nl> + TEST_F ( ApplierTest , CancelBeforeStartingDBWork ) { <nl> + / / Schedule a blocking DB work item before the applier to allow us to cancel the applier <nl> + / / work item before the executor runs it . <nl> + boost : : barrier barrier ( 2U ) ; <nl> + using CallbackData = ReplicationExecutor : : CallbackData ; <nl> + getExecutor ( ) . scheduleDBWork ( [ & ] ( const CallbackData & cbd ) { <nl> + barrier . count_down_and_wait ( ) ; / / generation 0 <nl> + } ) ; <nl> + const BSONObj operation = BSON ( " ts " < < Timestamp ( Seconds ( 123 ) , 0 ) ) ; <nl> + boost : : mutex mutex ; <nl> + StatusWith < Timestamp > result = getDetectableErrorStatus ( ) ; <nl> + Applier : : Operations operations ; <nl> + _applier . reset ( new Applier ( <nl> + & getExecutor ( ) , <nl> + { operation } , <nl> + [ ] ( OperationContext * txn , const BSONObj & operation ) { return Status : : OK ( ) ; } , <nl> + [ & ] ( const StatusWith < Timestamp > & theResult , const Operations & theOperations ) { <nl> + boost : : lock_guard < boost : : mutex > lock ( mutex ) ; <nl> + result = theResult ; <nl> + operations = theOperations ; <nl> + } ) ) ; <nl> + <nl> + getApplier ( ) - > start ( ) ; <nl> + getApplier ( ) - > cancel ( ) ; <nl> + ASSERT_TRUE ( getApplier ( ) - > isActive ( ) ) ; <nl> + <nl> + barrier . count_down_and_wait ( ) ; / / generation 0 <nl> + <nl> + getApplier ( ) - > wait ( ) ; <nl> + ASSERT_FALSE ( getApplier ( ) - > isActive ( ) ) ; <nl> + <nl> + boost : : lock_guard < boost : : mutex > lock ( mutex ) ; <nl> + ASSERT_EQUALS ( ErrorCodes : : CallbackCanceled , result . getStatus ( ) . code ( ) ) ; <nl> + ASSERT_EQUALS ( 1U , operations . size ( ) ) ; <nl> + ASSERT_EQUALS ( operation , operations . front ( ) ) ; <nl> + } <nl> + <nl> + TEST_F ( ApplierTest , DestroyBeforeStartingDBWork ) { <nl> + / / Schedule a blocking DB work item before the applier to allow us to destroy the applier <nl> + / / before the executor runs the work item . <nl> + boost : : barrier barrier ( 2U ) ; <nl> + using CallbackData = ReplicationExecutor : : CallbackData ; <nl> + getExecutor ( ) . scheduleDBWork ( [ & ] ( const CallbackData & cbd ) { <nl> + barrier . count_down_and_wait ( ) ; / / generation 0 <nl> + / / Give the main thread a head start in invoking the applier destructor . <nl> + sleepmillis ( 1 ) ; <nl> + } ) ; <nl> + const BSONObj operation = BSON ( " ts " < < Timestamp ( Seconds ( 123 ) , 0 ) ) ; <nl> + boost : : mutex mutex ; <nl> + StatusWith < Timestamp > result = getDetectableErrorStatus ( ) ; <nl> + Applier : : Operations operations ; <nl> + _applier . reset ( new Applier ( <nl> + & getExecutor ( ) , <nl> + { operation } , <nl> + [ ] ( OperationContext * txn , const BSONObj & operation ) { return Status : : OK ( ) ; } , <nl> + [ & ] ( const StatusWith < Timestamp > & theResult , const Operations & theOperations ) { <nl> + boost : : lock_guard < boost : : mutex > lock ( mutex ) ; <nl> + result = theResult ; <nl> + operations = theOperations ; <nl> + } ) ) ; <nl> + <nl> + getApplier ( ) - > start ( ) ; <nl> + ASSERT_TRUE ( getApplier ( ) - > isActive ( ) ) ; <nl> + <nl> + barrier . count_down_and_wait ( ) ; / / generation 0 <nl> + <nl> + / / It is possible the executor may have invoked the callback before we <nl> + / / destroy the applier . Therefore both OK and CallbackCanceled are acceptable <nl> + / / statuses . <nl> + _applier . reset ( ) ; <nl> + <nl> + boost : : lock_guard < boost : : mutex > lock ( mutex ) ; <nl> + if ( result . isOK ( ) ) { <nl> + ASSERT_TRUE ( operations . empty ( ) ) ; <nl> + } <nl> + else { <nl> + ASSERT_EQUALS ( ErrorCodes : : CallbackCanceled , result . getStatus ( ) . code ( ) ) ; <nl> + ASSERT_EQUALS ( 1U , operations . size ( ) ) ; <nl> + ASSERT_EQUALS ( operation , operations . front ( ) ) ; <nl> + } <nl> + } <nl> + <nl> + TEST_F ( ApplierTest , WaitForCompletion ) { <nl> + const Timestamp timestamp ( Seconds ( 123 ) , 0 ) ; <nl> + boost : : mutex mutex ; <nl> + StatusWith < Timestamp > result = getDetectableErrorStatus ( ) ; <nl> + Applier : : Operations operations ; <nl> + _applier . reset ( new Applier ( <nl> + & getExecutor ( ) , <nl> + { BSON ( " ts " < < timestamp ) } , <nl> + [ ] ( OperationContext * txn , const BSONObj & operation ) { return Status : : OK ( ) ; } , <nl> + [ & ] ( const StatusWith < Timestamp > & theResult , const Operations & theOperations ) { <nl> + boost : : lock_guard < boost : : mutex > lock ( mutex ) ; <nl> + result = theResult ; <nl> + operations = theOperations ; <nl> + } ) ) ; <nl> + <nl> + getApplier ( ) - > start ( ) ; <nl> + getApplier ( ) - > wait ( ) ; <nl> + ASSERT_FALSE ( getApplier ( ) - > isActive ( ) ) ; <nl> + <nl> + boost : : lock_guard < boost : : mutex > lock ( mutex ) ; <nl> + ASSERT_OK ( result . getStatus ( ) ) ; <nl> + ASSERT_EQUALS ( timestamp , result . getValue ( ) ) ; <nl> + ASSERT_TRUE ( operations . empty ( ) ) ; <nl> + } <nl> + <nl> + TEST_F ( ApplierTest , DestroyShouldBlockUntilInactive ) { <nl> + const Timestamp timestamp ( Seconds ( 123 ) , 0 ) ; <nl> + boost : : barrier barrier ( 2U ) ; <nl> + boost : : mutex mutex ; <nl> + StatusWith < Timestamp > result = getDetectableErrorStatus ( ) ; <nl> + Applier : : Operations operations ; <nl> + _applier . reset ( new Applier ( <nl> + & getExecutor ( ) , <nl> + { BSON ( " ts " < < timestamp ) } , <nl> + [ ] ( OperationContext * txn , const BSONObj & operation ) { return Status : : OK ( ) ; } , <nl> + [ & ] ( const StatusWith < Timestamp > & theResult , const Operations & theOperations ) { <nl> + boost : : lock_guard < boost : : mutex > lock ( mutex ) ; <nl> + result = theResult ; <nl> + operations = theOperations ; <nl> + barrier . count_down_and_wait ( ) ; <nl> + } ) ) ; <nl> + <nl> + getApplier ( ) - > start ( ) ; <nl> + barrier . count_down_and_wait ( ) ; <nl> + _applier . reset ( ) ; <nl> + <nl> + boost : : lock_guard < boost : : mutex > lock ( mutex ) ; <nl> + ASSERT_OK ( result . getStatus ( ) ) ; <nl> + ASSERT_EQUALS ( timestamp , result . getValue ( ) ) ; <nl> + ASSERT_TRUE ( operations . empty ( ) ) ; <nl> + } <nl> + <nl> + TEST_F ( ApplierTest , ApplyOperationSuccessful ) { <nl> + / / Bogus operations codes . <nl> + Applier : : Operations operationsToApply { <nl> + BSON ( " op " < < " a " < < " ts " < < Timestamp ( Seconds ( 123 ) , 0 ) ) , <nl> + BSON ( " op " < < " b " < < " ts " < < Timestamp ( Seconds ( 456 ) , 0 ) ) , <nl> + BSON ( " op " < < " c " < < " ts " < < Timestamp ( Seconds ( 789 ) , 0 ) ) , <nl> + } ; <nl> + boost : : mutex mutex ; <nl> + StatusWith < Timestamp > result = getDetectableErrorStatus ( ) ; <nl> + bool areWritesReplicationOnOperationContext = true ; <nl> + bool isLockBatchWriter = false ; <nl> + Applier : : Operations operationsApplied ; <nl> + Applier : : Operations operationsOnCompletion ; <nl> + auto apply = [ & ] ( OperationContext * txn , const BSONObj & operation ) { <nl> + boost : : lock_guard < boost : : mutex > lock ( mutex ) ; <nl> + areWritesReplicationOnOperationContext = txn - > writesAreReplicated ( ) ; <nl> + isLockBatchWriter = txn - > lockState ( ) - > isBatchWriter ( ) ; <nl> + operationsApplied . push_back ( operation ) ; <nl> + return Status : : OK ( ) ; <nl> + } ; <nl> + auto callback = [ & ] ( const StatusWith < Timestamp > & theResult , <nl> + const Operations & theOperations ) { <nl> + boost : : lock_guard < boost : : mutex > lock ( mutex ) ; <nl> + result = theResult ; <nl> + operationsOnCompletion = theOperations ; <nl> + } ; <nl> + <nl> + _applier . reset ( new Applier ( & getExecutor ( ) , operationsToApply , apply , callback ) ) ; <nl> + _applier - > start ( ) ; <nl> + _applier - > wait ( ) ; <nl> + <nl> + boost : : lock_guard < boost : : mutex > lock ( mutex ) ; <nl> + ASSERT_FALSE ( areWritesReplicationOnOperationContext ) ; <nl> + ASSERT_TRUE ( isLockBatchWriter ) ; <nl> + ASSERT_EQUALS ( operationsToApply . size ( ) , operationsApplied . size ( ) ) ; <nl> + ASSERT_EQUALS ( operationsToApply [ 0 ] , operationsApplied [ 0 ] ) ; <nl> + ASSERT_EQUALS ( operationsToApply [ 1 ] , operationsApplied [ 1 ] ) ; <nl> + ASSERT_EQUALS ( operationsToApply [ 2 ] , operationsApplied [ 2 ] ) ; <nl> + ASSERT_OK ( result . getStatus ( ) ) ; <nl> + ASSERT_EQUALS ( operationsToApply [ 2 ] [ " ts " ] . timestamp ( ) , result . getValue ( ) ) ; <nl> + ASSERT_TRUE ( operationsOnCompletion . empty ( ) ) ; <nl> + } <nl> + <nl> + void ApplierTest : : _testApplyOperationFailed ( size_t opIndex , stdx : : function < Status ( ) > fail ) { <nl> + / / Bogus operations codes . <nl> + Applier : : Operations operationsToApply { <nl> + BSON ( " op " < < " a " < < " ts " < < Timestamp ( Seconds ( 123 ) , 0 ) ) , <nl> + BSON ( " op " < < " b " < < " ts " < < Timestamp ( Seconds ( 456 ) , 0 ) ) , <nl> + BSON ( " op " < < " c " < < " ts " < < Timestamp ( Seconds ( 789 ) , 0 ) ) , <nl> + } ; <nl> + boost : : mutex mutex ; <nl> + StatusWith < Timestamp > result = getDetectableErrorStatus ( ) ; <nl> + Applier : : Operations operationsApplied ; <nl> + Applier : : Operations operationsOnCompletion ; <nl> + auto apply = [ & ] ( OperationContext * txn , const BSONObj & operation ) { <nl> + boost : : lock_guard < boost : : mutex > lock ( mutex ) ; <nl> + if ( operationsApplied . size ( ) = = opIndex ) { <nl> + return fail ( ) ; <nl> + } <nl> + operationsApplied . push_back ( operation ) ; <nl> + return Status : : OK ( ) ; <nl> + } ; <nl> + auto callback = [ & ] ( const StatusWith < Timestamp > & theResult , <nl> + const Operations & theOperations ) { <nl> + boost : : lock_guard < boost : : mutex > lock ( mutex ) ; <nl> + result = theResult ; <nl> + operationsOnCompletion = theOperations ; <nl> + } ; <nl> + <nl> + _applier . reset ( new Applier ( & getExecutor ( ) , operationsToApply , apply , callback ) ) ; <nl> + _applier - > start ( ) ; <nl> + _applier - > wait ( ) ; <nl> + <nl> + boost : : lock_guard < boost : : mutex > lock ( mutex ) ; <nl> + ASSERT_EQUALS ( opIndex , operationsApplied . size ( ) ) ; <nl> + size_t i = 0 ; <nl> + for ( const auto & operation : operationsApplied ) { <nl> + ASSERT_EQUALS ( operationsToApply [ i ] , operation ) ; <nl> + i + + ; <nl> + } <nl> + ASSERT_EQUALS ( ErrorCodes : : OperationFailed , result . getStatus ( ) . code ( ) ) ; <nl> + ASSERT_EQUALS ( operationsToApply . size ( ) - opIndex , operationsOnCompletion . size ( ) ) ; <nl> + ASSERT_EQUALS ( opIndex , i ) ; <nl> + for ( const auto & operation : operationsOnCompletion ) { <nl> + ASSERT_EQUALS ( operationsToApply [ i ] , operation ) ; <nl> + i + + ; <nl> + } <nl> + } <nl> + <nl> + TEST_F ( ApplierTest , ApplyOperationFailedOnFirstOperation ) { <nl> + _testApplyOperationFailed ( 0U , [ ] ( ) { <nl> + return Status ( ErrorCodes : : OperationFailed , " " ) ; <nl> + } ) ; <nl> + } <nl> + <nl> + TEST_F ( ApplierTest , ApplyOperationThrowsExceptionOnFirstOperation ) { <nl> + _testApplyOperationFailed ( 0U , [ ] ( ) { <nl> + uasserted ( ErrorCodes : : OperationFailed , " " ) ; <nl> + MONGO_UNREACHABLE ; <nl> + return Status ( ErrorCodes : : InternalError , " unreachable " ) ; <nl> + } ) ; <nl> + } <nl> + <nl> + TEST_F ( ApplierTest , ApplyOperationFailedOnSecondOperation ) { <nl> + _testApplyOperationFailed ( 1U , [ ] ( ) { <nl> + return Status ( ErrorCodes : : OperationFailed , " " ) ; <nl> + } ) ; <nl> + } <nl> + <nl> + TEST_F ( ApplierTest , ApplyOperationThrowsExceptionOnSecondOperation ) { <nl> + _testApplyOperationFailed ( 1U , [ ] ( ) { <nl> + uasserted ( ErrorCodes : : OperationFailed , " " ) ; <nl> + MONGO_UNREACHABLE ; <nl> + return Status ( ErrorCodes : : InternalError , " unreachable " ) ; <nl> + } ) ; <nl> + } <nl> + <nl> + TEST_F ( ApplierTest , ApplyOperationFailedOnLastOperation ) { <nl> + _testApplyOperationFailed ( 2U , [ ] ( ) { <nl> + return Status ( ErrorCodes : : OperationFailed , " " ) ; <nl> + } ) ; <nl> + } <nl> + <nl> + TEST_F ( ApplierTest , ApplyOperationThrowsExceptionOnLastOperation ) { <nl> + _testApplyOperationFailed ( 2U , [ ] ( ) { <nl> + uasserted ( ErrorCodes : : OperationFailed , " " ) ; <nl> + MONGO_UNREACHABLE ; <nl> + return Status ( ErrorCodes : : InternalError , " unreachable " ) ; <nl> + } ) ; <nl> + } <nl> + <nl> + } / / namespace <nl> mmm a / src / mongo / db / repl / base_cloner_test_fixture . cpp <nl> ppp b / src / mongo / db / repl / base_cloner_test_fixture . cpp <nl> namespace repl { <nl> const BSONObj BaseClonerTest : : idIndexSpec = <nl> BSON ( " v " < < 1 < < " key " < < BSON ( " _id " < < 1 ) < < " name " < < " _id_ " < < " ns " < < nss . ns ( ) ) ; <nl> <nl> - Status BaseClonerTest : : getDefaultStatus ( ) { <nl> + Status BaseClonerTest : : getDetectableErrorStatus ( ) { <nl> return Status ( ErrorCodes : : InternalError , " Not mutated " ) ; <nl> } <nl> <nl> namespace repl { <nl> BaseClonerTest : : BaseClonerTest ( ) <nl> : _mutex ( ) , <nl> _setStatusCondition ( ) , <nl> - _status ( getDefaultStatus ( ) ) { } <nl> + _status ( getDetectableErrorStatus ( ) ) { } <nl> <nl> void BaseClonerTest : : setUp ( ) { <nl> ReplicationExecutorTest : : setUp ( ) ; <nl> namespace repl { <nl> } <nl> <nl> void BaseClonerTest : : clear ( ) { <nl> - _status = getDefaultStatus ( ) ; <nl> + _status = getDetectableErrorStatus ( ) ; <nl> } <nl> <nl> void BaseClonerTest : : setStatus ( const Status & status ) { <nl> namespace repl { <nl> <nl> void BaseClonerTest : : waitForStatus ( ) { <nl> boost : : unique_lock < boost : : mutex > lk ( _mutex ) ; <nl> - if ( _status = = getDefaultStatus ( ) ) { <nl> + if ( _status = = getDetectableErrorStatus ( ) ) { <nl> try { <nl> _setStatusCondition . wait_for ( lk , Milliseconds ( 1000 ) ) ; <nl> } <nl> mmm a / src / mongo / db / repl / base_cloner_test_fixture . h <nl> ppp b / src / mongo / db / repl / base_cloner_test_fixture . h <nl> namespace repl { <nl> * Creates an initial error status suitable for checking if <nl> * cloner has modified the ' status ' field in test fixture . <nl> * / <nl> - static Status getDefaultStatus ( ) ; <nl> + static Status getDetectableErrorStatus ( ) ; <nl> <nl> / * * <nl> * Creates a cursor response with given array of documents . <nl> mmm a / src / mongo / db / repl / collection_cloner_test . cpp <nl> ppp b / src / mongo / db / repl / collection_cloner_test . cpp <nl> namespace { <nl> / / the cloner stops the fetcher from retrieving more results . <nl> processNetworkResponse ( createListIndexesResponse ( 1 , BSONArray ( ) ) ) ; <nl> <nl> - ASSERT_EQUALS ( getDefaultStatus ( ) , getStatus ( ) ) ; <nl> + ASSERT_EQUALS ( getDetectableErrorStatus ( ) , getStatus ( ) ) ; <nl> ASSERT_TRUE ( collectionCloner - > isActive ( ) ) ; <nl> <nl> ASSERT_TRUE ( getNet ( ) - > hasReadyRequests ( ) ) ; <nl> namespace { <nl> processNetworkResponse ( createListIndexesResponse ( 1 , BSON_ARRAY ( specs [ 0 ] < < specs [ 1 ] ) ) ) ; <nl> <nl> / / ' status ' should not be modified because cloning is not finished . <nl> - ASSERT_EQUALS ( getDefaultStatus ( ) , getStatus ( ) ) ; <nl> + ASSERT_EQUALS ( getDetectableErrorStatus ( ) , getStatus ( ) ) ; <nl> ASSERT_TRUE ( collectionCloner - > isActive ( ) ) ; <nl> <nl> processNetworkResponse ( createListIndexesResponse ( 0 , BSON_ARRAY ( specs [ 2 ] ) , " nextBatch " ) ) ; <nl> namespace { <nl> collectionCloner - > waitForDbWorker ( ) ; <nl> <nl> / / ' status ' will be set if listIndexes fails . <nl> - ASSERT_EQUALS ( getDefaultStatus ( ) , getStatus ( ) ) ; <nl> + ASSERT_EQUALS ( getDetectableErrorStatus ( ) , getStatus ( ) ) ; <nl> <nl> ASSERT_EQUALS ( nss . ns ( ) , collNss . ns ( ) ) ; <nl> ASSERT_EQUALS ( options . toBSON ( ) , collOptions . toBSON ( ) ) ; <nl> namespace { <nl> ASSERT_EQUALS ( 1U , collDocuments . size ( ) ) ; <nl> ASSERT_EQUALS ( doc , collDocuments [ 0 ] ) ; <nl> <nl> - ASSERT_EQUALS ( getDefaultStatus ( ) , getStatus ( ) ) ; <nl> + ASSERT_EQUALS ( getDetectableErrorStatus ( ) , getStatus ( ) ) ; <nl> ASSERT_TRUE ( collectionCloner - > isActive ( ) ) ; <nl> <nl> const BSONObj doc2 = BSON ( " _id " < < 1 ) ; <nl> mmm a / src / mongo / db / repl / database_cloner_test . cpp <nl> ppp b / src / mongo / db / repl / database_cloner_test . cpp <nl> namespace { <nl> / / Keep going even if initial batch is empty . <nl> processNetworkResponse ( createListCollectionsResponse ( 1 , BSONArray ( ) ) ) ; <nl> <nl> - ASSERT_EQUALS ( getDefaultStatus ( ) , getStatus ( ) ) ; <nl> + ASSERT_EQUALS ( getDetectableErrorStatus ( ) , getStatus ( ) ) ; <nl> ASSERT_TRUE ( databaseCloner - > isActive ( ) ) ; <nl> <nl> / / Final batch is also empty . Database cloner should stop and return a successful status . <nl> namespace { <nl> sourceInfos [ 1 ] < < <nl> sourceInfos [ 2 ] ) ) ) ; <nl> <nl> - ASSERT_EQUALS ( getDefaultStatus ( ) , getStatus ( ) ) ; <nl> + ASSERT_EQUALS ( getDetectableErrorStatus ( ) , getStatus ( ) ) ; <nl> ASSERT_TRUE ( databaseCloner - > isActive ( ) ) ; <nl> <nl> const std : : vector < BSONObj > & collectionInfos = databaseCloner - > getCollectionInfos ( ) ; <nl> namespace { <nl> BSON ( " name " < < " b " < < " options " < < BSONObj ( ) ) } ; <nl> processNetworkResponse ( createListCollectionsResponse ( 1 , BSON_ARRAY ( sourceInfos [ 0 ] ) ) ) ; <nl> <nl> - ASSERT_EQUALS ( getDefaultStatus ( ) , getStatus ( ) ) ; <nl> + ASSERT_EQUALS ( getDetectableErrorStatus ( ) , getStatus ( ) ) ; <nl> ASSERT_TRUE ( databaseCloner - > isActive ( ) ) ; <nl> <nl> { <nl> namespace { <nl> processNetworkResponse ( <nl> createListCollectionsResponse ( 0 , BSON_ARRAY ( sourceInfos [ 1 ] ) , " nextBatch " ) ) ; <nl> <nl> - ASSERT_EQUALS ( getDefaultStatus ( ) , getStatus ( ) ) ; <nl> + ASSERT_EQUALS ( getDetectableErrorStatus ( ) , getStatus ( ) ) ; <nl> ASSERT_TRUE ( databaseCloner - > isActive ( ) ) ; <nl> <nl> { <nl> namespace { <nl> processNetworkResponse ( createListCollectionsResponse ( 0 , BSON_ARRAY ( sourceInfos [ 0 ] < < <nl> sourceInfos [ 1 ] ) ) ) ; <nl> <nl> - ASSERT_EQUALS ( getDefaultStatus ( ) , getStatus ( ) ) ; <nl> + ASSERT_EQUALS ( getDetectableErrorStatus ( ) , getStatus ( ) ) ; <nl> ASSERT_TRUE ( databaseCloner - > isActive ( ) ) ; <nl> <nl> / / Collection cloners are run serially for now . <nl> namespace { <nl> processNetworkResponse ( createListCollectionsResponse ( 0 , BSON_ARRAY ( sourceInfos [ 0 ] < < <nl> sourceInfos [ 1 ] ) ) ) ; <nl> <nl> - ASSERT_EQUALS ( getDefaultStatus ( ) , getStatus ( ) ) ; <nl> + ASSERT_EQUALS ( getDetectableErrorStatus ( ) , getStatus ( ) ) ; <nl> ASSERT_TRUE ( databaseCloner - > isActive ( ) ) ; <nl> <nl> / / Collection cloners are run serially for now . <nl> mmm a / src / mongo / db / repl / database_task_test . cpp <nl> ppp b / src / mongo / db / repl / database_task_test . cpp <nl> namespace { <nl> bool called = false ; <nl> OperationContext * txn = nullptr ; <nl> bool lockIsW = false ; <nl> - Status status = getDefaultStatus ( ) ; <nl> + Status status = getDetectableErrorStatus ( ) ; <nl> / / Task returning ' void ' implies NextAction : : NoAction . <nl> auto task = [ & ] ( OperationContext * theTxn , const Status & theStatus ) { <nl> boost : : lock_guard < boost : : mutex > lk ( mutex ) ; <nl> namespace { <nl> bool called = false ; <nl> OperationContext * txn = nullptr ; <nl> bool isDatabaseLockedForMode = false ; <nl> - Status status = test . getDefaultStatus ( ) ; <nl> + Status status = test . getDetectableErrorStatus ( ) ; <nl> / / Task returning ' void ' implies NextAction : : NoAction . <nl> auto task = [ & ] ( OperationContext * theTxn , const Status & theStatus ) { <nl> boost : : lock_guard < boost : : mutex > lk ( mutex ) ; <nl> namespace { <nl> bool called = false ; <nl> OperationContext * txn = nullptr ; <nl> bool isCollectionLockedForMode = false ; <nl> - Status status = test . getDefaultStatus ( ) ; <nl> + Status status = test . getDetectableErrorStatus ( ) ; <nl> / / Task returning ' void ' implies NextAction : : NoAction . <nl> auto task = [ & ] ( OperationContext * theTxn , const Status & theStatus ) { <nl> boost : : lock_guard < boost : : mutex > lk ( mutex ) ; <nl> mmm a / src / mongo / db / repl / fetcher_test . cpp <nl> ppp b / src / mongo / db / repl / fetcher_test . cpp <nl> namespace { <nl> <nl> class FetcherTest : public ReplicationExecutorTest { <nl> public : <nl> - static Status getDefaultStatus ( ) ; <nl> + static Status getDetectableErrorStatus ( ) ; <nl> FetcherTest ( ) ; <nl> void setUp ( ) override ; <nl> void tearDown ( ) override ; <nl> namespace { <nl> Fetcher : : NextAction * nextAction ) ; <nl> } ; <nl> <nl> - Status FetcherTest : : getDefaultStatus ( ) { <nl> + Status FetcherTest : : getDetectableErrorStatus ( ) { <nl> return Status ( ErrorCodes : : InternalError , " Not mutated " ) ; <nl> } <nl> <nl> FetcherTest : : FetcherTest ( ) <nl> - : status ( getDefaultStatus ( ) ) , <nl> + : status ( getDetectableErrorStatus ( ) ) , <nl> cursorId ( - 1 ) , <nl> nextAction ( Fetcher : : NextAction : : kInvalid ) { } <nl> <nl> namespace { <nl> } <nl> <nl> void FetcherTest : : clear ( ) { <nl> - status = getDefaultStatus ( ) ; <nl> + status = getDetectableErrorStatus ( ) ; <nl> cursorId = - 1 ; <nl> documents . clear ( ) ; <nl> nextAction = Fetcher : : NextAction : : kInvalid ; <nl> mmm a / src / mongo / db / repl / network_interface_impl . cpp <nl> ppp b / src / mongo / db / repl / network_interface_impl . cpp <nl> <nl> # include < boost / make_shared . hpp > <nl> # include < memory > <nl> <nl> + # include " mongo / db / auth / authorization_session . h " <nl> # include " mongo / client / connection_pool . h " <nl> # include " mongo / db / client . h " <nl> # include " mongo / db / operation_context_impl . h " <nl> namespace { <nl> } <nl> <nl> OperationContext * NetworkInterfaceImpl : : createOperationContext ( ) { <nl> - Client : : initThreadIfNotAlready ( ) ; <nl> + if ( ! ClientBasic : : getCurrent ( ) ) { <nl> + Client : : initThreadIfNotAlready ( ) ; <nl> + AuthorizationSession : : get ( * ClientBasic : : getCurrent ( ) ) - > grantInternalAuthorization ( ) ; <nl> + } <nl> return new OperationContextImpl ( ) ; <nl> } <nl> <nl> mmm a / src / mongo / db / repl / replication_executor_test . cpp <nl> ppp b / src / mongo / db / repl / replication_executor_test . cpp <nl> namespace { <nl> ASSERT_TRUE ( lockIsW ) ; <nl> } <nl> <nl> + TEST_F ( ReplicationExecutorTest , ShutdownBeforeRunningSecondExclusiveLockOperation ) { <nl> + ReplicationExecutor & executor = getExecutor ( ) ; <nl> + using CallbackData = ReplicationExecutor : : CallbackData ; <nl> + Status status1 ( ErrorCodes : : InternalError , " Not mutated " ) ; <nl> + ASSERT_OK ( executor . scheduleWorkWithGlobalExclusiveLock ( [ & ] ( const CallbackData & cbData ) { <nl> + status1 = cbData . status ; <nl> + if ( cbData . status ! = ErrorCodes : : CallbackCanceled ) { <nl> + cbData . executor - > shutdown ( ) ; <nl> + } <nl> + } ) . getStatus ( ) ) ; <nl> + / / Second db work item is invoked by the main executor thread because the work item is <nl> + / / moved from the exclusive lock queue to the ready work item queue when the first callback <nl> + / / cancels the executor . <nl> + Status status2 ( ErrorCodes : : InternalError , " Not mutated " ) ; <nl> + ASSERT_OK ( executor . scheduleWorkWithGlobalExclusiveLock ( [ & ] ( const CallbackData & cbData ) { <nl> + status2 = cbData . status ; <nl> + if ( cbData . status ! = ErrorCodes : : CallbackCanceled ) { <nl> + cbData . executor - > shutdown ( ) ; <nl> + } <nl> + } ) . getStatus ( ) ) ; <nl> + executor . run ( ) ; <nl> + ASSERT_OK ( status1 ) ; <nl> + ASSERT_EQUALS ( ErrorCodes : : CallbackCanceled , status2 . code ( ) ) ; <nl> + } <nl> + <nl> TEST_F ( ReplicationExecutorTest , RemoteCommandWithTimeout ) { <nl> NetworkInterfaceMock * net = getNet ( ) ; <nl> ReplicationExecutor & executor = getExecutor ( ) ; <nl> mmm a / src / mongo / db / repl / reporter_test . cpp <nl> ppp b / src / mongo / db / repl / reporter_test . cpp <nl> namespace { <nl> <nl> class ReporterTest : public ReplicationExecutorTest { <nl> public : <nl> - static Status getDefaultStatus ( ) ; <nl> + static Status getDetectableErrorStatus ( ) ; <nl> ReporterTest ( ) ; <nl> void setUp ( ) override ; <nl> void tearDown ( ) override ; <nl> namespace { <nl> <nl> ReporterTest : : ReporterTest ( ) { } <nl> <nl> - Status ReporterTest : : getDefaultStatus ( ) { <nl> + Status ReporterTest : : getDetectableErrorStatus ( ) { <nl> return Status ( ErrorCodes : : InternalError , " Not mutated " ) ; <nl> } <nl> <nl> mmm a / src / mongo / db / repl / task_runner_test . cpp <nl> ppp b / src / mongo / db / repl / task_runner_test . cpp <nl> namespace { <nl> boost : : mutex mutex ; <nl> bool called = false ; <nl> OperationContext * txn = nullptr ; <nl> - Status status = getDefaultStatus ( ) ; <nl> + Status status = getDetectableErrorStatus ( ) ; <nl> auto task = [ & ] ( OperationContext * theTxn , const Status & theStatus ) { <nl> boost : : lock_guard < boost : : mutex > lk ( mutex ) ; <nl> called = true ; <nl> namespace { <nl> bool called = false ; <nl> OperationContextNoop opCtxNoop ; <nl> OperationContext * txn = & opCtxNoop ; <nl> - Status status = getDefaultStatus ( ) ; <nl> + Status status = getDetectableErrorStatus ( ) ; <nl> auto task = [ & ] ( OperationContext * theTxn , const Status & theStatus ) { <nl> boost : : lock_guard < boost : : mutex > lk ( mutex ) ; <nl> called = true ; <nl> namespace { <nl> boost : : mutex mutex ; <nl> int i = 0 ; <nl> OperationContext * txn [ 2 ] = { nullptr , nullptr } ; <nl> - Status status [ 2 ] = { getDefaultStatus ( ) , getDefaultStatus ( ) } ; <nl> + Status status [ 2 ] = { getDetectableErrorStatus ( ) , getDetectableErrorStatus ( ) } ; <nl> boost : : condition condition ; <nl> bool schedulingDone = false ; <nl> auto task = [ & ] ( OperationContext * theTxn , const Status & theStatus ) { <nl> namespace { <nl> boost : : mutex mutex ; <nl> int i = 0 ; <nl> OperationContext * txn [ 2 ] = { nullptr , nullptr } ; <nl> - Status status [ 2 ] = { getDefaultStatus ( ) , getDefaultStatus ( ) } ; <nl> + Status status [ 2 ] = { getDetectableErrorStatus ( ) , getDetectableErrorStatus ( ) } ; <nl> boost : : condition condition ; <nl> bool schedulingDone = false ; <nl> auto task = [ & ] ( OperationContext * theTxn , const Status & theStatus ) { <nl> namespace { <nl> TEST_F ( TaskRunnerTest , Cancel ) { <nl> boost : : mutex mutex ; <nl> boost : : condition condition ; <nl> - Status status = getDefaultStatus ( ) ; <nl> + Status status = getDetectableErrorStatus ( ) ; <nl> bool taskRunning = false ; <nl> <nl> / / Running this task causes the task runner to wait for another task that <nl> namespace { <nl> TEST_F ( TaskRunnerTest , DestroyShouldWaitForTasksToComplete ) { <nl> boost : : mutex mutex ; <nl> boost : : condition condition ; <nl> - Status status = getDefaultStatus ( ) ; <nl> + Status status = getDetectableErrorStatus ( ) ; <nl> bool taskRunning = false ; <nl> <nl> / / Running this task causes the task runner to wait for another task that <nl> mmm a / src / mongo / db / repl / task_runner_test_fixture . cpp <nl> ppp b / src / mongo / db / repl / task_runner_test_fixture . cpp <nl> namespace { <nl> <nl> } / / namespace <nl> <nl> - Status TaskRunnerTest : : getDefaultStatus ( ) { <nl> + Status TaskRunnerTest : : getDetectableErrorStatus ( ) { <nl> return Status ( ErrorCodes : : InternalError , " Not mutated " ) ; <nl> } <nl> <nl> mmm a / src / mongo / db / repl / task_runner_test_fixture . h <nl> ppp b / src / mongo / db / repl / task_runner_test_fixture . h <nl> namespace repl { <nl> * / <nl> class TaskRunnerTest : public unittest : : Test { <nl> public : <nl> - static Status getDefaultStatus ( ) ; <nl> + static Status getDetectableErrorStatus ( ) ; <nl> <nl> / * * <nl> * Returns ID of mock operation context returned from createOperationContext ( ) . <nl>
|
SERVER - 18016 added database replication applier
|
mongodb/mongo
|
4d0d95aa01a2c06769e56e42698db41a0dd877c4
|
2015-05-19T14:44:09Z
|
mmm a / . flake8 <nl> ppp b / . flake8 <nl> ignore = <nl> B007 , B008 , <nl> # these ignores are from flake8 - comprehensions ; please fix ! <nl> C400 , C401 , C402 , C403 , C404 , C405 , C407 , C411 , <nl> - exclude = docs / src , venv , third_party , caffe2 , scripts , docs / caffe2 , tools / amd_build / pyHIPIFY , torch / lib / include , torch / lib / tmp_install , build , torch / include , * . pyi <nl> + exclude = docs / src , venv , third_party , caffe2 , scripts , docs / caffe2 , torch / lib / include , torch / lib / tmp_install , build , torch / include , * . pyi <nl> mmm a / aten / src / ATen / hip / impl / HIPGuardImplMasqueradingAsCUDA . h <nl> ppp b / aten / src / ATen / hip / impl / HIPGuardImplMasqueradingAsCUDA . h <nl> namespace c10 { namespace hip { <nl> / / we switch PyTorch to calling a HIP a HIP . <nl> / / <nl> / / When you add a new MasqueradingAsCUDA class / function , you need to <nl> - / / also update the rewrite rules in tools / amd_build / pyHIPIFY / cuda_to_hip_mappings . py <nl> + / / also update the rewrite rules in torch / utils / hipify / cuda_to_hip_mappings . py <nl> / / <nl> / / <nl> / / <nl> mmm a / c10 / cuda / CMakeLists . txt <nl> ppp b / c10 / cuda / CMakeLists . txt <nl> configure_file ( <nl> # transitively passed on to all libraries dependent on PyTorch . <nl> <nl> # Note : if you add a new source file / header , you will need to update <nl> - # tools / amd_build / pyHIPIFY / cuda_to_hip_mappings . py for new files <nl> + # torch / utils / hipify / cuda_to_hip_mappings . py for new files <nl> # and headers you add <nl> set ( C10_CUDA_SRCS <nl> CUDAStream . cpp <nl> mmm a / c10 / cuda / README . md <nl> ppp b / c10 / cuda / README . md <nl> void my_func ( ) ; <nl> ` ` ` <nl> <nl> Thus , if you add new functionality to c10 , you must also update ` C10_MAPPINGS ` <nl> - ` tools / amd_build / pyHIPIFY / cuda_to_hip_mappings . py ` to transpile <nl> + ` torch / utils / hipify / cuda_to_hip_mappings . py ` to transpile <nl> occurrences of ` cuda : : my_func ` to ` hip : : my_func ` . ( At the moment , <nl> we do NOT have a catch all ` cuda : : ` to ` hip : : ` namespace conversion , <nl> as not all ` cuda ` namespaces are converted to ` hip : : ` , even though <nl> mmm a / test / test_utils . py <nl> ppp b / test / test_utils . py <nl> def test_load_zip_checkpoint ( self ) : <nl> SUM_OF_HUB_EXAMPLE ) <nl> <nl> <nl> + class TestHipify ( TestCase ) : <nl> + def test_import_hipify ( self ) : <nl> + from torch . utils . hipify import hipify_python # noqa <nl> + <nl> + <nl> if __name__ = = ' __main__ ' : <nl> run_tests ( ) <nl> mmm a / tools / amd_build / build_amd . py <nl> ppp b / tools / amd_build / build_amd . py <nl> <nl> import os <nl> import subprocess <nl> import argparse <nl> - <nl> - from pyHIPIFY import hipify_python <nl> + import sys <nl> + sys . path . append ( os . path . realpath ( os . path . join ( <nl> + __file__ , <nl> + os . path . pardir , <nl> + os . path . pardir , <nl> + os . path . pardir , <nl> + ' torch ' , <nl> + ' utils ' ) ) ) <nl> + <nl> + from hipify import hipify_python <nl> <nl> parser = argparse . ArgumentParser ( description = ' Top - level script for HIPifying , filling in most common parameters ' ) <nl> parser . add_argument ( <nl> deleted file mode 100644 <nl> index 1e04f687e457 . . 000000000000 <nl> mmm a / tools / amd_build / pyHIPIFY / cuda_to_hip_mappings . py <nl> ppp / dev / null <nl> <nl> - # ! / usr / bin / env python3 <nl> - import collections <nl> - <nl> - from pyHIPIFY . constants import * <nl> - <nl> - " " " Mapping of CUDA functions , include files , constants , and types to ROCm / HIP equivalents <nl> - This closely follows the implementation in hipify - clang <nl> - https : / / github . com / ROCm - Developer - Tools / HIP / blob / master / hipify - clang / src / CUDA2HipMap . cpp <nl> - and its structure . <nl> - There are different maps for fundamental names , include files , identifies , sparse , and <nl> - PyTorch specific translations . <nl> - Each of the entries in these maps translates a CUDA string to a tuple containing the <nl> - ROCm / HIP string , a type and API annotation and - optionally - an annotation if it is not <nl> - supported in ROCm / HIP yet . <nl> - " " " <nl> - <nl> - # List of math functions that should be replaced inside device code only . <nl> - MATH_TRANSPILATIONS = collections . OrderedDict ( [ <nl> - ( " std : : max " , ( " : : max " ) ) , <nl> - ( " std : : min " , ( " : : min " ) ) , <nl> - ( " std : : ceil " , ( " : : ceil " ) ) , <nl> - ( " std : : floor " , ( " : : floor " ) ) , <nl> - ( " std : : exp " , ( " : : exp " ) ) , <nl> - ( " std : : log " , ( " : : log " ) ) , <nl> - ( " std : : pow " , ( " : : pow " ) ) , <nl> - ( " std : : fabs " , ( " : : fabs " ) ) , <nl> - ( " std : : fmod " , ( " : : fmod " ) ) , <nl> - ( " std : : remainder " , ( " : : remainder " ) ) , <nl> - ] ) <nl> - <nl> - CUDA_TYPE_NAME_MAP = collections . OrderedDict ( [ <nl> - ( " CUresult " , ( " hipError_t " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " cudaError_t " , ( " hipError_t " , CONV_TYPE , API_RUNTIME ) ) , <nl> - ( " CUDA_ARRAY3D_DESCRIPTOR " , ( " HIP_ARRAY3D_DESCRIPTOR " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CUDA_ARRAY_DESCRIPTOR " , ( " HIP_ARRAY_DESCRIPTOR " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " CUDA_MEMCPY2D " , ( " hip_Memcpy2D " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " CUDA_MEMCPY3D " , ( " HIP_MEMCPY3D " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CUDA_MEMCPY3D_PEER " , ( " HIP_MEMCPY3D_PEER " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CUDA_POINTER_ATTRIBUTE_P2P_TOKENS " , ( " HIP_POINTER_ATTRIBUTE_P2P_TOKENS " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CUDA_RESOURCE_DESC " , ( " HIP_RESOURCE_DESC " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CUDA_RESOURCE_VIEW_DESC " , ( " HIP_RESOURCE_VIEW_DESC " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CUipcEventHandle " , ( " hipIpcEventHandle " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CUipcMemHandle " , ( " hipIpcMemHandle " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CUaddress_mode " , ( " hipAddress_mode " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CUarray_cubemap_face " , ( " hipArray_cubemap_face " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CUarray_format " , ( " hipArray_format " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " CUcomputemode " , ( " hipComputemode " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CUmem_advise " , ( " hipMemAdvise " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CUmem_range_attribute " , ( " hipMemRangeAttribute " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CUctx_flags " , ( " hipCctx_flags " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CUdevice " , ( " hipDevice_t " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " CUdevice_attribute_enum " , ( " hipDeviceAttribute_t " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " CUdevice_attribute " , ( " hipDeviceAttribute_t " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " CUdeviceptr " , ( " hipDeviceptr_t " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " CUarray_st " , ( " hipArray " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " CUarray " , ( " hipArray * " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " CUdevprop_st " , ( " hipDeviceProp_t " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " CUdevprop " , ( " hipDeviceProp_t " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " CUfunction " , ( " hipFunction_t " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " CUgraphicsResource " , ( " hipGraphicsResource_t " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CUmipmappedArray " , ( " hipMipmappedArray_t " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CUfunction_attribute " , ( " hipFuncAttribute_t " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CUfunction_attribute_enum " , ( " hipFuncAttribute_t " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CUgraphicsMapResourceFlags " , ( " hipGraphicsMapFlags " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CUgraphicsMapResourceFlags_enum " , ( " hipGraphicsMapFlags " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CUgraphicsRegisterFlags " , ( " hipGraphicsRegisterFlags " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CUgraphicsRegisterFlags_enum " , ( " hipGraphicsRegisterFlags " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CUoccupancy_flags " , ( " hipOccupancyFlags " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CUoccupancy_flags_enum " , ( " hipOccupancyFlags " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CUfunc_cache_enum " , ( " hipFuncCache " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " CUfunc_cache " , ( " hipFuncCache " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " CUipcMem_flags " , ( " hipIpcMemFlags " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CUipcMem_flags_enum " , ( " hipIpcMemFlags " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CUjit_cacheMode " , ( " hipJitCacheMode " , CONV_JIT , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CUjit_cacheMode_enum " , ( " hipJitCacheMode " , CONV_JIT , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CUjit_fallback " , ( " hipJitFallback " , CONV_JIT , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CUjit_fallback_enum " , ( " hipJitFallback " , CONV_JIT , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CUjit_option " , ( " hipJitOption " , CONV_JIT , API_DRIVER ) ) , <nl> - ( " CUjit_option_enum " , ( " hipJitOption " , CONV_JIT , API_DRIVER ) ) , <nl> - ( " CUjit_target " , ( " hipJitTarget " , CONV_JIT , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CUjit_target_enum " , ( " hipJitTarget " , CONV_JIT , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CUjitInputType " , ( " hipJitInputType " , CONV_JIT , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CUjitInputType_enum " , ( " hipJitInputType " , CONV_JIT , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CUlimit " , ( " hipLimit_t " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " CUlimit_enum " , ( " hipLimit_t " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " CUmemAttach_flags " , ( " hipMemAttachFlags_t " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CUmemAttach_flags_enum " , ( " hipMemAttachFlags_t " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CUmemorytype " , ( " hipMemType_t " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CUmemorytype_enum " , ( " hipMemType_t " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CUresourcetype " , ( " hipResourceType " , CONV_TEX , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CUresourcetype_enum " , ( " hipResourceType " , CONV_TEX , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CUresourceViewFormat " , ( " hipResourceViewFormat " , CONV_TEX , API_DRIVER ) ) , <nl> - ( " CUresourceViewFormat_enum " , ( " hipResourceViewFormat " , CONV_TEX , API_DRIVER ) ) , <nl> - ( " CUsharedconfig " , ( " hipSharedMemConfig " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " CUsharedconfig_enum " , ( " hipSharedMemConfig " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " CUcontext " , ( " hipCtx_t " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " CUmodule " , ( " hipModule_t " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " CUstream " , ( " hipStream_t " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " CUstream_st " , ( " ihipStream_t " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " CUstreamCallback " , ( " hipStreamCallback_t " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " CUsurfObject " , ( " hipSurfaceObject " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CUsurfref " , ( " hipSurfaceReference_t " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CUtexObject " , ( " hipTextureObject_t " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " CUtexref " , ( " textureReference " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " CUstream_flags " , ( " hipStreamFlags " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " CUstreamWaitValue_flags " , ( " hipStreamWaitValueFlags " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CUstreamWriteValue_flags " , ( " hipStreamWriteValueFlags " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CUstreamBatchMemOpType " , ( " hipStreamBatchMemOpType " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CUdevice_P2PAttribute " , ( " hipDeviceP2PAttribute " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CUevent " , ( " hipEvent_t " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " CUevent_st " , ( " ihipEvent_t " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " CUevent_flags " , ( " hipEventFlags " , CONV_EVENT , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CUfilter_mode " , ( " hipTextureFilterMode " , CONV_TEX , API_DRIVER ) ) , <nl> - ( " CUGLDeviceList " , ( " hipGLDeviceList " , CONV_GL , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CUGLmap_flags " , ( " hipGLMapFlags " , CONV_GL , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CUd3d9DeviceList " , ( " hipD3D9DeviceList " , CONV_D3D9 , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CUd3d9map_flags " , ( " hipD3D9MapFlags " , CONV_D3D9 , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CUd3d9register_flags " , ( " hipD3D9RegisterFlags " , CONV_D3D9 , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CUd3d10DeviceList " , ( " hipd3d10DeviceList " , CONV_D3D10 , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CUd3d10map_flags " , ( " hipD3D10MapFlags " , CONV_D3D10 , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CUd3d10register_flags " , ( " hipD3D10RegisterFlags " , CONV_D3D10 , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CUd3d11DeviceList " , ( " hipd3d11DeviceList " , CONV_D3D11 , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CUeglStreamConnection_st " , ( " hipEglStreamConnection " , CONV_EGL , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CUeglStreamConnection " , ( " hipEglStreamConnection " , CONV_EGL , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " libraryPropertyType_t " , ( " hipLibraryPropertyType_t " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " libraryPropertyType " , ( " hipLibraryPropertyType_t " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaStreamCallback_t " , ( " hipStreamCallback_t " , CONV_TYPE , API_RUNTIME ) ) , <nl> - ( " cudaArray " , ( " hipArray " , CONV_MEM , API_RUNTIME ) ) , <nl> - ( " cudaArray_t " , ( " hipArray_t " , CONV_MEM , API_RUNTIME ) ) , <nl> - ( " cudaArray_const_t " , ( " hipArray_const_t " , CONV_MEM , API_RUNTIME ) ) , <nl> - ( " cudaMipmappedArray_t " , ( " hipMipmappedArray_t " , CONV_MEM , API_RUNTIME ) ) , <nl> - ( " cudaMipmappedArray_const_t " , ( " hipMipmappedArray_const_t " , CONV_MEM , API_RUNTIME ) ) , <nl> - ( " cudaArrayDefault " , ( " hipArrayDefault " , CONV_MEM , API_RUNTIME ) ) , <nl> - ( " cudaArrayLayered " , ( " hipArrayLayered " , CONV_MEM , API_RUNTIME ) ) , <nl> - ( " cudaArraySurfaceLoadStore " , ( " hipArraySurfaceLoadStore " , CONV_MEM , API_RUNTIME ) ) , <nl> - ( " cudaArrayCubemap " , ( " hipArrayCubemap " , CONV_MEM , API_RUNTIME ) ) , <nl> - ( " cudaArrayTextureGather " , ( " hipArrayTextureGather " , CONV_MEM , API_RUNTIME ) ) , <nl> - ( " cudaMemoryAdvise " , ( " hipMemAdvise " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaMemRangeAttribute " , ( " hipMemRangeAttribute " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaMemcpyKind " , ( " hipMemcpyKind " , CONV_MEM , API_RUNTIME ) ) , <nl> - ( " cudaMemoryType " , ( " hipMemoryType " , CONV_MEM , API_RUNTIME ) ) , <nl> - ( " cudaExtent " , ( " hipExtent " , CONV_MEM , API_RUNTIME ) ) , <nl> - ( " cudaPitchedPtr " , ( " hipPitchedPtr " , CONV_MEM , API_RUNTIME ) ) , <nl> - ( " cudaPos " , ( " hipPos " , CONV_MEM , API_RUNTIME ) ) , <nl> - ( " cudaEvent_t " , ( " hipEvent_t " , CONV_TYPE , API_RUNTIME ) ) , <nl> - ( " cudaStream_t " , ( " hipStream_t " , CONV_TYPE , API_RUNTIME ) ) , <nl> - ( " cudaPointerAttributes " , ( " hipPointerAttribute_t " , CONV_TYPE , API_RUNTIME ) ) , <nl> - ( " cudaDeviceAttr " , ( " hipDeviceAttribute_t " , CONV_TYPE , API_RUNTIME ) ) , <nl> - ( " cudaDeviceProp " , ( " hipDeviceProp_t " , CONV_TYPE , API_RUNTIME ) ) , <nl> - ( " cudaDeviceP2PAttr " , ( " hipDeviceP2PAttribute " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaComputeMode " , ( " hipComputeMode " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaFuncCache " , ( " hipFuncCache_t " , CONV_CACHE , API_RUNTIME ) ) , <nl> - ( " cudaFuncAttributes " , ( " hipFuncAttributes " , CONV_EXEC , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaSharedMemConfig " , ( " hipSharedMemConfig " , CONV_TYPE , API_RUNTIME ) ) , <nl> - ( " cudaLimit " , ( " hipLimit_t " , CONV_TYPE , API_RUNTIME ) ) , <nl> - ( " cudaOutputMode " , ( " hipOutputMode " , CONV_OTHER , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaTextureReadMode " , ( " hipTextureReadMode " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaTextureFilterMode " , ( " hipTextureFilterMode " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaChannelFormatKind " , ( " hipChannelFormatKind " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaChannelFormatDesc " , ( " hipChannelFormatDesc " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaResourceDesc " , ( " hipResourceDesc " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaResourceViewDesc " , ( " hipResourceViewDesc " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaTextureDesc " , ( " hipTextureDesc " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " surfaceReference " , ( " hipSurfaceReference " , CONV_SURFACE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaTextureObject_t " , ( " hipTextureObject_t " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaResourceType " , ( " hipResourceType " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaResourceViewFormat " , ( " hipResourceViewFormat " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaTextureAddressMode " , ( " hipTextureAddressMode " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaSurfaceBoundaryMode " , ( " hipSurfaceBoundaryMode " , CONV_SURFACE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaSurfaceFormatMode " , ( " hipSurfaceFormatMode " , CONV_SURFACE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaTextureType1D " , ( " hipTextureType1D " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaTextureType2D " , ( " hipTextureType2D " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaTextureType3D " , ( " hipTextureType3D " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaTextureTypeCubemap " , ( " hipTextureTypeCubemap " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaTextureType1DLayered " , ( " hipTextureType1DLayered " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaTextureType2DLayered " , ( " hipTextureType2DLayered " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaTextureTypeCubemapLayered " , ( " hipTextureTypeCubemapLayered " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaIpcEventHandle_t " , ( " hipIpcEventHandle_t " , CONV_TYPE , API_RUNTIME ) ) , <nl> - ( " cudaIpcEventHandle_st " , ( " hipIpcEventHandle_t " , CONV_TYPE , API_RUNTIME ) ) , <nl> - ( " cudaIpcMemHandle_t " , ( " hipIpcMemHandle_t " , CONV_TYPE , API_RUNTIME ) ) , <nl> - ( " cudaIpcMemHandle_st " , ( " hipIpcMemHandle_t " , CONV_TYPE , API_RUNTIME ) ) , <nl> - ( " cudaGraphicsCubeFace " , ( " hipGraphicsCubeFace " , CONV_GRAPHICS , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaGraphicsMapFlags " , ( " hipGraphicsMapFlags " , CONV_GRAPHICS , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaGraphicsRegisterFlags " , ( " hipGraphicsRegisterFlags " , CONV_GRAPHICS , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaGLDeviceList " , ( " hipGLDeviceList " , CONV_GL , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaGLMapFlags " , ( " hipGLMapFlags " , CONV_GL , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaD3D9DeviceList " , ( " hipD3D9DeviceList " , CONV_D3D9 , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaD3D9MapFlags " , ( " hipD3D9MapFlags " , CONV_D3D9 , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaD3D9RegisterFlags " , ( " hipD3D9RegisterFlags " , CONV_D3D9 , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaD3D10DeviceList " , ( " hipd3d10DeviceList " , CONV_D3D10 , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaD3D10MapFlags " , ( " hipD3D10MapFlags " , CONV_D3D10 , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaD3D10RegisterFlags " , ( " hipD3D10RegisterFlags " , CONV_D3D10 , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaD3D11DeviceList " , ( " hipd3d11DeviceList " , CONV_D3D11 , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaEglStreamConnection " , ( " hipEglStreamConnection " , CONV_EGL , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasHandle_t " , ( " rocblas_handle " , CONV_TYPE , API_BLAS ) ) , <nl> - ( " cublasOperation_t " , ( " rocblas_operation " , CONV_TYPE , API_BLAS ) ) , <nl> - ( " cublasStatus_t " , ( " rocblas_status " , CONV_TYPE , API_BLAS ) ) , <nl> - ( " cublasFillMode_t " , ( " rocblas_fill " , CONV_TYPE , API_BLAS ) ) , <nl> - ( " cublasDiagType_t " , ( " rocblas_diagonal " , CONV_TYPE , API_BLAS ) ) , <nl> - ( " cublasSideMode_t " , ( " rocblas_side " , CONV_TYPE , API_BLAS ) ) , <nl> - ( " cublasPointerMode_t " , ( " rocblas_pointer_mode " , CONV_TYPE , API_BLAS ) ) , <nl> - ( " cublasAtomicsMode_t " , ( " rocblas_atomics_mode " , CONV_TYPE , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasDataType_t " , ( " rocblas_data_type " , CONV_TYPE , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " curandStatus " , ( " hiprandStatus_t " , CONV_TYPE , API_RAND ) ) , <nl> - ( " curandStatus_t " , ( " hiprandStatus_t " , CONV_TYPE , API_RAND ) ) , <nl> - ( " curandRngType " , ( " hiprandRngType_t " , CONV_TYPE , API_RAND ) ) , <nl> - ( " curandRngType_t " , ( " hiprandRngType_t " , CONV_TYPE , API_RAND ) ) , <nl> - ( " curandGenerator_st " , ( " hiprandGenerator_st " , CONV_TYPE , API_RAND ) ) , <nl> - ( " curandGenerator_t " , ( " hiprandGenerator_t " , CONV_TYPE , API_RAND ) ) , <nl> - ( " curandDirectionVectorSet " , ( " hiprandDirectionVectorSet_t " , CONV_TYPE , API_RAND , HIP_UNSUPPORTED ) ) , <nl> - ( " curandDirectionVectorSet_t " , ( " hiprandDirectionVectorSet_t " , CONV_TYPE , API_RAND , HIP_UNSUPPORTED ) ) , <nl> - ( " curandOrdering " , ( " hiprandOrdering_t " , CONV_TYPE , API_RAND , HIP_UNSUPPORTED ) ) , <nl> - ( " curandOrdering_t " , ( " hiprandOrdering_t " , CONV_TYPE , API_RAND , HIP_UNSUPPORTED ) ) , <nl> - ( " curandDistribution_st " , ( " hiprandDistribution_st " , CONV_TYPE , API_RAND , HIP_UNSUPPORTED ) ) , <nl> - ( " curandHistogramM2V_st " , ( " hiprandDistribution_st " , CONV_TYPE , API_RAND , HIP_UNSUPPORTED ) ) , <nl> - ( " curandDistribution_t " , ( " hiprandDistribution_t " , CONV_TYPE , API_RAND , HIP_UNSUPPORTED ) ) , <nl> - ( " curandHistogramM2V_t " , ( " hiprandDistribution_t " , CONV_TYPE , API_RAND , HIP_UNSUPPORTED ) ) , <nl> - ( " curandDistributionShift_st " , ( " hiprandDistributionShift_st " , CONV_TYPE , API_RAND , HIP_UNSUPPORTED ) ) , <nl> - ( " curandDistributionShift_t " , ( " hiprandDistributionShift_t " , CONV_TYPE , API_RAND , HIP_UNSUPPORTED ) ) , <nl> - ( " curandDistributionM2Shift_st " , ( " hiprandDistributionM2Shift_st " , CONV_TYPE , API_RAND , HIP_UNSUPPORTED ) ) , <nl> - ( " curandDistributionM2Shift_t " , ( " hiprandDistributionM2Shift_t " , CONV_TYPE , API_RAND , HIP_UNSUPPORTED ) ) , <nl> - ( " curandHistogramM2_st " , ( " hiprandHistogramM2_st " , CONV_TYPE , API_RAND , HIP_UNSUPPORTED ) ) , <nl> - ( " curandHistogramM2_t " , ( " hiprandHistogramM2_t " , CONV_TYPE , API_RAND , HIP_UNSUPPORTED ) ) , <nl> - ( " curandHistogramM2K_st " , ( " hiprandHistogramM2K_st " , CONV_TYPE , API_RAND , HIP_UNSUPPORTED ) ) , <nl> - ( " curandHistogramM2K_t " , ( " hiprandHistogramM2K_t " , CONV_TYPE , API_RAND , HIP_UNSUPPORTED ) ) , <nl> - ( " curandDiscreteDistribution_st " , ( " hiprandDiscreteDistribution_st " , CONV_TYPE , API_RAND ) ) , <nl> - ( " curandDiscreteDistribution_t " , ( " hiprandDiscreteDistribution_t " , CONV_TYPE , API_RAND ) ) , <nl> - ( " curandMethod " , ( " hiprandMethod_t " , CONV_TYPE , API_RAND , HIP_UNSUPPORTED ) ) , <nl> - ( " curandMethod_t " , ( " hiprandMethod_t " , CONV_TYPE , API_RAND , HIP_UNSUPPORTED ) ) , <nl> - ( " curandDirectionVectors32_t " , ( " hiprandDirectionVectors32_t " , CONV_TYPE , API_RAND ) ) , <nl> - ( " curandDirectionVectors64_t " , ( " hiprandDirectionVectors64_t " , CONV_TYPE , API_RAND , HIP_UNSUPPORTED ) ) , <nl> - ( " curandStateMtgp32_t " , ( " hiprandStateMtgp32_t " , CONV_TYPE , API_RAND ) ) , <nl> - ( " curandStateMtgp32 " , ( " hiprandStateMtgp32_t " , CONV_TYPE , API_RAND ) ) , <nl> - ( " curandStateScrambledSobol64_t " , ( " hiprandStateScrambledSobol64_t " , CONV_TYPE , API_RAND , HIP_UNSUPPORTED ) ) , <nl> - ( " curandStateSobol64_t " , ( " hiprandStateSobol64_t " , CONV_TYPE , API_RAND , HIP_UNSUPPORTED ) ) , <nl> - ( " curandStateScrambledSobol32_t " , ( " hiprandStateScrambledSobol32_t " , CONV_TYPE , API_RAND , HIP_UNSUPPORTED ) ) , <nl> - ( " curandStateSobol32_t " , ( " hiprandStateSobol32_t " , CONV_TYPE , API_RAND ) ) , <nl> - ( " curandStateMRG32k3a_t " , ( " hiprandStateMRG32k3a_t " , CONV_TYPE , API_RAND ) ) , <nl> - ( " curandStatePhilox4_32_10_t " , ( " hiprandStatePhilox4_32_10_t " , CONV_TYPE , API_RAND ) ) , <nl> - ( " curandStateXORWOW_t " , ( " hiprandStateXORWOW_t " , CONV_TYPE , API_RAND ) ) , <nl> - ( " curandState_t " , ( " hiprandState_t " , CONV_TYPE , API_RAND ) ) , <nl> - ( " curandState " , ( " hiprandState_t " , CONV_TYPE , API_RAND ) ) , <nl> - ] ) <nl> - <nl> - CUDA_INCLUDE_MAP = collections . OrderedDict ( [ <nl> - # since pytorch uses " \ b { pattern } \ b " as the actual re pattern , <nl> - # patterns listed here have to begin and end with alnum chars <nl> - ( " include < cuda . h " , ( " include < hip / hip_runtime . h " , CONV_INCLUDE_CUDA_MAIN_H , API_DRIVER ) ) , <nl> - ( ' include " cuda . h ' , ( ' include " hip / hip_runtime . h ' , CONV_INCLUDE_CUDA_MAIN_H , API_DRIVER ) ) , <nl> - ( " cuda_runtime . h " , ( " hip / hip_runtime . h " , CONV_INCLUDE_CUDA_MAIN_H , API_RUNTIME ) ) , <nl> - ( " cuda_runtime_api . h " , ( " hip / hip_runtime_api . h " , CONV_INCLUDE , API_RUNTIME ) ) , <nl> - ( " channel_descriptor . h " , ( " hip / channel_descriptor . h " , CONV_INCLUDE , API_RUNTIME ) ) , <nl> - ( " device_functions . h " , ( " hip / device_functions . h " , CONV_INCLUDE , API_RUNTIME ) ) , <nl> - ( " driver_types . h " , ( " hip / driver_types . h " , CONV_INCLUDE , API_RUNTIME ) ) , <nl> - ( " cuComplex . h " , ( " hip / hip_complex . h " , CONV_INCLUDE , API_RUNTIME ) ) , <nl> - ( " cuda_fp16 . h " , ( " hip / hip_fp16 . h " , CONV_INCLUDE , API_RUNTIME ) ) , <nl> - ( " cuda_texture_types . h " , ( " hip / hip_texture_types . h " , CONV_INCLUDE , API_RUNTIME ) ) , <nl> - ( " vector_types . h " , ( " hip / hip_vector_types . h " , CONV_INCLUDE , API_RUNTIME ) ) , <nl> - ( " cublas . h " , ( " rocblas . h " , CONV_INCLUDE_CUDA_MAIN_H , API_BLAS ) ) , <nl> - ( " cublas_v2 . h " , ( " rocblas . h " , CONV_INCLUDE_CUDA_MAIN_H , API_BLAS ) ) , <nl> - ( " curand . h " , ( " hiprand . h " , CONV_INCLUDE_CUDA_MAIN_H , API_RAND ) ) , <nl> - ( " curand_kernel . h " , ( " hiprand_kernel . h " , CONV_INCLUDE , API_RAND ) ) , <nl> - ( " curand_discrete . h " , ( " hiprand_kernel . h " , CONV_INCLUDE , API_RAND ) ) , <nl> - ( " curand_discrete2 . h " , ( " hiprand_kernel . h " , CONV_INCLUDE , API_RAND ) ) , <nl> - ( " curand_globals . h " , ( " hiprand_kernel . h " , CONV_INCLUDE , API_RAND ) ) , <nl> - ( " curand_lognormal . h " , ( " hiprand_kernel . h " , CONV_INCLUDE , API_RAND ) ) , <nl> - ( " curand_mrg32k3a . h " , ( " hiprand_kernel . h " , CONV_INCLUDE , API_RAND ) ) , <nl> - ( " curand_mtgp32 . h " , ( " hiprand_kernel . h " , CONV_INCLUDE , API_RAND ) ) , <nl> - ( " curand_mtgp32_host . h " , ( " hiprand_mtgp32_host . h " , CONV_INCLUDE , API_RAND ) ) , <nl> - ( " curand_mtgp32_kernel . h " , ( " hiprand_kernel . h " , CONV_INCLUDE , API_RAND ) ) , <nl> - ( " curand_mtgp32dc_p_11213 . h " , ( " rocrand_mtgp32_11213 . h " , CONV_INCLUDE , API_RAND ) ) , <nl> - ( " curand_normal . h " , ( " hiprand_kernel . h " , CONV_INCLUDE , API_RAND ) ) , <nl> - ( " curand_normal_static . h " , ( " hiprand_kernel . h " , CONV_INCLUDE , API_RAND ) ) , <nl> - ( " curand_philox4x32_x . h " , ( " hiprand_kernel . h " , CONV_INCLUDE , API_RAND ) ) , <nl> - ( " curand_poisson . h " , ( " hiprand_kernel . h " , CONV_INCLUDE , API_RAND ) ) , <nl> - ( " curand_precalc . h " , ( " hiprand_kernel . h " , CONV_INCLUDE , API_RAND ) ) , <nl> - ( " curand_uniform . h " , ( " hiprand_kernel . h " , CONV_INCLUDE , API_RAND ) ) , <nl> - ( " cusparse . h " , ( " hipsparse . h " , CONV_INCLUDE , API_RAND ) ) , <nl> - ( " cufft . h " , ( " hipfft . h " , CONV_INCLUDE , API_BLAS ) ) , <nl> - ( " cufftXt . h " , ( " hipfft . h " , CONV_INCLUDE , API_BLAS ) ) , <nl> - ( " < nccl . h > " , ( " < rccl . h > " , CONV_INCLUDE , API_RUNTIME ) ) , # PyTorch also has a source file named " nccl . h " , so we need to " < " " > " to differentiate <nl> - ( " nvrtc . h " , ( " hip / hiprtc . h " , CONV_INCLUDE , API_RTC ) ) , <nl> - ( " thrust / system / cuda " , ( " thrust / system / hip " , CONV_INCLUDE , API_BLAS ) ) , <nl> - ( " cub / util_allocator . cuh " , ( " hipcub / hipcub . hpp " , CONV_INCLUDE , API_BLAS ) ) , <nl> - ( " cub / block / block_reduce . cuh " , ( " hipcub / hipcub . hpp " , CONV_INCLUDE , API_BLAS ) ) , <nl> - ( " cub / cub . cuh " , ( " hipcub / hipcub . hpp " , CONV_INCLUDE , API_BLAS ) ) , <nl> - ( " cub / block / block_load . cuh " , ( " hipcub / hipcub . hpp " , CONV_INCLUDE , API_BLAS ) ) , <nl> - ( " cub / device / device_reduce . cuh " , ( " hipcub / hipcub . hpp " , CONV_INCLUDE , API_BLAS ) ) , <nl> - ( " cub / device / device_scan . cuh " , ( " hipcub / hipcub . hpp " , CONV_INCLUDE , API_BLAS ) ) , <nl> - ( " nvToolsExt . h " , ( " roctx . h " , CONV_INCLUDE , API_ROCTX ) ) , <nl> - ] ) <nl> - <nl> - CUDA_IDENTIFIER_MAP = collections . OrderedDict ( [ <nl> - ( " __CUDACC__ " , ( " __HIPCC__ " , CONV_DEF , API_RUNTIME ) ) , <nl> - ( " CUDA_ERROR_INVALID_CONTEXT " , ( " hipErrorInvalidContext " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " CUDA_ERROR_CONTEXT_ALREADY_CURRENT " , ( " hipErrorContextAlreadyCurrent " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " CUDA_ERROR_ARRAY_IS_MAPPED " , ( " hipErrorArrayIsMapped " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " CUDA_ERROR_ALREADY_MAPPED " , ( " hipErrorAlreadyMapped " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " CUDA_ERROR_ALREADY_ACQUIRED " , ( " hipErrorAlreadyAcquired " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " CUDA_ERROR_NOT_MAPPED " , ( " hipErrorNotMapped " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " CUDA_ERROR_NOT_MAPPED_AS_ARRAY " , ( " hipErrorNotMappedAsArray " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " CUDA_ERROR_NOT_MAPPED_AS_POINTER " , ( " hipErrorNotMappedAsPointer " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " CUDA_ERROR_CONTEXT_ALREADY_IN_USE " , ( " hipErrorContextAlreadyInUse " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " CUDA_ERROR_INVALID_SOURCE " , ( " hipErrorInvalidSource " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " CUDA_ERROR_FILE_NOT_FOUND " , ( " hipErrorFileNotFound " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " CUDA_ERROR_NOT_FOUND " , ( " hipErrorNotFound " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " CUDA_ERROR_LAUNCH_INCOMPATIBLE_TEXTURING " , ( " hipErrorLaunchIncompatibleTexturing " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CUDA_ERROR_PRIMARY_CONTEXT_ACTIVE " , ( " hipErrorPrimaryContextActive " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CUDA_ERROR_CONTEXT_IS_DESTROYED " , ( " hipErrorContextIsDestroyed " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CUDA_ERROR_NOT_PERMITTED " , ( " hipErrorNotPermitted " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CUDA_ERROR_NOT_SUPPORTED " , ( " hipErrorNotSupported " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaErrorMissingConfiguration " , ( " hipErrorMissingConfiguration " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaErrorPriorLaunchFailure " , ( " hipErrorPriorLaunchFailure " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaErrorInvalidDeviceFunction " , ( " hipErrorInvalidDeviceFunction " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaErrorInvalidConfiguration " , ( " hipErrorInvalidConfiguration " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaErrorInvalidPitchValue " , ( " hipErrorInvalidPitchValue " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaErrorInvalidSymbol " , ( " hipErrorInvalidSymbol " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaErrorInvalidHostPointer " , ( " hipErrorInvalidHostPointer " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaErrorInvalidDevicePointer " , ( " hipErrorInvalidDevicePointer " , CONV_TYPE , API_RUNTIME ) ) , <nl> - ( " cudaErrorInvalidTexture " , ( " hipErrorInvalidTexture " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaErrorInvalidTextureBinding " , ( " hipErrorInvalidTextureBinding " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaErrorInvalidChannelDescriptor " , ( " hipErrorInvalidChannelDescriptor " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaErrorInvalidMemcpyDirection " , ( " hipErrorInvalidMemcpyDirection " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaErrorAddressOfConstant " , ( " hipErrorAddressOfConstant " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaErrorTextureFetchFailed " , ( " hipErrorTextureFetchFailed " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaErrorTextureNotBound " , ( " hipErrorTextureNotBound " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaErrorSynchronizationError " , ( " hipErrorSynchronizationError " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaErrorInvalidFilterSetting " , ( " hipErrorInvalidFilterSetting " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaErrorInvalidNormSetting " , ( " hipErrorInvalidNormSetting " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaErrorMixedDeviceExecution " , ( " hipErrorMixedDeviceExecution " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaErrorNotYetImplemented " , ( " hipErrorNotYetImplemented " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaErrorMemoryValueTooLarge " , ( " hipErrorMemoryValueTooLarge " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaErrorInsufficientDriver " , ( " hipErrorInsufficientDriver " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaErrorSetOnActiveProcess " , ( " hipErrorSetOnActiveProcess " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaErrorInvalidSurface " , ( " hipErrorInvalidSurface " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaErrorDuplicateVariableName " , ( " hipErrorDuplicateVariableName " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaErrorDuplicateTextureName " , ( " hipErrorDuplicateTextureName " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaErrorDuplicateSurfaceName " , ( " hipErrorDuplicateSurfaceName " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaErrorDevicesUnavailable " , ( " hipErrorDevicesUnavailable " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaErrorIncompatibleDriverContext " , ( " hipErrorIncompatibleDriverContext " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaErrorDeviceAlreadyInUse " , ( " hipErrorDeviceAlreadyInUse " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaErrorLaunchMaxDepthExceeded " , ( " hipErrorLaunchMaxDepthExceeded " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaErrorLaunchFileScopedTex " , ( " hipErrorLaunchFileScopedTex " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaErrorLaunchFileScopedSurf " , ( " hipErrorLaunchFileScopedSurf " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaErrorSyncDepthExceeded " , ( " hipErrorSyncDepthExceeded " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaErrorLaunchPendingCountExceeded " , ( " hipErrorLaunchPendingCountExceeded " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaErrorNotPermitted " , ( " hipErrorNotPermitted " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaErrorNotSupported " , ( " hipErrorNotSupported " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaErrorStartupFailure " , ( " hipErrorStartupFailure " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaErrorApiFailureBase " , ( " hipErrorApiFailureBase " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " CUDA_SUCCESS " , ( " hipSuccess " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " cudaSuccess " , ( " hipSuccess " , CONV_TYPE , API_RUNTIME ) ) , <nl> - ( " CUDA_ERROR_INVALID_VALUE " , ( " hipErrorInvalidValue " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " cudaErrorInvalidValue " , ( " hipErrorInvalidValue " , CONV_TYPE , API_RUNTIME ) ) , <nl> - ( " CUDA_ERROR_OUT_OF_MEMORY " , ( " hipErrorMemoryAllocation " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " cudaErrorMemoryAllocation " , ( " hipErrorMemoryAllocation " , CONV_TYPE , API_RUNTIME ) ) , <nl> - ( " CUDA_ERROR_NOT_INITIALIZED " , ( " hipErrorNotInitialized " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " cudaErrorInitializationError " , ( " hipErrorInitializationError " , CONV_TYPE , API_RUNTIME ) ) , <nl> - ( " CUDA_ERROR_DEINITIALIZED " , ( " hipErrorDeinitialized " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " cudaErrorCudartUnloading " , ( " hipErrorDeinitialized " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " CUDA_ERROR_PROFILER_DISABLED " , ( " hipErrorProfilerDisabled " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " cudaErrorProfilerDisabled " , ( " hipErrorProfilerDisabled " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " CUDA_ERROR_PROFILER_NOT_INITIALIZED " , ( " hipErrorProfilerNotInitialized " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " cudaErrorProfilerNotInitialized " , ( " hipErrorProfilerNotInitialized " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " CUDA_ERROR_PROFILER_ALREADY_STARTED " , ( " hipErrorProfilerAlreadyStarted " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " cudaErrorProfilerAlreadyStarted " , ( " hipErrorProfilerAlreadyStarted " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " CUDA_ERROR_PROFILER_ALREADY_STOPPED " , ( " hipErrorProfilerAlreadyStopped " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " cudaErrorProfilerAlreadyStopped " , ( " hipErrorProfilerAlreadyStopped " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " CUDA_ERROR_NO_DEVICE " , ( " hipErrorNoDevice " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " cudaErrorNoDevice " , ( " hipErrorNoDevice " , CONV_TYPE , API_RUNTIME ) ) , <nl> - ( " CUDA_ERROR_INVALID_DEVICE " , ( " hipErrorInvalidDevice " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " cudaErrorInvalidDevice " , ( " hipErrorInvalidDevice " , CONV_TYPE , API_RUNTIME ) ) , <nl> - ( " CUDA_ERROR_INVALID_IMAGE " , ( " hipErrorInvalidImage " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " cudaErrorInvalidKernelImage " , ( " hipErrorInvalidImage " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " CUDA_ERROR_MAP_FAILED " , ( " hipErrorMapFailed " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " cudaErrorMapBufferObjectFailed " , ( " hipErrorMapFailed " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " CUDA_ERROR_UNMAP_FAILED " , ( " hipErrorUnmapFailed " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " cudaErrorUnmapBufferObjectFailed " , ( " hipErrorUnmapFailed " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " CUDA_ERROR_NO_BINARY_FOR_GPU " , ( " hipErrorNoBinaryForGpu " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " cudaErrorNoKernelImageForDevice " , ( " hipErrorNoBinaryForGpu " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " CUDA_ERROR_ECC_UNCORRECTABLE " , ( " hipErrorECCNotCorrectable " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " cudaErrorECCUncorrectable " , ( " hipErrorECCNotCorrectable " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " CUDA_ERROR_UNSUPPORTED_LIMIT " , ( " hipErrorUnsupportedLimit " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " cudaErrorUnsupportedLimit " , ( " hipErrorUnsupportedLimit " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " CUDA_ERROR_PEER_ACCESS_UNSUPPORTED " , ( " hipErrorPeerAccessUnsupported " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " cudaErrorPeerAccessUnsupported " , ( " hipErrorPeerAccessUnsupported " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " CUDA_ERROR_INVALID_PTX " , ( " hipErrorInvalidKernelFile " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " cudaErrorInvalidPtx " , ( " hipErrorInvalidKernelFile " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " CUDA_ERROR_INVALID_GRAPHICS_CONTEXT " , ( " hipErrorInvalidGraphicsContext " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " cudaErrorInvalidGraphicsContext " , ( " hipErrorInvalidGraphicsContext " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " CUDA_ERROR_NVLINK_UNCORRECTABLE " , ( " hipErrorNvlinkUncorrectable " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaErrorNvlinkUncorrectable " , ( " hipErrorNvlinkUncorrectable " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " CUDA_ERROR_SHARED_OBJECT_SYMBOL_NOT_FOUND " , ( " hipErrorSharedObjectSymbolNotFound " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " cudaErrorSharedObjectSymbolNotFound " , ( " hipErrorSharedObjectSymbolNotFound " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " CUDA_ERROR_SHARED_OBJECT_INIT_FAILED " , ( " hipErrorSharedObjectInitFailed " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " cudaErrorSharedObjectInitFailed " , ( " hipErrorSharedObjectInitFailed " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " CUDA_ERROR_OPERATING_SYSTEM " , ( " hipErrorOperatingSystem " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " cudaErrorOperatingSystem " , ( " hipErrorOperatingSystem " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " CUDA_ERROR_INVALID_HANDLE " , ( " hipErrorInvalidResourceHandle " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " cudaErrorInvalidResourceHandle " , ( " hipErrorInvalidResourceHandle " , CONV_TYPE , API_RUNTIME ) ) , <nl> - ( " CUDA_ERROR_NOT_READY " , ( " hipErrorNotReady " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " cudaErrorNotReady " , ( " hipErrorNotReady " , CONV_TYPE , API_RUNTIME ) ) , <nl> - ( " CUDA_ERROR_ILLEGAL_ADDRESS " , ( " hipErrorIllegalAddress " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " cudaErrorIllegalAddress " , ( " hipErrorIllegalAddress " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " CUDA_ERROR_LAUNCH_OUT_OF_RESOURCES " , ( " hipErrorLaunchOutOfResources " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " cudaErrorLaunchOutOfResources " , ( " hipErrorLaunchOutOfResources " , CONV_TYPE , API_RUNTIME ) ) , <nl> - ( " CUDA_ERROR_LAUNCH_TIMEOUT " , ( " hipErrorLaunchTimeOut " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " cudaErrorLaunchTimeout " , ( " hipErrorLaunchTimeOut " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " CUDA_ERROR_PEER_ACCESS_ALREADY_ENABLED " , ( " hipErrorPeerAccessAlreadyEnabled " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " cudaErrorPeerAccessAlreadyEnabled " , ( " hipErrorPeerAccessAlreadyEnabled " , CONV_TYPE , API_RUNTIME ) ) , <nl> - ( " CUDA_ERROR_PEER_ACCESS_NOT_ENABLED " , ( " hipErrorPeerAccessNotEnabled " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " cudaErrorPeerAccessNotEnabled " , ( " hipErrorPeerAccessNotEnabled " , CONV_TYPE , API_RUNTIME ) ) , <nl> - ( " CUDA_ERROR_ASSERT " , ( " hipErrorAssert " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaErrorAssert " , ( " hipErrorAssert " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " CUDA_ERROR_TOO_MANY_PEERS " , ( " hipErrorTooManyPeers " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaErrorTooManyPeers " , ( " hipErrorTooManyPeers " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " CUDA_ERROR_HOST_MEMORY_ALREADY_REGISTERED " , ( " hipErrorHostMemoryAlreadyRegistered " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " cudaErrorHostMemoryAlreadyRegistered " , ( " hipErrorHostMemoryAlreadyRegistered " , CONV_TYPE , API_RUNTIME ) ) , <nl> - ( " CUDA_ERROR_HOST_MEMORY_NOT_REGISTERED " , ( " hipErrorHostMemoryNotRegistered " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " cudaErrorHostMemoryNotRegistered " , ( " hipErrorHostMemoryNotRegistered " , CONV_TYPE , API_RUNTIME ) ) , <nl> - ( " CUDA_ERROR_HARDWARE_STACK_ERROR " , ( " hipErrorHardwareStackError " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaErrorHardwareStackError " , ( " hipErrorHardwareStackError " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " CUDA_ERROR_ILLEGAL_INSTRUCTION " , ( " hipErrorIllegalInstruction " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaErrorIllegalInstruction " , ( " hipErrorIllegalInstruction " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " CUDA_ERROR_MISALIGNED_ADDRESS " , ( " hipErrorMisalignedAddress " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaErrorMisalignedAddress " , ( " hipErrorMisalignedAddress " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " CUDA_ERROR_INVALID_ADDRESS_SPACE " , ( " hipErrorInvalidAddressSpace " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaErrorInvalidAddressSpace " , ( " hipErrorInvalidAddressSpace " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " CUDA_ERROR_INVALID_PC " , ( " hipErrorInvalidPc " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaErrorInvalidPc " , ( " hipErrorInvalidPc " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " CUDA_ERROR_LAUNCH_FAILED " , ( " hipErrorLaunchFailure " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaErrorLaunchFailure " , ( " hipErrorLaunchFailure " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " CUDA_ERROR_UNKNOWN " , ( " hipErrorUnknown " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaErrorUnknown " , ( " hipErrorUnknown " , CONV_TYPE , API_RUNTIME ) ) , <nl> - ( " CU_TR_ADDRESS_MODE_WRAP " , ( " HIP_TR_ADDRESS_MODE_WRAP " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_TR_ADDRESS_MODE_CLAMP " , ( " HIP_TR_ADDRESS_MODE_CLAMP " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_TR_ADDRESS_MODE_MIRROR " , ( " HIP_TR_ADDRESS_MODE_MIRROR " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_TR_ADDRESS_MODE_BORDER " , ( " HIP_TR_ADDRESS_MODE_BORDER " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_CUBEMAP_FACE_POSITIVE_X " , ( " HIP_CUBEMAP_FACE_POSITIVE_X " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_CUBEMAP_FACE_NEGATIVE_X " , ( " HIP_CUBEMAP_FACE_NEGATIVE_X " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_CUBEMAP_FACE_POSITIVE_Y " , ( " HIP_CUBEMAP_FACE_POSITIVE_Y " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_CUBEMAP_FACE_NEGATIVE_Y " , ( " HIP_CUBEMAP_FACE_NEGATIVE_Y " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_CUBEMAP_FACE_POSITIVE_Z " , ( " HIP_CUBEMAP_FACE_POSITIVE_Z " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_CUBEMAP_FACE_NEGATIVE_Z " , ( " HIP_CUBEMAP_FACE_NEGATIVE_Z " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_AD_FORMAT_UNSIGNED_INT8 " , ( " HIP_AD_FORMAT_UNSIGNED_INT8 " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " CU_AD_FORMAT_UNSIGNED_INT16 " , ( " HIP_AD_FORMAT_UNSIGNED_INT16 " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " CU_AD_FORMAT_UNSIGNED_INT32 " , ( " HIP_AD_FORMAT_UNSIGNED_INT32 " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " CU_AD_FORMAT_SIGNED_INT8 " , ( " HIP_AD_FORMAT_SIGNED_INT8 " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " CU_AD_FORMAT_SIGNED_INT16 " , ( " HIP_AD_FORMAT_SIGNED_INT16 " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " CU_AD_FORMAT_SIGNED_INT32 " , ( " HIP_AD_FORMAT_SIGNED_INT32 " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " CU_AD_FORMAT_HALF " , ( " HIP_AD_FORMAT_HALF " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " CU_AD_FORMAT_FLOAT " , ( " HIP_AD_FORMAT_FLOAT " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " CU_COMPUTEMODE_DEFAULT " , ( " hipComputeModeDefault " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_COMPUTEMODE_EXCLUSIVE " , ( " hipComputeModeExclusive " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_COMPUTEMODE_PROHIBITED " , ( " hipComputeModeProhibited " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_COMPUTEMODE_EXCLUSIVE_PROCESS " , ( " hipComputeModeExclusiveProcess " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_MEM_ADVISE_SET_READ_MOSTLY " , ( " hipMemAdviseSetReadMostly " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_MEM_ADVISE_UNSET_READ_MOSTLY " , ( " hipMemAdviseUnsetReadMostly " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_MEM_ADVISE_SET_PREFERRED_LOCATION " , ( " hipMemAdviseSetPreferredLocation " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_MEM_ADVISE_UNSET_PREFERRED_LOCATION " , ( " hipMemAdviseUnsetPreferredLocation " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_MEM_ADVISE_SET_ACCESSED_BY " , ( " hipMemAdviseSetAccessedBy " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_MEM_ADVISE_UNSET_ACCESSED_BY " , ( " hipMemAdviseUnsetAccessedBy " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_MEM_RANGE_ATTRIBUTE_READ_MOSTLY " , ( " hipMemRangeAttributeReadMostly " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_MEM_RANGE_ATTRIBUTE_PREFERRED_LOCATION " , ( " hipMemRangeAttributePreferredLocation " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_MEM_RANGE_ATTRIBUTE_ACCESSED_BY " , ( " hipMemRangeAttributeAccessedBy " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_MEM_RANGE_ATTRIBUTE_LAST_PREFETCH_LOCATION " , ( " hipMemRangeAttributeLastPrefetchLocation " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_CTX_SCHED_AUTO " , ( " HIP_CTX_SCHED_AUTO " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_CTX_SCHED_SPIN " , ( " HIP_CTX_SCHED_SPIN " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_CTX_SCHED_YIELD " , ( " HIP_CTX_SCHED_YIELD " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_CTX_SCHED_BLOCKING_SYNC " , ( " HIP_CTX_SCHED_BLOCKING_SYNC " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_CTX_BLOCKING_SYNC " , ( " HIP_CTX_BLOCKING_SYNC " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_CTX_SCHED_MASK " , ( " HIP_CTX_SCHED_MASK " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_CTX_MAP_HOST " , ( " HIP_CTX_MAP_HOST " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_CTX_LMEM_RESIZE_TO_MAX " , ( " HIP_CTX_LMEM_RESIZE_TO_MAX " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_CTX_FLAGS_MASK " , ( " HIP_CTX_FLAGS_MASK " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_LAUNCH_PARAM_BUFFER_POINTER " , ( " HIP_LAUNCH_PARAM_BUFFER_POINTER " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " CU_LAUNCH_PARAM_BUFFER_SIZE " , ( " HIP_LAUNCH_PARAM_BUFFER_SIZE " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " CU_LAUNCH_PARAM_END " , ( " HIP_LAUNCH_PARAM_END " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " CU_IPC_HANDLE_SIZE " , ( " HIP_LAUNCH_PARAM_END " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_MEMHOSTALLOC_DEVICEMAP " , ( " HIP_MEMHOSTALLOC_DEVICEMAP " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_MEMHOSTALLOC_PORTABLE " , ( " HIP_MEMHOSTALLOC_PORTABLE " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_MEMHOSTALLOC_WRITECOMBINED " , ( " HIP_MEMHOSTALLOC_WRITECOMBINED " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_MEMHOSTREGISTER_DEVICEMAP " , ( " HIP_MEMHOSTREGISTER_DEVICEMAP " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_MEMHOSTREGISTER_IOMEMORY " , ( " HIP_MEMHOSTREGISTER_IOMEMORY " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_MEMHOSTREGISTER_PORTABLE " , ( " HIP_MEMHOSTREGISTER_PORTABLE " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_PARAM_TR_DEFAULT " , ( " HIP_PARAM_TR_DEFAULT " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_STREAM_LEGACY " , ( " HIP_STREAM_LEGACY " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_STREAM_PER_THREAD " , ( " HIP_STREAM_PER_THREAD " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_TRSA_OVERRIDE_FORMAT " , ( " HIP_TRSA_OVERRIDE_FORMAT " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_TRSF_NORMALIZED_COORDINATES " , ( " HIP_TRSF_NORMALIZED_COORDINATES " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_TRSF_READ_AS_INTEGER " , ( " HIP_TRSF_READ_AS_INTEGER " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_TRSF_SRGB " , ( " HIP_TRSF_SRGB " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CUDA_ARRAY3D_2DARRAY " , ( " HIP_ARRAY3D_LAYERED " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CUDA_ARRAY3D_CUBEMAP " , ( " HIP_ARRAY3D_CUBEMAP " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CUDA_ARRAY3D_DEPTH_TEXTURE " , ( " HIP_ARRAY3D_DEPTH_TEXTURE " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CUDA_ARRAY3D_LAYERED " , ( " HIP_ARRAY3D_LAYERED " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CUDA_ARRAY3D_SURFACE_LDST " , ( " HIP_ARRAY3D_SURFACE_LDST " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CUDA_ARRAY3D_TEXTURE_GATHER " , ( " HIP_ARRAY3D_TEXTURE_GATHER " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_MAX_THREADS_PER_BLOCK " , ( " hipDeviceAttributeMaxThreadsPerBlock " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_MAX_BLOCK_DIM_X " , ( " hipDeviceAttributeMaxBlockDimX " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_MAX_BLOCK_DIM_Y " , ( " hipDeviceAttributeMaxBlockDimY " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_MAX_BLOCK_DIM_Z " , ( " hipDeviceAttributeMaxBlockDimZ " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_MAX_GRID_DIM_X " , ( " hipDeviceAttributeMaxGridDimX " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_MAX_GRID_DIM_Y " , ( " hipDeviceAttributeMaxGridDimY " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_MAX_GRID_DIM_Z " , ( " hipDeviceAttributeMaxGridDimZ " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_BLOCK " , ( " hipDeviceAttributeMaxSharedMemoryPerBlock " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_SHARED_MEMORY_PER_BLOCK " , ( " hipDeviceAttributeMaxSharedMemoryPerBlock " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_TOTAL_CONSTANT_MEMORY " , ( " hipDeviceAttributeTotalConstantMemory " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_WARP_SIZE " , ( " hipDeviceAttributeWarpSize " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_MAX_PITCH " , ( " hipDeviceAttributeMaxPitch " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_MAX_REGISTERS_PER_BLOCK " , ( " hipDeviceAttributeMaxRegistersPerBlock " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_REGISTERS_PER_BLOCK " , ( " hipDeviceAttributeMaxRegistersPerBlock " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_CLOCK_RATE " , ( " hipDeviceAttributeClockRate " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_TEXTURE_ALIGNMENT " , ( " hipDeviceAttributeTextureAlignment " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_GPU_OVERLAP " , ( " hipDeviceAttributeAsyncEngineCount " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_MULTIPROCESSOR_COUNT " , ( " hipDeviceAttributeMultiprocessorCount " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_KERNEL_EXEC_TIMEOUT " , ( " hipDeviceAttributeKernelExecTimeout " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_INTEGRATED " , ( " hipDeviceAttributeIntegrated " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_CAN_MAP_HOST_MEMORY " , ( " hipDeviceAttributeCanMapHostMemory " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_COMPUTE_MODE " , ( " hipDeviceAttributeComputeMode " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_WIDTH " , ( " hipDeviceAttributeMaxTexture1DWidth " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_WIDTH " , ( " hipDeviceAttributeMaxTexture2DWidth " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_HEIGHT " , ( " hipDeviceAttributeMaxTexture2DHeight " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_WIDTH " , ( " hipDeviceAttributeMaxTexture3DWidth " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_HEIGHT " , ( " hipDeviceAttributeMaxTexture3DHeight " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_DEPTH " , ( " hipDeviceAttributeMaxTexture3DDepth " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LAYERED_WIDTH " , ( " hipDeviceAttributeMaxTexture2DLayeredWidth " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LAYERED_HEIGHT " , ( " hipDeviceAttributeMaxTexture2DLayeredHeight " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LAYERED_LAYERS " , ( " hipDeviceAttributeMaxTexture2DLayeredLayers " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_ARRAY_WIDTH " , ( " hipDeviceAttributeMaxTexture2DLayeredWidth " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_ARRAY_HEIGHT " , ( " hipDeviceAttributeMaxTexture2DLayeredHeight " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_ARRAY_NUMSLICES " , ( " hipDeviceAttributeMaxTexture2DLayeredLayers " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_SURFACE_ALIGNMENT " , ( " hipDeviceAttributeSurfaceAlignment " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_CONCURRENT_KERNELS " , ( " hipDeviceAttributeConcurrentKernels " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_ECC_ENABLED " , ( " hipDeviceAttributeEccEnabled " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_PCI_BUS_ID " , ( " hipDeviceAttributePciBusId " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_PCI_DEVICE_ID " , ( " hipDeviceAttributePciDeviceId " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_TCC_DRIVER " , ( " hipDeviceAttributeTccDriver " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_MEMORY_CLOCK_RATE " , ( " hipDeviceAttributeMemoryClockRate " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_GLOBAL_MEMORY_BUS_WIDTH " , ( " hipDeviceAttributeMemoryBusWidth " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_L2_CACHE_SIZE " , ( " hipDeviceAttributeL2CacheSize " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_MAX_THREADS_PER_MULTIPROCESSOR " , ( " hipDeviceAttributeMaxThreadsPerMultiProcessor " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_ASYNC_ENGINE_COUNT " , ( " hipDeviceAttributeAsyncEngineCount " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_UNIFIED_ADDRESSING " , ( " hipDeviceAttributeUnifiedAddressing " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_LAYERED_WIDTH " , ( " hipDeviceAttributeMaxTexture1DLayeredWidth " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_LAYERED_LAYERS " , ( " hipDeviceAttributeMaxTexture1DLayeredLayers " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_CAN_TEX2D_GATHER " , ( " hipDeviceAttributeCanTex2DGather " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_GATHER_WIDTH " , ( " hipDeviceAttributeMaxTexture2DGatherWidth " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_GATHER_HEIGHT " , ( " hipDeviceAttributeMaxTexture2DGatherHeight " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_WIDTH_ALTERNATE " , ( " hipDeviceAttributeMaxTexture3DWidthAlternate " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_HEIGHT_ALTERNATE " , ( " hipDeviceAttributeMaxTexture3DHeightAlternate " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_DEPTH_ALTERNATE " , ( " hipDeviceAttributeMaxTexture3DDepthAlternate " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_PCI_DOMAIN_ID " , ( " hipDeviceAttributePciDomainId " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_TEXTURE_PITCH_ALIGNMENT " , ( " hipDeviceAttributeTexturePitchAlignment " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURECUBEMAP_WIDTH " , ( " hipDeviceAttributeMaxTextureCubemapWidth " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURECUBEMAP_LAYERED_WIDTH " , ( " hipDeviceAttributeMaxTextureCubemapLayeredWidth " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURECUBEMAP_LAYERED_LAYERS " , ( " hipDeviceAttributeMaxTextureCubemapLayeredLayers " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE1D_WIDTH " , ( " hipDeviceAttributeMaxSurface1DWidth " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_WIDTH " , ( " hipDeviceAttributeMaxSurface2DWidth " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_HEIGHT " , ( " hipDeviceAttributeMaxSurface2DHeight " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE3D_WIDTH " , ( " hipDeviceAttributeMaxSurface3DWidth " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE3D_HEIGHT " , ( " hipDeviceAttributeMaxSurface3DHeight " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE3D_DEPTH " , ( " hipDeviceAttributeMaxSurface3DDepth " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE1D_LAYERED_WIDTH " , ( " hipDeviceAttributeMaxSurface1DLayeredWidth " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE1D_LAYERED_LAYERS " , ( " hipDeviceAttributeMaxSurface1DLayeredLayers " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_LAYERED_WIDTH " , ( " hipDeviceAttributeMaxSurface2DLayeredWidth " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_LAYERED_HEIGHT " , ( " hipDeviceAttributeMaxSurface2DLayeredHeight " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_LAYERED_LAYERS " , ( " hipDeviceAttributeMaxSurface2DLayeredLayers " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACECUBEMAP_WIDTH " , ( " hipDeviceAttributeMaxSurfaceCubemapWidth " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACECUBEMAP_LAYERED_WIDTH " , ( " hipDeviceAttributeMaxSurfaceCubemapLayeredWidth " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACECUBEMAP_LAYERED_LAYERS " , ( " hipDeviceAttributeMaxSurfaceCubemapLayeredLayers " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_LINEAR_WIDTH " , ( " hipDeviceAttributeMaxTexture1DLinearWidth " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LINEAR_WIDTH " , ( " hipDeviceAttributeMaxTexture2DLinearWidth " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LINEAR_HEIGHT " , ( " hipDeviceAttributeMaxTexture2DLinearHeight " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LINEAR_PITCH " , ( " hipDeviceAttributeMaxTexture2DLinearPitch " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_MIPMAPPED_WIDTH " , ( " hipDeviceAttributeMaxTexture2DMipmappedWidth " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_MIPMAPPED_HEIGHT " , ( " hipDeviceAttributeMaxTexture2DMipmappedHeight " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR " , ( " hipDeviceAttributeComputeCapabilityMajor " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR " , ( " hipDeviceAttributeComputeCapabilityMinor " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_MIPMAPPED_WIDTH " , ( " hipDeviceAttributeMaxTexture1DMipmappedWidth " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_STREAM_PRIORITIES_SUPPORTED " , ( " hipDeviceAttributeStreamPrioritiesSupported " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_GLOBAL_L1_CACHE_SUPPORTED " , ( " hipDeviceAttributeGlobalL1CacheSupported " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_LOCAL_L1_CACHE_SUPPORTED " , ( " hipDeviceAttributeLocalL1CacheSupported " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_MULTIPROCESSOR " , ( " hipDeviceAttributeMaxSharedMemoryPerMultiprocessor " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_MAX_REGISTERS_PER_MULTIPROCESSOR " , ( " hipDeviceAttributeMaxRegistersPerMultiprocessor " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_MANAGED_MEMORY " , ( " hipDeviceAttributeManagedMemory " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_MULTI_GPU_BOARD " , ( " hipDeviceAttributeIsMultiGpuBoard " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_MULTI_GPU_BOARD_GROUP_ID " , ( " hipDeviceAttributeMultiGpuBoardGroupId " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_HOST_NATIVE_ATOMIC_SUPPORTED " , ( " hipDeviceAttributeHostNativeAtomicSupported " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_SINGLE_TO_DOUBLE_PRECISION_PERF_RATIO " , ( " hipDeviceAttributeSingleToDoublePrecisionPerfRatio " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_PAGEABLE_MEMORY_ACCESS " , ( " hipDeviceAttributePageableMemoryAccess " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS " , ( " hipDeviceAttributeConcurrentManagedAccess " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_COMPUTE_PREEMPTION_SUPPORTED " , ( " hipDeviceAttributeComputePreemptionSupported " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_CAN_USE_HOST_POINTER_FOR_REGISTERED_MEM " , ( " hipDeviceAttributeCanUseHostPointerForRegisteredMem " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_ATTRIBUTE_MAX " , ( " hipDeviceAttributeMax " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_POINTER_ATTRIBUTE_CONTEXT " , ( " hipPointerAttributeContext " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_POINTER_ATTRIBUTE_MEMORY_TYPE " , ( " hipPointerAttributeMemoryType " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_POINTER_ATTRIBUTE_DEVICE_POINTER " , ( " hipPointerAttributeDevicePointer " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_POINTER_ATTRIBUTE_HOST_POINTER " , ( " hipPointerAttributeHostPointer " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_POINTER_ATTRIBUTE_P2P_TOKENS " , ( " hipPointerAttributeP2pTokens " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_POINTER_ATTRIBUTE_SYNC_MEMOPS " , ( " hipPointerAttributeSyncMemops " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_POINTER_ATTRIBUTE_BUFFER_ID " , ( " hipPointerAttributeBufferId " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_POINTER_ATTRIBUTE_IS_MANAGED " , ( " hipPointerAttributeIsManaged " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_FUNC_ATTRIBUTE_MAX_THREADS_PER_BLOCK " , ( " hipFuncAttributeMaxThreadsPerBlocks " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_FUNC_ATTRIBUTE_SHARED_SIZE_BYTES " , ( " hipFuncAttributeSharedSizeBytes " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_FUNC_ATTRIBUTE_CONST_SIZE_BYTES " , ( " hipFuncAttributeConstSizeBytes " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_FUNC_ATTRIBUTE_LOCAL_SIZE_BYTES " , ( " hipFuncAttributeLocalSizeBytes " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_FUNC_ATTRIBUTE_NUM_REGS " , ( " hipFuncAttributeNumRegs " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_FUNC_ATTRIBUTE_PTX_VERSION " , ( " hipFuncAttributePtxVersion " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_FUNC_ATTRIBUTE_BINARY_VERSION " , ( " hipFuncAttributeBinaryVersion " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_FUNC_ATTRIBUTE_CACHE_MODE_CA " , ( " hipFuncAttributeCacheModeCA " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_FUNC_ATTRIBUTE_MAX " , ( " hipFuncAttributeMax " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_GRAPHICS_MAP_RESOURCE_FLAGS_NONE " , ( " hipGraphicsMapFlagsNone " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_GRAPHICS_MAP_RESOURCE_FLAGS_READ_ONLY " , ( " hipGraphicsMapFlagsReadOnly " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_GRAPHICS_MAP_RESOURCE_FLAGS_WRITE_DISCARD " , ( " hipGraphicsMapFlagsWriteDiscard " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_GRAPHICS_REGISTER_FLAGS_NONE " , ( " hipGraphicsRegisterFlagsNone " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_GRAPHICS_REGISTER_FLAGS_READ_ONLY " , ( " hipGraphicsRegisterFlagsReadOnly " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_GRAPHICS_REGISTER_FLAGS_WRITE_DISCARD " , ( " hipGraphicsRegisterFlagsWriteDiscard " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_GRAPHICS_REGISTER_FLAGS_SURFACE_LDST " , ( " hipGraphicsRegisterFlagsSurfaceLoadStore " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_GRAPHICS_REGISTER_FLAGS_TEXTURE_GATHER " , ( " hipGraphicsRegisterFlagsTextureGather " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_OCCUPANCY_DEFAULT " , ( " hipOccupancyDefault " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_OCCUPANCY_DISABLE_CACHING_OVERRIDE " , ( " hipOccupancyDisableCachingOverride " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_FUNC_CACHE_PREFER_NONE " , ( " hipFuncCachePreferNone " , CONV_CACHE , API_DRIVER ) ) , <nl> - ( " CU_FUNC_CACHE_PREFER_SHARED " , ( " hipFuncCachePreferShared " , CONV_CACHE , API_DRIVER ) ) , <nl> - ( " CU_FUNC_CACHE_PREFER_L1 " , ( " hipFuncCachePreferL1 " , CONV_CACHE , API_DRIVER ) ) , <nl> - ( " CU_FUNC_CACHE_PREFER_EQUAL " , ( " hipFuncCachePreferEqual " , CONV_CACHE , API_DRIVER ) ) , <nl> - ( " CU_IPC_MEM_LAZY_ENABLE_PEER_ACCESS " , ( " hipIpcMemLazyEnablePeerAccess " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CUDA_IPC_HANDLE_SIZE " , ( " HIP_IPC_HANDLE_SIZE " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " CU_JIT_CACHE_OPTION_NONE " , ( " hipJitCacheModeOptionNone " , CONV_JIT , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_JIT_CACHE_OPTION_CG " , ( " hipJitCacheModeOptionCG " , CONV_JIT , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_JIT_CACHE_OPTION_CA " , ( " hipJitCacheModeOptionCA " , CONV_JIT , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_PREFER_PTX " , ( " hipJitFallbackPreferPtx " , CONV_JIT , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_PREFER_BINARY " , ( " hipJitFallbackPreferBinary " , CONV_JIT , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_JIT_MAX_REGISTERS " , ( " hipJitOptionMaxRegisters " , CONV_JIT , API_DRIVER ) ) , <nl> - ( " CU_JIT_THREADS_PER_BLOCK " , ( " hipJitOptionThreadsPerBlock " , CONV_JIT , API_DRIVER ) ) , <nl> - ( " CU_JIT_WALL_TIME " , ( " hipJitOptionWallTime " , CONV_JIT , API_DRIVER ) ) , <nl> - ( " CU_JIT_INFO_LOG_BUFFER " , ( " hipJitOptionInfoLogBuffer " , CONV_JIT , API_DRIVER ) ) , <nl> - ( " CU_JIT_INFO_LOG_BUFFER_SIZE_BYTES " , ( " hipJitOptionInfoLogBufferSizeBytes " , CONV_JIT , API_DRIVER ) ) , <nl> - ( " CU_JIT_ERROR_LOG_BUFFER " , ( " hipJitOptionErrorLogBuffer " , CONV_JIT , API_DRIVER ) ) , <nl> - ( " CU_JIT_ERROR_LOG_BUFFER_SIZE_BYTES " , ( " hipJitOptionErrorLogBufferSizeBytes " , CONV_JIT , API_DRIVER ) ) , <nl> - ( " CU_JIT_OPTIMIZATION_LEVEL " , ( " hipJitOptionOptimizationLevel " , CONV_JIT , API_DRIVER ) ) , <nl> - ( " CU_JIT_TARGET_FROM_CUCONTEXT " , ( " hipJitOptionTargetFromContext " , CONV_JIT , API_DRIVER ) ) , <nl> - ( " CU_JIT_TARGET " , ( " hipJitOptionTarget " , CONV_JIT , API_DRIVER ) ) , <nl> - ( " CU_JIT_FALLBACK_STRATEGY " , ( " hipJitOptionFallbackStrategy " , CONV_JIT , API_DRIVER ) ) , <nl> - ( " CU_JIT_GENERATE_DEBUG_INFO " , ( " hipJitOptionGenerateDebugInfo " , CONV_JIT , API_DRIVER ) ) , <nl> - ( " CU_JIT_LOG_VERBOSE " , ( " hipJitOptionLogVerbose " , CONV_JIT , API_DRIVER ) ) , <nl> - ( " CU_JIT_GENERATE_LINE_INFO " , ( " hipJitOptionGenerateLineInfo " , CONV_JIT , API_DRIVER ) ) , <nl> - ( " CU_JIT_CACHE_MODE " , ( " hipJitOptionCacheMode " , CONV_JIT , API_DRIVER ) ) , <nl> - ( " CU_JIT_NEW_SM3X_OPT " , ( " hipJitOptionSm3xOpt " , CONV_JIT , API_DRIVER ) ) , <nl> - ( " CU_JIT_FAST_COMPILE " , ( " hipJitOptionFastCompile " , CONV_JIT , API_DRIVER ) ) , <nl> - ( " CU_JIT_NUM_OPTIONS " , ( " hipJitOptionNumOptions " , CONV_JIT , API_DRIVER ) ) , <nl> - ( " CU_TARGET_COMPUTE_10 " , ( " hipJitTargetCompute10 " , CONV_JIT , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_TARGET_COMPUTE_11 " , ( " hipJitTargetCompute11 " , CONV_JIT , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_TARGET_COMPUTE_12 " , ( " hipJitTargetCompute12 " , CONV_JIT , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_TARGET_COMPUTE_13 " , ( " hipJitTargetCompute13 " , CONV_JIT , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_TARGET_COMPUTE_20 " , ( " hipJitTargetCompute20 " , CONV_JIT , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_TARGET_COMPUTE_21 " , ( " hipJitTargetCompute21 " , CONV_JIT , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_TARGET_COMPUTE_30 " , ( " hipJitTargetCompute30 " , CONV_JIT , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_TARGET_COMPUTE_32 " , ( " hipJitTargetCompute32 " , CONV_JIT , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_TARGET_COMPUTE_35 " , ( " hipJitTargetCompute35 " , CONV_JIT , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_TARGET_COMPUTE_37 " , ( " hipJitTargetCompute37 " , CONV_JIT , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_TARGET_COMPUTE_50 " , ( " hipJitTargetCompute50 " , CONV_JIT , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_TARGET_COMPUTE_52 " , ( " hipJitTargetCompute52 " , CONV_JIT , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_TARGET_COMPUTE_53 " , ( " hipJitTargetCompute53 " , CONV_JIT , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_TARGET_COMPUTE_60 " , ( " hipJitTargetCompute60 " , CONV_JIT , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_TARGET_COMPUTE_61 " , ( " hipJitTargetCompute61 " , CONV_JIT , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_TARGET_COMPUTE_62 " , ( " hipJitTargetCompute62 " , CONV_JIT , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_JIT_INPUT_CUBIN " , ( " hipJitInputTypeBin " , CONV_JIT , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_JIT_INPUT_PTX " , ( " hipJitInputTypePtx " , CONV_JIT , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_JIT_INPUT_FATBINARY " , ( " hipJitInputTypeFatBinary " , CONV_JIT , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_JIT_INPUT_OBJECT " , ( " hipJitInputTypeObject " , CONV_JIT , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_JIT_INPUT_LIBRARY " , ( " hipJitInputTypeLibrary " , CONV_JIT , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_JIT_NUM_INPUT_TYPES " , ( " hipJitInputTypeNumInputTypes " , CONV_JIT , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_LIMIT_STACK_SIZE " , ( " hipLimitStackSize " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_LIMIT_PRINTF_FIFO_SIZE " , ( " hipLimitPrintfFifoSize " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_LIMIT_MALLOC_HEAP_SIZE " , ( " hipLimitMallocHeapSize " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " CU_LIMIT_DEV_RUNTIME_SYNC_DEPTH " , ( " hipLimitDevRuntimeSyncDepth " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_LIMIT_DEV_RUNTIME_PENDING_LAUNCH_COUNT " , ( " hipLimitDevRuntimePendingLaunchCount " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_LIMIT_STACK_SIZE " , ( " hipLimitStackSize " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_MEM_ATTACH_GLOBAL " , ( " hipMemAttachGlobal " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_MEM_ATTACH_HOST " , ( " hipMemAttachHost " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_MEM_ATTACH_SINGLE " , ( " hipMemAttachSingle " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_MEMORYTYPE_HOST " , ( " hipMemTypeHost " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_MEMORYTYPE_DEVICE " , ( " hipMemTypeDevice " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_MEMORYTYPE_ARRAY " , ( " hipMemTypeArray " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_MEMORYTYPE_UNIFIED " , ( " hipMemTypeUnified " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_RESOURCE_TYPE_ARRAY " , ( " hipResourceTypeArray " , CONV_TEX , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_RESOURCE_TYPE_MIPMAPPED_ARRAY " , ( " hipResourceTypeMipmappedArray " , CONV_TEX , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_RESOURCE_TYPE_LINEAR " , ( " hipResourceTypeLinear " , CONV_TEX , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_RESOURCE_TYPE_PITCH2D " , ( " hipResourceTypePitch2D " , CONV_TEX , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_RES_VIEW_FORMAT_NONE " , ( " hipResViewFormatNone " , CONV_TEX , API_DRIVER ) ) , <nl> - ( " CU_RES_VIEW_FORMAT_UINT_1X8 " , ( " hipResViewFormatUnsignedChar1 " , CONV_TEX , API_DRIVER ) ) , <nl> - ( " CU_RES_VIEW_FORMAT_UINT_2X8 " , ( " hipResViewFormatUnsignedChar2 " , CONV_TEX , API_DRIVER ) ) , <nl> - ( " CU_RES_VIEW_FORMAT_UINT_4X8 " , ( " hipResViewFormatUnsignedChar4 " , CONV_TEX , API_DRIVER ) ) , <nl> - ( " CU_RES_VIEW_FORMAT_SINT_1X8 " , ( " hipResViewFormatSignedChar1 " , CONV_TEX , API_DRIVER ) ) , <nl> - ( " CU_RES_VIEW_FORMAT_SINT_2X8 " , ( " hipResViewFormatSignedChar2 " , CONV_TEX , API_DRIVER ) ) , <nl> - ( " CU_RES_VIEW_FORMAT_SINT_4X8 " , ( " hipResViewFormatSignedChar4 " , CONV_TEX , API_DRIVER ) ) , <nl> - ( " CU_RES_VIEW_FORMAT_UINT_1X16 " , ( " hipResViewFormatUnsignedShort1 " , CONV_TEX , API_DRIVER ) ) , <nl> - ( " CU_RES_VIEW_FORMAT_UINT_2X16 " , ( " hipResViewFormatUnsignedShort2 " , CONV_TEX , API_DRIVER ) ) , <nl> - ( " CU_RES_VIEW_FORMAT_UINT_4X16 " , ( " hipResViewFormatUnsignedShort4 " , CONV_TEX , API_DRIVER ) ) , <nl> - ( " CU_RES_VIEW_FORMAT_SINT_1X16 " , ( " hipResViewFormatSignedShort1 " , CONV_TEX , API_DRIVER ) ) , <nl> - ( " CU_RES_VIEW_FORMAT_SINT_2X16 " , ( " hipResViewFormatSignedShort2 " , CONV_TEX , API_DRIVER ) ) , <nl> - ( " CU_RES_VIEW_FORMAT_SINT_4X16 " , ( " hipResViewFormatSignedShort4 " , CONV_TEX , API_DRIVER ) ) , <nl> - ( " CU_RES_VIEW_FORMAT_UINT_1X32 " , ( " hipResViewFormatUnsignedInt1 " , CONV_TEX , API_DRIVER ) ) , <nl> - ( " CU_RES_VIEW_FORMAT_UINT_2X32 " , ( " hipResViewFormatUnsignedInt2 " , CONV_TEX , API_DRIVER ) ) , <nl> - ( " CU_RES_VIEW_FORMAT_UINT_4X32 " , ( " hipResViewFormatUnsignedInt4 " , CONV_TEX , API_DRIVER ) ) , <nl> - ( " CU_RES_VIEW_FORMAT_SINT_1X32 " , ( " hipResViewFormatSignedInt1 " , CONV_TEX , API_DRIVER ) ) , <nl> - ( " CU_RES_VIEW_FORMAT_SINT_2X32 " , ( " hipResViewFormatSignedInt2 " , CONV_TEX , API_DRIVER ) ) , <nl> - ( " CU_RES_VIEW_FORMAT_SINT_4X32 " , ( " hipResViewFormatSignedInt4 " , CONV_TEX , API_DRIVER ) ) , <nl> - ( " CU_RES_VIEW_FORMAT_FLOAT_1X16 " , ( " hipResViewFormatHalf1 " , CONV_TEX , API_DRIVER ) ) , <nl> - ( " CU_RES_VIEW_FORMAT_FLOAT_2X16 " , ( " hipResViewFormatHalf2 " , CONV_TEX , API_DRIVER ) ) , <nl> - ( " CU_RES_VIEW_FORMAT_FLOAT_4X16 " , ( " hipResViewFormatHalf4 " , CONV_TEX , API_DRIVER ) ) , <nl> - ( " CU_RES_VIEW_FORMAT_FLOAT_1X32 " , ( " hipResViewFormatFloat1 " , CONV_TEX , API_DRIVER ) ) , <nl> - ( " CU_RES_VIEW_FORMAT_FLOAT_2X32 " , ( " hipResViewFormatFloat2 " , CONV_TEX , API_DRIVER ) ) , <nl> - ( " CU_RES_VIEW_FORMAT_FLOAT_4X32 " , ( " hipResViewFormatFloat4 " , CONV_TEX , API_DRIVER ) ) , <nl> - ( " CU_RES_VIEW_FORMAT_UNSIGNED_BC1 " , ( " hipResViewFormatUnsignedBlockCompressed1 " , CONV_TEX , API_DRIVER ) ) , <nl> - ( " CU_RES_VIEW_FORMAT_UNSIGNED_BC2 " , ( " hipResViewFormatUnsignedBlockCompressed2 " , CONV_TEX , API_DRIVER ) ) , <nl> - ( " CU_RES_VIEW_FORMAT_UNSIGNED_BC3 " , ( " hipResViewFormatUnsignedBlockCompressed3 " , CONV_TEX , API_DRIVER ) ) , <nl> - ( " CU_RES_VIEW_FORMAT_UNSIGNED_BC4 " , ( " hipResViewFormatUnsignedBlockCompressed4 " , CONV_TEX , API_DRIVER ) ) , <nl> - ( " CU_RES_VIEW_FORMAT_SIGNED_BC4 " , ( " hipResViewFormatSignedBlockCompressed4 " , CONV_TEX , API_DRIVER ) ) , <nl> - ( " CU_RES_VIEW_FORMAT_UNSIGNED_BC5 " , ( " hipResViewFormatUnsignedBlockCompressed5 " , CONV_TEX , API_DRIVER ) ) , <nl> - ( " CU_RES_VIEW_FORMAT_SIGNED_BC5 " , ( " hipResViewFormatSignedBlockCompressed5 " , CONV_TEX , API_DRIVER ) ) , <nl> - ( " CU_RES_VIEW_FORMAT_UNSIGNED_BC6H " , ( " hipResViewFormatUnsignedBlockCompressed6H " , CONV_TEX , API_DRIVER ) ) , <nl> - ( " CU_RES_VIEW_FORMAT_SIGNED_BC6H " , ( " hipResViewFormatSignedBlockCompressed6H " , CONV_TEX , API_DRIVER ) ) , <nl> - ( " CU_RES_VIEW_FORMAT_UNSIGNED_BC7 " , ( " hipResViewFormatUnsignedBlockCompressed7 " , CONV_TEX , API_DRIVER ) ) , <nl> - ( " CU_SHARED_MEM_CONFIG_DEFAULT_BANK_SIZE " , ( " hipSharedMemBankSizeDefault " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " CU_SHARED_MEM_CONFIG_FOUR_BYTE_BANK_SIZE " , ( " hipSharedMemBankSizeFourByte " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " CU_SHARED_MEM_CONFIG_EIGHT_BYTE_BANK_SIZE " , ( " hipSharedMemBankSizeEightByte " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " CU_STREAM_DEFAULT " , ( " hipStreamDefault " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " CU_STREAM_NON_BLOCKING " , ( " hipStreamNonBlocking " , CONV_TYPE , API_DRIVER ) ) , <nl> - ( " CU_STREAM_WAIT_VALUE_GEQ " , ( " hipStreamWaitValueGeq " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_STREAM_WAIT_VALUE_EQ " , ( " hipStreamWaitValueEq " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_STREAM_WAIT_VALUE_AND " , ( " hipStreamWaitValueAnd " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_STREAM_WAIT_VALUE_FLUSH " , ( " hipStreamWaitValueFlush " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_STREAM_WRITE_VALUE_DEFAULT " , ( " hipStreamWriteValueDefault " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_STREAM_WRITE_VALUE_NO_MEMORY_BARRIER " , ( " hipStreamWriteValueNoMemoryBarrier " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_STREAM_MEM_OP_WAIT_VALUE_32 " , ( " hipStreamBatchMemOpWaitValue32 " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_STREAM_MEM_OP_WRITE_VALUE_32 " , ( " hipStreamBatchMemOpWriteValue32 " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_STREAM_MEM_OP_FLUSH_REMOTE_WRITES " , ( " hipStreamBatchMemOpFlushRemoteWrites " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuGetErrorName " , ( " hipGetErrorName___ " , CONV_ERROR , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuGetErrorString " , ( " hipGetErrorString___ " , CONV_ERROR , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuInit " , ( " hipInit " , CONV_INIT , API_DRIVER ) ) , <nl> - ( " cuDriverGetVersion " , ( " hipDriverGetVersion " , CONV_VERSION , API_DRIVER ) ) , <nl> - ( " cuCtxCreate_v2 " , ( " hipCtxCreate " , CONV_CONTEXT , API_DRIVER ) ) , <nl> - ( " cuCtxDestroy_v2 " , ( " hipCtxDestroy " , CONV_CONTEXT , API_DRIVER ) ) , <nl> - ( " cuCtxGetApiVersion " , ( " hipCtxGetApiVersion " , CONV_CONTEXT , API_DRIVER ) ) , <nl> - ( " cuCtxGetCacheConfig " , ( " hipCtxGetCacheConfig " , CONV_CONTEXT , API_DRIVER ) ) , <nl> - ( " cuCtxGetCurrent " , ( " hipCtxGetCurrent " , CONV_CONTEXT , API_DRIVER ) ) , <nl> - ( " cuCtxGetDevice " , ( " hipCtxGetDevice " , CONV_CONTEXT , API_DRIVER ) ) , <nl> - ( " cuCtxGetFlags " , ( " hipCtxGetFlags " , CONV_CONTEXT , API_DRIVER ) ) , <nl> - ( " cuCtxGetLimit " , ( " hipCtxGetLimit " , CONV_CONTEXT , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuCtxGetSharedMemConfig " , ( " hipCtxGetSharedMemConfig " , CONV_CONTEXT , API_DRIVER ) ) , <nl> - ( " cuCtxGetStreamPriorityRange " , ( " hipCtxGetStreamPriorityRange " , CONV_CONTEXT , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuCtxPopCurrent_v2 " , ( " hipCtxPopCurrent " , CONV_CONTEXT , API_DRIVER ) ) , <nl> - ( " cuCtxPushCurrent_v2 " , ( " hipCtxPushCurrent " , CONV_CONTEXT , API_DRIVER ) ) , <nl> - ( " cuCtxSetCacheConfig " , ( " hipCtxSetCacheConfig " , CONV_CONTEXT , API_DRIVER ) ) , <nl> - ( " cuCtxSetCurrent " , ( " hipCtxSetCurrent " , CONV_CONTEXT , API_DRIVER ) ) , <nl> - ( " cuCtxSetLimit " , ( " hipCtxSetLimit " , CONV_CONTEXT , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuCtxSetSharedMemConfig " , ( " hipCtxSetSharedMemConfig " , CONV_CONTEXT , API_DRIVER ) ) , <nl> - ( " cuCtxSynchronize " , ( " hipCtxSynchronize " , CONV_CONTEXT , API_DRIVER ) ) , <nl> - ( " cuCtxAttach " , ( " hipCtxAttach " , CONV_CONTEXT , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuCtxDetach " , ( " hipCtxDetach " , CONV_CONTEXT , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuCtxEnablePeerAccess " , ( " hipCtxEnablePeerAccess " , CONV_PEER , API_DRIVER ) ) , <nl> - ( " cuCtxDisablePeerAccess " , ( " hipCtxDisablePeerAccess " , CONV_PEER , API_DRIVER ) ) , <nl> - ( " cuDeviceCanAccessPeer " , ( " hipDeviceCanAccessPeer " , CONV_PEER , API_DRIVER ) ) , <nl> - ( " cuDeviceGetP2PAttribute " , ( " hipDeviceGetP2PAttribute " , CONV_PEER , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuDevicePrimaryCtxGetState " , ( " hipDevicePrimaryCtxGetState " , CONV_CONTEXT , API_DRIVER ) ) , <nl> - ( " cuDevicePrimaryCtxRelease " , ( " hipDevicePrimaryCtxRelease " , CONV_CONTEXT , API_DRIVER ) ) , <nl> - ( " cuDevicePrimaryCtxReset " , ( " hipDevicePrimaryCtxReset " , CONV_CONTEXT , API_DRIVER ) ) , <nl> - ( " cuDevicePrimaryCtxRetain " , ( " hipDevicePrimaryCtxRetain " , CONV_CONTEXT , API_DRIVER ) ) , <nl> - ( " cuDevicePrimaryCtxSetFlags " , ( " hipDevicePrimaryCtxSetFlags " , CONV_CONTEXT , API_DRIVER ) ) , <nl> - ( " cuDeviceGet " , ( " hipGetDevice " , CONV_DEVICE , API_DRIVER ) ) , <nl> - ( " cuDeviceGetName " , ( " hipDeviceGetName " , CONV_DEVICE , API_DRIVER ) ) , <nl> - ( " cuDeviceGetCount " , ( " hipGetDeviceCount " , CONV_DEVICE , API_DRIVER ) ) , <nl> - ( " cuDeviceGetAttribute " , ( " hipDeviceGetAttribute " , CONV_DEVICE , API_DRIVER ) ) , <nl> - ( " cuDeviceGetPCIBusId " , ( " hipDeviceGetPCIBusId " , CONV_DEVICE , API_DRIVER ) ) , <nl> - ( " cuDeviceGetByPCIBusId " , ( " hipDeviceGetByPCIBusId " , CONV_DEVICE , API_DRIVER ) ) , <nl> - ( " cuDeviceTotalMem_v2 " , ( " hipDeviceTotalMem " , CONV_DEVICE , API_DRIVER ) ) , <nl> - ( " cuDeviceComputeCapability " , ( " hipDeviceComputeCapability " , CONV_DEVICE , API_DRIVER ) ) , <nl> - ( " cuDeviceGetProperties " , ( " hipGetDeviceProperties " , CONV_DEVICE , API_DRIVER ) ) , <nl> - ( " cuLinkAddData " , ( " hipLinkAddData " , CONV_MODULE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuLinkAddFile " , ( " hipLinkAddFile " , CONV_MODULE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuLinkComplete " , ( " hipLinkComplete " , CONV_MODULE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuLinkCreate " , ( " hipLinkCreate " , CONV_MODULE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuLinkDestroy " , ( " hipLinkDestroy " , CONV_MODULE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuModuleGetFunction " , ( " hipModuleGetFunction " , CONV_MODULE , API_DRIVER ) ) , <nl> - ( " cuModuleGetGlobal_v2 " , ( " hipModuleGetGlobal " , CONV_MODULE , API_DRIVER ) ) , <nl> - ( " cuModuleGetSurfRef " , ( " hipModuleGetSurfRef " , CONV_MODULE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuModuleGetTexRef " , ( " hipModuleGetTexRef " , CONV_MODULE , API_DRIVER ) ) , <nl> - ( " cuModuleLoad " , ( " hipModuleLoad " , CONV_MODULE , API_DRIVER ) ) , <nl> - ( " cuModuleLoadData " , ( " hipModuleLoadData " , CONV_MODULE , API_DRIVER ) ) , <nl> - ( " cuModuleLoadDataEx " , ( " hipModuleLoadDataEx " , CONV_MODULE , API_DRIVER ) ) , <nl> - ( " cuModuleLoadFatBinary " , ( " hipModuleLoadFatBinary " , CONV_MODULE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuModuleUnload " , ( " hipModuleUnload " , CONV_MODULE , API_DRIVER ) ) , <nl> - ( " CU_DEVICE_P2P_ATTRIBUTE_PERFORMANCE_RANK " , ( " hipDeviceP2PAttributePerformanceRank " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_P2P_ATTRIBUTE_ACCESS_SUPPORTED " , ( " hipDeviceP2PAttributeAccessSupported " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_DEVICE_P2P_ATTRIBUTE_NATIVE_ATOMIC_SUPPORTED " , ( " hipDeviceP2PAttributeNativeAtomicSupported " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_EVENT_DEFAULT " , ( " hipEventDefault " , CONV_EVENT , API_DRIVER ) ) , <nl> - ( " CU_EVENT_BLOCKING_SYNC " , ( " hipEventBlockingSync " , CONV_EVENT , API_DRIVER ) ) , <nl> - ( " CU_EVENT_DISABLE_TIMING " , ( " hipEventDisableTiming " , CONV_EVENT , API_DRIVER ) ) , <nl> - ( " CU_EVENT_INTERPROCESS " , ( " hipEventInterprocess " , CONV_EVENT , API_DRIVER ) ) , <nl> - ( " cuEventCreate " , ( " hipEventCreate " , CONV_EVENT , API_DRIVER ) ) , <nl> - ( " cuEventDestroy_v2 " , ( " hipEventDestroy " , CONV_EVENT , API_DRIVER ) ) , <nl> - ( " cuEventElapsedTime " , ( " hipEventElapsedTime " , CONV_EVENT , API_DRIVER ) ) , <nl> - ( " cuEventQuery " , ( " hipEventQuery " , CONV_EVENT , API_DRIVER ) ) , <nl> - ( " cuEventRecord " , ( " hipEventRecord " , CONV_EVENT , API_DRIVER ) ) , <nl> - ( " cuEventSynchronize " , ( " hipEventSynchronize " , CONV_EVENT , API_DRIVER ) ) , <nl> - ( " cuFuncGetAttribute " , ( " hipFuncGetAttribute " , CONV_MODULE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuFuncSetCacheConfig " , ( " hipFuncSetCacheConfig " , CONV_MODULE , API_DRIVER ) ) , <nl> - ( " cuFuncSetSharedMemConfig " , ( " hipFuncSetSharedMemConfig " , CONV_MODULE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuLaunchKernel " , ( " hipModuleLaunchKernel " , CONV_MODULE , API_DRIVER ) ) , <nl> - ( " cuFuncSetBlockShape " , ( " hipFuncSetBlockShape " , CONV_MODULE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuFuncSetSharedSize " , ( " hipFuncSetSharedSize " , CONV_MODULE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuLaunch " , ( " hipLaunch " , CONV_MODULE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuLaunchGrid " , ( " hipLaunchGrid " , CONV_MODULE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuLaunchGridAsync " , ( " hipLaunchGridAsync " , CONV_MODULE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuParamSetf " , ( " hipParamSetf " , CONV_MODULE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuParamSeti " , ( " hipParamSeti " , CONV_MODULE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuParamSetSize " , ( " hipParamSetSize " , CONV_MODULE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuParamSetSize " , ( " hipParamSetSize " , CONV_MODULE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuParamSetv " , ( " hipParamSetv " , CONV_MODULE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuOccupancyMaxActiveBlocksPerMultiprocessor " , ( " hipOccupancyMaxActiveBlocksPerMultiprocessor " , CONV_OCCUPANCY , API_DRIVER ) ) , <nl> - ( " cuOccupancyMaxActiveBlocksPerMultiprocessorWithFlags " , ( " hipOccupancyMaxActiveBlocksPerMultiprocessorWithFlags " , CONV_OCCUPANCY , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuOccupancyMaxPotentialBlockSize " , ( " hipOccupancyMaxPotentialBlockSize " , CONV_OCCUPANCY , API_DRIVER ) ) , <nl> - ( " cuOccupancyMaxPotentialBlockSizeWithFlags " , ( " hipOccupancyMaxPotentialBlockSizeWithFlags " , CONV_OCCUPANCY , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuStreamAddCallback " , ( " hipStreamAddCallback " , CONV_STREAM , API_DRIVER ) ) , <nl> - ( " cuStreamAttachMemAsync " , ( " hipStreamAttachMemAsync " , CONV_STREAM , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuStreamCreate " , ( " hipStreamCreate__ " , CONV_STREAM , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuStreamCreateWithPriority " , ( " hipStreamCreateWithPriority " , CONV_STREAM , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuStreamDestroy_v2 " , ( " hipStreamDestroy " , CONV_STREAM , API_DRIVER ) ) , <nl> - ( " cuStreamGetFlags " , ( " hipStreamGetFlags " , CONV_STREAM , API_DRIVER ) ) , <nl> - ( " cuStreamGetPriority " , ( " hipStreamGetPriority " , CONV_STREAM , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuStreamQuery " , ( " hipStreamQuery " , CONV_STREAM , API_DRIVER ) ) , <nl> - ( " cuStreamSynchronize " , ( " hipStreamSynchronize " , CONV_STREAM , API_DRIVER ) ) , <nl> - ( " cuStreamWaitEvent " , ( " hipStreamWaitEvent " , CONV_STREAM , API_DRIVER ) ) , <nl> - ( " cuStreamWaitValue32 " , ( " hipStreamWaitValue32 " , CONV_STREAM , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuStreamWriteValue32 " , ( " hipStreamWriteValue32 " , CONV_STREAM , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuStreamBatchMemOp " , ( " hipStreamBatchMemOp " , CONV_STREAM , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuArray3DCreate " , ( " hipArray3DCreate " , CONV_MEM , API_DRIVER ) ) , <nl> - ( " cuArray3DGetDescriptor " , ( " hipArray3DGetDescriptor " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuArrayCreate " , ( " hipArrayCreate " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuArrayDestroy " , ( " hipArrayDestroy " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuArrayGetDescriptor " , ( " hipArrayGetDescriptor " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuIpcCloseMemHandle " , ( " hipIpcCloseMemHandle " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuIpcGetEventHandle " , ( " hipIpcGetEventHandle " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuIpcGetMemHandle " , ( " hipIpcGetMemHandle " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuIpcOpenEventHandle " , ( " hipIpcOpenEventHandle " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuIpcOpenMemHandle " , ( " hipIpcOpenMemHandle " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuMemAlloc_v2 " , ( " hipMalloc " , CONV_MEM , API_DRIVER ) ) , <nl> - ( " cuMemAllocHost " , ( " hipMemAllocHost " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuMemAllocManaged " , ( " hipMemAllocManaged " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuMemAllocPitch " , ( " hipMemAllocPitch__ " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuMemcpy " , ( " hipMemcpy__ " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuMemcpy2D " , ( " hipMemcpy2D__ " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuMemcpy2DAsync " , ( " hipMemcpy2DAsync__ " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuMemcpy2DUnaligned " , ( " hipMemcpy2DUnaligned " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuMemcpy3D " , ( " hipMemcpy3D__ " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuMemcpy3DAsync " , ( " hipMemcpy3DAsync__ " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuMemcpy3DPeer " , ( " hipMemcpy3DPeer__ " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuMemcpy3DPeerAsync " , ( " hipMemcpy3DPeerAsync__ " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuMemcpyAsync " , ( " hipMemcpyAsync__ " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuMemcpyAtoA " , ( " hipMemcpyAtoA " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuMemcpyAtoD " , ( " hipMemcpyAtoD " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuMemcpyAtoH " , ( " hipMemcpyAtoH " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuMemcpyAtoHAsync " , ( " hipMemcpyAtoHAsync " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuMemcpyDtoA " , ( " hipMemcpyDtoA " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuMemcpyDtoD_v2 " , ( " hipMemcpyDtoD " , CONV_MEM , API_DRIVER ) ) , <nl> - ( " cuMemcpyDtoDAsync_v2 " , ( " hipMemcpyDtoDAsync " , CONV_MEM , API_DRIVER ) ) , <nl> - ( " cuMemcpyDtoH_v2 " , ( " hipMemcpyDtoH " , CONV_MEM , API_DRIVER ) ) , <nl> - ( " cuMemcpyDtoHAsync_v2 " , ( " hipMemcpyDtoHAsync " , CONV_MEM , API_DRIVER ) ) , <nl> - ( " cuMemcpyHtoA " , ( " hipMemcpyHtoA " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuMemcpyHtoAAsync " , ( " hipMemcpyHtoAAsync " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuMemcpyHtoD_v2 " , ( " hipMemcpyHtoD " , CONV_MEM , API_DRIVER ) ) , <nl> - ( " cuMemcpyHtoDAsync_v2 " , ( " hipMemcpyHtoDAsync " , CONV_MEM , API_DRIVER ) ) , <nl> - ( " cuMemcpyPeerAsync " , ( " hipMemcpyPeerAsync__ " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuMemcpyPeer " , ( " hipMemcpyPeer__ " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuMemFree_v2 " , ( " hipFree " , CONV_MEM , API_DRIVER ) ) , <nl> - ( " cuMemFreeHost " , ( " hipHostFree " , CONV_MEM , API_DRIVER ) ) , <nl> - ( " cuMemGetAddressRange " , ( " hipMemGetAddressRange " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuMemGetInfo_v2 " , ( " hipMemGetInfo " , CONV_MEM , API_DRIVER ) ) , <nl> - ( " cuMemHostAlloc " , ( " hipHostMalloc " , CONV_MEM , API_DRIVER ) ) , <nl> - ( " cuMemHostGetDevicePointer " , ( " hipMemHostGetDevicePointer " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuMemHostGetFlags " , ( " hipMemHostGetFlags " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuMemHostRegister_v2 " , ( " hipHostRegister " , CONV_MEM , API_DRIVER ) ) , <nl> - ( " cuMemHostUnregister " , ( " hipHostUnregister " , CONV_MEM , API_DRIVER ) ) , <nl> - ( " cuMemsetD16_v2 " , ( " hipMemsetD16 " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuMemsetD16Async " , ( " hipMemsetD16Async " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuMemsetD2D16_v2 " , ( " hipMemsetD2D16 " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuMemsetD2D16Async " , ( " hipMemsetD2D16Async " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuMemsetD2D32_v2 " , ( " hipMemsetD2D32 " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuMemsetD2D32Async " , ( " hipMemsetD2D32Async " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuMemsetD2D8_v2 " , ( " hipMemsetD2D8 " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuMemsetD2D8Async " , ( " hipMemsetD2D8Async " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuMemsetD32_v2 " , ( " hipMemset " , CONV_MEM , API_DRIVER ) ) , <nl> - ( " cuMemsetD32Async " , ( " hipMemsetAsync " , CONV_MEM , API_DRIVER ) ) , <nl> - ( " cuMemsetD8_v2 " , ( " hipMemsetD8 " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuMemsetD8Async " , ( " hipMemsetD8Async " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuMipmappedArrayCreate " , ( " hipMipmappedArrayCreate " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuMipmappedArrayDestroy " , ( " hipMipmappedArrayDestroy " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuMipmappedArrayGetLevel " , ( " hipMipmappedArrayGetLevel " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuMemPrefetchAsync " , ( " hipMemPrefetchAsync__ " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuMemAdvise " , ( " hipMemAdvise " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuMemRangeGetAttribute " , ( " hipMemRangeGetAttribute " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuMemRangeGetAttributes " , ( " hipMemRangeGetAttributes " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuPointerGetAttribute " , ( " hipPointerGetAttribute " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuPointerGetAttributes " , ( " hipPointerGetAttributes " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuPointerSetAttribute " , ( " hipPointerSetAttribute " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_TR_FILTER_MODE_POINT " , ( " hipFilterModePoint " , CONV_TEX , API_DRIVER ) ) , <nl> - ( " CU_TR_FILTER_MODE_LINEAR " , ( " hipFilterModeLinear " , CONV_TEX , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuTexRefGetAddress " , ( " hipTexRefGetAddress " , CONV_TEX , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuTexRefGetAddressMode " , ( " hipTexRefGetAddressMode " , CONV_TEX , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuTexRefGetArray " , ( " hipTexRefGetArray " , CONV_TEX , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuTexRefGetBorderColor " , ( " hipTexRefGetBorderColor " , CONV_TEX , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuTexRefGetFilterMode " , ( " hipTexRefGetFilterMode " , CONV_TEX , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuTexRefGetFlags " , ( " hipTexRefGetFlags " , CONV_TEX , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuTexRefGetFormat " , ( " hipTexRefGetFormat " , CONV_TEX , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuTexRefGetMaxAnisotropy " , ( " hipTexRefGetMaxAnisotropy " , CONV_TEX , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuTexRefGetMipmapFilterMode " , ( " hipTexRefGetMipmapFilterMode " , CONV_TEX , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuTexRefGetMipmapLevelBias " , ( " hipTexRefGetMipmapLevelBias " , CONV_TEX , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuTexRefGetMipmapLevelClamp " , ( " hipTexRefGetMipmapLevelClamp " , CONV_TEX , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuTexRefGetMipmappedArray " , ( " hipTexRefGetMipmappedArray " , CONV_TEX , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuTexRefSetAddress " , ( " hipTexRefSetAddress " , CONV_TEX , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuTexRefSetAddress2D " , ( " hipTexRefSetAddress2D " , CONV_TEX , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuTexRefSetAddressMode " , ( " hipTexRefSetAddressMode " , CONV_TEX , API_DRIVER ) ) , <nl> - ( " cuTexRefSetArray " , ( " hipTexRefSetArray " , CONV_TEX , API_DRIVER ) ) , <nl> - ( " cuTexRefSetBorderColor " , ( " hipTexRefSetBorderColor " , CONV_TEX , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuTexRefSetFilterMode " , ( " hipTexRefSetFilterMode " , CONV_TEX , API_DRIVER ) ) , <nl> - ( " cuTexRefSetFlags " , ( " hipTexRefSetFlags " , CONV_TEX , API_DRIVER ) ) , <nl> - ( " cuTexRefSetFormat " , ( " hipTexRefSetFormat " , CONV_TEX , API_DRIVER ) ) , <nl> - ( " cuTexRefSetMaxAnisotropy " , ( " hipTexRefSetMaxAnisotropy " , CONV_TEX , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuTexRefSetMipmapFilterMode " , ( " hipTexRefSetMipmapFilterMode " , CONV_TEX , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuTexRefSetMipmapLevelBias " , ( " hipTexRefSetMipmapLevelBias " , CONV_TEX , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuTexRefSetMipmapLevelClamp " , ( " hipTexRefSetMipmapLevelClamp " , CONV_TEX , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuTexRefSetMipmappedArray " , ( " hipTexRefSetMipmappedArray " , CONV_TEX , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuTexRefCreate " , ( " hipTexRefCreate " , CONV_TEX , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuTexRefDestroy " , ( " hipTexRefDestroy " , CONV_TEX , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuSurfRefGetArray " , ( " hipSurfRefGetArray " , CONV_SURFACE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuSurfRefSetArray " , ( " hipSurfRefSetArray " , CONV_SURFACE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuTexObjectCreate " , ( " hipTexObjectCreate " , CONV_TEX , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuTexObjectDestroy " , ( " hipTexObjectDestroy " , CONV_TEX , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuTexObjectGetResourceDesc " , ( " hipTexObjectGetResourceDesc " , CONV_TEX , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuTexObjectGetResourceViewDesc " , ( " hipTexObjectGetResourceViewDesc " , CONV_TEX , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuTexObjectGetTextureDesc " , ( " hipTexObjectGetTextureDesc " , CONV_TEX , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuSurfObjectCreate " , ( " hipSurfObjectCreate " , CONV_TEX , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuSurfObjectDestroy " , ( " hipSurfObjectDestroy " , CONV_TEX , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuSurfObjectGetResourceDesc " , ( " hipSurfObjectGetResourceDesc " , CONV_TEX , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuGraphicsMapResources " , ( " hipGraphicsMapResources " , CONV_GRAPHICS , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuGraphicsResourceGetMappedMipmappedArray " , ( " hipGraphicsResourceGetMappedMipmappedArray " , CONV_GRAPHICS , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuGraphicsResourceGetMappedPointer " , ( " hipGraphicsResourceGetMappedPointer " , CONV_GRAPHICS , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuGraphicsResourceSetMapFlags " , ( " hipGraphicsResourceSetMapFlags " , CONV_GRAPHICS , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuGraphicsSubResourceGetMappedArray " , ( " hipGraphicsSubResourceGetMappedArray " , CONV_GRAPHICS , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuGraphicsUnmapResources " , ( " hipGraphicsUnmapResources " , CONV_GRAPHICS , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuGraphicsUnregisterResource " , ( " hipGraphicsUnregisterResource " , CONV_GRAPHICS , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuProfilerInitialize " , ( " hipProfilerInitialize " , CONV_OTHER , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuProfilerStart " , ( " hipProfilerStart " , CONV_OTHER , API_DRIVER ) ) , <nl> - ( " cuProfilerStop " , ( " hipProfilerStop " , CONV_OTHER , API_DRIVER ) ) , <nl> - ( " CU_GL_DEVICE_LIST_ALL " , ( " HIP_GL_DEVICE_LIST_ALL " , CONV_GL , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_GL_DEVICE_LIST_CURRENT_FRAME " , ( " HIP_GL_DEVICE_LIST_CURRENT_FRAME " , CONV_GL , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_GL_DEVICE_LIST_NEXT_FRAME " , ( " HIP_GL_DEVICE_LIST_NEXT_FRAME " , CONV_GL , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuGLGetDevices " , ( " hipGLGetDevices " , CONV_GL , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuGraphicsGLRegisterBuffer " , ( " hipGraphicsGLRegisterBuffer " , CONV_GL , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuGraphicsGLRegisterImage " , ( " hipGraphicsGLRegisterImage " , CONV_GL , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuWGLGetDevice " , ( " hipWGLGetDevice " , CONV_GL , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_GL_MAP_RESOURCE_FLAGS_NONE " , ( " HIP_GL_MAP_RESOURCE_FLAGS_NONE " , CONV_GL , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_GL_MAP_RESOURCE_FLAGS_READ_ONLY " , ( " HIP_GL_MAP_RESOURCE_FLAGS_READ_ONLY " , CONV_GL , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_GL_MAP_RESOURCE_FLAGS_WRITE_DISCARD " , ( " HIP_GL_MAP_RESOURCE_FLAGS_WRITE_DISCARD " , CONV_GL , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuGLCtxCreate " , ( " hipGLCtxCreate " , CONV_GL , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuGLInit " , ( " hipGLInit " , CONV_GL , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuGLMapBufferObject " , ( " hipGLMapBufferObject " , CONV_GL , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuGLMapBufferObjectAsync " , ( " hipGLMapBufferObjectAsync " , CONV_GL , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuGLRegisterBufferObject " , ( " hipGLRegisterBufferObject " , CONV_GL , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuGLSetBufferObjectMapFlags " , ( " hipGLSetBufferObjectMapFlags " , CONV_GL , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuGLUnmapBufferObject " , ( " hipGLUnmapBufferObject " , CONV_GL , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuGLUnmapBufferObjectAsync " , ( " hipGLUnmapBufferObjectAsync " , CONV_GL , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuGLUnregisterBufferObject " , ( " hipGLUnregisterBufferObject " , CONV_GL , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_D3D9_DEVICE_LIST_ALL " , ( " HIP_D3D9_DEVICE_LIST_ALL " , CONV_D3D9 , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_D3D9_DEVICE_LIST_CURRENT_FRAME " , ( " HIP_D3D9_DEVICE_LIST_CURRENT_FRAME " , CONV_D3D9 , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_D3D9_DEVICE_LIST_NEXT_FRAME " , ( " HIP_D3D9_DEVICE_LIST_NEXT_FRAME " , CONV_D3D9 , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuD3D9CtxCreate " , ( " hipD3D9CtxCreate " , CONV_D3D9 , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuD3D9CtxCreateOnDevice " , ( " hipD3D9CtxCreateOnDevice " , CONV_D3D9 , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuD3D9GetDevice " , ( " hipD3D9GetDevice " , CONV_D3D9 , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuD3D9GetDevices " , ( " hipD3D9GetDevices " , CONV_D3D9 , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuD3D9GetDirect3DDevice " , ( " hipD3D9GetDirect3DDevice " , CONV_D3D9 , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuGraphicsD3D9RegisterResource " , ( " hipGraphicsD3D9RegisterResource " , CONV_D3D9 , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_D3D9_MAPRESOURCE_FLAGS_NONE " , ( " HIP_D3D9_MAPRESOURCE_FLAGS_NONE " , CONV_D3D9 , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_D3D9_MAPRESOURCE_FLAGS_READONLY " , ( " HIP_D3D9_MAPRESOURCE_FLAGS_READONLY " , CONV_D3D9 , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_D3D9_MAPRESOURCE_FLAGS_WRITEDISCARD " , ( " HIP_D3D9_MAPRESOURCE_FLAGS_WRITEDISCARD " , CONV_D3D9 , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_D3D9_REGISTER_FLAGS_NONE " , ( " HIP_D3D9_REGISTER_FLAGS_NONE " , CONV_D3D9 , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_D3D9_REGISTER_FLAGS_ARRAY " , ( " HIP_D3D9_REGISTER_FLAGS_ARRAY " , CONV_D3D9 , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuD3D9MapResources " , ( " hipD3D9MapResources " , CONV_D3D9 , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuD3D9RegisterResource " , ( " hipD3D9RegisterResource " , CONV_D3D9 , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuD3D9ResourceGetMappedArray " , ( " hipD3D9ResourceGetMappedArray " , CONV_D3D9 , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuD3D9ResourceGetMappedPitch " , ( " hipD3D9ResourceGetMappedPitch " , CONV_D3D9 , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuD3D9ResourceGetMappedPointer " , ( " hipD3D9ResourceGetMappedPointer " , CONV_D3D9 , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuD3D9ResourceGetMappedSize " , ( " hipD3D9ResourceGetMappedSize " , CONV_D3D9 , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuD3D9ResourceGetSurfaceDimensions " , ( " hipD3D9ResourceGetSurfaceDimensions " , CONV_D3D9 , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuD3D9ResourceSetMapFlags " , ( " hipD3D9ResourceSetMapFlags " , CONV_D3D9 , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuD3D9UnmapResources " , ( " hipD3D9UnmapResources " , CONV_D3D9 , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuD3D9UnregisterResource " , ( " hipD3D9UnregisterResource " , CONV_D3D9 , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_D3D10_DEVICE_LIST_ALL " , ( " HIP_D3D10_DEVICE_LIST_ALL " , CONV_D3D10 , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_D3D10_DEVICE_LIST_CURRENT_FRAME " , ( " HIP_D3D10_DEVICE_LIST_CURRENT_FRAME " , CONV_D3D10 , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_D3D10_DEVICE_LIST_NEXT_FRAME " , ( " HIP_D3D10_DEVICE_LIST_NEXT_FRAME " , CONV_D3D10 , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuD3D10GetDevice " , ( " hipD3D10GetDevice " , CONV_D3D10 , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuD3D10GetDevices " , ( " hipD3D10GetDevices " , CONV_D3D10 , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuGraphicsD3D10RegisterResource " , ( " hipGraphicsD3D10RegisterResource " , CONV_D3D10 , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_D3D10_MAPRESOURCE_FLAGS_NONE " , ( " HIP_D3D10_MAPRESOURCE_FLAGS_NONE " , CONV_D3D10 , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_D3D10_MAPRESOURCE_FLAGS_READONLY " , ( " HIP_D3D10_MAPRESOURCE_FLAGS_READONLY " , CONV_D3D10 , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_D3D10_MAPRESOURCE_FLAGS_WRITEDISCARD " , ( " HIP_D3D10_MAPRESOURCE_FLAGS_WRITEDISCARD " , CONV_D3D10 , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_D3D10_REGISTER_FLAGS_NONE " , ( " HIP_D3D10_REGISTER_FLAGS_NONE " , CONV_D3D10 , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_D3D10_REGISTER_FLAGS_ARRAY " , ( " HIP_D3D10_REGISTER_FLAGS_ARRAY " , CONV_D3D10 , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuD3D10CtxCreate " , ( " hipD3D10CtxCreate " , CONV_D3D10 , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuD3D10CtxCreateOnDevice " , ( " hipD3D10CtxCreateOnDevice " , CONV_D3D10 , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuD3D10GetDirect3DDevice " , ( " hipD3D10GetDirect3DDevice " , CONV_D3D10 , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuD3D10MapResources " , ( " hipD3D10MapResources " , CONV_D3D10 , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuD3D10RegisterResource " , ( " hipD3D10RegisterResource " , CONV_D3D10 , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuD3D10ResourceGetMappedArray " , ( " hipD3D10ResourceGetMappedArray " , CONV_D3D10 , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuD3D10ResourceGetMappedPitch " , ( " hipD3D10ResourceGetMappedPitch " , CONV_D3D10 , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuD3D10ResourceGetMappedPointer " , ( " hipD3D10ResourceGetMappedPointer " , CONV_D3D10 , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuD3D10ResourceGetMappedSize " , ( " hipD3D10ResourceGetMappedSize " , CONV_D3D10 , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuD3D10ResourceGetSurfaceDimensions " , ( " hipD3D10ResourceGetSurfaceDimensions " , CONV_D3D10 , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuD310ResourceSetMapFlags " , ( " hipD3D10ResourceSetMapFlags " , CONV_D3D10 , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuD3D10UnmapResources " , ( " hipD3D10UnmapResources " , CONV_D3D10 , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuD3D10UnregisterResource " , ( " hipD3D10UnregisterResource " , CONV_D3D10 , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_D3D11_DEVICE_LIST_ALL " , ( " HIP_D3D11_DEVICE_LIST_ALL " , CONV_D3D11 , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_D3D11_DEVICE_LIST_CURRENT_FRAME " , ( " HIP_D3D11_DEVICE_LIST_CURRENT_FRAME " , CONV_D3D11 , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " CU_D3D11_DEVICE_LIST_NEXT_FRAME " , ( " HIP_D3D11_DEVICE_LIST_NEXT_FRAME " , CONV_D3D11 , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuD3D11GetDevice " , ( " hipD3D11GetDevice " , CONV_D3D11 , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuD3D11GetDevices " , ( " hipD3D11GetDevices " , CONV_D3D11 , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuGraphicsD3D11RegisterResource " , ( " hipGraphicsD3D11RegisterResource " , CONV_D3D11 , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuD3D11CtxCreate " , ( " hipD3D11CtxCreate " , CONV_D3D11 , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuD3D11CtxCreateOnDevice " , ( " hipD3D11CtxCreateOnDevice " , CONV_D3D11 , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuD3D11GetDirect3DDevice " , ( " hipD3D11GetDirect3DDevice " , CONV_D3D11 , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuGraphicsVDPAURegisterOutputSurface " , ( " hipGraphicsVDPAURegisterOutputSurface " , CONV_VDPAU , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuGraphicsVDPAURegisterVideoSurface " , ( " hipGraphicsVDPAURegisterVideoSurface " , CONV_VDPAU , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuVDPAUGetDevice " , ( " hipVDPAUGetDevice " , CONV_VDPAU , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuVDPAUCtxCreate " , ( " hipVDPAUCtxCreate " , CONV_VDPAU , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuEGLStreamConsumerAcquireFrame " , ( " hipEGLStreamConsumerAcquireFrame " , CONV_EGL , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuEGLStreamConsumerConnect " , ( " hipEGLStreamConsumerConnect " , CONV_EGL , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuEGLStreamConsumerConnectWithFlags " , ( " hipEGLStreamConsumerConnectWithFlags " , CONV_EGL , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuEGLStreamConsumerDisconnect " , ( " hipEGLStreamConsumerDisconnect " , CONV_EGL , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuEGLStreamConsumerReleaseFrame " , ( " hipEGLStreamConsumerReleaseFrame " , CONV_EGL , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuEGLStreamProducerConnect " , ( " hipEGLStreamProducerConnect " , CONV_EGL , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuEGLStreamProducerDisconnect " , ( " hipEGLStreamProducerDisconnect " , CONV_EGL , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuEGLStreamProducerPresentFrame " , ( " hipEGLStreamProducerPresentFrame " , CONV_EGL , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuEGLStreamProducerReturnFrame " , ( " hipEGLStreamProducerReturnFrame " , CONV_EGL , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuGraphicsEGLRegisterImage " , ( " hipGraphicsEGLRegisterImage " , CONV_EGL , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cuGraphicsResourceGetMappedEglFrame " , ( " hipGraphicsResourceGetMappedEglFrame " , CONV_EGL , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaDataType_t " , ( " hipDataType_t " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaDataType " , ( " hipDataType_t " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " CUDA_R_16F " , ( " hipR16F " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " CUDA_C_16F " , ( " hipC16F " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " CUDA_R_32F " , ( " hipR32F " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " CUDA_C_32F " , ( " hipC32F " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " CUDA_R_64F " , ( " hipR64F " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " CUDA_C_64F " , ( " hipC64F " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " CUDA_R_8I " , ( " hipR8I " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " CUDA_C_8I " , ( " hipC8I " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " CUDA_R_8U " , ( " hipR8U " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " CUDA_C_8U " , ( " hipC8U " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " CUDA_R_32I " , ( " hipR32I " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " CUDA_C_32I " , ( " hipC32I " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " CUDA_R_32U " , ( " hipR32U " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " CUDA_C_32U " , ( " hipC32U " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " MAJOR_VERSION " , ( " hipLibraryMajorVersion " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " MINOR_VERSION " , ( " hipLibraryMinorVersion " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " PATCH_LEVEL " , ( " hipLibraryPatchVersion " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaMemAttachGlobal " , ( " hipMemAttachGlobal " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaMemAttachHost " , ( " hipMemAttachHost " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaMemAttachSingle " , ( " hipMemAttachSingle " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaOccupancyDefault " , ( " hipOccupancyDefault " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaOccupancyDisableCachingOverride " , ( " hipOccupancyDisableCachingOverride " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaGetLastError " , ( " hipGetLastError " , CONV_ERROR , API_RUNTIME ) ) , <nl> - ( " cudaPeekAtLastError " , ( " hipPeekAtLastError " , CONV_ERROR , API_RUNTIME ) ) , <nl> - ( " cudaGetErrorName " , ( " hipGetErrorName " , CONV_ERROR , API_RUNTIME ) ) , <nl> - ( " cudaGetErrorString " , ( " hipGetErrorString " , CONV_ERROR , API_RUNTIME ) ) , <nl> - ( " cudaMemcpy3DParms " , ( " hipMemcpy3DParms " , CONV_MEM , API_RUNTIME ) ) , <nl> - ( " cudaMemcpy3DPeerParms " , ( " hipMemcpy3DPeerParms " , CONV_MEM , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaMemcpy " , ( " hipMemcpy " , CONV_MEM , API_RUNTIME ) ) , <nl> - ( " cudaMemcpyToArray " , ( " hipMemcpyToArray " , CONV_MEM , API_RUNTIME ) ) , <nl> - ( " cudaMemcpyToSymbol " , ( " hipMemcpyToSymbol " , CONV_MEM , API_RUNTIME ) ) , <nl> - ( " cudaMemcpyToSymbolAsync " , ( " hipMemcpyToSymbolAsync " , CONV_MEM , API_RUNTIME ) ) , <nl> - ( " cudaMemcpyAsync " , ( " hipMemcpyAsync " , CONV_MEM , API_RUNTIME ) ) , <nl> - ( " cudaMemcpy2D " , ( " hipMemcpy2D " , CONV_MEM , API_RUNTIME ) ) , <nl> - ( " cudaMemcpy2DAsync " , ( " hipMemcpy2DAsync " , CONV_MEM , API_RUNTIME ) ) , <nl> - ( " cudaMemcpy2DToArray " , ( " hipMemcpy2DToArray " , CONV_MEM , API_RUNTIME ) ) , <nl> - ( " cudaMemcpy2DArrayToArray " , ( " hipMemcpy2DArrayToArray " , CONV_MEM , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaMemcpy2DFromArray " , ( " hipMemcpy2DFromArray " , CONV_MEM , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaMemcpy2DFromArrayAsync " , ( " hipMemcpy2DFromArrayAsync " , CONV_MEM , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaMemcpy2DToArrayAsync " , ( " hipMemcpy2DToArrayAsync " , CONV_MEM , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaMemcpy3D " , ( " hipMemcpy3D " , CONV_MEM , API_RUNTIME ) ) , <nl> - ( " cudaMemcpy3DAsync " , ( " hipMemcpy3DAsync " , CONV_MEM , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaMemcpy3DPeer " , ( " hipMemcpy3DPeer " , CONV_MEM , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaMemcpy3DPeerAsync " , ( " hipMemcpy3DPeerAsync " , CONV_MEM , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaMemcpyArrayToArray " , ( " hipMemcpyArrayToArray " , CONV_MEM , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaMemcpyFromArrayAsync " , ( " hipMemcpyFromArrayAsync " , CONV_MEM , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaMemcpyFromSymbol " , ( " hipMemcpyFromSymbol " , CONV_MEM , API_RUNTIME ) ) , <nl> - ( " cudaMemcpyFromSymbolAsync " , ( " hipMemcpyFromSymbolAsync " , CONV_MEM , API_RUNTIME ) ) , <nl> - ( " cudaMemAdvise " , ( " hipMemAdvise " , CONV_MEM , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaMemRangeGetAttribute " , ( " hipMemRangeGetAttribute " , CONV_MEM , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaMemRangeGetAttributes " , ( " hipMemRangeGetAttributes " , CONV_MEM , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaMemAdviseSetReadMostly " , ( " hipMemAdviseSetReadMostly " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaMemAdviseUnsetReadMostly " , ( " hipMemAdviseUnsetReadMostly " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaMemAdviseSetPreferredLocation " , ( " hipMemAdviseSetPreferredLocation " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaMemAdviseUnsetPreferredLocation " , ( " hipMemAdviseUnsetPreferredLocation " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaMemAdviseSetAccessedBy " , ( " hipMemAdviseSetAccessedBy " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaMemAdviseUnsetAccessedBy " , ( " hipMemAdviseUnsetAccessedBy " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaMemRangeAttributeReadMostly " , ( " hipMemRangeAttributeReadMostly " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaMemRangeAttributePreferredLocation " , ( " hipMemRangeAttributePreferredLocation " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaMemRangeAttributeAccessedBy " , ( " hipMemRangeAttributeAccessedBy " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaMemRangeAttributeLastPrefetchLocation " , ( " hipMemRangeAttributeLastPrefetchLocation " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaMemcpyHostToHost " , ( " hipMemcpyHostToHost " , CONV_MEM , API_RUNTIME ) ) , <nl> - ( " cudaMemcpyHostToDevice " , ( " hipMemcpyHostToDevice " , CONV_MEM , API_RUNTIME ) ) , <nl> - ( " cudaMemcpyDeviceToHost " , ( " hipMemcpyDeviceToHost " , CONV_MEM , API_RUNTIME ) ) , <nl> - ( " cudaMemcpyDeviceToDevice " , ( " hipMemcpyDeviceToDevice " , CONV_MEM , API_RUNTIME ) ) , <nl> - ( " cudaMemcpyDefault " , ( " hipMemcpyDefault " , CONV_MEM , API_RUNTIME ) ) , <nl> - ( " cudaMemset " , ( " hipMemset " , CONV_MEM , API_RUNTIME ) ) , <nl> - ( " cudaMemsetAsync " , ( " hipMemsetAsync " , CONV_MEM , API_RUNTIME ) ) , <nl> - ( " cudaMemset2D " , ( " hipMemset2D " , CONV_MEM , API_RUNTIME ) ) , <nl> - ( " cudaMemset2DAsync " , ( " hipMemset2DAsync " , CONV_MEM , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaMemset3D " , ( " hipMemset3D " , CONV_MEM , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaMemset3DAsync " , ( " hipMemset3DAsync " , CONV_MEM , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaMemGetInfo " , ( " hipMemGetInfo " , CONV_MEM , API_RUNTIME ) ) , <nl> - ( " cudaArrayGetInfo " , ( " hipArrayGetInfo " , CONV_MEM , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaFreeMipmappedArray " , ( " hipFreeMipmappedArray " , CONV_MEM , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaGetMipmappedArrayLevel " , ( " hipGetMipmappedArrayLevel " , CONV_MEM , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaGetSymbolAddress " , ( " hipGetSymbolAddress " , CONV_MEM , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaGetSymbolSize " , ( " hipGetSymbolSize " , CONV_MEM , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaMemPrefetchAsync " , ( " hipMemPrefetchAsync " , CONV_MEM , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaMallocHost " , ( " hipHostMalloc " , CONV_MEM , API_RUNTIME ) ) , <nl> - ( " cudaMallocArray " , ( " hipMallocArray " , CONV_MEM , API_RUNTIME ) ) , <nl> - ( " cudaMalloc " , ( " hipMalloc " , CONV_MEM , API_RUNTIME ) ) , <nl> - ( " cudaMalloc3D " , ( " hipMalloc3D " , CONV_MEM , API_RUNTIME ) ) , <nl> - ( " cudaMalloc3DArray " , ( " hipMalloc3DArray " , CONV_MEM , API_RUNTIME ) ) , <nl> - ( " cudaMallocManaged " , ( " hipMallocManaged " , CONV_MEM , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaMallocMipmappedArray " , ( " hipMallocMipmappedArray " , CONV_MEM , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaMallocPitch " , ( " hipMallocPitch " , CONV_MEM , API_RUNTIME ) ) , <nl> - ( " cudaFreeHost " , ( " hipHostFree " , CONV_MEM , API_RUNTIME ) ) , <nl> - ( " cudaFreeArray " , ( " hipFreeArray " , CONV_MEM , API_RUNTIME ) ) , <nl> - ( " cudaFree " , ( " hipFree " , CONV_MEM , API_RUNTIME ) ) , <nl> - ( " cudaHostRegister " , ( " hipHostRegister " , CONV_MEM , API_RUNTIME ) ) , <nl> - ( " cudaHostUnregister " , ( " hipHostUnregister " , CONV_MEM , API_RUNTIME ) ) , <nl> - ( " cudaHostAlloc " , ( " hipHostMalloc " , CONV_MEM , API_RUNTIME ) ) , <nl> - ( " cudaMemoryTypeHost " , ( " hipMemoryTypeHost " , CONV_MEM , API_RUNTIME ) ) , <nl> - ( " cudaMemoryTypeDevice " , ( " hipMemoryTypeDevice " , CONV_MEM , API_RUNTIME ) ) , <nl> - ( " make_cudaExtent " , ( " make_hipExtent " , CONV_MEM , API_RUNTIME ) ) , <nl> - ( " make_cudaPitchedPtr " , ( " make_hipPitchedPtr " , CONV_MEM , API_RUNTIME ) ) , <nl> - ( " make_cudaPos " , ( " make_hipPos " , CONV_MEM , API_RUNTIME ) ) , <nl> - ( " cudaHostAllocDefault " , ( " hipHostMallocDefault " , CONV_MEM , API_RUNTIME ) ) , <nl> - ( " cudaHostAllocPortable " , ( " hipHostMallocPortable " , CONV_MEM , API_RUNTIME ) ) , <nl> - ( " cudaHostAllocMapped " , ( " hipHostMallocMapped " , CONV_MEM , API_RUNTIME ) ) , <nl> - ( " cudaHostAllocWriteCombined " , ( " hipHostMallocWriteCombined " , CONV_MEM , API_RUNTIME ) ) , <nl> - ( " cudaHostGetFlags " , ( " hipHostGetFlags " , CONV_MEM , API_RUNTIME ) ) , <nl> - ( " cudaHostRegisterDefault " , ( " hipHostRegisterDefault " , CONV_MEM , API_RUNTIME ) ) , <nl> - ( " cudaHostRegisterPortable " , ( " hipHostRegisterPortable " , CONV_MEM , API_RUNTIME ) ) , <nl> - ( " cudaHostRegisterMapped " , ( " hipHostRegisterMapped " , CONV_MEM , API_RUNTIME ) ) , <nl> - ( " cudaHostRegisterIoMemory " , ( " hipHostRegisterIoMemory " , CONV_MEM , API_RUNTIME ) ) , <nl> - # ( " warpSize " , ( " hipWarpSize " , CONV_SPECIAL_FUNC , API_RUNTIME ) , ( HIP actually uses warpSize . . . ) , <nl> - ( " cudaEventCreate " , ( " hipEventCreate " , CONV_EVENT , API_RUNTIME ) ) , <nl> - ( " cudaEventCreateWithFlags " , ( " hipEventCreateWithFlags " , CONV_EVENT , API_RUNTIME ) ) , <nl> - ( " cudaEventDestroy " , ( " hipEventDestroy " , CONV_EVENT , API_RUNTIME ) ) , <nl> - ( " cudaEventRecord " , ( " hipEventRecord " , CONV_EVENT , API_RUNTIME ) ) , <nl> - ( " cudaEventElapsedTime " , ( " hipEventElapsedTime " , CONV_EVENT , API_RUNTIME ) ) , <nl> - ( " cudaEventSynchronize " , ( " hipEventSynchronize " , CONV_EVENT , API_RUNTIME ) ) , <nl> - ( " cudaEventQuery " , ( " hipEventQuery " , CONV_EVENT , API_RUNTIME ) ) , <nl> - ( " cudaEventDefault " , ( " hipEventDefault " , CONV_EVENT , API_RUNTIME ) ) , <nl> - ( " cudaEventBlockingSync " , ( " hipEventBlockingSync " , CONV_EVENT , API_RUNTIME ) ) , <nl> - ( " cudaEventDisableTiming " , ( " hipEventDisableTiming " , CONV_EVENT , API_RUNTIME ) ) , <nl> - ( " cudaEventInterprocess " , ( " hipEventInterprocess " , CONV_EVENT , API_RUNTIME ) ) , <nl> - ( " cudaStreamCreate " , ( " hipStreamCreate " , CONV_STREAM , API_RUNTIME ) ) , <nl> - ( " cudaStreamCreateWithFlags " , ( " hipStreamCreateWithFlags " , CONV_STREAM , API_RUNTIME ) ) , <nl> - ( " cudaStreamCreateWithPriority " , ( " hipStreamCreateWithPriority " , CONV_STREAM , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaStreamDestroy " , ( " hipStreamDestroy " , CONV_STREAM , API_RUNTIME ) ) , <nl> - ( " cudaStreamWaitEvent " , ( " hipStreamWaitEvent " , CONV_STREAM , API_RUNTIME ) ) , <nl> - ( " cudaStreamSynchronize " , ( " hipStreamSynchronize " , CONV_STREAM , API_RUNTIME ) ) , <nl> - ( " cudaStreamGetFlags " , ( " hipStreamGetFlags " , CONV_STREAM , API_RUNTIME ) ) , <nl> - ( " cudaStreamQuery " , ( " hipStreamQuery " , CONV_STREAM , API_RUNTIME ) ) , <nl> - ( " cudaStreamAddCallback " , ( " hipStreamAddCallback " , CONV_STREAM , API_RUNTIME ) ) , <nl> - ( " cudaStreamAttachMemAsync " , ( " hipStreamAttachMemAsync " , CONV_STREAM , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaStreamGetPriority " , ( " hipStreamGetPriority " , CONV_STREAM , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaStreamDefault " , ( " hipStreamDefault " , CONV_TYPE , API_RUNTIME ) ) , <nl> - ( " cudaStreamNonBlocking " , ( " hipStreamNonBlocking " , CONV_TYPE , API_RUNTIME ) ) , <nl> - ( " cudaDeviceSynchronize " , ( " hipDeviceSynchronize " , CONV_DEVICE , API_RUNTIME ) ) , <nl> - ( " cudaDeviceReset " , ( " hipDeviceReset " , CONV_DEVICE , API_RUNTIME ) ) , <nl> - ( " cudaSetDevice " , ( " hipSetDevice " , CONV_DEVICE , API_RUNTIME ) ) , <nl> - ( " cudaGetDevice " , ( " hipGetDevice " , CONV_DEVICE , API_RUNTIME ) ) , <nl> - ( " cudaGetDeviceCount " , ( " hipGetDeviceCount " , CONV_DEVICE , API_RUNTIME ) ) , <nl> - ( " cudaChooseDevice " , ( " hipChooseDevice " , CONV_DEVICE , API_RUNTIME ) ) , <nl> - ( " cudaThreadExit " , ( " hipDeviceReset " , CONV_THREAD , API_RUNTIME ) ) , <nl> - ( " cudaThreadGetCacheConfig " , ( " hipDeviceGetCacheConfig " , CONV_THREAD , API_RUNTIME ) ) , <nl> - ( " cudaThreadGetLimit " , ( " hipThreadGetLimit " , CONV_THREAD , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaThreadSetCacheConfig " , ( " hipDeviceSetCacheConfig " , CONV_THREAD , API_RUNTIME ) ) , <nl> - ( " cudaThreadSetLimit " , ( " hipThreadSetLimit " , CONV_THREAD , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaThreadSynchronize " , ( " hipDeviceSynchronize " , CONV_THREAD , API_RUNTIME ) ) , <nl> - ( " cudaDeviceGetAttribute " , ( " hipDeviceGetAttribute " , CONV_DEVICE , API_RUNTIME ) ) , <nl> - ( " cudaDevAttrMaxThreadsPerBlock " , ( " hipDeviceAttributeMaxThreadsPerBlock " , CONV_TYPE , API_RUNTIME ) ) , <nl> - ( " cudaDevAttrMaxBlockDimX " , ( " hipDeviceAttributeMaxBlockDimX " , CONV_TYPE , API_RUNTIME ) ) , <nl> - ( " cudaDevAttrMaxBlockDimY " , ( " hipDeviceAttributeMaxBlockDimY " , CONV_TYPE , API_RUNTIME ) ) , <nl> - ( " cudaDevAttrMaxBlockDimZ " , ( " hipDeviceAttributeMaxBlockDimZ " , CONV_TYPE , API_RUNTIME ) ) , <nl> - ( " cudaDevAttrMaxGridDimX " , ( " hipDeviceAttributeMaxGridDimX " , CONV_TYPE , API_RUNTIME ) ) , <nl> - ( " cudaDevAttrMaxGridDimY " , ( " hipDeviceAttributeMaxGridDimY " , CONV_TYPE , API_RUNTIME ) ) , <nl> - ( " cudaDevAttrMaxGridDimZ " , ( " hipDeviceAttributeMaxGridDimZ " , CONV_TYPE , API_RUNTIME ) ) , <nl> - ( " cudaDevAttrMaxSharedMemoryPerBlock " , ( " hipDeviceAttributeMaxSharedMemoryPerBlock " , CONV_TYPE , API_RUNTIME ) ) , <nl> - ( " cudaDevAttrTotalConstantMemory " , ( " hipDeviceAttributeTotalConstantMemory " , CONV_TYPE , API_RUNTIME ) ) , <nl> - ( " cudaDevAttrWarpSize " , ( " hipDeviceAttributeWarpSize " , CONV_TYPE , API_RUNTIME ) ) , <nl> - ( " cudaDevAttrMaxPitch " , ( " hipDeviceAttributeMaxPitch " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaDevAttrMaxRegistersPerBlock " , ( " hipDeviceAttributeMaxRegistersPerBlock " , CONV_TYPE , API_RUNTIME ) ) , <nl> - ( " cudaDevAttrClockRate " , ( " hipDeviceAttributeClockRate " , CONV_TYPE , API_RUNTIME ) ) , <nl> - ( " cudaDevAttrTextureAlignment " , ( " hipDeviceAttributeTextureAlignment " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaDevAttrGpuOverlap " , ( " hipDeviceAttributeGpuOverlap " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaDevAttrMultiProcessorCount " , ( " hipDeviceAttributeMultiprocessorCount " , CONV_TYPE , API_RUNTIME ) ) , <nl> - ( " cudaDevAttrKernelExecTimeout " , ( " hipDeviceAttributeKernelExecTimeout " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaDevAttrIntegrated " , ( " hipDeviceAttributeIntegrated " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaDevAttrCanMapHostMemory " , ( " hipDeviceAttributeCanMapHostMemory " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaDevAttrComputeMode " , ( " hipDeviceAttributeComputeMode " , CONV_TYPE , API_RUNTIME ) ) , <nl> - ( " cudaDevAttrMaxTexture1DWidth " , ( " hipDeviceAttributeMaxTexture1DWidth " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaDevAttrMaxTexture2DWidth " , ( " hipDeviceAttributeMaxTexture2DWidth " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaDevAttrMaxTexture2DHeight " , ( " hipDeviceAttributeMaxTexture2DHeight " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaDevAttrMaxTexture3DWidth " , ( " hipDeviceAttributeMaxTexture3DWidth " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaDevAttrMaxTexture3DHeight " , ( " hipDeviceAttributeMaxTexture3DHeight " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaDevAttrMaxTexture3DDepth " , ( " hipDeviceAttributeMaxTexture3DDepth " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaDevAttrMaxTexture2DLayeredWidth " , ( " hipDeviceAttributeMaxTexture2DLayeredWidth " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaDevAttrMaxTexture2DLayeredHeight " , ( " hipDeviceAttributeMaxTexture2DLayeredHeight " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaDevAttrMaxTexture2DLayeredLayers " , ( " hipDeviceAttributeMaxTexture2DLayeredLayers " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaDevAttrSurfaceAlignment " , ( " hipDeviceAttributeSurfaceAlignment " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaDevAttrConcurrentKernels " , ( " hipDeviceAttributeConcurrentKernels " , CONV_TYPE , API_RUNTIME ) ) , <nl> - ( " cudaDevAttrEccEnabled " , ( " hipDeviceAttributeEccEnabled " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaDevAttrPciBusId " , ( " hipDeviceAttributePciBusId " , CONV_TYPE , API_RUNTIME ) ) , <nl> - ( " cudaDevAttrPciDeviceId " , ( " hipDeviceAttributePciDeviceId " , CONV_TYPE , API_RUNTIME ) ) , <nl> - ( " cudaDevAttrTccDriver " , ( " hipDeviceAttributeTccDriver " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaDevAttrMemoryClockRate " , ( " hipDeviceAttributeMemoryClockRate " , CONV_TYPE , API_RUNTIME ) ) , <nl> - ( " cudaDevAttrGlobalMemoryBusWidth " , ( " hipDeviceAttributeMemoryBusWidth " , CONV_TYPE , API_RUNTIME ) ) , <nl> - ( " cudaDevAttrL2CacheSize " , ( " hipDeviceAttributeL2CacheSize " , CONV_TYPE , API_RUNTIME ) ) , <nl> - ( " cudaDevAttrMaxThreadsPerMultiProcessor " , ( " hipDeviceAttributeMaxThreadsPerMultiProcessor " , CONV_TYPE , API_RUNTIME ) ) , <nl> - ( " cudaDevAttrAsyncEngineCount " , ( " hipDeviceAttributeAsyncEngineCount " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaDevAttrUnifiedAddressing " , ( " hipDeviceAttributeUnifiedAddressing " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaDevAttrMaxTexture1DLayeredWidth " , ( " hipDeviceAttributeMaxTexture1DLayeredWidth " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaDevAttrMaxTexture1DLayeredLayers " , ( " hipDeviceAttributeMaxTexture1DLayeredLayers " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaDevAttrMaxTexture2DGatherWidth " , ( " hipDeviceAttributeMaxTexture2DGatherWidth " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaDevAttrMaxTexture2DGatherHeight " , ( " hipDeviceAttributeMaxTexture2DGatherHeight " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaDevAttrMaxTexture3DWidthAlt " , ( " hipDeviceAttributeMaxTexture3DWidthAlternate " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaDevAttrMaxTexture3DHeightAlt " , ( " hipDeviceAttributeMaxTexture3DHeightAlternate " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaDevAttrMaxTexture3DDepthAlt " , ( " hipDeviceAttributeMaxTexture3DDepthAlternate " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaDevAttrPciDomainId " , ( " hipDeviceAttributePciDomainId " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaDevAttrTexturePitchAlignment " , ( " hipDeviceAttributeTexturePitchAlignment " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaDevAttrMaxTextureCubemapWidth " , ( " hipDeviceAttributeMaxTextureCubemapWidth " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaDevAttrMaxTextureCubemapLayeredWidth " , ( " hipDeviceAttributeMaxTextureCubemapLayeredWidth " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaDevAttrMaxTextureCubemapLayeredLayers " , ( " hipDeviceAttributeMaxTextureCubemapLayeredLayers " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaDevAttrMaxSurface1DWidth " , ( " hipDeviceAttributeMaxSurface1DWidth " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaDevAttrMaxSurface2DWidth " , ( " hipDeviceAttributeMaxSurface2DWidth " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaDevAttrMaxSurface2DHeight " , ( " hipDeviceAttributeMaxSurface2DHeight " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaDevAttrMaxSurface3DWidth " , ( " hipDeviceAttributeMaxSurface3DWidth " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaDevAttrMaxSurface3DHeight " , ( " hipDeviceAttributeMaxSurface3DHeight " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaDevAttrMaxSurface3DDepth " , ( " hipDeviceAttributeMaxSurface3DDepth " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaDevAttrMaxSurface1DLayeredWidth " , ( " hipDeviceAttributeMaxSurface1DLayeredWidth " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaDevAttrMaxSurface1DLayeredLayers " , ( " hipDeviceAttributeMaxSurface1DLayeredLayers " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaDevAttrMaxSurface2DLayeredWidth " , ( " hipDeviceAttributeMaxSurface2DLayeredWidth " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaDevAttrMaxSurface2DLayeredHeight " , ( " hipDeviceAttributeMaxSurface2DLayeredHeight " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaDevAttrMaxSurface2DLayeredLayers " , ( " hipDeviceAttributeMaxSurface2DLayeredLayers " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaDevAttrMaxSurfaceCubemapWidth " , ( " hipDeviceAttributeMaxSurfaceCubemapWidth " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaDevAttrMaxSurfaceCubemapLayeredWidth " , ( " hipDeviceAttributeMaxSurfaceCubemapLayeredWidth " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaDevAttrMaxSurfaceCubemapLayeredLayers " , ( " hipDeviceAttributeMaxSurfaceCubemapLayeredLayers " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaDevAttrMaxTexture1DLinearWidth " , ( " hipDeviceAttributeMaxTexture1DLinearWidth " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaDevAttrMaxTexture2DLinearWidth " , ( " hipDeviceAttributeMaxTexture2DLinearWidth " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaDevAttrMaxTexture2DLinearHeight " , ( " hipDeviceAttributeMaxTexture2DLinearHeight " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaDevAttrMaxTexture2DLinearPitch " , ( " hipDeviceAttributeMaxTexture2DLinearPitch " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaDevAttrMaxTexture2DMipmappedWidth " , ( " hipDeviceAttributeMaxTexture2DMipmappedWidth " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaDevAttrMaxTexture2DMipmappedHeight " , ( " hipDeviceAttributeMaxTexture2DMipmappedHeight " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaDevAttrComputeCapabilityMajor " , ( " hipDeviceAttributeComputeCapabilityMajor " , CONV_TYPE , API_RUNTIME ) ) , <nl> - ( " cudaDevAttrComputeCapabilityMinor " , ( " hipDeviceAttributeComputeCapabilityMinor " , CONV_TYPE , API_RUNTIME ) ) , <nl> - ( " cudaDevAttrMaxTexture1DMipmappedWidth " , ( " hipDeviceAttributeMaxTexture1DMipmappedWidth " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaDevAttrStreamPrioritiesSupported " , ( " hipDeviceAttributeStreamPrioritiesSupported " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaDevAttrGlobalL1CacheSupported " , ( " hipDeviceAttributeGlobalL1CacheSupported " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaDevAttrLocalL1CacheSupported " , ( " hipDeviceAttributeLocalL1CacheSupported " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaDevAttrMaxSharedMemoryPerMultiprocessor " , ( " hipDeviceAttributeMaxSharedMemoryPerMultiprocessor " , CONV_TYPE , API_RUNTIME ) ) , <nl> - ( " cudaDevAttrMaxRegistersPerMultiprocessor " , ( " hipDeviceAttributeMaxRegistersPerMultiprocessor " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaDevAttrManagedMemory " , ( " hipDeviceAttributeManagedMemory " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaDevAttrIsMultiGpuBoard " , ( " hipDeviceAttributeIsMultiGpuBoard " , CONV_TYPE , API_RUNTIME ) ) , <nl> - ( " cudaDevAttrMultiGpuBoardGroupID " , ( " hipDeviceAttributeMultiGpuBoardGroupID " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaDevAttrHostNativeAtomicSupported " , ( " hipDeviceAttributeHostNativeAtomicSupported " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaDevAttrSingleToDoublePrecisionPerfRatio " , ( " hipDeviceAttributeSingleToDoublePrecisionPerfRatio " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaDevAttrPageableMemoryAccess " , ( " hipDeviceAttributePageableMemoryAccess " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaDevAttrConcurrentManagedAccess " , ( " hipDeviceAttributeConcurrentManagedAccess " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaDevAttrComputePreemptionSupported " , ( " hipDeviceAttributeComputePreemptionSupported " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaDevAttrCanUseHostPointerForRegisteredMem " , ( " hipDeviceAttributeCanUseHostPointerForRegisteredMem " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaPointerGetAttributes " , ( " hipPointerGetAttributes " , CONV_MEM , API_RUNTIME ) ) , <nl> - ( " cudaHostGetDevicePointer " , ( " hipHostGetDevicePointer " , CONV_MEM , API_RUNTIME ) ) , <nl> - ( " cudaGetDeviceProperties " , ( " hipGetDeviceProperties " , CONV_DEVICE , API_RUNTIME ) ) , <nl> - ( " cudaDeviceGetPCIBusId " , ( " hipDeviceGetPCIBusId " , CONV_DEVICE , API_RUNTIME ) ) , <nl> - ( " cudaDeviceGetByPCIBusId " , ( " hipDeviceGetByPCIBusId " , CONV_DEVICE , API_RUNTIME ) ) , <nl> - ( " cudaDeviceGetStreamPriorityRange " , ( " hipDeviceGetStreamPriorityRange " , CONV_DEVICE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaSetValidDevices " , ( " hipSetValidDevices " , CONV_DEVICE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaDevP2PAttrPerformanceRank " , ( " hipDeviceP2PAttributePerformanceRank " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaDevP2PAttrAccessSupported " , ( " hipDeviceP2PAttributeAccessSupported " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaDevP2PAttrNativeAtomicSupported " , ( " hipDeviceP2PAttributeNativeAtomicSupported " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaDeviceGetP2PAttribute " , ( " hipDeviceGetP2PAttribute " , CONV_DEVICE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaComputeModeDefault " , ( " hipComputeModeDefault " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaComputeModeExclusive " , ( " hipComputeModeExclusive " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaComputeModeProhibited " , ( " hipComputeModeProhibited " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaComputeModeExclusiveProcess " , ( " hipComputeModeExclusiveProcess " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaGetDeviceFlags " , ( " hipGetDeviceFlags " , CONV_DEVICE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaSetDeviceFlags " , ( " hipSetDeviceFlags " , CONV_DEVICE , API_RUNTIME ) ) , <nl> - ( " cudaDeviceScheduleAuto " , ( " hipDeviceScheduleAuto " , CONV_TYPE , API_RUNTIME ) ) , <nl> - ( " cudaDeviceScheduleSpin " , ( " hipDeviceScheduleSpin " , CONV_TYPE , API_RUNTIME ) ) , <nl> - ( " cudaDeviceScheduleYield " , ( " hipDeviceScheduleYield " , CONV_TYPE , API_RUNTIME ) ) , <nl> - ( " cudaDeviceBlockingSync " , ( " hipDeviceScheduleBlockingSync " , CONV_TYPE , API_RUNTIME ) ) , <nl> - ( " cudaDeviceScheduleBlockingSync " , ( " hipDeviceScheduleBlockingSync " , CONV_TYPE , API_RUNTIME ) ) , <nl> - ( " cudaDeviceScheduleMask " , ( " hipDeviceScheduleMask " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaDeviceMapHost " , ( " hipDeviceMapHost " , CONV_TYPE , API_RUNTIME ) ) , <nl> - ( " cudaDeviceLmemResizeToMax " , ( " hipDeviceLmemResizeToMax " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaDeviceMask " , ( " hipDeviceMask " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaDeviceSetCacheConfig " , ( " hipDeviceSetCacheConfig " , CONV_CACHE , API_RUNTIME ) ) , <nl> - ( " cudaDeviceGetCacheConfig " , ( " hipDeviceGetCacheConfig " , CONV_CACHE , API_RUNTIME ) ) , <nl> - ( " cudaFuncSetCacheConfig " , ( " hipFuncSetCacheConfig " , CONV_CACHE , API_RUNTIME ) ) , <nl> - ( " cudaFuncCachePreferNone " , ( " hipFuncCachePreferNone " , CONV_CACHE , API_RUNTIME ) ) , <nl> - ( " cudaFuncCachePreferShared " , ( " hipFuncCachePreferShared " , CONV_CACHE , API_RUNTIME ) ) , <nl> - ( " cudaFuncCachePreferL1 " , ( " hipFuncCachePreferL1 " , CONV_CACHE , API_RUNTIME ) ) , <nl> - ( " cudaFuncCachePreferEqual " , ( " hipFuncCachePreferEqual " , CONV_CACHE , API_RUNTIME ) ) , <nl> - ( " cudaFuncGetAttributes " , ( " hipFuncGetAttributes " , CONV_EXEC , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaFuncSetSharedMemConfig " , ( " hipFuncSetSharedMemConfig " , CONV_EXEC , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaGetParameterBuffer " , ( " hipGetParameterBuffer " , CONV_EXEC , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaSetDoubleForDevice " , ( " hipSetDoubleForDevice " , CONV_EXEC , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaSetDoubleForHost " , ( " hipSetDoubleForHost " , CONV_EXEC , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaConfigureCall " , ( " hipConfigureCall " , CONV_EXEC , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaLaunch " , ( " hipLaunch " , CONV_EXEC , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaSetupArgument " , ( " hipSetupArgument " , CONV_EXEC , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaDriverGetVersion " , ( " hipDriverGetVersion " , CONV_VERSION , API_RUNTIME ) ) , <nl> - ( " cudaRuntimeGetVersion " , ( " hipRuntimeGetVersion " , CONV_VERSION , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaOccupancyMaxPotentialBlockSize " , ( " hipOccupancyMaxPotentialBlockSize " , CONV_OCCUPANCY , API_RUNTIME ) ) , <nl> - ( " cudaOccupancyMaxPotentialBlockSizeWithFlags " , ( " hipOccupancyMaxPotentialBlockSizeWithFlags " , CONV_OCCUPANCY , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaOccupancyMaxActiveBlocksPerMultiprocessor " , ( " hipOccupancyMaxActiveBlocksPerMultiprocessor " , CONV_OCCUPANCY , API_RUNTIME ) ) , <nl> - ( " cudaOccupancyMaxActiveBlocksPerMultiprocessorWithFlags " , ( " hipOccupancyMaxActiveBlocksPerMultiprocessorWithFlags " , CONV_OCCUPANCY , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaOccupancyMaxPotentialBlockSizeVariableSMem " , ( " hipOccupancyMaxPotentialBlockSizeVariableSMem " , CONV_OCCUPANCY , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaOccupancyMaxPotentialBlockSizeVariableSMemWithFlags " , ( " hipOccupancyMaxPotentialBlockSizeVariableSMemWithFlags " , CONV_OCCUPANCY , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaDeviceCanAccessPeer " , ( " hipDeviceCanAccessPeer " , CONV_PEER , API_RUNTIME ) ) , <nl> - ( " cudaDeviceDisablePeerAccess " , ( " hipDeviceDisablePeerAccess " , CONV_PEER , API_RUNTIME ) ) , <nl> - ( " cudaDeviceEnablePeerAccess " , ( " hipDeviceEnablePeerAccess " , CONV_PEER , API_RUNTIME ) ) , <nl> - ( " cudaMemcpyPeerAsync " , ( " hipMemcpyPeerAsync " , CONV_MEM , API_RUNTIME ) ) , <nl> - ( " cudaMemcpyPeer " , ( " hipMemcpyPeer " , CONV_MEM , API_RUNTIME ) ) , <nl> - ( " cudaIpcMemLazyEnablePeerAccess " , ( " hipIpcMemLazyEnablePeerAccess " , CONV_TYPE , API_RUNTIME ) ) , <nl> - ( " cudaDeviceSetSharedMemConfig " , ( " hipDeviceSetSharedMemConfig " , CONV_DEVICE , API_RUNTIME ) ) , <nl> - ( " cudaDeviceGetSharedMemConfig " , ( " hipDeviceGetSharedMemConfig " , CONV_DEVICE , API_RUNTIME ) ) , <nl> - ( " cudaSharedMemBankSizeDefault " , ( " hipSharedMemBankSizeDefault " , CONV_TYPE , API_RUNTIME ) ) , <nl> - ( " cudaSharedMemBankSizeFourByte " , ( " hipSharedMemBankSizeFourByte " , CONV_TYPE , API_RUNTIME ) ) , <nl> - ( " cudaSharedMemBankSizeEightByte " , ( " hipSharedMemBankSizeEightByte " , CONV_TYPE , API_RUNTIME ) ) , <nl> - ( " cudaLimitStackSize " , ( " hipLimitStackSize " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaLimitPrintfFifoSize " , ( " hipLimitPrintfFifoSize " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaLimitMallocHeapSize " , ( " hipLimitMallocHeapSize " , CONV_TYPE , API_RUNTIME ) ) , <nl> - ( " cudaLimitDevRuntimeSyncDepth " , ( " hipLimitDevRuntimeSyncDepth " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaLimitDevRuntimePendingLaunchCount " , ( " hipLimitDevRuntimePendingLaunchCount " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaDeviceGetLimit " , ( " hipDeviceGetLimit " , CONV_DEVICE , API_RUNTIME ) ) , <nl> - ( " cudaProfilerInitialize " , ( " hipProfilerInitialize " , CONV_OTHER , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaProfilerStart " , ( " hipProfilerStart " , CONV_OTHER , API_RUNTIME ) ) , <nl> - ( " cudaProfilerStop " , ( " hipProfilerStop " , CONV_OTHER , API_RUNTIME ) ) , <nl> - ( " cudaKeyValuePair " , ( " hipKeyValuePair " , CONV_OTHER , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaCSV " , ( " hipCSV " , CONV_OTHER , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaReadModeElementType " , ( " hipReadModeElementType " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaReadModeNormalizedFloat " , ( " hipReadModeNormalizedFloat " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaFilterModePoint " , ( " hipFilterModePoint " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaFilterModeLinear " , ( " hipFilterModeLinear " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaBindTexture " , ( " hipBindTexture " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaUnbindTexture " , ( " hipUnbindTexture " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaBindTexture2D " , ( " hipBindTexture2D " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaBindTextureToArray " , ( " hipBindTextureToArray " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaBindTextureToMipmappedArray " , ( " hipBindTextureToMipmappedArray " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaGetTextureAlignmentOffset " , ( " hipGetTextureAlignmentOffset " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaGetTextureReference " , ( " hipGetTextureReference " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaChannelFormatKindSigned " , ( " hipChannelFormatKindSigned " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaChannelFormatKindUnsigned " , ( " hipChannelFormatKindUnsigned " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaChannelFormatKindFloat " , ( " hipChannelFormatKindFloat " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaChannelFormatKindNone " , ( " hipChannelFormatKindNone " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaCreateChannelDesc " , ( " hipCreateChannelDesc " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaGetChannelDesc " , ( " hipGetChannelDesc " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaResourceTypeArray " , ( " hipResourceTypeArray " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaResourceTypeMipmappedArray " , ( " hipResourceTypeMipmappedArray " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaResourceTypeLinear " , ( " hipResourceTypeLinear " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaResourceTypePitch2D " , ( " hipResourceTypePitch2D " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaResViewFormatNone " , ( " hipResViewFormatNone " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaResViewFormatUnsignedChar1 " , ( " hipResViewFormatUnsignedChar1 " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaResViewFormatUnsignedChar2 " , ( " hipResViewFormatUnsignedChar2 " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaResViewFormatUnsignedChar4 " , ( " hipResViewFormatUnsignedChar4 " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaResViewFormatSignedChar1 " , ( " hipResViewFormatSignedChar1 " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaResViewFormatSignedChar2 " , ( " hipResViewFormatSignedChar2 " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaResViewFormatSignedChar4 " , ( " hipResViewFormatSignedChar4 " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaResViewFormatUnsignedShort1 " , ( " hipResViewFormatUnsignedShort1 " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaResViewFormatUnsignedShort2 " , ( " hipResViewFormatUnsignedShort2 " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaResViewFormatUnsignedShort4 " , ( " hipResViewFormatUnsignedShort4 " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaResViewFormatSignedShort1 " , ( " hipResViewFormatSignedShort1 " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaResViewFormatSignedShort2 " , ( " hipResViewFormatSignedShort2 " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaResViewFormatSignedShort4 " , ( " hipResViewFormatSignedShort4 " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaResViewFormatUnsignedInt1 " , ( " hipResViewFormatUnsignedInt1 " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaResViewFormatUnsignedInt2 " , ( " hipResViewFormatUnsignedInt2 " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaResViewFormatUnsignedInt4 " , ( " hipResViewFormatUnsignedInt4 " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaResViewFormatSignedInt1 " , ( " hipResViewFormatSignedInt1 " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaResViewFormatSignedInt2 " , ( " hipResViewFormatSignedInt2 " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaResViewFormatSignedInt4 " , ( " hipResViewFormatSignedInt4 " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaResViewFormatHalf1 " , ( " hipResViewFormatHalf1 " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaResViewFormatHalf2 " , ( " hipResViewFormatHalf2 " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaResViewFormatHalf4 " , ( " hipResViewFormatHalf4 " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaResViewFormatFloat1 " , ( " hipResViewFormatFloat1 " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaResViewFormatFloat2 " , ( " hipResViewFormatFloat2 " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaResViewFormatFloat4 " , ( " hipResViewFormatFloat4 " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaResViewFormatUnsignedBlockCompressed1 " , ( " hipResViewFormatUnsignedBlockCompressed1 " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaResViewFormatUnsignedBlockCompressed2 " , ( " hipResViewFormatUnsignedBlockCompressed2 " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaResViewFormatUnsignedBlockCompressed3 " , ( " hipResViewFormatUnsignedBlockCompressed3 " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaResViewFormatUnsignedBlockCompressed4 " , ( " hipResViewFormatUnsignedBlockCompressed4 " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaResViewFormatSignedBlockCompressed4 " , ( " hipResViewFormatSignedBlockCompressed4 " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaResViewFormatUnsignedBlockCompressed5 " , ( " hipResViewFormatUnsignedBlockCompressed5 " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaResViewFormatSignedBlockCompressed5 " , ( " hipResViewFormatSignedBlockCompressed5 " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaResViewFormatUnsignedBlockCompressed6H " , ( " hipResViewFormatUnsignedBlockCompressed6H " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaResViewFormatSignedBlockCompressed6H " , ( " hipResViewFormatSignedBlockCompressed6H " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaResViewFormatUnsignedBlockCompressed7 " , ( " hipResViewFormatUnsignedBlockCompressed7 " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaAddressModeWrap " , ( " hipAddressModeWrap " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaAddressModeClamp " , ( " hipAddressModeClamp " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaAddressModeMirror " , ( " hipAddressModeMirror " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaAddressModeBorder " , ( " hipAddressModeBorder " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaCreateTextureObject " , ( " hipCreateTextureObject " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaDestroyTextureObject " , ( " hipDestroyTextureObject " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaGetTextureObjectResourceDesc " , ( " hipGetTextureObjectResourceDesc " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaGetTextureObjectResourceViewDesc " , ( " hipGetTextureObjectResourceViewDesc " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaGetTextureObjectTextureDesc " , ( " hipGetTextureObjectTextureDesc " , CONV_TEX , API_RUNTIME ) ) , <nl> - ( " cudaBindSurfaceToArray " , ( " hipBindSurfaceToArray " , CONV_SURFACE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaGetSurfaceReference " , ( " hipGetSurfaceReference " , CONV_SURFACE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaBoundaryModeZero " , ( " hipBoundaryModeZero " , CONV_SURFACE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaBoundaryModeClamp " , ( " hipBoundaryModeClamp " , CONV_SURFACE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaBoundaryModeTrap " , ( " hipBoundaryModeTrap " , CONV_SURFACE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaFormatModeForced " , ( " hipFormatModeForced " , CONV_SURFACE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaFormatModeAuto " , ( " hipFormatModeAuto " , CONV_SURFACE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaCreateSurfaceObject " , ( " hipCreateSurfaceObject " , CONV_SURFACE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaDestroySurfaceObject " , ( " hipDestroySurfaceObject " , CONV_SURFACE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaGetSurfaceObjectResourceDesc " , ( " hipGetSurfaceObjectResourceDesc " , CONV_SURFACE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaIpcCloseMemHandle " , ( " hipIpcCloseMemHandle " , CONV_DEVICE , API_RUNTIME ) ) , <nl> - ( " cudaIpcGetEventHandle " , ( " hipIpcGetEventHandle " , CONV_DEVICE , API_RUNTIME ) ) , <nl> - ( " cudaIpcGetMemHandle " , ( " hipIpcGetMemHandle " , CONV_DEVICE , API_RUNTIME ) ) , <nl> - ( " cudaIpcOpenEventHandle " , ( " hipIpcOpenEventHandle " , CONV_DEVICE , API_RUNTIME ) ) , <nl> - ( " cudaIpcOpenMemHandle " , ( " hipIpcOpenMemHandle " , CONV_DEVICE , API_RUNTIME ) ) , <nl> - ( " cudaGLGetDevices " , ( " hipGLGetDevices " , CONV_GL , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaGraphicsGLRegisterBuffer " , ( " hipGraphicsGLRegisterBuffer " , CONV_GL , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaGraphicsGLRegisterImage " , ( " hipGraphicsGLRegisterImage " , CONV_GL , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaWGLGetDevice " , ( " hipWGLGetDevice " , CONV_GL , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaGraphicsMapResources " , ( " hipGraphicsMapResources " , CONV_GRAPHICS , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaGraphicsResourceGetMappedMipmappedArray " , ( " hipGraphicsResourceGetMappedMipmappedArray " , CONV_GRAPHICS , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaGraphicsResourceGetMappedPointer " , ( " hipGraphicsResourceGetMappedPointer " , CONV_GRAPHICS , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaGraphicsResourceSetMapFlags " , ( " hipGraphicsResourceSetMapFlags " , CONV_GRAPHICS , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaGraphicsSubResourceGetMappedArray " , ( " hipGraphicsSubResourceGetMappedArray " , CONV_GRAPHICS , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaGraphicsUnmapResources " , ( " hipGraphicsUnmapResources " , CONV_GRAPHICS , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaGraphicsUnregisterResource " , ( " hipGraphicsUnregisterResource " , CONV_GRAPHICS , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaGraphicsCubeFacePositiveX " , ( " hipGraphicsCubeFacePositiveX " , CONV_GRAPHICS , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaGraphicsCubeFaceNegativeX " , ( " hipGraphicsCubeFaceNegativeX " , CONV_GRAPHICS , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaGraphicsCubeFacePositiveY " , ( " hipGraphicsCubeFacePositiveY " , CONV_GRAPHICS , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaGraphicsCubeFaceNegativeY " , ( " hipGraphicsCubeFaceNegativeY " , CONV_GRAPHICS , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaGraphicsCubeFacePositiveZ " , ( " hipGraphicsCubeFacePositiveZ " , CONV_GRAPHICS , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaGraphicsCubeFaceNegativeZ " , ( " hipGraphicsCubeFaceNegativeZ " , CONV_GRAPHICS , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaGraphicsMapFlagsNone " , ( " hipGraphicsMapFlagsNone " , CONV_GRAPHICS , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaGraphicsMapFlagsReadOnly " , ( " hipGraphicsMapFlagsReadOnly " , CONV_GRAPHICS , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaGraphicsMapFlagsWriteDiscard " , ( " hipGraphicsMapFlagsWriteDiscard " , CONV_GRAPHICS , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaGraphicsRegisterFlagsNone " , ( " hipGraphicsRegisterFlagsNone " , CONV_GRAPHICS , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaGraphicsRegisterFlagsReadOnly " , ( " hipGraphicsRegisterFlagsReadOnly " , CONV_GRAPHICS , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaGraphicsRegisterFlagsWriteDiscard " , ( " hipGraphicsRegisterFlagsWriteDiscard " , CONV_GRAPHICS , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaGraphicsRegisterFlagsSurfaceLoadStore " , ( " hipGraphicsRegisterFlagsSurfaceLoadStore " , CONV_GRAPHICS , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaGraphicsRegisterFlagsTextureGather " , ( " hipGraphicsRegisterFlagsTextureGather " , CONV_GRAPHICS , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaGLDeviceListAll " , ( " HIP_GL_DEVICE_LIST_ALL " , CONV_GL , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaGLDeviceListCurrentFrame " , ( " HIP_GL_DEVICE_LIST_CURRENT_FRAME " , CONV_GL , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaGLDeviceListNextFrame " , ( " HIP_GL_DEVICE_LIST_NEXT_FRAME " , CONV_GL , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaGLGetDevices " , ( " hipGLGetDevices " , CONV_GL , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaGraphicsGLRegisterBuffer " , ( " hipGraphicsGLRegisterBuffer " , CONV_GL , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaGraphicsGLRegisterImage " , ( " hipGraphicsGLRegisterImage " , CONV_GL , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaWGLGetDevice " , ( " hipWGLGetDevice " , CONV_GL , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaGLMapFlagsNone " , ( " HIP_GL_MAP_RESOURCE_FLAGS_NONE " , CONV_GL , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaGLMapFlagsReadOnly " , ( " HIP_GL_MAP_RESOURCE_FLAGS_READ_ONLY " , CONV_GL , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaGLMapFlagsWriteDiscard " , ( " HIP_GL_MAP_RESOURCE_FLAGS_WRITE_DISCARD " , CONV_GL , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaGLMapBufferObject " , ( " hipGLMapBufferObject__ " , CONV_GL , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaGLMapBufferObjectAsync " , ( " hipGLMapBufferObjectAsync__ " , CONV_GL , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaGLRegisterBufferObject " , ( " hipGLRegisterBufferObject " , CONV_GL , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaGLSetBufferObjectMapFlags " , ( " hipGLSetBufferObjectMapFlags " , CONV_GL , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaGLSetGLDevice " , ( " hipGLSetGLDevice " , CONV_GL , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaGLUnmapBufferObject " , ( " hipGLUnmapBufferObject " , CONV_GL , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaGLUnmapBufferObjectAsync " , ( " hipGLUnmapBufferObjectAsync " , CONV_GL , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaGLUnregisterBufferObject " , ( " hipGLUnregisterBufferObject " , CONV_GL , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaD3D9DeviceListAll " , ( " HIP_D3D9_DEVICE_LIST_ALL " , CONV_D3D9 , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaD3D9DeviceListCurrentFrame " , ( " HIP_D3D9_DEVICE_LIST_CURRENT_FRAME " , CONV_D3D9 , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaD3D9DeviceListNextFrame " , ( " HIP_D3D9_DEVICE_LIST_NEXT_FRAME " , CONV_D3D9 , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaD3D9GetDevice " , ( " hipD3D9GetDevice " , CONV_D3D9 , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaD3D9GetDevices " , ( " hipD3D9GetDevices " , CONV_D3D9 , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaD3D9GetDirect3DDevice " , ( " hipD3D9GetDirect3DDevice " , CONV_D3D9 , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaD3D9SetDirect3DDevice " , ( " hipD3D9SetDirect3DDevice " , CONV_D3D9 , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaGraphicsD3D9RegisterResource " , ( " hipGraphicsD3D9RegisterResource " , CONV_D3D9 , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaD3D9MapFlags " , ( " hipD3D9MapFlags " , CONV_D3D9 , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaD3D9MapFlagsNone " , ( " HIP_D3D9_MAPRESOURCE_FLAGS_NONE " , CONV_D3D9 , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaD3D9MapFlagsReadOnly " , ( " HIP_D3D9_MAPRESOURCE_FLAGS_READONLY " , CONV_D3D9 , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaD3D9MapFlagsWriteDiscard " , ( " HIP_D3D9_MAPRESOURCE_FLAGS_WRITEDISCARD " , CONV_D3D9 , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaD3D9RegisterFlagsNone " , ( " HIP_D3D9_REGISTER_FLAGS_NONE " , CONV_D3D9 , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaD3D9RegisterFlagsArray " , ( " HIP_D3D9_REGISTER_FLAGS_ARRAY " , CONV_D3D9 , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaD3D9MapResources " , ( " hipD3D9MapResources " , CONV_D3D9 , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaD3D9RegisterResource " , ( " hipD3D9RegisterResource " , CONV_D3D9 , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaD3D9ResourceGetMappedArray " , ( " hipD3D9ResourceGetMappedArray " , CONV_D3D9 , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaD3D9ResourceGetMappedPitch " , ( " hipD3D9ResourceGetMappedPitch " , CONV_D3D9 , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaD3D9ResourceGetMappedPointer " , ( " hipD3D9ResourceGetMappedPointer " , CONV_D3D9 , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaD3D9ResourceGetMappedSize " , ( " hipD3D9ResourceGetMappedSize " , CONV_D3D9 , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaD3D9ResourceGetSurfaceDimensions " , ( " hipD3D9ResourceGetSurfaceDimensions " , CONV_D3D9 , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaD3D9ResourceSetMapFlags " , ( " hipD3D9ResourceSetMapFlags " , CONV_D3D9 , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaD3D9UnmapResources " , ( " hipD3D9UnmapResources " , CONV_D3D9 , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaD3D9UnregisterResource " , ( " hipD3D9UnregisterResource " , CONV_D3D9 , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaD3D10DeviceListAll " , ( " HIP_D3D10_DEVICE_LIST_ALL " , CONV_D3D10 , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaD3D10DeviceListCurrentFrame " , ( " HIP_D3D10_DEVICE_LIST_CURRENT_FRAME " , CONV_D3D10 , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaD3D10DeviceListNextFrame " , ( " HIP_D3D10_DEVICE_LIST_NEXT_FRAME " , CONV_D3D10 , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaD3D10GetDevice " , ( " hipD3D10GetDevice " , CONV_D3D10 , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaD3D10GetDevices " , ( " hipD3D10GetDevices " , CONV_D3D10 , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaGraphicsD3D10RegisterResource " , ( " hipGraphicsD3D10RegisterResource " , CONV_D3D10 , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaD3D10MapFlagsNone " , ( " HIP_D3D10_MAPRESOURCE_FLAGS_NONE " , CONV_D3D10 , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaD3D10MapFlagsReadOnly " , ( " HIP_D3D10_MAPRESOURCE_FLAGS_READONLY " , CONV_D3D10 , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaD3D10MapFlagsWriteDiscard " , ( " HIP_D3D10_MAPRESOURCE_FLAGS_WRITEDISCARD " , CONV_D3D10 , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaD3D10RegisterFlagsNone " , ( " HIP_D3D10_REGISTER_FLAGS_NONE " , CONV_D3D10 , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaD3D10RegisterFlagsArray " , ( " HIP_D3D10_REGISTER_FLAGS_ARRAY " , CONV_D3D10 , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaD3D10GetDirect3DDevice " , ( " hipD3D10GetDirect3DDevice " , CONV_D3D10 , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaD3D10MapResources " , ( " hipD3D10MapResources " , CONV_D3D10 , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaD3D10RegisterResource " , ( " hipD3D10RegisterResource " , CONV_D3D10 , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaD3D10ResourceGetMappedArray " , ( " hipD3D10ResourceGetMappedArray " , CONV_D3D10 , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaD3D10ResourceGetMappedPitch " , ( " hipD3D10ResourceGetMappedPitch " , CONV_D3D10 , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaD3D10ResourceGetMappedPointer " , ( " hipD3D10ResourceGetMappedPointer " , CONV_D3D10 , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaD3D10ResourceGetMappedSize " , ( " hipD3D10ResourceGetMappedSize " , CONV_D3D10 , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaD3D10ResourceGetSurfaceDimensions " , ( " hipD3D10ResourceGetSurfaceDimensions " , CONV_D3D10 , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaD3D10ResourceSetMapFlags " , ( " hipD3D10ResourceSetMapFlags " , CONV_D3D10 , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaD3D10SetDirect3DDevice " , ( " hipD3D10SetDirect3DDevice " , CONV_D3D10 , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaD3D10UnmapResources " , ( " hipD3D10UnmapResources " , CONV_D3D10 , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaD3D10UnregisterResource " , ( " hipD3D10UnregisterResource " , CONV_D3D10 , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaD3D11DeviceListAll " , ( " HIP_D3D11_DEVICE_LIST_ALL " , CONV_D3D11 , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaD3D11DeviceListCurrentFrame " , ( " HIP_D3D11_DEVICE_LIST_CURRENT_FRAME " , CONV_D3D11 , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaD3D11DeviceListNextFrame " , ( " HIP_D3D11_DEVICE_LIST_NEXT_FRAME " , CONV_D3D11 , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaD3D11GetDevice " , ( " hipD3D11GetDevice " , CONV_D3D11 , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaD3D11GetDevices " , ( " hipD3D11GetDevices " , CONV_D3D11 , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaGraphicsD3D11RegisterResource " , ( " hipGraphicsD3D11RegisterResource " , CONV_D3D11 , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaD3D11GetDevice " , ( " hipD3D11GetDevice " , CONV_D3D11 , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaD3D11GetDevices " , ( " hipD3D11GetDevices " , CONV_D3D11 , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaGraphicsD3D11RegisterResource " , ( " hipGraphicsD3D11RegisterResource " , CONV_D3D11 , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaGraphicsVDPAURegisterOutputSurface " , ( " hipGraphicsVDPAURegisterOutputSurface " , CONV_VDPAU , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaGraphicsVDPAURegisterVideoSurface " , ( " hipGraphicsVDPAURegisterVideoSurface " , CONV_VDPAU , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaVDPAUGetDevice " , ( " hipVDPAUGetDevice " , CONV_VDPAU , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaVDPAUSetVDPAUDevice " , ( " hipVDPAUSetDevice " , CONV_VDPAU , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaEGLStreamConsumerAcquireFrame " , ( " hipEGLStreamConsumerAcquireFrame " , CONV_EGL , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaEGLStreamConsumerConnect " , ( " hipEGLStreamConsumerConnect " , CONV_EGL , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaEGLStreamConsumerConnectWithFlags " , ( " hipEGLStreamConsumerConnectWithFlags " , CONV_EGL , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaEGLStreamConsumerReleaseFrame " , ( " hipEGLStreamConsumerReleaseFrame " , CONV_EGL , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaEGLStreamProducerConnect " , ( " hipEGLStreamProducerConnect " , CONV_EGL , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaEGLStreamProducerDisconnect " , ( " hipEGLStreamProducerDisconnect " , CONV_EGL , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaEGLStreamProducerPresentFrame " , ( " hipEGLStreamProducerPresentFrame " , CONV_EGL , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaEGLStreamProducerReturnFrame " , ( " hipEGLStreamProducerReturnFrame " , CONV_EGL , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaGraphicsEGLRegisterImage " , ( " hipGraphicsEGLRegisterImage " , CONV_EGL , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cudaGraphicsResourceGetMappedEglFrame " , ( " hipGraphicsResourceGetMappedEglFrame " , CONV_EGL , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasInit " , ( " rocblas_init " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasShutdown " , ( " rocblas_shutdown " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasGetVersion " , ( " rocblas_get_version " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasGetError " , ( " rocblas_get_error " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasAlloc " , ( " rocblas_alloc " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasFree " , ( " rocblas_free " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasSetKernelStream " , ( " rocblas_set_kernel_stream " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasGetAtomicsMode " , ( " rocblas_get_atomics_mode " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasSetAtomicsMode " , ( " rocblas_set_atomics_mode " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasGetMathMode " , ( " rocblas_get_math_mode " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasSetMathMode " , ( " rocblas_set_math_mode " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " CUBLAS_OP_N " , ( " rocblas_operation_none " , CONV_NUMERIC_LITERAL , API_BLAS ) ) , <nl> - ( " CUBLAS_OP_T " , ( " rocblas_operation_transpose " , CONV_NUMERIC_LITERAL , API_BLAS ) ) , <nl> - ( " CUBLAS_OP_C " , ( " rocblas_operation_conjugate_transpose " , CONV_NUMERIC_LITERAL , API_BLAS ) ) , <nl> - ( " CUBLAS_STATUS_SUCCESS " , ( " rocblas_status_success " , CONV_NUMERIC_LITERAL , API_BLAS ) ) , <nl> - ( " CUBLAS_STATUS_NOT_INITIALIZED " , ( " rocblas_status_invalid_handle " , CONV_NUMERIC_LITERAL , API_BLAS ) ) , <nl> - ( " CUBLAS_STATUS_ALLOC_FAILED " , ( " rocblas_status_memory_error " , CONV_NUMERIC_LITERAL , API_BLAS ) ) , <nl> - ( " CUBLAS_STATUS_INVALID_VALUE " , ( " rocblas_status_invalid_pointer " , CONV_NUMERIC_LITERAL , API_BLAS ) ) , <nl> - ( " CUBLAS_STATUS_MAPPING_ERROR " , ( " rocblas_status_internal_error " , CONV_NUMERIC_LITERAL , API_BLAS ) ) , <nl> - ( " CUBLAS_STATUS_EXECUTION_FAILED " , ( " rocblas_status_internal_error " , CONV_NUMERIC_LITERAL , API_BLAS ) ) , <nl> - ( " CUBLAS_STATUS_INTERNAL_ERROR " , ( " rocblas_status_internal_error " , CONV_NUMERIC_LITERAL , API_BLAS ) ) , <nl> - ( " CUBLAS_STATUS_NOT_SUPPORTED " , ( " rocblas_status_not_implemented " , CONV_NUMERIC_LITERAL , API_BLAS ) ) , <nl> - ( " CUBLAS_STATUS_ARCH_MISMATCH " , ( " rocblas_status_not_implemented " , CONV_NUMERIC_LITERAL , API_BLAS ) ) , <nl> - ( " CUBLAS_FILL_MODE_LOWER " , ( " rocblas_fill_lower " , CONV_NUMERIC_LITERAL , API_BLAS ) ) , <nl> - ( " CUBLAS_FILL_MODE_UPPER " , ( " rocblas_fill_upper " , CONV_NUMERIC_LITERAL , API_BLAS ) ) , <nl> - ( " CUBLAS_DIAG_NON_UNIT " , ( " rocblas_diagonal_non_unit " , CONV_NUMERIC_LITERAL , API_BLAS ) ) , <nl> - ( " CUBLAS_DIAG_UNIT " , ( " rocblas_diagonal_unit " , CONV_NUMERIC_LITERAL , API_BLAS ) ) , <nl> - ( " CUBLAS_SIDE_LEFT " , ( " rocblas_side_left " , CONV_NUMERIC_LITERAL , API_BLAS ) ) , <nl> - ( " CUBLAS_SIDE_RIGHT " , ( " rocblas_side_right " , CONV_NUMERIC_LITERAL , API_BLAS ) ) , <nl> - ( " CUBLAS_POINTER_MODE_HOST " , ( " rocblas_pointer_mode_host " , CONV_NUMERIC_LITERAL , API_BLAS ) ) , <nl> - ( " CUBLAS_POINTER_MODE_DEVICE " , ( " rocblas_pointer_mode_device " , CONV_NUMERIC_LITERAL , API_BLAS ) ) , <nl> - ( " CUBLAS_ATOMICS_NOT_ALLOWED " , ( " rocblas_atomics_not_allowed " , CONV_NUMERIC_LITERAL , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " CUBLAS_ATOMICS_ALLOWED " , ( " rocblas_atomics_allowed " , CONV_NUMERIC_LITERAL , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " CUBLAS_DATA_FLOAT " , ( " rocblas_precision_float " , CONV_NUMERIC_LITERAL , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " CUBLAS_DATA_DOUBLE " , ( " rocblas_precision_double " , CONV_NUMERIC_LITERAL , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " CUBLAS_DATA_HALF " , ( " rocblas_precision_half " , CONV_NUMERIC_LITERAL , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " CUBLAS_DATA_INT8 " , ( " rocblas_precision_int8 " , CONV_NUMERIC_LITERAL , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasCreate " , ( " rocblas_create_handle " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> - ( " cublasDestroy " , ( " rocblas_destroy_handle " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> - ( " cublasSetVector " , ( " rocblas_set_vector " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> - ( " cublasGetVector " , ( " rocblas_get_vector " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> - ( " cublasSetVectorAsync " , ( " rocblas_set_vector_async " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasGetVectorAsync " , ( " rocblas_get_vector_async " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasSetMatrix " , ( " rocblas_set_matrix " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> - ( " cublasGetMatrix " , ( " rocblas_get_matrix " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> - ( " cublasGetMatrixAsync " , ( " rocblas_get_matrix_async " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasSetMatrixAsync " , ( " rocblas_set_matrix_async " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasXerbla " , ( " rocblas_xerbla " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasSnrm2 " , ( " rocblas_snrm2 " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> - ( " cublasDnrm2 " , ( " rocblas_dnrm2 " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> - ( " cublasScnrm2 " , ( " rocblas_scnrm2 " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasDznrm2 " , ( " rocblas_dznrm2 " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasNrm2Ex " , ( " rocblas_nrm2_ex " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasSdot " , ( " rocblas_sdot " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> - ( " cublasSdotBatched " , ( " rocblas_sdot_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasDdot " , ( " rocblas_ddot " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> - ( " cublasDdotBatched " , ( " rocblas_ddot_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasCdotu " , ( " rocblas_cdotu " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasCdotc " , ( " rocblas_cdotc " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZdotu " , ( " rocblas_zdotu " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZdotc " , ( " rocblas_zdotc " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasSscal " , ( " rocblas_sscal " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> - ( " cublasSscalBatched " , ( " rocblas_sscal_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasDscal " , ( " rocblas_dscal " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> - ( " cublasDscalBatched " , ( " rocblas_dscal_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasCscal " , ( " rocblas_cscal " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasCsscal " , ( " rocblas_csscal " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZscal " , ( " rocblas_zscal " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZdscal " , ( " rocblas_zdscal " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasSaxpy " , ( " rocblas_saxpy " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> - ( " cublasSaxpyBatched " , ( " rocblas_saxpy_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasDaxpy " , ( " rocblas_daxpy " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> - ( " cublasCaxpy " , ( " rocblas_caxpy " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZaxpy " , ( " rocblas_zaxpy " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasScopy " , ( " rocblas_scopy " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> - ( " cublasScopyBatched " , ( " rocblas_scopy_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasDcopy " , ( " rocblas_dcopy " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> - ( " cublasDcopyBatched " , ( " rocblas_dcopy_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasCcopy " , ( " rocblas_ccopy " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZcopy " , ( " rocblas_zcopy " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasSswap " , ( " rocblas_sswap " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> - ( " cublasDswap " , ( " rocblas_dswap " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> - ( " cublasCswap " , ( " rocblas_cswap " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZswap " , ( " rocblas_zswap " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasIsamax " , ( " rocblas_isamax " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> - ( " cublasIdamax " , ( " rocblas_idamax " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> - ( " cublasIcamax " , ( " rocblas_icamax " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasIzamax " , ( " rocblas_izamax " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasIsamin " , ( " rocblas_isamin " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> - ( " cublasIdamin " , ( " rocblas_idamin " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> - ( " cublasIcamin " , ( " rocblas_icamin " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasIzamin " , ( " rocblas_izamin " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasSasum " , ( " rocblas_sasum " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> - ( " cublasSasumBatched " , ( " rocblas_sasum_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasDasum " , ( " rocblas_dasum " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> - ( " cublasDasumBatched " , ( " rocblas_dasum_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasScasum " , ( " rocblas_scasum " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasDzasum " , ( " rocblas_dzasum " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasSrot " , ( " rocblas_srot " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasDrot " , ( " rocblas_drot " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasCrot " , ( " rocblas_crot " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasCsrot " , ( " rocblas_csrot " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZrot " , ( " rocblas_zrot " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZdrot " , ( " rocblas_zdrot " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasSrotg " , ( " rocblas_srotg " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasDrotg " , ( " rocblas_drotg " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasCrotg " , ( " rocblas_crotg " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZrotg " , ( " rocblas_zrotg " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasSrotm " , ( " rocblas_srotm " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasDrotm " , ( " rocblas_drotm " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasSrotmg " , ( " rocblas_srotmg " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasDrotmg " , ( " rocblas_drotmg " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasSgemv " , ( " rocblas_sgemv " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> - ( " cublasSgemvBatched " , ( " rocblas_sgemv_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasDgemv " , ( " rocblas_dgemv " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> - ( " cublasCgemv " , ( " rocblas_cgemv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZgemv " , ( " rocblas_zgemv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasSgbmv " , ( " rocblas_sgbmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasDgbmv " , ( " rocblas_dgbmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasCgbmv " , ( " rocblas_cgbmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZgbmv " , ( " rocblas_zgbmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasStrmv " , ( " rocblas_strmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasDtrmv " , ( " rocblas_dtrmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasCtrmv " , ( " rocblas_ctrmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZtrmv " , ( " rocblas_ztrmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasStbmv " , ( " rocblas_stbmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasDtbmv " , ( " rocblas_dtbmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasCtbmv " , ( " rocblas_ctbmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZtbmv " , ( " rocblas_ztbmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasStpmv " , ( " rocblas_stpmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasDtpmv " , ( " rocblas_dtpmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasCtpmv " , ( " rocblas_ctpmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZtpmv " , ( " rocblas_ztpmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasStrsv " , ( " rocblas_strsv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasDtrsv " , ( " rocblas_dtrsv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasCtrsv " , ( " rocblas_ctrsv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZtrsv " , ( " rocblas_ztrsv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasStpsv " , ( " rocblas_stpsv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasDtpsv " , ( " rocblas_dtpsv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasCtpsv " , ( " rocblas_ctpsv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZtpsv " , ( " rocblas_ztpsv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasStbsv " , ( " rocblas_stbsv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasDtbsv " , ( " rocblas_dtbsv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasCtbsv " , ( " rocblas_ctbsv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZtbsv " , ( " rocblas_ztbsv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasSsymv " , ( " rocblas_ssymv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasDsymv " , ( " rocblas_dsymv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasCsymv " , ( " rocblas_csymv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZsymv " , ( " rocblas_zsymv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasChemv " , ( " rocblas_chemv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZhemv " , ( " rocblas_zhemv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasSsbmv " , ( " rocblas_ssbmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasDsbmv " , ( " rocblas_dsbmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasChbmv " , ( " rocblas_chbmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZhbmv " , ( " rocblas_zhbmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasSspmv " , ( " rocblas_sspmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasDspmv " , ( " rocblas_dspmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasChpmv " , ( " rocblas_chpmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZhpmv " , ( " rocblas_zhpmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasSger " , ( " rocblas_sger " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> - ( " cublasDger " , ( " rocblas_dger " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> - ( " cublasCgeru " , ( " rocblas_cgeru " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasCgerc " , ( " rocblas_cgerc " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZgeru " , ( " rocblas_zgeru " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZgerc " , ( " rocblas_zgerc " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasSsyr " , ( " rocblas_ssyr " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> - ( " cublasDsyr " , ( " rocblas_dsyr " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> - ( " cublasCher " , ( " rocblas_cher " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZher " , ( " rocblas_zher " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasSspr " , ( " rocblas_sspr " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasDspr " , ( " rocblas_dspr " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasChpr " , ( " rocblas_chpr " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZhpr " , ( " rocblas_zhpr " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasSsyr2 " , ( " rocblas_ssyr2 " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasDsyr2 " , ( " rocblas_dsyr2 " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasCher2 " , ( " rocblas_cher2 " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZher2 " , ( " rocblas_zher2 " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasSspr2 " , ( " rocblas_sspr2 " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasDspr2 " , ( " rocblas_dspr2 " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasChpr2 " , ( " rocblas_chpr2 " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZhpr2 " , ( " rocblas_zhpr2 " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasSgemmBatched " , ( " rocblas_sgemm_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasDgemmBatched " , ( " rocblas_dgemm_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasHgemmBatched " , ( " rocblas_hgemm_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasSgemmStridedBatched " , ( " rocblas_sgemm_strided_batched " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> - ( " cublasDgemmStridedBatched " , ( " rocblas_dgemm_strided_batched " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> - ( " cublasHgemmStridedBatched " , ( " rocblas_hgemm_strided_batched " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> - ( " cublasCgemmBatched " , ( " rocblas_cgemm_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasCgemm3mBatched " , ( " rocblas_cgemm_3m_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZgemmBatched " , ( " rocblas_zgemm_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasCgemmStridedBatched " , ( " rocblas_cgemm_strided_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasCgemm3mStridedBatched " , ( " rocblas_cgemm_3m_strided_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZgemmStridedBatched " , ( " rocblas_zgemm_strided_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasHgemmStridedBatched " , ( " rocblas_hgemm_strided_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasSgemm " , ( " rocblas_sgemm " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> - ( " cublasDgemm " , ( " rocblas_dgemm " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> - ( " cublasCgemm " , ( " rocblas_cgemm " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> - ( " cublasZgemm " , ( " rocblas_zgemm " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasHgemm " , ( " rocblas_hgemm " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> - ( " cublasSsyrk " , ( " rocblas_ssyrk " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasDsyrk " , ( " rocblas_dsyrk " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasCsyrk " , ( " rocblas_csyrk " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZsyrk " , ( " rocblas_zsyrk " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasCherk " , ( " rocblas_cherk " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZherk " , ( " rocblas_zherk " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasSsyr2k " , ( " rocblas_ssyr2k " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasDsyr2k " , ( " rocblas_dsyr2k " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasCsyr2k " , ( " rocblas_csyr2k " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZsyr2k " , ( " rocblas_zyr2k " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasSsyrkx " , ( " rocblas_ssyrkx " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasDsyrkx " , ( " rocblas_dsyrkx " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasCsyrkx " , ( " rocblas_csyrkx " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZsyrkx " , ( " rocblas_zsyrkx " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasCher2k " , ( " rocblas_cher2k " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZher2k " , ( " rocblas_zher2k " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasCherkx " , ( " rocblas_cherkx " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZherkx " , ( " rocblas_zherkx " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasSsymm " , ( " rocblas_ssymm " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasDsymm " , ( " rocblas_dsymm " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasCsymm " , ( " rocblas_csymm " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZsymm " , ( " rocblas_zsymm " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasChemm " , ( " rocblas_chemm " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZhemm " , ( " rocblas_zhemm " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasStrsm " , ( " rocblas_strsm " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> - ( " cublasDtrsm " , ( " rocblas_dtrsm " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> - ( " cublasCtrsm " , ( " rocblas_ctrsm " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZtrsm " , ( " rocblas_ztrsm " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasStrsmBatched " , ( " rocblas_strsm_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasDtrsmBatched " , ( " rocblas_dtrsm_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasCtrsmBatched " , ( " rocblas_ctrsm_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZtrsmBatched " , ( " rocblas_ztrsm_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasStrmm " , ( " rocblas_strmm " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasDtrmm " , ( " rocblas_dtrmm " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasCtrmm " , ( " rocblas_ctrmm " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZtrmm " , ( " rocblas_ztrmm " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasSgeam " , ( " rocblas_sgeam " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> - ( " cublasDgeam " , ( " rocblas_dgeam " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> - ( " cublasCgeam " , ( " rocblas_cgeam " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZgeam " , ( " rocblas_zgeam " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasSgetrfBatched " , ( " rocblas_sgetrf_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasDgetrfBatched " , ( " rocblas_dgetrf_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasCgetrfBatched " , ( " rocblas_cgetrf_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZgetrfBatched " , ( " rocblas_zgetrf_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasSgetriBatched " , ( " rocblas_sgetri_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasDgetriBatched " , ( " rocblas_dgetri_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasCgetriBatched " , ( " rocblas_cgetri_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZgetriBatched " , ( " rocblas_zgetri_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasSgetrsBatched " , ( " rocblas_sgetrs_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasDgetrsBatched " , ( " rocblas_dgetrs_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasCgetrsBatched " , ( " rocblas_cgetrs_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZgetrsBatched " , ( " rocblas_zgetrs_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasStrsmBatched " , ( " rocblas_strsm_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasDtrsmBatched " , ( " rocblas_dtrsm_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasCtrsmBatched " , ( " rocblas_ctrsm_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZtrsmBatched " , ( " rocblas_dtrsm_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasSmatinvBatched " , ( " rocblas_smatinv_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasDmatinvBatched " , ( " rocblas_dmatinv_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasCmatinvBatched " , ( " rocblas_cmatinv_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZmatinvBatched " , ( " rocblas_zmatinv_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasSgeqrfBatched " , ( " rocblas_sgeqrf_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasDgeqrfBatched " , ( " rocblas_dgeqrf_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasCgeqrfBatched " , ( " rocblas_cgeqrf_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZgeqrfBatched " , ( " rocblas_zgeqrf_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasSgelsBatched " , ( " rocblas_sgels_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasDgelsBatched " , ( " rocblas_dgels_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasCgelsBatched " , ( " rocblas_cgels_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZgelsBatched " , ( " rocblas_zgels_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasSdgmm " , ( " rocblas_sdgmm " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasDdgmm " , ( " rocblas_ddgmm " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasCdgmm " , ( " rocblas_cdgmm " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZdgmm " , ( " rocblas_zdgmm " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasStpttr " , ( " rocblas_stpttr " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasDtpttr " , ( " rocblas_dtpttr " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasCtpttr " , ( " rocblas_ctpttr " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZtpttr " , ( " rocblas_ztpttr " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasStrttp " , ( " rocblas_strttp " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasDtrttp " , ( " rocblas_dtrttp " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasCtrttp " , ( " rocblas_ctrttp " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZtrttp " , ( " rocblas_ztrttp " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasCreate_v2 " , ( " rocblas_create_handle " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> - ( " cublasDestroy_v2 " , ( " rocblas_destroy_handle " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> - ( " cublasGetVersion_v2 " , ( " rocblas_get_version " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasSetStream " , ( " rocblas_set_stream " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> - ( " cublasGetStream " , ( " rocblas_get_stream " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> - ( " cublasSetStream_v2 " , ( " rocblas_set_stream " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> - ( " cublasGetStream_v2 " , ( " rocblas_get_stream " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> - ( " cublasGetPointerMode " , ( " rocblas_get_pointer_mode " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> - ( " cublasSetPointerMode " , ( " rocblas_set_pointer_mode " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> - ( " cublasGetPointerMode_v2 " , ( " rocblas_get_pointer_mode " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> - ( " cublasSetPointerMode_v2 " , ( " rocblas_set_pointer_mode " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> - ( " cublasSgemv_v2 " , ( " rocblas_sgemv " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> - ( " cublasDgemv_v2 " , ( " rocblas_dgemv " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> - ( " cublasCgemv_v2 " , ( " rocblas_cgemv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZgemv_v2 " , ( " rocblas_zgemv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasSgbmv_v2 " , ( " rocblas_sgbmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasDgbmv_v2 " , ( " rocblas_dgbmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasCgbmv_v2 " , ( " rocblas_cgbmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZgbmv_v2 " , ( " rocblas_zgbmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasStrmv_v2 " , ( " rocblas_strmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasDtrmv_v2 " , ( " rocblas_dtrmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasCtrmv_v2 " , ( " rocblas_ctrmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZtrmv_v2 " , ( " rocblas_ztrmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasStbmv_v2 " , ( " rocblas_stbmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasDtbmv_v2 " , ( " rocblas_dtbmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasCtbmv_v2 " , ( " rocblas_ctbmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZtbmv_v2 " , ( " rocblas_ztbmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasStpmv_v2 " , ( " rocblas_stpmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasDtpmv_v2 " , ( " rocblas_dtpmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasCtpmv_v2 " , ( " rocblas_ctpmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZtpmv_v2 " , ( " rocblas_ztpmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasStrsv_v2 " , ( " rocblas_strsv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasDtrsv_v2 " , ( " rocblas_dtrsv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasCtrsv_v2 " , ( " rocblas_ctrsv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZtrsv_v2 " , ( " rocblas_ztrsv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasStpsv_v2 " , ( " rocblas_stpsv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasDtpsv_v2 " , ( " rocblas_dtpsv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasCtpsv_v2 " , ( " rocblas_ctpsv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZtpsv_v2 " , ( " rocblas_ztpsv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasStbsv_v2 " , ( " rocblas_stbsv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasDtbsv_v2 " , ( " rocblas_dtbsv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasCtbsv_v2 " , ( " rocblas_ctbsv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZtbsv_v2 " , ( " rocblas_ztbsv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasSsymv_v2 " , ( " rocblas_ssymv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasDsymv_v2 " , ( " rocblas_dsymv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasCsymv_v2 " , ( " rocblas_csymv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZsymv_v2 " , ( " rocblas_zsymv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasChemv_v2 " , ( " rocblas_chemv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZhemv_v2 " , ( " rocblas_zhemv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasSsbmv_v2 " , ( " rocblas_ssbmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasDsbmv_v2 " , ( " rocblas_dsbmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasChbmv_v2 " , ( " rocblas_chbmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZhbmv_v2 " , ( " rocblas_zhbmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasSspmv_v2 " , ( " rocblas_sspmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasDspmv_v2 " , ( " rocblas_dspmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasChpmv_v2 " , ( " rocblas_chpmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZhpmv_v2 " , ( " rocblas_zhpmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasSger_v2 " , ( " rocblas_sger " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> - ( " cublasDger_v2 " , ( " rocblas_dger " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> - ( " cublasCgeru_v2 " , ( " rocblas_cgeru " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasCgerc_v2 " , ( " rocblas_cergc " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZgeru_v2 " , ( " rocblas_zgeru " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZgerc_v2 " , ( " rocblas_zgerc " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasSsyr_v2 " , ( " rocblas_ssyr " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasDsyr_v2 " , ( " rocblas_dsyr " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasCsyr_v2 " , ( " rocblas_csyr " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZsyr_v2 " , ( " rocblas_zsyr " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasCher_v2 " , ( " rocblas_cher " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZher_v2 " , ( " rocblas_zher " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasSspr_v2 " , ( " rocblas_sspr " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasDspr_v2 " , ( " rocblas_dspr " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasChpr_v2 " , ( " rocblas_chpr " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZhpr_v2 " , ( " rocblas_zhpr " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasSsyr2_v2 " , ( " rocblas_ssyr2 " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasDsyr2_v2 " , ( " rocblas_dsyr2 " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasCsyr2_v2 " , ( " rocblas_csyr2 " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZsyr2_v2 " , ( " rocblas_zsyr2 " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasCher2_v2 " , ( " rocblas_cher2 " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZher2_v2 " , ( " rocblas_zher2 " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasSspr2_v2 " , ( " rocblas_sspr2 " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasDspr2_v2 " , ( " rocblas_dspr2 " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasChpr2_v2 " , ( " rocblas_chpr2 " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZhpr2_v2 " , ( " rocblas_zhpr2 " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasSgemm_v2 " , ( " rocblas_sgemm " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> - ( " cublasDgemm_v2 " , ( " rocblas_dgemm " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> - ( " cublasCgemm_v2 " , ( " rocblas_cgemm " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasCgemm3m " , ( " rocblas_cgemm_3m " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasCgemm3mEx " , ( " rocblas_cgemm_3mex " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZgemm_v2 " , ( " rocblas_zgemm " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZgemm3m " , ( " rocblas_zgemm_3m " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - # NB : The function rocblas_sgemmex doesn ' t actually exist in <nl> - # rocblas , as of 2018 - 12 - 05 <nl> - ( " cublasSgemmEx " , ( " rocblas_sgemmex " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasGemmEx " , ( " rocblas_gemmex " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasCgemmEx " , ( " rocblas_cgemmex " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasUint8gemmBias " , ( " rocblas_uint8gemmbias " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasSsyrk_v2 " , ( " rocblas_ssyrk " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasDsyrk_v2 " , ( " rocblas_dsyrk " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasCsyrk_v2 " , ( " rocblas_csyrk " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZsyrk_v2 " , ( " rocblas_zsyrk " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasCsyrkEx " , ( " rocblas_csyrkex " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasCsyrk3mEx " , ( " rocblas_csyrk3mex " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasCherk_v2 " , ( " rocblas_cherk " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasCherkEx " , ( " rocblas_cherkex " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasCherk3mEx " , ( " rocblas_cherk3mex " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZherk_v2 " , ( " rocblas_zherk " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasSsyr2k_v2 " , ( " rocblas_ssyr2k " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasDsyr2k_v2 " , ( " rocblas_dsyr2k " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasCsyr2k_v2 " , ( " rocblas_csyr2k " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZsyr2k_v2 " , ( " rocblas_zsyr2k " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasCher2k_v2 " , ( " rocblas_cher2k " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZher2k_v2 " , ( " rocblas_zher2k " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasSsymm_v2 " , ( " rocblas_ssymm " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasDsymm_v2 " , ( " rocblas_dsymm " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasCsymm_v2 " , ( " rocblas_csymm " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZsymm_v2 " , ( " rocblas_zsymm " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasChemm_v2 " , ( " rocblas_chemm " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZhemm_v2 " , ( " rocblas_zhemm " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasStrsm_v2 " , ( " rocblas_strsm " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasDtrsm_v2 " , ( " rocblas_dtrsm " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasCtrsm_v2 " , ( " rocblas_ctrsm " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZtrsm_v2 " , ( " rocblas_ztrsm " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasStrmm_v2 " , ( " rocblas_strmm " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasDtrmm_v2 " , ( " rocblas_dtrmm " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasCtrmm_v2 " , ( " rocblas_ctrmm " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZtrmm_v2 " , ( " rocblas_ztrmm " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasSnrm2_v2 " , ( " rocblas_snrm2 " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> - ( " cublasDnrm2_v2 " , ( " rocblas_dnrm2 " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> - ( " cublasScnrm2_v2 " , ( " rocblas_scnrm2 " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasDznrm2_v2 " , ( " rocblas_dznrm2 " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasDotEx " , ( " rocblas_dotex " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasDotcEx " , ( " rocblas_dotcex " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasSdot_v2 " , ( " rocblas_sdot " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> - ( " cublasDdot_v2 " , ( " rocblas_ddot " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> - ( " cublasCdotu_v2 " , ( " rocblas_cdotu " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasCdotc_v2 " , ( " rocblas_cdotc " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZdotu_v2 " , ( " rocblas_zdotu " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZdotc_v2 " , ( " rocblas_zdotc " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasScalEx " , ( " rocblas_scalex " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasSscal_v2 " , ( " rocblas_sscal " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> - ( " cublasDscal_v2 " , ( " rocblas_dscal " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> - ( " cublasCscal_v2 " , ( " rocblas_cscal " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasCsscal_v2 " , ( " rocblas_csscal " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZscal_v2 " , ( " rocblas_zcsal " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZdscal_v2 " , ( " rocblas_zdscal " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasAxpyEx " , ( " rocblas_axpyex " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasSaxpy_v2 " , ( " rocblas_saxpy " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> - ( " cublasDaxpy_v2 " , ( " rocblas_daxpy " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> - ( " cublasCaxpy_v2 " , ( " rocblas_caxpy " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZaxpy_v2 " , ( " rocblas_zaxpy " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasScopy_v2 " , ( " rocblas_scopy " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> - ( " cublasDcopy_v2 " , ( " rocblas_dcopy " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> - ( " cublasCcopy_v2 " , ( " rocblas_ccopy " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZcopy_v2 " , ( " rocblas_zcopy " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasSswap_v2 " , ( " rocblas_sswap " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> - ( " cublasDswap_v2 " , ( " rocblas_dswap " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> - ( " cublasCswap_v2 " , ( " rocblas_cswap " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZswap_v2 " , ( " rocblas_zswap " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasIsamax_v2 " , ( " rocblas_isamax " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> - ( " cublasIdamax_v2 " , ( " rocblas_idamax " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> - ( " cublasIcamax_v2 " , ( " rocblas_icamax " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasIzamax_v2 " , ( " rocblas_izamax " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasIsamin_v2 " , ( " rocblas_isamin " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> - ( " cublasIdamin_v2 " , ( " rocblas_idamin " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> - ( " cublasIcamin_v2 " , ( " rocblas_icamin " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasIzamin_v2 " , ( " rocblas_izamin " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasSasum_v2 " , ( " rocblas_sasum " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> - ( " cublasDasum_v2 " , ( " rocblas_dasum " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> - ( " cublasScasum_v2 " , ( " rocblas_scasum " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasDzasum_v2 " , ( " rocblas_dzasum " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasSrot_v2 " , ( " rocblas_srot " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasDrot_v2 " , ( " rocblas_drot " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasCrot_v2 " , ( " rocblas_crot " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasCsrot_v2 " , ( " rocblas_csrot " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZrot_v2 " , ( " rocblas_zrot " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZdrot_v2 " , ( " rocblas_zdrot " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasSrotg_v2 " , ( " rocblas_srotg " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasDrotg_v2 " , ( " rocblas_drotg " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasCrotg_v2 " , ( " rocblas_crotg " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasZrotg_v2 " , ( " rocblas_zrotg " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasSrotm_v2 " , ( " rocblas_srotm " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasDrotm_v2 " , ( " rocblas_drotm " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasSrotmg_v2 " , ( " rocblas_srotmg " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cublasDrotmg_v2 " , ( " rocblas_drotmg " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " CURAND_STATUS_SUCCESS " , ( " HIPRAND_STATUS_SUCCESS " , CONV_NUMERIC_LITERAL , API_RAND ) ) , <nl> - ( " CURAND_STATUS_VERSION_MISMATCH " , ( " HIPRAND_STATUS_VERSION_MISMATCH " , CONV_NUMERIC_LITERAL , API_RAND ) ) , <nl> - ( " CURAND_STATUS_NOT_INITIALIZED " , ( " HIPRAND_STATUS_NOT_INITIALIZED " , CONV_NUMERIC_LITERAL , API_RAND ) ) , <nl> - ( " CURAND_STATUS_ALLOCATION_FAILED " , ( " HIPRAND_STATUS_ALLOCATION_FAILED " , CONV_NUMERIC_LITERAL , API_RAND ) ) , <nl> - ( " CURAND_STATUS_TYPE_ERROR " , ( " HIPRAND_STATUS_TYPE_ERROR " , CONV_NUMERIC_LITERAL , API_RAND ) ) , <nl> - ( " CURAND_STATUS_OUT_OF_RANGE " , ( " HIPRAND_STATUS_OUT_OF_RANGE " , CONV_NUMERIC_LITERAL , API_RAND ) ) , <nl> - ( " CURAND_STATUS_LENGTH_NOT_MULTIPLE " , ( " HIPRAND_STATUS_LENGTH_NOT_MULTIPLE " , CONV_NUMERIC_LITERAL , API_RAND ) ) , <nl> - ( " CURAND_STATUS_DOUBLE_PRECISION_REQUIRED " , ( " HIPRAND_STATUS_DOUBLE_PRECISION_REQUIRED " , CONV_NUMERIC_LITERAL , API_RAND ) ) , <nl> - ( " CURAND_STATUS_LAUNCH_FAILURE " , ( " HIPRAND_STATUS_LAUNCH_FAILURE " , CONV_NUMERIC_LITERAL , API_RAND ) ) , <nl> - ( " CURAND_STATUS_PREEXISTING_FAILURE " , ( " HIPRAND_STATUS_PREEXISTING_FAILURE " , CONV_NUMERIC_LITERAL , API_RAND ) ) , <nl> - ( " CURAND_STATUS_INITIALIZATION_FAILED " , ( " HIPRAND_STATUS_INITIALIZATION_FAILED " , CONV_NUMERIC_LITERAL , API_RAND ) ) , <nl> - ( " CURAND_STATUS_ARCH_MISMATCH " , ( " HIPRAND_STATUS_ARCH_MISMATCH " , CONV_NUMERIC_LITERAL , API_RAND ) ) , <nl> - ( " CURAND_STATUS_INTERNAL_ERROR " , ( " HIPRAND_STATUS_INTERNAL_ERROR " , CONV_NUMERIC_LITERAL , API_RAND ) ) , <nl> - ( " CURAND_RNG_TEST " , ( " HIPRAND_RNG_TEST " , CONV_NUMERIC_LITERAL , API_RAND ) ) , <nl> - ( " mtgp32dc_params_fast_11213 " , ( " mtgp32dc_params_fast_11213 " , CONV_NUMERIC_LITERAL , API_RAND ) ) , <nl> - ( " CURAND_RNG_PSEUDO_DEFAULT " , ( " HIPRAND_RNG_PSEUDO_DEFAULT " , CONV_NUMERIC_LITERAL , API_RAND ) ) , <nl> - ( " CURAND_RNG_PSEUDO_XORWOW " , ( " HIPRAND_RNG_PSEUDO_XORWOW " , CONV_NUMERIC_LITERAL , API_RAND ) ) , <nl> - ( " CURAND_RNG_PSEUDO_MRG32K3A " , ( " HIPRAND_RNG_PSEUDO_MRG32K3A " , CONV_NUMERIC_LITERAL , API_RAND ) ) , <nl> - ( " CURAND_RNG_PSEUDO_MTGP32 " , ( " HIPRAND_RNG_PSEUDO_MTGP32 " , CONV_NUMERIC_LITERAL , API_RAND ) ) , <nl> - ( " CURAND_RNG_PSEUDO_MT19937 " , ( " HIPRAND_RNG_PSEUDO_MT19937 " , CONV_NUMERIC_LITERAL , API_RAND ) ) , <nl> - ( " CURAND_RNG_PSEUDO_PHILOX4_32_10 " , ( " HIPRAND_RNG_PSEUDO_PHILOX4_32_10 " , CONV_NUMERIC_LITERAL , API_RAND ) ) , <nl> - ( " CURAND_RNG_QUASI_DEFAULT " , ( " HIPRAND_RNG_QUASI_DEFAULT " , CONV_NUMERIC_LITERAL , API_RAND ) ) , <nl> - ( " CURAND_RNG_QUASI_SOBOL32 " , ( " HIPRAND_RNG_QUASI_SOBOL32 " , CONV_NUMERIC_LITERAL , API_RAND ) ) , <nl> - ( " CURAND_RNG_QUASI_SCRAMBLED_SOBOL32 " , ( " HIPRAND_RNG_QUASI_SCRAMBLED_SOBOL32 " , CONV_NUMERIC_LITERAL , API_RAND ) ) , <nl> - ( " CURAND_RNG_QUASI_SOBOL64 " , ( " HIPRAND_RNG_QUASI_SOBOL64 " , CONV_NUMERIC_LITERAL , API_RAND ) ) , <nl> - ( " CURAND_RNG_QUASI_SCRAMBLED_SOBOL64 " , ( " HIPRAND_RNG_QUASI_SCRAMBLED_SOBOL64 " , CONV_NUMERIC_LITERAL , API_RAND ) ) , <nl> - ( " curand_ORDERING_PSEUDO_BEST " , ( " HIPRAND_ORDERING_PSEUDO_BEST " , CONV_NUMERIC_LITERAL , API_RAND , HIP_UNSUPPORTED ) ) , <nl> - ( " curand_ORDERING_PSEUDO_DEFAULT " , ( " HIPRAND_ORDERING_PSEUDO_DEFAULT " , CONV_NUMERIC_LITERAL , API_RAND , HIP_UNSUPPORTED ) ) , <nl> - ( " curand_ORDERING_PSEUDO_SEEDED " , ( " HIPRAND_ORDERING_PSEUDO_SEEDED " , CONV_NUMERIC_LITERAL , API_RAND , HIP_UNSUPPORTED ) ) , <nl> - ( " curand_ORDERING_QUASI_DEFAULT " , ( " HIPRAND_ORDERING_QUASI_DEFAULT " , CONV_NUMERIC_LITERAL , API_RAND , HIP_UNSUPPORTED ) ) , <nl> - ( " curand_DIRECTION_VECTORS_32_JOEKUO6 " , ( " HIPRAND_DIRECTION_VECTORS_32_JOEKUO6 " , CONV_NUMERIC_LITERAL , API_RAND , HIP_UNSUPPORTED ) ) , <nl> - ( " curand_SCRAMBLED_DIRECTION_VECTORS_32_JOEKUO6 " , ( " HIPRAND_SCRAMBLED_DIRECTION_VECTORS_32_JOEKUO6 " , CONV_NUMERIC_LITERAL , API_RAND , HIP_UNSUPPORTED ) ) , <nl> - ( " curand_DIRECTION_VECTORS_64_JOEKUO6 " , ( " HIPRAND_DIRECTION_VECTORS_64_JOEKUO6 " , CONV_NUMERIC_LITERAL , API_RAND , HIP_UNSUPPORTED ) ) , <nl> - ( " curand_SCRAMBLED_DIRECTION_VECTORS_64_JOEKUO6 " , ( " HIPRAND_SCRAMBLED_DIRECTION_VECTORS_64_JOEKUO6 " , CONV_NUMERIC_LITERAL , API_RAND , HIP_UNSUPPORTED ) ) , <nl> - ( " curand_CHOOSE_BEST " , ( " HIPRAND_CHOOSE_BEST " , CONV_NUMERIC_LITERAL , API_RAND , HIP_UNSUPPORTED ) ) , <nl> - ( " curand_ITR " , ( " HIPRAND_ITR " , CONV_NUMERIC_LITERAL , API_RAND , HIP_UNSUPPORTED ) ) , <nl> - ( " curand_KNUTH " , ( " HIPRAND_KNUTH " , CONV_NUMERIC_LITERAL , API_RAND , HIP_UNSUPPORTED ) ) , <nl> - ( " curand_HITR " , ( " HIPRAND_HITR " , CONV_NUMERIC_LITERAL , API_RAND , HIP_UNSUPPORTED ) ) , <nl> - ( " curand_M1 " , ( " HIPRAND_M1 " , CONV_NUMERIC_LITERAL , API_RAND , HIP_UNSUPPORTED ) ) , <nl> - ( " curand_M2 " , ( " HIPRAND_M2 " , CONV_NUMERIC_LITERAL , API_RAND , HIP_UNSUPPORTED ) ) , <nl> - ( " curand_BINARY_SEARCH " , ( " HIPRAND_BINARY_SEARCH " , CONV_NUMERIC_LITERAL , API_RAND , HIP_UNSUPPORTED ) ) , <nl> - ( " curand_DISCRETE_GAUSS " , ( " HIPRAND_DISCRETE_GAUSS " , CONV_NUMERIC_LITERAL , API_RAND , HIP_UNSUPPORTED ) ) , <nl> - ( " curand_REJECTION " , ( " HIPRAND_REJECTION " , CONV_NUMERIC_LITERAL , API_RAND , HIP_UNSUPPORTED ) ) , <nl> - ( " curand_DEVICE_API " , ( " HIPRAND_DEVICE_API " , CONV_NUMERIC_LITERAL , API_RAND , HIP_UNSUPPORTED ) ) , <nl> - ( " curand_FAST_REJECTION " , ( " HIPRAND_FAST_REJECTION " , CONV_NUMERIC_LITERAL , API_RAND , HIP_UNSUPPORTED ) ) , <nl> - ( " curand_3RD " , ( " HIPRAND_3RD " , CONV_NUMERIC_LITERAL , API_RAND , HIP_UNSUPPORTED ) ) , <nl> - ( " curand_DEFINITION " , ( " HIPRAND_DEFINITION " , CONV_NUMERIC_LITERAL , API_RAND , HIP_UNSUPPORTED ) ) , <nl> - ( " curand_POISSON " , ( " HIPRAND_POISSON " , CONV_NUMERIC_LITERAL , API_RAND , HIP_UNSUPPORTED ) ) , <nl> - ( " curandCreateGenerator " , ( " hiprandCreateGenerator " , CONV_MATH_FUNC , API_RAND ) ) , <nl> - ( " curandCreateGeneratorHost " , ( " hiprandCreateGeneratorHost " , CONV_MATH_FUNC , API_RAND ) ) , <nl> - ( " curandCreatePoissonDistribution " , ( " hiprandCreatePoissonDistribution " , CONV_MATH_FUNC , API_RAND ) ) , <nl> - ( " curandDestroyDistribution " , ( " hiprandDestroyDistribution " , CONV_MATH_FUNC , API_RAND ) ) , <nl> - ( " curandDestroyGenerator " , ( " hiprandDestroyGenerator " , CONV_MATH_FUNC , API_RAND ) ) , <nl> - ( " curandGenerate " , ( " hiprandGenerate " , CONV_MATH_FUNC , API_RAND ) ) , <nl> - ( " curandGenerateLogNormal " , ( " hiprandGenerateLogNormal " , CONV_MATH_FUNC , API_RAND ) ) , <nl> - ( " curandGenerateLogNormalDouble " , ( " hiprandGenerateLogNormalDouble " , CONV_MATH_FUNC , API_RAND ) ) , <nl> - ( " curandGenerateLongLong " , ( " hiprandGenerateLongLong " , CONV_MATH_FUNC , API_RAND , HIP_UNSUPPORTED ) ) , <nl> - ( " curandGenerateNormal " , ( " hiprandGenerateNormal " , CONV_MATH_FUNC , API_RAND ) ) , <nl> - ( " curandGenerateNormalDouble " , ( " hiprandGenerateNormalDouble " , CONV_MATH_FUNC , API_RAND ) ) , <nl> - ( " curandGeneratePoisson " , ( " hiprandGeneratePoisson " , CONV_MATH_FUNC , API_RAND ) ) , <nl> - ( " curandGenerateSeeds " , ( " hiprandGenerateSeeds " , CONV_MATH_FUNC , API_RAND ) ) , <nl> - ( " curandGenerateUniform " , ( " hiprandGenerateUniform " , CONV_MATH_FUNC , API_RAND ) ) , <nl> - ( " curandGenerateUniformDouble " , ( " hiprandGenerateUniformDouble " , CONV_MATH_FUNC , API_RAND ) ) , <nl> - ( " curandGetDirectionVectors32 " , ( " hiprandGetDirectionVectors32 " , CONV_MATH_FUNC , API_RAND , HIP_UNSUPPORTED ) ) , <nl> - ( " curandGetDirectionVectors64 " , ( " hiprandGetDirectionVectors64 " , CONV_MATH_FUNC , API_RAND , HIP_UNSUPPORTED ) ) , <nl> - ( " curandGetProperty " , ( " hiprandGetProperty " , CONV_MATH_FUNC , API_RAND , HIP_UNSUPPORTED ) ) , <nl> - ( " curandGetScrambleConstants32 " , ( " hiprandGetScrambleConstants32 " , CONV_MATH_FUNC , API_RAND , HIP_UNSUPPORTED ) ) , <nl> - ( " curandGetScrambleConstants64 " , ( " hiprandGetScrambleConstants64 " , CONV_MATH_FUNC , API_RAND , HIP_UNSUPPORTED ) ) , <nl> - ( " curandGetVersion " , ( " hiprandGetVersion " , CONV_MATH_FUNC , API_RAND ) ) , <nl> - ( " curandSetGeneratorOffset " , ( " hiprandSetGeneratorOffset " , CONV_MATH_FUNC , API_RAND ) ) , <nl> - ( " curandSetGeneratorOrdering " , ( " hiprandSetGeneratorOrdering " , CONV_MATH_FUNC , API_RAND , HIP_UNSUPPORTED ) ) , <nl> - ( " curandSetPseudoRandomGeneratorSeed " , ( " hiprandSetPseudoRandomGeneratorSeed " , CONV_MATH_FUNC , API_RAND ) ) , <nl> - ( " curandSetQuasiRandomGeneratorDimensions " , ( " hiprandSetQuasiRandomGeneratorDimensions " , CONV_MATH_FUNC , API_RAND ) ) , <nl> - ( " curandSetStream " , ( " hiprandSetStream " , CONV_MATH_FUNC , API_RAND ) ) , <nl> - ( " curand " , ( " hiprand " , CONV_DEVICE_FUNC , API_RAND ) ) , <nl> - ( " curand4 " , ( " hiprand4 " , CONV_DEVICE_FUNC , API_RAND ) ) , <nl> - ( " curand_init " , ( " hiprand_init " , CONV_DEVICE_FUNC , API_RAND ) ) , <nl> - ( " curand_log_normal " , ( " hiprand_log_normal " , CONV_DEVICE_FUNC , API_RAND ) ) , <nl> - ( " curand_log_normal_double " , ( " hiprand_log_normal_double " , CONV_DEVICE_FUNC , API_RAND ) ) , <nl> - ( " curand_log_normal2 " , ( " hiprand_log_normal2 " , CONV_DEVICE_FUNC , API_RAND ) ) , <nl> - ( " curand_log_normal2_double " , ( " hiprand_log_normal2_double " , CONV_DEVICE_FUNC , API_RAND ) ) , <nl> - ( " curand_log_normal4 " , ( " hiprand_log_normal4 " , CONV_DEVICE_FUNC , API_RAND ) ) , <nl> - ( " curand_log_normal4_double " , ( " hiprand_log_normal4_double " , CONV_DEVICE_FUNC , API_RAND ) ) , <nl> - ( " curand_mtgp32_single " , ( " hiprand_mtgp32_single " , CONV_DEVICE_FUNC , API_RAND , HIP_UNSUPPORTED ) ) , <nl> - ( " curand_mtgp32_single_specific " , ( " hiprand_mtgp32_single_specific " , CONV_DEVICE_FUNC , API_RAND , HIP_UNSUPPORTED ) ) , <nl> - ( " curand_mtgp32_specific " , ( " hiprand_mtgp32_specific " , CONV_DEVICE_FUNC , API_RAND , HIP_UNSUPPORTED ) ) , <nl> - ( " curand_normal " , ( " hiprand_normal " , CONV_DEVICE_FUNC , API_RAND ) ) , <nl> - ( " curandMakeMTGP32Constants " , ( " hiprandMakeMTGP32Constants " , CONV_DEVICE_FUNC , API_RAND ) ) , <nl> - ( " curandMakeMTGP32KernelState " , ( " hiprandMakeMTGP32KernelState " , CONV_DEVICE_FUNC , API_RAND ) ) , <nl> - ( " curand_normal_double " , ( " hiprand_normal_double " , CONV_DEVICE_FUNC , API_RAND ) ) , <nl> - ( " curand_normal2 " , ( " hiprand_normal2 " , CONV_DEVICE_FUNC , API_RAND ) ) , <nl> - ( " curand_normal2_double " , ( " hiprand_normal2_double " , CONV_DEVICE_FUNC , API_RAND ) ) , <nl> - ( " curand_normal4 " , ( " hiprand_normal4 " , CONV_DEVICE_FUNC , API_RAND ) ) , <nl> - ( " curand_normal4_double " , ( " hiprand_normal4_double " , CONV_DEVICE_FUNC , API_RAND ) ) , <nl> - ( " curand_uniform " , ( " hiprand_uniform " , CONV_DEVICE_FUNC , API_RAND ) ) , <nl> - ( " curand_uniform_double " , ( " hiprand_uniform_double " , CONV_DEVICE_FUNC , API_RAND ) ) , <nl> - ( " curand_uniform2_double " , ( " hiprand_uniform2_double " , CONV_DEVICE_FUNC , API_RAND ) ) , <nl> - ( " curand_uniform4 " , ( " hiprand_uniform4 " , CONV_DEVICE_FUNC , API_RAND ) ) , <nl> - ( " curand_uniform4_double " , ( " hiprand_uniform4_double " , CONV_DEVICE_FUNC , API_RAND ) ) , <nl> - ( " curand_discrete " , ( " hiprand_discrete " , CONV_DEVICE_FUNC , API_RAND ) ) , <nl> - ( " curand_discrete4 " , ( " hiprand_discrete4 " , CONV_DEVICE_FUNC , API_RAND ) ) , <nl> - ( " curand_poisson " , ( " hiprand_poisson " , CONV_DEVICE_FUNC , API_RAND ) ) , <nl> - ( " curand_poisson4 " , ( " hiprand_poisson4 " , CONV_DEVICE_FUNC , API_RAND ) ) , <nl> - ( " curand_Philox4x32_10 " , ( " hiprand_Philox4x32_10 " , CONV_DEVICE_FUNC , API_RAND , HIP_UNSUPPORTED ) ) , <nl> - ( " mtgp32_kernel_params " , ( " mtgp32_kernel_params_t " , CONV_MATH_FUNC , API_RAND ) ) , <nl> - ( " CUFFT_FORWARD " , ( " HIPFFT_FORWARD " , CONV_NUMERIC_LITERAL , API_BLAS ) ) , <nl> - ( " CUFFT_INVERSE " , ( " HIPFFT_BACKWARD " , CONV_NUMERIC_LITERAL , API_BLAS ) ) , <nl> - ( " CUFFT_COMPATIBILITY_DEFAULT " , ( " HIPFFT_COMPATIBILITY_DEFAULT " , CONV_NUMERIC_LITERAL , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> - ( " cufftResult_t " , ( " hipfftResult_t " , CONV_TYPE , API_FFT ) ) , <nl> - ( " cufftResult " , ( " hipfftResult " , CONV_TYPE , API_FFT ) ) , <nl> - ( " CUFFT_SUCCESS " , ( " HIPFFT_SUCCESS " , CONV_NUMERIC_LITERAL , API_FFT ) ) , <nl> - ( " CUFFT_INVALID_PLAN " , ( " HIPFFT_INVALID_PLAN " , CONV_NUMERIC_LITERAL , API_FFT ) ) , <nl> - ( " CUFFT_ALLOC_FAILED " , ( " HIPFFT_ALLOC_FAILED " , CONV_NUMERIC_LITERAL , API_FFT ) ) , <nl> - ( " CUFFT_INVALID_TYPE " , ( " HIPFFT_INVALID_TYPE " , CONV_NUMERIC_LITERAL , API_FFT ) ) , <nl> - ( " CUFFT_INVALID_VALUE " , ( " HIPFFT_INVALID_VALUE " , CONV_NUMERIC_LITERAL , API_FFT ) ) , <nl> - ( " CUFFT_INTERNAL_ERROR " , ( " HIPFFT_INTERNAL_ERROR " , CONV_NUMERIC_LITERAL , API_FFT ) ) , <nl> - ( " CUFFT_EXEC_FAILED " , ( " HIPFFT_EXEC_FAILED " , CONV_NUMERIC_LITERAL , API_FFT ) ) , <nl> - ( " CUFFT_SETUP_FAILED " , ( " HIPFFT_SETUP_FAILED " , CONV_NUMERIC_LITERAL , API_FFT ) ) , <nl> - ( " CUFFT_INVALID_SIZE " , ( " HIPFFT_INVALID_SIZE " , CONV_NUMERIC_LITERAL , API_FFT ) ) , <nl> - ( " CUFFT_UNALIGNED_DATA " , ( " HIPFFT_UNALIGNED_DATA " , CONV_NUMERIC_LITERAL , API_FFT ) ) , <nl> - ( " CUFFT_INCOMPLETE_PARAMETER_LIST " , ( " HIPFFT_INCOMPLETE_PARAMETER_LIST " , CONV_NUMERIC_LITERAL , API_FFT ) ) , <nl> - ( " CUFFT_INVALID_DEVICE " , ( " HIPFFT_INVALID_DEVICE " , CONV_NUMERIC_LITERAL , API_FFT ) ) , <nl> - ( " CUFFT_PARSE_ERROR " , ( " HIPFFT_PARSE_ERROR " , CONV_NUMERIC_LITERAL , API_FFT ) ) , <nl> - ( " CUFFT_NO_WORKSPACE " , ( " HIPFFT_NO_WORKSPACE " , CONV_NUMERIC_LITERAL , API_FFT ) ) , <nl> - ( " CUFFT_NOT_IMPLEMENTED " , ( " HIPFFT_NOT_IMPLEMENTED " , CONV_NUMERIC_LITERAL , API_FFT ) ) , <nl> - ( " CUFFT_LICENSE_ERROR " , ( " HIPFFT_LICENSE_ERROR " , CONV_NUMERIC_LITERAL , API_FFT , HIP_UNSUPPORTED ) ) , <nl> - ( " CUFFT_NOT_SUPPORTED " , ( " HIPFFT_NOT_SUPPORTED " , CONV_NUMERIC_LITERAL , API_FFT ) ) , <nl> - ( " cufftType_t " , ( " hipfftType_t " , CONV_TYPE , API_FFT ) ) , <nl> - ( " cufftType " , ( " hipfftType " , CONV_TYPE , API_FFT ) ) , <nl> - ( " CUFFT_R2C " , ( " HIPFFT_R2C " , CONV_NUMERIC_LITERAL , API_FFT ) ) , <nl> - ( " CUFFT_C2R " , ( " HIPFFT_C2R " , CONV_NUMERIC_LITERAL , API_FFT ) ) , <nl> - ( " CUFFT_C2C " , ( " HIPFFT_C2C " , CONV_NUMERIC_LITERAL , API_FFT ) ) , <nl> - ( " CUFFT_D2Z " , ( " HIPFFT_D2Z " , CONV_NUMERIC_LITERAL , API_FFT ) ) , <nl> - ( " CUFFT_Z2D " , ( " HIPFFT_Z2D " , CONV_NUMERIC_LITERAL , API_FFT ) ) , <nl> - ( " CUFFT_Z2Z " , ( " HIPFFT_Z2Z " , CONV_NUMERIC_LITERAL , API_FFT ) ) , <nl> - ( " cufftCompatibility_t " , ( " hipfftCompatibility_t " , CONV_TYPE , API_FFT , HIP_UNSUPPORTED ) ) , <nl> - ( " cufftCompatibility " , ( " hipfftCompatibility " , CONV_TYPE , API_FFT , HIP_UNSUPPORTED ) ) , <nl> - ( " CUFFT_COMPATIBILITY_FFTW_PADDING " , ( " HIPFFT_COMPATIBILITY_FFTW_PADDING " , CONV_NUMERIC_LITERAL , API_FFT , HIP_UNSUPPORTED ) ) , <nl> - ( " cufftReal " , ( " hipfftReal " , CONV_TYPE , API_FFT ) ) , <nl> - ( " cufftDoubleReal " , ( " hipfftDoubleReal " , CONV_TYPE , API_FFT ) ) , <nl> - ( " cufftComplex " , ( " hipfftComplex " , CONV_TYPE , API_FFT ) ) , <nl> - ( " cufftDoubleComplex " , ( " hipfftDoubleComplex " , CONV_TYPE , API_FFT ) ) , <nl> - ( " cufftHandle " , ( " hipfftHandle " , CONV_TYPE , API_FFT ) ) , <nl> - ( " cufftPlan1d " , ( " hipfftPlan1d " , CONV_MATH_FUNC , API_FFT ) ) , <nl> - ( " cufftPlan2d " , ( " hipfftPlan2d " , CONV_MATH_FUNC , API_FFT ) ) , <nl> - ( " cufftPlan3d " , ( " hipfftPlan3d " , CONV_MATH_FUNC , API_FFT ) ) , <nl> - ( " cufftPlanMany " , ( " hipfftPlanMany " , CONV_MATH_FUNC , API_FFT ) ) , <nl> - ( " cufftMakePlan1d " , ( " hipfftMakePlan1d " , CONV_MATH_FUNC , API_FFT ) ) , <nl> - ( " cufftMakePlan2d " , ( " hipfftMakePlan2d " , CONV_MATH_FUNC , API_FFT ) ) , <nl> - ( " cufftMakePlan3d " , ( " hipfftMakePlan3d " , CONV_MATH_FUNC , API_FFT ) ) , <nl> - ( " cufftMakePlanMany " , ( " hipfftMakePlanMany " , CONV_MATH_FUNC , API_FFT ) ) , <nl> - ( " cufftMakePlanMany64 " , ( " hipfftMakePlanMany64 " , CONV_MATH_FUNC , API_FFT ) ) , <nl> - ( " cufftGetSizeMany64 " , ( " hipfftGetSizeMany64 " , CONV_MATH_FUNC , API_FFT ) ) , <nl> - ( " cufftEstimate1d " , ( " hipfftEstimate1d " , CONV_MATH_FUNC , API_FFT ) ) , <nl> - ( " cufftEstimate2d " , ( " hipfftEstimate2d " , CONV_MATH_FUNC , API_FFT ) ) , <nl> - ( " cufftEstimate3d " , ( " hipfftEstimate3d " , CONV_MATH_FUNC , API_FFT ) ) , <nl> - ( " cufftEstimateMany " , ( " hipfftEstimateMany " , CONV_MATH_FUNC , API_FFT ) ) , <nl> - ( " cufftCreate " , ( " hipfftCreate " , CONV_MATH_FUNC , API_FFT ) ) , <nl> - ( " cufftGetSize1d " , ( " hipfftGetSize1d " , CONV_MATH_FUNC , API_FFT ) ) , <nl> - ( " cufftGetSize2d " , ( " hipfftGetSize2d " , CONV_MATH_FUNC , API_FFT ) ) , <nl> - ( " cufftGetSize3d " , ( " hipfftGetSize3d " , CONV_MATH_FUNC , API_FFT ) ) , <nl> - ( " cufftGetSizeMany " , ( " hipfftGetSizeMany " , CONV_MATH_FUNC , API_FFT ) ) , <nl> - ( " cufftGetSize " , ( " hipfftGetSize " , CONV_MATH_FUNC , API_FFT ) ) , <nl> - ( " cufftSetWorkArea " , ( " hipfftSetWorkArea " , CONV_MATH_FUNC , API_FFT ) ) , <nl> - ( " cufftSetAutoAllocation " , ( " hipfftSetAutoAllocation " , CONV_MATH_FUNC , API_FFT ) ) , <nl> - ( " cufftExecC2C " , ( " hipfftExecC2C " , CONV_MATH_FUNC , API_FFT ) ) , <nl> - ( " cufftExecR2C " , ( " hipfftExecR2C " , CONV_MATH_FUNC , API_FFT ) ) , <nl> - ( " cufftExecC2R " , ( " hipfftExecC2R " , CONV_MATH_FUNC , API_FFT ) ) , <nl> - ( " cufftExecZ2Z " , ( " hipfftExecZ2Z " , CONV_MATH_FUNC , API_FFT ) ) , <nl> - ( " cufftExecD2Z " , ( " hipfftExecD2Z " , CONV_MATH_FUNC , API_FFT ) ) , <nl> - ( " cufftExecZ2D " , ( " hipfftExecZ2D " , CONV_MATH_FUNC , API_FFT ) ) , <nl> - ( " cufftSetStream " , ( " hipfftSetStream " , CONV_MATH_FUNC , API_FFT ) ) , <nl> - ( " cufftDestroy " , ( " hipfftDestroy " , CONV_MATH_FUNC , API_FFT ) ) , <nl> - ( " cufftGetVersion " , ( " hipfftGetVersion " , CONV_MATH_FUNC , API_FFT ) ) , <nl> - ( " cufftGetProperty " , ( " hipfftGetProperty " , CONV_MATH_FUNC , API_FFT , HIP_UNSUPPORTED ) ) , <nl> - ( " nvrtcResult " , ( " hiprtcResult " , CONV_TYPE , API_RTC ) ) , <nl> - ( " NVRTC_SUCCESS " , ( " HIPRTC_SUCCESS " , CONV_TYPE , API_RTC ) ) , <nl> - ( " NVRTC_ERROR_OUT_OF_MEMORY " , ( " HIPRTC_ERROR_OUT_OF_MEMORY " , CONV_TYPE , API_RTC ) ) , <nl> - ( " NVRTC_ERROR_PROGRAM_CREATION_FAILURE " , ( " HIPRTC_ERROR_PROGRAM_CREATION_FAILURE " , CONV_TYPE , API_RTC ) ) , <nl> - ( " NVRTC_ERROR_INVALID_INPUT " , ( " HIPRTC_ERROR_INVALID_INPUT " , CONV_TYPE , API_RTC ) ) , <nl> - ( " NVRTC_ERROR_INVALID_PROGRAM " , ( " HIPRTC_ERROR_INVALID_PROGRAM " , CONV_TYPE , API_RTC ) ) , <nl> - ( " NVRTC_ERROR_COMPILATION " , ( " HIPRTC_ERROR_COMPILATION " , CONV_TYPE , API_RTC ) ) , <nl> - ( " NVRTC_ERROR_BUILTIN_OPERATION_FAILURE " , ( " HIPRTC_ERROR_BUILTIN_OPERATION_FAILURE " , CONV_TYPE , API_RTC ) ) , <nl> - ( " NVRTC_ERROR_NO_NAME_EXPRESSIONS_AFTER_COMPILATION " , ( " HIPRTC_ERROR_NO_NAME_EXPRESSIONS_AFTER_COMPILATION " , CONV_TYPE , API_RTC ) ) , <nl> - ( " NVRTC_ERROR_NAME_EXPRESSION_NOT_VALID " , ( " HIPRTC_ERROR_NAME_EXPRESSION_NOT_VALID " , CONV_TYPE , API_RTC ) ) , <nl> - ( " NVRTC_ERROR_INTERNAL_ERROR " , ( " HIPRTC_ERROR_INTERNAL_ERROR " , CONV_TYPE , API_RTC ) ) , <nl> - ( " nvrtcGetErrorString " , ( " hiprtcGetErrorString " , CONV_JIT , API_RTC ) ) , <nl> - ( " nvrtcVersion " , ( " hiprtcVersion " , CONV_JIT , API_RTC ) ) , <nl> - ( " nvrtcProgram " , ( " hiprtcProgram " , CONV_TYPE , API_RTC ) ) , <nl> - ( " nvrtcAddNameExpression " , ( " hiprtcAddNameExpression " , CONV_JIT , API_RTC ) ) , <nl> - ( " nvrtcCompileProgram " , ( " hiprtcCompileProgram " , CONV_JIT , API_RTC ) ) , <nl> - ( " nvrtcCreateProgram " , ( " hiprtcCreateProgram " , CONV_JIT , API_RTC ) ) , <nl> - ( " nvrtcDestroyProgram " , ( " hiprtcDestroyProgram " , CONV_JIT , API_RTC ) ) , <nl> - ( " nvrtcGetLoweredName " , ( " hiprtcGetLoweredName " , CONV_JIT , API_RTC ) ) , <nl> - ( " nvrtcGetProgramLog " , ( " hiprtcGetProgramLog " , CONV_JIT , API_RTC ) ) , <nl> - ( " nvrtcGetProgramLogSize " , ( " hiprtcGetProgramLogSize " , CONV_JIT , API_RTC ) ) , <nl> - ( " nvrtcGetPTX " , ( " hiprtcGetCode " , CONV_JIT , API_RTC ) ) , <nl> - ( " nvrtcGetPTXSize " , ( " hiprtcGetCodeSize " , CONV_JIT , API_RTC ) ) , <nl> - ( " thrust : : cuda " , ( " thrust : : hip " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> - ( " cub : : " , ( " hipcub : : " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> - ( " nvtxMark " , ( " roctxMark " , CONV_OTHER , API_ROCTX ) ) , <nl> - ( " nvtxMarkA " , ( " roctxMarkA " , CONV_OTHER , API_ROCTX ) ) , <nl> - ( " nvtxRangePushA " , ( " roctxRangePushA " , CONV_OTHER , API_ROCTX ) ) , <nl> - ( " nvtxRangePop " , ( " roctxRangePop " , CONV_OTHER , API_ROCTX ) ) , <nl> - ] ) <nl> - <nl> - CUDA_SPARSE_MAP = collections . OrderedDict ( [ <nl> - ( " cusparseStatus_t " , ( " hipsparseStatus_t " , CONV_MATH_FUNC , API_SPARSE ) ) , <nl> - ( " cusparseHandle_t " , ( " hipsparseHandle_t " , CONV_MATH_FUNC , API_SPARSE ) ) , <nl> - ( " cusparseOperation_t " , ( " hipsparseOperation_t " , CONV_TYPE , API_SPARSE ) ) , <nl> - ( " cusparseCreateMatDescr " , ( " hipsparseCreateMatDescr " , CONV_MATH_FUNC , API_SPARSE ) ) , <nl> - ( " cusparseCreate " , ( " hipsparseCreate " , CONV_MATH_FUNC , API_SPARSE ) ) , <nl> - ( " cusparseDestroyMatDescr " , ( " hipsparseDestroyMatDescr " , CONV_MATH_FUNC , API_SPARSE ) ) , <nl> - ( " cusparseDestroy " , ( " hipsparseDestroy " , CONV_MATH_FUNC , API_SPARSE ) ) , <nl> - ( " cusparseXcoo2csr " , ( " hipsparseXcoo2csr " , CONV_MATH_FUNC , API_SPARSE ) ) , <nl> - ( " cusparseMatDescr_t " , ( " hipsparseMatDescr_t " , CONV_MATH_FUNC , API_SPARSE ) ) , <nl> - ( " cusparseScsrmm2 " , ( " hipsparseScsrmm2 " , CONV_MATH_FUNC , API_SPARSE ) ) , <nl> - ( " cusparseDcsrmm2 " , ( " hipsparseDcsrmm2 " , CONV_MATH_FUNC , API_SPARSE ) ) , <nl> - ( " cusparseScsrmm " , ( " hipsparseScsrmm " , CONV_MATH_FUNC , API_SPARSE ) ) , <nl> - ( " cusparseDcsrmm " , ( " hipsparseDcsrmm " , CONV_MATH_FUNC , API_SPARSE ) ) , <nl> - ( " cusparseXcsrsort_bufferSizeExt " , ( " hipsparseXcsrsort_bufferSizeExt " , CONV_MATH_FUNC , API_SPARSE ) ) , <nl> - ( " cusparseXcsrsort " , ( " hipsparseXcsrsort " , CONV_MATH_FUNC , API_SPARSE ) ) , <nl> - ( " cusparseXcoosort_bufferSizeExt " , ( " hipsparseXcoosort_bufferSizeExt " , CONV_MATH_FUNC , API_SPARSE ) ) , <nl> - ( " cusparseXcoosortByRow " , ( " hipsparseXcoosortByRow " , CONV_MATH_FUNC , API_SPARSE ) ) , <nl> - ( " cusparseSetStream " , ( " hipsparseSetStream " , CONV_MATH_FUNC , API_SPARSE ) ) , <nl> - ( " cusparseCreateIdentityPermutation " , ( " hipsparseCreateIdentityPermutation " , CONV_MATH_FUNC , API_SPARSE ) ) , <nl> - ( " cusparseSetMatIndexBase " , ( " hipsparseSetMatIndexBase " , CONV_MATH_FUNC , API_SPARSE ) ) , <nl> - ( " cusparseSetMatType " , ( " hipsparseSetMatType " , CONV_MATH_FUNC , API_SPARSE ) ) , <nl> - ( " CUSPARSE_STATUS_SUCCESS " , ( " HIPSPARSE_STATUS_SUCCESS " , CONV_NUMERIC_LITERAL , API_SPARSE ) ) , <nl> - ( " CUSPARSE_STATUS_NOT_INITIALIZED " , ( " HIPSPARSE_STATUS_NOT_INITIALIZED " , CONV_NUMERIC_LITERAL , API_SPARSE ) ) , <nl> - ( " CUSPARSE_STATUS_ALLOC_FAILED " , ( " HIPSPARSE_STATUS_ALLOC_FAILED " , CONV_NUMERIC_LITERAL , API_SPARSE ) ) , <nl> - ( " CUSPARSE_STATUS_INVALID_VALUE " , ( " HIPSPARSE_STATUS_INVALID_VALUE " , CONV_NUMERIC_LITERAL , API_SPARSE ) ) , <nl> - ( " CUSPARSE_STATUS_MAPPING_ERROR " , ( " HIPSPARSE_STATUS_MAPPING_ERROR " , CONV_NUMERIC_LITERAL , API_SPARSE ) ) , <nl> - ( " CUSPARSE_STATUS_EXECUTION_FAILED " , ( " HIPSPARSE_STATUS_EXECUTION_FAILED " , CONV_NUMERIC_LITERAL , API_SPARSE ) ) , <nl> - ( " CUSPARSE_STATUS_INTERNAL_ERROR " , ( " HIPSPARSE_STATUS_INTERNAL_ERROR " , CONV_NUMERIC_LITERAL , API_SPARSE ) ) , <nl> - ( " CUSPARSE_STATUS_MATRIX_TYPE_NOT_SUPPORTED " , ( " HIPSPARSE_STATUS_MATRIX_TYPE_NOT_SUPPORTED " , CONV_NUMERIC_LITERAL , API_SPARSE ) ) , <nl> - ( " CUSPARSE_STATUS_ARCH_MISMATCH " , ( " HIPSPARSE_STATUS_ARCH_MISMATCH " , CONV_NUMERIC_LITERAL , API_SPARSE ) ) , <nl> - ( " CUSPARSE_STATUS_ZERO_PIVOT " , ( " HIPSPARSE_STATUS_ZERO_PIVOT " , CONV_NUMERIC_LITERAL , API_SPARSE ) ) , <nl> - ( " CUSPARSE_OPERATION_TRANSPOSE " , ( " HIPSPARSE_OPERATION_TRANSPOSE " , CONV_NUMERIC_LITERAL , API_SPARSE ) ) , <nl> - ( " CUSPARSE_OPERATION_NON_TRANSPOSE " , ( " HIPSPARSE_OPERATION_NON_TRANSPOSE " , CONV_NUMERIC_LITERAL , API_SPARSE ) ) , <nl> - ( " CUSPARSE_OPERATION_CONJUGATE_TRANSPOSE " , ( " HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE " , CONV_NUMERIC_LITERAL , API_SPARSE ) ) , <nl> - ( " CUSPARSE_INDEX_BASE_ZERO " , ( " HIPSPARSE_INDEX_BASE_ZERO " , CONV_NUMERIC_LITERAL , API_SPARSE ) ) , <nl> - ( " CUSPARSE_INDEX_BASE_ONE " , ( " HIPSPARSE_INDEX_BASE_ONE " , CONV_NUMERIC_LITERAL , API_SPARSE ) ) , <nl> - ( " CUSPARSE_MATRIX_TYPE_GENERAL " , ( " HIPSPARSE_MATRIX_TYPE_GENERAL " , CONV_NUMERIC_LITERAL , API_SPARSE ) ) , <nl> - ] ) <nl> - <nl> - PYTORCH_SPECIFIC_MAPPINGS = collections . OrderedDict ( [ <nl> - ( " USE_CUDA " , ( " USE_ROCM " , API_PYTORCH ) ) , <nl> - ( " CUDA_VERSION " , ( " HIP_VERSION " , API_PYTORCH ) ) , <nl> - ( " cudaHostAllocator " , ( " hipHostAllocator " , API_PYTORCH ) ) , <nl> - ( " cudaDeviceAllocator " , ( " hipDeviceAllocator " , API_PYTORCH ) ) , <nl> - ( " define MAX_NUM_BLOCKS 200 " , ( " define MAX_NUM_BLOCKS 64 " , API_PYTORCH ) ) , <nl> - <nl> - ( " cuda : : CUDAGuard " , ( " hip : : HIPGuardMasqueradingAsCUDA " , API_PYTORCH ) ) , <nl> - ( " CUDAGuard " , ( " HIPGuardMasqueradingAsCUDA " , API_PYTORCH ) ) , <nl> - <nl> - ( " cuda : : OptionalCUDAGuard " , ( " hip : : OptionalHIPGuardMasqueradingAsCUDA " , API_PYTORCH ) ) , <nl> - ( " OptionalCUDAGuard " , ( " OptionalHIPGuardMasqueradingAsCUDA " , API_PYTORCH ) ) , <nl> - <nl> - ( " cuda : : CUDAStreamGuard " , ( " hip : : HIPStreamGuardMasqueradingAsCUDA " , API_PYTORCH ) ) , <nl> - ( " CUDAStreamGuard " , ( " HIPStreamGuardMasqueradingAsCUDA " , API_PYTORCH ) ) , <nl> - <nl> - ( " cuda : : OptionalCUDAStreamGuard " , ( " hip : : OptionalHIPStreamGuardMasqueradingAsCUDA " , API_PYTORCH ) ) , <nl> - ( " OptionalCUDAStreamGuard " , ( " OptionalHIPStreamGuardMasqueradingAsCUDA " , API_PYTORCH ) ) , <nl> - <nl> - # Only get needs to be transformed this way ; all the other ones can go <nl> - # straight to the normal versions hip : : HIPCachingAllocator <nl> - ( " cuda : : CUDACachingAllocator : : get " , ( " hip : : HIPCachingAllocatorMasqueradingAsCUDA : : get " , API_PYTORCH ) ) , <nl> - ( " CUDACachingAllocator : : get " , ( " HIPCachingAllocatorMasqueradingAsCUDA : : get " , API_PYTORCH ) ) , <nl> - ( " cuda : : CUDACachingAllocator : : recordStream " , ( " hip : : HIPCachingAllocatorMasqueradingAsCUDA : : recordStreamMasqueradingAsCUDA " , API_PYTORCH ) ) , <nl> - ( " CUDACachingAllocator : : recordStream " , ( " HIPCachingAllocatorMasqueradingAsCUDA : : recordStreamMasqueradingAsCUDA " , API_PYTORCH ) ) , <nl> - <nl> - ( " cuda : : CUDAStream " , ( " hip : : HIPStreamMasqueradingAsCUDA " , API_PYTORCH ) ) , <nl> - ( " CUDAStream " , ( " HIPStreamMasqueradingAsCUDA " , API_PYTORCH ) ) , <nl> - <nl> - ( " cuda : : getStreamFromPool " , ( " hip : : getStreamFromPoolMasqueradingAsCUDA " , API_PYTORCH ) ) , <nl> - ( " getStreamFromPool " , ( " getStreamFromPoolMasqueradingAsCUDA " , API_PYTORCH ) ) , <nl> - <nl> - ( " cuda : : getDefaultCUDAStream " , ( " hip : : getDefaultHIPStreamMasqueradingAsCUDA " , API_PYTORCH ) ) , <nl> - ( " getDefaultCUDAStream " , ( " getDefaultHIPStreamMasqueradingAsCUDA " , API_PYTORCH ) ) , <nl> - <nl> - ( " cuda : : getCurrentCUDAStream " , ( " hip : : getCurrentHIPStreamMasqueradingAsCUDA " , API_PYTORCH ) ) , <nl> - ( " getCurrentCUDAStream " , ( " getCurrentHIPStreamMasqueradingAsCUDA " , API_PYTORCH ) ) , <nl> - <nl> - ( " cuda : : setCurrentCUDAStream " , ( " hip : : setCurrentHIPStreamMasqueradingAsCUDA " , API_PYTORCH ) ) , <nl> - ( " setCurrentCUDAStream " , ( " setCurrentHIPStreamMasqueradingAsCUDA " , API_PYTORCH ) ) , <nl> - <nl> - # TODO : Undo this special - case ; see the header for motivation behind this <nl> - # hack . It ' s VERY important this is only applied to PyTorch HIPify . <nl> - ( " c10 / cuda / CUDAGuard . h " , ( " ATen / hip / impl / HIPGuardImplMasqueradingAsCUDA . h " , API_PYTORCH ) ) , <nl> - ( " c10 / cuda / CUDACachingAllocator . h " , ( " ATen / hip / impl / HIPCachingAllocatorMasqueradingAsCUDA . h " , API_PYTORCH ) ) , <nl> - ( " c10 / cuda / CUDAStream . h " , ( " ATen / hip / impl / HIPStreamMasqueradingAsCUDA . h " , API_PYTORCH ) ) , <nl> - ( " gloo / cuda . h " , ( " gloo / hip . h " , API_PYTORCH ) ) , <nl> - ( " gloo / cuda_allreduce_halving_doubling . h " , ( " gloo / hip_allreduce_halving_doubling . h " , API_PYTORCH ) ) , <nl> - ( " gloo / cuda_allreduce_halving_doubling_pipelined . h " , ( " gloo / hip_allreduce_halving_doubling_pipelined . h " , API_PYTORCH ) ) , <nl> - ( " gloo / cuda_allreduce_ring . h " , ( " gloo / hip_allreduce_ring . h " , API_PYTORCH ) ) , <nl> - ( " gloo / cuda_broadcast_one_to_all . h " , ( " gloo / hip_broadcast_one_to_all . h " , API_PYTORCH ) ) , <nl> - ( " gloo : : CudaAllreduceHalvingDoublingPipelined " , ( " gloo : : HipAllreduceHalvingDoublingPipelined " , API_PYTORCH ) ) , <nl> - ( " gloo : : CudaBroadcastOneToAll " , ( " gloo : : HipBroadcastOneToAll " , API_PYTORCH ) ) , <nl> - ( " gloo : : CudaHostWorkspace " , ( " gloo : : HipHostWorkspace " , API_PYTORCH ) ) , <nl> - ( " gloo : : CudaDeviceWorkspace " , ( " gloo : : HipDeviceWorkspace " , API_PYTORCH ) ) , <nl> - ] ) <nl> - <nl> - CAFFE2_SPECIFIC_MAPPINGS = collections . OrderedDict ( [ <nl> - ( " cuda_stream " , ( " hip_stream " , API_CAFFE2 ) ) , <nl> - # if the header is a native hip folder ( under hip directory ) , <nl> - # there is no need to add a hip path to it ; the trie in hipify script <nl> - # takes this mapping order to forbid further replacement <nl> - ( " / hip / " , ( " / hip / " , API_CAFFE2 ) ) , <nl> - ( " / context_gpu " , ( " / hip / context_gpu " , API_CAFFE2 ) ) , <nl> - ( " / common_gpu " , ( " / hip / common_gpu " , API_CAFFE2 ) ) , <nl> - ( " / mixed_utils " , ( " / hip / mixed_utils " , API_CAFFE2 ) ) , <nl> - ( " / operator_fallback_gpu " , ( " / hip / operator_fallback_gpu " , API_CAFFE2 ) ) , <nl> - ( " / spatial_batch_norm_op_impl " , ( " / hip / spatial_batch_norm_op_impl " , API_CAFFE2 ) ) , <nl> - ( " / recurrent_network_executor_gpu " , ( " / hip / recurrent_network_executor_gpu " , API_CAFFE2 ) ) , <nl> - ( " / generate_proposals_op_util_nms_gpu " , ( " / hip / generate_proposals_op_util_nms_gpu " , API_CAFFE2 ) ) , <nl> - ( " / max_pool_with_index_gpu " , ( " / hip / max_pool_with_index_gpu " , API_CAFFE2 ) ) , <nl> - ( " / THCCachingAllocator_gpu " , ( " / hip / THCCachingAllocator_gpu " , API_CAFFE2 ) ) , <nl> - ( " / top_k_heap_selection " , ( " / hip / top_k_heap_selection " , API_CAFFE2 ) ) , <nl> - ( " / top_k_radix_selection " , ( " / hip / top_k_radix_selection " , API_CAFFE2 ) ) , <nl> - ( " / GpuDefs " , ( " / hip / GpuDefs " , API_CAFFE2 ) ) , <nl> - ( " / GpuScanUtils " , ( " / hip / GpuScanUtils " , API_CAFFE2 ) ) , <nl> - ( " / GpuBitonicSort " , ( " / hip / GpuBitonicSort " , API_CAFFE2 ) ) , <nl> - ( " / math / reduce . cuh " , ( " / math / hip / reduce . cuh " , API_CAFFE2 ) ) , <nl> - ( " / gather_op . cuh " , ( " / hip / gather_op . cuh " , API_CAFFE2 ) ) , <nl> - ( " caffe2 / core / common_cudnn . h " , ( " caffe2 / core / hip / common_miopen . h " , API_CAFFE2 ) ) , <nl> - ( " REGISTER_CUDA_OPERATOR " , ( " REGISTER_HIP_OPERATOR " , API_CAFFE2 ) ) , <nl> - ( " CUDA_1D_KERNEL_LOOP " , ( " HIP_1D_KERNEL_LOOP " , API_CAFFE2 ) ) , <nl> - ( " CUDAContext " , ( " HIPContext " , API_CAFFE2 ) ) , <nl> - ( " CAFFE_CUDA_NUM_THREADS " , ( " CAFFE_HIP_NUM_THREADS " , API_CAFFE2 ) ) , <nl> - ( " HasCudaGPU " , ( " HasHipGPU " , API_CAFFE2 ) ) , <nl> - ( " __expf " , ( " expf " , API_CAFFE2 ) ) , <nl> - ( " CUBLAS_ENFORCE " , ( " ROCBLAS_ENFORCE " , API_CAFFE2 ) ) , <nl> - ( " CUBLAS_CHECK " , ( " ROCBLAS_CHECK " , API_CAFFE2 ) ) , <nl> - ( " cublas_handle " , ( " rocblashandle " , API_CAFFE2 ) ) , <nl> - ( " CURAND_ENFORCE " , ( " HIPRAND_ENFORCE " , API_CAFFE2 ) ) , <nl> - ( " CURAND_CHECK " , ( " HIPRAND_CHECK " , API_CAFFE2 ) ) , <nl> - ( " curandGenerateUniform " , ( " hiprandGenerateUniform " , API_CAFFE2 ) ) , <nl> - ( " curand_generator " , ( " hiprand_generator " , API_CAFFE2 ) ) , <nl> - ( " CaffeCudaGetDevice " , ( " CaffeHipGetDevice " , API_CAFFE2 ) ) , <nl> - ( " CUDA " , ( " HIP " , API_CAFFE2 ) ) , <nl> - ( " Cuda " , ( " Hip " , API_CAFFE2 ) ) , <nl> - ( " cuda_ " , ( " hip_ " , API_CAFFE2 ) ) , <nl> - ( " _cuda " , ( " _hip " , API_CAFFE2 ) ) , <nl> - ( " CUDNN " , ( " MIOPEN " , API_CAFFE2 ) ) , <nl> - ( " CuDNN " , ( " MIOPEN " , API_CAFFE2 ) ) , <nl> - ( " cudnn " , ( " miopen " , API_CAFFE2 ) ) , <nl> - ( " namespace cuda " , ( " namespace hip " , API_CAFFE2 ) ) , <nl> - ( " cuda : : CUDAGuard " , ( " hip : : HIPGuard " , API_CAFFE2 ) ) , <nl> - ( " cuda : : OptionalCUDAGuard " , ( " hip : : OptionalHIPGuard " , API_CAFFE2 ) ) , <nl> - ( " cuda : : CUDAStreamGuard " , ( " hip : : HIPStreamGuard " , API_CAFFE2 ) ) , <nl> - ( " cuda : : OptionalCUDAStreamGuard " , ( " hip : : OptionalHIPStreamGuard " , API_CAFFE2 ) ) , <nl> - ( " c10 / cuda / CUDAGuard . h " , ( " c10 / hip / HIPGuard . h " , API_CAFFE2 ) ) , <nl> - ( " gloo / cuda " , ( " gloo / hip " , API_CAFFE2 ) ) , <nl> - ] ) <nl> - <nl> - # We must tread very carefully here . Blanket conversions like are done <nl> - # in CAFFE2_SPECIFIC_MAPPINGS are not presently supported on PyTorch , <nl> - # because a regex for CUDA will also match a filename like CUDAGuard . h , <nl> - # but the HIPIFY script doesn ' t presently move the file and so the substitution <nl> - # will be invalid . Instead , we specifically list out every identifier <nl> - # and file from c10 / cuda which may be used externally , and do substitutions this <nl> - # way . <nl> - # <nl> - # NB : if you want a transformation to ONLY apply to the c10 / directory , <nl> - # put it as API_CAFFE2 <nl> - C10_MAPPINGS = collections . OrderedDict ( [ <nl> - ( " cuda : : compat : : " , ( " hip : : compat : : " , API_C10 ) ) , <nl> - ( " c10 / cuda / CUDAException . h " , ( " c10 / hip / HIPException . h " , API_C10 ) ) , <nl> - ( " c10 / cuda / CUDAMacros . h " , ( " c10 / hip / HIPMacros . h " , API_C10 ) ) , <nl> - ( " c10 / cuda / CUDAMathCompat . h " , ( " c10 / hip / HIPMathCompat . h " , API_C10 ) ) , <nl> - ( " c10 / cuda / CUDAFunctions . h " , ( " c10 / hip / HIPFunctions . h " , API_C10 ) ) , <nl> - ( " c10 / cuda / CUDAStream . h " , ( " c10 / hip / HIPStream . h " , API_C10 ) ) , <nl> - ( " c10 / cuda / CUDACachingAllocator . h " , ( " c10 / hip / HIPCachingAllocator . h " , API_C10 ) ) , <nl> - ( " c10 / cuda / impl / CUDATest . h " , ( " c10 / hip / impl / HIPTest . h " , API_C10 ) ) , <nl> - ( " c10 / cuda / impl / CUDAGuardImpl . h " , ( " c10 / hip / impl / HIPGuardImpl . h " , API_C10 ) ) , <nl> - ( " c10 / cuda / impl / cuda_cmake_macros . h " , ( " c10 / hip / impl / hip_cmake_macros . h " , API_C10 ) ) , <nl> - ( " C10_CUDA_CHECK " , ( " C10_HIP_CHECK " , API_C10 ) ) , <nl> - ( " C10_CUDA_CHECK_WARN " , ( " C10_HIP_CHECK_WARN " , API_C10 ) ) , <nl> - ( " c10 : : cuda " , ( " c10 : : hip " , API_C10 ) ) , <nl> - ( " cuda : : CUDAStream " , ( " hip : : HIPStream " , API_C10 ) ) , <nl> - ( " CUDAStream " , ( " HIPStream " , API_C10 ) ) , <nl> - # This substitution is not permissible , because there ' s another copy of this <nl> - # function in torch / cuda . h <nl> - # ( " cuda : : device_count " , ( " hip : : device_count " , API_C10 ) ) , <nl> - ( " cuda : : current_device " , ( " hip : : current_device " , API_C10 ) ) , <nl> - ( " cuda : : set_device " , ( " hip : : set_device " , API_C10 ) ) , <nl> - ( " cuda : : getStreamFromPool " , ( " hip : : getStreamFromPool " , API_C10 ) ) , <nl> - ( " getStreamFromPool " , ( " getStreamFromPool " , API_C10 ) ) , <nl> - ( " cuda : : getDefaultCUDAStream " , ( " hip : : getDefaultHIPStream " , API_C10 ) ) , <nl> - ( " getDefaultCUDAStream " , ( " getDefaultHIPStream " , API_C10 ) ) , <nl> - ( " cuda : : getCurrentCUDAStream " , ( " hip : : getCurrentHIPStream " , API_C10 ) ) , <nl> - ( " getCurrentCUDAStream " , ( " getCurrentHIPStream " , API_C10 ) ) , <nl> - ( " cuda : : setCurrentCUDAStream " , ( " hip : : setCurrentHIPStream " , API_C10 ) ) , <nl> - ( " setCurrentCUDAStream " , ( " setCurrentHIPStream " , API_C10 ) ) , <nl> - ( " cuda : : CUDACachingAllocator " , ( " hip : : HIPCachingAllocator " , API_C10 ) ) , <nl> - ( " CUDACachingAllocator " , ( " HIPCachingAllocator " , API_C10 ) ) , <nl> - ] ) <nl> - <nl> - # NB : C10 mappings are more specific than Caffe2 mappings , so run them <nl> - # first <nl> - CUDA_TO_HIP_MAPPINGS = [ CUDA_IDENTIFIER_MAP , CUDA_TYPE_NAME_MAP , <nl> - CUDA_INCLUDE_MAP , CUDA_SPARSE_MAP , C10_MAPPINGS , PYTORCH_SPECIFIC_MAPPINGS , CAFFE2_SPECIFIC_MAPPINGS ] <nl> similarity index 100 % <nl> rename from tools / amd_build / pyHIPIFY / __init__ . py <nl> rename to torch / utils / hipify / __init__ . py <nl> similarity index 100 % <nl> rename from tools / amd_build / pyHIPIFY / constants . py <nl> rename to torch / utils / hipify / constants . py <nl> new file mode 100644 <nl> index 000000000000 . . 54848b888840 <nl> mmm / dev / null <nl> ppp b / torch / utils / hipify / cuda_to_hip_mappings . py <nl> <nl> + # ! / usr / bin / env python3 <nl> + import collections <nl> + <nl> + from . constants import * <nl> + <nl> + " " " Mapping of CUDA functions , include files , constants , and types to ROCm / HIP equivalents <nl> + This closely follows the implementation in hipify - clang <nl> + https : / / github . com / ROCm - Developer - Tools / HIP / blob / master / hipify - clang / src / CUDA2HipMap . cpp <nl> + and its structure . <nl> + There are different maps for fundamental names , include files , identifies , sparse , and <nl> + PyTorch specific translations . <nl> + Each of the entries in these maps translates a CUDA string to a tuple containing the <nl> + ROCm / HIP string , a type and API annotation and - optionally - an annotation if it is not <nl> + supported in ROCm / HIP yet . <nl> + " " " <nl> + <nl> + # List of math functions that should be replaced inside device code only . <nl> + MATH_TRANSPILATIONS = collections . OrderedDict ( <nl> + [ <nl> + ( " std : : max " , ( " : : max " ) ) , <nl> + ( " std : : min " , ( " : : min " ) ) , <nl> + ( " std : : ceil " , ( " : : ceil " ) ) , <nl> + ( " std : : floor " , ( " : : floor " ) ) , <nl> + ( " std : : exp " , ( " : : exp " ) ) , <nl> + ( " std : : log " , ( " : : log " ) ) , <nl> + ( " std : : pow " , ( " : : pow " ) ) , <nl> + ( " std : : fabs " , ( " : : fabs " ) ) , <nl> + ( " std : : fmod " , ( " : : fmod " ) ) , <nl> + ( " std : : remainder " , ( " : : remainder " ) ) , <nl> + ] <nl> + ) <nl> + <nl> + CUDA_TYPE_NAME_MAP = collections . OrderedDict ( <nl> + [ <nl> + ( " CUresult " , ( " hipError_t " , CONV_TYPE , API_DRIVER ) ) , <nl> + ( " cudaError_t " , ( " hipError_t " , CONV_TYPE , API_RUNTIME ) ) , <nl> + ( <nl> + " CUDA_ARRAY3D_DESCRIPTOR " , <nl> + ( " HIP_ARRAY3D_DESCRIPTOR " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " CUDA_ARRAY_DESCRIPTOR " , ( " HIP_ARRAY_DESCRIPTOR " , CONV_TYPE , API_DRIVER ) ) , <nl> + ( " CUDA_MEMCPY2D " , ( " hip_Memcpy2D " , CONV_TYPE , API_DRIVER ) ) , <nl> + ( " CUDA_MEMCPY3D " , ( " HIP_MEMCPY3D " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> + ( <nl> + " CUDA_MEMCPY3D_PEER " , <nl> + ( " HIP_MEMCPY3D_PEER " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CUDA_POINTER_ATTRIBUTE_P2P_TOKENS " , <nl> + ( <nl> + " HIP_POINTER_ATTRIBUTE_P2P_TOKENS " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CUDA_RESOURCE_DESC " , <nl> + ( " HIP_RESOURCE_DESC " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CUDA_RESOURCE_VIEW_DESC " , <nl> + ( " HIP_RESOURCE_VIEW_DESC " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CUipcEventHandle " , <nl> + ( " hipIpcEventHandle " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " CUipcMemHandle " , ( " hipIpcMemHandle " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> + ( " CUaddress_mode " , ( " hipAddress_mode " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> + ( <nl> + " CUarray_cubemap_face " , <nl> + ( " hipArray_cubemap_face " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " CUarray_format " , ( " hipArray_format " , CONV_TYPE , API_DRIVER ) ) , <nl> + ( " CUcomputemode " , ( " hipComputemode " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> + ( " CUmem_advise " , ( " hipMemAdvise " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> + ( <nl> + " CUmem_range_attribute " , <nl> + ( " hipMemRangeAttribute " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " CUctx_flags " , ( " hipCctx_flags " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> + ( " CUdevice " , ( " hipDevice_t " , CONV_TYPE , API_DRIVER ) ) , <nl> + ( " CUdevice_attribute_enum " , ( " hipDeviceAttribute_t " , CONV_TYPE , API_DRIVER ) ) , <nl> + ( " CUdevice_attribute " , ( " hipDeviceAttribute_t " , CONV_TYPE , API_DRIVER ) ) , <nl> + ( " CUdeviceptr " , ( " hipDeviceptr_t " , CONV_TYPE , API_DRIVER ) ) , <nl> + ( " CUarray_st " , ( " hipArray " , CONV_TYPE , API_DRIVER ) ) , <nl> + ( " CUarray " , ( " hipArray * " , CONV_TYPE , API_DRIVER ) ) , <nl> + ( " CUdevprop_st " , ( " hipDeviceProp_t " , CONV_TYPE , API_DRIVER ) ) , <nl> + ( " CUdevprop " , ( " hipDeviceProp_t " , CONV_TYPE , API_DRIVER ) ) , <nl> + ( " CUfunction " , ( " hipFunction_t " , CONV_TYPE , API_DRIVER ) ) , <nl> + ( <nl> + " CUgraphicsResource " , <nl> + ( " hipGraphicsResource_t " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CUmipmappedArray " , <nl> + ( " hipMipmappedArray_t " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CUfunction_attribute " , <nl> + ( " hipFuncAttribute_t " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CUfunction_attribute_enum " , <nl> + ( " hipFuncAttribute_t " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CUgraphicsMapResourceFlags " , <nl> + ( " hipGraphicsMapFlags " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CUgraphicsMapResourceFlags_enum " , <nl> + ( " hipGraphicsMapFlags " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CUgraphicsRegisterFlags " , <nl> + ( " hipGraphicsRegisterFlags " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CUgraphicsRegisterFlags_enum " , <nl> + ( " hipGraphicsRegisterFlags " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CUoccupancy_flags " , <nl> + ( " hipOccupancyFlags " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CUoccupancy_flags_enum " , <nl> + ( " hipOccupancyFlags " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " CUfunc_cache_enum " , ( " hipFuncCache " , CONV_TYPE , API_DRIVER ) ) , <nl> + ( " CUfunc_cache " , ( " hipFuncCache " , CONV_TYPE , API_DRIVER ) ) , <nl> + ( " CUipcMem_flags " , ( " hipIpcMemFlags " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> + ( <nl> + " CUipcMem_flags_enum " , <nl> + ( " hipIpcMemFlags " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " CUjit_cacheMode " , ( " hipJitCacheMode " , CONV_JIT , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> + ( <nl> + " CUjit_cacheMode_enum " , <nl> + ( " hipJitCacheMode " , CONV_JIT , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " CUjit_fallback " , ( " hipJitFallback " , CONV_JIT , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> + ( <nl> + " CUjit_fallback_enum " , <nl> + ( " hipJitFallback " , CONV_JIT , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " CUjit_option " , ( " hipJitOption " , CONV_JIT , API_DRIVER ) ) , <nl> + ( " CUjit_option_enum " , ( " hipJitOption " , CONV_JIT , API_DRIVER ) ) , <nl> + ( " CUjit_target " , ( " hipJitTarget " , CONV_JIT , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> + ( " CUjit_target_enum " , ( " hipJitTarget " , CONV_JIT , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> + ( " CUjitInputType " , ( " hipJitInputType " , CONV_JIT , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> + ( <nl> + " CUjitInputType_enum " , <nl> + ( " hipJitInputType " , CONV_JIT , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " CUlimit " , ( " hipLimit_t " , CONV_TYPE , API_DRIVER ) ) , <nl> + ( " CUlimit_enum " , ( " hipLimit_t " , CONV_TYPE , API_DRIVER ) ) , <nl> + ( <nl> + " CUmemAttach_flags " , <nl> + ( " hipMemAttachFlags_t " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CUmemAttach_flags_enum " , <nl> + ( " hipMemAttachFlags_t " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " CUmemorytype " , ( " hipMemType_t " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> + ( " CUmemorytype_enum " , ( " hipMemType_t " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> + ( " CUresourcetype " , ( " hipResourceType " , CONV_TEX , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> + ( <nl> + " CUresourcetype_enum " , <nl> + ( " hipResourceType " , CONV_TEX , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " CUresourceViewFormat " , ( " hipResourceViewFormat " , CONV_TEX , API_DRIVER ) ) , <nl> + ( " CUresourceViewFormat_enum " , ( " hipResourceViewFormat " , CONV_TEX , API_DRIVER ) ) , <nl> + ( " CUsharedconfig " , ( " hipSharedMemConfig " , CONV_TYPE , API_DRIVER ) ) , <nl> + ( " CUsharedconfig_enum " , ( " hipSharedMemConfig " , CONV_TYPE , API_DRIVER ) ) , <nl> + ( " CUcontext " , ( " hipCtx_t " , CONV_TYPE , API_DRIVER ) ) , <nl> + ( " CUmodule " , ( " hipModule_t " , CONV_TYPE , API_DRIVER ) ) , <nl> + ( " CUstream " , ( " hipStream_t " , CONV_TYPE , API_DRIVER ) ) , <nl> + ( " CUstream_st " , ( " ihipStream_t " , CONV_TYPE , API_DRIVER ) ) , <nl> + ( " CUstreamCallback " , ( " hipStreamCallback_t " , CONV_TYPE , API_DRIVER ) ) , <nl> + ( " CUsurfObject " , ( " hipSurfaceObject " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> + ( <nl> + " CUsurfref " , <nl> + ( " hipSurfaceReference_t " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " CUtexObject " , ( " hipTextureObject_t " , CONV_TYPE , API_DRIVER ) ) , <nl> + ( " CUtexref " , ( " textureReference " , CONV_TYPE , API_DRIVER ) ) , <nl> + ( " CUstream_flags " , ( " hipStreamFlags " , CONV_TYPE , API_DRIVER ) ) , <nl> + ( <nl> + " CUstreamWaitValue_flags " , <nl> + ( " hipStreamWaitValueFlags " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CUstreamWriteValue_flags " , <nl> + ( " hipStreamWriteValueFlags " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CUstreamBatchMemOpType " , <nl> + ( " hipStreamBatchMemOpType " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CUdevice_P2PAttribute " , <nl> + ( " hipDeviceP2PAttribute " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " CUevent " , ( " hipEvent_t " , CONV_TYPE , API_DRIVER ) ) , <nl> + ( " CUevent_st " , ( " ihipEvent_t " , CONV_TYPE , API_DRIVER ) ) , <nl> + ( " CUevent_flags " , ( " hipEventFlags " , CONV_EVENT , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> + ( " CUfilter_mode " , ( " hipTextureFilterMode " , CONV_TEX , API_DRIVER ) ) , <nl> + ( " CUGLDeviceList " , ( " hipGLDeviceList " , CONV_GL , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> + ( " CUGLmap_flags " , ( " hipGLMapFlags " , CONV_GL , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> + ( <nl> + " CUd3d9DeviceList " , <nl> + ( " hipD3D9DeviceList " , CONV_D3D9 , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CUd3d9map_flags " , <nl> + ( " hipD3D9MapFlags " , CONV_D3D9 , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CUd3d9register_flags " , <nl> + ( " hipD3D9RegisterFlags " , CONV_D3D9 , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CUd3d10DeviceList " , <nl> + ( " hipd3d10DeviceList " , CONV_D3D10 , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CUd3d10map_flags " , <nl> + ( " hipD3D10MapFlags " , CONV_D3D10 , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CUd3d10register_flags " , <nl> + ( " hipD3D10RegisterFlags " , CONV_D3D10 , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CUd3d11DeviceList " , <nl> + ( " hipd3d11DeviceList " , CONV_D3D11 , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CUeglStreamConnection_st " , <nl> + ( " hipEglStreamConnection " , CONV_EGL , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CUeglStreamConnection " , <nl> + ( " hipEglStreamConnection " , CONV_EGL , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " libraryPropertyType_t " , <nl> + ( " hipLibraryPropertyType_t " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " libraryPropertyType " , <nl> + ( " hipLibraryPropertyType_t " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cudaStreamCallback_t " , ( " hipStreamCallback_t " , CONV_TYPE , API_RUNTIME ) ) , <nl> + ( " cudaArray " , ( " hipArray " , CONV_MEM , API_RUNTIME ) ) , <nl> + ( " cudaArray_t " , ( " hipArray_t " , CONV_MEM , API_RUNTIME ) ) , <nl> + ( " cudaArray_const_t " , ( " hipArray_const_t " , CONV_MEM , API_RUNTIME ) ) , <nl> + ( " cudaMipmappedArray_t " , ( " hipMipmappedArray_t " , CONV_MEM , API_RUNTIME ) ) , <nl> + ( <nl> + " cudaMipmappedArray_const_t " , <nl> + ( " hipMipmappedArray_const_t " , CONV_MEM , API_RUNTIME ) , <nl> + ) , <nl> + ( " cudaArrayDefault " , ( " hipArrayDefault " , CONV_MEM , API_RUNTIME ) ) , <nl> + ( " cudaArrayLayered " , ( " hipArrayLayered " , CONV_MEM , API_RUNTIME ) ) , <nl> + ( <nl> + " cudaArraySurfaceLoadStore " , <nl> + ( " hipArraySurfaceLoadStore " , CONV_MEM , API_RUNTIME ) , <nl> + ) , <nl> + ( " cudaArrayCubemap " , ( " hipArrayCubemap " , CONV_MEM , API_RUNTIME ) ) , <nl> + ( " cudaArrayTextureGather " , ( " hipArrayTextureGather " , CONV_MEM , API_RUNTIME ) ) , <nl> + ( " cudaMemoryAdvise " , ( " hipMemAdvise " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> + ( <nl> + " cudaMemRangeAttribute " , <nl> + ( " hipMemRangeAttribute " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cudaMemcpyKind " , ( " hipMemcpyKind " , CONV_MEM , API_RUNTIME ) ) , <nl> + ( " cudaMemoryType " , ( " hipMemoryType " , CONV_MEM , API_RUNTIME ) ) , <nl> + ( " cudaExtent " , ( " hipExtent " , CONV_MEM , API_RUNTIME ) ) , <nl> + ( " cudaPitchedPtr " , ( " hipPitchedPtr " , CONV_MEM , API_RUNTIME ) ) , <nl> + ( " cudaPos " , ( " hipPos " , CONV_MEM , API_RUNTIME ) ) , <nl> + ( " cudaEvent_t " , ( " hipEvent_t " , CONV_TYPE , API_RUNTIME ) ) , <nl> + ( " cudaStream_t " , ( " hipStream_t " , CONV_TYPE , API_RUNTIME ) ) , <nl> + ( " cudaPointerAttributes " , ( " hipPointerAttribute_t " , CONV_TYPE , API_RUNTIME ) ) , <nl> + ( " cudaDeviceAttr " , ( " hipDeviceAttribute_t " , CONV_TYPE , API_RUNTIME ) ) , <nl> + ( " cudaDeviceProp " , ( " hipDeviceProp_t " , CONV_TYPE , API_RUNTIME ) ) , <nl> + ( <nl> + " cudaDeviceP2PAttr " , <nl> + ( " hipDeviceP2PAttribute " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaComputeMode " , <nl> + ( " hipComputeMode " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cudaFuncCache " , ( " hipFuncCache_t " , CONV_CACHE , API_RUNTIME ) ) , <nl> + ( <nl> + " cudaFuncAttributes " , <nl> + ( " hipFuncAttributes " , CONV_EXEC , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cudaSharedMemConfig " , ( " hipSharedMemConfig " , CONV_TYPE , API_RUNTIME ) ) , <nl> + ( " cudaLimit " , ( " hipLimit_t " , CONV_TYPE , API_RUNTIME ) ) , <nl> + ( " cudaOutputMode " , ( " hipOutputMode " , CONV_OTHER , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> + ( " cudaTextureReadMode " , ( " hipTextureReadMode " , CONV_TEX , API_RUNTIME ) ) , <nl> + ( " cudaTextureFilterMode " , ( " hipTextureFilterMode " , CONV_TEX , API_RUNTIME ) ) , <nl> + ( " cudaChannelFormatKind " , ( " hipChannelFormatKind " , CONV_TEX , API_RUNTIME ) ) , <nl> + ( " cudaChannelFormatDesc " , ( " hipChannelFormatDesc " , CONV_TEX , API_RUNTIME ) ) , <nl> + ( " cudaResourceDesc " , ( " hipResourceDesc " , CONV_TEX , API_RUNTIME ) ) , <nl> + ( " cudaResourceViewDesc " , ( " hipResourceViewDesc " , CONV_TEX , API_RUNTIME ) ) , <nl> + ( " cudaTextureDesc " , ( " hipTextureDesc " , CONV_TEX , API_RUNTIME ) ) , <nl> + ( <nl> + " surfaceReference " , <nl> + ( " hipSurfaceReference " , CONV_SURFACE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cudaTextureObject_t " , ( " hipTextureObject_t " , CONV_TEX , API_RUNTIME ) ) , <nl> + ( " cudaResourceType " , ( " hipResourceType " , CONV_TEX , API_RUNTIME ) ) , <nl> + ( " cudaResourceViewFormat " , ( " hipResourceViewFormat " , CONV_TEX , API_RUNTIME ) ) , <nl> + ( " cudaTextureAddressMode " , ( " hipTextureAddressMode " , CONV_TEX , API_RUNTIME ) ) , <nl> + ( <nl> + " cudaSurfaceBoundaryMode " , <nl> + ( " hipSurfaceBoundaryMode " , CONV_SURFACE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaSurfaceFormatMode " , <nl> + ( " hipSurfaceFormatMode " , CONV_SURFACE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cudaTextureType1D " , ( " hipTextureType1D " , CONV_TEX , API_RUNTIME ) ) , <nl> + ( " cudaTextureType2D " , ( " hipTextureType2D " , CONV_TEX , API_RUNTIME ) ) , <nl> + ( " cudaTextureType3D " , ( " hipTextureType3D " , CONV_TEX , API_RUNTIME ) ) , <nl> + ( " cudaTextureTypeCubemap " , ( " hipTextureTypeCubemap " , CONV_TEX , API_RUNTIME ) ) , <nl> + ( <nl> + " cudaTextureType1DLayered " , <nl> + ( " hipTextureType1DLayered " , CONV_TEX , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " cudaTextureType2DLayered " , <nl> + ( " hipTextureType2DLayered " , CONV_TEX , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " cudaTextureTypeCubemapLayered " , <nl> + ( " hipTextureTypeCubemapLayered " , CONV_TEX , API_RUNTIME ) , <nl> + ) , <nl> + ( " cudaIpcEventHandle_t " , ( " hipIpcEventHandle_t " , CONV_TYPE , API_RUNTIME ) ) , <nl> + ( " cudaIpcEventHandle_st " , ( " hipIpcEventHandle_t " , CONV_TYPE , API_RUNTIME ) ) , <nl> + ( " cudaIpcMemHandle_t " , ( " hipIpcMemHandle_t " , CONV_TYPE , API_RUNTIME ) ) , <nl> + ( " cudaIpcMemHandle_st " , ( " hipIpcMemHandle_t " , CONV_TYPE , API_RUNTIME ) ) , <nl> + ( <nl> + " cudaGraphicsCubeFace " , <nl> + ( " hipGraphicsCubeFace " , CONV_GRAPHICS , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaGraphicsMapFlags " , <nl> + ( " hipGraphicsMapFlags " , CONV_GRAPHICS , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaGraphicsRegisterFlags " , <nl> + ( " hipGraphicsRegisterFlags " , CONV_GRAPHICS , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaGLDeviceList " , <nl> + ( " hipGLDeviceList " , CONV_GL , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cudaGLMapFlags " , ( " hipGLMapFlags " , CONV_GL , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> + ( <nl> + " cudaD3D9DeviceList " , <nl> + ( " hipD3D9DeviceList " , CONV_D3D9 , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaD3D9MapFlags " , <nl> + ( " hipD3D9MapFlags " , CONV_D3D9 , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaD3D9RegisterFlags " , <nl> + ( " hipD3D9RegisterFlags " , CONV_D3D9 , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaD3D10DeviceList " , <nl> + ( " hipd3d10DeviceList " , CONV_D3D10 , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaD3D10MapFlags " , <nl> + ( " hipD3D10MapFlags " , CONV_D3D10 , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaD3D10RegisterFlags " , <nl> + ( " hipD3D10RegisterFlags " , CONV_D3D10 , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaD3D11DeviceList " , <nl> + ( " hipd3d11DeviceList " , CONV_D3D11 , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaEglStreamConnection " , <nl> + ( " hipEglStreamConnection " , CONV_EGL , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cublasHandle_t " , ( " rocblas_handle " , CONV_TYPE , API_BLAS ) ) , <nl> + ( " cublasOperation_t " , ( " rocblas_operation " , CONV_TYPE , API_BLAS ) ) , <nl> + ( " cublasStatus_t " , ( " rocblas_status " , CONV_TYPE , API_BLAS ) ) , <nl> + ( " cublasFillMode_t " , ( " rocblas_fill " , CONV_TYPE , API_BLAS ) ) , <nl> + ( " cublasDiagType_t " , ( " rocblas_diagonal " , CONV_TYPE , API_BLAS ) ) , <nl> + ( " cublasSideMode_t " , ( " rocblas_side " , CONV_TYPE , API_BLAS ) ) , <nl> + ( " cublasPointerMode_t " , ( " rocblas_pointer_mode " , CONV_TYPE , API_BLAS ) ) , <nl> + ( <nl> + " cublasAtomicsMode_t " , <nl> + ( " rocblas_atomics_mode " , CONV_TYPE , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasDataType_t " , <nl> + ( " rocblas_data_type " , CONV_TYPE , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " curandStatus " , ( " hiprandStatus_t " , CONV_TYPE , API_RAND ) ) , <nl> + ( " curandStatus_t " , ( " hiprandStatus_t " , CONV_TYPE , API_RAND ) ) , <nl> + ( " curandRngType " , ( " hiprandRngType_t " , CONV_TYPE , API_RAND ) ) , <nl> + ( " curandRngType_t " , ( " hiprandRngType_t " , CONV_TYPE , API_RAND ) ) , <nl> + ( " curandGenerator_st " , ( " hiprandGenerator_st " , CONV_TYPE , API_RAND ) ) , <nl> + ( " curandGenerator_t " , ( " hiprandGenerator_t " , CONV_TYPE , API_RAND ) ) , <nl> + ( <nl> + " curandDirectionVectorSet " , <nl> + ( " hiprandDirectionVectorSet_t " , CONV_TYPE , API_RAND , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " curandDirectionVectorSet_t " , <nl> + ( " hiprandDirectionVectorSet_t " , CONV_TYPE , API_RAND , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " curandOrdering " , ( " hiprandOrdering_t " , CONV_TYPE , API_RAND , HIP_UNSUPPORTED ) ) , <nl> + ( <nl> + " curandOrdering_t " , <nl> + ( " hiprandOrdering_t " , CONV_TYPE , API_RAND , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " curandDistribution_st " , <nl> + ( " hiprandDistribution_st " , CONV_TYPE , API_RAND , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " curandHistogramM2V_st " , <nl> + ( " hiprandDistribution_st " , CONV_TYPE , API_RAND , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " curandDistribution_t " , <nl> + ( " hiprandDistribution_t " , CONV_TYPE , API_RAND , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " curandHistogramM2V_t " , <nl> + ( " hiprandDistribution_t " , CONV_TYPE , API_RAND , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " curandDistributionShift_st " , <nl> + ( " hiprandDistributionShift_st " , CONV_TYPE , API_RAND , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " curandDistributionShift_t " , <nl> + ( " hiprandDistributionShift_t " , CONV_TYPE , API_RAND , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " curandDistributionM2Shift_st " , <nl> + ( " hiprandDistributionM2Shift_st " , CONV_TYPE , API_RAND , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " curandDistributionM2Shift_t " , <nl> + ( " hiprandDistributionM2Shift_t " , CONV_TYPE , API_RAND , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " curandHistogramM2_st " , <nl> + ( " hiprandHistogramM2_st " , CONV_TYPE , API_RAND , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " curandHistogramM2_t " , <nl> + ( " hiprandHistogramM2_t " , CONV_TYPE , API_RAND , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " curandHistogramM2K_st " , <nl> + ( " hiprandHistogramM2K_st " , CONV_TYPE , API_RAND , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " curandHistogramM2K_t " , <nl> + ( " hiprandHistogramM2K_t " , CONV_TYPE , API_RAND , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " curandDiscreteDistribution_st " , <nl> + ( " hiprandDiscreteDistribution_st " , CONV_TYPE , API_RAND ) , <nl> + ) , <nl> + ( <nl> + " curandDiscreteDistribution_t " , <nl> + ( " hiprandDiscreteDistribution_t " , CONV_TYPE , API_RAND ) , <nl> + ) , <nl> + ( " curandMethod " , ( " hiprandMethod_t " , CONV_TYPE , API_RAND , HIP_UNSUPPORTED ) ) , <nl> + ( " curandMethod_t " , ( " hiprandMethod_t " , CONV_TYPE , API_RAND , HIP_UNSUPPORTED ) ) , <nl> + ( <nl> + " curandDirectionVectors32_t " , <nl> + ( " hiprandDirectionVectors32_t " , CONV_TYPE , API_RAND ) , <nl> + ) , <nl> + ( <nl> + " curandDirectionVectors64_t " , <nl> + ( " hiprandDirectionVectors64_t " , CONV_TYPE , API_RAND , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " curandStateMtgp32_t " , ( " hiprandStateMtgp32_t " , CONV_TYPE , API_RAND ) ) , <nl> + ( " curandStateMtgp32 " , ( " hiprandStateMtgp32_t " , CONV_TYPE , API_RAND ) ) , <nl> + ( <nl> + " curandStateScrambledSobol64_t " , <nl> + ( " hiprandStateScrambledSobol64_t " , CONV_TYPE , API_RAND , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " curandStateSobol64_t " , <nl> + ( " hiprandStateSobol64_t " , CONV_TYPE , API_RAND , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " curandStateScrambledSobol32_t " , <nl> + ( " hiprandStateScrambledSobol32_t " , CONV_TYPE , API_RAND , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " curandStateSobol32_t " , ( " hiprandStateSobol32_t " , CONV_TYPE , API_RAND ) ) , <nl> + ( " curandStateMRG32k3a_t " , ( " hiprandStateMRG32k3a_t " , CONV_TYPE , API_RAND ) ) , <nl> + ( <nl> + " curandStatePhilox4_32_10_t " , <nl> + ( " hiprandStatePhilox4_32_10_t " , CONV_TYPE , API_RAND ) , <nl> + ) , <nl> + ( " curandStateXORWOW_t " , ( " hiprandStateXORWOW_t " , CONV_TYPE , API_RAND ) ) , <nl> + ( " curandState_t " , ( " hiprandState_t " , CONV_TYPE , API_RAND ) ) , <nl> + ( " curandState " , ( " hiprandState_t " , CONV_TYPE , API_RAND ) ) , <nl> + ] <nl> + ) <nl> + <nl> + CUDA_INCLUDE_MAP = collections . OrderedDict ( <nl> + [ <nl> + # since pytorch uses " \ b { pattern } \ b " as the actual re pattern , <nl> + # patterns listed here have to begin and end with alnum chars <nl> + ( <nl> + " include < cuda . h " , <nl> + ( " include < hip / hip_runtime . h " , CONV_INCLUDE_CUDA_MAIN_H , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + ' include " cuda . h ' , <nl> + ( ' include " hip / hip_runtime . h ' , CONV_INCLUDE_CUDA_MAIN_H , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " cuda_runtime . h " , <nl> + ( " hip / hip_runtime . h " , CONV_INCLUDE_CUDA_MAIN_H , API_RUNTIME ) , <nl> + ) , <nl> + ( " cuda_runtime_api . h " , ( " hip / hip_runtime_api . h " , CONV_INCLUDE , API_RUNTIME ) ) , <nl> + ( <nl> + " channel_descriptor . h " , <nl> + ( " hip / channel_descriptor . h " , CONV_INCLUDE , API_RUNTIME ) , <nl> + ) , <nl> + ( " device_functions . h " , ( " hip / device_functions . h " , CONV_INCLUDE , API_RUNTIME ) ) , <nl> + ( " driver_types . h " , ( " hip / driver_types . h " , CONV_INCLUDE , API_RUNTIME ) ) , <nl> + ( " cuComplex . h " , ( " hip / hip_complex . h " , CONV_INCLUDE , API_RUNTIME ) ) , <nl> + ( " cuda_fp16 . h " , ( " hip / hip_fp16 . h " , CONV_INCLUDE , API_RUNTIME ) ) , <nl> + ( <nl> + " cuda_texture_types . h " , <nl> + ( " hip / hip_texture_types . h " , CONV_INCLUDE , API_RUNTIME ) , <nl> + ) , <nl> + ( " vector_types . h " , ( " hip / hip_vector_types . h " , CONV_INCLUDE , API_RUNTIME ) ) , <nl> + ( " cublas . h " , ( " rocblas . h " , CONV_INCLUDE_CUDA_MAIN_H , API_BLAS ) ) , <nl> + ( " cublas_v2 . h " , ( " rocblas . h " , CONV_INCLUDE_CUDA_MAIN_H , API_BLAS ) ) , <nl> + ( " curand . h " , ( " hiprand . h " , CONV_INCLUDE_CUDA_MAIN_H , API_RAND ) ) , <nl> + ( " curand_kernel . h " , ( " hiprand_kernel . h " , CONV_INCLUDE , API_RAND ) ) , <nl> + ( " curand_discrete . h " , ( " hiprand_kernel . h " , CONV_INCLUDE , API_RAND ) ) , <nl> + ( " curand_discrete2 . h " , ( " hiprand_kernel . h " , CONV_INCLUDE , API_RAND ) ) , <nl> + ( " curand_globals . h " , ( " hiprand_kernel . h " , CONV_INCLUDE , API_RAND ) ) , <nl> + ( " curand_lognormal . h " , ( " hiprand_kernel . h " , CONV_INCLUDE , API_RAND ) ) , <nl> + ( " curand_mrg32k3a . h " , ( " hiprand_kernel . h " , CONV_INCLUDE , API_RAND ) ) , <nl> + ( " curand_mtgp32 . h " , ( " hiprand_kernel . h " , CONV_INCLUDE , API_RAND ) ) , <nl> + ( " curand_mtgp32_host . h " , ( " hiprand_mtgp32_host . h " , CONV_INCLUDE , API_RAND ) ) , <nl> + ( " curand_mtgp32_kernel . h " , ( " hiprand_kernel . h " , CONV_INCLUDE , API_RAND ) ) , <nl> + ( <nl> + " curand_mtgp32dc_p_11213 . h " , <nl> + ( " rocrand_mtgp32_11213 . h " , CONV_INCLUDE , API_RAND ) , <nl> + ) , <nl> + ( " curand_normal . h " , ( " hiprand_kernel . h " , CONV_INCLUDE , API_RAND ) ) , <nl> + ( " curand_normal_static . h " , ( " hiprand_kernel . h " , CONV_INCLUDE , API_RAND ) ) , <nl> + ( " curand_philox4x32_x . h " , ( " hiprand_kernel . h " , CONV_INCLUDE , API_RAND ) ) , <nl> + ( " curand_poisson . h " , ( " hiprand_kernel . h " , CONV_INCLUDE , API_RAND ) ) , <nl> + ( " curand_precalc . h " , ( " hiprand_kernel . h " , CONV_INCLUDE , API_RAND ) ) , <nl> + ( " curand_uniform . h " , ( " hiprand_kernel . h " , CONV_INCLUDE , API_RAND ) ) , <nl> + ( " cusparse . h " , ( " hipsparse . h " , CONV_INCLUDE , API_RAND ) ) , <nl> + ( " cufft . h " , ( " hipfft . h " , CONV_INCLUDE , API_BLAS ) ) , <nl> + ( " cufftXt . h " , ( " hipfft . h " , CONV_INCLUDE , API_BLAS ) ) , <nl> + # PyTorch also has a source file named " nccl . h " , so we need to " < " " > " to differentiate <nl> + ( " < nccl . h > " , ( " < rccl . h > " , CONV_INCLUDE , API_RUNTIME ) ) , <nl> + ( " nvrtc . h " , ( " hip / hiprtc . h " , CONV_INCLUDE , API_RTC ) ) , <nl> + ( " thrust / system / cuda " , ( " thrust / system / hip " , CONV_INCLUDE , API_BLAS ) ) , <nl> + ( " cub / util_allocator . cuh " , ( " hipcub / hipcub . hpp " , CONV_INCLUDE , API_BLAS ) ) , <nl> + ( " cub / block / block_reduce . cuh " , ( " hipcub / hipcub . hpp " , CONV_INCLUDE , API_BLAS ) ) , <nl> + ( " cub / cub . cuh " , ( " hipcub / hipcub . hpp " , CONV_INCLUDE , API_BLAS ) ) , <nl> + ( " cub / block / block_load . cuh " , ( " hipcub / hipcub . hpp " , CONV_INCLUDE , API_BLAS ) ) , <nl> + ( " cub / device / device_reduce . cuh " , ( " hipcub / hipcub . hpp " , CONV_INCLUDE , API_BLAS ) ) , <nl> + ( " cub / device / device_scan . cuh " , ( " hipcub / hipcub . hpp " , CONV_INCLUDE , API_BLAS ) ) , <nl> + ( " nvToolsExt . h " , ( " roctx . h " , CONV_INCLUDE , API_ROCTX ) ) , <nl> + ] <nl> + ) <nl> + <nl> + CUDA_IDENTIFIER_MAP = collections . OrderedDict ( <nl> + [ <nl> + ( " __CUDACC__ " , ( " __HIPCC__ " , CONV_DEF , API_RUNTIME ) ) , <nl> + ( <nl> + " CUDA_ERROR_INVALID_CONTEXT " , <nl> + ( " hipErrorInvalidContext " , CONV_TYPE , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " CUDA_ERROR_CONTEXT_ALREADY_CURRENT " , <nl> + ( " hipErrorContextAlreadyCurrent " , CONV_TYPE , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " CUDA_ERROR_ARRAY_IS_MAPPED " , <nl> + ( " hipErrorArrayIsMapped " , CONV_TYPE , API_DRIVER ) , <nl> + ) , <nl> + ( " CUDA_ERROR_ALREADY_MAPPED " , ( " hipErrorAlreadyMapped " , CONV_TYPE , API_DRIVER ) ) , <nl> + ( <nl> + " CUDA_ERROR_ALREADY_ACQUIRED " , <nl> + ( " hipErrorAlreadyAcquired " , CONV_TYPE , API_DRIVER ) , <nl> + ) , <nl> + ( " CUDA_ERROR_NOT_MAPPED " , ( " hipErrorNotMapped " , CONV_TYPE , API_DRIVER ) ) , <nl> + ( <nl> + " CUDA_ERROR_NOT_MAPPED_AS_ARRAY " , <nl> + ( " hipErrorNotMappedAsArray " , CONV_TYPE , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " CUDA_ERROR_NOT_MAPPED_AS_POINTER " , <nl> + ( " hipErrorNotMappedAsPointer " , CONV_TYPE , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " CUDA_ERROR_CONTEXT_ALREADY_IN_USE " , <nl> + ( " hipErrorContextAlreadyInUse " , CONV_TYPE , API_DRIVER ) , <nl> + ) , <nl> + ( " CUDA_ERROR_INVALID_SOURCE " , ( " hipErrorInvalidSource " , CONV_TYPE , API_DRIVER ) ) , <nl> + ( " CUDA_ERROR_FILE_NOT_FOUND " , ( " hipErrorFileNotFound " , CONV_TYPE , API_DRIVER ) ) , <nl> + ( " CUDA_ERROR_NOT_FOUND " , ( " hipErrorNotFound " , CONV_TYPE , API_DRIVER ) ) , <nl> + ( <nl> + " CUDA_ERROR_LAUNCH_INCOMPATIBLE_TEXTURING " , <nl> + ( <nl> + " hipErrorLaunchIncompatibleTexturing " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CUDA_ERROR_PRIMARY_CONTEXT_ACTIVE " , <nl> + ( " hipErrorPrimaryContextActive " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CUDA_ERROR_CONTEXT_IS_DESTROYED " , <nl> + ( " hipErrorContextIsDestroyed " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CUDA_ERROR_NOT_PERMITTED " , <nl> + ( " hipErrorNotPermitted " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CUDA_ERROR_NOT_SUPPORTED " , <nl> + ( " hipErrorNotSupported " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaErrorMissingConfiguration " , <nl> + ( " hipErrorMissingConfiguration " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaErrorPriorLaunchFailure " , <nl> + ( " hipErrorPriorLaunchFailure " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaErrorInvalidDeviceFunction " , <nl> + ( " hipErrorInvalidDeviceFunction " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaErrorInvalidConfiguration " , <nl> + ( " hipErrorInvalidConfiguration " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaErrorInvalidPitchValue " , <nl> + ( " hipErrorInvalidPitchValue " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaErrorInvalidSymbol " , <nl> + ( " hipErrorInvalidSymbol " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaErrorInvalidHostPointer " , <nl> + ( " hipErrorInvalidHostPointer " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaErrorInvalidDevicePointer " , <nl> + ( " hipErrorInvalidDevicePointer " , CONV_TYPE , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " cudaErrorInvalidTexture " , <nl> + ( " hipErrorInvalidTexture " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaErrorInvalidTextureBinding " , <nl> + ( " hipErrorInvalidTextureBinding " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaErrorInvalidChannelDescriptor " , <nl> + ( <nl> + " hipErrorInvalidChannelDescriptor " , <nl> + CONV_TYPE , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaErrorInvalidMemcpyDirection " , <nl> + ( " hipErrorInvalidMemcpyDirection " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaErrorAddressOfConstant " , <nl> + ( " hipErrorAddressOfConstant " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaErrorTextureFetchFailed " , <nl> + ( " hipErrorTextureFetchFailed " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaErrorTextureNotBound " , <nl> + ( " hipErrorTextureNotBound " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaErrorSynchronizationError " , <nl> + ( " hipErrorSynchronizationError " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaErrorInvalidFilterSetting " , <nl> + ( " hipErrorInvalidFilterSetting " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaErrorInvalidNormSetting " , <nl> + ( " hipErrorInvalidNormSetting " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaErrorMixedDeviceExecution " , <nl> + ( " hipErrorMixedDeviceExecution " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaErrorNotYetImplemented " , <nl> + ( " hipErrorNotYetImplemented " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaErrorMemoryValueTooLarge " , <nl> + ( " hipErrorMemoryValueTooLarge " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaErrorInsufficientDriver " , <nl> + ( " hipErrorInsufficientDriver " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaErrorSetOnActiveProcess " , <nl> + ( " hipErrorSetOnActiveProcess " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaErrorInvalidSurface " , <nl> + ( " hipErrorInvalidSurface " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaErrorDuplicateVariableName " , <nl> + ( " hipErrorDuplicateVariableName " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaErrorDuplicateTextureName " , <nl> + ( " hipErrorDuplicateTextureName " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaErrorDuplicateSurfaceName " , <nl> + ( " hipErrorDuplicateSurfaceName " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaErrorDevicesUnavailable " , <nl> + ( " hipErrorDevicesUnavailable " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaErrorIncompatibleDriverContext " , <nl> + ( <nl> + " hipErrorIncompatibleDriverContext " , <nl> + CONV_TYPE , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaErrorDeviceAlreadyInUse " , <nl> + ( " hipErrorDeviceAlreadyInUse " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaErrorLaunchMaxDepthExceeded " , <nl> + ( " hipErrorLaunchMaxDepthExceeded " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaErrorLaunchFileScopedTex " , <nl> + ( " hipErrorLaunchFileScopedTex " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaErrorLaunchFileScopedSurf " , <nl> + ( " hipErrorLaunchFileScopedSurf " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaErrorSyncDepthExceeded " , <nl> + ( " hipErrorSyncDepthExceeded " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaErrorLaunchPendingCountExceeded " , <nl> + ( <nl> + " hipErrorLaunchPendingCountExceeded " , <nl> + CONV_TYPE , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaErrorNotPermitted " , <nl> + ( " hipErrorNotPermitted " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaErrorNotSupported " , <nl> + ( " hipErrorNotSupported " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaErrorStartupFailure " , <nl> + ( " hipErrorStartupFailure " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaErrorApiFailureBase " , <nl> + ( " hipErrorApiFailureBase " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " CUDA_SUCCESS " , ( " hipSuccess " , CONV_TYPE , API_DRIVER ) ) , <nl> + ( " cudaSuccess " , ( " hipSuccess " , CONV_TYPE , API_RUNTIME ) ) , <nl> + ( " CUDA_ERROR_INVALID_VALUE " , ( " hipErrorInvalidValue " , CONV_TYPE , API_DRIVER ) ) , <nl> + ( " cudaErrorInvalidValue " , ( " hipErrorInvalidValue " , CONV_TYPE , API_RUNTIME ) ) , <nl> + ( <nl> + " CUDA_ERROR_OUT_OF_MEMORY " , <nl> + ( " hipErrorMemoryAllocation " , CONV_TYPE , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " cudaErrorMemoryAllocation " , <nl> + ( " hipErrorMemoryAllocation " , CONV_TYPE , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " CUDA_ERROR_NOT_INITIALIZED " , <nl> + ( " hipErrorNotInitialized " , CONV_TYPE , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " cudaErrorInitializationError " , <nl> + ( " hipErrorInitializationError " , CONV_TYPE , API_RUNTIME ) , <nl> + ) , <nl> + ( " CUDA_ERROR_DEINITIALIZED " , ( " hipErrorDeinitialized " , CONV_TYPE , API_DRIVER ) ) , <nl> + ( <nl> + " cudaErrorCudartUnloading " , <nl> + ( " hipErrorDeinitialized " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CUDA_ERROR_PROFILER_DISABLED " , <nl> + ( " hipErrorProfilerDisabled " , CONV_TYPE , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " cudaErrorProfilerDisabled " , <nl> + ( " hipErrorProfilerDisabled " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CUDA_ERROR_PROFILER_NOT_INITIALIZED " , <nl> + ( " hipErrorProfilerNotInitialized " , CONV_TYPE , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " cudaErrorProfilerNotInitialized " , <nl> + ( " hipErrorProfilerNotInitialized " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CUDA_ERROR_PROFILER_ALREADY_STARTED " , <nl> + ( " hipErrorProfilerAlreadyStarted " , CONV_TYPE , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " cudaErrorProfilerAlreadyStarted " , <nl> + ( " hipErrorProfilerAlreadyStarted " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CUDA_ERROR_PROFILER_ALREADY_STOPPED " , <nl> + ( " hipErrorProfilerAlreadyStopped " , CONV_TYPE , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " cudaErrorProfilerAlreadyStopped " , <nl> + ( " hipErrorProfilerAlreadyStopped " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " CUDA_ERROR_NO_DEVICE " , ( " hipErrorNoDevice " , CONV_TYPE , API_DRIVER ) ) , <nl> + ( " cudaErrorNoDevice " , ( " hipErrorNoDevice " , CONV_TYPE , API_RUNTIME ) ) , <nl> + ( " CUDA_ERROR_INVALID_DEVICE " , ( " hipErrorInvalidDevice " , CONV_TYPE , API_DRIVER ) ) , <nl> + ( " cudaErrorInvalidDevice " , ( " hipErrorInvalidDevice " , CONV_TYPE , API_RUNTIME ) ) , <nl> + ( " CUDA_ERROR_INVALID_IMAGE " , ( " hipErrorInvalidImage " , CONV_TYPE , API_DRIVER ) ) , <nl> + ( <nl> + " cudaErrorInvalidKernelImage " , <nl> + ( " hipErrorInvalidImage " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " CUDA_ERROR_MAP_FAILED " , ( " hipErrorMapFailed " , CONV_TYPE , API_DRIVER ) ) , <nl> + ( <nl> + " cudaErrorMapBufferObjectFailed " , <nl> + ( " hipErrorMapFailed " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " CUDA_ERROR_UNMAP_FAILED " , ( " hipErrorUnmapFailed " , CONV_TYPE , API_DRIVER ) ) , <nl> + ( <nl> + " cudaErrorUnmapBufferObjectFailed " , <nl> + ( " hipErrorUnmapFailed " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CUDA_ERROR_NO_BINARY_FOR_GPU " , <nl> + ( " hipErrorNoBinaryForGpu " , CONV_TYPE , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " cudaErrorNoKernelImageForDevice " , <nl> + ( " hipErrorNoBinaryForGpu " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CUDA_ERROR_ECC_UNCORRECTABLE " , <nl> + ( " hipErrorECCNotCorrectable " , CONV_TYPE , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " cudaErrorECCUncorrectable " , <nl> + ( " hipErrorECCNotCorrectable " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CUDA_ERROR_UNSUPPORTED_LIMIT " , <nl> + ( " hipErrorUnsupportedLimit " , CONV_TYPE , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " cudaErrorUnsupportedLimit " , <nl> + ( " hipErrorUnsupportedLimit " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CUDA_ERROR_PEER_ACCESS_UNSUPPORTED " , <nl> + ( " hipErrorPeerAccessUnsupported " , CONV_TYPE , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " cudaErrorPeerAccessUnsupported " , <nl> + ( " hipErrorPeerAccessUnsupported " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CUDA_ERROR_INVALID_PTX " , <nl> + ( " hipErrorInvalidKernelFile " , CONV_TYPE , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " cudaErrorInvalidPtx " , <nl> + ( " hipErrorInvalidKernelFile " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CUDA_ERROR_INVALID_GRAPHICS_CONTEXT " , <nl> + ( " hipErrorInvalidGraphicsContext " , CONV_TYPE , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " cudaErrorInvalidGraphicsContext " , <nl> + ( " hipErrorInvalidGraphicsContext " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CUDA_ERROR_NVLINK_UNCORRECTABLE " , <nl> + ( " hipErrorNvlinkUncorrectable " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaErrorNvlinkUncorrectable " , <nl> + ( " hipErrorNvlinkUncorrectable " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CUDA_ERROR_SHARED_OBJECT_SYMBOL_NOT_FOUND " , <nl> + ( " hipErrorSharedObjectSymbolNotFound " , CONV_TYPE , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " cudaErrorSharedObjectSymbolNotFound " , <nl> + ( <nl> + " hipErrorSharedObjectSymbolNotFound " , <nl> + CONV_TYPE , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CUDA_ERROR_SHARED_OBJECT_INIT_FAILED " , <nl> + ( " hipErrorSharedObjectInitFailed " , CONV_TYPE , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " cudaErrorSharedObjectInitFailed " , <nl> + ( " hipErrorSharedObjectInitFailed " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CUDA_ERROR_OPERATING_SYSTEM " , <nl> + ( " hipErrorOperatingSystem " , CONV_TYPE , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " cudaErrorOperatingSystem " , <nl> + ( " hipErrorOperatingSystem " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CUDA_ERROR_INVALID_HANDLE " , <nl> + ( " hipErrorInvalidResourceHandle " , CONV_TYPE , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " cudaErrorInvalidResourceHandle " , <nl> + ( " hipErrorInvalidResourceHandle " , CONV_TYPE , API_RUNTIME ) , <nl> + ) , <nl> + ( " CUDA_ERROR_NOT_READY " , ( " hipErrorNotReady " , CONV_TYPE , API_DRIVER ) ) , <nl> + ( " cudaErrorNotReady " , ( " hipErrorNotReady " , CONV_TYPE , API_RUNTIME ) ) , <nl> + ( <nl> + " CUDA_ERROR_ILLEGAL_ADDRESS " , <nl> + ( " hipErrorIllegalAddress " , CONV_TYPE , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " cudaErrorIllegalAddress " , <nl> + ( " hipErrorIllegalAddress " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CUDA_ERROR_LAUNCH_OUT_OF_RESOURCES " , <nl> + ( " hipErrorLaunchOutOfResources " , CONV_TYPE , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " cudaErrorLaunchOutOfResources " , <nl> + ( " hipErrorLaunchOutOfResources " , CONV_TYPE , API_RUNTIME ) , <nl> + ) , <nl> + ( " CUDA_ERROR_LAUNCH_TIMEOUT " , ( " hipErrorLaunchTimeOut " , CONV_TYPE , API_DRIVER ) ) , <nl> + ( <nl> + " cudaErrorLaunchTimeout " , <nl> + ( " hipErrorLaunchTimeOut " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CUDA_ERROR_PEER_ACCESS_ALREADY_ENABLED " , <nl> + ( " hipErrorPeerAccessAlreadyEnabled " , CONV_TYPE , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " cudaErrorPeerAccessAlreadyEnabled " , <nl> + ( " hipErrorPeerAccessAlreadyEnabled " , CONV_TYPE , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " CUDA_ERROR_PEER_ACCESS_NOT_ENABLED " , <nl> + ( " hipErrorPeerAccessNotEnabled " , CONV_TYPE , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " cudaErrorPeerAccessNotEnabled " , <nl> + ( " hipErrorPeerAccessNotEnabled " , CONV_TYPE , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " CUDA_ERROR_ASSERT " , <nl> + ( " hipErrorAssert " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaErrorAssert " , <nl> + ( " hipErrorAssert " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CUDA_ERROR_TOO_MANY_PEERS " , <nl> + ( " hipErrorTooManyPeers " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaErrorTooManyPeers " , <nl> + ( " hipErrorTooManyPeers " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CUDA_ERROR_HOST_MEMORY_ALREADY_REGISTERED " , <nl> + ( " hipErrorHostMemoryAlreadyRegistered " , CONV_TYPE , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " cudaErrorHostMemoryAlreadyRegistered " , <nl> + ( " hipErrorHostMemoryAlreadyRegistered " , CONV_TYPE , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " CUDA_ERROR_HOST_MEMORY_NOT_REGISTERED " , <nl> + ( " hipErrorHostMemoryNotRegistered " , CONV_TYPE , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " cudaErrorHostMemoryNotRegistered " , <nl> + ( " hipErrorHostMemoryNotRegistered " , CONV_TYPE , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " CUDA_ERROR_HARDWARE_STACK_ERROR " , <nl> + ( " hipErrorHardwareStackError " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaErrorHardwareStackError " , <nl> + ( " hipErrorHardwareStackError " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CUDA_ERROR_ILLEGAL_INSTRUCTION " , <nl> + ( " hipErrorIllegalInstruction " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaErrorIllegalInstruction " , <nl> + ( " hipErrorIllegalInstruction " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CUDA_ERROR_MISALIGNED_ADDRESS " , <nl> + ( " hipErrorMisalignedAddress " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaErrorMisalignedAddress " , <nl> + ( " hipErrorMisalignedAddress " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CUDA_ERROR_INVALID_ADDRESS_SPACE " , <nl> + ( " hipErrorInvalidAddressSpace " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaErrorInvalidAddressSpace " , <nl> + ( " hipErrorInvalidAddressSpace " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CUDA_ERROR_INVALID_PC " , <nl> + ( " hipErrorInvalidPc " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaErrorInvalidPc " , <nl> + ( " hipErrorInvalidPc " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CUDA_ERROR_LAUNCH_FAILED " , <nl> + ( " hipErrorLaunchFailure " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaErrorLaunchFailure " , <nl> + ( " hipErrorLaunchFailure " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CUDA_ERROR_UNKNOWN " , <nl> + ( " hipErrorUnknown " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cudaErrorUnknown " , ( " hipErrorUnknown " , CONV_TYPE , API_RUNTIME ) ) , <nl> + ( <nl> + " CU_TR_ADDRESS_MODE_WRAP " , <nl> + ( " HIP_TR_ADDRESS_MODE_WRAP " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_TR_ADDRESS_MODE_CLAMP " , <nl> + ( " HIP_TR_ADDRESS_MODE_CLAMP " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_TR_ADDRESS_MODE_MIRROR " , <nl> + ( " HIP_TR_ADDRESS_MODE_MIRROR " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_TR_ADDRESS_MODE_BORDER " , <nl> + ( " HIP_TR_ADDRESS_MODE_BORDER " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_CUBEMAP_FACE_POSITIVE_X " , <nl> + ( " HIP_CUBEMAP_FACE_POSITIVE_X " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_CUBEMAP_FACE_NEGATIVE_X " , <nl> + ( " HIP_CUBEMAP_FACE_NEGATIVE_X " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_CUBEMAP_FACE_POSITIVE_Y " , <nl> + ( " HIP_CUBEMAP_FACE_POSITIVE_Y " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_CUBEMAP_FACE_NEGATIVE_Y " , <nl> + ( " HIP_CUBEMAP_FACE_NEGATIVE_Y " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_CUBEMAP_FACE_POSITIVE_Z " , <nl> + ( " HIP_CUBEMAP_FACE_POSITIVE_Z " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_CUBEMAP_FACE_NEGATIVE_Z " , <nl> + ( " HIP_CUBEMAP_FACE_NEGATIVE_Z " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_AD_FORMAT_UNSIGNED_INT8 " , <nl> + ( " HIP_AD_FORMAT_UNSIGNED_INT8 " , CONV_TYPE , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " CU_AD_FORMAT_UNSIGNED_INT16 " , <nl> + ( " HIP_AD_FORMAT_UNSIGNED_INT16 " , CONV_TYPE , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " CU_AD_FORMAT_UNSIGNED_INT32 " , <nl> + ( " HIP_AD_FORMAT_UNSIGNED_INT32 " , CONV_TYPE , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " CU_AD_FORMAT_SIGNED_INT8 " , <nl> + ( " HIP_AD_FORMAT_SIGNED_INT8 " , CONV_TYPE , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " CU_AD_FORMAT_SIGNED_INT16 " , <nl> + ( " HIP_AD_FORMAT_SIGNED_INT16 " , CONV_TYPE , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " CU_AD_FORMAT_SIGNED_INT32 " , <nl> + ( " HIP_AD_FORMAT_SIGNED_INT32 " , CONV_TYPE , API_DRIVER ) , <nl> + ) , <nl> + ( " CU_AD_FORMAT_HALF " , ( " HIP_AD_FORMAT_HALF " , CONV_TYPE , API_DRIVER ) ) , <nl> + ( " CU_AD_FORMAT_FLOAT " , ( " HIP_AD_FORMAT_FLOAT " , CONV_TYPE , API_DRIVER ) ) , <nl> + ( <nl> + " CU_COMPUTEMODE_DEFAULT " , <nl> + ( " hipComputeModeDefault " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_COMPUTEMODE_EXCLUSIVE " , <nl> + ( " hipComputeModeExclusive " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_COMPUTEMODE_PROHIBITED " , <nl> + ( " hipComputeModeProhibited " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_COMPUTEMODE_EXCLUSIVE_PROCESS " , <nl> + ( " hipComputeModeExclusiveProcess " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_MEM_ADVISE_SET_READ_MOSTLY " , <nl> + ( " hipMemAdviseSetReadMostly " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_MEM_ADVISE_UNSET_READ_MOSTLY " , <nl> + ( " hipMemAdviseUnsetReadMostly " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_MEM_ADVISE_SET_PREFERRED_LOCATION " , <nl> + ( <nl> + " hipMemAdviseSetPreferredLocation " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_MEM_ADVISE_UNSET_PREFERRED_LOCATION " , <nl> + ( <nl> + " hipMemAdviseUnsetPreferredLocation " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_MEM_ADVISE_SET_ACCESSED_BY " , <nl> + ( " hipMemAdviseSetAccessedBy " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_MEM_ADVISE_UNSET_ACCESSED_BY " , <nl> + ( " hipMemAdviseUnsetAccessedBy " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_MEM_RANGE_ATTRIBUTE_READ_MOSTLY " , <nl> + ( " hipMemRangeAttributeReadMostly " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_MEM_RANGE_ATTRIBUTE_PREFERRED_LOCATION " , <nl> + ( <nl> + " hipMemRangeAttributePreferredLocation " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_MEM_RANGE_ATTRIBUTE_ACCESSED_BY " , <nl> + ( " hipMemRangeAttributeAccessedBy " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_MEM_RANGE_ATTRIBUTE_LAST_PREFETCH_LOCATION " , <nl> + ( <nl> + " hipMemRangeAttributeLastPrefetchLocation " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_CTX_SCHED_AUTO " , <nl> + ( " HIP_CTX_SCHED_AUTO " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_CTX_SCHED_SPIN " , <nl> + ( " HIP_CTX_SCHED_SPIN " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_CTX_SCHED_YIELD " , <nl> + ( " HIP_CTX_SCHED_YIELD " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_CTX_SCHED_BLOCKING_SYNC " , <nl> + ( " HIP_CTX_SCHED_BLOCKING_SYNC " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_CTX_BLOCKING_SYNC " , <nl> + ( " HIP_CTX_BLOCKING_SYNC " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_CTX_SCHED_MASK " , <nl> + ( " HIP_CTX_SCHED_MASK " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_CTX_MAP_HOST " , <nl> + ( " HIP_CTX_MAP_HOST " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_CTX_LMEM_RESIZE_TO_MAX " , <nl> + ( " HIP_CTX_LMEM_RESIZE_TO_MAX " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_CTX_FLAGS_MASK " , <nl> + ( " HIP_CTX_FLAGS_MASK " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_LAUNCH_PARAM_BUFFER_POINTER " , <nl> + ( " HIP_LAUNCH_PARAM_BUFFER_POINTER " , CONV_TYPE , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " CU_LAUNCH_PARAM_BUFFER_SIZE " , <nl> + ( " HIP_LAUNCH_PARAM_BUFFER_SIZE " , CONV_TYPE , API_DRIVER ) , <nl> + ) , <nl> + ( " CU_LAUNCH_PARAM_END " , ( " HIP_LAUNCH_PARAM_END " , CONV_TYPE , API_DRIVER ) ) , <nl> + ( <nl> + " CU_IPC_HANDLE_SIZE " , <nl> + ( " HIP_LAUNCH_PARAM_END " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_MEMHOSTALLOC_DEVICEMAP " , <nl> + ( " HIP_MEMHOSTALLOC_DEVICEMAP " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_MEMHOSTALLOC_PORTABLE " , <nl> + ( " HIP_MEMHOSTALLOC_PORTABLE " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_MEMHOSTALLOC_WRITECOMBINED " , <nl> + ( " HIP_MEMHOSTALLOC_WRITECOMBINED " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_MEMHOSTREGISTER_DEVICEMAP " , <nl> + ( " HIP_MEMHOSTREGISTER_DEVICEMAP " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_MEMHOSTREGISTER_IOMEMORY " , <nl> + ( " HIP_MEMHOSTREGISTER_IOMEMORY " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_MEMHOSTREGISTER_PORTABLE " , <nl> + ( " HIP_MEMHOSTREGISTER_PORTABLE " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_PARAM_TR_DEFAULT " , <nl> + ( " HIP_PARAM_TR_DEFAULT " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_STREAM_LEGACY " , <nl> + ( " HIP_STREAM_LEGACY " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_STREAM_PER_THREAD " , <nl> + ( " HIP_STREAM_PER_THREAD " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_TRSA_OVERRIDE_FORMAT " , <nl> + ( " HIP_TRSA_OVERRIDE_FORMAT " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_TRSF_NORMALIZED_COORDINATES " , <nl> + ( " HIP_TRSF_NORMALIZED_COORDINATES " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_TRSF_READ_AS_INTEGER " , <nl> + ( " HIP_TRSF_READ_AS_INTEGER " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " CU_TRSF_SRGB " , ( " HIP_TRSF_SRGB " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> + ( <nl> + " CUDA_ARRAY3D_2DARRAY " , <nl> + ( " HIP_ARRAY3D_LAYERED " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CUDA_ARRAY3D_CUBEMAP " , <nl> + ( " HIP_ARRAY3D_CUBEMAP " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CUDA_ARRAY3D_DEPTH_TEXTURE " , <nl> + ( " HIP_ARRAY3D_DEPTH_TEXTURE " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CUDA_ARRAY3D_LAYERED " , <nl> + ( " HIP_ARRAY3D_LAYERED " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CUDA_ARRAY3D_SURFACE_LDST " , <nl> + ( " HIP_ARRAY3D_SURFACE_LDST " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CUDA_ARRAY3D_TEXTURE_GATHER " , <nl> + ( " HIP_ARRAY3D_TEXTURE_GATHER " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_MAX_THREADS_PER_BLOCK " , <nl> + ( <nl> + " hipDeviceAttributeMaxThreadsPerBlock " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_MAX_BLOCK_DIM_X " , <nl> + ( " hipDeviceAttributeMaxBlockDimX " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_MAX_BLOCK_DIM_Y " , <nl> + ( " hipDeviceAttributeMaxBlockDimY " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_MAX_BLOCK_DIM_Z " , <nl> + ( " hipDeviceAttributeMaxBlockDimZ " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_MAX_GRID_DIM_X " , <nl> + ( " hipDeviceAttributeMaxGridDimX " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_MAX_GRID_DIM_Y " , <nl> + ( " hipDeviceAttributeMaxGridDimY " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_MAX_GRID_DIM_Z " , <nl> + ( " hipDeviceAttributeMaxGridDimZ " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_BLOCK " , <nl> + ( <nl> + " hipDeviceAttributeMaxSharedMemoryPerBlock " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_SHARED_MEMORY_PER_BLOCK " , <nl> + ( <nl> + " hipDeviceAttributeMaxSharedMemoryPerBlock " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_TOTAL_CONSTANT_MEMORY " , <nl> + ( <nl> + " hipDeviceAttributeTotalConstantMemory " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_WARP_SIZE " , <nl> + ( " hipDeviceAttributeWarpSize " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_MAX_PITCH " , <nl> + ( " hipDeviceAttributeMaxPitch " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_MAX_REGISTERS_PER_BLOCK " , <nl> + ( <nl> + " hipDeviceAttributeMaxRegistersPerBlock " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_REGISTERS_PER_BLOCK " , <nl> + ( <nl> + " hipDeviceAttributeMaxRegistersPerBlock " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_CLOCK_RATE " , <nl> + ( " hipDeviceAttributeClockRate " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_TEXTURE_ALIGNMENT " , <nl> + ( <nl> + " hipDeviceAttributeTextureAlignment " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_GPU_OVERLAP " , <nl> + ( <nl> + " hipDeviceAttributeAsyncEngineCount " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_MULTIPROCESSOR_COUNT " , <nl> + ( <nl> + " hipDeviceAttributeMultiprocessorCount " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_KERNEL_EXEC_TIMEOUT " , <nl> + ( <nl> + " hipDeviceAttributeKernelExecTimeout " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_INTEGRATED " , <nl> + ( " hipDeviceAttributeIntegrated " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_CAN_MAP_HOST_MEMORY " , <nl> + ( <nl> + " hipDeviceAttributeCanMapHostMemory " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_COMPUTE_MODE " , <nl> + ( " hipDeviceAttributeComputeMode " , CONV_TYPE , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_WIDTH " , <nl> + ( <nl> + " hipDeviceAttributeMaxTexture1DWidth " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_WIDTH " , <nl> + ( <nl> + " hipDeviceAttributeMaxTexture2DWidth " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_HEIGHT " , <nl> + ( <nl> + " hipDeviceAttributeMaxTexture2DHeight " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_WIDTH " , <nl> + ( <nl> + " hipDeviceAttributeMaxTexture3DWidth " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_HEIGHT " , <nl> + ( <nl> + " hipDeviceAttributeMaxTexture3DHeight " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_DEPTH " , <nl> + ( <nl> + " hipDeviceAttributeMaxTexture3DDepth " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LAYERED_WIDTH " , <nl> + ( <nl> + " hipDeviceAttributeMaxTexture2DLayeredWidth " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LAYERED_HEIGHT " , <nl> + ( <nl> + " hipDeviceAttributeMaxTexture2DLayeredHeight " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LAYERED_LAYERS " , <nl> + ( <nl> + " hipDeviceAttributeMaxTexture2DLayeredLayers " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_ARRAY_WIDTH " , <nl> + ( <nl> + " hipDeviceAttributeMaxTexture2DLayeredWidth " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_ARRAY_HEIGHT " , <nl> + ( <nl> + " hipDeviceAttributeMaxTexture2DLayeredHeight " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_ARRAY_NUMSLICES " , <nl> + ( <nl> + " hipDeviceAttributeMaxTexture2DLayeredLayers " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_SURFACE_ALIGNMENT " , <nl> + ( <nl> + " hipDeviceAttributeSurfaceAlignment " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_CONCURRENT_KERNELS " , <nl> + ( " hipDeviceAttributeConcurrentKernels " , CONV_TYPE , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_ECC_ENABLED " , <nl> + ( " hipDeviceAttributeEccEnabled " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_PCI_BUS_ID " , <nl> + ( " hipDeviceAttributePciBusId " , CONV_TYPE , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_PCI_DEVICE_ID " , <nl> + ( " hipDeviceAttributePciDeviceId " , CONV_TYPE , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_TCC_DRIVER " , <nl> + ( " hipDeviceAttributeTccDriver " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_MEMORY_CLOCK_RATE " , <nl> + ( <nl> + " hipDeviceAttributeMemoryClockRate " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_GLOBAL_MEMORY_BUS_WIDTH " , <nl> + ( " hipDeviceAttributeMemoryBusWidth " , CONV_TYPE , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_L2_CACHE_SIZE " , <nl> + ( " hipDeviceAttributeL2CacheSize " , CONV_TYPE , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_MAX_THREADS_PER_MULTIPROCESSOR " , <nl> + ( " hipDeviceAttributeMaxThreadsPerMultiProcessor " , CONV_TYPE , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_ASYNC_ENGINE_COUNT " , <nl> + ( <nl> + " hipDeviceAttributeAsyncEngineCount " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_UNIFIED_ADDRESSING " , <nl> + ( <nl> + " hipDeviceAttributeUnifiedAddressing " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_LAYERED_WIDTH " , <nl> + ( <nl> + " hipDeviceAttributeMaxTexture1DLayeredWidth " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_LAYERED_LAYERS " , <nl> + ( <nl> + " hipDeviceAttributeMaxTexture1DLayeredLayers " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_CAN_TEX2D_GATHER " , <nl> + ( <nl> + " hipDeviceAttributeCanTex2DGather " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_GATHER_WIDTH " , <nl> + ( <nl> + " hipDeviceAttributeMaxTexture2DGatherWidth " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_GATHER_HEIGHT " , <nl> + ( <nl> + " hipDeviceAttributeMaxTexture2DGatherHeight " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_WIDTH_ALTERNATE " , <nl> + ( <nl> + " hipDeviceAttributeMaxTexture3DWidthAlternate " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_HEIGHT_ALTERNATE " , <nl> + ( <nl> + " hipDeviceAttributeMaxTexture3DHeightAlternate " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_DEPTH_ALTERNATE " , <nl> + ( <nl> + " hipDeviceAttributeMaxTexture3DDepthAlternate " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_PCI_DOMAIN_ID " , <nl> + ( " hipDeviceAttributePciDomainId " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_TEXTURE_PITCH_ALIGNMENT " , <nl> + ( <nl> + " hipDeviceAttributeTexturePitchAlignment " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURECUBEMAP_WIDTH " , <nl> + ( <nl> + " hipDeviceAttributeMaxTextureCubemapWidth " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURECUBEMAP_LAYERED_WIDTH " , <nl> + ( <nl> + " hipDeviceAttributeMaxTextureCubemapLayeredWidth " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURECUBEMAP_LAYERED_LAYERS " , <nl> + ( <nl> + " hipDeviceAttributeMaxTextureCubemapLayeredLayers " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE1D_WIDTH " , <nl> + ( <nl> + " hipDeviceAttributeMaxSurface1DWidth " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_WIDTH " , <nl> + ( <nl> + " hipDeviceAttributeMaxSurface2DWidth " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_HEIGHT " , <nl> + ( <nl> + " hipDeviceAttributeMaxSurface2DHeight " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE3D_WIDTH " , <nl> + ( <nl> + " hipDeviceAttributeMaxSurface3DWidth " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE3D_HEIGHT " , <nl> + ( <nl> + " hipDeviceAttributeMaxSurface3DHeight " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE3D_DEPTH " , <nl> + ( <nl> + " hipDeviceAttributeMaxSurface3DDepth " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE1D_LAYERED_WIDTH " , <nl> + ( <nl> + " hipDeviceAttributeMaxSurface1DLayeredWidth " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE1D_LAYERED_LAYERS " , <nl> + ( <nl> + " hipDeviceAttributeMaxSurface1DLayeredLayers " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_LAYERED_WIDTH " , <nl> + ( <nl> + " hipDeviceAttributeMaxSurface2DLayeredWidth " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_LAYERED_HEIGHT " , <nl> + ( <nl> + " hipDeviceAttributeMaxSurface2DLayeredHeight " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_LAYERED_LAYERS " , <nl> + ( <nl> + " hipDeviceAttributeMaxSurface2DLayeredLayers " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACECUBEMAP_WIDTH " , <nl> + ( <nl> + " hipDeviceAttributeMaxSurfaceCubemapWidth " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACECUBEMAP_LAYERED_WIDTH " , <nl> + ( <nl> + " hipDeviceAttributeMaxSurfaceCubemapLayeredWidth " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACECUBEMAP_LAYERED_LAYERS " , <nl> + ( <nl> + " hipDeviceAttributeMaxSurfaceCubemapLayeredLayers " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_LINEAR_WIDTH " , <nl> + ( <nl> + " hipDeviceAttributeMaxTexture1DLinearWidth " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LINEAR_WIDTH " , <nl> + ( <nl> + " hipDeviceAttributeMaxTexture2DLinearWidth " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LINEAR_HEIGHT " , <nl> + ( <nl> + " hipDeviceAttributeMaxTexture2DLinearHeight " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LINEAR_PITCH " , <nl> + ( <nl> + " hipDeviceAttributeMaxTexture2DLinearPitch " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_MIPMAPPED_WIDTH " , <nl> + ( <nl> + " hipDeviceAttributeMaxTexture2DMipmappedWidth " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_MIPMAPPED_HEIGHT " , <nl> + ( <nl> + " hipDeviceAttributeMaxTexture2DMipmappedHeight " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR " , <nl> + ( " hipDeviceAttributeComputeCapabilityMajor " , CONV_TYPE , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR " , <nl> + ( " hipDeviceAttributeComputeCapabilityMinor " , CONV_TYPE , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_MIPMAPPED_WIDTH " , <nl> + ( <nl> + " hipDeviceAttributeMaxTexture1DMipmappedWidth " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_STREAM_PRIORITIES_SUPPORTED " , <nl> + ( <nl> + " hipDeviceAttributeStreamPrioritiesSupported " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_GLOBAL_L1_CACHE_SUPPORTED " , <nl> + ( <nl> + " hipDeviceAttributeGlobalL1CacheSupported " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_LOCAL_L1_CACHE_SUPPORTED " , <nl> + ( <nl> + " hipDeviceAttributeLocalL1CacheSupported " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_MULTIPROCESSOR " , <nl> + ( <nl> + " hipDeviceAttributeMaxSharedMemoryPerMultiprocessor " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_MAX_REGISTERS_PER_MULTIPROCESSOR " , <nl> + ( <nl> + " hipDeviceAttributeMaxRegistersPerMultiprocessor " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_MANAGED_MEMORY " , <nl> + ( " hipDeviceAttributeManagedMemory " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_MULTI_GPU_BOARD " , <nl> + ( " hipDeviceAttributeIsMultiGpuBoard " , CONV_TYPE , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_MULTI_GPU_BOARD_GROUP_ID " , <nl> + ( <nl> + " hipDeviceAttributeMultiGpuBoardGroupId " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_HOST_NATIVE_ATOMIC_SUPPORTED " , <nl> + ( <nl> + " hipDeviceAttributeHostNativeAtomicSupported " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_SINGLE_TO_DOUBLE_PRECISION_PERF_RATIO " , <nl> + ( <nl> + " hipDeviceAttributeSingleToDoublePrecisionPerfRatio " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_PAGEABLE_MEMORY_ACCESS " , <nl> + ( <nl> + " hipDeviceAttributePageableMemoryAccess " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS " , <nl> + ( <nl> + " hipDeviceAttributeConcurrentManagedAccess " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_COMPUTE_PREEMPTION_SUPPORTED " , <nl> + ( <nl> + " hipDeviceAttributeComputePreemptionSupported " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_CAN_USE_HOST_POINTER_FOR_REGISTERED_MEM " , <nl> + ( <nl> + " hipDeviceAttributeCanUseHostPointerForRegisteredMem " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_ATTRIBUTE_MAX " , <nl> + ( " hipDeviceAttributeMax " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_POINTER_ATTRIBUTE_CONTEXT " , <nl> + ( " hipPointerAttributeContext " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_POINTER_ATTRIBUTE_MEMORY_TYPE " , <nl> + ( " hipPointerAttributeMemoryType " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_POINTER_ATTRIBUTE_DEVICE_POINTER " , <nl> + ( <nl> + " hipPointerAttributeDevicePointer " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_POINTER_ATTRIBUTE_HOST_POINTER " , <nl> + ( " hipPointerAttributeHostPointer " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_POINTER_ATTRIBUTE_P2P_TOKENS " , <nl> + ( " hipPointerAttributeP2pTokens " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_POINTER_ATTRIBUTE_SYNC_MEMOPS " , <nl> + ( " hipPointerAttributeSyncMemops " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_POINTER_ATTRIBUTE_BUFFER_ID " , <nl> + ( " hipPointerAttributeBufferId " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_POINTER_ATTRIBUTE_IS_MANAGED " , <nl> + ( " hipPointerAttributeIsManaged " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_FUNC_ATTRIBUTE_MAX_THREADS_PER_BLOCK " , <nl> + ( <nl> + " hipFuncAttributeMaxThreadsPerBlocks " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_FUNC_ATTRIBUTE_SHARED_SIZE_BYTES " , <nl> + ( " hipFuncAttributeSharedSizeBytes " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_FUNC_ATTRIBUTE_CONST_SIZE_BYTES " , <nl> + ( " hipFuncAttributeConstSizeBytes " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_FUNC_ATTRIBUTE_LOCAL_SIZE_BYTES " , <nl> + ( " hipFuncAttributeLocalSizeBytes " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_FUNC_ATTRIBUTE_NUM_REGS " , <nl> + ( " hipFuncAttributeNumRegs " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_FUNC_ATTRIBUTE_PTX_VERSION " , <nl> + ( " hipFuncAttributePtxVersion " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_FUNC_ATTRIBUTE_BINARY_VERSION " , <nl> + ( " hipFuncAttributeBinaryVersion " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_FUNC_ATTRIBUTE_CACHE_MODE_CA " , <nl> + ( " hipFuncAttributeCacheModeCA " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_FUNC_ATTRIBUTE_MAX " , <nl> + ( " hipFuncAttributeMax " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_GRAPHICS_MAP_RESOURCE_FLAGS_NONE " , <nl> + ( " hipGraphicsMapFlagsNone " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_GRAPHICS_MAP_RESOURCE_FLAGS_READ_ONLY " , <nl> + ( " hipGraphicsMapFlagsReadOnly " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_GRAPHICS_MAP_RESOURCE_FLAGS_WRITE_DISCARD " , <nl> + ( " hipGraphicsMapFlagsWriteDiscard " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_GRAPHICS_REGISTER_FLAGS_NONE " , <nl> + ( " hipGraphicsRegisterFlagsNone " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_GRAPHICS_REGISTER_FLAGS_READ_ONLY " , <nl> + ( <nl> + " hipGraphicsRegisterFlagsReadOnly " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_GRAPHICS_REGISTER_FLAGS_WRITE_DISCARD " , <nl> + ( <nl> + " hipGraphicsRegisterFlagsWriteDiscard " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_GRAPHICS_REGISTER_FLAGS_SURFACE_LDST " , <nl> + ( <nl> + " hipGraphicsRegisterFlagsSurfaceLoadStore " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_GRAPHICS_REGISTER_FLAGS_TEXTURE_GATHER " , <nl> + ( <nl> + " hipGraphicsRegisterFlagsTextureGather " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_OCCUPANCY_DEFAULT " , <nl> + ( " hipOccupancyDefault " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_OCCUPANCY_DISABLE_CACHING_OVERRIDE " , <nl> + ( <nl> + " hipOccupancyDisableCachingOverride " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_FUNC_CACHE_PREFER_NONE " , <nl> + ( " hipFuncCachePreferNone " , CONV_CACHE , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " CU_FUNC_CACHE_PREFER_SHARED " , <nl> + ( " hipFuncCachePreferShared " , CONV_CACHE , API_DRIVER ) , <nl> + ) , <nl> + ( " CU_FUNC_CACHE_PREFER_L1 " , ( " hipFuncCachePreferL1 " , CONV_CACHE , API_DRIVER ) ) , <nl> + ( <nl> + " CU_FUNC_CACHE_PREFER_EQUAL " , <nl> + ( " hipFuncCachePreferEqual " , CONV_CACHE , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " CU_IPC_MEM_LAZY_ENABLE_PEER_ACCESS " , <nl> + ( " hipIpcMemLazyEnablePeerAccess " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " CUDA_IPC_HANDLE_SIZE " , ( " HIP_IPC_HANDLE_SIZE " , CONV_TYPE , API_DRIVER ) ) , <nl> + ( <nl> + " CU_JIT_CACHE_OPTION_NONE " , <nl> + ( " hipJitCacheModeOptionNone " , CONV_JIT , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_JIT_CACHE_OPTION_CG " , <nl> + ( " hipJitCacheModeOptionCG " , CONV_JIT , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_JIT_CACHE_OPTION_CA " , <nl> + ( " hipJitCacheModeOptionCA " , CONV_JIT , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_PREFER_PTX " , <nl> + ( " hipJitFallbackPreferPtx " , CONV_JIT , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_PREFER_BINARY " , <nl> + ( " hipJitFallbackPreferBinary " , CONV_JIT , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " CU_JIT_MAX_REGISTERS " , ( " hipJitOptionMaxRegisters " , CONV_JIT , API_DRIVER ) ) , <nl> + ( <nl> + " CU_JIT_THREADS_PER_BLOCK " , <nl> + ( " hipJitOptionThreadsPerBlock " , CONV_JIT , API_DRIVER ) , <nl> + ) , <nl> + ( " CU_JIT_WALL_TIME " , ( " hipJitOptionWallTime " , CONV_JIT , API_DRIVER ) ) , <nl> + ( " CU_JIT_INFO_LOG_BUFFER " , ( " hipJitOptionInfoLogBuffer " , CONV_JIT , API_DRIVER ) ) , <nl> + ( <nl> + " CU_JIT_INFO_LOG_BUFFER_SIZE_BYTES " , <nl> + ( " hipJitOptionInfoLogBufferSizeBytes " , CONV_JIT , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " CU_JIT_ERROR_LOG_BUFFER " , <nl> + ( " hipJitOptionErrorLogBuffer " , CONV_JIT , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " CU_JIT_ERROR_LOG_BUFFER_SIZE_BYTES " , <nl> + ( " hipJitOptionErrorLogBufferSizeBytes " , CONV_JIT , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " CU_JIT_OPTIMIZATION_LEVEL " , <nl> + ( " hipJitOptionOptimizationLevel " , CONV_JIT , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " CU_JIT_TARGET_FROM_CUCONTEXT " , <nl> + ( " hipJitOptionTargetFromContext " , CONV_JIT , API_DRIVER ) , <nl> + ) , <nl> + ( " CU_JIT_TARGET " , ( " hipJitOptionTarget " , CONV_JIT , API_DRIVER ) ) , <nl> + ( <nl> + " CU_JIT_FALLBACK_STRATEGY " , <nl> + ( " hipJitOptionFallbackStrategy " , CONV_JIT , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " CU_JIT_GENERATE_DEBUG_INFO " , <nl> + ( " hipJitOptionGenerateDebugInfo " , CONV_JIT , API_DRIVER ) , <nl> + ) , <nl> + ( " CU_JIT_LOG_VERBOSE " , ( " hipJitOptionLogVerbose " , CONV_JIT , API_DRIVER ) ) , <nl> + ( <nl> + " CU_JIT_GENERATE_LINE_INFO " , <nl> + ( " hipJitOptionGenerateLineInfo " , CONV_JIT , API_DRIVER ) , <nl> + ) , <nl> + ( " CU_JIT_CACHE_MODE " , ( " hipJitOptionCacheMode " , CONV_JIT , API_DRIVER ) ) , <nl> + ( " CU_JIT_NEW_SM3X_OPT " , ( " hipJitOptionSm3xOpt " , CONV_JIT , API_DRIVER ) ) , <nl> + ( " CU_JIT_FAST_COMPILE " , ( " hipJitOptionFastCompile " , CONV_JIT , API_DRIVER ) ) , <nl> + ( " CU_JIT_NUM_OPTIONS " , ( " hipJitOptionNumOptions " , CONV_JIT , API_DRIVER ) ) , <nl> + ( <nl> + " CU_TARGET_COMPUTE_10 " , <nl> + ( " hipJitTargetCompute10 " , CONV_JIT , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_TARGET_COMPUTE_11 " , <nl> + ( " hipJitTargetCompute11 " , CONV_JIT , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_TARGET_COMPUTE_12 " , <nl> + ( " hipJitTargetCompute12 " , CONV_JIT , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_TARGET_COMPUTE_13 " , <nl> + ( " hipJitTargetCompute13 " , CONV_JIT , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_TARGET_COMPUTE_20 " , <nl> + ( " hipJitTargetCompute20 " , CONV_JIT , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_TARGET_COMPUTE_21 " , <nl> + ( " hipJitTargetCompute21 " , CONV_JIT , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_TARGET_COMPUTE_30 " , <nl> + ( " hipJitTargetCompute30 " , CONV_JIT , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_TARGET_COMPUTE_32 " , <nl> + ( " hipJitTargetCompute32 " , CONV_JIT , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_TARGET_COMPUTE_35 " , <nl> + ( " hipJitTargetCompute35 " , CONV_JIT , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_TARGET_COMPUTE_37 " , <nl> + ( " hipJitTargetCompute37 " , CONV_JIT , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_TARGET_COMPUTE_50 " , <nl> + ( " hipJitTargetCompute50 " , CONV_JIT , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_TARGET_COMPUTE_52 " , <nl> + ( " hipJitTargetCompute52 " , CONV_JIT , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_TARGET_COMPUTE_53 " , <nl> + ( " hipJitTargetCompute53 " , CONV_JIT , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_TARGET_COMPUTE_60 " , <nl> + ( " hipJitTargetCompute60 " , CONV_JIT , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_TARGET_COMPUTE_61 " , <nl> + ( " hipJitTargetCompute61 " , CONV_JIT , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_TARGET_COMPUTE_62 " , <nl> + ( " hipJitTargetCompute62 " , CONV_JIT , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_JIT_INPUT_CUBIN " , <nl> + ( " hipJitInputTypeBin " , CONV_JIT , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_JIT_INPUT_PTX " , <nl> + ( " hipJitInputTypePtx " , CONV_JIT , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_JIT_INPUT_FATBINARY " , <nl> + ( " hipJitInputTypeFatBinary " , CONV_JIT , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_JIT_INPUT_OBJECT " , <nl> + ( " hipJitInputTypeObject " , CONV_JIT , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_JIT_INPUT_LIBRARY " , <nl> + ( " hipJitInputTypeLibrary " , CONV_JIT , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_JIT_NUM_INPUT_TYPES " , <nl> + ( " hipJitInputTypeNumInputTypes " , CONV_JIT , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_LIMIT_STACK_SIZE " , <nl> + ( " hipLimitStackSize " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_LIMIT_PRINTF_FIFO_SIZE " , <nl> + ( " hipLimitPrintfFifoSize " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_LIMIT_MALLOC_HEAP_SIZE " , <nl> + ( " hipLimitMallocHeapSize " , CONV_TYPE , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " CU_LIMIT_DEV_RUNTIME_SYNC_DEPTH " , <nl> + ( " hipLimitDevRuntimeSyncDepth " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_LIMIT_DEV_RUNTIME_PENDING_LAUNCH_COUNT " , <nl> + ( <nl> + " hipLimitDevRuntimePendingLaunchCount " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_LIMIT_STACK_SIZE " , <nl> + ( " hipLimitStackSize " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_MEM_ATTACH_GLOBAL " , <nl> + ( " hipMemAttachGlobal " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_MEM_ATTACH_HOST " , <nl> + ( " hipMemAttachHost " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_MEM_ATTACH_SINGLE " , <nl> + ( " hipMemAttachSingle " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_MEMORYTYPE_HOST " , <nl> + ( " hipMemTypeHost " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_MEMORYTYPE_DEVICE " , <nl> + ( " hipMemTypeDevice " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_MEMORYTYPE_ARRAY " , <nl> + ( " hipMemTypeArray " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_MEMORYTYPE_UNIFIED " , <nl> + ( " hipMemTypeUnified " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_RESOURCE_TYPE_ARRAY " , <nl> + ( " hipResourceTypeArray " , CONV_TEX , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_RESOURCE_TYPE_MIPMAPPED_ARRAY " , <nl> + ( " hipResourceTypeMipmappedArray " , CONV_TEX , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_RESOURCE_TYPE_LINEAR " , <nl> + ( " hipResourceTypeLinear " , CONV_TEX , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_RESOURCE_TYPE_PITCH2D " , <nl> + ( " hipResourceTypePitch2D " , CONV_TEX , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " CU_RES_VIEW_FORMAT_NONE " , ( " hipResViewFormatNone " , CONV_TEX , API_DRIVER ) ) , <nl> + ( <nl> + " CU_RES_VIEW_FORMAT_UINT_1X8 " , <nl> + ( " hipResViewFormatUnsignedChar1 " , CONV_TEX , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " CU_RES_VIEW_FORMAT_UINT_2X8 " , <nl> + ( " hipResViewFormatUnsignedChar2 " , CONV_TEX , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " CU_RES_VIEW_FORMAT_UINT_4X8 " , <nl> + ( " hipResViewFormatUnsignedChar4 " , CONV_TEX , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " CU_RES_VIEW_FORMAT_SINT_1X8 " , <nl> + ( " hipResViewFormatSignedChar1 " , CONV_TEX , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " CU_RES_VIEW_FORMAT_SINT_2X8 " , <nl> + ( " hipResViewFormatSignedChar2 " , CONV_TEX , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " CU_RES_VIEW_FORMAT_SINT_4X8 " , <nl> + ( " hipResViewFormatSignedChar4 " , CONV_TEX , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " CU_RES_VIEW_FORMAT_UINT_1X16 " , <nl> + ( " hipResViewFormatUnsignedShort1 " , CONV_TEX , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " CU_RES_VIEW_FORMAT_UINT_2X16 " , <nl> + ( " hipResViewFormatUnsignedShort2 " , CONV_TEX , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " CU_RES_VIEW_FORMAT_UINT_4X16 " , <nl> + ( " hipResViewFormatUnsignedShort4 " , CONV_TEX , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " CU_RES_VIEW_FORMAT_SINT_1X16 " , <nl> + ( " hipResViewFormatSignedShort1 " , CONV_TEX , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " CU_RES_VIEW_FORMAT_SINT_2X16 " , <nl> + ( " hipResViewFormatSignedShort2 " , CONV_TEX , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " CU_RES_VIEW_FORMAT_SINT_4X16 " , <nl> + ( " hipResViewFormatSignedShort4 " , CONV_TEX , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " CU_RES_VIEW_FORMAT_UINT_1X32 " , <nl> + ( " hipResViewFormatUnsignedInt1 " , CONV_TEX , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " CU_RES_VIEW_FORMAT_UINT_2X32 " , <nl> + ( " hipResViewFormatUnsignedInt2 " , CONV_TEX , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " CU_RES_VIEW_FORMAT_UINT_4X32 " , <nl> + ( " hipResViewFormatUnsignedInt4 " , CONV_TEX , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " CU_RES_VIEW_FORMAT_SINT_1X32 " , <nl> + ( " hipResViewFormatSignedInt1 " , CONV_TEX , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " CU_RES_VIEW_FORMAT_SINT_2X32 " , <nl> + ( " hipResViewFormatSignedInt2 " , CONV_TEX , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " CU_RES_VIEW_FORMAT_SINT_4X32 " , <nl> + ( " hipResViewFormatSignedInt4 " , CONV_TEX , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " CU_RES_VIEW_FORMAT_FLOAT_1X16 " , <nl> + ( " hipResViewFormatHalf1 " , CONV_TEX , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " CU_RES_VIEW_FORMAT_FLOAT_2X16 " , <nl> + ( " hipResViewFormatHalf2 " , CONV_TEX , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " CU_RES_VIEW_FORMAT_FLOAT_4X16 " , <nl> + ( " hipResViewFormatHalf4 " , CONV_TEX , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " CU_RES_VIEW_FORMAT_FLOAT_1X32 " , <nl> + ( " hipResViewFormatFloat1 " , CONV_TEX , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " CU_RES_VIEW_FORMAT_FLOAT_2X32 " , <nl> + ( " hipResViewFormatFloat2 " , CONV_TEX , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " CU_RES_VIEW_FORMAT_FLOAT_4X32 " , <nl> + ( " hipResViewFormatFloat4 " , CONV_TEX , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " CU_RES_VIEW_FORMAT_UNSIGNED_BC1 " , <nl> + ( " hipResViewFormatUnsignedBlockCompressed1 " , CONV_TEX , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " CU_RES_VIEW_FORMAT_UNSIGNED_BC2 " , <nl> + ( " hipResViewFormatUnsignedBlockCompressed2 " , CONV_TEX , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " CU_RES_VIEW_FORMAT_UNSIGNED_BC3 " , <nl> + ( " hipResViewFormatUnsignedBlockCompressed3 " , CONV_TEX , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " CU_RES_VIEW_FORMAT_UNSIGNED_BC4 " , <nl> + ( " hipResViewFormatUnsignedBlockCompressed4 " , CONV_TEX , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " CU_RES_VIEW_FORMAT_SIGNED_BC4 " , <nl> + ( " hipResViewFormatSignedBlockCompressed4 " , CONV_TEX , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " CU_RES_VIEW_FORMAT_UNSIGNED_BC5 " , <nl> + ( " hipResViewFormatUnsignedBlockCompressed5 " , CONV_TEX , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " CU_RES_VIEW_FORMAT_SIGNED_BC5 " , <nl> + ( " hipResViewFormatSignedBlockCompressed5 " , CONV_TEX , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " CU_RES_VIEW_FORMAT_UNSIGNED_BC6H " , <nl> + ( " hipResViewFormatUnsignedBlockCompressed6H " , CONV_TEX , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " CU_RES_VIEW_FORMAT_SIGNED_BC6H " , <nl> + ( " hipResViewFormatSignedBlockCompressed6H " , CONV_TEX , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " CU_RES_VIEW_FORMAT_UNSIGNED_BC7 " , <nl> + ( " hipResViewFormatUnsignedBlockCompressed7 " , CONV_TEX , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " CU_SHARED_MEM_CONFIG_DEFAULT_BANK_SIZE " , <nl> + ( " hipSharedMemBankSizeDefault " , CONV_TYPE , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " CU_SHARED_MEM_CONFIG_FOUR_BYTE_BANK_SIZE " , <nl> + ( " hipSharedMemBankSizeFourByte " , CONV_TYPE , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " CU_SHARED_MEM_CONFIG_EIGHT_BYTE_BANK_SIZE " , <nl> + ( " hipSharedMemBankSizeEightByte " , CONV_TYPE , API_DRIVER ) , <nl> + ) , <nl> + ( " CU_STREAM_DEFAULT " , ( " hipStreamDefault " , CONV_TYPE , API_DRIVER ) ) , <nl> + ( " CU_STREAM_NON_BLOCKING " , ( " hipStreamNonBlocking " , CONV_TYPE , API_DRIVER ) ) , <nl> + ( <nl> + " CU_STREAM_WAIT_VALUE_GEQ " , <nl> + ( " hipStreamWaitValueGeq " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_STREAM_WAIT_VALUE_EQ " , <nl> + ( " hipStreamWaitValueEq " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_STREAM_WAIT_VALUE_AND " , <nl> + ( " hipStreamWaitValueAnd " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_STREAM_WAIT_VALUE_FLUSH " , <nl> + ( " hipStreamWaitValueFlush " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_STREAM_WRITE_VALUE_DEFAULT " , <nl> + ( " hipStreamWriteValueDefault " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_STREAM_WRITE_VALUE_NO_MEMORY_BARRIER " , <nl> + ( <nl> + " hipStreamWriteValueNoMemoryBarrier " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_STREAM_MEM_OP_WAIT_VALUE_32 " , <nl> + ( " hipStreamBatchMemOpWaitValue32 " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_STREAM_MEM_OP_WRITE_VALUE_32 " , <nl> + ( " hipStreamBatchMemOpWriteValue32 " , CONV_TYPE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_STREAM_MEM_OP_FLUSH_REMOTE_WRITES " , <nl> + ( <nl> + " hipStreamBatchMemOpFlushRemoteWrites " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cuGetErrorName " , <nl> + ( " hipGetErrorName___ " , CONV_ERROR , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuGetErrorString " , <nl> + ( " hipGetErrorString___ " , CONV_ERROR , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cuInit " , ( " hipInit " , CONV_INIT , API_DRIVER ) ) , <nl> + ( " cuDriverGetVersion " , ( " hipDriverGetVersion " , CONV_VERSION , API_DRIVER ) ) , <nl> + ( " cuCtxCreate_v2 " , ( " hipCtxCreate " , CONV_CONTEXT , API_DRIVER ) ) , <nl> + ( " cuCtxDestroy_v2 " , ( " hipCtxDestroy " , CONV_CONTEXT , API_DRIVER ) ) , <nl> + ( " cuCtxGetApiVersion " , ( " hipCtxGetApiVersion " , CONV_CONTEXT , API_DRIVER ) ) , <nl> + ( " cuCtxGetCacheConfig " , ( " hipCtxGetCacheConfig " , CONV_CONTEXT , API_DRIVER ) ) , <nl> + ( " cuCtxGetCurrent " , ( " hipCtxGetCurrent " , CONV_CONTEXT , API_DRIVER ) ) , <nl> + ( " cuCtxGetDevice " , ( " hipCtxGetDevice " , CONV_CONTEXT , API_DRIVER ) ) , <nl> + ( " cuCtxGetFlags " , ( " hipCtxGetFlags " , CONV_CONTEXT , API_DRIVER ) ) , <nl> + ( <nl> + " cuCtxGetLimit " , <nl> + ( " hipCtxGetLimit " , CONV_CONTEXT , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuCtxGetSharedMemConfig " , <nl> + ( " hipCtxGetSharedMemConfig " , CONV_CONTEXT , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " cuCtxGetStreamPriorityRange " , <nl> + ( " hipCtxGetStreamPriorityRange " , CONV_CONTEXT , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cuCtxPopCurrent_v2 " , ( " hipCtxPopCurrent " , CONV_CONTEXT , API_DRIVER ) ) , <nl> + ( " cuCtxPushCurrent_v2 " , ( " hipCtxPushCurrent " , CONV_CONTEXT , API_DRIVER ) ) , <nl> + ( " cuCtxSetCacheConfig " , ( " hipCtxSetCacheConfig " , CONV_CONTEXT , API_DRIVER ) ) , <nl> + ( " cuCtxSetCurrent " , ( " hipCtxSetCurrent " , CONV_CONTEXT , API_DRIVER ) ) , <nl> + ( <nl> + " cuCtxSetLimit " , <nl> + ( " hipCtxSetLimit " , CONV_CONTEXT , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuCtxSetSharedMemConfig " , <nl> + ( " hipCtxSetSharedMemConfig " , CONV_CONTEXT , API_DRIVER ) , <nl> + ) , <nl> + ( " cuCtxSynchronize " , ( " hipCtxSynchronize " , CONV_CONTEXT , API_DRIVER ) ) , <nl> + ( " cuCtxAttach " , ( " hipCtxAttach " , CONV_CONTEXT , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> + ( " cuCtxDetach " , ( " hipCtxDetach " , CONV_CONTEXT , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> + ( " cuCtxEnablePeerAccess " , ( " hipCtxEnablePeerAccess " , CONV_PEER , API_DRIVER ) ) , <nl> + ( " cuCtxDisablePeerAccess " , ( " hipCtxDisablePeerAccess " , CONV_PEER , API_DRIVER ) ) , <nl> + ( " cuDeviceCanAccessPeer " , ( " hipDeviceCanAccessPeer " , CONV_PEER , API_DRIVER ) ) , <nl> + ( <nl> + " cuDeviceGetP2PAttribute " , <nl> + ( " hipDeviceGetP2PAttribute " , CONV_PEER , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuDevicePrimaryCtxGetState " , <nl> + ( " hipDevicePrimaryCtxGetState " , CONV_CONTEXT , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " cuDevicePrimaryCtxRelease " , <nl> + ( " hipDevicePrimaryCtxRelease " , CONV_CONTEXT , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " cuDevicePrimaryCtxReset " , <nl> + ( " hipDevicePrimaryCtxReset " , CONV_CONTEXT , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " cuDevicePrimaryCtxRetain " , <nl> + ( " hipDevicePrimaryCtxRetain " , CONV_CONTEXT , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " cuDevicePrimaryCtxSetFlags " , <nl> + ( " hipDevicePrimaryCtxSetFlags " , CONV_CONTEXT , API_DRIVER ) , <nl> + ) , <nl> + ( " cuDeviceGet " , ( " hipGetDevice " , CONV_DEVICE , API_DRIVER ) ) , <nl> + ( " cuDeviceGetName " , ( " hipDeviceGetName " , CONV_DEVICE , API_DRIVER ) ) , <nl> + ( " cuDeviceGetCount " , ( " hipGetDeviceCount " , CONV_DEVICE , API_DRIVER ) ) , <nl> + ( " cuDeviceGetAttribute " , ( " hipDeviceGetAttribute " , CONV_DEVICE , API_DRIVER ) ) , <nl> + ( " cuDeviceGetPCIBusId " , ( " hipDeviceGetPCIBusId " , CONV_DEVICE , API_DRIVER ) ) , <nl> + ( " cuDeviceGetByPCIBusId " , ( " hipDeviceGetByPCIBusId " , CONV_DEVICE , API_DRIVER ) ) , <nl> + ( " cuDeviceTotalMem_v2 " , ( " hipDeviceTotalMem " , CONV_DEVICE , API_DRIVER ) ) , <nl> + ( <nl> + " cuDeviceComputeCapability " , <nl> + ( " hipDeviceComputeCapability " , CONV_DEVICE , API_DRIVER ) , <nl> + ) , <nl> + ( " cuDeviceGetProperties " , ( " hipGetDeviceProperties " , CONV_DEVICE , API_DRIVER ) ) , <nl> + ( " cuLinkAddData " , ( " hipLinkAddData " , CONV_MODULE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> + ( " cuLinkAddFile " , ( " hipLinkAddFile " , CONV_MODULE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> + ( <nl> + " cuLinkComplete " , <nl> + ( " hipLinkComplete " , CONV_MODULE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cuLinkCreate " , ( " hipLinkCreate " , CONV_MODULE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> + ( " cuLinkDestroy " , ( " hipLinkDestroy " , CONV_MODULE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> + ( " cuModuleGetFunction " , ( " hipModuleGetFunction " , CONV_MODULE , API_DRIVER ) ) , <nl> + ( " cuModuleGetGlobal_v2 " , ( " hipModuleGetGlobal " , CONV_MODULE , API_DRIVER ) ) , <nl> + ( <nl> + " cuModuleGetSurfRef " , <nl> + ( " hipModuleGetSurfRef " , CONV_MODULE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cuModuleGetTexRef " , ( " hipModuleGetTexRef " , CONV_MODULE , API_DRIVER ) ) , <nl> + ( " cuModuleLoad " , ( " hipModuleLoad " , CONV_MODULE , API_DRIVER ) ) , <nl> + ( " cuModuleLoadData " , ( " hipModuleLoadData " , CONV_MODULE , API_DRIVER ) ) , <nl> + ( " cuModuleLoadDataEx " , ( " hipModuleLoadDataEx " , CONV_MODULE , API_DRIVER ) ) , <nl> + ( <nl> + " cuModuleLoadFatBinary " , <nl> + ( " hipModuleLoadFatBinary " , CONV_MODULE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cuModuleUnload " , ( " hipModuleUnload " , CONV_MODULE , API_DRIVER ) ) , <nl> + ( <nl> + " CU_DEVICE_P2P_ATTRIBUTE_PERFORMANCE_RANK " , <nl> + ( <nl> + " hipDeviceP2PAttributePerformanceRank " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_P2P_ATTRIBUTE_ACCESS_SUPPORTED " , <nl> + ( <nl> + " hipDeviceP2PAttributeAccessSupported " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_DEVICE_P2P_ATTRIBUTE_NATIVE_ATOMIC_SUPPORTED " , <nl> + ( <nl> + " hipDeviceP2PAttributeNativeAtomicSupported " , <nl> + CONV_TYPE , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( " CU_EVENT_DEFAULT " , ( " hipEventDefault " , CONV_EVENT , API_DRIVER ) ) , <nl> + ( " CU_EVENT_BLOCKING_SYNC " , ( " hipEventBlockingSync " , CONV_EVENT , API_DRIVER ) ) , <nl> + ( " CU_EVENT_DISABLE_TIMING " , ( " hipEventDisableTiming " , CONV_EVENT , API_DRIVER ) ) , <nl> + ( " CU_EVENT_INTERPROCESS " , ( " hipEventInterprocess " , CONV_EVENT , API_DRIVER ) ) , <nl> + ( " cuEventCreate " , ( " hipEventCreate " , CONV_EVENT , API_DRIVER ) ) , <nl> + ( " cuEventDestroy_v2 " , ( " hipEventDestroy " , CONV_EVENT , API_DRIVER ) ) , <nl> + ( " cuEventElapsedTime " , ( " hipEventElapsedTime " , CONV_EVENT , API_DRIVER ) ) , <nl> + ( " cuEventQuery " , ( " hipEventQuery " , CONV_EVENT , API_DRIVER ) ) , <nl> + ( " cuEventRecord " , ( " hipEventRecord " , CONV_EVENT , API_DRIVER ) ) , <nl> + ( " cuEventSynchronize " , ( " hipEventSynchronize " , CONV_EVENT , API_DRIVER ) ) , <nl> + ( <nl> + " cuFuncGetAttribute " , <nl> + ( " hipFuncGetAttribute " , CONV_MODULE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cuFuncSetCacheConfig " , ( " hipFuncSetCacheConfig " , CONV_MODULE , API_DRIVER ) ) , <nl> + ( <nl> + " cuFuncSetSharedMemConfig " , <nl> + ( " hipFuncSetSharedMemConfig " , CONV_MODULE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cuLaunchKernel " , ( " hipModuleLaunchKernel " , CONV_MODULE , API_DRIVER ) ) , <nl> + ( <nl> + " cuFuncSetBlockShape " , <nl> + ( " hipFuncSetBlockShape " , CONV_MODULE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuFuncSetSharedSize " , <nl> + ( " hipFuncSetSharedSize " , CONV_MODULE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cuLaunch " , ( " hipLaunch " , CONV_MODULE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> + ( " cuLaunchGrid " , ( " hipLaunchGrid " , CONV_MODULE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> + ( <nl> + " cuLaunchGridAsync " , <nl> + ( " hipLaunchGridAsync " , CONV_MODULE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cuParamSetf " , ( " hipParamSetf " , CONV_MODULE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> + ( " cuParamSeti " , ( " hipParamSeti " , CONV_MODULE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> + ( <nl> + " cuParamSetSize " , <nl> + ( " hipParamSetSize " , CONV_MODULE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuParamSetSize " , <nl> + ( " hipParamSetSize " , CONV_MODULE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cuParamSetv " , ( " hipParamSetv " , CONV_MODULE , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> + ( <nl> + " cuOccupancyMaxActiveBlocksPerMultiprocessor " , <nl> + ( <nl> + " hipOccupancyMaxActiveBlocksPerMultiprocessor " , <nl> + CONV_OCCUPANCY , <nl> + API_DRIVER , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cuOccupancyMaxActiveBlocksPerMultiprocessorWithFlags " , <nl> + ( <nl> + " hipOccupancyMaxActiveBlocksPerMultiprocessorWithFlags " , <nl> + CONV_OCCUPANCY , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cuOccupancyMaxPotentialBlockSize " , <nl> + ( " hipOccupancyMaxPotentialBlockSize " , CONV_OCCUPANCY , API_DRIVER ) , <nl> + ) , <nl> + ( <nl> + " cuOccupancyMaxPotentialBlockSizeWithFlags " , <nl> + ( <nl> + " hipOccupancyMaxPotentialBlockSizeWithFlags " , <nl> + CONV_OCCUPANCY , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( " cuStreamAddCallback " , ( " hipStreamAddCallback " , CONV_STREAM , API_DRIVER ) ) , <nl> + ( <nl> + " cuStreamAttachMemAsync " , <nl> + ( " hipStreamAttachMemAsync " , CONV_STREAM , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuStreamCreate " , <nl> + ( " hipStreamCreate__ " , CONV_STREAM , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuStreamCreateWithPriority " , <nl> + ( " hipStreamCreateWithPriority " , CONV_STREAM , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cuStreamDestroy_v2 " , ( " hipStreamDestroy " , CONV_STREAM , API_DRIVER ) ) , <nl> + ( " cuStreamGetFlags " , ( " hipStreamGetFlags " , CONV_STREAM , API_DRIVER ) ) , <nl> + ( <nl> + " cuStreamGetPriority " , <nl> + ( " hipStreamGetPriority " , CONV_STREAM , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cuStreamQuery " , ( " hipStreamQuery " , CONV_STREAM , API_DRIVER ) ) , <nl> + ( " cuStreamSynchronize " , ( " hipStreamSynchronize " , CONV_STREAM , API_DRIVER ) ) , <nl> + ( " cuStreamWaitEvent " , ( " hipStreamWaitEvent " , CONV_STREAM , API_DRIVER ) ) , <nl> + ( <nl> + " cuStreamWaitValue32 " , <nl> + ( " hipStreamWaitValue32 " , CONV_STREAM , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuStreamWriteValue32 " , <nl> + ( " hipStreamWriteValue32 " , CONV_STREAM , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuStreamBatchMemOp " , <nl> + ( " hipStreamBatchMemOp " , CONV_STREAM , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cuArray3DCreate " , ( " hipArray3DCreate " , CONV_MEM , API_DRIVER ) ) , <nl> + ( <nl> + " cuArray3DGetDescriptor " , <nl> + ( " hipArray3DGetDescriptor " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cuArrayCreate " , ( " hipArrayCreate " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> + ( " cuArrayDestroy " , ( " hipArrayDestroy " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> + ( <nl> + " cuArrayGetDescriptor " , <nl> + ( " hipArrayGetDescriptor " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuIpcCloseMemHandle " , <nl> + ( " hipIpcCloseMemHandle " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuIpcGetEventHandle " , <nl> + ( " hipIpcGetEventHandle " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuIpcGetMemHandle " , <nl> + ( " hipIpcGetMemHandle " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuIpcOpenEventHandle " , <nl> + ( " hipIpcOpenEventHandle " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuIpcOpenMemHandle " , <nl> + ( " hipIpcOpenMemHandle " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cuMemAlloc_v2 " , ( " hipMalloc " , CONV_MEM , API_DRIVER ) ) , <nl> + ( " cuMemAllocHost " , ( " hipMemAllocHost " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> + ( <nl> + " cuMemAllocManaged " , <nl> + ( " hipMemAllocManaged " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuMemAllocPitch " , <nl> + ( " hipMemAllocPitch__ " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cuMemcpy " , ( " hipMemcpy__ " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> + ( " cuMemcpy2D " , ( " hipMemcpy2D__ " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> + ( <nl> + " cuMemcpy2DAsync " , <nl> + ( " hipMemcpy2DAsync__ " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuMemcpy2DUnaligned " , <nl> + ( " hipMemcpy2DUnaligned " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cuMemcpy3D " , ( " hipMemcpy3D__ " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> + ( <nl> + " cuMemcpy3DAsync " , <nl> + ( " hipMemcpy3DAsync__ " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuMemcpy3DPeer " , <nl> + ( " hipMemcpy3DPeer__ " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuMemcpy3DPeerAsync " , <nl> + ( " hipMemcpy3DPeerAsync__ " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cuMemcpyAsync " , ( " hipMemcpyAsync__ " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> + ( " cuMemcpyAtoA " , ( " hipMemcpyAtoA " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> + ( " cuMemcpyAtoD " , ( " hipMemcpyAtoD " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> + ( " cuMemcpyAtoH " , ( " hipMemcpyAtoH " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> + ( <nl> + " cuMemcpyAtoHAsync " , <nl> + ( " hipMemcpyAtoHAsync " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cuMemcpyDtoA " , ( " hipMemcpyDtoA " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> + ( " cuMemcpyDtoD_v2 " , ( " hipMemcpyDtoD " , CONV_MEM , API_DRIVER ) ) , <nl> + ( " cuMemcpyDtoDAsync_v2 " , ( " hipMemcpyDtoDAsync " , CONV_MEM , API_DRIVER ) ) , <nl> + ( " cuMemcpyDtoH_v2 " , ( " hipMemcpyDtoH " , CONV_MEM , API_DRIVER ) ) , <nl> + ( " cuMemcpyDtoHAsync_v2 " , ( " hipMemcpyDtoHAsync " , CONV_MEM , API_DRIVER ) ) , <nl> + ( " cuMemcpyHtoA " , ( " hipMemcpyHtoA " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> + ( <nl> + " cuMemcpyHtoAAsync " , <nl> + ( " hipMemcpyHtoAAsync " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cuMemcpyHtoD_v2 " , ( " hipMemcpyHtoD " , CONV_MEM , API_DRIVER ) ) , <nl> + ( " cuMemcpyHtoDAsync_v2 " , ( " hipMemcpyHtoDAsync " , CONV_MEM , API_DRIVER ) ) , <nl> + ( <nl> + " cuMemcpyPeerAsync " , <nl> + ( " hipMemcpyPeerAsync__ " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cuMemcpyPeer " , ( " hipMemcpyPeer__ " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> + ( " cuMemFree_v2 " , ( " hipFree " , CONV_MEM , API_DRIVER ) ) , <nl> + ( " cuMemFreeHost " , ( " hipHostFree " , CONV_MEM , API_DRIVER ) ) , <nl> + ( <nl> + " cuMemGetAddressRange " , <nl> + ( " hipMemGetAddressRange " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cuMemGetInfo_v2 " , ( " hipMemGetInfo " , CONV_MEM , API_DRIVER ) ) , <nl> + ( " cuMemHostAlloc " , ( " hipHostMalloc " , CONV_MEM , API_DRIVER ) ) , <nl> + ( <nl> + " cuMemHostGetDevicePointer " , <nl> + ( " hipMemHostGetDevicePointer " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuMemHostGetFlags " , <nl> + ( " hipMemHostGetFlags " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cuMemHostRegister_v2 " , ( " hipHostRegister " , CONV_MEM , API_DRIVER ) ) , <nl> + ( " cuMemHostUnregister " , ( " hipHostUnregister " , CONV_MEM , API_DRIVER ) ) , <nl> + ( " cuMemsetD16_v2 " , ( " hipMemsetD16 " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> + ( <nl> + " cuMemsetD16Async " , <nl> + ( " hipMemsetD16Async " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cuMemsetD2D16_v2 " , ( " hipMemsetD2D16 " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> + ( <nl> + " cuMemsetD2D16Async " , <nl> + ( " hipMemsetD2D16Async " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cuMemsetD2D32_v2 " , ( " hipMemsetD2D32 " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> + ( <nl> + " cuMemsetD2D32Async " , <nl> + ( " hipMemsetD2D32Async " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cuMemsetD2D8_v2 " , ( " hipMemsetD2D8 " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> + ( <nl> + " cuMemsetD2D8Async " , <nl> + ( " hipMemsetD2D8Async " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cuMemsetD32_v2 " , ( " hipMemset " , CONV_MEM , API_DRIVER ) ) , <nl> + ( " cuMemsetD32Async " , ( " hipMemsetAsync " , CONV_MEM , API_DRIVER ) ) , <nl> + ( " cuMemsetD8_v2 " , ( " hipMemsetD8 " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> + ( <nl> + " cuMemsetD8Async " , <nl> + ( " hipMemsetD8Async " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuMipmappedArrayCreate " , <nl> + ( " hipMipmappedArrayCreate " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuMipmappedArrayDestroy " , <nl> + ( " hipMipmappedArrayDestroy " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuMipmappedArrayGetLevel " , <nl> + ( " hipMipmappedArrayGetLevel " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuMemPrefetchAsync " , <nl> + ( " hipMemPrefetchAsync__ " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cuMemAdvise " , ( " hipMemAdvise " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> + ( <nl> + " cuMemRangeGetAttribute " , <nl> + ( " hipMemRangeGetAttribute " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuMemRangeGetAttributes " , <nl> + ( " hipMemRangeGetAttributes " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuPointerGetAttribute " , <nl> + ( " hipPointerGetAttribute " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuPointerGetAttributes " , <nl> + ( " hipPointerGetAttributes " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuPointerSetAttribute " , <nl> + ( " hipPointerSetAttribute " , CONV_MEM , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " CU_TR_FILTER_MODE_POINT " , ( " hipFilterModePoint " , CONV_TEX , API_DRIVER ) ) , <nl> + ( <nl> + " CU_TR_FILTER_MODE_LINEAR " , <nl> + ( " hipFilterModeLinear " , CONV_TEX , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuTexRefGetAddress " , <nl> + ( " hipTexRefGetAddress " , CONV_TEX , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuTexRefGetAddressMode " , <nl> + ( " hipTexRefGetAddressMode " , CONV_TEX , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuTexRefGetArray " , <nl> + ( " hipTexRefGetArray " , CONV_TEX , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuTexRefGetBorderColor " , <nl> + ( " hipTexRefGetBorderColor " , CONV_TEX , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuTexRefGetFilterMode " , <nl> + ( " hipTexRefGetFilterMode " , CONV_TEX , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuTexRefGetFlags " , <nl> + ( " hipTexRefGetFlags " , CONV_TEX , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuTexRefGetFormat " , <nl> + ( " hipTexRefGetFormat " , CONV_TEX , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuTexRefGetMaxAnisotropy " , <nl> + ( " hipTexRefGetMaxAnisotropy " , CONV_TEX , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuTexRefGetMipmapFilterMode " , <nl> + ( " hipTexRefGetMipmapFilterMode " , CONV_TEX , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuTexRefGetMipmapLevelBias " , <nl> + ( " hipTexRefGetMipmapLevelBias " , CONV_TEX , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuTexRefGetMipmapLevelClamp " , <nl> + ( " hipTexRefGetMipmapLevelClamp " , CONV_TEX , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuTexRefGetMipmappedArray " , <nl> + ( " hipTexRefGetMipmappedArray " , CONV_TEX , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuTexRefSetAddress " , <nl> + ( " hipTexRefSetAddress " , CONV_TEX , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuTexRefSetAddress2D " , <nl> + ( " hipTexRefSetAddress2D " , CONV_TEX , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cuTexRefSetAddressMode " , ( " hipTexRefSetAddressMode " , CONV_TEX , API_DRIVER ) ) , <nl> + ( " cuTexRefSetArray " , ( " hipTexRefSetArray " , CONV_TEX , API_DRIVER ) ) , <nl> + ( <nl> + " cuTexRefSetBorderColor " , <nl> + ( " hipTexRefSetBorderColor " , CONV_TEX , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cuTexRefSetFilterMode " , ( " hipTexRefSetFilterMode " , CONV_TEX , API_DRIVER ) ) , <nl> + ( " cuTexRefSetFlags " , ( " hipTexRefSetFlags " , CONV_TEX , API_DRIVER ) ) , <nl> + ( " cuTexRefSetFormat " , ( " hipTexRefSetFormat " , CONV_TEX , API_DRIVER ) ) , <nl> + ( <nl> + " cuTexRefSetMaxAnisotropy " , <nl> + ( " hipTexRefSetMaxAnisotropy " , CONV_TEX , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuTexRefSetMipmapFilterMode " , <nl> + ( " hipTexRefSetMipmapFilterMode " , CONV_TEX , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuTexRefSetMipmapLevelBias " , <nl> + ( " hipTexRefSetMipmapLevelBias " , CONV_TEX , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuTexRefSetMipmapLevelClamp " , <nl> + ( " hipTexRefSetMipmapLevelClamp " , CONV_TEX , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuTexRefSetMipmappedArray " , <nl> + ( " hipTexRefSetMipmappedArray " , CONV_TEX , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cuTexRefCreate " , ( " hipTexRefCreate " , CONV_TEX , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> + ( <nl> + " cuTexRefDestroy " , <nl> + ( " hipTexRefDestroy " , CONV_TEX , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuSurfRefGetArray " , <nl> + ( " hipSurfRefGetArray " , CONV_SURFACE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuSurfRefSetArray " , <nl> + ( " hipSurfRefSetArray " , CONV_SURFACE , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuTexObjectCreate " , <nl> + ( " hipTexObjectCreate " , CONV_TEX , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuTexObjectDestroy " , <nl> + ( " hipTexObjectDestroy " , CONV_TEX , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuTexObjectGetResourceDesc " , <nl> + ( " hipTexObjectGetResourceDesc " , CONV_TEX , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuTexObjectGetResourceViewDesc " , <nl> + ( " hipTexObjectGetResourceViewDesc " , CONV_TEX , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuTexObjectGetTextureDesc " , <nl> + ( " hipTexObjectGetTextureDesc " , CONV_TEX , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuSurfObjectCreate " , <nl> + ( " hipSurfObjectCreate " , CONV_TEX , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuSurfObjectDestroy " , <nl> + ( " hipSurfObjectDestroy " , CONV_TEX , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuSurfObjectGetResourceDesc " , <nl> + ( " hipSurfObjectGetResourceDesc " , CONV_TEX , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuGraphicsMapResources " , <nl> + ( " hipGraphicsMapResources " , CONV_GRAPHICS , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuGraphicsResourceGetMappedMipmappedArray " , <nl> + ( <nl> + " hipGraphicsResourceGetMappedMipmappedArray " , <nl> + CONV_GRAPHICS , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cuGraphicsResourceGetMappedPointer " , <nl> + ( <nl> + " hipGraphicsResourceGetMappedPointer " , <nl> + CONV_GRAPHICS , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cuGraphicsResourceSetMapFlags " , <nl> + ( <nl> + " hipGraphicsResourceSetMapFlags " , <nl> + CONV_GRAPHICS , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cuGraphicsSubResourceGetMappedArray " , <nl> + ( <nl> + " hipGraphicsSubResourceGetMappedArray " , <nl> + CONV_GRAPHICS , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cuGraphicsUnmapResources " , <nl> + ( " hipGraphicsUnmapResources " , CONV_GRAPHICS , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuGraphicsUnregisterResource " , <nl> + ( <nl> + " hipGraphicsUnregisterResource " , <nl> + CONV_GRAPHICS , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cuProfilerInitialize " , <nl> + ( " hipProfilerInitialize " , CONV_OTHER , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cuProfilerStart " , ( " hipProfilerStart " , CONV_OTHER , API_DRIVER ) ) , <nl> + ( " cuProfilerStop " , ( " hipProfilerStop " , CONV_OTHER , API_DRIVER ) ) , <nl> + ( <nl> + " CU_GL_DEVICE_LIST_ALL " , <nl> + ( " HIP_GL_DEVICE_LIST_ALL " , CONV_GL , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_GL_DEVICE_LIST_CURRENT_FRAME " , <nl> + ( " HIP_GL_DEVICE_LIST_CURRENT_FRAME " , CONV_GL , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_GL_DEVICE_LIST_NEXT_FRAME " , <nl> + ( " HIP_GL_DEVICE_LIST_NEXT_FRAME " , CONV_GL , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cuGLGetDevices " , ( " hipGLGetDevices " , CONV_GL , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> + ( <nl> + " cuGraphicsGLRegisterBuffer " , <nl> + ( " hipGraphicsGLRegisterBuffer " , CONV_GL , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuGraphicsGLRegisterImage " , <nl> + ( " hipGraphicsGLRegisterImage " , CONV_GL , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cuWGLGetDevice " , ( " hipWGLGetDevice " , CONV_GL , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> + ( <nl> + " CU_GL_MAP_RESOURCE_FLAGS_NONE " , <nl> + ( " HIP_GL_MAP_RESOURCE_FLAGS_NONE " , CONV_GL , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_GL_MAP_RESOURCE_FLAGS_READ_ONLY " , <nl> + ( <nl> + " HIP_GL_MAP_RESOURCE_FLAGS_READ_ONLY " , <nl> + CONV_GL , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_GL_MAP_RESOURCE_FLAGS_WRITE_DISCARD " , <nl> + ( <nl> + " HIP_GL_MAP_RESOURCE_FLAGS_WRITE_DISCARD " , <nl> + CONV_GL , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( " cuGLCtxCreate " , ( " hipGLCtxCreate " , CONV_GL , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> + ( " cuGLInit " , ( " hipGLInit " , CONV_GL , API_DRIVER , HIP_UNSUPPORTED ) ) , <nl> + ( <nl> + " cuGLMapBufferObject " , <nl> + ( " hipGLMapBufferObject " , CONV_GL , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuGLMapBufferObjectAsync " , <nl> + ( " hipGLMapBufferObjectAsync " , CONV_GL , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuGLRegisterBufferObject " , <nl> + ( " hipGLRegisterBufferObject " , CONV_GL , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuGLSetBufferObjectMapFlags " , <nl> + ( " hipGLSetBufferObjectMapFlags " , CONV_GL , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuGLUnmapBufferObject " , <nl> + ( " hipGLUnmapBufferObject " , CONV_GL , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuGLUnmapBufferObjectAsync " , <nl> + ( " hipGLUnmapBufferObjectAsync " , CONV_GL , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuGLUnregisterBufferObject " , <nl> + ( " hipGLUnregisterBufferObject " , CONV_GL , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_D3D9_DEVICE_LIST_ALL " , <nl> + ( " HIP_D3D9_DEVICE_LIST_ALL " , CONV_D3D9 , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_D3D9_DEVICE_LIST_CURRENT_FRAME " , <nl> + ( <nl> + " HIP_D3D9_DEVICE_LIST_CURRENT_FRAME " , <nl> + CONV_D3D9 , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_D3D9_DEVICE_LIST_NEXT_FRAME " , <nl> + ( " HIP_D3D9_DEVICE_LIST_NEXT_FRAME " , CONV_D3D9 , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuD3D9CtxCreate " , <nl> + ( " hipD3D9CtxCreate " , CONV_D3D9 , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuD3D9CtxCreateOnDevice " , <nl> + ( " hipD3D9CtxCreateOnDevice " , CONV_D3D9 , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuD3D9GetDevice " , <nl> + ( " hipD3D9GetDevice " , CONV_D3D9 , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuD3D9GetDevices " , <nl> + ( " hipD3D9GetDevices " , CONV_D3D9 , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuD3D9GetDirect3DDevice " , <nl> + ( " hipD3D9GetDirect3DDevice " , CONV_D3D9 , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuGraphicsD3D9RegisterResource " , <nl> + ( " hipGraphicsD3D9RegisterResource " , CONV_D3D9 , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_D3D9_MAPRESOURCE_FLAGS_NONE " , <nl> + ( " HIP_D3D9_MAPRESOURCE_FLAGS_NONE " , CONV_D3D9 , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_D3D9_MAPRESOURCE_FLAGS_READONLY " , <nl> + ( <nl> + " HIP_D3D9_MAPRESOURCE_FLAGS_READONLY " , <nl> + CONV_D3D9 , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_D3D9_MAPRESOURCE_FLAGS_WRITEDISCARD " , <nl> + ( <nl> + " HIP_D3D9_MAPRESOURCE_FLAGS_WRITEDISCARD " , <nl> + CONV_D3D9 , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_D3D9_REGISTER_FLAGS_NONE " , <nl> + ( " HIP_D3D9_REGISTER_FLAGS_NONE " , CONV_D3D9 , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_D3D9_REGISTER_FLAGS_ARRAY " , <nl> + ( " HIP_D3D9_REGISTER_FLAGS_ARRAY " , CONV_D3D9 , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuD3D9MapResources " , <nl> + ( " hipD3D9MapResources " , CONV_D3D9 , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuD3D9RegisterResource " , <nl> + ( " hipD3D9RegisterResource " , CONV_D3D9 , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuD3D9ResourceGetMappedArray " , <nl> + ( " hipD3D9ResourceGetMappedArray " , CONV_D3D9 , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuD3D9ResourceGetMappedPitch " , <nl> + ( " hipD3D9ResourceGetMappedPitch " , CONV_D3D9 , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuD3D9ResourceGetMappedPointer " , <nl> + ( " hipD3D9ResourceGetMappedPointer " , CONV_D3D9 , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuD3D9ResourceGetMappedSize " , <nl> + ( " hipD3D9ResourceGetMappedSize " , CONV_D3D9 , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuD3D9ResourceGetSurfaceDimensions " , <nl> + ( <nl> + " hipD3D9ResourceGetSurfaceDimensions " , <nl> + CONV_D3D9 , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cuD3D9ResourceSetMapFlags " , <nl> + ( " hipD3D9ResourceSetMapFlags " , CONV_D3D9 , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuD3D9UnmapResources " , <nl> + ( " hipD3D9UnmapResources " , CONV_D3D9 , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuD3D9UnregisterResource " , <nl> + ( " hipD3D9UnregisterResource " , CONV_D3D9 , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_D3D10_DEVICE_LIST_ALL " , <nl> + ( " HIP_D3D10_DEVICE_LIST_ALL " , CONV_D3D10 , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_D3D10_DEVICE_LIST_CURRENT_FRAME " , <nl> + ( <nl> + " HIP_D3D10_DEVICE_LIST_CURRENT_FRAME " , <nl> + CONV_D3D10 , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_D3D10_DEVICE_LIST_NEXT_FRAME " , <nl> + ( <nl> + " HIP_D3D10_DEVICE_LIST_NEXT_FRAME " , <nl> + CONV_D3D10 , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cuD3D10GetDevice " , <nl> + ( " hipD3D10GetDevice " , CONV_D3D10 , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuD3D10GetDevices " , <nl> + ( " hipD3D10GetDevices " , CONV_D3D10 , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuGraphicsD3D10RegisterResource " , <nl> + ( <nl> + " hipGraphicsD3D10RegisterResource " , <nl> + CONV_D3D10 , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_D3D10_MAPRESOURCE_FLAGS_NONE " , <nl> + ( <nl> + " HIP_D3D10_MAPRESOURCE_FLAGS_NONE " , <nl> + CONV_D3D10 , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_D3D10_MAPRESOURCE_FLAGS_READONLY " , <nl> + ( <nl> + " HIP_D3D10_MAPRESOURCE_FLAGS_READONLY " , <nl> + CONV_D3D10 , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_D3D10_MAPRESOURCE_FLAGS_WRITEDISCARD " , <nl> + ( <nl> + " HIP_D3D10_MAPRESOURCE_FLAGS_WRITEDISCARD " , <nl> + CONV_D3D10 , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_D3D10_REGISTER_FLAGS_NONE " , <nl> + ( " HIP_D3D10_REGISTER_FLAGS_NONE " , CONV_D3D10 , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_D3D10_REGISTER_FLAGS_ARRAY " , <nl> + ( " HIP_D3D10_REGISTER_FLAGS_ARRAY " , CONV_D3D10 , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuD3D10CtxCreate " , <nl> + ( " hipD3D10CtxCreate " , CONV_D3D10 , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuD3D10CtxCreateOnDevice " , <nl> + ( " hipD3D10CtxCreateOnDevice " , CONV_D3D10 , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuD3D10GetDirect3DDevice " , <nl> + ( " hipD3D10GetDirect3DDevice " , CONV_D3D10 , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuD3D10MapResources " , <nl> + ( " hipD3D10MapResources " , CONV_D3D10 , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuD3D10RegisterResource " , <nl> + ( " hipD3D10RegisterResource " , CONV_D3D10 , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuD3D10ResourceGetMappedArray " , <nl> + ( " hipD3D10ResourceGetMappedArray " , CONV_D3D10 , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuD3D10ResourceGetMappedPitch " , <nl> + ( " hipD3D10ResourceGetMappedPitch " , CONV_D3D10 , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuD3D10ResourceGetMappedPointer " , <nl> + ( <nl> + " hipD3D10ResourceGetMappedPointer " , <nl> + CONV_D3D10 , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cuD3D10ResourceGetMappedSize " , <nl> + ( " hipD3D10ResourceGetMappedSize " , CONV_D3D10 , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuD3D10ResourceGetSurfaceDimensions " , <nl> + ( <nl> + " hipD3D10ResourceGetSurfaceDimensions " , <nl> + CONV_D3D10 , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cuD310ResourceSetMapFlags " , <nl> + ( " hipD3D10ResourceSetMapFlags " , CONV_D3D10 , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuD3D10UnmapResources " , <nl> + ( " hipD3D10UnmapResources " , CONV_D3D10 , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuD3D10UnregisterResource " , <nl> + ( " hipD3D10UnregisterResource " , CONV_D3D10 , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_D3D11_DEVICE_LIST_ALL " , <nl> + ( " HIP_D3D11_DEVICE_LIST_ALL " , CONV_D3D11 , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CU_D3D11_DEVICE_LIST_CURRENT_FRAME " , <nl> + ( <nl> + " HIP_D3D11_DEVICE_LIST_CURRENT_FRAME " , <nl> + CONV_D3D11 , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CU_D3D11_DEVICE_LIST_NEXT_FRAME " , <nl> + ( <nl> + " HIP_D3D11_DEVICE_LIST_NEXT_FRAME " , <nl> + CONV_D3D11 , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cuD3D11GetDevice " , <nl> + ( " hipD3D11GetDevice " , CONV_D3D11 , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuD3D11GetDevices " , <nl> + ( " hipD3D11GetDevices " , CONV_D3D11 , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuGraphicsD3D11RegisterResource " , <nl> + ( <nl> + " hipGraphicsD3D11RegisterResource " , <nl> + CONV_D3D11 , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cuD3D11CtxCreate " , <nl> + ( " hipD3D11CtxCreate " , CONV_D3D11 , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuD3D11CtxCreateOnDevice " , <nl> + ( " hipD3D11CtxCreateOnDevice " , CONV_D3D11 , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuD3D11GetDirect3DDevice " , <nl> + ( " hipD3D11GetDirect3DDevice " , CONV_D3D11 , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuGraphicsVDPAURegisterOutputSurface " , <nl> + ( <nl> + " hipGraphicsVDPAURegisterOutputSurface " , <nl> + CONV_VDPAU , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cuGraphicsVDPAURegisterVideoSurface " , <nl> + ( <nl> + " hipGraphicsVDPAURegisterVideoSurface " , <nl> + CONV_VDPAU , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cuVDPAUGetDevice " , <nl> + ( " hipVDPAUGetDevice " , CONV_VDPAU , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuVDPAUCtxCreate " , <nl> + ( " hipVDPAUCtxCreate " , CONV_VDPAU , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuEGLStreamConsumerAcquireFrame " , <nl> + ( " hipEGLStreamConsumerAcquireFrame " , CONV_EGL , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuEGLStreamConsumerConnect " , <nl> + ( " hipEGLStreamConsumerConnect " , CONV_EGL , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuEGLStreamConsumerConnectWithFlags " , <nl> + ( <nl> + " hipEGLStreamConsumerConnectWithFlags " , <nl> + CONV_EGL , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cuEGLStreamConsumerDisconnect " , <nl> + ( " hipEGLStreamConsumerDisconnect " , CONV_EGL , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuEGLStreamConsumerReleaseFrame " , <nl> + ( " hipEGLStreamConsumerReleaseFrame " , CONV_EGL , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuEGLStreamProducerConnect " , <nl> + ( " hipEGLStreamProducerConnect " , CONV_EGL , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuEGLStreamProducerDisconnect " , <nl> + ( " hipEGLStreamProducerDisconnect " , CONV_EGL , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuEGLStreamProducerPresentFrame " , <nl> + ( " hipEGLStreamProducerPresentFrame " , CONV_EGL , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuEGLStreamProducerReturnFrame " , <nl> + ( " hipEGLStreamProducerReturnFrame " , CONV_EGL , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuGraphicsEGLRegisterImage " , <nl> + ( " hipGraphicsEGLRegisterImage " , CONV_EGL , API_DRIVER , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cuGraphicsResourceGetMappedEglFrame " , <nl> + ( <nl> + " hipGraphicsResourceGetMappedEglFrame " , <nl> + CONV_EGL , <nl> + API_DRIVER , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( " cudaDataType_t " , ( " hipDataType_t " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> + ( " cudaDataType " , ( " hipDataType_t " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> + ( " CUDA_R_16F " , ( " hipR16F " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> + ( " CUDA_C_16F " , ( " hipC16F " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> + ( " CUDA_R_32F " , ( " hipR32F " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> + ( " CUDA_C_32F " , ( " hipC32F " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> + ( " CUDA_R_64F " , ( " hipR64F " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> + ( " CUDA_C_64F " , ( " hipC64F " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> + ( " CUDA_R_8I " , ( " hipR8I " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> + ( " CUDA_C_8I " , ( " hipC8I " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> + ( " CUDA_R_8U " , ( " hipR8U " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> + ( " CUDA_C_8U " , ( " hipC8U " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> + ( " CUDA_R_32I " , ( " hipR32I " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> + ( " CUDA_C_32I " , ( " hipC32I " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> + ( " CUDA_R_32U " , ( " hipR32U " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> + ( " CUDA_C_32U " , ( " hipC32U " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> + ( <nl> + " MAJOR_VERSION " , <nl> + ( " hipLibraryMajorVersion " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " MINOR_VERSION " , <nl> + ( " hipLibraryMinorVersion " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " PATCH_LEVEL " , <nl> + ( " hipLibraryPatchVersion " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaMemAttachGlobal " , <nl> + ( " hipMemAttachGlobal " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaMemAttachHost " , <nl> + ( " hipMemAttachHost " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaMemAttachSingle " , <nl> + ( " hipMemAttachSingle " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaOccupancyDefault " , <nl> + ( " hipOccupancyDefault " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaOccupancyDisableCachingOverride " , <nl> + ( <nl> + " hipOccupancyDisableCachingOverride " , <nl> + CONV_TYPE , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( " cudaGetLastError " , ( " hipGetLastError " , CONV_ERROR , API_RUNTIME ) ) , <nl> + ( " cudaPeekAtLastError " , ( " hipPeekAtLastError " , CONV_ERROR , API_RUNTIME ) ) , <nl> + ( " cudaGetErrorName " , ( " hipGetErrorName " , CONV_ERROR , API_RUNTIME ) ) , <nl> + ( " cudaGetErrorString " , ( " hipGetErrorString " , CONV_ERROR , API_RUNTIME ) ) , <nl> + ( " cudaMemcpy3DParms " , ( " hipMemcpy3DParms " , CONV_MEM , API_RUNTIME ) ) , <nl> + ( <nl> + " cudaMemcpy3DPeerParms " , <nl> + ( " hipMemcpy3DPeerParms " , CONV_MEM , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cudaMemcpy " , ( " hipMemcpy " , CONV_MEM , API_RUNTIME ) ) , <nl> + ( " cudaMemcpyToArray " , ( " hipMemcpyToArray " , CONV_MEM , API_RUNTIME ) ) , <nl> + ( " cudaMemcpyToSymbol " , ( " hipMemcpyToSymbol " , CONV_MEM , API_RUNTIME ) ) , <nl> + ( " cudaMemcpyToSymbolAsync " , ( " hipMemcpyToSymbolAsync " , CONV_MEM , API_RUNTIME ) ) , <nl> + ( " cudaMemcpyAsync " , ( " hipMemcpyAsync " , CONV_MEM , API_RUNTIME ) ) , <nl> + ( " cudaMemcpy2D " , ( " hipMemcpy2D " , CONV_MEM , API_RUNTIME ) ) , <nl> + ( " cudaMemcpy2DAsync " , ( " hipMemcpy2DAsync " , CONV_MEM , API_RUNTIME ) ) , <nl> + ( " cudaMemcpy2DToArray " , ( " hipMemcpy2DToArray " , CONV_MEM , API_RUNTIME ) ) , <nl> + ( <nl> + " cudaMemcpy2DArrayToArray " , <nl> + ( " hipMemcpy2DArrayToArray " , CONV_MEM , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaMemcpy2DFromArray " , <nl> + ( " hipMemcpy2DFromArray " , CONV_MEM , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaMemcpy2DFromArrayAsync " , <nl> + ( " hipMemcpy2DFromArrayAsync " , CONV_MEM , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaMemcpy2DToArrayAsync " , <nl> + ( " hipMemcpy2DToArrayAsync " , CONV_MEM , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cudaMemcpy3D " , ( " hipMemcpy3D " , CONV_MEM , API_RUNTIME ) ) , <nl> + ( <nl> + " cudaMemcpy3DAsync " , <nl> + ( " hipMemcpy3DAsync " , CONV_MEM , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaMemcpy3DPeer " , <nl> + ( " hipMemcpy3DPeer " , CONV_MEM , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaMemcpy3DPeerAsync " , <nl> + ( " hipMemcpy3DPeerAsync " , CONV_MEM , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaMemcpyArrayToArray " , <nl> + ( " hipMemcpyArrayToArray " , CONV_MEM , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaMemcpyFromArrayAsync " , <nl> + ( " hipMemcpyFromArrayAsync " , CONV_MEM , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cudaMemcpyFromSymbol " , ( " hipMemcpyFromSymbol " , CONV_MEM , API_RUNTIME ) ) , <nl> + ( <nl> + " cudaMemcpyFromSymbolAsync " , <nl> + ( " hipMemcpyFromSymbolAsync " , CONV_MEM , API_RUNTIME ) , <nl> + ) , <nl> + ( " cudaMemAdvise " , ( " hipMemAdvise " , CONV_MEM , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> + ( <nl> + " cudaMemRangeGetAttribute " , <nl> + ( " hipMemRangeGetAttribute " , CONV_MEM , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaMemRangeGetAttributes " , <nl> + ( " hipMemRangeGetAttributes " , CONV_MEM , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaMemAdviseSetReadMostly " , <nl> + ( " hipMemAdviseSetReadMostly " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaMemAdviseUnsetReadMostly " , <nl> + ( " hipMemAdviseUnsetReadMostly " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaMemAdviseSetPreferredLocation " , <nl> + ( <nl> + " hipMemAdviseSetPreferredLocation " , <nl> + CONV_TYPE , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaMemAdviseUnsetPreferredLocation " , <nl> + ( <nl> + " hipMemAdviseUnsetPreferredLocation " , <nl> + CONV_TYPE , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaMemAdviseSetAccessedBy " , <nl> + ( " hipMemAdviseSetAccessedBy " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaMemAdviseUnsetAccessedBy " , <nl> + ( " hipMemAdviseUnsetAccessedBy " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaMemRangeAttributeReadMostly " , <nl> + ( " hipMemRangeAttributeReadMostly " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaMemRangeAttributePreferredLocation " , <nl> + ( <nl> + " hipMemRangeAttributePreferredLocation " , <nl> + CONV_TYPE , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaMemRangeAttributeAccessedBy " , <nl> + ( " hipMemRangeAttributeAccessedBy " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaMemRangeAttributeLastPrefetchLocation " , <nl> + ( <nl> + " hipMemRangeAttributeLastPrefetchLocation " , <nl> + CONV_TYPE , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( " cudaMemcpyHostToHost " , ( " hipMemcpyHostToHost " , CONV_MEM , API_RUNTIME ) ) , <nl> + ( " cudaMemcpyHostToDevice " , ( " hipMemcpyHostToDevice " , CONV_MEM , API_RUNTIME ) ) , <nl> + ( " cudaMemcpyDeviceToHost " , ( " hipMemcpyDeviceToHost " , CONV_MEM , API_RUNTIME ) ) , <nl> + ( <nl> + " cudaMemcpyDeviceToDevice " , <nl> + ( " hipMemcpyDeviceToDevice " , CONV_MEM , API_RUNTIME ) , <nl> + ) , <nl> + ( " cudaMemcpyDefault " , ( " hipMemcpyDefault " , CONV_MEM , API_RUNTIME ) ) , <nl> + ( " cudaMemset " , ( " hipMemset " , CONV_MEM , API_RUNTIME ) ) , <nl> + ( " cudaMemsetAsync " , ( " hipMemsetAsync " , CONV_MEM , API_RUNTIME ) ) , <nl> + ( " cudaMemset2D " , ( " hipMemset2D " , CONV_MEM , API_RUNTIME ) ) , <nl> + ( <nl> + " cudaMemset2DAsync " , <nl> + ( " hipMemset2DAsync " , CONV_MEM , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cudaMemset3D " , ( " hipMemset3D " , CONV_MEM , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> + ( <nl> + " cudaMemset3DAsync " , <nl> + ( " hipMemset3DAsync " , CONV_MEM , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cudaMemGetInfo " , ( " hipMemGetInfo " , CONV_MEM , API_RUNTIME ) ) , <nl> + ( <nl> + " cudaArrayGetInfo " , <nl> + ( " hipArrayGetInfo " , CONV_MEM , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaFreeMipmappedArray " , <nl> + ( " hipFreeMipmappedArray " , CONV_MEM , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaGetMipmappedArrayLevel " , <nl> + ( " hipGetMipmappedArrayLevel " , CONV_MEM , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaGetSymbolAddress " , <nl> + ( " hipGetSymbolAddress " , CONV_MEM , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaGetSymbolSize " , <nl> + ( " hipGetSymbolSize " , CONV_MEM , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaMemPrefetchAsync " , <nl> + ( " hipMemPrefetchAsync " , CONV_MEM , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cudaMallocHost " , ( " hipHostMalloc " , CONV_MEM , API_RUNTIME ) ) , <nl> + ( " cudaMallocArray " , ( " hipMallocArray " , CONV_MEM , API_RUNTIME ) ) , <nl> + ( " cudaMalloc " , ( " hipMalloc " , CONV_MEM , API_RUNTIME ) ) , <nl> + ( " cudaMalloc3D " , ( " hipMalloc3D " , CONV_MEM , API_RUNTIME ) ) , <nl> + ( " cudaMalloc3DArray " , ( " hipMalloc3DArray " , CONV_MEM , API_RUNTIME ) ) , <nl> + ( <nl> + " cudaMallocManaged " , <nl> + ( " hipMallocManaged " , CONV_MEM , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaMallocMipmappedArray " , <nl> + ( " hipMallocMipmappedArray " , CONV_MEM , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cudaMallocPitch " , ( " hipMallocPitch " , CONV_MEM , API_RUNTIME ) ) , <nl> + ( " cudaFreeHost " , ( " hipHostFree " , CONV_MEM , API_RUNTIME ) ) , <nl> + ( " cudaFreeArray " , ( " hipFreeArray " , CONV_MEM , API_RUNTIME ) ) , <nl> + ( " cudaFree " , ( " hipFree " , CONV_MEM , API_RUNTIME ) ) , <nl> + ( " cudaHostRegister " , ( " hipHostRegister " , CONV_MEM , API_RUNTIME ) ) , <nl> + ( " cudaHostUnregister " , ( " hipHostUnregister " , CONV_MEM , API_RUNTIME ) ) , <nl> + ( " cudaHostAlloc " , ( " hipHostMalloc " , CONV_MEM , API_RUNTIME ) ) , <nl> + ( " cudaMemoryTypeHost " , ( " hipMemoryTypeHost " , CONV_MEM , API_RUNTIME ) ) , <nl> + ( " cudaMemoryTypeDevice " , ( " hipMemoryTypeDevice " , CONV_MEM , API_RUNTIME ) ) , <nl> + ( " make_cudaExtent " , ( " make_hipExtent " , CONV_MEM , API_RUNTIME ) ) , <nl> + ( " make_cudaPitchedPtr " , ( " make_hipPitchedPtr " , CONV_MEM , API_RUNTIME ) ) , <nl> + ( " make_cudaPos " , ( " make_hipPos " , CONV_MEM , API_RUNTIME ) ) , <nl> + ( " cudaHostAllocDefault " , ( " hipHostMallocDefault " , CONV_MEM , API_RUNTIME ) ) , <nl> + ( " cudaHostAllocPortable " , ( " hipHostMallocPortable " , CONV_MEM , API_RUNTIME ) ) , <nl> + ( " cudaHostAllocMapped " , ( " hipHostMallocMapped " , CONV_MEM , API_RUNTIME ) ) , <nl> + ( <nl> + " cudaHostAllocWriteCombined " , <nl> + ( " hipHostMallocWriteCombined " , CONV_MEM , API_RUNTIME ) , <nl> + ) , <nl> + ( " cudaHostGetFlags " , ( " hipHostGetFlags " , CONV_MEM , API_RUNTIME ) ) , <nl> + ( " cudaHostRegisterDefault " , ( " hipHostRegisterDefault " , CONV_MEM , API_RUNTIME ) ) , <nl> + ( <nl> + " cudaHostRegisterPortable " , <nl> + ( " hipHostRegisterPortable " , CONV_MEM , API_RUNTIME ) , <nl> + ) , <nl> + ( " cudaHostRegisterMapped " , ( " hipHostRegisterMapped " , CONV_MEM , API_RUNTIME ) ) , <nl> + ( <nl> + " cudaHostRegisterIoMemory " , <nl> + ( " hipHostRegisterIoMemory " , CONV_MEM , API_RUNTIME ) , <nl> + ) , <nl> + # ( " warpSize " , ( " hipWarpSize " , CONV_SPECIAL_FUNC , API_RUNTIME ) , ( HIP actually uses warpSize . . . ) , <nl> + ( " cudaEventCreate " , ( " hipEventCreate " , CONV_EVENT , API_RUNTIME ) ) , <nl> + ( <nl> + " cudaEventCreateWithFlags " , <nl> + ( " hipEventCreateWithFlags " , CONV_EVENT , API_RUNTIME ) , <nl> + ) , <nl> + ( " cudaEventDestroy " , ( " hipEventDestroy " , CONV_EVENT , API_RUNTIME ) ) , <nl> + ( " cudaEventRecord " , ( " hipEventRecord " , CONV_EVENT , API_RUNTIME ) ) , <nl> + ( " cudaEventElapsedTime " , ( " hipEventElapsedTime " , CONV_EVENT , API_RUNTIME ) ) , <nl> + ( " cudaEventSynchronize " , ( " hipEventSynchronize " , CONV_EVENT , API_RUNTIME ) ) , <nl> + ( " cudaEventQuery " , ( " hipEventQuery " , CONV_EVENT , API_RUNTIME ) ) , <nl> + ( " cudaEventDefault " , ( " hipEventDefault " , CONV_EVENT , API_RUNTIME ) ) , <nl> + ( " cudaEventBlockingSync " , ( " hipEventBlockingSync " , CONV_EVENT , API_RUNTIME ) ) , <nl> + ( " cudaEventDisableTiming " , ( " hipEventDisableTiming " , CONV_EVENT , API_RUNTIME ) ) , <nl> + ( " cudaEventInterprocess " , ( " hipEventInterprocess " , CONV_EVENT , API_RUNTIME ) ) , <nl> + ( " cudaStreamCreate " , ( " hipStreamCreate " , CONV_STREAM , API_RUNTIME ) ) , <nl> + ( <nl> + " cudaStreamCreateWithFlags " , <nl> + ( " hipStreamCreateWithFlags " , CONV_STREAM , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " cudaStreamCreateWithPriority " , <nl> + ( " hipStreamCreateWithPriority " , CONV_STREAM , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cudaStreamDestroy " , ( " hipStreamDestroy " , CONV_STREAM , API_RUNTIME ) ) , <nl> + ( " cudaStreamWaitEvent " , ( " hipStreamWaitEvent " , CONV_STREAM , API_RUNTIME ) ) , <nl> + ( " cudaStreamSynchronize " , ( " hipStreamSynchronize " , CONV_STREAM , API_RUNTIME ) ) , <nl> + ( " cudaStreamGetFlags " , ( " hipStreamGetFlags " , CONV_STREAM , API_RUNTIME ) ) , <nl> + ( " cudaStreamQuery " , ( " hipStreamQuery " , CONV_STREAM , API_RUNTIME ) ) , <nl> + ( " cudaStreamAddCallback " , ( " hipStreamAddCallback " , CONV_STREAM , API_RUNTIME ) ) , <nl> + ( <nl> + " cudaStreamAttachMemAsync " , <nl> + ( " hipStreamAttachMemAsync " , CONV_STREAM , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaStreamGetPriority " , <nl> + ( " hipStreamGetPriority " , CONV_STREAM , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cudaStreamDefault " , ( " hipStreamDefault " , CONV_TYPE , API_RUNTIME ) ) , <nl> + ( " cudaStreamNonBlocking " , ( " hipStreamNonBlocking " , CONV_TYPE , API_RUNTIME ) ) , <nl> + ( " cudaDeviceSynchronize " , ( " hipDeviceSynchronize " , CONV_DEVICE , API_RUNTIME ) ) , <nl> + ( " cudaDeviceReset " , ( " hipDeviceReset " , CONV_DEVICE , API_RUNTIME ) ) , <nl> + ( " cudaSetDevice " , ( " hipSetDevice " , CONV_DEVICE , API_RUNTIME ) ) , <nl> + ( " cudaGetDevice " , ( " hipGetDevice " , CONV_DEVICE , API_RUNTIME ) ) , <nl> + ( " cudaGetDeviceCount " , ( " hipGetDeviceCount " , CONV_DEVICE , API_RUNTIME ) ) , <nl> + ( " cudaChooseDevice " , ( " hipChooseDevice " , CONV_DEVICE , API_RUNTIME ) ) , <nl> + ( " cudaThreadExit " , ( " hipDeviceReset " , CONV_THREAD , API_RUNTIME ) ) , <nl> + ( <nl> + " cudaThreadGetCacheConfig " , <nl> + ( " hipDeviceGetCacheConfig " , CONV_THREAD , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " cudaThreadGetLimit " , <nl> + ( " hipThreadGetLimit " , CONV_THREAD , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaThreadSetCacheConfig " , <nl> + ( " hipDeviceSetCacheConfig " , CONV_THREAD , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " cudaThreadSetLimit " , <nl> + ( " hipThreadSetLimit " , CONV_THREAD , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cudaThreadSynchronize " , ( " hipDeviceSynchronize " , CONV_THREAD , API_RUNTIME ) ) , <nl> + ( " cudaDeviceGetAttribute " , ( " hipDeviceGetAttribute " , CONV_DEVICE , API_RUNTIME ) ) , <nl> + ( <nl> + " cudaDevAttrMaxThreadsPerBlock " , <nl> + ( " hipDeviceAttributeMaxThreadsPerBlock " , CONV_TYPE , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrMaxBlockDimX " , <nl> + ( " hipDeviceAttributeMaxBlockDimX " , CONV_TYPE , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrMaxBlockDimY " , <nl> + ( " hipDeviceAttributeMaxBlockDimY " , CONV_TYPE , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrMaxBlockDimZ " , <nl> + ( " hipDeviceAttributeMaxBlockDimZ " , CONV_TYPE , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrMaxGridDimX " , <nl> + ( " hipDeviceAttributeMaxGridDimX " , CONV_TYPE , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrMaxGridDimY " , <nl> + ( " hipDeviceAttributeMaxGridDimY " , CONV_TYPE , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrMaxGridDimZ " , <nl> + ( " hipDeviceAttributeMaxGridDimZ " , CONV_TYPE , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrMaxSharedMemoryPerBlock " , <nl> + ( " hipDeviceAttributeMaxSharedMemoryPerBlock " , CONV_TYPE , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrTotalConstantMemory " , <nl> + ( " hipDeviceAttributeTotalConstantMemory " , CONV_TYPE , API_RUNTIME ) , <nl> + ) , <nl> + ( " cudaDevAttrWarpSize " , ( " hipDeviceAttributeWarpSize " , CONV_TYPE , API_RUNTIME ) ) , <nl> + ( <nl> + " cudaDevAttrMaxPitch " , <nl> + ( " hipDeviceAttributeMaxPitch " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrMaxRegistersPerBlock " , <nl> + ( " hipDeviceAttributeMaxRegistersPerBlock " , CONV_TYPE , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrClockRate " , <nl> + ( " hipDeviceAttributeClockRate " , CONV_TYPE , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrTextureAlignment " , <nl> + ( <nl> + " hipDeviceAttributeTextureAlignment " , <nl> + CONV_TYPE , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrGpuOverlap " , <nl> + ( " hipDeviceAttributeGpuOverlap " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrMultiProcessorCount " , <nl> + ( " hipDeviceAttributeMultiprocessorCount " , CONV_TYPE , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrKernelExecTimeout " , <nl> + ( <nl> + " hipDeviceAttributeKernelExecTimeout " , <nl> + CONV_TYPE , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrIntegrated " , <nl> + ( " hipDeviceAttributeIntegrated " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrCanMapHostMemory " , <nl> + ( <nl> + " hipDeviceAttributeCanMapHostMemory " , <nl> + CONV_TYPE , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrComputeMode " , <nl> + ( " hipDeviceAttributeComputeMode " , CONV_TYPE , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrMaxTexture1DWidth " , <nl> + ( <nl> + " hipDeviceAttributeMaxTexture1DWidth " , <nl> + CONV_TYPE , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrMaxTexture2DWidth " , <nl> + ( <nl> + " hipDeviceAttributeMaxTexture2DWidth " , <nl> + CONV_TYPE , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrMaxTexture2DHeight " , <nl> + ( <nl> + " hipDeviceAttributeMaxTexture2DHeight " , <nl> + CONV_TYPE , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrMaxTexture3DWidth " , <nl> + ( <nl> + " hipDeviceAttributeMaxTexture3DWidth " , <nl> + CONV_TYPE , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrMaxTexture3DHeight " , <nl> + ( <nl> + " hipDeviceAttributeMaxTexture3DHeight " , <nl> + CONV_TYPE , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrMaxTexture3DDepth " , <nl> + ( <nl> + " hipDeviceAttributeMaxTexture3DDepth " , <nl> + CONV_TYPE , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrMaxTexture2DLayeredWidth " , <nl> + ( <nl> + " hipDeviceAttributeMaxTexture2DLayeredWidth " , <nl> + CONV_TYPE , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrMaxTexture2DLayeredHeight " , <nl> + ( <nl> + " hipDeviceAttributeMaxTexture2DLayeredHeight " , <nl> + CONV_TYPE , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrMaxTexture2DLayeredLayers " , <nl> + ( <nl> + " hipDeviceAttributeMaxTexture2DLayeredLayers " , <nl> + CONV_TYPE , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrSurfaceAlignment " , <nl> + ( <nl> + " hipDeviceAttributeSurfaceAlignment " , <nl> + CONV_TYPE , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrConcurrentKernels " , <nl> + ( " hipDeviceAttributeConcurrentKernels " , CONV_TYPE , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrEccEnabled " , <nl> + ( " hipDeviceAttributeEccEnabled " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cudaDevAttrPciBusId " , ( " hipDeviceAttributePciBusId " , CONV_TYPE , API_RUNTIME ) ) , <nl> + ( <nl> + " cudaDevAttrPciDeviceId " , <nl> + ( " hipDeviceAttributePciDeviceId " , CONV_TYPE , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrTccDriver " , <nl> + ( " hipDeviceAttributeTccDriver " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrMemoryClockRate " , <nl> + ( " hipDeviceAttributeMemoryClockRate " , CONV_TYPE , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrGlobalMemoryBusWidth " , <nl> + ( " hipDeviceAttributeMemoryBusWidth " , CONV_TYPE , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrL2CacheSize " , <nl> + ( " hipDeviceAttributeL2CacheSize " , CONV_TYPE , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrMaxThreadsPerMultiProcessor " , <nl> + ( " hipDeviceAttributeMaxThreadsPerMultiProcessor " , CONV_TYPE , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrAsyncEngineCount " , <nl> + ( <nl> + " hipDeviceAttributeAsyncEngineCount " , <nl> + CONV_TYPE , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrUnifiedAddressing " , <nl> + ( <nl> + " hipDeviceAttributeUnifiedAddressing " , <nl> + CONV_TYPE , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrMaxTexture1DLayeredWidth " , <nl> + ( <nl> + " hipDeviceAttributeMaxTexture1DLayeredWidth " , <nl> + CONV_TYPE , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrMaxTexture1DLayeredLayers " , <nl> + ( <nl> + " hipDeviceAttributeMaxTexture1DLayeredLayers " , <nl> + CONV_TYPE , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrMaxTexture2DGatherWidth " , <nl> + ( <nl> + " hipDeviceAttributeMaxTexture2DGatherWidth " , <nl> + CONV_TYPE , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrMaxTexture2DGatherHeight " , <nl> + ( <nl> + " hipDeviceAttributeMaxTexture2DGatherHeight " , <nl> + CONV_TYPE , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrMaxTexture3DWidthAlt " , <nl> + ( <nl> + " hipDeviceAttributeMaxTexture3DWidthAlternate " , <nl> + CONV_TYPE , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrMaxTexture3DHeightAlt " , <nl> + ( <nl> + " hipDeviceAttributeMaxTexture3DHeightAlternate " , <nl> + CONV_TYPE , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrMaxTexture3DDepthAlt " , <nl> + ( <nl> + " hipDeviceAttributeMaxTexture3DDepthAlternate " , <nl> + CONV_TYPE , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrPciDomainId " , <nl> + ( " hipDeviceAttributePciDomainId " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrTexturePitchAlignment " , <nl> + ( <nl> + " hipDeviceAttributeTexturePitchAlignment " , <nl> + CONV_TYPE , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrMaxTextureCubemapWidth " , <nl> + ( <nl> + " hipDeviceAttributeMaxTextureCubemapWidth " , <nl> + CONV_TYPE , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrMaxTextureCubemapLayeredWidth " , <nl> + ( <nl> + " hipDeviceAttributeMaxTextureCubemapLayeredWidth " , <nl> + CONV_TYPE , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrMaxTextureCubemapLayeredLayers " , <nl> + ( <nl> + " hipDeviceAttributeMaxTextureCubemapLayeredLayers " , <nl> + CONV_TYPE , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrMaxSurface1DWidth " , <nl> + ( <nl> + " hipDeviceAttributeMaxSurface1DWidth " , <nl> + CONV_TYPE , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrMaxSurface2DWidth " , <nl> + ( <nl> + " hipDeviceAttributeMaxSurface2DWidth " , <nl> + CONV_TYPE , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrMaxSurface2DHeight " , <nl> + ( <nl> + " hipDeviceAttributeMaxSurface2DHeight " , <nl> + CONV_TYPE , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrMaxSurface3DWidth " , <nl> + ( <nl> + " hipDeviceAttributeMaxSurface3DWidth " , <nl> + CONV_TYPE , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrMaxSurface3DHeight " , <nl> + ( <nl> + " hipDeviceAttributeMaxSurface3DHeight " , <nl> + CONV_TYPE , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrMaxSurface3DDepth " , <nl> + ( <nl> + " hipDeviceAttributeMaxSurface3DDepth " , <nl> + CONV_TYPE , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrMaxSurface1DLayeredWidth " , <nl> + ( <nl> + " hipDeviceAttributeMaxSurface1DLayeredWidth " , <nl> + CONV_TYPE , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrMaxSurface1DLayeredLayers " , <nl> + ( <nl> + " hipDeviceAttributeMaxSurface1DLayeredLayers " , <nl> + CONV_TYPE , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrMaxSurface2DLayeredWidth " , <nl> + ( <nl> + " hipDeviceAttributeMaxSurface2DLayeredWidth " , <nl> + CONV_TYPE , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrMaxSurface2DLayeredHeight " , <nl> + ( <nl> + " hipDeviceAttributeMaxSurface2DLayeredHeight " , <nl> + CONV_TYPE , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrMaxSurface2DLayeredLayers " , <nl> + ( <nl> + " hipDeviceAttributeMaxSurface2DLayeredLayers " , <nl> + CONV_TYPE , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrMaxSurfaceCubemapWidth " , <nl> + ( <nl> + " hipDeviceAttributeMaxSurfaceCubemapWidth " , <nl> + CONV_TYPE , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrMaxSurfaceCubemapLayeredWidth " , <nl> + ( <nl> + " hipDeviceAttributeMaxSurfaceCubemapLayeredWidth " , <nl> + CONV_TYPE , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrMaxSurfaceCubemapLayeredLayers " , <nl> + ( <nl> + " hipDeviceAttributeMaxSurfaceCubemapLayeredLayers " , <nl> + CONV_TYPE , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrMaxTexture1DLinearWidth " , <nl> + ( <nl> + " hipDeviceAttributeMaxTexture1DLinearWidth " , <nl> + CONV_TYPE , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrMaxTexture2DLinearWidth " , <nl> + ( <nl> + " hipDeviceAttributeMaxTexture2DLinearWidth " , <nl> + CONV_TYPE , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrMaxTexture2DLinearHeight " , <nl> + ( <nl> + " hipDeviceAttributeMaxTexture2DLinearHeight " , <nl> + CONV_TYPE , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrMaxTexture2DLinearPitch " , <nl> + ( <nl> + " hipDeviceAttributeMaxTexture2DLinearPitch " , <nl> + CONV_TYPE , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrMaxTexture2DMipmappedWidth " , <nl> + ( <nl> + " hipDeviceAttributeMaxTexture2DMipmappedWidth " , <nl> + CONV_TYPE , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrMaxTexture2DMipmappedHeight " , <nl> + ( <nl> + " hipDeviceAttributeMaxTexture2DMipmappedHeight " , <nl> + CONV_TYPE , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrComputeCapabilityMajor " , <nl> + ( " hipDeviceAttributeComputeCapabilityMajor " , CONV_TYPE , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrComputeCapabilityMinor " , <nl> + ( " hipDeviceAttributeComputeCapabilityMinor " , CONV_TYPE , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrMaxTexture1DMipmappedWidth " , <nl> + ( <nl> + " hipDeviceAttributeMaxTexture1DMipmappedWidth " , <nl> + CONV_TYPE , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrStreamPrioritiesSupported " , <nl> + ( <nl> + " hipDeviceAttributeStreamPrioritiesSupported " , <nl> + CONV_TYPE , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrGlobalL1CacheSupported " , <nl> + ( <nl> + " hipDeviceAttributeGlobalL1CacheSupported " , <nl> + CONV_TYPE , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrLocalL1CacheSupported " , <nl> + ( <nl> + " hipDeviceAttributeLocalL1CacheSupported " , <nl> + CONV_TYPE , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrMaxSharedMemoryPerMultiprocessor " , <nl> + ( <nl> + " hipDeviceAttributeMaxSharedMemoryPerMultiprocessor " , <nl> + CONV_TYPE , <nl> + API_RUNTIME , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrMaxRegistersPerMultiprocessor " , <nl> + ( <nl> + " hipDeviceAttributeMaxRegistersPerMultiprocessor " , <nl> + CONV_TYPE , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrManagedMemory " , <nl> + ( <nl> + " hipDeviceAttributeManagedMemory " , <nl> + CONV_TYPE , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrIsMultiGpuBoard " , <nl> + ( " hipDeviceAttributeIsMultiGpuBoard " , CONV_TYPE , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrMultiGpuBoardGroupID " , <nl> + ( <nl> + " hipDeviceAttributeMultiGpuBoardGroupID " , <nl> + CONV_TYPE , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrHostNativeAtomicSupported " , <nl> + ( <nl> + " hipDeviceAttributeHostNativeAtomicSupported " , <nl> + CONV_TYPE , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrSingleToDoublePrecisionPerfRatio " , <nl> + ( <nl> + " hipDeviceAttributeSingleToDoublePrecisionPerfRatio " , <nl> + CONV_TYPE , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrPageableMemoryAccess " , <nl> + ( <nl> + " hipDeviceAttributePageableMemoryAccess " , <nl> + CONV_TYPE , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrConcurrentManagedAccess " , <nl> + ( <nl> + " hipDeviceAttributeConcurrentManagedAccess " , <nl> + CONV_TYPE , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrComputePreemptionSupported " , <nl> + ( <nl> + " hipDeviceAttributeComputePreemptionSupported " , <nl> + CONV_TYPE , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaDevAttrCanUseHostPointerForRegisteredMem " , <nl> + ( <nl> + " hipDeviceAttributeCanUseHostPointerForRegisteredMem " , <nl> + CONV_TYPE , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaPointerGetAttributes " , <nl> + ( " hipPointerGetAttributes " , CONV_MEM , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " cudaHostGetDevicePointer " , <nl> + ( " hipHostGetDevicePointer " , CONV_MEM , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " cudaGetDeviceProperties " , <nl> + ( " hipGetDeviceProperties " , CONV_DEVICE , API_RUNTIME ) , <nl> + ) , <nl> + ( " cudaDeviceGetPCIBusId " , ( " hipDeviceGetPCIBusId " , CONV_DEVICE , API_RUNTIME ) ) , <nl> + ( <nl> + " cudaDeviceGetByPCIBusId " , <nl> + ( " hipDeviceGetByPCIBusId " , CONV_DEVICE , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " cudaDeviceGetStreamPriorityRange " , <nl> + ( <nl> + " hipDeviceGetStreamPriorityRange " , <nl> + CONV_DEVICE , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaSetValidDevices " , <nl> + ( " hipSetValidDevices " , CONV_DEVICE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaDevP2PAttrPerformanceRank " , <nl> + ( <nl> + " hipDeviceP2PAttributePerformanceRank " , <nl> + CONV_TYPE , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaDevP2PAttrAccessSupported " , <nl> + ( <nl> + " hipDeviceP2PAttributeAccessSupported " , <nl> + CONV_TYPE , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaDevP2PAttrNativeAtomicSupported " , <nl> + ( <nl> + " hipDeviceP2PAttributeNativeAtomicSupported " , <nl> + CONV_TYPE , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaDeviceGetP2PAttribute " , <nl> + ( " hipDeviceGetP2PAttribute " , CONV_DEVICE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaComputeModeDefault " , <nl> + ( " hipComputeModeDefault " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaComputeModeExclusive " , <nl> + ( " hipComputeModeExclusive " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaComputeModeProhibited " , <nl> + ( " hipComputeModeProhibited " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaComputeModeExclusiveProcess " , <nl> + ( " hipComputeModeExclusiveProcess " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaGetDeviceFlags " , <nl> + ( " hipGetDeviceFlags " , CONV_DEVICE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cudaSetDeviceFlags " , ( " hipSetDeviceFlags " , CONV_DEVICE , API_RUNTIME ) ) , <nl> + ( " cudaDeviceScheduleAuto " , ( " hipDeviceScheduleAuto " , CONV_TYPE , API_RUNTIME ) ) , <nl> + ( " cudaDeviceScheduleSpin " , ( " hipDeviceScheduleSpin " , CONV_TYPE , API_RUNTIME ) ) , <nl> + ( " cudaDeviceScheduleYield " , ( " hipDeviceScheduleYield " , CONV_TYPE , API_RUNTIME ) ) , <nl> + ( <nl> + " cudaDeviceBlockingSync " , <nl> + ( " hipDeviceScheduleBlockingSync " , CONV_TYPE , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " cudaDeviceScheduleBlockingSync " , <nl> + ( " hipDeviceScheduleBlockingSync " , CONV_TYPE , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " cudaDeviceScheduleMask " , <nl> + ( " hipDeviceScheduleMask " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cudaDeviceMapHost " , ( " hipDeviceMapHost " , CONV_TYPE , API_RUNTIME ) ) , <nl> + ( <nl> + " cudaDeviceLmemResizeToMax " , <nl> + ( " hipDeviceLmemResizeToMax " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cudaDeviceMask " , ( " hipDeviceMask " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> + ( <nl> + " cudaDeviceSetCacheConfig " , <nl> + ( " hipDeviceSetCacheConfig " , CONV_CACHE , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " cudaDeviceGetCacheConfig " , <nl> + ( " hipDeviceGetCacheConfig " , CONV_CACHE , API_RUNTIME ) , <nl> + ) , <nl> + ( " cudaFuncSetCacheConfig " , ( " hipFuncSetCacheConfig " , CONV_CACHE , API_RUNTIME ) ) , <nl> + ( <nl> + " cudaFuncCachePreferNone " , <nl> + ( " hipFuncCachePreferNone " , CONV_CACHE , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " cudaFuncCachePreferShared " , <nl> + ( " hipFuncCachePreferShared " , CONV_CACHE , API_RUNTIME ) , <nl> + ) , <nl> + ( " cudaFuncCachePreferL1 " , ( " hipFuncCachePreferL1 " , CONV_CACHE , API_RUNTIME ) ) , <nl> + ( <nl> + " cudaFuncCachePreferEqual " , <nl> + ( " hipFuncCachePreferEqual " , CONV_CACHE , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " cudaFuncGetAttributes " , <nl> + ( " hipFuncGetAttributes " , CONV_EXEC , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaFuncSetSharedMemConfig " , <nl> + ( " hipFuncSetSharedMemConfig " , CONV_EXEC , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaGetParameterBuffer " , <nl> + ( " hipGetParameterBuffer " , CONV_EXEC , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaSetDoubleForDevice " , <nl> + ( " hipSetDoubleForDevice " , CONV_EXEC , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaSetDoubleForHost " , <nl> + ( " hipSetDoubleForHost " , CONV_EXEC , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaConfigureCall " , <nl> + ( " hipConfigureCall " , CONV_EXEC , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cudaLaunch " , ( " hipLaunch " , CONV_EXEC , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> + ( <nl> + " cudaSetupArgument " , <nl> + ( " hipSetupArgument " , CONV_EXEC , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cudaDriverGetVersion " , ( " hipDriverGetVersion " , CONV_VERSION , API_RUNTIME ) ) , <nl> + ( <nl> + " cudaRuntimeGetVersion " , <nl> + ( " hipRuntimeGetVersion " , CONV_VERSION , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaOccupancyMaxPotentialBlockSize " , <nl> + ( " hipOccupancyMaxPotentialBlockSize " , CONV_OCCUPANCY , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " cudaOccupancyMaxPotentialBlockSizeWithFlags " , <nl> + ( <nl> + " hipOccupancyMaxPotentialBlockSizeWithFlags " , <nl> + CONV_OCCUPANCY , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaOccupancyMaxActiveBlocksPerMultiprocessor " , <nl> + ( <nl> + " hipOccupancyMaxActiveBlocksPerMultiprocessor " , <nl> + CONV_OCCUPANCY , <nl> + API_RUNTIME , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaOccupancyMaxActiveBlocksPerMultiprocessorWithFlags " , <nl> + ( <nl> + " hipOccupancyMaxActiveBlocksPerMultiprocessorWithFlags " , <nl> + CONV_OCCUPANCY , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaOccupancyMaxPotentialBlockSizeVariableSMem " , <nl> + ( <nl> + " hipOccupancyMaxPotentialBlockSizeVariableSMem " , <nl> + CONV_OCCUPANCY , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaOccupancyMaxPotentialBlockSizeVariableSMemWithFlags " , <nl> + ( <nl> + " hipOccupancyMaxPotentialBlockSizeVariableSMemWithFlags " , <nl> + CONV_OCCUPANCY , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( " cudaDeviceCanAccessPeer " , ( " hipDeviceCanAccessPeer " , CONV_PEER , API_RUNTIME ) ) , <nl> + ( <nl> + " cudaDeviceDisablePeerAccess " , <nl> + ( " hipDeviceDisablePeerAccess " , CONV_PEER , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " cudaDeviceEnablePeerAccess " , <nl> + ( " hipDeviceEnablePeerAccess " , CONV_PEER , API_RUNTIME ) , <nl> + ) , <nl> + ( " cudaMemcpyPeerAsync " , ( " hipMemcpyPeerAsync " , CONV_MEM , API_RUNTIME ) ) , <nl> + ( " cudaMemcpyPeer " , ( " hipMemcpyPeer " , CONV_MEM , API_RUNTIME ) ) , <nl> + ( <nl> + " cudaIpcMemLazyEnablePeerAccess " , <nl> + ( " hipIpcMemLazyEnablePeerAccess " , CONV_TYPE , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " cudaDeviceSetSharedMemConfig " , <nl> + ( " hipDeviceSetSharedMemConfig " , CONV_DEVICE , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " cudaDeviceGetSharedMemConfig " , <nl> + ( " hipDeviceGetSharedMemConfig " , CONV_DEVICE , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " cudaSharedMemBankSizeDefault " , <nl> + ( " hipSharedMemBankSizeDefault " , CONV_TYPE , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " cudaSharedMemBankSizeFourByte " , <nl> + ( " hipSharedMemBankSizeFourByte " , CONV_TYPE , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " cudaSharedMemBankSizeEightByte " , <nl> + ( " hipSharedMemBankSizeEightByte " , CONV_TYPE , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " cudaLimitStackSize " , <nl> + ( " hipLimitStackSize " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaLimitPrintfFifoSize " , <nl> + ( " hipLimitPrintfFifoSize " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cudaLimitMallocHeapSize " , ( " hipLimitMallocHeapSize " , CONV_TYPE , API_RUNTIME ) ) , <nl> + ( <nl> + " cudaLimitDevRuntimeSyncDepth " , <nl> + ( " hipLimitDevRuntimeSyncDepth " , CONV_TYPE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaLimitDevRuntimePendingLaunchCount " , <nl> + ( <nl> + " hipLimitDevRuntimePendingLaunchCount " , <nl> + CONV_TYPE , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( " cudaDeviceGetLimit " , ( " hipDeviceGetLimit " , CONV_DEVICE , API_RUNTIME ) ) , <nl> + ( <nl> + " cudaProfilerInitialize " , <nl> + ( " hipProfilerInitialize " , CONV_OTHER , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cudaProfilerStart " , ( " hipProfilerStart " , CONV_OTHER , API_RUNTIME ) ) , <nl> + ( " cudaProfilerStop " , ( " hipProfilerStop " , CONV_OTHER , API_RUNTIME ) ) , <nl> + ( <nl> + " cudaKeyValuePair " , <nl> + ( " hipKeyValuePair " , CONV_OTHER , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cudaCSV " , ( " hipCSV " , CONV_OTHER , API_RUNTIME , HIP_UNSUPPORTED ) ) , <nl> + ( " cudaReadModeElementType " , ( " hipReadModeElementType " , CONV_TEX , API_RUNTIME ) ) , <nl> + ( <nl> + " cudaReadModeNormalizedFloat " , <nl> + ( " hipReadModeNormalizedFloat " , CONV_TEX , API_RUNTIME ) , <nl> + ) , <nl> + ( " cudaFilterModePoint " , ( " hipFilterModePoint " , CONV_TEX , API_RUNTIME ) ) , <nl> + ( " cudaFilterModeLinear " , ( " hipFilterModeLinear " , CONV_TEX , API_RUNTIME ) ) , <nl> + ( " cudaBindTexture " , ( " hipBindTexture " , CONV_TEX , API_RUNTIME ) ) , <nl> + ( " cudaUnbindTexture " , ( " hipUnbindTexture " , CONV_TEX , API_RUNTIME ) ) , <nl> + ( " cudaBindTexture2D " , ( " hipBindTexture2D " , CONV_TEX , API_RUNTIME ) ) , <nl> + ( " cudaBindTextureToArray " , ( " hipBindTextureToArray " , CONV_TEX , API_RUNTIME ) ) , <nl> + ( <nl> + " cudaBindTextureToMipmappedArray " , <nl> + ( " hipBindTextureToMipmappedArray " , CONV_TEX , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " cudaGetTextureAlignmentOffset " , <nl> + ( " hipGetTextureAlignmentOffset " , CONV_TEX , API_RUNTIME ) , <nl> + ) , <nl> + ( " cudaGetTextureReference " , ( " hipGetTextureReference " , CONV_TEX , API_RUNTIME ) ) , <nl> + ( <nl> + " cudaChannelFormatKindSigned " , <nl> + ( " hipChannelFormatKindSigned " , CONV_TEX , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " cudaChannelFormatKindUnsigned " , <nl> + ( " hipChannelFormatKindUnsigned " , CONV_TEX , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " cudaChannelFormatKindFloat " , <nl> + ( " hipChannelFormatKindFloat " , CONV_TEX , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " cudaChannelFormatKindNone " , <nl> + ( " hipChannelFormatKindNone " , CONV_TEX , API_RUNTIME ) , <nl> + ) , <nl> + ( " cudaCreateChannelDesc " , ( " hipCreateChannelDesc " , CONV_TEX , API_RUNTIME ) ) , <nl> + ( " cudaGetChannelDesc " , ( " hipGetChannelDesc " , CONV_TEX , API_RUNTIME ) ) , <nl> + ( " cudaResourceTypeArray " , ( " hipResourceTypeArray " , CONV_TEX , API_RUNTIME ) ) , <nl> + ( <nl> + " cudaResourceTypeMipmappedArray " , <nl> + ( " hipResourceTypeMipmappedArray " , CONV_TEX , API_RUNTIME ) , <nl> + ) , <nl> + ( " cudaResourceTypeLinear " , ( " hipResourceTypeLinear " , CONV_TEX , API_RUNTIME ) ) , <nl> + ( " cudaResourceTypePitch2D " , ( " hipResourceTypePitch2D " , CONV_TEX , API_RUNTIME ) ) , <nl> + ( " cudaResViewFormatNone " , ( " hipResViewFormatNone " , CONV_TEX , API_RUNTIME ) ) , <nl> + ( <nl> + " cudaResViewFormatUnsignedChar1 " , <nl> + ( " hipResViewFormatUnsignedChar1 " , CONV_TEX , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " cudaResViewFormatUnsignedChar2 " , <nl> + ( " hipResViewFormatUnsignedChar2 " , CONV_TEX , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " cudaResViewFormatUnsignedChar4 " , <nl> + ( " hipResViewFormatUnsignedChar4 " , CONV_TEX , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " cudaResViewFormatSignedChar1 " , <nl> + ( " hipResViewFormatSignedChar1 " , CONV_TEX , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " cudaResViewFormatSignedChar2 " , <nl> + ( " hipResViewFormatSignedChar2 " , CONV_TEX , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " cudaResViewFormatSignedChar4 " , <nl> + ( " hipResViewFormatSignedChar4 " , CONV_TEX , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " cudaResViewFormatUnsignedShort1 " , <nl> + ( " hipResViewFormatUnsignedShort1 " , CONV_TEX , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " cudaResViewFormatUnsignedShort2 " , <nl> + ( " hipResViewFormatUnsignedShort2 " , CONV_TEX , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " cudaResViewFormatUnsignedShort4 " , <nl> + ( " hipResViewFormatUnsignedShort4 " , CONV_TEX , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " cudaResViewFormatSignedShort1 " , <nl> + ( " hipResViewFormatSignedShort1 " , CONV_TEX , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " cudaResViewFormatSignedShort2 " , <nl> + ( " hipResViewFormatSignedShort2 " , CONV_TEX , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " cudaResViewFormatSignedShort4 " , <nl> + ( " hipResViewFormatSignedShort4 " , CONV_TEX , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " cudaResViewFormatUnsignedInt1 " , <nl> + ( " hipResViewFormatUnsignedInt1 " , CONV_TEX , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " cudaResViewFormatUnsignedInt2 " , <nl> + ( " hipResViewFormatUnsignedInt2 " , CONV_TEX , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " cudaResViewFormatUnsignedInt4 " , <nl> + ( " hipResViewFormatUnsignedInt4 " , CONV_TEX , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " cudaResViewFormatSignedInt1 " , <nl> + ( " hipResViewFormatSignedInt1 " , CONV_TEX , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " cudaResViewFormatSignedInt2 " , <nl> + ( " hipResViewFormatSignedInt2 " , CONV_TEX , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " cudaResViewFormatSignedInt4 " , <nl> + ( " hipResViewFormatSignedInt4 " , CONV_TEX , API_RUNTIME ) , <nl> + ) , <nl> + ( " cudaResViewFormatHalf1 " , ( " hipResViewFormatHalf1 " , CONV_TEX , API_RUNTIME ) ) , <nl> + ( " cudaResViewFormatHalf2 " , ( " hipResViewFormatHalf2 " , CONV_TEX , API_RUNTIME ) ) , <nl> + ( " cudaResViewFormatHalf4 " , ( " hipResViewFormatHalf4 " , CONV_TEX , API_RUNTIME ) ) , <nl> + ( " cudaResViewFormatFloat1 " , ( " hipResViewFormatFloat1 " , CONV_TEX , API_RUNTIME ) ) , <nl> + ( " cudaResViewFormatFloat2 " , ( " hipResViewFormatFloat2 " , CONV_TEX , API_RUNTIME ) ) , <nl> + ( " cudaResViewFormatFloat4 " , ( " hipResViewFormatFloat4 " , CONV_TEX , API_RUNTIME ) ) , <nl> + ( <nl> + " cudaResViewFormatUnsignedBlockCompressed1 " , <nl> + ( " hipResViewFormatUnsignedBlockCompressed1 " , CONV_TEX , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " cudaResViewFormatUnsignedBlockCompressed2 " , <nl> + ( " hipResViewFormatUnsignedBlockCompressed2 " , CONV_TEX , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " cudaResViewFormatUnsignedBlockCompressed3 " , <nl> + ( " hipResViewFormatUnsignedBlockCompressed3 " , CONV_TEX , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " cudaResViewFormatUnsignedBlockCompressed4 " , <nl> + ( " hipResViewFormatUnsignedBlockCompressed4 " , CONV_TEX , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " cudaResViewFormatSignedBlockCompressed4 " , <nl> + ( " hipResViewFormatSignedBlockCompressed4 " , CONV_TEX , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " cudaResViewFormatUnsignedBlockCompressed5 " , <nl> + ( " hipResViewFormatUnsignedBlockCompressed5 " , CONV_TEX , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " cudaResViewFormatSignedBlockCompressed5 " , <nl> + ( " hipResViewFormatSignedBlockCompressed5 " , CONV_TEX , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " cudaResViewFormatUnsignedBlockCompressed6H " , <nl> + ( " hipResViewFormatUnsignedBlockCompressed6H " , CONV_TEX , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " cudaResViewFormatSignedBlockCompressed6H " , <nl> + ( " hipResViewFormatSignedBlockCompressed6H " , CONV_TEX , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " cudaResViewFormatUnsignedBlockCompressed7 " , <nl> + ( " hipResViewFormatUnsignedBlockCompressed7 " , CONV_TEX , API_RUNTIME ) , <nl> + ) , <nl> + ( " cudaAddressModeWrap " , ( " hipAddressModeWrap " , CONV_TEX , API_RUNTIME ) ) , <nl> + ( " cudaAddressModeClamp " , ( " hipAddressModeClamp " , CONV_TEX , API_RUNTIME ) ) , <nl> + ( " cudaAddressModeMirror " , ( " hipAddressModeMirror " , CONV_TEX , API_RUNTIME ) ) , <nl> + ( " cudaAddressModeBorder " , ( " hipAddressModeBorder " , CONV_TEX , API_RUNTIME ) ) , <nl> + ( " cudaCreateTextureObject " , ( " hipCreateTextureObject " , CONV_TEX , API_RUNTIME ) ) , <nl> + ( <nl> + " cudaDestroyTextureObject " , <nl> + ( " hipDestroyTextureObject " , CONV_TEX , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " cudaGetTextureObjectResourceDesc " , <nl> + ( " hipGetTextureObjectResourceDesc " , CONV_TEX , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " cudaGetTextureObjectResourceViewDesc " , <nl> + ( " hipGetTextureObjectResourceViewDesc " , CONV_TEX , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " cudaGetTextureObjectTextureDesc " , <nl> + ( " hipGetTextureObjectTextureDesc " , CONV_TEX , API_RUNTIME ) , <nl> + ) , <nl> + ( <nl> + " cudaBindSurfaceToArray " , <nl> + ( " hipBindSurfaceToArray " , CONV_SURFACE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaGetSurfaceReference " , <nl> + ( " hipGetSurfaceReference " , CONV_SURFACE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaBoundaryModeZero " , <nl> + ( " hipBoundaryModeZero " , CONV_SURFACE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaBoundaryModeClamp " , <nl> + ( " hipBoundaryModeClamp " , CONV_SURFACE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaBoundaryModeTrap " , <nl> + ( " hipBoundaryModeTrap " , CONV_SURFACE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaFormatModeForced " , <nl> + ( " hipFormatModeForced " , CONV_SURFACE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaFormatModeAuto " , <nl> + ( " hipFormatModeAuto " , CONV_SURFACE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaCreateSurfaceObject " , <nl> + ( " hipCreateSurfaceObject " , CONV_SURFACE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaDestroySurfaceObject " , <nl> + ( " hipDestroySurfaceObject " , CONV_SURFACE , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaGetSurfaceObjectResourceDesc " , <nl> + ( <nl> + " hipGetSurfaceObjectResourceDesc " , <nl> + CONV_SURFACE , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( " cudaIpcCloseMemHandle " , ( " hipIpcCloseMemHandle " , CONV_DEVICE , API_RUNTIME ) ) , <nl> + ( " cudaIpcGetEventHandle " , ( " hipIpcGetEventHandle " , CONV_DEVICE , API_RUNTIME ) ) , <nl> + ( " cudaIpcGetMemHandle " , ( " hipIpcGetMemHandle " , CONV_DEVICE , API_RUNTIME ) ) , <nl> + ( " cudaIpcOpenEventHandle " , ( " hipIpcOpenEventHandle " , CONV_DEVICE , API_RUNTIME ) ) , <nl> + ( " cudaIpcOpenMemHandle " , ( " hipIpcOpenMemHandle " , CONV_DEVICE , API_RUNTIME ) ) , <nl> + ( <nl> + " cudaGLGetDevices " , <nl> + ( " hipGLGetDevices " , CONV_GL , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaGraphicsGLRegisterBuffer " , <nl> + ( " hipGraphicsGLRegisterBuffer " , CONV_GL , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaGraphicsGLRegisterImage " , <nl> + ( " hipGraphicsGLRegisterImage " , CONV_GL , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaWGLGetDevice " , <nl> + ( " hipWGLGetDevice " , CONV_GL , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaGraphicsMapResources " , <nl> + ( " hipGraphicsMapResources " , CONV_GRAPHICS , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaGraphicsResourceGetMappedMipmappedArray " , <nl> + ( <nl> + " hipGraphicsResourceGetMappedMipmappedArray " , <nl> + CONV_GRAPHICS , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaGraphicsResourceGetMappedPointer " , <nl> + ( <nl> + " hipGraphicsResourceGetMappedPointer " , <nl> + CONV_GRAPHICS , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaGraphicsResourceSetMapFlags " , <nl> + ( <nl> + " hipGraphicsResourceSetMapFlags " , <nl> + CONV_GRAPHICS , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaGraphicsSubResourceGetMappedArray " , <nl> + ( <nl> + " hipGraphicsSubResourceGetMappedArray " , <nl> + CONV_GRAPHICS , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaGraphicsUnmapResources " , <nl> + ( " hipGraphicsUnmapResources " , CONV_GRAPHICS , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaGraphicsUnregisterResource " , <nl> + ( <nl> + " hipGraphicsUnregisterResource " , <nl> + CONV_GRAPHICS , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaGraphicsCubeFacePositiveX " , <nl> + ( <nl> + " hipGraphicsCubeFacePositiveX " , <nl> + CONV_GRAPHICS , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaGraphicsCubeFaceNegativeX " , <nl> + ( <nl> + " hipGraphicsCubeFaceNegativeX " , <nl> + CONV_GRAPHICS , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaGraphicsCubeFacePositiveY " , <nl> + ( <nl> + " hipGraphicsCubeFacePositiveY " , <nl> + CONV_GRAPHICS , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaGraphicsCubeFaceNegativeY " , <nl> + ( <nl> + " hipGraphicsCubeFaceNegativeY " , <nl> + CONV_GRAPHICS , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaGraphicsCubeFacePositiveZ " , <nl> + ( <nl> + " hipGraphicsCubeFacePositiveZ " , <nl> + CONV_GRAPHICS , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaGraphicsCubeFaceNegativeZ " , <nl> + ( <nl> + " hipGraphicsCubeFaceNegativeZ " , <nl> + CONV_GRAPHICS , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaGraphicsMapFlagsNone " , <nl> + ( " hipGraphicsMapFlagsNone " , CONV_GRAPHICS , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaGraphicsMapFlagsReadOnly " , <nl> + ( <nl> + " hipGraphicsMapFlagsReadOnly " , <nl> + CONV_GRAPHICS , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaGraphicsMapFlagsWriteDiscard " , <nl> + ( <nl> + " hipGraphicsMapFlagsWriteDiscard " , <nl> + CONV_GRAPHICS , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaGraphicsRegisterFlagsNone " , <nl> + ( <nl> + " hipGraphicsRegisterFlagsNone " , <nl> + CONV_GRAPHICS , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaGraphicsRegisterFlagsReadOnly " , <nl> + ( <nl> + " hipGraphicsRegisterFlagsReadOnly " , <nl> + CONV_GRAPHICS , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaGraphicsRegisterFlagsWriteDiscard " , <nl> + ( <nl> + " hipGraphicsRegisterFlagsWriteDiscard " , <nl> + CONV_GRAPHICS , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaGraphicsRegisterFlagsSurfaceLoadStore " , <nl> + ( <nl> + " hipGraphicsRegisterFlagsSurfaceLoadStore " , <nl> + CONV_GRAPHICS , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaGraphicsRegisterFlagsTextureGather " , <nl> + ( <nl> + " hipGraphicsRegisterFlagsTextureGather " , <nl> + CONV_GRAPHICS , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaGLDeviceListAll " , <nl> + ( " HIP_GL_DEVICE_LIST_ALL " , CONV_GL , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaGLDeviceListCurrentFrame " , <nl> + ( " HIP_GL_DEVICE_LIST_CURRENT_FRAME " , CONV_GL , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaGLDeviceListNextFrame " , <nl> + ( " HIP_GL_DEVICE_LIST_NEXT_FRAME " , CONV_GL , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaGLGetDevices " , <nl> + ( " hipGLGetDevices " , CONV_GL , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaGraphicsGLRegisterBuffer " , <nl> + ( " hipGraphicsGLRegisterBuffer " , CONV_GL , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaGraphicsGLRegisterImage " , <nl> + ( " hipGraphicsGLRegisterImage " , CONV_GL , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaWGLGetDevice " , <nl> + ( " hipWGLGetDevice " , CONV_GL , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaGLMapFlagsNone " , <nl> + ( " HIP_GL_MAP_RESOURCE_FLAGS_NONE " , CONV_GL , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaGLMapFlagsReadOnly " , <nl> + ( <nl> + " HIP_GL_MAP_RESOURCE_FLAGS_READ_ONLY " , <nl> + CONV_GL , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaGLMapFlagsWriteDiscard " , <nl> + ( <nl> + " HIP_GL_MAP_RESOURCE_FLAGS_WRITE_DISCARD " , <nl> + CONV_GL , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaGLMapBufferObject " , <nl> + ( " hipGLMapBufferObject__ " , CONV_GL , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaGLMapBufferObjectAsync " , <nl> + ( " hipGLMapBufferObjectAsync__ " , CONV_GL , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaGLRegisterBufferObject " , <nl> + ( " hipGLRegisterBufferObject " , CONV_GL , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaGLSetBufferObjectMapFlags " , <nl> + ( " hipGLSetBufferObjectMapFlags " , CONV_GL , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaGLSetGLDevice " , <nl> + ( " hipGLSetGLDevice " , CONV_GL , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaGLUnmapBufferObject " , <nl> + ( " hipGLUnmapBufferObject " , CONV_GL , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaGLUnmapBufferObjectAsync " , <nl> + ( " hipGLUnmapBufferObjectAsync " , CONV_GL , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaGLUnregisterBufferObject " , <nl> + ( " hipGLUnregisterBufferObject " , CONV_GL , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaD3D9DeviceListAll " , <nl> + ( " HIP_D3D9_DEVICE_LIST_ALL " , CONV_D3D9 , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaD3D9DeviceListCurrentFrame " , <nl> + ( <nl> + " HIP_D3D9_DEVICE_LIST_CURRENT_FRAME " , <nl> + CONV_D3D9 , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaD3D9DeviceListNextFrame " , <nl> + ( <nl> + " HIP_D3D9_DEVICE_LIST_NEXT_FRAME " , <nl> + CONV_D3D9 , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaD3D9GetDevice " , <nl> + ( " hipD3D9GetDevice " , CONV_D3D9 , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaD3D9GetDevices " , <nl> + ( " hipD3D9GetDevices " , CONV_D3D9 , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaD3D9GetDirect3DDevice " , <nl> + ( " hipD3D9GetDirect3DDevice " , CONV_D3D9 , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaD3D9SetDirect3DDevice " , <nl> + ( " hipD3D9SetDirect3DDevice " , CONV_D3D9 , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaGraphicsD3D9RegisterResource " , <nl> + ( <nl> + " hipGraphicsD3D9RegisterResource " , <nl> + CONV_D3D9 , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaD3D9MapFlags " , <nl> + ( " hipD3D9MapFlags " , CONV_D3D9 , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaD3D9MapFlagsNone " , <nl> + ( <nl> + " HIP_D3D9_MAPRESOURCE_FLAGS_NONE " , <nl> + CONV_D3D9 , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaD3D9MapFlagsReadOnly " , <nl> + ( <nl> + " HIP_D3D9_MAPRESOURCE_FLAGS_READONLY " , <nl> + CONV_D3D9 , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaD3D9MapFlagsWriteDiscard " , <nl> + ( <nl> + " HIP_D3D9_MAPRESOURCE_FLAGS_WRITEDISCARD " , <nl> + CONV_D3D9 , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaD3D9RegisterFlagsNone " , <nl> + ( " HIP_D3D9_REGISTER_FLAGS_NONE " , CONV_D3D9 , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaD3D9RegisterFlagsArray " , <nl> + ( " HIP_D3D9_REGISTER_FLAGS_ARRAY " , CONV_D3D9 , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaD3D9MapResources " , <nl> + ( " hipD3D9MapResources " , CONV_D3D9 , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaD3D9RegisterResource " , <nl> + ( " hipD3D9RegisterResource " , CONV_D3D9 , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaD3D9ResourceGetMappedArray " , <nl> + ( " hipD3D9ResourceGetMappedArray " , CONV_D3D9 , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaD3D9ResourceGetMappedPitch " , <nl> + ( " hipD3D9ResourceGetMappedPitch " , CONV_D3D9 , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaD3D9ResourceGetMappedPointer " , <nl> + ( <nl> + " hipD3D9ResourceGetMappedPointer " , <nl> + CONV_D3D9 , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaD3D9ResourceGetMappedSize " , <nl> + ( " hipD3D9ResourceGetMappedSize " , CONV_D3D9 , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaD3D9ResourceGetSurfaceDimensions " , <nl> + ( <nl> + " hipD3D9ResourceGetSurfaceDimensions " , <nl> + CONV_D3D9 , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaD3D9ResourceSetMapFlags " , <nl> + ( " hipD3D9ResourceSetMapFlags " , CONV_D3D9 , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaD3D9UnmapResources " , <nl> + ( " hipD3D9UnmapResources " , CONV_D3D9 , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaD3D9UnregisterResource " , <nl> + ( " hipD3D9UnregisterResource " , CONV_D3D9 , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaD3D10DeviceListAll " , <nl> + ( " HIP_D3D10_DEVICE_LIST_ALL " , CONV_D3D10 , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaD3D10DeviceListCurrentFrame " , <nl> + ( <nl> + " HIP_D3D10_DEVICE_LIST_CURRENT_FRAME " , <nl> + CONV_D3D10 , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaD3D10DeviceListNextFrame " , <nl> + ( <nl> + " HIP_D3D10_DEVICE_LIST_NEXT_FRAME " , <nl> + CONV_D3D10 , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaD3D10GetDevice " , <nl> + ( " hipD3D10GetDevice " , CONV_D3D10 , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaD3D10GetDevices " , <nl> + ( " hipD3D10GetDevices " , CONV_D3D10 , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaGraphicsD3D10RegisterResource " , <nl> + ( <nl> + " hipGraphicsD3D10RegisterResource " , <nl> + CONV_D3D10 , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaD3D10MapFlagsNone " , <nl> + ( <nl> + " HIP_D3D10_MAPRESOURCE_FLAGS_NONE " , <nl> + CONV_D3D10 , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaD3D10MapFlagsReadOnly " , <nl> + ( <nl> + " HIP_D3D10_MAPRESOURCE_FLAGS_READONLY " , <nl> + CONV_D3D10 , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaD3D10MapFlagsWriteDiscard " , <nl> + ( <nl> + " HIP_D3D10_MAPRESOURCE_FLAGS_WRITEDISCARD " , <nl> + CONV_D3D10 , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaD3D10RegisterFlagsNone " , <nl> + ( " HIP_D3D10_REGISTER_FLAGS_NONE " , CONV_D3D10 , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaD3D10RegisterFlagsArray " , <nl> + ( <nl> + " HIP_D3D10_REGISTER_FLAGS_ARRAY " , <nl> + CONV_D3D10 , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaD3D10GetDirect3DDevice " , <nl> + ( " hipD3D10GetDirect3DDevice " , CONV_D3D10 , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaD3D10MapResources " , <nl> + ( " hipD3D10MapResources " , CONV_D3D10 , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaD3D10RegisterResource " , <nl> + ( " hipD3D10RegisterResource " , CONV_D3D10 , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaD3D10ResourceGetMappedArray " , <nl> + ( <nl> + " hipD3D10ResourceGetMappedArray " , <nl> + CONV_D3D10 , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaD3D10ResourceGetMappedPitch " , <nl> + ( <nl> + " hipD3D10ResourceGetMappedPitch " , <nl> + CONV_D3D10 , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaD3D10ResourceGetMappedPointer " , <nl> + ( <nl> + " hipD3D10ResourceGetMappedPointer " , <nl> + CONV_D3D10 , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaD3D10ResourceGetMappedSize " , <nl> + ( " hipD3D10ResourceGetMappedSize " , CONV_D3D10 , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaD3D10ResourceGetSurfaceDimensions " , <nl> + ( <nl> + " hipD3D10ResourceGetSurfaceDimensions " , <nl> + CONV_D3D10 , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaD3D10ResourceSetMapFlags " , <nl> + ( " hipD3D10ResourceSetMapFlags " , CONV_D3D10 , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaD3D10SetDirect3DDevice " , <nl> + ( " hipD3D10SetDirect3DDevice " , CONV_D3D10 , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaD3D10UnmapResources " , <nl> + ( " hipD3D10UnmapResources " , CONV_D3D10 , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaD3D10UnregisterResource " , <nl> + ( " hipD3D10UnregisterResource " , CONV_D3D10 , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaD3D11DeviceListAll " , <nl> + ( " HIP_D3D11_DEVICE_LIST_ALL " , CONV_D3D11 , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaD3D11DeviceListCurrentFrame " , <nl> + ( <nl> + " HIP_D3D11_DEVICE_LIST_CURRENT_FRAME " , <nl> + CONV_D3D11 , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaD3D11DeviceListNextFrame " , <nl> + ( <nl> + " HIP_D3D11_DEVICE_LIST_NEXT_FRAME " , <nl> + CONV_D3D11 , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaD3D11GetDevice " , <nl> + ( " hipD3D11GetDevice " , CONV_D3D11 , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaD3D11GetDevices " , <nl> + ( " hipD3D11GetDevices " , CONV_D3D11 , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaGraphicsD3D11RegisterResource " , <nl> + ( <nl> + " hipGraphicsD3D11RegisterResource " , <nl> + CONV_D3D11 , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaD3D11GetDevice " , <nl> + ( " hipD3D11GetDevice " , CONV_D3D11 , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaD3D11GetDevices " , <nl> + ( " hipD3D11GetDevices " , CONV_D3D11 , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaGraphicsD3D11RegisterResource " , <nl> + ( <nl> + " hipGraphicsD3D11RegisterResource " , <nl> + CONV_D3D11 , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaGraphicsVDPAURegisterOutputSurface " , <nl> + ( <nl> + " hipGraphicsVDPAURegisterOutputSurface " , <nl> + CONV_VDPAU , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaGraphicsVDPAURegisterVideoSurface " , <nl> + ( <nl> + " hipGraphicsVDPAURegisterVideoSurface " , <nl> + CONV_VDPAU , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaVDPAUGetDevice " , <nl> + ( " hipVDPAUGetDevice " , CONV_VDPAU , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaVDPAUSetVDPAUDevice " , <nl> + ( " hipVDPAUSetDevice " , CONV_VDPAU , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaEGLStreamConsumerAcquireFrame " , <nl> + ( <nl> + " hipEGLStreamConsumerAcquireFrame " , <nl> + CONV_EGL , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaEGLStreamConsumerConnect " , <nl> + ( " hipEGLStreamConsumerConnect " , CONV_EGL , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaEGLStreamConsumerConnectWithFlags " , <nl> + ( <nl> + " hipEGLStreamConsumerConnectWithFlags " , <nl> + CONV_EGL , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaEGLStreamConsumerReleaseFrame " , <nl> + ( <nl> + " hipEGLStreamConsumerReleaseFrame " , <nl> + CONV_EGL , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaEGLStreamProducerConnect " , <nl> + ( " hipEGLStreamProducerConnect " , CONV_EGL , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaEGLStreamProducerDisconnect " , <nl> + ( " hipEGLStreamProducerDisconnect " , CONV_EGL , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaEGLStreamProducerPresentFrame " , <nl> + ( <nl> + " hipEGLStreamProducerPresentFrame " , <nl> + CONV_EGL , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cudaEGLStreamProducerReturnFrame " , <nl> + ( " hipEGLStreamProducerReturnFrame " , CONV_EGL , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaGraphicsEGLRegisterImage " , <nl> + ( " hipGraphicsEGLRegisterImage " , CONV_EGL , API_RUNTIME , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cudaGraphicsResourceGetMappedEglFrame " , <nl> + ( <nl> + " hipGraphicsResourceGetMappedEglFrame " , <nl> + CONV_EGL , <nl> + API_RUNTIME , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( " cublasInit " , ( " rocblas_init " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( <nl> + " cublasShutdown " , <nl> + ( " rocblas_shutdown " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasGetVersion " , <nl> + ( " rocblas_get_version " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasGetError " , <nl> + ( " rocblas_get_error " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cublasAlloc " , ( " rocblas_alloc " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasFree " , ( " rocblas_free " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( <nl> + " cublasSetKernelStream " , <nl> + ( " rocblas_set_kernel_stream " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasGetAtomicsMode " , <nl> + ( " rocblas_get_atomics_mode " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasSetAtomicsMode " , <nl> + ( " rocblas_set_atomics_mode " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasGetMathMode " , <nl> + ( " rocblas_get_math_mode " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasSetMathMode " , <nl> + ( " rocblas_set_math_mode " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " CUBLAS_OP_N " , ( " rocblas_operation_none " , CONV_NUMERIC_LITERAL , API_BLAS ) ) , <nl> + ( <nl> + " CUBLAS_OP_T " , <nl> + ( " rocblas_operation_transpose " , CONV_NUMERIC_LITERAL , API_BLAS ) , <nl> + ) , <nl> + ( <nl> + " CUBLAS_OP_C " , <nl> + ( " rocblas_operation_conjugate_transpose " , CONV_NUMERIC_LITERAL , API_BLAS ) , <nl> + ) , <nl> + ( <nl> + " CUBLAS_STATUS_SUCCESS " , <nl> + ( " rocblas_status_success " , CONV_NUMERIC_LITERAL , API_BLAS ) , <nl> + ) , <nl> + ( <nl> + " CUBLAS_STATUS_NOT_INITIALIZED " , <nl> + ( " rocblas_status_invalid_handle " , CONV_NUMERIC_LITERAL , API_BLAS ) , <nl> + ) , <nl> + ( <nl> + " CUBLAS_STATUS_ALLOC_FAILED " , <nl> + ( " rocblas_status_memory_error " , CONV_NUMERIC_LITERAL , API_BLAS ) , <nl> + ) , <nl> + ( <nl> + " CUBLAS_STATUS_INVALID_VALUE " , <nl> + ( " rocblas_status_invalid_pointer " , CONV_NUMERIC_LITERAL , API_BLAS ) , <nl> + ) , <nl> + ( <nl> + " CUBLAS_STATUS_MAPPING_ERROR " , <nl> + ( " rocblas_status_internal_error " , CONV_NUMERIC_LITERAL , API_BLAS ) , <nl> + ) , <nl> + ( <nl> + " CUBLAS_STATUS_EXECUTION_FAILED " , <nl> + ( " rocblas_status_internal_error " , CONV_NUMERIC_LITERAL , API_BLAS ) , <nl> + ) , <nl> + ( <nl> + " CUBLAS_STATUS_INTERNAL_ERROR " , <nl> + ( " rocblas_status_internal_error " , CONV_NUMERIC_LITERAL , API_BLAS ) , <nl> + ) , <nl> + ( <nl> + " CUBLAS_STATUS_NOT_SUPPORTED " , <nl> + ( " rocblas_status_not_implemented " , CONV_NUMERIC_LITERAL , API_BLAS ) , <nl> + ) , <nl> + ( <nl> + " CUBLAS_STATUS_ARCH_MISMATCH " , <nl> + ( " rocblas_status_not_implemented " , CONV_NUMERIC_LITERAL , API_BLAS ) , <nl> + ) , <nl> + ( <nl> + " CUBLAS_FILL_MODE_LOWER " , <nl> + ( " rocblas_fill_lower " , CONV_NUMERIC_LITERAL , API_BLAS ) , <nl> + ) , <nl> + ( <nl> + " CUBLAS_FILL_MODE_UPPER " , <nl> + ( " rocblas_fill_upper " , CONV_NUMERIC_LITERAL , API_BLAS ) , <nl> + ) , <nl> + ( <nl> + " CUBLAS_DIAG_NON_UNIT " , <nl> + ( " rocblas_diagonal_non_unit " , CONV_NUMERIC_LITERAL , API_BLAS ) , <nl> + ) , <nl> + ( " CUBLAS_DIAG_UNIT " , ( " rocblas_diagonal_unit " , CONV_NUMERIC_LITERAL , API_BLAS ) ) , <nl> + ( " CUBLAS_SIDE_LEFT " , ( " rocblas_side_left " , CONV_NUMERIC_LITERAL , API_BLAS ) ) , <nl> + ( " CUBLAS_SIDE_RIGHT " , ( " rocblas_side_right " , CONV_NUMERIC_LITERAL , API_BLAS ) ) , <nl> + ( <nl> + " CUBLAS_POINTER_MODE_HOST " , <nl> + ( " rocblas_pointer_mode_host " , CONV_NUMERIC_LITERAL , API_BLAS ) , <nl> + ) , <nl> + ( <nl> + " CUBLAS_POINTER_MODE_DEVICE " , <nl> + ( " rocblas_pointer_mode_device " , CONV_NUMERIC_LITERAL , API_BLAS ) , <nl> + ) , <nl> + ( <nl> + " CUBLAS_ATOMICS_NOT_ALLOWED " , <nl> + ( <nl> + " rocblas_atomics_not_allowed " , <nl> + CONV_NUMERIC_LITERAL , <nl> + API_BLAS , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CUBLAS_ATOMICS_ALLOWED " , <nl> + ( <nl> + " rocblas_atomics_allowed " , <nl> + CONV_NUMERIC_LITERAL , <nl> + API_BLAS , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CUBLAS_DATA_FLOAT " , <nl> + ( <nl> + " rocblas_precision_float " , <nl> + CONV_NUMERIC_LITERAL , <nl> + API_BLAS , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CUBLAS_DATA_DOUBLE " , <nl> + ( <nl> + " rocblas_precision_double " , <nl> + CONV_NUMERIC_LITERAL , <nl> + API_BLAS , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CUBLAS_DATA_HALF " , <nl> + ( " rocblas_precision_half " , CONV_NUMERIC_LITERAL , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CUBLAS_DATA_INT8 " , <nl> + ( " rocblas_precision_int8 " , CONV_NUMERIC_LITERAL , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cublasCreate " , ( " rocblas_create_handle " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> + ( " cublasDestroy " , ( " rocblas_destroy_handle " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> + ( " cublasSetVector " , ( " rocblas_set_vector " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> + ( " cublasGetVector " , ( " rocblas_get_vector " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> + ( <nl> + " cublasSetVectorAsync " , <nl> + ( " rocblas_set_vector_async " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasGetVectorAsync " , <nl> + ( " rocblas_get_vector_async " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cublasSetMatrix " , ( " rocblas_set_matrix " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> + ( " cublasGetMatrix " , ( " rocblas_get_matrix " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> + ( <nl> + " cublasGetMatrixAsync " , <nl> + ( " rocblas_get_matrix_async " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasSetMatrixAsync " , <nl> + ( " rocblas_set_matrix_async " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cublasXerbla " , ( " rocblas_xerbla " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasSnrm2 " , ( " rocblas_snrm2 " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> + ( " cublasDnrm2 " , ( " rocblas_dnrm2 " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> + ( " cublasScnrm2 " , ( " rocblas_scnrm2 " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasDznrm2 " , ( " rocblas_dznrm2 " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( <nl> + " cublasNrm2Ex " , <nl> + ( " rocblas_nrm2_ex " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cublasSdot " , ( " rocblas_sdot " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> + ( <nl> + " cublasSdotBatched " , <nl> + ( " rocblas_sdot_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cublasDdot " , ( " rocblas_ddot " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> + ( <nl> + " cublasDdotBatched " , <nl> + ( " rocblas_ddot_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cublasCdotu " , ( " rocblas_cdotu " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasCdotc " , ( " rocblas_cdotc " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasZdotu " , ( " rocblas_zdotu " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasZdotc " , ( " rocblas_zdotc " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasSscal " , ( " rocblas_sscal " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> + ( <nl> + " cublasSscalBatched " , <nl> + ( " rocblas_sscal_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cublasDscal " , ( " rocblas_dscal " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> + ( <nl> + " cublasDscalBatched " , <nl> + ( " rocblas_dscal_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cublasCscal " , ( " rocblas_cscal " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasCsscal " , ( " rocblas_csscal " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasZscal " , ( " rocblas_zscal " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasZdscal " , ( " rocblas_zdscal " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasSaxpy " , ( " rocblas_saxpy " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> + ( <nl> + " cublasSaxpyBatched " , <nl> + ( " rocblas_saxpy_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cublasDaxpy " , ( " rocblas_daxpy " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> + ( " cublasCaxpy " , ( " rocblas_caxpy " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasZaxpy " , ( " rocblas_zaxpy " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasScopy " , ( " rocblas_scopy " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> + ( <nl> + " cublasScopyBatched " , <nl> + ( " rocblas_scopy_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cublasDcopy " , ( " rocblas_dcopy " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> + ( <nl> + " cublasDcopyBatched " , <nl> + ( " rocblas_dcopy_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cublasCcopy " , ( " rocblas_ccopy " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasZcopy " , ( " rocblas_zcopy " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasSswap " , ( " rocblas_sswap " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> + ( " cublasDswap " , ( " rocblas_dswap " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> + ( " cublasCswap " , ( " rocblas_cswap " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasZswap " , ( " rocblas_zswap " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasIsamax " , ( " rocblas_isamax " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> + ( " cublasIdamax " , ( " rocblas_idamax " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> + ( " cublasIcamax " , ( " rocblas_icamax " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasIzamax " , ( " rocblas_izamax " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasIsamin " , ( " rocblas_isamin " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> + ( " cublasIdamin " , ( " rocblas_idamin " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> + ( " cublasIcamin " , ( " rocblas_icamin " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasIzamin " , ( " rocblas_izamin " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasSasum " , ( " rocblas_sasum " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> + ( <nl> + " cublasSasumBatched " , <nl> + ( " rocblas_sasum_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cublasDasum " , ( " rocblas_dasum " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> + ( <nl> + " cublasDasumBatched " , <nl> + ( " rocblas_dasum_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cublasScasum " , ( " rocblas_scasum " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasDzasum " , ( " rocblas_dzasum " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasSrot " , ( " rocblas_srot " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasDrot " , ( " rocblas_drot " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasCrot " , ( " rocblas_crot " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasCsrot " , ( " rocblas_csrot " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasZrot " , ( " rocblas_zrot " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasZdrot " , ( " rocblas_zdrot " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasSrotg " , ( " rocblas_srotg " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasDrotg " , ( " rocblas_drotg " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasCrotg " , ( " rocblas_crotg " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasZrotg " , ( " rocblas_zrotg " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasSrotm " , ( " rocblas_srotm " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasDrotm " , ( " rocblas_drotm " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasSrotmg " , ( " rocblas_srotmg " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasDrotmg " , ( " rocblas_drotmg " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasSgemv " , ( " rocblas_sgemv " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> + ( <nl> + " cublasSgemvBatched " , <nl> + ( " rocblas_sgemv_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cublasDgemv " , ( " rocblas_dgemv " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> + ( " cublasCgemv " , ( " rocblas_cgemv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasZgemv " , ( " rocblas_zgemv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasSgbmv " , ( " rocblas_sgbmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasDgbmv " , ( " rocblas_dgbmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasCgbmv " , ( " rocblas_cgbmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasZgbmv " , ( " rocblas_zgbmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasStrmv " , ( " rocblas_strmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasDtrmv " , ( " rocblas_dtrmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasCtrmv " , ( " rocblas_ctrmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasZtrmv " , ( " rocblas_ztrmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasStbmv " , ( " rocblas_stbmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasDtbmv " , ( " rocblas_dtbmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasCtbmv " , ( " rocblas_ctbmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasZtbmv " , ( " rocblas_ztbmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasStpmv " , ( " rocblas_stpmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasDtpmv " , ( " rocblas_dtpmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasCtpmv " , ( " rocblas_ctpmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasZtpmv " , ( " rocblas_ztpmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasStrsv " , ( " rocblas_strsv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasDtrsv " , ( " rocblas_dtrsv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasCtrsv " , ( " rocblas_ctrsv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasZtrsv " , ( " rocblas_ztrsv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasStpsv " , ( " rocblas_stpsv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasDtpsv " , ( " rocblas_dtpsv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasCtpsv " , ( " rocblas_ctpsv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasZtpsv " , ( " rocblas_ztpsv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasStbsv " , ( " rocblas_stbsv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasDtbsv " , ( " rocblas_dtbsv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasCtbsv " , ( " rocblas_ctbsv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasZtbsv " , ( " rocblas_ztbsv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasSsymv " , ( " rocblas_ssymv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasDsymv " , ( " rocblas_dsymv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasCsymv " , ( " rocblas_csymv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasZsymv " , ( " rocblas_zsymv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasChemv " , ( " rocblas_chemv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasZhemv " , ( " rocblas_zhemv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasSsbmv " , ( " rocblas_ssbmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasDsbmv " , ( " rocblas_dsbmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasChbmv " , ( " rocblas_chbmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasZhbmv " , ( " rocblas_zhbmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasSspmv " , ( " rocblas_sspmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasDspmv " , ( " rocblas_dspmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasChpmv " , ( " rocblas_chpmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasZhpmv " , ( " rocblas_zhpmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasSger " , ( " rocblas_sger " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> + ( " cublasDger " , ( " rocblas_dger " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> + ( " cublasCgeru " , ( " rocblas_cgeru " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasCgerc " , ( " rocblas_cgerc " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasZgeru " , ( " rocblas_zgeru " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasZgerc " , ( " rocblas_zgerc " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasSsyr " , ( " rocblas_ssyr " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> + ( " cublasDsyr " , ( " rocblas_dsyr " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> + ( " cublasCher " , ( " rocblas_cher " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasZher " , ( " rocblas_zher " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasSspr " , ( " rocblas_sspr " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasDspr " , ( " rocblas_dspr " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasChpr " , ( " rocblas_chpr " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasZhpr " , ( " rocblas_zhpr " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasSsyr2 " , ( " rocblas_ssyr2 " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasDsyr2 " , ( " rocblas_dsyr2 " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasCher2 " , ( " rocblas_cher2 " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasZher2 " , ( " rocblas_zher2 " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasSspr2 " , ( " rocblas_sspr2 " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasDspr2 " , ( " rocblas_dspr2 " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasChpr2 " , ( " rocblas_chpr2 " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasZhpr2 " , ( " rocblas_zhpr2 " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( <nl> + " cublasSgemmBatched " , <nl> + ( " rocblas_sgemm_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasDgemmBatched " , <nl> + ( " rocblas_dgemm_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasHgemmBatched " , <nl> + ( " rocblas_hgemm_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasSgemmStridedBatched " , <nl> + ( " rocblas_sgemm_strided_batched " , CONV_MATH_FUNC , API_BLAS ) , <nl> + ) , <nl> + ( <nl> + " cublasDgemmStridedBatched " , <nl> + ( " rocblas_dgemm_strided_batched " , CONV_MATH_FUNC , API_BLAS ) , <nl> + ) , <nl> + ( <nl> + " cublasHgemmStridedBatched " , <nl> + ( " rocblas_hgemm_strided_batched " , CONV_MATH_FUNC , API_BLAS ) , <nl> + ) , <nl> + ( <nl> + " cublasCgemmBatched " , <nl> + ( " rocblas_cgemm_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasCgemm3mBatched " , <nl> + ( " rocblas_cgemm_3m_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasZgemmBatched " , <nl> + ( " rocblas_zgemm_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasCgemmStridedBatched " , <nl> + ( <nl> + " rocblas_cgemm_strided_batched " , <nl> + CONV_MATH_FUNC , <nl> + API_BLAS , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cublasCgemm3mStridedBatched " , <nl> + ( <nl> + " rocblas_cgemm_3m_strided_batched " , <nl> + CONV_MATH_FUNC , <nl> + API_BLAS , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cublasZgemmStridedBatched " , <nl> + ( <nl> + " rocblas_zgemm_strided_batched " , <nl> + CONV_MATH_FUNC , <nl> + API_BLAS , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " cublasHgemmStridedBatched " , <nl> + ( <nl> + " rocblas_hgemm_strided_batched " , <nl> + CONV_MATH_FUNC , <nl> + API_BLAS , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( " cublasSgemm " , ( " rocblas_sgemm " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> + ( " cublasDgemm " , ( " rocblas_dgemm " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> + ( " cublasCgemm " , ( " rocblas_cgemm " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> + ( " cublasZgemm " , ( " rocblas_zgemm " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasHgemm " , ( " rocblas_hgemm " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> + ( " cublasSsyrk " , ( " rocblas_ssyrk " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasDsyrk " , ( " rocblas_dsyrk " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasCsyrk " , ( " rocblas_csyrk " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasZsyrk " , ( " rocblas_zsyrk " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasCherk " , ( " rocblas_cherk " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasZherk " , ( " rocblas_zherk " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasSsyr2k " , ( " rocblas_ssyr2k " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasDsyr2k " , ( " rocblas_dsyr2k " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasCsyr2k " , ( " rocblas_csyr2k " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasZsyr2k " , ( " rocblas_zyr2k " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasSsyrkx " , ( " rocblas_ssyrkx " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasDsyrkx " , ( " rocblas_dsyrkx " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasCsyrkx " , ( " rocblas_csyrkx " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasZsyrkx " , ( " rocblas_zsyrkx " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasCher2k " , ( " rocblas_cher2k " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasZher2k " , ( " rocblas_zher2k " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasCherkx " , ( " rocblas_cherkx " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasZherkx " , ( " rocblas_zherkx " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasSsymm " , ( " rocblas_ssymm " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasDsymm " , ( " rocblas_dsymm " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasCsymm " , ( " rocblas_csymm " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasZsymm " , ( " rocblas_zsymm " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasChemm " , ( " rocblas_chemm " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasZhemm " , ( " rocblas_zhemm " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasStrsm " , ( " rocblas_strsm " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> + ( " cublasDtrsm " , ( " rocblas_dtrsm " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> + ( " cublasCtrsm " , ( " rocblas_ctrsm " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasZtrsm " , ( " rocblas_ztrsm " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( <nl> + " cublasStrsmBatched " , <nl> + ( " rocblas_strsm_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasDtrsmBatched " , <nl> + ( " rocblas_dtrsm_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasCtrsmBatched " , <nl> + ( " rocblas_ctrsm_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasZtrsmBatched " , <nl> + ( " rocblas_ztrsm_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cublasStrmm " , ( " rocblas_strmm " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasDtrmm " , ( " rocblas_dtrmm " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasCtrmm " , ( " rocblas_ctrmm " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasZtrmm " , ( " rocblas_ztrmm " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasSgeam " , ( " rocblas_sgeam " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> + ( " cublasDgeam " , ( " rocblas_dgeam " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> + ( " cublasCgeam " , ( " rocblas_cgeam " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasZgeam " , ( " rocblas_zgeam " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( <nl> + " cublasSgetrfBatched " , <nl> + ( " rocblas_sgetrf_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasDgetrfBatched " , <nl> + ( " rocblas_dgetrf_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasCgetrfBatched " , <nl> + ( " rocblas_cgetrf_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasZgetrfBatched " , <nl> + ( " rocblas_zgetrf_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasSgetriBatched " , <nl> + ( " rocblas_sgetri_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasDgetriBatched " , <nl> + ( " rocblas_dgetri_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasCgetriBatched " , <nl> + ( " rocblas_cgetri_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasZgetriBatched " , <nl> + ( " rocblas_zgetri_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasSgetrsBatched " , <nl> + ( " rocblas_sgetrs_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasDgetrsBatched " , <nl> + ( " rocblas_dgetrs_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasCgetrsBatched " , <nl> + ( " rocblas_cgetrs_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasZgetrsBatched " , <nl> + ( " rocblas_zgetrs_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasStrsmBatched " , <nl> + ( " rocblas_strsm_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasDtrsmBatched " , <nl> + ( " rocblas_dtrsm_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasCtrsmBatched " , <nl> + ( " rocblas_ctrsm_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasZtrsmBatched " , <nl> + ( " rocblas_dtrsm_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasSmatinvBatched " , <nl> + ( " rocblas_smatinv_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasDmatinvBatched " , <nl> + ( " rocblas_dmatinv_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasCmatinvBatched " , <nl> + ( " rocblas_cmatinv_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasZmatinvBatched " , <nl> + ( " rocblas_zmatinv_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasSgeqrfBatched " , <nl> + ( " rocblas_sgeqrf_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasDgeqrfBatched " , <nl> + ( " rocblas_dgeqrf_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasCgeqrfBatched " , <nl> + ( " rocblas_cgeqrf_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasZgeqrfBatched " , <nl> + ( " rocblas_zgeqrf_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasSgelsBatched " , <nl> + ( " rocblas_sgels_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasDgelsBatched " , <nl> + ( " rocblas_dgels_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasCgelsBatched " , <nl> + ( " rocblas_cgels_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasZgelsBatched " , <nl> + ( " rocblas_zgels_batched " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cublasSdgmm " , ( " rocblas_sdgmm " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasDdgmm " , ( " rocblas_ddgmm " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasCdgmm " , ( " rocblas_cdgmm " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasZdgmm " , ( " rocblas_zdgmm " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasStpttr " , ( " rocblas_stpttr " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasDtpttr " , ( " rocblas_dtpttr " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasCtpttr " , ( " rocblas_ctpttr " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasZtpttr " , ( " rocblas_ztpttr " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasStrttp " , ( " rocblas_strttp " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasDtrttp " , ( " rocblas_dtrttp " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasCtrttp " , ( " rocblas_ctrttp " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasZtrttp " , ( " rocblas_ztrttp " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasCreate_v2 " , ( " rocblas_create_handle " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> + ( " cublasDestroy_v2 " , ( " rocblas_destroy_handle " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> + ( <nl> + " cublasGetVersion_v2 " , <nl> + ( " rocblas_get_version " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cublasSetStream " , ( " rocblas_set_stream " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> + ( " cublasGetStream " , ( " rocblas_get_stream " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> + ( " cublasSetStream_v2 " , ( " rocblas_set_stream " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> + ( " cublasGetStream_v2 " , ( " rocblas_get_stream " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> + ( <nl> + " cublasGetPointerMode " , <nl> + ( " rocblas_get_pointer_mode " , CONV_MATH_FUNC , API_BLAS ) , <nl> + ) , <nl> + ( <nl> + " cublasSetPointerMode " , <nl> + ( " rocblas_set_pointer_mode " , CONV_MATH_FUNC , API_BLAS ) , <nl> + ) , <nl> + ( <nl> + " cublasGetPointerMode_v2 " , <nl> + ( " rocblas_get_pointer_mode " , CONV_MATH_FUNC , API_BLAS ) , <nl> + ) , <nl> + ( <nl> + " cublasSetPointerMode_v2 " , <nl> + ( " rocblas_set_pointer_mode " , CONV_MATH_FUNC , API_BLAS ) , <nl> + ) , <nl> + ( " cublasSgemv_v2 " , ( " rocblas_sgemv " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> + ( " cublasDgemv_v2 " , ( " rocblas_dgemv " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> + ( <nl> + " cublasCgemv_v2 " , <nl> + ( " rocblas_cgemv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasZgemv_v2 " , <nl> + ( " rocblas_zgemv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasSgbmv_v2 " , <nl> + ( " rocblas_sgbmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasDgbmv_v2 " , <nl> + ( " rocblas_dgbmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasCgbmv_v2 " , <nl> + ( " rocblas_cgbmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasZgbmv_v2 " , <nl> + ( " rocblas_zgbmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasStrmv_v2 " , <nl> + ( " rocblas_strmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasDtrmv_v2 " , <nl> + ( " rocblas_dtrmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasCtrmv_v2 " , <nl> + ( " rocblas_ctrmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasZtrmv_v2 " , <nl> + ( " rocblas_ztrmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasStbmv_v2 " , <nl> + ( " rocblas_stbmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasDtbmv_v2 " , <nl> + ( " rocblas_dtbmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasCtbmv_v2 " , <nl> + ( " rocblas_ctbmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasZtbmv_v2 " , <nl> + ( " rocblas_ztbmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasStpmv_v2 " , <nl> + ( " rocblas_stpmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasDtpmv_v2 " , <nl> + ( " rocblas_dtpmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasCtpmv_v2 " , <nl> + ( " rocblas_ctpmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasZtpmv_v2 " , <nl> + ( " rocblas_ztpmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasStrsv_v2 " , <nl> + ( " rocblas_strsv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasDtrsv_v2 " , <nl> + ( " rocblas_dtrsv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasCtrsv_v2 " , <nl> + ( " rocblas_ctrsv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasZtrsv_v2 " , <nl> + ( " rocblas_ztrsv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasStpsv_v2 " , <nl> + ( " rocblas_stpsv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasDtpsv_v2 " , <nl> + ( " rocblas_dtpsv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasCtpsv_v2 " , <nl> + ( " rocblas_ctpsv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasZtpsv_v2 " , <nl> + ( " rocblas_ztpsv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasStbsv_v2 " , <nl> + ( " rocblas_stbsv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasDtbsv_v2 " , <nl> + ( " rocblas_dtbsv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasCtbsv_v2 " , <nl> + ( " rocblas_ctbsv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasZtbsv_v2 " , <nl> + ( " rocblas_ztbsv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasSsymv_v2 " , <nl> + ( " rocblas_ssymv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasDsymv_v2 " , <nl> + ( " rocblas_dsymv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasCsymv_v2 " , <nl> + ( " rocblas_csymv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasZsymv_v2 " , <nl> + ( " rocblas_zsymv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasChemv_v2 " , <nl> + ( " rocblas_chemv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasZhemv_v2 " , <nl> + ( " rocblas_zhemv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasSsbmv_v2 " , <nl> + ( " rocblas_ssbmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasDsbmv_v2 " , <nl> + ( " rocblas_dsbmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasChbmv_v2 " , <nl> + ( " rocblas_chbmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasZhbmv_v2 " , <nl> + ( " rocblas_zhbmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasSspmv_v2 " , <nl> + ( " rocblas_sspmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasDspmv_v2 " , <nl> + ( " rocblas_dspmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasChpmv_v2 " , <nl> + ( " rocblas_chpmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasZhpmv_v2 " , <nl> + ( " rocblas_zhpmv " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cublasSger_v2 " , ( " rocblas_sger " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> + ( " cublasDger_v2 " , ( " rocblas_dger " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> + ( <nl> + " cublasCgeru_v2 " , <nl> + ( " rocblas_cgeru " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasCgerc_v2 " , <nl> + ( " rocblas_cergc " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasZgeru_v2 " , <nl> + ( " rocblas_zgeru " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasZgerc_v2 " , <nl> + ( " rocblas_zgerc " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cublasSsyr_v2 " , ( " rocblas_ssyr " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasDsyr_v2 " , ( " rocblas_dsyr " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasCsyr_v2 " , ( " rocblas_csyr " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasZsyr_v2 " , ( " rocblas_zsyr " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasCher_v2 " , ( " rocblas_cher " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasZher_v2 " , ( " rocblas_zher " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasSspr_v2 " , ( " rocblas_sspr " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasDspr_v2 " , ( " rocblas_dspr " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasChpr_v2 " , ( " rocblas_chpr " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasZhpr_v2 " , ( " rocblas_zhpr " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( <nl> + " cublasSsyr2_v2 " , <nl> + ( " rocblas_ssyr2 " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasDsyr2_v2 " , <nl> + ( " rocblas_dsyr2 " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasCsyr2_v2 " , <nl> + ( " rocblas_csyr2 " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasZsyr2_v2 " , <nl> + ( " rocblas_zsyr2 " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasCher2_v2 " , <nl> + ( " rocblas_cher2 " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasZher2_v2 " , <nl> + ( " rocblas_zher2 " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasSspr2_v2 " , <nl> + ( " rocblas_sspr2 " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasDspr2_v2 " , <nl> + ( " rocblas_dspr2 " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasChpr2_v2 " , <nl> + ( " rocblas_chpr2 " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasZhpr2_v2 " , <nl> + ( " rocblas_zhpr2 " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cublasSgemm_v2 " , ( " rocblas_sgemm " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> + ( " cublasDgemm_v2 " , ( " rocblas_dgemm " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> + ( <nl> + " cublasCgemm_v2 " , <nl> + ( " rocblas_cgemm " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasCgemm3m " , <nl> + ( " rocblas_cgemm_3m " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasCgemm3mEx " , <nl> + ( " rocblas_cgemm_3mex " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasZgemm_v2 " , <nl> + ( " rocblas_zgemm " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasZgemm3m " , <nl> + ( " rocblas_zgemm_3m " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + # NB : The function rocblas_sgemmex doesn ' t actually exist in <nl> + # rocblas , as of 2018 - 12 - 05 <nl> + ( <nl> + " cublasSgemmEx " , <nl> + ( " rocblas_sgemmex " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cublasGemmEx " , ( " rocblas_gemmex " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( <nl> + " cublasCgemmEx " , <nl> + ( " rocblas_cgemmex " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasUint8gemmBias " , <nl> + ( " rocblas_uint8gemmbias " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasSsyrk_v2 " , <nl> + ( " rocblas_ssyrk " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasDsyrk_v2 " , <nl> + ( " rocblas_dsyrk " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasCsyrk_v2 " , <nl> + ( " rocblas_csyrk " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasZsyrk_v2 " , <nl> + ( " rocblas_zsyrk " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasCsyrkEx " , <nl> + ( " rocblas_csyrkex " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasCsyrk3mEx " , <nl> + ( " rocblas_csyrk3mex " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasCherk_v2 " , <nl> + ( " rocblas_cherk " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasCherkEx " , <nl> + ( " rocblas_cherkex " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasCherk3mEx " , <nl> + ( " rocblas_cherk3mex " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasZherk_v2 " , <nl> + ( " rocblas_zherk " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasSsyr2k_v2 " , <nl> + ( " rocblas_ssyr2k " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasDsyr2k_v2 " , <nl> + ( " rocblas_dsyr2k " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasCsyr2k_v2 " , <nl> + ( " rocblas_csyr2k " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasZsyr2k_v2 " , <nl> + ( " rocblas_zsyr2k " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasCher2k_v2 " , <nl> + ( " rocblas_cher2k " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasZher2k_v2 " , <nl> + ( " rocblas_zher2k " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasSsymm_v2 " , <nl> + ( " rocblas_ssymm " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasDsymm_v2 " , <nl> + ( " rocblas_dsymm " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasCsymm_v2 " , <nl> + ( " rocblas_csymm " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasZsymm_v2 " , <nl> + ( " rocblas_zsymm " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasChemm_v2 " , <nl> + ( " rocblas_chemm " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasZhemm_v2 " , <nl> + ( " rocblas_zhemm " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasStrsm_v2 " , <nl> + ( " rocblas_strsm " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasDtrsm_v2 " , <nl> + ( " rocblas_dtrsm " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasCtrsm_v2 " , <nl> + ( " rocblas_ctrsm " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasZtrsm_v2 " , <nl> + ( " rocblas_ztrsm " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasStrmm_v2 " , <nl> + ( " rocblas_strmm " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasDtrmm_v2 " , <nl> + ( " rocblas_dtrmm " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasCtrmm_v2 " , <nl> + ( " rocblas_ctrmm " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasZtrmm_v2 " , <nl> + ( " rocblas_ztrmm " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cublasSnrm2_v2 " , ( " rocblas_snrm2 " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> + ( " cublasDnrm2_v2 " , ( " rocblas_dnrm2 " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> + ( <nl> + " cublasScnrm2_v2 " , <nl> + ( " rocblas_scnrm2 " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasDznrm2_v2 " , <nl> + ( " rocblas_dznrm2 " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cublasDotEx " , ( " rocblas_dotex " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasDotcEx " , ( " rocblas_dotcex " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasSdot_v2 " , ( " rocblas_sdot " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> + ( " cublasDdot_v2 " , ( " rocblas_ddot " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> + ( <nl> + " cublasCdotu_v2 " , <nl> + ( " rocblas_cdotu " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasCdotc_v2 " , <nl> + ( " rocblas_cdotc " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasZdotu_v2 " , <nl> + ( " rocblas_zdotu " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasZdotc_v2 " , <nl> + ( " rocblas_zdotc " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cublasScalEx " , ( " rocblas_scalex " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasSscal_v2 " , ( " rocblas_sscal " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> + ( " cublasDscal_v2 " , ( " rocblas_dscal " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> + ( <nl> + " cublasCscal_v2 " , <nl> + ( " rocblas_cscal " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasCsscal_v2 " , <nl> + ( " rocblas_csscal " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasZscal_v2 " , <nl> + ( " rocblas_zcsal " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasZdscal_v2 " , <nl> + ( " rocblas_zdscal " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cublasAxpyEx " , ( " rocblas_axpyex " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasSaxpy_v2 " , ( " rocblas_saxpy " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> + ( " cublasDaxpy_v2 " , ( " rocblas_daxpy " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> + ( <nl> + " cublasCaxpy_v2 " , <nl> + ( " rocblas_caxpy " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasZaxpy_v2 " , <nl> + ( " rocblas_zaxpy " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cublasScopy_v2 " , ( " rocblas_scopy " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> + ( " cublasDcopy_v2 " , ( " rocblas_dcopy " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> + ( <nl> + " cublasCcopy_v2 " , <nl> + ( " rocblas_ccopy " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasZcopy_v2 " , <nl> + ( " rocblas_zcopy " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cublasSswap_v2 " , ( " rocblas_sswap " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> + ( " cublasDswap_v2 " , ( " rocblas_dswap " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> + ( <nl> + " cublasCswap_v2 " , <nl> + ( " rocblas_cswap " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasZswap_v2 " , <nl> + ( " rocblas_zswap " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cublasIsamax_v2 " , ( " rocblas_isamax " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> + ( " cublasIdamax_v2 " , ( " rocblas_idamax " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> + ( <nl> + " cublasIcamax_v2 " , <nl> + ( " rocblas_icamax " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasIzamax_v2 " , <nl> + ( " rocblas_izamax " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cublasIsamin_v2 " , ( " rocblas_isamin " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> + ( " cublasIdamin_v2 " , ( " rocblas_idamin " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> + ( <nl> + " cublasIcamin_v2 " , <nl> + ( " rocblas_icamin " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasIzamin_v2 " , <nl> + ( " rocblas_izamin " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cublasSasum_v2 " , ( " rocblas_sasum " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> + ( " cublasDasum_v2 " , ( " rocblas_dasum " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> + ( <nl> + " cublasScasum_v2 " , <nl> + ( " rocblas_scasum " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasDzasum_v2 " , <nl> + ( " rocblas_dzasum " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cublasSrot_v2 " , ( " rocblas_srot " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasDrot_v2 " , ( " rocblas_drot " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( " cublasCrot_v2 " , ( " rocblas_crot " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( <nl> + " cublasCsrot_v2 " , <nl> + ( " rocblas_csrot " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " cublasZrot_v2 " , ( " rocblas_zrot " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) ) , <nl> + ( <nl> + " cublasZdrot_v2 " , <nl> + ( " rocblas_zdrot " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasSrotg_v2 " , <nl> + ( " rocblas_srotg " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasDrotg_v2 " , <nl> + ( " rocblas_drotg " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasCrotg_v2 " , <nl> + ( " rocblas_crotg " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasZrotg_v2 " , <nl> + ( " rocblas_zrotg " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasSrotm_v2 " , <nl> + ( " rocblas_srotm " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasDrotm_v2 " , <nl> + ( " rocblas_drotm " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasSrotmg_v2 " , <nl> + ( " rocblas_srotmg " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cublasDrotmg_v2 " , <nl> + ( " rocblas_drotmg " , CONV_MATH_FUNC , API_BLAS , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CURAND_STATUS_SUCCESS " , <nl> + ( " HIPRAND_STATUS_SUCCESS " , CONV_NUMERIC_LITERAL , API_RAND ) , <nl> + ) , <nl> + ( <nl> + " CURAND_STATUS_VERSION_MISMATCH " , <nl> + ( " HIPRAND_STATUS_VERSION_MISMATCH " , CONV_NUMERIC_LITERAL , API_RAND ) , <nl> + ) , <nl> + ( <nl> + " CURAND_STATUS_NOT_INITIALIZED " , <nl> + ( " HIPRAND_STATUS_NOT_INITIALIZED " , CONV_NUMERIC_LITERAL , API_RAND ) , <nl> + ) , <nl> + ( <nl> + " CURAND_STATUS_ALLOCATION_FAILED " , <nl> + ( " HIPRAND_STATUS_ALLOCATION_FAILED " , CONV_NUMERIC_LITERAL , API_RAND ) , <nl> + ) , <nl> + ( <nl> + " CURAND_STATUS_TYPE_ERROR " , <nl> + ( " HIPRAND_STATUS_TYPE_ERROR " , CONV_NUMERIC_LITERAL , API_RAND ) , <nl> + ) , <nl> + ( <nl> + " CURAND_STATUS_OUT_OF_RANGE " , <nl> + ( " HIPRAND_STATUS_OUT_OF_RANGE " , CONV_NUMERIC_LITERAL , API_RAND ) , <nl> + ) , <nl> + ( <nl> + " CURAND_STATUS_LENGTH_NOT_MULTIPLE " , <nl> + ( " HIPRAND_STATUS_LENGTH_NOT_MULTIPLE " , CONV_NUMERIC_LITERAL , API_RAND ) , <nl> + ) , <nl> + ( <nl> + " CURAND_STATUS_DOUBLE_PRECISION_REQUIRED " , <nl> + ( <nl> + " HIPRAND_STATUS_DOUBLE_PRECISION_REQUIRED " , <nl> + CONV_NUMERIC_LITERAL , <nl> + API_RAND , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CURAND_STATUS_LAUNCH_FAILURE " , <nl> + ( " HIPRAND_STATUS_LAUNCH_FAILURE " , CONV_NUMERIC_LITERAL , API_RAND ) , <nl> + ) , <nl> + ( <nl> + " CURAND_STATUS_PREEXISTING_FAILURE " , <nl> + ( " HIPRAND_STATUS_PREEXISTING_FAILURE " , CONV_NUMERIC_LITERAL , API_RAND ) , <nl> + ) , <nl> + ( <nl> + " CURAND_STATUS_INITIALIZATION_FAILED " , <nl> + ( " HIPRAND_STATUS_INITIALIZATION_FAILED " , CONV_NUMERIC_LITERAL , API_RAND ) , <nl> + ) , <nl> + ( <nl> + " CURAND_STATUS_ARCH_MISMATCH " , <nl> + ( " HIPRAND_STATUS_ARCH_MISMATCH " , CONV_NUMERIC_LITERAL , API_RAND ) , <nl> + ) , <nl> + ( <nl> + " CURAND_STATUS_INTERNAL_ERROR " , <nl> + ( " HIPRAND_STATUS_INTERNAL_ERROR " , CONV_NUMERIC_LITERAL , API_RAND ) , <nl> + ) , <nl> + ( " CURAND_RNG_TEST " , ( " HIPRAND_RNG_TEST " , CONV_NUMERIC_LITERAL , API_RAND ) ) , <nl> + ( <nl> + " mtgp32dc_params_fast_11213 " , <nl> + ( " mtgp32dc_params_fast_11213 " , CONV_NUMERIC_LITERAL , API_RAND ) , <nl> + ) , <nl> + ( <nl> + " CURAND_RNG_PSEUDO_DEFAULT " , <nl> + ( " HIPRAND_RNG_PSEUDO_DEFAULT " , CONV_NUMERIC_LITERAL , API_RAND ) , <nl> + ) , <nl> + ( <nl> + " CURAND_RNG_PSEUDO_XORWOW " , <nl> + ( " HIPRAND_RNG_PSEUDO_XORWOW " , CONV_NUMERIC_LITERAL , API_RAND ) , <nl> + ) , <nl> + ( <nl> + " CURAND_RNG_PSEUDO_MRG32K3A " , <nl> + ( " HIPRAND_RNG_PSEUDO_MRG32K3A " , CONV_NUMERIC_LITERAL , API_RAND ) , <nl> + ) , <nl> + ( <nl> + " CURAND_RNG_PSEUDO_MTGP32 " , <nl> + ( " HIPRAND_RNG_PSEUDO_MTGP32 " , CONV_NUMERIC_LITERAL , API_RAND ) , <nl> + ) , <nl> + ( <nl> + " CURAND_RNG_PSEUDO_MT19937 " , <nl> + ( " HIPRAND_RNG_PSEUDO_MT19937 " , CONV_NUMERIC_LITERAL , API_RAND ) , <nl> + ) , <nl> + ( <nl> + " CURAND_RNG_PSEUDO_PHILOX4_32_10 " , <nl> + ( " HIPRAND_RNG_PSEUDO_PHILOX4_32_10 " , CONV_NUMERIC_LITERAL , API_RAND ) , <nl> + ) , <nl> + ( <nl> + " CURAND_RNG_QUASI_DEFAULT " , <nl> + ( " HIPRAND_RNG_QUASI_DEFAULT " , CONV_NUMERIC_LITERAL , API_RAND ) , <nl> + ) , <nl> + ( <nl> + " CURAND_RNG_QUASI_SOBOL32 " , <nl> + ( " HIPRAND_RNG_QUASI_SOBOL32 " , CONV_NUMERIC_LITERAL , API_RAND ) , <nl> + ) , <nl> + ( <nl> + " CURAND_RNG_QUASI_SCRAMBLED_SOBOL32 " , <nl> + ( " HIPRAND_RNG_QUASI_SCRAMBLED_SOBOL32 " , CONV_NUMERIC_LITERAL , API_RAND ) , <nl> + ) , <nl> + ( <nl> + " CURAND_RNG_QUASI_SOBOL64 " , <nl> + ( " HIPRAND_RNG_QUASI_SOBOL64 " , CONV_NUMERIC_LITERAL , API_RAND ) , <nl> + ) , <nl> + ( <nl> + " CURAND_RNG_QUASI_SCRAMBLED_SOBOL64 " , <nl> + ( " HIPRAND_RNG_QUASI_SCRAMBLED_SOBOL64 " , CONV_NUMERIC_LITERAL , API_RAND ) , <nl> + ) , <nl> + ( <nl> + " curand_ORDERING_PSEUDO_BEST " , <nl> + ( <nl> + " HIPRAND_ORDERING_PSEUDO_BEST " , <nl> + CONV_NUMERIC_LITERAL , <nl> + API_RAND , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " curand_ORDERING_PSEUDO_DEFAULT " , <nl> + ( <nl> + " HIPRAND_ORDERING_PSEUDO_DEFAULT " , <nl> + CONV_NUMERIC_LITERAL , <nl> + API_RAND , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " curand_ORDERING_PSEUDO_SEEDED " , <nl> + ( <nl> + " HIPRAND_ORDERING_PSEUDO_SEEDED " , <nl> + CONV_NUMERIC_LITERAL , <nl> + API_RAND , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " curand_ORDERING_QUASI_DEFAULT " , <nl> + ( <nl> + " HIPRAND_ORDERING_QUASI_DEFAULT " , <nl> + CONV_NUMERIC_LITERAL , <nl> + API_RAND , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " curand_DIRECTION_VECTORS_32_JOEKUO6 " , <nl> + ( <nl> + " HIPRAND_DIRECTION_VECTORS_32_JOEKUO6 " , <nl> + CONV_NUMERIC_LITERAL , <nl> + API_RAND , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " curand_SCRAMBLED_DIRECTION_VECTORS_32_JOEKUO6 " , <nl> + ( <nl> + " HIPRAND_SCRAMBLED_DIRECTION_VECTORS_32_JOEKUO6 " , <nl> + CONV_NUMERIC_LITERAL , <nl> + API_RAND , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " curand_DIRECTION_VECTORS_64_JOEKUO6 " , <nl> + ( <nl> + " HIPRAND_DIRECTION_VECTORS_64_JOEKUO6 " , <nl> + CONV_NUMERIC_LITERAL , <nl> + API_RAND , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " curand_SCRAMBLED_DIRECTION_VECTORS_64_JOEKUO6 " , <nl> + ( <nl> + " HIPRAND_SCRAMBLED_DIRECTION_VECTORS_64_JOEKUO6 " , <nl> + CONV_NUMERIC_LITERAL , <nl> + API_RAND , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " curand_CHOOSE_BEST " , <nl> + ( " HIPRAND_CHOOSE_BEST " , CONV_NUMERIC_LITERAL , API_RAND , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " curand_ITR " , <nl> + ( " HIPRAND_ITR " , CONV_NUMERIC_LITERAL , API_RAND , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " curand_KNUTH " , <nl> + ( " HIPRAND_KNUTH " , CONV_NUMERIC_LITERAL , API_RAND , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " curand_HITR " , <nl> + ( " HIPRAND_HITR " , CONV_NUMERIC_LITERAL , API_RAND , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " curand_M1 " , ( " HIPRAND_M1 " , CONV_NUMERIC_LITERAL , API_RAND , HIP_UNSUPPORTED ) ) , <nl> + ( " curand_M2 " , ( " HIPRAND_M2 " , CONV_NUMERIC_LITERAL , API_RAND , HIP_UNSUPPORTED ) ) , <nl> + ( <nl> + " curand_BINARY_SEARCH " , <nl> + ( " HIPRAND_BINARY_SEARCH " , CONV_NUMERIC_LITERAL , API_RAND , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " curand_DISCRETE_GAUSS " , <nl> + ( " HIPRAND_DISCRETE_GAUSS " , CONV_NUMERIC_LITERAL , API_RAND , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " curand_REJECTION " , <nl> + ( " HIPRAND_REJECTION " , CONV_NUMERIC_LITERAL , API_RAND , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " curand_DEVICE_API " , <nl> + ( " HIPRAND_DEVICE_API " , CONV_NUMERIC_LITERAL , API_RAND , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " curand_FAST_REJECTION " , <nl> + ( " HIPRAND_FAST_REJECTION " , CONV_NUMERIC_LITERAL , API_RAND , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " curand_3RD " , <nl> + ( " HIPRAND_3RD " , CONV_NUMERIC_LITERAL , API_RAND , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " curand_DEFINITION " , <nl> + ( " HIPRAND_DEFINITION " , CONV_NUMERIC_LITERAL , API_RAND , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " curand_POISSON " , <nl> + ( " HIPRAND_POISSON " , CONV_NUMERIC_LITERAL , API_RAND , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " curandCreateGenerator " , ( " hiprandCreateGenerator " , CONV_MATH_FUNC , API_RAND ) ) , <nl> + ( <nl> + " curandCreateGeneratorHost " , <nl> + ( " hiprandCreateGeneratorHost " , CONV_MATH_FUNC , API_RAND ) , <nl> + ) , <nl> + ( <nl> + " curandCreatePoissonDistribution " , <nl> + ( " hiprandCreatePoissonDistribution " , CONV_MATH_FUNC , API_RAND ) , <nl> + ) , <nl> + ( <nl> + " curandDestroyDistribution " , <nl> + ( " hiprandDestroyDistribution " , CONV_MATH_FUNC , API_RAND ) , <nl> + ) , <nl> + ( <nl> + " curandDestroyGenerator " , <nl> + ( " hiprandDestroyGenerator " , CONV_MATH_FUNC , API_RAND ) , <nl> + ) , <nl> + ( " curandGenerate " , ( " hiprandGenerate " , CONV_MATH_FUNC , API_RAND ) ) , <nl> + ( <nl> + " curandGenerateLogNormal " , <nl> + ( " hiprandGenerateLogNormal " , CONV_MATH_FUNC , API_RAND ) , <nl> + ) , <nl> + ( <nl> + " curandGenerateLogNormalDouble " , <nl> + ( " hiprandGenerateLogNormalDouble " , CONV_MATH_FUNC , API_RAND ) , <nl> + ) , <nl> + ( <nl> + " curandGenerateLongLong " , <nl> + ( " hiprandGenerateLongLong " , CONV_MATH_FUNC , API_RAND , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " curandGenerateNormal " , ( " hiprandGenerateNormal " , CONV_MATH_FUNC , API_RAND ) ) , <nl> + ( <nl> + " curandGenerateNormalDouble " , <nl> + ( " hiprandGenerateNormalDouble " , CONV_MATH_FUNC , API_RAND ) , <nl> + ) , <nl> + ( " curandGeneratePoisson " , ( " hiprandGeneratePoisson " , CONV_MATH_FUNC , API_RAND ) ) , <nl> + ( " curandGenerateSeeds " , ( " hiprandGenerateSeeds " , CONV_MATH_FUNC , API_RAND ) ) , <nl> + ( " curandGenerateUniform " , ( " hiprandGenerateUniform " , CONV_MATH_FUNC , API_RAND ) ) , <nl> + ( <nl> + " curandGenerateUniformDouble " , <nl> + ( " hiprandGenerateUniformDouble " , CONV_MATH_FUNC , API_RAND ) , <nl> + ) , <nl> + ( <nl> + " curandGetDirectionVectors32 " , <nl> + ( " hiprandGetDirectionVectors32 " , CONV_MATH_FUNC , API_RAND , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " curandGetDirectionVectors64 " , <nl> + ( " hiprandGetDirectionVectors64 " , CONV_MATH_FUNC , API_RAND , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " curandGetProperty " , <nl> + ( " hiprandGetProperty " , CONV_MATH_FUNC , API_RAND , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " curandGetScrambleConstants32 " , <nl> + ( <nl> + " hiprandGetScrambleConstants32 " , <nl> + CONV_MATH_FUNC , <nl> + API_RAND , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " curandGetScrambleConstants64 " , <nl> + ( <nl> + " hiprandGetScrambleConstants64 " , <nl> + CONV_MATH_FUNC , <nl> + API_RAND , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( " curandGetVersion " , ( " hiprandGetVersion " , CONV_MATH_FUNC , API_RAND ) ) , <nl> + ( <nl> + " curandSetGeneratorOffset " , <nl> + ( " hiprandSetGeneratorOffset " , CONV_MATH_FUNC , API_RAND ) , <nl> + ) , <nl> + ( <nl> + " curandSetGeneratorOrdering " , <nl> + ( " hiprandSetGeneratorOrdering " , CONV_MATH_FUNC , API_RAND , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " curandSetPseudoRandomGeneratorSeed " , <nl> + ( " hiprandSetPseudoRandomGeneratorSeed " , CONV_MATH_FUNC , API_RAND ) , <nl> + ) , <nl> + ( <nl> + " curandSetQuasiRandomGeneratorDimensions " , <nl> + ( " hiprandSetQuasiRandomGeneratorDimensions " , CONV_MATH_FUNC , API_RAND ) , <nl> + ) , <nl> + ( " curandSetStream " , ( " hiprandSetStream " , CONV_MATH_FUNC , API_RAND ) ) , <nl> + ( " curand " , ( " hiprand " , CONV_DEVICE_FUNC , API_RAND ) ) , <nl> + ( " curand4 " , ( " hiprand4 " , CONV_DEVICE_FUNC , API_RAND ) ) , <nl> + ( " curand_init " , ( " hiprand_init " , CONV_DEVICE_FUNC , API_RAND ) ) , <nl> + ( " curand_log_normal " , ( " hiprand_log_normal " , CONV_DEVICE_FUNC , API_RAND ) ) , <nl> + ( <nl> + " curand_log_normal_double " , <nl> + ( " hiprand_log_normal_double " , CONV_DEVICE_FUNC , API_RAND ) , <nl> + ) , <nl> + ( " curand_log_normal2 " , ( " hiprand_log_normal2 " , CONV_DEVICE_FUNC , API_RAND ) ) , <nl> + ( <nl> + " curand_log_normal2_double " , <nl> + ( " hiprand_log_normal2_double " , CONV_DEVICE_FUNC , API_RAND ) , <nl> + ) , <nl> + ( " curand_log_normal4 " , ( " hiprand_log_normal4 " , CONV_DEVICE_FUNC , API_RAND ) ) , <nl> + ( <nl> + " curand_log_normal4_double " , <nl> + ( " hiprand_log_normal4_double " , CONV_DEVICE_FUNC , API_RAND ) , <nl> + ) , <nl> + ( <nl> + " curand_mtgp32_single " , <nl> + ( " hiprand_mtgp32_single " , CONV_DEVICE_FUNC , API_RAND , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " curand_mtgp32_single_specific " , <nl> + ( <nl> + " hiprand_mtgp32_single_specific " , <nl> + CONV_DEVICE_FUNC , <nl> + API_RAND , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " curand_mtgp32_specific " , <nl> + ( " hiprand_mtgp32_specific " , CONV_DEVICE_FUNC , API_RAND , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " curand_normal " , ( " hiprand_normal " , CONV_DEVICE_FUNC , API_RAND ) ) , <nl> + ( <nl> + " curandMakeMTGP32Constants " , <nl> + ( " hiprandMakeMTGP32Constants " , CONV_DEVICE_FUNC , API_RAND ) , <nl> + ) , <nl> + ( <nl> + " curandMakeMTGP32KernelState " , <nl> + ( " hiprandMakeMTGP32KernelState " , CONV_DEVICE_FUNC , API_RAND ) , <nl> + ) , <nl> + ( " curand_normal_double " , ( " hiprand_normal_double " , CONV_DEVICE_FUNC , API_RAND ) ) , <nl> + ( " curand_normal2 " , ( " hiprand_normal2 " , CONV_DEVICE_FUNC , API_RAND ) ) , <nl> + ( <nl> + " curand_normal2_double " , <nl> + ( " hiprand_normal2_double " , CONV_DEVICE_FUNC , API_RAND ) , <nl> + ) , <nl> + ( " curand_normal4 " , ( " hiprand_normal4 " , CONV_DEVICE_FUNC , API_RAND ) ) , <nl> + ( <nl> + " curand_normal4_double " , <nl> + ( " hiprand_normal4_double " , CONV_DEVICE_FUNC , API_RAND ) , <nl> + ) , <nl> + ( " curand_uniform " , ( " hiprand_uniform " , CONV_DEVICE_FUNC , API_RAND ) ) , <nl> + ( <nl> + " curand_uniform_double " , <nl> + ( " hiprand_uniform_double " , CONV_DEVICE_FUNC , API_RAND ) , <nl> + ) , <nl> + ( <nl> + " curand_uniform2_double " , <nl> + ( " hiprand_uniform2_double " , CONV_DEVICE_FUNC , API_RAND ) , <nl> + ) , <nl> + ( " curand_uniform4 " , ( " hiprand_uniform4 " , CONV_DEVICE_FUNC , API_RAND ) ) , <nl> + ( <nl> + " curand_uniform4_double " , <nl> + ( " hiprand_uniform4_double " , CONV_DEVICE_FUNC , API_RAND ) , <nl> + ) , <nl> + ( " curand_discrete " , ( " hiprand_discrete " , CONV_DEVICE_FUNC , API_RAND ) ) , <nl> + ( " curand_discrete4 " , ( " hiprand_discrete4 " , CONV_DEVICE_FUNC , API_RAND ) ) , <nl> + ( " curand_poisson " , ( " hiprand_poisson " , CONV_DEVICE_FUNC , API_RAND ) ) , <nl> + ( " curand_poisson4 " , ( " hiprand_poisson4 " , CONV_DEVICE_FUNC , API_RAND ) ) , <nl> + ( <nl> + " curand_Philox4x32_10 " , <nl> + ( " hiprand_Philox4x32_10 " , CONV_DEVICE_FUNC , API_RAND , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " mtgp32_kernel_params " , ( " mtgp32_kernel_params_t " , CONV_MATH_FUNC , API_RAND ) ) , <nl> + ( " CUFFT_FORWARD " , ( " HIPFFT_FORWARD " , CONV_NUMERIC_LITERAL , API_BLAS ) ) , <nl> + ( " CUFFT_INVERSE " , ( " HIPFFT_BACKWARD " , CONV_NUMERIC_LITERAL , API_BLAS ) ) , <nl> + ( <nl> + " CUFFT_COMPATIBILITY_DEFAULT " , <nl> + ( <nl> + " HIPFFT_COMPATIBILITY_DEFAULT " , <nl> + CONV_NUMERIC_LITERAL , <nl> + API_BLAS , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( " cufftResult_t " , ( " hipfftResult_t " , CONV_TYPE , API_FFT ) ) , <nl> + ( " cufftResult " , ( " hipfftResult " , CONV_TYPE , API_FFT ) ) , <nl> + ( " CUFFT_SUCCESS " , ( " HIPFFT_SUCCESS " , CONV_NUMERIC_LITERAL , API_FFT ) ) , <nl> + ( " CUFFT_INVALID_PLAN " , ( " HIPFFT_INVALID_PLAN " , CONV_NUMERIC_LITERAL , API_FFT ) ) , <nl> + ( " CUFFT_ALLOC_FAILED " , ( " HIPFFT_ALLOC_FAILED " , CONV_NUMERIC_LITERAL , API_FFT ) ) , <nl> + ( " CUFFT_INVALID_TYPE " , ( " HIPFFT_INVALID_TYPE " , CONV_NUMERIC_LITERAL , API_FFT ) ) , <nl> + ( <nl> + " CUFFT_INVALID_VALUE " , <nl> + ( " HIPFFT_INVALID_VALUE " , CONV_NUMERIC_LITERAL , API_FFT ) , <nl> + ) , <nl> + ( <nl> + " CUFFT_INTERNAL_ERROR " , <nl> + ( " HIPFFT_INTERNAL_ERROR " , CONV_NUMERIC_LITERAL , API_FFT ) , <nl> + ) , <nl> + ( " CUFFT_EXEC_FAILED " , ( " HIPFFT_EXEC_FAILED " , CONV_NUMERIC_LITERAL , API_FFT ) ) , <nl> + ( " CUFFT_SETUP_FAILED " , ( " HIPFFT_SETUP_FAILED " , CONV_NUMERIC_LITERAL , API_FFT ) ) , <nl> + ( " CUFFT_INVALID_SIZE " , ( " HIPFFT_INVALID_SIZE " , CONV_NUMERIC_LITERAL , API_FFT ) ) , <nl> + ( <nl> + " CUFFT_UNALIGNED_DATA " , <nl> + ( " HIPFFT_UNALIGNED_DATA " , CONV_NUMERIC_LITERAL , API_FFT ) , <nl> + ) , <nl> + ( <nl> + " CUFFT_INCOMPLETE_PARAMETER_LIST " , <nl> + ( " HIPFFT_INCOMPLETE_PARAMETER_LIST " , CONV_NUMERIC_LITERAL , API_FFT ) , <nl> + ) , <nl> + ( <nl> + " CUFFT_INVALID_DEVICE " , <nl> + ( " HIPFFT_INVALID_DEVICE " , CONV_NUMERIC_LITERAL , API_FFT ) , <nl> + ) , <nl> + ( " CUFFT_PARSE_ERROR " , ( " HIPFFT_PARSE_ERROR " , CONV_NUMERIC_LITERAL , API_FFT ) ) , <nl> + ( " CUFFT_NO_WORKSPACE " , ( " HIPFFT_NO_WORKSPACE " , CONV_NUMERIC_LITERAL , API_FFT ) ) , <nl> + ( <nl> + " CUFFT_NOT_IMPLEMENTED " , <nl> + ( " HIPFFT_NOT_IMPLEMENTED " , CONV_NUMERIC_LITERAL , API_FFT ) , <nl> + ) , <nl> + ( <nl> + " CUFFT_LICENSE_ERROR " , <nl> + ( " HIPFFT_LICENSE_ERROR " , CONV_NUMERIC_LITERAL , API_FFT , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CUFFT_NOT_SUPPORTED " , <nl> + ( " HIPFFT_NOT_SUPPORTED " , CONV_NUMERIC_LITERAL , API_FFT ) , <nl> + ) , <nl> + ( " cufftType_t " , ( " hipfftType_t " , CONV_TYPE , API_FFT ) ) , <nl> + ( " cufftType " , ( " hipfftType " , CONV_TYPE , API_FFT ) ) , <nl> + ( " CUFFT_R2C " , ( " HIPFFT_R2C " , CONV_NUMERIC_LITERAL , API_FFT ) ) , <nl> + ( " CUFFT_C2R " , ( " HIPFFT_C2R " , CONV_NUMERIC_LITERAL , API_FFT ) ) , <nl> + ( " CUFFT_C2C " , ( " HIPFFT_C2C " , CONV_NUMERIC_LITERAL , API_FFT ) ) , <nl> + ( " CUFFT_D2Z " , ( " HIPFFT_D2Z " , CONV_NUMERIC_LITERAL , API_FFT ) ) , <nl> + ( " CUFFT_Z2D " , ( " HIPFFT_Z2D " , CONV_NUMERIC_LITERAL , API_FFT ) ) , <nl> + ( " CUFFT_Z2Z " , ( " HIPFFT_Z2Z " , CONV_NUMERIC_LITERAL , API_FFT ) ) , <nl> + ( <nl> + " cufftCompatibility_t " , <nl> + ( " hipfftCompatibility_t " , CONV_TYPE , API_FFT , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " cufftCompatibility " , <nl> + ( " hipfftCompatibility " , CONV_TYPE , API_FFT , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( <nl> + " CUFFT_COMPATIBILITY_FFTW_PADDING " , <nl> + ( <nl> + " HIPFFT_COMPATIBILITY_FFTW_PADDING " , <nl> + CONV_NUMERIC_LITERAL , <nl> + API_FFT , <nl> + HIP_UNSUPPORTED , <nl> + ) , <nl> + ) , <nl> + ( " cufftReal " , ( " hipfftReal " , CONV_TYPE , API_FFT ) ) , <nl> + ( " cufftDoubleReal " , ( " hipfftDoubleReal " , CONV_TYPE , API_FFT ) ) , <nl> + ( " cufftComplex " , ( " hipfftComplex " , CONV_TYPE , API_FFT ) ) , <nl> + ( " cufftDoubleComplex " , ( " hipfftDoubleComplex " , CONV_TYPE , API_FFT ) ) , <nl> + ( " cufftHandle " , ( " hipfftHandle " , CONV_TYPE , API_FFT ) ) , <nl> + ( " cufftPlan1d " , ( " hipfftPlan1d " , CONV_MATH_FUNC , API_FFT ) ) , <nl> + ( " cufftPlan2d " , ( " hipfftPlan2d " , CONV_MATH_FUNC , API_FFT ) ) , <nl> + ( " cufftPlan3d " , ( " hipfftPlan3d " , CONV_MATH_FUNC , API_FFT ) ) , <nl> + ( " cufftPlanMany " , ( " hipfftPlanMany " , CONV_MATH_FUNC , API_FFT ) ) , <nl> + ( " cufftMakePlan1d " , ( " hipfftMakePlan1d " , CONV_MATH_FUNC , API_FFT ) ) , <nl> + ( " cufftMakePlan2d " , ( " hipfftMakePlan2d " , CONV_MATH_FUNC , API_FFT ) ) , <nl> + ( " cufftMakePlan3d " , ( " hipfftMakePlan3d " , CONV_MATH_FUNC , API_FFT ) ) , <nl> + ( " cufftMakePlanMany " , ( " hipfftMakePlanMany " , CONV_MATH_FUNC , API_FFT ) ) , <nl> + ( " cufftMakePlanMany64 " , ( " hipfftMakePlanMany64 " , CONV_MATH_FUNC , API_FFT ) ) , <nl> + ( " cufftGetSizeMany64 " , ( " hipfftGetSizeMany64 " , CONV_MATH_FUNC , API_FFT ) ) , <nl> + ( " cufftEstimate1d " , ( " hipfftEstimate1d " , CONV_MATH_FUNC , API_FFT ) ) , <nl> + ( " cufftEstimate2d " , ( " hipfftEstimate2d " , CONV_MATH_FUNC , API_FFT ) ) , <nl> + ( " cufftEstimate3d " , ( " hipfftEstimate3d " , CONV_MATH_FUNC , API_FFT ) ) , <nl> + ( " cufftEstimateMany " , ( " hipfftEstimateMany " , CONV_MATH_FUNC , API_FFT ) ) , <nl> + ( " cufftCreate " , ( " hipfftCreate " , CONV_MATH_FUNC , API_FFT ) ) , <nl> + ( " cufftGetSize1d " , ( " hipfftGetSize1d " , CONV_MATH_FUNC , API_FFT ) ) , <nl> + ( " cufftGetSize2d " , ( " hipfftGetSize2d " , CONV_MATH_FUNC , API_FFT ) ) , <nl> + ( " cufftGetSize3d " , ( " hipfftGetSize3d " , CONV_MATH_FUNC , API_FFT ) ) , <nl> + ( " cufftGetSizeMany " , ( " hipfftGetSizeMany " , CONV_MATH_FUNC , API_FFT ) ) , <nl> + ( " cufftGetSize " , ( " hipfftGetSize " , CONV_MATH_FUNC , API_FFT ) ) , <nl> + ( " cufftSetWorkArea " , ( " hipfftSetWorkArea " , CONV_MATH_FUNC , API_FFT ) ) , <nl> + ( <nl> + " cufftSetAutoAllocation " , <nl> + ( " hipfftSetAutoAllocation " , CONV_MATH_FUNC , API_FFT ) , <nl> + ) , <nl> + ( " cufftExecC2C " , ( " hipfftExecC2C " , CONV_MATH_FUNC , API_FFT ) ) , <nl> + ( " cufftExecR2C " , ( " hipfftExecR2C " , CONV_MATH_FUNC , API_FFT ) ) , <nl> + ( " cufftExecC2R " , ( " hipfftExecC2R " , CONV_MATH_FUNC , API_FFT ) ) , <nl> + ( " cufftExecZ2Z " , ( " hipfftExecZ2Z " , CONV_MATH_FUNC , API_FFT ) ) , <nl> + ( " cufftExecD2Z " , ( " hipfftExecD2Z " , CONV_MATH_FUNC , API_FFT ) ) , <nl> + ( " cufftExecZ2D " , ( " hipfftExecZ2D " , CONV_MATH_FUNC , API_FFT ) ) , <nl> + ( " cufftSetStream " , ( " hipfftSetStream " , CONV_MATH_FUNC , API_FFT ) ) , <nl> + ( " cufftDestroy " , ( " hipfftDestroy " , CONV_MATH_FUNC , API_FFT ) ) , <nl> + ( " cufftGetVersion " , ( " hipfftGetVersion " , CONV_MATH_FUNC , API_FFT ) ) , <nl> + ( <nl> + " cufftGetProperty " , <nl> + ( " hipfftGetProperty " , CONV_MATH_FUNC , API_FFT , HIP_UNSUPPORTED ) , <nl> + ) , <nl> + ( " nvrtcResult " , ( " hiprtcResult " , CONV_TYPE , API_RTC ) ) , <nl> + ( " NVRTC_SUCCESS " , ( " HIPRTC_SUCCESS " , CONV_TYPE , API_RTC ) ) , <nl> + ( <nl> + " NVRTC_ERROR_OUT_OF_MEMORY " , <nl> + ( " HIPRTC_ERROR_OUT_OF_MEMORY " , CONV_TYPE , API_RTC ) , <nl> + ) , <nl> + ( <nl> + " NVRTC_ERROR_PROGRAM_CREATION_FAILURE " , <nl> + ( " HIPRTC_ERROR_PROGRAM_CREATION_FAILURE " , CONV_TYPE , API_RTC ) , <nl> + ) , <nl> + ( <nl> + " NVRTC_ERROR_INVALID_INPUT " , <nl> + ( " HIPRTC_ERROR_INVALID_INPUT " , CONV_TYPE , API_RTC ) , <nl> + ) , <nl> + ( <nl> + " NVRTC_ERROR_INVALID_PROGRAM " , <nl> + ( " HIPRTC_ERROR_INVALID_PROGRAM " , CONV_TYPE , API_RTC ) , <nl> + ) , <nl> + ( " NVRTC_ERROR_COMPILATION " , ( " HIPRTC_ERROR_COMPILATION " , CONV_TYPE , API_RTC ) ) , <nl> + ( <nl> + " NVRTC_ERROR_BUILTIN_OPERATION_FAILURE " , <nl> + ( " HIPRTC_ERROR_BUILTIN_OPERATION_FAILURE " , CONV_TYPE , API_RTC ) , <nl> + ) , <nl> + ( <nl> + " NVRTC_ERROR_NO_NAME_EXPRESSIONS_AFTER_COMPILATION " , <nl> + ( " HIPRTC_ERROR_NO_NAME_EXPRESSIONS_AFTER_COMPILATION " , CONV_TYPE , API_RTC ) , <nl> + ) , <nl> + ( <nl> + " NVRTC_ERROR_NAME_EXPRESSION_NOT_VALID " , <nl> + ( " HIPRTC_ERROR_NAME_EXPRESSION_NOT_VALID " , CONV_TYPE , API_RTC ) , <nl> + ) , <nl> + ( <nl> + " NVRTC_ERROR_INTERNAL_ERROR " , <nl> + ( " HIPRTC_ERROR_INTERNAL_ERROR " , CONV_TYPE , API_RTC ) , <nl> + ) , <nl> + ( " nvrtcGetErrorString " , ( " hiprtcGetErrorString " , CONV_JIT , API_RTC ) ) , <nl> + ( " nvrtcVersion " , ( " hiprtcVersion " , CONV_JIT , API_RTC ) ) , <nl> + ( " nvrtcProgram " , ( " hiprtcProgram " , CONV_TYPE , API_RTC ) ) , <nl> + ( " nvrtcAddNameExpression " , ( " hiprtcAddNameExpression " , CONV_JIT , API_RTC ) ) , <nl> + ( " nvrtcCompileProgram " , ( " hiprtcCompileProgram " , CONV_JIT , API_RTC ) ) , <nl> + ( " nvrtcCreateProgram " , ( " hiprtcCreateProgram " , CONV_JIT , API_RTC ) ) , <nl> + ( " nvrtcDestroyProgram " , ( " hiprtcDestroyProgram " , CONV_JIT , API_RTC ) ) , <nl> + ( " nvrtcGetLoweredName " , ( " hiprtcGetLoweredName " , CONV_JIT , API_RTC ) ) , <nl> + ( " nvrtcGetProgramLog " , ( " hiprtcGetProgramLog " , CONV_JIT , API_RTC ) ) , <nl> + ( " nvrtcGetProgramLogSize " , ( " hiprtcGetProgramLogSize " , CONV_JIT , API_RTC ) ) , <nl> + ( " nvrtcGetPTX " , ( " hiprtcGetCode " , CONV_JIT , API_RTC ) ) , <nl> + ( " nvrtcGetPTXSize " , ( " hiprtcGetCodeSize " , CONV_JIT , API_RTC ) ) , <nl> + ( " thrust : : cuda " , ( " thrust : : hip " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> + ( " cub : : " , ( " hipcub : : " , CONV_MATH_FUNC , API_BLAS ) ) , <nl> + ( " nvtxMark " , ( " roctxMark " , CONV_OTHER , API_ROCTX ) ) , <nl> + ( " nvtxMarkA " , ( " roctxMarkA " , CONV_OTHER , API_ROCTX ) ) , <nl> + ( " nvtxRangePushA " , ( " roctxRangePushA " , CONV_OTHER , API_ROCTX ) ) , <nl> + ( " nvtxRangePop " , ( " roctxRangePop " , CONV_OTHER , API_ROCTX ) ) , <nl> + ] <nl> + ) <nl> + <nl> + CUDA_SPARSE_MAP = collections . OrderedDict ( <nl> + [ <nl> + ( " cusparseStatus_t " , ( " hipsparseStatus_t " , CONV_MATH_FUNC , API_SPARSE ) ) , <nl> + ( " cusparseHandle_t " , ( " hipsparseHandle_t " , CONV_MATH_FUNC , API_SPARSE ) ) , <nl> + ( " cusparseOperation_t " , ( " hipsparseOperation_t " , CONV_TYPE , API_SPARSE ) ) , <nl> + ( <nl> + " cusparseCreateMatDescr " , <nl> + ( " hipsparseCreateMatDescr " , CONV_MATH_FUNC , API_SPARSE ) , <nl> + ) , <nl> + ( " cusparseCreate " , ( " hipsparseCreate " , CONV_MATH_FUNC , API_SPARSE ) ) , <nl> + ( <nl> + " cusparseDestroyMatDescr " , <nl> + ( " hipsparseDestroyMatDescr " , CONV_MATH_FUNC , API_SPARSE ) , <nl> + ) , <nl> + ( " cusparseDestroy " , ( " hipsparseDestroy " , CONV_MATH_FUNC , API_SPARSE ) ) , <nl> + ( " cusparseXcoo2csr " , ( " hipsparseXcoo2csr " , CONV_MATH_FUNC , API_SPARSE ) ) , <nl> + ( " cusparseMatDescr_t " , ( " hipsparseMatDescr_t " , CONV_MATH_FUNC , API_SPARSE ) ) , <nl> + ( " cusparseScsrmm2 " , ( " hipsparseScsrmm2 " , CONV_MATH_FUNC , API_SPARSE ) ) , <nl> + ( " cusparseDcsrmm2 " , ( " hipsparseDcsrmm2 " , CONV_MATH_FUNC , API_SPARSE ) ) , <nl> + ( " cusparseScsrmm " , ( " hipsparseScsrmm " , CONV_MATH_FUNC , API_SPARSE ) ) , <nl> + ( " cusparseDcsrmm " , ( " hipsparseDcsrmm " , CONV_MATH_FUNC , API_SPARSE ) ) , <nl> + ( <nl> + " cusparseXcsrsort_bufferSizeExt " , <nl> + ( " hipsparseXcsrsort_bufferSizeExt " , CONV_MATH_FUNC , API_SPARSE ) , <nl> + ) , <nl> + ( " cusparseXcsrsort " , ( " hipsparseXcsrsort " , CONV_MATH_FUNC , API_SPARSE ) ) , <nl> + ( <nl> + " cusparseXcoosort_bufferSizeExt " , <nl> + ( " hipsparseXcoosort_bufferSizeExt " , CONV_MATH_FUNC , API_SPARSE ) , <nl> + ) , <nl> + ( <nl> + " cusparseXcoosortByRow " , <nl> + ( " hipsparseXcoosortByRow " , CONV_MATH_FUNC , API_SPARSE ) , <nl> + ) , <nl> + ( " cusparseSetStream " , ( " hipsparseSetStream " , CONV_MATH_FUNC , API_SPARSE ) ) , <nl> + ( <nl> + " cusparseCreateIdentityPermutation " , <nl> + ( " hipsparseCreateIdentityPermutation " , CONV_MATH_FUNC , API_SPARSE ) , <nl> + ) , <nl> + ( <nl> + " cusparseSetMatIndexBase " , <nl> + ( " hipsparseSetMatIndexBase " , CONV_MATH_FUNC , API_SPARSE ) , <nl> + ) , <nl> + ( " cusparseSetMatType " , ( " hipsparseSetMatType " , CONV_MATH_FUNC , API_SPARSE ) ) , <nl> + ( <nl> + " CUSPARSE_STATUS_SUCCESS " , <nl> + ( " HIPSPARSE_STATUS_SUCCESS " , CONV_NUMERIC_LITERAL , API_SPARSE ) , <nl> + ) , <nl> + ( <nl> + " CUSPARSE_STATUS_NOT_INITIALIZED " , <nl> + ( " HIPSPARSE_STATUS_NOT_INITIALIZED " , CONV_NUMERIC_LITERAL , API_SPARSE ) , <nl> + ) , <nl> + ( <nl> + " CUSPARSE_STATUS_ALLOC_FAILED " , <nl> + ( " HIPSPARSE_STATUS_ALLOC_FAILED " , CONV_NUMERIC_LITERAL , API_SPARSE ) , <nl> + ) , <nl> + ( <nl> + " CUSPARSE_STATUS_INVALID_VALUE " , <nl> + ( " HIPSPARSE_STATUS_INVALID_VALUE " , CONV_NUMERIC_LITERAL , API_SPARSE ) , <nl> + ) , <nl> + ( <nl> + " CUSPARSE_STATUS_MAPPING_ERROR " , <nl> + ( " HIPSPARSE_STATUS_MAPPING_ERROR " , CONV_NUMERIC_LITERAL , API_SPARSE ) , <nl> + ) , <nl> + ( <nl> + " CUSPARSE_STATUS_EXECUTION_FAILED " , <nl> + ( " HIPSPARSE_STATUS_EXECUTION_FAILED " , CONV_NUMERIC_LITERAL , API_SPARSE ) , <nl> + ) , <nl> + ( <nl> + " CUSPARSE_STATUS_INTERNAL_ERROR " , <nl> + ( " HIPSPARSE_STATUS_INTERNAL_ERROR " , CONV_NUMERIC_LITERAL , API_SPARSE ) , <nl> + ) , <nl> + ( <nl> + " CUSPARSE_STATUS_MATRIX_TYPE_NOT_SUPPORTED " , <nl> + ( <nl> + " HIPSPARSE_STATUS_MATRIX_TYPE_NOT_SUPPORTED " , <nl> + CONV_NUMERIC_LITERAL , <nl> + API_SPARSE , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CUSPARSE_STATUS_ARCH_MISMATCH " , <nl> + ( " HIPSPARSE_STATUS_ARCH_MISMATCH " , CONV_NUMERIC_LITERAL , API_SPARSE ) , <nl> + ) , <nl> + ( <nl> + " CUSPARSE_STATUS_ZERO_PIVOT " , <nl> + ( " HIPSPARSE_STATUS_ZERO_PIVOT " , CONV_NUMERIC_LITERAL , API_SPARSE ) , <nl> + ) , <nl> + ( <nl> + " CUSPARSE_OPERATION_TRANSPOSE " , <nl> + ( " HIPSPARSE_OPERATION_TRANSPOSE " , CONV_NUMERIC_LITERAL , API_SPARSE ) , <nl> + ) , <nl> + ( <nl> + " CUSPARSE_OPERATION_NON_TRANSPOSE " , <nl> + ( " HIPSPARSE_OPERATION_NON_TRANSPOSE " , CONV_NUMERIC_LITERAL , API_SPARSE ) , <nl> + ) , <nl> + ( <nl> + " CUSPARSE_OPERATION_CONJUGATE_TRANSPOSE " , <nl> + ( <nl> + " HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE " , <nl> + CONV_NUMERIC_LITERAL , <nl> + API_SPARSE , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CUSPARSE_INDEX_BASE_ZERO " , <nl> + ( " HIPSPARSE_INDEX_BASE_ZERO " , CONV_NUMERIC_LITERAL , API_SPARSE ) , <nl> + ) , <nl> + ( <nl> + " CUSPARSE_INDEX_BASE_ONE " , <nl> + ( " HIPSPARSE_INDEX_BASE_ONE " , CONV_NUMERIC_LITERAL , API_SPARSE ) , <nl> + ) , <nl> + ( <nl> + " CUSPARSE_MATRIX_TYPE_GENERAL " , <nl> + ( " HIPSPARSE_MATRIX_TYPE_GENERAL " , CONV_NUMERIC_LITERAL , API_SPARSE ) , <nl> + ) , <nl> + ] <nl> + ) <nl> + <nl> + PYTORCH_SPECIFIC_MAPPINGS = collections . OrderedDict ( <nl> + [ <nl> + ( " USE_CUDA " , ( " USE_ROCM " , API_PYTORCH ) ) , <nl> + ( " CUDA_VERSION " , ( " HIP_VERSION " , API_PYTORCH ) ) , <nl> + ( " cudaHostAllocator " , ( " hipHostAllocator " , API_PYTORCH ) ) , <nl> + ( " cudaDeviceAllocator " , ( " hipDeviceAllocator " , API_PYTORCH ) ) , <nl> + ( " define MAX_NUM_BLOCKS 200 " , ( " define MAX_NUM_BLOCKS 64 " , API_PYTORCH ) ) , <nl> + ( " cuda : : CUDAGuard " , ( " hip : : HIPGuardMasqueradingAsCUDA " , API_PYTORCH ) ) , <nl> + ( " CUDAGuard " , ( " HIPGuardMasqueradingAsCUDA " , API_PYTORCH ) ) , <nl> + ( <nl> + " cuda : : OptionalCUDAGuard " , <nl> + ( " hip : : OptionalHIPGuardMasqueradingAsCUDA " , API_PYTORCH ) , <nl> + ) , <nl> + ( " OptionalCUDAGuard " , ( " OptionalHIPGuardMasqueradingAsCUDA " , API_PYTORCH ) ) , <nl> + ( <nl> + " cuda : : CUDAStreamGuard " , <nl> + ( " hip : : HIPStreamGuardMasqueradingAsCUDA " , API_PYTORCH ) , <nl> + ) , <nl> + ( " CUDAStreamGuard " , ( " HIPStreamGuardMasqueradingAsCUDA " , API_PYTORCH ) ) , <nl> + ( <nl> + " cuda : : OptionalCUDAStreamGuard " , <nl> + ( " hip : : OptionalHIPStreamGuardMasqueradingAsCUDA " , API_PYTORCH ) , <nl> + ) , <nl> + ( <nl> + " OptionalCUDAStreamGuard " , <nl> + ( " OptionalHIPStreamGuardMasqueradingAsCUDA " , API_PYTORCH ) , <nl> + ) , <nl> + # Only get needs to be transformed this way ; all the other ones can go <nl> + # straight to the normal versions hip : : HIPCachingAllocator <nl> + ( <nl> + " cuda : : CUDACachingAllocator : : get " , <nl> + ( " hip : : HIPCachingAllocatorMasqueradingAsCUDA : : get " , API_PYTORCH ) , <nl> + ) , <nl> + ( <nl> + " CUDACachingAllocator : : get " , <nl> + ( " HIPCachingAllocatorMasqueradingAsCUDA : : get " , API_PYTORCH ) , <nl> + ) , <nl> + ( <nl> + " cuda : : CUDACachingAllocator : : recordStream " , <nl> + ( <nl> + " hip : : HIPCachingAllocatorMasqueradingAsCUDA : : recordStreamMasqueradingAsCUDA " , <nl> + API_PYTORCH , <nl> + ) , <nl> + ) , <nl> + ( <nl> + " CUDACachingAllocator : : recordStream " , <nl> + ( <nl> + " HIPCachingAllocatorMasqueradingAsCUDA : : recordStreamMasqueradingAsCUDA " , <nl> + API_PYTORCH , <nl> + ) , <nl> + ) , <nl> + ( " cuda : : CUDAStream " , ( " hip : : HIPStreamMasqueradingAsCUDA " , API_PYTORCH ) ) , <nl> + ( " CUDAStream " , ( " HIPStreamMasqueradingAsCUDA " , API_PYTORCH ) ) , <nl> + ( <nl> + " cuda : : getStreamFromPool " , <nl> + ( " hip : : getStreamFromPoolMasqueradingAsCUDA " , API_PYTORCH ) , <nl> + ) , <nl> + ( " getStreamFromPool " , ( " getStreamFromPoolMasqueradingAsCUDA " , API_PYTORCH ) ) , <nl> + ( <nl> + " cuda : : getDefaultCUDAStream " , <nl> + ( " hip : : getDefaultHIPStreamMasqueradingAsCUDA " , API_PYTORCH ) , <nl> + ) , <nl> + ( <nl> + " getDefaultCUDAStream " , <nl> + ( " getDefaultHIPStreamMasqueradingAsCUDA " , API_PYTORCH ) , <nl> + ) , <nl> + ( <nl> + " cuda : : getCurrentCUDAStream " , <nl> + ( " hip : : getCurrentHIPStreamMasqueradingAsCUDA " , API_PYTORCH ) , <nl> + ) , <nl> + ( <nl> + " getCurrentCUDAStream " , <nl> + ( " getCurrentHIPStreamMasqueradingAsCUDA " , API_PYTORCH ) , <nl> + ) , <nl> + ( <nl> + " cuda : : setCurrentCUDAStream " , <nl> + ( " hip : : setCurrentHIPStreamMasqueradingAsCUDA " , API_PYTORCH ) , <nl> + ) , <nl> + ( <nl> + " setCurrentCUDAStream " , <nl> + ( " setCurrentHIPStreamMasqueradingAsCUDA " , API_PYTORCH ) , <nl> + ) , <nl> + # TODO : Undo this special - case ; see the header for motivation behind this <nl> + # hack . It ' s VERY important this is only applied to PyTorch HIPify . <nl> + ( <nl> + " c10 / cuda / CUDAGuard . h " , <nl> + ( " ATen / hip / impl / HIPGuardImplMasqueradingAsCUDA . h " , API_PYTORCH ) , <nl> + ) , <nl> + ( <nl> + " c10 / cuda / CUDACachingAllocator . h " , <nl> + ( " ATen / hip / impl / HIPCachingAllocatorMasqueradingAsCUDA . h " , API_PYTORCH ) , <nl> + ) , <nl> + ( <nl> + " c10 / cuda / CUDAStream . h " , <nl> + ( " ATen / hip / impl / HIPStreamMasqueradingAsCUDA . h " , API_PYTORCH ) , <nl> + ) , <nl> + ( " gloo / cuda . h " , ( " gloo / hip . h " , API_PYTORCH ) ) , <nl> + ( <nl> + " gloo / cuda_allreduce_halving_doubling . h " , <nl> + ( " gloo / hip_allreduce_halving_doubling . h " , API_PYTORCH ) , <nl> + ) , <nl> + ( <nl> + " gloo / cuda_allreduce_halving_doubling_pipelined . h " , <nl> + ( " gloo / hip_allreduce_halving_doubling_pipelined . h " , API_PYTORCH ) , <nl> + ) , <nl> + ( " gloo / cuda_allreduce_ring . h " , ( " gloo / hip_allreduce_ring . h " , API_PYTORCH ) ) , <nl> + ( <nl> + " gloo / cuda_broadcast_one_to_all . h " , <nl> + ( " gloo / hip_broadcast_one_to_all . h " , API_PYTORCH ) , <nl> + ) , <nl> + ( <nl> + " gloo : : CudaAllreduceHalvingDoublingPipelined " , <nl> + ( " gloo : : HipAllreduceHalvingDoublingPipelined " , API_PYTORCH ) , <nl> + ) , <nl> + ( " gloo : : CudaBroadcastOneToAll " , ( " gloo : : HipBroadcastOneToAll " , API_PYTORCH ) ) , <nl> + ( " gloo : : CudaHostWorkspace " , ( " gloo : : HipHostWorkspace " , API_PYTORCH ) ) , <nl> + ( " gloo : : CudaDeviceWorkspace " , ( " gloo : : HipDeviceWorkspace " , API_PYTORCH ) ) , <nl> + ] <nl> + ) <nl> + <nl> + CAFFE2_SPECIFIC_MAPPINGS = collections . OrderedDict ( <nl> + [ <nl> + ( " cuda_stream " , ( " hip_stream " , API_CAFFE2 ) ) , <nl> + # if the header is a native hip folder ( under hip directory ) , <nl> + # there is no need to add a hip path to it ; the trie in hipify script <nl> + # takes this mapping order to forbid further replacement <nl> + ( " / hip / " , ( " / hip / " , API_CAFFE2 ) ) , <nl> + ( " / context_gpu " , ( " / hip / context_gpu " , API_CAFFE2 ) ) , <nl> + ( " / common_gpu " , ( " / hip / common_gpu " , API_CAFFE2 ) ) , <nl> + ( " / mixed_utils " , ( " / hip / mixed_utils " , API_CAFFE2 ) ) , <nl> + ( " / operator_fallback_gpu " , ( " / hip / operator_fallback_gpu " , API_CAFFE2 ) ) , <nl> + ( <nl> + " / spatial_batch_norm_op_impl " , <nl> + ( " / hip / spatial_batch_norm_op_impl " , API_CAFFE2 ) , <nl> + ) , <nl> + ( <nl> + " / recurrent_network_executor_gpu " , <nl> + ( " / hip / recurrent_network_executor_gpu " , API_CAFFE2 ) , <nl> + ) , <nl> + ( <nl> + " / generate_proposals_op_util_nms_gpu " , <nl> + ( " / hip / generate_proposals_op_util_nms_gpu " , API_CAFFE2 ) , <nl> + ) , <nl> + ( " / max_pool_with_index_gpu " , ( " / hip / max_pool_with_index_gpu " , API_CAFFE2 ) ) , <nl> + ( " / THCCachingAllocator_gpu " , ( " / hip / THCCachingAllocator_gpu " , API_CAFFE2 ) ) , <nl> + ( " / top_k_heap_selection " , ( " / hip / top_k_heap_selection " , API_CAFFE2 ) ) , <nl> + ( " / top_k_radix_selection " , ( " / hip / top_k_radix_selection " , API_CAFFE2 ) ) , <nl> + ( " / GpuDefs " , ( " / hip / GpuDefs " , API_CAFFE2 ) ) , <nl> + ( " / GpuScanUtils " , ( " / hip / GpuScanUtils " , API_CAFFE2 ) ) , <nl> + ( " / GpuBitonicSort " , ( " / hip / GpuBitonicSort " , API_CAFFE2 ) ) , <nl> + ( " / math / reduce . cuh " , ( " / math / hip / reduce . cuh " , API_CAFFE2 ) ) , <nl> + ( " / gather_op . cuh " , ( " / hip / gather_op . cuh " , API_CAFFE2 ) ) , <nl> + ( " caffe2 / core / common_cudnn . h " , ( " caffe2 / core / hip / common_miopen . h " , API_CAFFE2 ) ) , <nl> + ( " REGISTER_CUDA_OPERATOR " , ( " REGISTER_HIP_OPERATOR " , API_CAFFE2 ) ) , <nl> + ( " CUDA_1D_KERNEL_LOOP " , ( " HIP_1D_KERNEL_LOOP " , API_CAFFE2 ) ) , <nl> + ( " CUDAContext " , ( " HIPContext " , API_CAFFE2 ) ) , <nl> + ( " CAFFE_CUDA_NUM_THREADS " , ( " CAFFE_HIP_NUM_THREADS " , API_CAFFE2 ) ) , <nl> + ( " HasCudaGPU " , ( " HasHipGPU " , API_CAFFE2 ) ) , <nl> + ( " __expf " , ( " expf " , API_CAFFE2 ) ) , <nl> + ( " CUBLAS_ENFORCE " , ( " ROCBLAS_ENFORCE " , API_CAFFE2 ) ) , <nl> + ( " CUBLAS_CHECK " , ( " ROCBLAS_CHECK " , API_CAFFE2 ) ) , <nl> + ( " cublas_handle " , ( " rocblashandle " , API_CAFFE2 ) ) , <nl> + ( " CURAND_ENFORCE " , ( " HIPRAND_ENFORCE " , API_CAFFE2 ) ) , <nl> + ( " CURAND_CHECK " , ( " HIPRAND_CHECK " , API_CAFFE2 ) ) , <nl> + ( " curandGenerateUniform " , ( " hiprandGenerateUniform " , API_CAFFE2 ) ) , <nl> + ( " curand_generator " , ( " hiprand_generator " , API_CAFFE2 ) ) , <nl> + ( " CaffeCudaGetDevice " , ( " CaffeHipGetDevice " , API_CAFFE2 ) ) , <nl> + ( " CUDA " , ( " HIP " , API_CAFFE2 ) ) , <nl> + ( " Cuda " , ( " Hip " , API_CAFFE2 ) ) , <nl> + ( " cuda_ " , ( " hip_ " , API_CAFFE2 ) ) , <nl> + ( " _cuda " , ( " _hip " , API_CAFFE2 ) ) , <nl> + ( " CUDNN " , ( " MIOPEN " , API_CAFFE2 ) ) , <nl> + ( " CuDNN " , ( " MIOPEN " , API_CAFFE2 ) ) , <nl> + ( " cudnn " , ( " miopen " , API_CAFFE2 ) ) , <nl> + ( " namespace cuda " , ( " namespace hip " , API_CAFFE2 ) ) , <nl> + ( " cuda : : CUDAGuard " , ( " hip : : HIPGuard " , API_CAFFE2 ) ) , <nl> + ( " cuda : : OptionalCUDAGuard " , ( " hip : : OptionalHIPGuard " , API_CAFFE2 ) ) , <nl> + ( " cuda : : CUDAStreamGuard " , ( " hip : : HIPStreamGuard " , API_CAFFE2 ) ) , <nl> + ( " cuda : : OptionalCUDAStreamGuard " , ( " hip : : OptionalHIPStreamGuard " , API_CAFFE2 ) ) , <nl> + ( " c10 / cuda / CUDAGuard . h " , ( " c10 / hip / HIPGuard . h " , API_CAFFE2 ) ) , <nl> + ( " gloo / cuda " , ( " gloo / hip " , API_CAFFE2 ) ) , <nl> + ] <nl> + ) <nl> + <nl> + # We must tread very carefully here . Blanket conversions like are done <nl> + # in CAFFE2_SPECIFIC_MAPPINGS are not presently supported on PyTorch , <nl> + # because a regex for CUDA will also match a filename like CUDAGuard . h , <nl> + # but the HIPIFY script doesn ' t presently move the file and so the substitution <nl> + # will be invalid . Instead , we specifically list out every identifier <nl> + # and file from c10 / cuda which may be used externally , and do substitutions this <nl> + # way . <nl> + # <nl> + # NB : if you want a transformation to ONLY apply to the c10 / directory , <nl> + # put it as API_CAFFE2 <nl> + C10_MAPPINGS = collections . OrderedDict ( <nl> + [ <nl> + ( " cuda : : compat : : " , ( " hip : : compat : : " , API_C10 ) ) , <nl> + ( " c10 / cuda / CUDAException . h " , ( " c10 / hip / HIPException . h " , API_C10 ) ) , <nl> + ( " c10 / cuda / CUDAMacros . h " , ( " c10 / hip / HIPMacros . h " , API_C10 ) ) , <nl> + ( " c10 / cuda / CUDAMathCompat . h " , ( " c10 / hip / HIPMathCompat . h " , API_C10 ) ) , <nl> + ( " c10 / cuda / CUDAFunctions . h " , ( " c10 / hip / HIPFunctions . h " , API_C10 ) ) , <nl> + ( " c10 / cuda / CUDAStream . h " , ( " c10 / hip / HIPStream . h " , API_C10 ) ) , <nl> + ( " c10 / cuda / CUDACachingAllocator . h " , ( " c10 / hip / HIPCachingAllocator . h " , API_C10 ) ) , <nl> + ( " c10 / cuda / impl / CUDATest . h " , ( " c10 / hip / impl / HIPTest . h " , API_C10 ) ) , <nl> + ( " c10 / cuda / impl / CUDAGuardImpl . h " , ( " c10 / hip / impl / HIPGuardImpl . h " , API_C10 ) ) , <nl> + ( <nl> + " c10 / cuda / impl / cuda_cmake_macros . h " , <nl> + ( " c10 / hip / impl / hip_cmake_macros . h " , API_C10 ) , <nl> + ) , <nl> + ( " C10_CUDA_CHECK " , ( " C10_HIP_CHECK " , API_C10 ) ) , <nl> + ( " C10_CUDA_CHECK_WARN " , ( " C10_HIP_CHECK_WARN " , API_C10 ) ) , <nl> + ( " c10 : : cuda " , ( " c10 : : hip " , API_C10 ) ) , <nl> + ( " cuda : : CUDAStream " , ( " hip : : HIPStream " , API_C10 ) ) , <nl> + ( " CUDAStream " , ( " HIPStream " , API_C10 ) ) , <nl> + # This substitution is not permissible , because there ' s another copy of this <nl> + # function in torch / cuda . h <nl> + # ( " cuda : : device_count " , ( " hip : : device_count " , API_C10 ) ) , <nl> + ( " cuda : : current_device " , ( " hip : : current_device " , API_C10 ) ) , <nl> + ( " cuda : : set_device " , ( " hip : : set_device " , API_C10 ) ) , <nl> + ( " cuda : : getStreamFromPool " , ( " hip : : getStreamFromPool " , API_C10 ) ) , <nl> + ( " getStreamFromPool " , ( " getStreamFromPool " , API_C10 ) ) , <nl> + ( " cuda : : getDefaultCUDAStream " , ( " hip : : getDefaultHIPStream " , API_C10 ) ) , <nl> + ( " getDefaultCUDAStream " , ( " getDefaultHIPStream " , API_C10 ) ) , <nl> + ( " cuda : : getCurrentCUDAStream " , ( " hip : : getCurrentHIPStream " , API_C10 ) ) , <nl> + ( " getCurrentCUDAStream " , ( " getCurrentHIPStream " , API_C10 ) ) , <nl> + ( " cuda : : setCurrentCUDAStream " , ( " hip : : setCurrentHIPStream " , API_C10 ) ) , <nl> + ( " setCurrentCUDAStream " , ( " setCurrentHIPStream " , API_C10 ) ) , <nl> + ( " cuda : : CUDACachingAllocator " , ( " hip : : HIPCachingAllocator " , API_C10 ) ) , <nl> + ( " CUDACachingAllocator " , ( " HIPCachingAllocator " , API_C10 ) ) , <nl> + ] <nl> + ) <nl> + <nl> + # NB : C10 mappings are more specific than Caffe2 mappings , so run them <nl> + # first <nl> + CUDA_TO_HIP_MAPPINGS = [ <nl> + CUDA_IDENTIFIER_MAP , <nl> + CUDA_TYPE_NAME_MAP , <nl> + CUDA_INCLUDE_MAP , <nl> + CUDA_SPARSE_MAP , <nl> + C10_MAPPINGS , <nl> + PYTORCH_SPECIFIC_MAPPINGS , <nl> + CAFFE2_SPECIFIC_MAPPINGS , <nl> + ] <nl> similarity index 98 % <nl> rename from tools / amd_build / pyHIPIFY / hipify_python . py <nl> rename to torch / utils / hipify / hipify_python . py <nl> mmm a / tools / amd_build / pyHIPIFY / hipify_python . py <nl> ppp b / torch / utils / hipify / hipify_python . py <nl> <nl> import sys <nl> import os <nl> <nl> - from pyHIPIFY import constants <nl> - from pyHIPIFY . cuda_to_hip_mappings import CUDA_TO_HIP_MAPPINGS <nl> - from pyHIPIFY . cuda_to_hip_mappings import MATH_TRANSPILATIONS <nl> + from . import constants <nl> + from . cuda_to_hip_mappings import CUDA_TO_HIP_MAPPINGS <nl> + from . cuda_to_hip_mappings import MATH_TRANSPILATIONS <nl> <nl> # Hardcode the PyTorch template map <nl> " " " This dictionary provides the mapping from PyTorch kernel template types <nl> def find_parentheses_group ( input_string , start ) : <nl> <nl> <nl> def replace_math_functions ( input_string ) : <nl> - " " " FIXME : Temporarily replace std : : invocations of math functions with non - std : : versions to prevent linker errors <nl> - NOTE : This can lead to correctness issues when running tests , since the correct version of the math function ( exp / expf ) might not get called . <nl> - Plan is to remove this function once HIP supports std : : math function calls inside device code <nl> + " " " FIXME : Temporarily replace std : : invocations of math functions <nl> + with non - std : : versions to prevent linker errors NOTE : This <nl> + can lead to correctness issues when running tests , since the <nl> + correct version of the math function ( exp / expf ) might not get <nl> + called . Plan is to remove this function once HIP supports <nl> + std : : math function calls inside device code <nl> + <nl> " " " <nl> output_string = input_string <nl> for func in MATH_TRANSPILATIONS : <nl>
|
Move hipify to torch / utils to bundle them into torch package ( )
|
pytorch/pytorch
|
4bd8ae13c68644b977e10ab87ac57e7332fb7994
|
2019-10-08T00:25:45Z
|
mmm a / test / backward_compatibility / check_backward_compatibility . py <nl> ppp b / test / backward_compatibility / check_backward_compatibility . py <nl> <nl> ( " aten : : ifft " , datetime . date ( 2021 , 1 , 31 ) ) , <nl> ( " aten : : irfft " , datetime . date ( 2021 , 1 , 31 ) ) , <nl> ( " aten : : rfft " , datetime . date ( 2021 , 1 , 31 ) ) , <nl> + ( " aten : : quantile " , datetime . date ( 2021 , 1 , 31 ) ) , <nl> + ( " aten : : nanquantile " , datetime . date ( 2021 , 1 , 31 ) ) , <nl> ] <nl> <nl> def allow_listed ( schema , allow_list ) : <nl>
|
fix backwards compatibility for and its revert ( )
|
pytorch/pytorch
|
796b267763dee6e3451dacbf1c22c77b98ef91d9
|
2020-12-11T20:07:55Z
|
mmm a / tensorflow / tf_version_script . lds <nl> ppp b / tensorflow / tf_version_script . lds <nl> tensorflow { <nl> * tensorflow * ; <nl> * toco * ; <nl> * perftools * gputools * ; <nl> + * tf_ * ; <nl> * TF_ * ; <nl> * Eager * ; <nl> * TFE_ * ; <nl>
|
Export symbols with the characteristic ` tf_ ` like ` tf_git_version ` .
|
tensorflow/tensorflow
|
4a09b2febe2f76711d78628ffd791a3167ac8f8c
|
2020-03-03T18:37:10Z
|
mmm a / src / compiler / bytecode - graph - builder . cc <nl> ppp b / src / compiler / bytecode - graph - builder . cc <nl> void BytecodeGraphBuilder : : VisitInvokeIntrinsic ( ) { <nl> } <nl> <nl> void BytecodeGraphBuilder : : VisitThrow ( ) { <nl> - BuildLoopExitsForFunctionExit ( bytecode_analysis ( ) - > GetOutLivenessFor ( <nl> + BuildLoopExitsForFunctionExit ( bytecode_analysis ( ) - > GetInLivenessFor ( <nl> bytecode_iterator ( ) . current_offset ( ) ) ) ; <nl> Node * value = environment ( ) - > LookupAccumulator ( ) ; <nl> Node * call = NewNode ( javascript ( ) - > CallRuntime ( Runtime : : kThrow ) , value ) ; <nl> void BytecodeGraphBuilder : : VisitThrow ( ) { <nl> } <nl> <nl> void BytecodeGraphBuilder : : VisitAbort ( ) { <nl> - BuildLoopExitsForFunctionExit ( bytecode_analysis ( ) - > GetOutLivenessFor ( <nl> + BuildLoopExitsForFunctionExit ( bytecode_analysis ( ) - > GetInLivenessFor ( <nl> bytecode_iterator ( ) . current_offset ( ) ) ) ; <nl> BailoutReason reason = <nl> static_cast < BailoutReason > ( bytecode_iterator ( ) . GetIndexOperand ( 0 ) ) ; <nl> void BytecodeGraphBuilder : : VisitAbort ( ) { <nl> } <nl> <nl> void BytecodeGraphBuilder : : VisitReThrow ( ) { <nl> - BuildLoopExitsForFunctionExit ( bytecode_analysis ( ) - > GetOutLivenessFor ( <nl> + BuildLoopExitsForFunctionExit ( bytecode_analysis ( ) - > GetInLivenessFor ( <nl> bytecode_iterator ( ) . current_offset ( ) ) ) ; <nl> Node * value = environment ( ) - > LookupAccumulator ( ) ; <nl> NewNode ( javascript ( ) - > CallRuntime ( Runtime : : kReThrow ) , value ) ; <nl>
|
[ Turbofan ] Fix incorrect liveness in VisitThrow
|
v8/v8
|
44d71893ffe1f759dc166c48dbb97a38cda92087
|
2017-11-28T20:46:00Z
|
mmm a / include / swift / AST / DiagnosticsSema . def <nl> ppp b / include / swift / AST / DiagnosticsSema . def <nl> ERROR ( implementation_only_override_import_without_attr , none , <nl> / / Derived conformances <nl> ERROR ( cannot_synthesize_init_in_extension_of_nonfinal , none , <nl> " implementation of % 0 for non - final class cannot be automatically " <nl> - " synthesized in extension because initializer requirement % 1 can only be " <nl> + " synthesized in extension because initializer requirement % 1 can only " <nl> " be satisfied by a ' required ' initializer in the class definition " , <nl> ( Type , DeclName ) ) <nl> ERROR ( cannot_synthesize_in_crossfile_extension , none , <nl> mmm a / test / decl / protocol / special / coding / class_codable_failure_diagnostics . swift <nl> ppp b / test / decl / protocol / special / coding / class_codable_failure_diagnostics . swift <nl> class C6 : Codable { <nl> / / Non - final classes cannot synthesize Decodable in an extension . <nl> class C7 { } <nl> extension C7 : Decodable { } <nl> - / / expected - error @ - 1 { { implementation of ' Decodable ' for non - final class cannot be automatically synthesized in extension because initializer requirement ' init ( from : ) ' can only be be satisfied by a ' required ' initializer in the class definition } } <nl> + / / expected - error @ - 1 { { implementation of ' Decodable ' for non - final class cannot be automatically synthesized in extension because initializer requirement ' init ( from : ) ' can only be satisfied by a ' required ' initializer in the class definition } } <nl> <nl> / / Check that the diagnostics from an extension end up on the extension <nl> class C8 { <nl> mmm a / test / decl / protocol / special / coding / class_codable_simple_conditional . swift <nl> ppp b / test / decl / protocol / special / coding / class_codable_simple_conditional . swift <nl> class Conditional < T > { <nl> } <nl> <nl> extension Conditional : Codable where T : Codable { / / expected - note 2 { { where ' T ' = ' Nonconforming ' } } <nl> - / / expected - error @ - 1 2 { { implementation of ' Decodable ' for non - final class cannot be automatically synthesized in extension because initializer requirement ' init ( from : ) ' can only be be satisfied by a ' required ' initializer in the class definition } } <nl> + / / expected - error @ - 1 2 { { implementation of ' Decodable ' for non - final class cannot be automatically synthesized in extension because initializer requirement ' init ( from : ) ' can only be satisfied by a ' required ' initializer in the class definition } } <nl> } <nl> <nl> / / They should receive synthesized init ( from : ) and an encode ( to : ) . <nl> mmm a / test / decl / protocol / special / coding / class_codable_simple_conditional_separate . swift <nl> ppp b / test / decl / protocol / special / coding / class_codable_simple_conditional_separate . swift <nl> extension Conditional : Encodable where T : Encodable { / / expected - note { { where ' <nl> } <nl> <nl> extension Conditional : Decodable where T : Decodable { <nl> - / / expected - error @ - 1 2 { { implementation of ' Decodable ' for non - final class cannot be automatically synthesized in extension because initializer requirement ' init ( from : ) ' can only be be satisfied by a ' required ' initializer in the class definition } } <nl> + / / expected - error @ - 1 2 { { implementation of ' Decodable ' for non - final class cannot be automatically synthesized in extension because initializer requirement ' init ( from : ) ' can only be satisfied by a ' required ' initializer in the class definition } } <nl> } <nl> <nl> struct OnlyEnc : Encodable { } <nl> mmm a / test / decl / protocol / special / coding / class_codable_simple_extension . swift <nl> ppp b / test / decl / protocol / special / coding / class_codable_simple_extension . swift <nl> class SimpleClass { / / expected - note { { did you mean ' init ' ? } } <nl> } <nl> } <nl> <nl> - extension SimpleClass : Codable { } / / expected - error 2 { { implementation of ' Decodable ' for non - final class cannot be automatically synthesized in extension because initializer requirement ' init ( from : ) ' can only be be satisfied by a ' required ' initializer in the class definition } } <nl> + extension SimpleClass : Codable { } / / expected - error 2 { { implementation of ' Decodable ' for non - final class cannot be automatically synthesized in extension because initializer requirement ' init ( from : ) ' can only be satisfied by a ' required ' initializer in the class definition } } <nl> <nl> / / They should not receive synthesized init ( from : ) , but should receive an encode ( to : ) . <nl> let _ = SimpleClass . init ( from : ) / / expected - error { { type ' SimpleClass ' has no member ' init ( from : ) ' } } <nl>
|
[ Gardening ] Fix repeated word in diagnostic message
|
apple/swift
|
6d12fa0a830753183af35762eac3ea7a4feed962
|
2020-05-01T22:10:13Z
|
mmm a / src / library_html5 . js <nl> ppp b / src / library_html5 . js <nl> var LibraryJSEvents = { <nl> / / Track in this field whether we have yet registered that __ATEXIT__ handler . <nl> removeEventListenersRegistered : false , <nl> <nl> + _onGamepadConnected : function ( ) { + + JSEvents . numGamepadsConnected ; } , <nl> + _onGamepadDisconnected : function ( ) { - - JSEvents . numGamepadsConnected ; } , <nl> + <nl> staticInit : function ( ) { <nl> if ( typeof window ! = = ' undefined ' ) { <nl> - window . addEventListener ( " gamepadconnected " , function ( ) { + + JSEvents . numGamepadsConnected ; } ) ; <nl> - window . addEventListener ( " gamepaddisconnected " , function ( ) { - - JSEvents . numGamepadsConnected ; } ) ; <nl> + window . addEventListener ( " gamepadconnected " , JSEvents . _onGamepadConnected ) ; <nl> + window . addEventListener ( " gamepaddisconnected " , JSEvents . _onGamepadDisconnected ) ; <nl> <nl> / / Chromium does not fire the gamepadconnected event on reload , so we need to get the number of gamepads here as a workaround . <nl> / / See https : / / bugs . chromium . org / p / chromium / issues / detail ? id = 502824 <nl> var LibraryJSEvents = { <nl> } <nl> } , <nl> <nl> + removeAllEventListeners : function ( ) { <nl> + for ( var i = JSEvents . eventHandlers . length - 1 ; i > = 0 ; - - i ) { <nl> + JSEvents . _removeHandler ( i ) ; <nl> + } <nl> + JSEvents . eventHandlers = [ ] ; <nl> + JSEvents . deferredCalls = [ ] ; <nl> + window . removeEventListener ( " gamepadconnected " , JSEvents . _onGamepadConnected ) ; <nl> + window . removeEventListener ( " gamepaddisconnected " , JSEvents . _onGamepadDisconnected ) ; <nl> + } , <nl> + <nl> registerRemoveEventListeners : function ( ) { <nl> if ( ! JSEvents . removeEventListenersRegistered ) { <nl> - __ATEXIT__ . push ( function ( ) { <nl> - for ( var i = JSEvents . eventHandlers . length - 1 ; i > = 0 ; - - i ) { <nl> - JSEvents . _removeHandler ( i ) ; <nl> - } <nl> - } ) ; <nl> + __ATEXIT__ . push ( JSEvents . removeAllEventListeners ) ; <nl> JSEvents . removeEventListenersRegistered = true ; <nl> } <nl> } , <nl> var LibraryJSEvents = { <nl> } <nl> <nl> return { { { cDefine ( ' EMSCRIPTEN_RESULT_SUCCESS ' ) } } } ; <nl> + } , <nl> + <nl> + emscripten_html5_remove_all_event_listeners : function ( ) { <nl> + JSEvents . removeAllEventListeners ( ) ; <nl> } <nl> } ; <nl> <nl> mmm a / system / include / emscripten / html5 . h <nl> ppp b / system / include / emscripten / html5 . h <nl> extern EMSCRIPTEN_RESULT emscripten_get_canvas_element_size ( const char * target , <nl> extern EMSCRIPTEN_RESULT emscripten_set_element_css_size ( const char * target , double width , double height ) ; <nl> extern EMSCRIPTEN_RESULT emscripten_get_element_css_size ( const char * target , double * width , double * height ) ; <nl> <nl> + extern void emscripten_html5_remove_all_event_listeners ( void ) ; <nl> + <nl> # define EM_CALLBACK_THREAD_CONTEXT_MAIN_BROWSER_THREAD ( ( pthread_t ) 0x1 ) <nl> # define EM_CALLBACK_THREAD_CONTEXT_CALLING_THREAD ( ( pthread_t ) 0x2 ) <nl> <nl> mmm a / tests / test_html5 . c <nl> ppp b / tests / test_html5 . c <nl> void mainloop ( ) <nl> # ifdef REPORT_RESULT <nl> void report_result ( void * arg ) <nl> { <nl> + emscripten_html5_remove_all_event_listeners ( ) ; <nl> REPORT_RESULT ( 0 ) ; <nl> } <nl> # endif <nl> int main ( ) <nl> / * For the events to function , one must either call emscripten_set_main_loop or enable Module . noExitRuntime by some other means . <nl> Otherwise the application will exit after leaving main ( ) , and the atexit handlers will clean up all event hooks ( by design ) . * / <nl> EM_ASM ( Module [ ' noExitRuntime ' ] = true ) ; <nl> - <nl> + <nl> # ifdef REPORT_RESULT <nl> / / Keep the page running for a moment . <nl> emscripten_async_call ( report_result , 0 , 5000 ) ; <nl> mmm a / tests / test_other . py <nl> ppp b / tests / test_other . py <nl> def test ( filename , expectations ) : <nl> 0 , [ ] , [ ] , 8 , 0 , 0 , 0 ) , # noqa ; totally empty ! <nl> # but we don ' t metadce with linkable code ! other modules may want it <nl> ( [ ' - O3 ' , ' - s ' , ' MAIN_MODULE = 1 ' ] , <nl> - 1493 , [ ] , [ ] , 226057 , 30 , 75 , None ) , # noqa ; don ' t compare the # of functions in a main module , which changes a lot <nl> + 1494 , [ ] , [ ] , 226057 , 30 , 75 , None ) , # noqa ; don ' t compare the # of functions in a main module , which changes a lot <nl> ] ) # noqa <nl> <nl> print ( ' test on a minimal pure computational thing ' ) <nl>
|
Merge pull request from juj / manual_html5_event_unloading
|
emscripten-core/emscripten
|
3efad6bd6e6bc2df08c8f15becdebc9052f9735d
|
2018-11-04T13:57:38Z
|
mmm a / src / objective - c / GRPCClient / private / GRPCWrappedCall . m <nl> ppp b / src / objective - c / GRPCClient / private / GRPCWrappedCall . m <nl> - ( void ) startBatchWithOperations : ( NSArray * ) operations errorHandler : ( void ( ^ ) ( vo <nl> gpr_free ( ops_array ) ; <nl> <nl> NSAssert ( error = = GRPC_CALL_OK , @ " Error starting a batch of operations : % i " , error ) ; <nl> + / / To avoid compiler complaint when NSAssert is disabled . <nl> + if ( error ! = GRPC_CALL_OK ) { <nl> + return ; <nl> + } <nl> } <nl> } <nl> } <nl> mmm a / src / objective - c / ProtoRPC / ProtoService . h <nl> ppp b / src / objective - c / ProtoRPC / ProtoService . h <nl> <nl> @ class GRPCProtoCall ; <nl> @ class GRPCUnaryProtoCall ; <nl> @ class GRPCStreamingProtoCall ; <nl> - @ protocol GRPCProtoResponseCallbacks ; <nl> + @ protocol GRPCProtoResponseHandler ; <nl> <nl> # pragma clang diagnostic push <nl> # pragma clang diagnostic ignored " - Wnullability - completeness " <nl> __attribute__ ( ( deprecated ( " Please use GRPCProtoService . " ) ) ) @ interface ProtoServ <nl> <nl> - ( nullable GRPCUnaryProtoCall * ) RPCToMethod : ( nonnull NSString * ) method <nl> message : ( nonnull id ) message <nl> - responseHandler : ( nonnull id < GRPCProtoResponseCallbacks > ) handler <nl> + responseHandler : ( nonnull id < GRPCProtoResponseHandler > ) handler <nl> callOptions : ( nullable GRPCCallOptions * ) callOptions <nl> responseClass : ( nonnull Class ) responseClass ; <nl> <nl> - ( nullable GRPCStreamingProtoCall * ) RPCToMethod : ( nonnull NSString * ) method <nl> - responseHandler : ( nonnull id < GRPCProtoResponseCallbacks > ) handler <nl> + responseHandler : ( nonnull id < GRPCProtoResponseHandler > ) handler <nl> callOptions : ( nullable GRPCCallOptions * ) callOptions <nl> responseClass : ( nonnull Class ) responseClass ; <nl> <nl> mmm a / src / objective - c / ProtoRPC / ProtoService . m <nl> ppp b / src / objective - c / ProtoRPC / ProtoService . m <nl> - ( instancetype ) initWithHost : ( NSString * ) host <nl> return self ; <nl> } <nl> <nl> + # pragma clang diagnostic push <nl> + # pragma clang diagnostic ignored " - Wobjc - designated - initializers " <nl> + / / Do not call designated initializer here due to nullability incompatibility . This method is from <nl> + / / old API and does not assert on nullability of the parameters . <nl> + <nl> - ( instancetype ) initWithHost : ( NSString * ) host <nl> packageName : ( NSString * ) packageName <nl> serviceName : ( NSString * ) serviceName { <nl> - / / Do not call designated initializer here due to nullability incompatibility . This method is from <nl> - / / old API and does not assert on nullability of the parameters . <nl> if ( ( self = [ super init ] ) ) { <nl> _host = [ host copy ] ; <nl> _packageName = [ packageName copy ] ; <nl> - ( instancetype ) initWithHost : ( NSString * ) host <nl> return self ; <nl> } <nl> <nl> + # pragma clang diagnostic pop <nl> + <nl> - ( GRPCProtoCall * ) RPCToMethod : ( NSString * ) method <nl> requestsWriter : ( GRXWriter * ) requestsWriter <nl> responseClass : ( Class ) responseClass <nl> - ( GRPCProtoCall * ) RPCToMethod : ( NSString * ) method <nl> <nl> - ( GRPCUnaryProtoCall * ) RPCToMethod : ( NSString * ) method <nl> message : ( id ) message <nl> - responseHandler : ( id < GRPCProtoResponseCallbacks > ) handler <nl> + responseHandler : ( id < GRPCProtoResponseHandler > ) handler <nl> callOptions : ( GRPCCallOptions * ) callOptions <nl> responseClass : ( Class ) responseClass { <nl> GRPCProtoMethod * methodName = <nl> - ( GRPCUnaryProtoCall * ) RPCToMethod : ( NSString * ) method <nl> } <nl> <nl> - ( GRPCStreamingProtoCall * ) RPCToMethod : ( NSString * ) method <nl> - responseHandler : ( id < GRPCProtoResponseCallbacks > ) handler <nl> + responseHandler : ( id < GRPCProtoResponseHandler > ) handler <nl> callOptions : ( GRPCCallOptions * ) callOptions <nl> responseClass : ( Class ) responseClass { <nl> GRPCProtoMethod * methodName = <nl>
|
Batch fix
|
grpc/grpc
|
c5f84c5cb8830ad5ac4a9f097804308adce204be
|
2018-12-19T22:09:56Z
|
mmm a / tools / gce_setup / grpc_docker . sh <nl> ppp b / tools / gce_setup / grpc_docker . sh <nl> grpc_interop_gen_python_cmd ( ) { <nl> echo $ the_cmd <nl> } <nl> <nl> + # constructs the full dockerized python interop test cmd . <nl> + # <nl> + # call - seq : <nl> + # flags = . . . . # generic flags to include the command <nl> + # cmd = $ ( $ grpc_gen_test_cmd $ flags ) <nl> + grpc_cloud_prod_gen_python_cmd ( ) { <nl> + local cmd_prefix = " sudo docker run grpc / python bin / bash - l - c " <nl> + local gfe_flags = $ ( _grpc_prod_gfe_flags ) <nl> + local env_prefix = " SSL_CERT_FILE = / cacerts / roots . pem " <nl> + local the_cmd = " $ cmd_prefix ' $ env_prefix python - B - m interop . client - - use_tls $ gfe_flags $ @ ' " <nl> + echo $ the_cmd <nl> + } <nl> + <nl> # constructs the full dockerized python service_account auth interop test cmd . <nl> # <nl> # call - seq : <nl>
|
Add Python cloud prod gen interop command
|
grpc/grpc
|
b553476be70475dc96f4684b05db3957a6f6e54f
|
2015-04-14T22:16:31Z
|
mmm a / js / apps / system / aardvark / frontend / js / modules / org / arangodb / arango - collection . js <nl> ppp b / js / apps / system / aardvark / frontend / js / modules / org / arangodb / arango - collection . js <nl> ArangoCollection . prototype . properties = function ( properties ) { <nl> var attributes = { <nl> " doCompact " : true , <nl> " journalSize " : true , <nl> + " isVolatile " : false , <nl> " waitForSync " : true , <nl> " shardKeys " : false , <nl> " numberOfShards " : false , <nl> ArangoCollection . prototype . properties = function ( properties ) { <nl> <nl> var result = { } ; <nl> for ( a in attributes ) { <nl> - if ( attributes . hasOwnProperty ( a ) & & requestResult . hasOwnProperty ( a ) ) { <nl> + if ( attributes . hasOwnProperty ( a ) & & <nl> + requestResult . hasOwnProperty ( a ) & & <nl> + requestResult [ a ] ! = = undefined ) { <nl> result [ a ] = requestResult [ a ] ; <nl> } <nl> } <nl> <nl> - if ( requestResult . keyOptions ! = = undefined ) { <nl> - result . keyOptions = requestResult . keyOptions ; <nl> - } <nl> - <nl> return result ; <nl> } ; <nl> <nl> mmm a / js / client / modules / org / arangodb / arango - collection . js <nl> ppp b / js / client / modules / org / arangodb / arango - collection . js <nl> ArangoCollection . prototype . properties = function ( properties ) { <nl> var attributes = { <nl> " doCompact " : true , <nl> " journalSize " : true , <nl> + " isVolatile " : false , <nl> " waitForSync " : true , <nl> " shardKeys " : false , <nl> " numberOfShards " : false , <nl> ArangoCollection . prototype . properties = function ( properties ) { <nl> <nl> var result = { } ; <nl> for ( a in attributes ) { <nl> - if ( attributes . hasOwnProperty ( a ) & & requestResult . hasOwnProperty ( a ) ) { <nl> + if ( attributes . hasOwnProperty ( a ) & & <nl> + requestResult . hasOwnProperty ( a ) & & <nl> + requestResult [ a ] ! = = undefined ) { <nl> result [ a ] = requestResult [ a ] ; <nl> } <nl> } <nl> <nl> - if ( requestResult . keyOptions ! = = undefined ) { <nl> - result . keyOptions = requestResult . keyOptions ; <nl> - } <nl> - <nl> return result ; <nl> } ; <nl> <nl>
|
re - added isvolatile to result
|
arangodb/arangodb
|
028bf5b94b169473240805a93b11bb4c547b0e6e
|
2014-02-26T12:06:14Z
|
mmm a / R - package / DESCRIPTION <nl> ppp b / R - package / DESCRIPTION <nl> Date : 2014 - 08 - 23 <nl> Author : Tianqi Chen , Tong He <nl> Maintainer : Tianqi Chen < tianqi . tchen @ gmail . com > , Tong He < hetong007 @ gmail . com > <nl> Description : xgboost <nl> - License : See LICENSE file <nl> + License : See LICENSE file in the project root <nl> URL : https : / / github . com / tqchen / xgboost <nl> BugReports : https : / / github . com / tqchen / xgboost / issues <nl> Depends : <nl>
|
Update DESCRIPTION
|
dmlc/xgboost
|
077c5561796baf1cc4fc497104e6d22c401a24ff
|
2014-08-28T04:34:41Z
|
mmm a / arangod / RestHandler / RestDocumentHandler . cpp <nl> ppp b / arangod / RestHandler / RestDocumentHandler . cpp <nl> bool RestDocumentHandler : : createDocument ( ) { <nl> int res = useCollection ( collection , getCollectionType ( ) , create ) ; <nl> <nl> if ( res ! = TRI_ERROR_NO_ERROR ) { <nl> + / / error is already generated by useCollection ! <nl> return false ; <nl> } <nl> <nl> bool RestDocumentHandler : : createDocument ( ) { <nl> bool waitForSync = _documentCollection - > base . _waitForSync ; <nl> TRI_voc_cid_t cid = _documentCollection - > base . _cid ; <nl> <nl> - / / note : unlocked is performed by createJson ( ) <nl> + / / unlocking is performed in createJson ( ) <nl> TRI_doc_mptr_t const mptr = _documentCollection - > createJson ( _documentCollection , TRI_DOC_MARKER_DOCUMENT , json , 0 , reuseId , true ) ; <nl> <nl> / / . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . <nl> bool RestDocumentHandler : : readSingleDocument ( bool generateBody ) { <nl> int res = useCollection ( collection , getCollectionType ( ) ) ; <nl> <nl> if ( res ! = TRI_ERROR_NO_ERROR ) { <nl> + / / error is already generated by useCollection ! <nl> return false ; <nl> } <nl> <nl> bool RestDocumentHandler : : readAllDocuments ( ) { <nl> int res = useCollection ( collection , getCollectionType ( ) ) ; <nl> <nl> if ( res ! = TRI_ERROR_NO_ERROR ) { <nl> + / / error is already generated by useCollection ! <nl> return false ; <nl> } <nl> <nl> bool RestDocumentHandler : : modifyDocument ( bool isPatch ) { <nl> / / auto - ptr that will free JSON data when scope is left <nl> JsonContainer container ( TRI_UNKNOWN_MEM_ZONE , parseJsonBody ( ) ) ; <nl> TRI_json_t * json = container . ptr ( ) ; <nl> + <nl> if ( json = = 0 ) { <nl> return false ; <nl> } <nl> bool RestDocumentHandler : : modifyDocument ( bool isPatch ) { <nl> int res = useCollection ( collection , getCollectionType ( ) ) ; <nl> <nl> if ( res ! = TRI_ERROR_NO_ERROR ) { <nl> + / / error is already generated by useCollection ! <nl> return false ; <nl> } <nl> <nl> bool RestDocumentHandler : : deleteDocument ( ) { <nl> int res = useCollection ( collection , getCollectionType ( ) ) ; <nl> <nl> if ( res ! = TRI_ERROR_NO_ERROR ) { <nl> + / / error is already generated by useCollection ! <nl> return false ; <nl> } <nl> <nl> mmm a / arangod / RestHandler / RestEdgeHandler . cpp <nl> ppp b / arangod / RestHandler / RestEdgeHandler . cpp <nl> bool RestEdgeHandler : : createDocument ( ) { <nl> int res = useCollection ( collection , getCollectionType ( ) , create ) ; <nl> <nl> if ( res ! = TRI_ERROR_NO_ERROR ) { <nl> + / / error is already generated by useCollection ! <nl> return false ; <nl> } <nl> <nl> mmm a / arangod / RestHandler / RestVocbaseBaseHandler . cpp <nl> ppp b / arangod / RestHandler / RestVocbaseBaseHandler . cpp <nl> int RestVocbaseBaseHandler : : useCollection ( string const & name , <nl> int res = TRI_UseCollectionVocBase ( _vocbase , const_cast < TRI_vocbase_col_s * > ( _collection ) ) ; <nl> <nl> if ( res = = TRI_ERROR_NO_ERROR ) { <nl> + / / when we get here , this will have acquired the read - lock TRI_READ_LOCK_STATUS_VOCBASE_COL ( collection ) <nl> + / / that must later be unlocked by the caller <nl> assert ( _collection ! = 0 ) ; <nl> <nl> _documentCollection = _collection - > _collection ; <nl> assert ( _documentCollection ! = 0 ) ; <nl> } <nl> + else { <nl> + / / reset collection to 0 , otherwise the read - lock would be released later and this would be invalid <nl> + _collection = 0 ; <nl> + generateError ( HttpResponse : : SERVER_ERROR , res ) ; <nl> + } <nl> <nl> return res ; <nl> } <nl> mmm a / arangod / V8Server / v8 - vocbase . cpp <nl> ppp b / arangod / V8Server / v8 - vocbase . cpp <nl> static v8 : : Handle < v8 : : Value > EnsureGeoIndexVocbaseCol ( v8 : : Arguments const & argv <nl> TRI_json_t * json = idx - > json ( idx , collection - > _collection ) ; <nl> <nl> if ( ! json ) { <nl> + TRI_ReleaseCollection ( collection ) ; <nl> return scope . Close ( v8 : : ThrowException ( v8 : : String : : New ( " out of memory " ) ) ) ; <nl> } <nl> <nl>
|
fixed some edge cases in which no proper error messages got generated
|
arangodb/arangodb
|
c1d08176b551a1e910342ba23c5e4f12d22a139b
|
2012-09-05T13:41:19Z
|
mmm a / src / core / grabber / include / manipulator / details / basic . hpp <nl> ppp b / src / core / grabber / include / manipulator / details / basic . hpp <nl> class basic final : public base { <nl> original_event_ = = other . original_event_ ; <nl> } <nl> <nl> + friend size_t hash_value ( const from_event & value ) { <nl> + size_t h = 0 ; <nl> + boost : : hash_combine ( h , value . device_id_ ) ; <nl> + boost : : hash_combine ( h , value . original_event_ ) ; <nl> + return h ; <nl> + } <nl> + <nl> private : <nl> device_id device_id_ ; <nl> event_queue : : queued_event : : event original_event_ ; <nl> } ; <nl> <nl> + struct from_event_hash final { <nl> + std : : size_t operator ( ) ( const from_event & v ) const noexcept { <nl> + return hash_value ( v ) ; <nl> + } <nl> + } ; <nl> + <nl> class events_at_key_up final { <nl> public : <nl> class entry { <nl> class basic final : public base { <nl> std : : vector < entry > events_ ; <nl> } ; <nl> <nl> - manipulated_original_event ( const from_event & from_event , <nl> + manipulated_original_event ( const std : : unordered_set < from_event , from_event_hash > & from_events , <nl> const std : : unordered_set < modifier_flag > & from_mandatory_modifiers , <nl> - uint64_t key_down_time_stamp ) : from_event_ ( from_event ) , <nl> + uint64_t key_down_time_stamp ) : from_events_ ( from_events ) , <nl> from_mandatory_modifiers_ ( from_mandatory_modifiers ) , <nl> from_mandatory_modifiers_restored_ ( false ) , <nl> key_down_time_stamp_ ( key_down_time_stamp ) , <nl> alone_ ( true ) { <nl> } <nl> <nl> - const from_event & get_from_event ( void ) const { <nl> - return from_event_ ; <nl> + const std : : unordered_set < from_event , from_event_hash > & get_from_events ( void ) const { <nl> + return from_events_ ; <nl> } <nl> <nl> const std : : unordered_set < modifier_flag > & get_from_mandatory_modifiers ( void ) const { <nl> class basic final : public base { <nl> alone_ = false ; <nl> } <nl> <nl> + void erase_from_events_by_device_id ( device_id device_id ) { <nl> + for ( auto it = std : : begin ( from_events_ ) ; it ! = std : : end ( from_events_ ) ; ) { <nl> + if ( it - > get_device_id ( ) = = device_id ) { <nl> + it = from_events_ . erase ( it ) ; <nl> + } else { <nl> + std : : advance ( it , 1 ) ; <nl> + } <nl> + } <nl> + } <nl> + <nl> bool operator = = ( const manipulated_original_event & other ) const { <nl> / / Do not compare ` from_mandatory_modifiers_ ` . <nl> - return from_event_ = = other . from_event_ ; <nl> + return from_events_ = = other . from_events_ ; <nl> } <nl> <nl> private : <nl> - from_event from_event_ ; <nl> + std : : unordered_set < from_event , from_event_hash > from_events_ ; <nl> std : : unordered_set < modifier_flag > from_mandatory_modifiers_ ; <nl> bool from_mandatory_modifiers_restored_ ; <nl> uint64_t key_down_time_stamp_ ; <nl> class basic final : public base { <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> <nl> if ( is_target ) { <nl> - manipulated_original_event : : from_event from_event ( front_input_event . get_device_id ( ) , <nl> - front_input_event . get_original_event ( ) ) ; <nl> - current_manipulated_original_event = std : : make_shared < manipulated_original_event > ( from_event , <nl> + std : : unordered_set < manipulated_original_event : : from_event , manipulated_original_event : : from_event_hash > from_events ( { <nl> + manipulated_original_event : : from_event ( front_input_event . get_device_id ( ) , <nl> + front_input_event . get_original_event ( ) ) , <nl> + } ) ; <nl> + current_manipulated_original_event = std : : make_shared < manipulated_original_event > ( from_events , <nl> from_mandatory_modifiers , <nl> front_input_event . get_time_stamp ( ) ) ; <nl> manipulated_original_events_ . push_back ( current_manipulated_original_event ) ; <nl> class basic final : public base { <nl> auto it = std : : find_if ( std : : begin ( manipulated_original_events_ ) , <nl> std : : end ( manipulated_original_events_ ) , <nl> [ & ] ( const auto & manipulated_original_event ) { <nl> - return manipulated_original_event - > get_from_event ( ) = = from_event ; <nl> + auto & from_events = manipulated_original_event - > get_from_events ( ) ; <nl> + return from_events . find ( from_event ) ! = std : : end ( from_events ) ; <nl> } ) ; <nl> if ( it ! = std : : end ( manipulated_original_events_ ) ) { <nl> current_manipulated_original_event = * it ; <nl> class basic final : public base { <nl> virtual void handle_device_ungrabbed_event ( device_id device_id , <nl> const event_queue & output_event_queue , <nl> uint64_t time_stamp ) { <nl> + for ( auto & & e : manipulated_original_events_ ) { <nl> + e - > erase_from_events_by_device_id ( device_id ) ; <nl> + } <nl> + <nl> manipulated_original_events_ . erase ( std : : remove_if ( std : : begin ( manipulated_original_events_ ) , <nl> std : : end ( manipulated_original_events_ ) , <nl> [ & ] ( const auto & e ) { <nl> - return e - > get_from_event ( ) . get_device_id ( ) = = device_id ; <nl> + return e - > get_from_events ( ) . empty ( ) ; <nl> } ) , <nl> std : : end ( manipulated_original_events_ ) ) ; <nl> } <nl>
|
from_event - > from_events_
|
pqrs-org/Karabiner-Elements
|
6fc597df798e1567191786a811c77dc187680603
|
2018-02-07T16:00:41Z
|
mmm a / dbms / src / Common / ThreadStatus . h <nl> ppp b / dbms / src / Common / ThreadStatus . h <nl> class ThreadGroupStatus <nl> InternalTextLogsQueueWeakPtr logs_queue_ptr ; <nl> <nl> std : : vector < UInt32 > thread_numbers ; <nl> + std : : vector < UInt32 > os_thread_ids ; <nl> <nl> / / / The first thread created this thread group <nl> UInt32 master_thread_number = 0 ; <nl> mmm a / dbms / src / Interpreters / ProcessList . cpp <nl> ppp b / dbms / src / Interpreters / ProcessList . cpp <nl> QueryStatusInfo QueryStatus : : getInfo ( bool get_thread_list , bool get_profile_even <nl> { <nl> std : : lock_guard lock ( thread_group - > mutex ) ; <nl> res . thread_numbers = thread_group - > thread_numbers ; <nl> + res . os_thread_ids = thread_group - > os_thread_ids ; <nl> } <nl> <nl> if ( get_profile_events ) <nl> mmm a / dbms / src / Interpreters / ProcessList . h <nl> ppp b / dbms / src / Interpreters / ProcessList . h <nl> struct QueryStatusInfo <nl> <nl> / / / Optional fields , filled by request <nl> std : : vector < UInt32 > thread_numbers ; <nl> + std : : vector < UInt32 > os_thread_ids ; <nl> std : : shared_ptr < ProfileEvents : : Counters > profile_counters ; <nl> std : : shared_ptr < Settings > query_settings ; <nl> } ; <nl> mmm a / dbms / src / Interpreters / QueryLog . cpp <nl> ppp b / dbms / src / Interpreters / QueryLog . cpp <nl> Block QueryLogElement : : createBlock ( ) <nl> { std : : make_shared < DataTypeUInt32 > ( ) , " revision " } , <nl> <nl> { std : : make_shared < DataTypeArray > ( std : : make_shared < DataTypeUInt32 > ( ) ) , " thread_numbers " } , <nl> + { std : : make_shared < DataTypeArray > ( std : : make_shared < DataTypeUInt32 > ( ) ) , " os_thread_ids " } , <nl> { std : : make_shared < DataTypeArray > ( std : : make_shared < DataTypeString > ( ) ) , " ProfileEvents . Names " } , <nl> { std : : make_shared < DataTypeArray > ( std : : make_shared < DataTypeUInt64 > ( ) ) , " ProfileEvents . Values " } , <nl> { std : : make_shared < DataTypeArray > ( std : : make_shared < DataTypeString > ( ) ) , " Settings . Names " } , <nl> void QueryLogElement : : appendToBlock ( Block & block ) const <nl> columns [ i + + ] - > insert ( threads_array ) ; <nl> } <nl> <nl> + { <nl> + Array threads_array ; <nl> + threads_array . reserve ( os_thread_ids . size ( ) ) ; <nl> + for ( const UInt32 thread_number : os_thread_ids ) <nl> + threads_array . emplace_back ( UInt64 ( thread_number ) ) ; <nl> + columns [ i + + ] - > insert ( threads_array ) ; <nl> + } <nl> + <nl> if ( profile_counters ) <nl> { <nl> auto column_names = columns [ i + + ] . get ( ) ; <nl> mmm a / dbms / src / Interpreters / QueryLog . h <nl> ppp b / dbms / src / Interpreters / QueryLog . h <nl> struct QueryLogElement <nl> ClientInfo client_info ; <nl> <nl> std : : vector < UInt32 > thread_numbers ; <nl> + std : : vector < UInt32 > os_thread_ids ; <nl> std : : shared_ptr < ProfileEvents : : Counters > profile_counters ; <nl> std : : shared_ptr < Settings > query_settings ; <nl> <nl> mmm a / dbms / src / Interpreters / ThreadStatusExt . cpp <nl> ppp b / dbms / src / Interpreters / ThreadStatusExt . cpp <nl> void ThreadStatus : : initializeQuery ( ) <nl> thread_group - > memory_tracker . setDescription ( " ( for query ) " ) ; <nl> <nl> thread_group - > thread_numbers . emplace_back ( thread_number ) ; <nl> + thread_group - > os_thread_ids . emplace_back ( os_thread_id ) ; <nl> thread_group - > master_thread_number = thread_number ; <nl> thread_group - > master_thread_os_id = os_thread_id ; <nl> <nl> void ThreadStatus : : attachQuery ( const ThreadGroupStatusPtr & thread_group_ , bool <nl> <nl> / / / NOTE : A thread may be attached multiple times if it is reused from a thread pool . <nl> thread_group - > thread_numbers . emplace_back ( thread_number ) ; <nl> + thread_group - > os_thread_ids . emplace_back ( os_thread_id ) ; <nl> } <nl> <nl> if ( query_context ) <nl> mmm a / dbms / src / Interpreters / executeQuery . cpp <nl> ppp b / dbms / src / Interpreters / executeQuery . cpp <nl> static std : : tuple < ASTPtr , BlockIO > executeQueryImpl ( <nl> } <nl> <nl> elem . thread_numbers = std : : move ( info . thread_numbers ) ; <nl> + elem . os_thread_ids = std : : move ( info . os_thread_ids ) ; <nl> elem . profile_counters = std : : move ( info . profile_counters ) ; <nl> <nl> if ( log_queries ) <nl> static std : : tuple < ASTPtr , BlockIO > executeQueryImpl ( <nl> elem . memory_usage = info . peak_memory_usage > 0 ? info . peak_memory_usage : 0 ; <nl> <nl> elem . thread_numbers = std : : move ( info . thread_numbers ) ; <nl> + elem . os_thread_ids = std : : move ( info . os_thread_ids ) ; <nl> elem . profile_counters = std : : move ( info . profile_counters ) ; <nl> } <nl> <nl> mmm a / dbms / src / Storages / System / StorageSystemProcesses . cpp <nl> ppp b / dbms / src / Storages / System / StorageSystemProcesses . cpp <nl> NamesAndTypesList StorageSystemProcesses : : getNamesAndTypes ( ) <nl> { " query " , std : : make_shared < DataTypeString > ( ) } , <nl> <nl> { " thread_numbers " , std : : make_shared < DataTypeArray > ( std : : make_shared < DataTypeUInt32 > ( ) ) } , <nl> + { " os_thread_ids " , std : : make_shared < DataTypeArray > ( std : : make_shared < DataTypeUInt32 > ( ) ) } , <nl> { " ProfileEvents . Names " , std : : make_shared < DataTypeArray > ( std : : make_shared < DataTypeString > ( ) ) } , <nl> { " ProfileEvents . Values " , std : : make_shared < DataTypeArray > ( std : : make_shared < DataTypeUInt64 > ( ) ) } , <nl> { " Settings . Names " , std : : make_shared < DataTypeArray > ( std : : make_shared < DataTypeString > ( ) ) } , <nl> void StorageSystemProcesses : : fillData ( MutableColumns & res_columns , const Contex <nl> res_columns [ i + + ] - > insert ( threads_array ) ; <nl> } <nl> <nl> + { <nl> + Array threads_array ; <nl> + threads_array . reserve ( process . os_thread_ids . size ( ) ) ; <nl> + for ( const UInt32 thread_number : process . os_thread_ids ) <nl> + threads_array . emplace_back ( thread_number ) ; <nl> + res_columns [ i + + ] - > insert ( threads_array ) ; <nl> + } <nl> + <nl> { <nl> IColumn * column_profile_events_names = res_columns [ i + + ] . get ( ) ; <nl> IColumn * column_profile_events_values = res_columns [ i + + ] . get ( ) ; <nl>
|
Add " os_thread_ids " column to system tables
|
ClickHouse/ClickHouse
|
cb79e2371ed1899b7ee0fa3c9647dddada218993
|
2019-08-31T21:47:15Z
|
mmm a / arangod / V8Server / ApplicationV8 . cpp <nl> ppp b / arangod / V8Server / ApplicationV8 . cpp <nl> bool ApplicationV8 : : prepareV8Instance ( const size_t i ) { <nl> bool ok = TRI_V8RunVersionCheck ( vocbase , & _startupLoader , context - > _context ) ; <nl> <nl> if ( ! ok ) { <nl> - if ( _performUpgrade ) { <nl> - LOG_FATAL_AND_EXIT ( " Database upgrade failed for ' % s ' . Please inspect the logs from the upgrade procedure " , vocbase - > _name ) ; <nl> + if ( context - > _context - > Global ( ) - > Has ( v8 : : String : : New ( " UPGRADE_STARTED " ) ) ) { <nl> + if ( _performUpgrade ) { <nl> + LOG_FATAL_AND_EXIT ( " Database upgrade failed for ' % s ' . Please inspect the logs from the upgrade procedure " , vocbase - > _name ) ; <nl> + } <nl> + else { <nl> + LOG_FATAL_AND_EXIT ( " Database version check failed for ' % s ' . Please start the server with the - - upgrade option " , vocbase - > _name ) ; <nl> + } <nl> } <nl> else { <nl> - LOG_FATAL_AND_EXIT ( " Database version check failed for ' % s ' . Please start the server with the - - upgrade option " , vocbase - > _name ) ; <nl> + LOG_FATAL_AND_EXIT ( " JavaScript error during server start " ) ; <nl> } <nl> } <nl> <nl> mmm a / js / server / version - check . js <nl> ppp b / js / server / version - check . js <nl> <nl> / * jslint indent : 2 , nomen : true , maxlen : 100 , sloppy : true , vars : true , white : true , plusplus : true , stupid : true , continue : true , regexp : true * / <nl> - / * global require , exports , module , UPGRADE_ARGS * / <nl> + / * global require , exports , module , UPGRADE_ARGS , UPGRADE_STARTED * / <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / / @ brief version check at the start of the server , will optionally perform <nl> <nl> / / whether or not we are initialising an empty / a new database <nl> var isInitialisation ; <nl> <nl> + / / set this global variable to inform the server we actually got until here . . . <nl> + UPGRADE_STARTED = true ; <nl> <nl> var logger = { <nl> info : function ( msg ) { <nl>
|
prevent confusing message at startup
|
arangodb/arangodb
|
85f36777b8f2f08c855bd0d951f01a290bbf661e
|
2014-02-12T16:07:10Z
|
mmm a / doc / tutorials / introduction / android_binary_package / O4A_SDK . rst <nl> ppp b / doc / tutorials / introduction / android_binary_package / O4A_SDK . rst <nl> The structure of package contents looks as follows : <nl> OpenCV - 2 . 4 . 7 - android - sdk <nl> | _ apk <nl> | | _ OpenCV_2 . 4 . 7_binary_pack_armv7a . apk <nl> - | | _ OpenCV_2 . 4 . 7_Manager_2 . 13_XXX . apk <nl> + | | _ OpenCV_2 . 4 . 7_Manager_2 . 14_XXX . apk <nl> | <nl> | _ doc <nl> | _ samples <nl> Well , running samples from Eclipse is very simple : <nl> . . code - block : : sh <nl> : linenos : <nl> <nl> - < Android SDK path > / platform - tools / adb install < OpenCV4Android SDK path > / apk / OpenCV_2 . 4 . 7_Manager_2 . 13_armv7a - neon . apk <nl> + < Android SDK path > / platform - tools / adb install < OpenCV4Android SDK path > / apk / OpenCV_2 . 4 . 7_Manager_2 . 14_armv7a - neon . apk <nl> <nl> . . note : : ` ` armeabi ` ` , ` ` armv7a - neon ` ` , ` ` arm7a - neon - android8 ` ` , ` ` mips ` ` and ` ` x86 ` ` stand for <nl> platform targets : <nl> mmm a / platforms / android / service / engine / AndroidManifest . xml <nl> ppp b / platforms / android / service / engine / AndroidManifest . xml <nl> <nl> < ? xml version = " 1 . 0 " encoding = " utf - 8 " ? > <nl> < manifest xmlns : android = " http : / / schemas . android . com / apk / res / android " <nl> package = " org . opencv . engine " <nl> - android : versionCode = " 213 @ ANDROID_PLATFORM_VERSION_CODE @ " <nl> - android : versionName = " 2 . 13 " > <nl> + android : versionCode = " 214 @ ANDROID_PLATFORM_VERSION_CODE @ " <nl> + android : versionName = " 2 . 14 " > <nl> <nl> < uses - sdk android : minSdkVersion = " @ ANDROID_NATIVE_API_LEVEL @ " / > <nl> < uses - feature android : name = " android . hardware . touchscreen " android : required = " false " / > <nl> mmm a / platforms / android / service / readme . txt <nl> ppp b / platforms / android / service / readme . txt <nl> manually using adb tool : <nl> <nl> . . code - block : : sh <nl> <nl> - adb install OpenCV - 2 . 4 . 6 - android - sdk / apk / OpenCV_2 . 4 . 6_Manager_2 . 9_ < platform > . apk <nl> + adb install OpenCV - 2 . 4 . 7 - android - sdk / apk / OpenCV_2 . 4 . 7_Manager_2 . 14_ < platform > . apk <nl> <nl> Use the table below to determine proper OpenCV Manager package for your device : <nl> <nl> - + mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm + mmmmmmmmmmmm - - + mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm + <nl> - | Hardware Platform | Android ver . | Package name | <nl> - + = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + = = = = = = = = = = = = = = + = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + <nl> - | armeabi - v7a ( ARMv7 - A + NEON ) | > = 2 . 3 | OpenCV_2 . 4 . 6_Manager_2 . 9_armv7a - neon . apk | <nl> - + mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm + mmmmmmmmmmmm - - + mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm + <nl> - | armeabi - v7a ( ARMv7 - A + NEON ) | = 2 . 2 | OpenCV_2 . 4 . 6_Manager_2 . 9_armv7a - neon - android8 . apk | <nl> - + mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm + mmmmmmmmmmmm - - + mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm + <nl> - | armeabi ( ARMv5 , ARMv6 ) | > = 2 . 3 | OpenCV_2 . 4 . 6_Manager_2 . 9_armeabi . apk | <nl> - + mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm + mmmmmmmmmmmm - - + mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm + <nl> - | Intel x86 | > = 2 . 3 | OpenCV_2 . 4 . 6_Manager_2 . 9_x86 . apk | <nl> - + mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm + mmmmmmmmmmmm - - + mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm + <nl> - | MIPS | > = 2 . 3 | OpenCV_2 . 4 . 6_Manager_2 . 9_mips . apk | <nl> - + mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm + mmmmmmmmmmmm - - + mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm + <nl> + + mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm + mmmmmmmmmmmm - - + mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - + <nl> + | Hardware Platform | Android ver . | Package name | <nl> + + = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + = = = = = = = = = = = = = = + = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + <nl> + | armeabi - v7a ( ARMv7 - A + NEON ) | > = 2 . 3 | OpenCV_2 . 4 . 7_Manager_2 . 14_armv7a - neon . apk | <nl> + + mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm + mmmmmmmmmmmm - - + mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - + <nl> + | armeabi - v7a ( ARMv7 - A + NEON ) | = 2 . 2 | OpenCV_2 . 4 . 7_Manager_2 . 14_armv7a - neon - android8 . apk | <nl> + + mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm + mmmmmmmmmmmm - - + mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - + <nl> + | armeabi ( ARMv5 , ARMv6 ) | > = 2 . 3 | OpenCV_2 . 4 . 7_Manager_2 . 14_armeabi . apk | <nl> + + mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm + mmmmmmmmmmmm - - + mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - + <nl> + | Intel x86 | > = 2 . 3 | OpenCV_2 . 4 . 7_Manager_2 . 14_x86 . apk | <nl> + + mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm + mmmmmmmmmmmm - - + mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - + <nl> + | MIPS | > = 2 . 3 | OpenCV_2 . 4 . 7_Manager_2 . 14_mips . apk | <nl> + + mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm + mmmmmmmmmmmm - - + mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - + <nl>
|
Merge pull request from asmorkalov : android_manager_version_inc2
|
opencv/opencv
|
bca63083a83580db528808e268a42f03b936629d
|
2013-11-06T13:50:20Z
|
mmm a / configure <nl> ppp b / configure <nl> public : <nl> QString version , libs , other ; <nl> VersionMode mode = VersionMin ; <nl> if ( conf - > findPkgConfig ( " libnotify " , mode , req_ver , & version , & incs , & libs , & other ) ) { <nl> - conf - > addDefine ( " WITH_LIBNOTIFY " ) ; <nl> + conf - > addExtra ( " CONFIG + = libnotify " ) ; <nl> for ( int n = 0 ; n < incs . count ( ) ; + + n ) <nl> conf - > addIncludePath ( incs [ n ] ) ; <nl> if ( ! libs . isEmpty ( ) ) <nl> mmm a / qcm / libnotify . qcm <nl> ppp b / qcm / libnotify . qcm <nl> public : <nl> QString version , libs , other ; <nl> VersionMode mode = VersionMin ; <nl> if ( conf - > findPkgConfig ( " libnotify " , mode , req_ver , & version , & incs , & libs , & other ) ) { <nl> - conf - > addDefine ( " WITH_LIBNOTIFY " ) ; <nl> + conf - > addExtra ( " CONFIG + = libnotify " ) ; <nl> for ( int n = 0 ; n < incs . count ( ) ; + + n ) <nl> conf - > addIncludePath ( incs [ n ] ) ; <nl> if ( ! libs . isEmpty ( ) ) <nl> mmm a / unixconf . pri <nl> ppp b / unixconf . pri <nl> QMAKE_LFLAGS_APP + = - rdynamic <nl> CONFIG + = link_pkgconfig <nl> PKGCONFIG + = libtorrent - rasterbar <nl> <nl> + libnotify { <nl> + DEFINES + = WITH_LIBNOTIFY <nl> + } <nl> + <nl> # Man page <nl> nox { <nl> man . files = . . / doc / qbittorrent - nox . 1 <nl>
|
Further project file clean up
|
qbittorrent/qBittorrent
|
b7ae2eabc77011ed5e18be777106d343690a6d97
|
2010-11-20T17:32:59Z
|
mmm a / src / simulator - base . h <nl> ppp b / src / simulator - base . h <nl> <nl> <nl> # include " src / assembler . h " <nl> # include " src / globals . h " <nl> + # include " src / isolate . h " <nl> <nl> # if defined ( USE_SIMULATOR ) <nl> <nl>
|
Add missing include in simulator - base . h
|
v8/v8
|
d5fad76e8d7bc0da9251c44aca69e434930b9b87
|
2018-03-21T16:12:50Z
|
mmm a / CMake / Packages . cmake <nl> ppp b / CMake / Packages . cmake <nl> elseif ( LINUX ) <nl> " $ { PACKAGE_DEPENDENCIES } " <nl> " libudev " <nl> ) <nl> + elseif ( OSQUERY_BUILD_DISTRO STREQUAL " scientific6 " ) <nl> + set ( PACKAGE_ITERATION " 1 . el6 " ) <nl> + set ( PACKAGE_DEPENDENCIES <nl> + " $ { PACKAGE_DEPENDENCIES } " <nl> + " libudev " <nl> + ) <nl> elseif ( OSQUERY_BUILD_DISTRO STREQUAL " oracle6 " ) <nl> set ( PACKAGE_ITERATION " 1 . oel6 " ) <nl> set ( PACKAGE_DEPENDENCIES <nl> elseif ( LINUX ) <nl> set ( PACKAGE_DEPENDENCIES <nl> " $ { PACKAGE_DEPENDENCIES } " <nl> ) <nl> + elseif ( OSQUERY_BUILD_DISTRO STREQUAL " scientific7 " ) <nl> + set ( PACKAGE_ITERATION " 1 . el7 " ) <nl> + set ( PACKAGE_DEPENDENCIES <nl> + " $ { PACKAGE_DEPENDENCIES } " <nl> + ) <nl> elseif ( OSQUERY_BUILD_DISTRO STREQUAL " oracle7 " ) <nl> set ( PACKAGE_ITERATION " 1 . oel7 " ) <nl> set ( PACKAGE_DEPENDENCIES <nl> mmm a / CMakeLists . txt <nl> ppp b / CMakeLists . txt <nl> set ( OSQUERY_REQUIRE_RUNTIMES <nl> " lucid " <nl> " precise " <nl> " centos6 " <nl> + " scientific6 " <nl> " rhel6 " <nl> " oracle6 " <nl> " wheezy " <nl> elseif ( OSQUERY_BUILD_PLATFORM STREQUAL " centos " ) <nl> set ( REDHAT_BASED TRUE ) <nl> set ( CENTOS TRUE ) <nl> LOG_PLATFORM ( " CentOS " ) <nl> + elseif ( OSQUERY_BUILD_PLATFORM STREQUAL " scientific " ) <nl> + set ( REDHAT_BASED TRUE ) <nl> + set ( SCIENTIFIC TRUE ) <nl> + LOG_PLATFORM ( " Scientific Linux " ) <nl> elseif ( OSQUERY_BUILD_PLATFORM STREQUAL " rhel " ) <nl> set ( REDHAT_BASED TRUE ) <nl> set ( RHEL TRUE ) <nl> elseif ( OSQUERY_BUILD_PLATFORM STREQUAL " windows " ) <nl> LOG_PLATFORM ( " Windows " ) <nl> endif ( ) <nl> <nl> - if ( " $ { OSQUERY_BUILD_DISTRO } " MATCHES " ^ ( centos | rhel | oracle ) 7 $ " ) <nl> + if ( " $ { OSQUERY_BUILD_DISTRO } " MATCHES " ^ ( centos | rhel | scientific | oracle ) 7 $ " ) <nl> # Useful for libudev version detection . <nl> set ( SYSTEMD TRUE ) <nl> endif ( ) <nl> mmm a / osquery / CMakeLists . txt <nl> ppp b / osquery / CMakeLists . txt <nl> if ( APPLE ) <nl> elseif ( LINUX OR FREEBSD ) <nl> ADD_OSQUERY_LINK_CORE ( " - Wl , - zrelro - Wl , - znow " ) <nl> if ( NOT $ { OSQUERY_BUILD_DISTRO } STREQUAL " rhel6 " AND <nl> - NOT $ { OSQUERY_BUILD_DISTRO } STREQUAL " centos6 " ) <nl> + NOT $ { OSQUERY_BUILD_DISTRO } STREQUAL " centos6 " AND <nl> + NOT $ { OSQUERY_BUILD_DISTRO } STREQUAL " scientific6 " ) <nl> ADD_OSQUERY_LINK_CORE ( " - Wl , - - gc - sections " ) <nl> endif ( ) <nl> ADD_OSQUERY_LINK_CORE ( " librt . so " ) <nl> mmm a / osquery / tables / system / centos / rpm_packages . cpp <nl> ppp b / osquery / tables / system / centos / rpm_packages . cpp <nl> QueryData genRpmPackageFiles ( QueryContext & context ) { <nl> r [ " mode " ] = lsperms ( rpmfiFMode ( fi ) ) ; <nl> r [ " size " ] = BIGINT ( rpmfiFSize ( fi ) ) ; <nl> <nl> - # if defined ( CENTOS_CENTOS6 ) | | defined ( RHEL_RHEL6 ) <nl> + # if defined ( CENTOS_CENTOS6 ) | | defined ( RHEL_RHEL6 ) | | defined ( SCIENTIFIC_SCIENTIFIC6 ) <nl> / / Older versions of rpmlib / rpmip use a hash algorithm enum . <nl> pgpHashAlgo digest_algo ; <nl> # else <nl> mmm a / osquery / tables / system / linux / disk_encryption . cpp <nl> ppp b / osquery / tables / system / linux / disk_encryption . cpp <nl> void genFDEStatusForBlockDevice ( const std : : string & name , <nl> r [ " encrypted " ] = " 1 " ; <nl> <nl> int crypt_init ; <nl> - # if defined ( CENTOS_CENTOS6 ) | | defined ( RHEL_RHEL6 ) <nl> + # if defined ( CENTOS_CENTOS6 ) | | defined ( RHEL_RHEL6 ) | | defined ( SCIENTIFIC_SCIENTIFIC6 ) <nl> crypt_init = crypt_init_by_name ( & cd , name . c_str ( ) ) ; <nl> # else <nl> crypt_init = <nl>
|
Add more Scientific Linux conditionals
|
osquery/osquery
|
0c072031218651bd19765a817b7c4b385a401df3
|
2016-03-30T06:56:11Z
|
mmm a / test / test_jit . py <nl> ppp b / test / test_jit . py <nl> def emitFunctionHook ( self , func ) : <nl> self . assertMultiLineEqual ( src , src2 ) <nl> except RuntimeError as e : <nl> se = str ( e ) <nl> - if " could not export python function " not in se and \ <nl> + if " Could not export Python function " not in se and \ <nl> " closures are not exportable " not in se : <nl> raise <nl> <nl> def copy_structure_and_params ( m ) : <nl> main_module_code + = line . decode ( ) <nl> except RuntimeError as e : <nl> se = str ( e ) <nl> - if " could not export python function " not in se and \ <nl> + if " Could not export Python function " not in se and \ <nl> " closures are not exportable " not in se : <nl> raise <nl> else : <nl> def forward ( self , x ) : <nl> self . ignored_code ( x ) <nl> return x <nl> <nl> - @ torch . jit . ignore <nl> + @ torch . jit . ignore ( drop_on_export = True ) <nl> def ignored_code ( self , x ) : <nl> self . some_state = torch . tensor ( ( 100 , ) ) <nl> <nl> def a_script_fn ( d , e , f ) : <nl> t = torch . ones ( 2 , 2 ) <nl> self . assertEqual ( a_script_fn ( t , t , t ) , t + t + t ) <nl> <nl> + def test_module_recursive ( self ) : <nl> + class Other ( torch . nn . Module ) : <nl> + __constants__ = [ ' x ' ] <nl> + <nl> + def __init__ ( self , x ) : <nl> + super ( Other , self ) . __init__ ( ) <nl> + self . x = x <nl> + self . param = torch . nn . Parameter ( torch . ones ( 2 , 2 ) ) <nl> + <nl> + def some_unscriptable_method ( self ) : <nl> + a = 2 <nl> + a = [ 2 ] <nl> + return a <nl> + <nl> + def forward ( self , t ) : <nl> + return t + self . x + self . param <nl> + <nl> + <nl> + class M ( torch . nn . Module ) : <nl> + __constants__ = [ ' x ' ] <nl> + <nl> + def __init__ ( self ) : <nl> + super ( M , self ) . __init__ ( ) <nl> + self . other = Other ( 200 ) <nl> + <nl> + def forward ( self , t ) : <nl> + return self . other ( t ) * 2 <nl> + <nl> + with torch . jit . _enable_recursive_script ( ) : <nl> + sm = torch . jit . script ( M ( ) ) <nl> + <nl> + self . assertExportImportModule ( sm , ( torch . ones ( 2 , 2 ) , ) ) <nl> + <nl> + def test_module_function_export ( self ) : <nl> + class Other ( torch . nn . Module ) : <nl> + __constants__ = [ ' x ' ] <nl> + <nl> + def __init__ ( self , x ) : <nl> + super ( Other , self ) . __init__ ( ) <nl> + self . x = x <nl> + self . param = torch . nn . Parameter ( torch . ones ( 2 , 2 ) ) <nl> + <nl> + @ torch . jit . export <nl> + def some_entry_point ( self , y ) : <nl> + return y + 20 <nl> + <nl> + def forward ( self , t ) : <nl> + return t + self . x + self . param <nl> + <nl> + <nl> + class M ( torch . nn . Module ) : <nl> + __constants__ = [ ' x ' ] <nl> + <nl> + def __init__ ( self ) : <nl> + super ( M , self ) . __init__ ( ) <nl> + self . other = Other ( 200 ) <nl> + <nl> + def forward ( self , t ) : <nl> + return self . other ( t ) * 2 <nl> + <nl> + with torch . jit . _enable_recursive_script ( ) : <nl> + sm = torch . jit . script ( M ( ) ) <nl> + <nl> + self . assertExportImportModule ( sm , ( torch . ones ( 2 , 2 ) , ) ) <nl> + <nl> @ unittest . skipIf ( IS_WINDOWS or IS_SANDCASTLE , " NYI : TemporaryFileName support for Windows or Sandcastle " ) <nl> def test_old_models_bc ( self ) : <nl> model = { <nl> mmm a / torch / _jit_internal . py <nl> ppp b / torch / _jit_internal . py <nl> <nl> # argument <nl> boolean_dispatched = weakref . WeakKeyDictionary ( ) # noqa : T484 <nl> <nl> - # Python Op functions that should be ignored by the compiler . These will be replaced <nl> - # with an operator that always throws an error <nl> - ignored_fns = weakref . WeakSet ( ) # noqa : T484 <nl> - <nl> COMPILATION_PENDING = object ( ) <nl> COMPILED = object ( ) <nl> <nl> def fn ( * args , * * kwargs ) : <nl> return fn <nl> <nl> <nl> - def ignore ( fn ) : <nl> - ignored_fns . add ( fn ) <nl> + <nl> + class FunctionModifiers ( object ) : <nl> + " " " <nl> + Used to denote the behavior of a function in TorchScript . See export ( ) and <nl> + ignore ( ) for details . <nl> + " " " <nl> + IGNORE_AND_DROP = " ignore ( leave as a call to Python , replace with a ' raise ' on torch . jit . save ) " <nl> + IGNORE = " ignore ( leave as a call to Python , cannot be torch . jit . save ' d ) " <nl> + EXPORT = " export ( compile this function even if nothing calls it ) " <nl> + DEFAULT = " default ( compile if called from a exported function / forward ) " <nl> + <nl> + <nl> + def export ( fn ) : <nl> + " " " <nl> + This decorator indicates that a method is used as an entry point into a <nl> + ScriptModule . ` forward ` implicitly is used as an entry point , so it does <nl> + not need this decorator . <nl> + <nl> + Methods are added to a ScriptModule as they are called in Python . If a <nl> + method is never called , it will not be included in the ScriptModule when <nl> + saving . This decorator explicitly marks that a method should be included <nl> + even if it is not called from Python . <nl> + " " " <nl> + fn . _torchscript_modifier = FunctionModifiers . EXPORT <nl> return fn <nl> <nl> <nl> + def ignore ( maybe_fn = None , * , drop_on_export = False ) : <nl> + " " " <nl> + This decorator indicates to the compiler that a function or method should <nl> + be ignored and left as a Python function . <nl> + <nl> + With ` drop_on_export = False ` ( the default ) , calls to this function will <nl> + prevent saving a TorchScript model . <nl> + <nl> + With ` drop_on_export = True ` , any calls to this function from other <nl> + TorchScript code will be replaced with a ` raise ` . This allows you to leave <nl> + code in your TorchScript model that is only ever run when the Python <nl> + interpreter is present . <nl> + " " " <nl> + if maybe_fn is None : <nl> + # No positional args passed , so the decorator as been used with a kwarg , <nl> + # like @ torch . jit . ignore ( drop_on_export = True ) <nl> + def decorator ( fn ) : <nl> + if drop_on_export : <nl> + fn . _torchscript_modifier = FunctionModifiers . IGNORE_AND_DROP <nl> + else : <nl> + fn . _torchscript_modifier = FunctionModifiers . IGNORE <nl> + return fn <nl> + return decorator <nl> + <nl> + if callable ( maybe_fn ) : <nl> + # used without any args , so drop_on_export is actually a function <nl> + # @ torch . jit . ignore <nl> + # def fn ( . . . ) : <nl> + maybe_fn . _torchscript_modifier = FunctionModifiers . IGNORE <nl> + return maybe_fn <nl> + else : <nl> + if isinstance ( maybe_fn , bool ) : <nl> + correct_usage = " @ torch . jit . ignore ( drop_on_export = { } ) " . format ( " True " if maybe_fn else " False " ) <nl> + raise RuntimeError ( " drop_on_export must be used as a kwarg , e . g . " <nl> + " ' { } ' " . format ( correct_usage ) ) <nl> + raise RuntimeError ( " Argument to @ torch . jit . ignore must be a bool or " <nl> + " a function but got { } " . format ( maybe_fn ) ) <nl> + <nl> + <nl> + def should_drop_on_export ( fn ) : <nl> + attr = get_torchscript_modifier ( fn ) <nl> + if attr is None : <nl> + return False <nl> + return attr is FunctionModifiers . IGNORE_AND_DROP <nl> + <nl> + <nl> + def is_ignored_fn ( fn ) : <nl> + mod = get_torchscript_modifier ( fn ) <nl> + return mod is FunctionModifiers . IGNORE_AND_DROP or mod is FunctionModifiers . IGNORE <nl> + <nl> + <nl> + def get_torchscript_modifier ( fn ) : <nl> + if not callable ( fn ) : <nl> + return None <nl> + if hasattr ( fn , ' __func__ ' ) : <nl> + fn = fn . __func__ <nl> + return getattr ( fn , ' _torchscript_modifier ' , FunctionModifiers . DEFAULT ) <nl> + <nl> + <nl> def _parameter_list ( parameter_names_fn ) : <nl> " " " <nl> Decorator to denote that a function returns a list of all the parameters <nl> mmm a / torch / csrc / jit / passes / python_print . cpp <nl> ppp b / torch / csrc / jit / passes / python_print . cpp <nl> struct PythonPrintPass { <nl> auto value = static_cast < const PythonOp * > ( node ) ; <nl> if ( enforce_importable_ & & ! value - > ignore_on_export ) { <nl> throw script : : ErrorReport ( node - > sourceRange ( ) ) <nl> - < < " could not export python function call " < < value - > name ( ) <nl> - < < " . Remove calls to Python functions before export . " <nl> + < < " Could not export Python function call ' " < < value - > name ( ) <nl> + < < " ' . Remove calls to Python functions before export . " <nl> < < " Did you forget add @ script or @ script_method annotation ? " <nl> - < < " If this is a nn . ModuleList , add it to __constants__ . " ; <nl> + < < " If this is a nn . ModuleList , add it to __constants__ " ; <nl> } <nl> <nl> if ( value - > ignore_on_export ) { <nl> mmm a / torch / csrc / jit / script / init . cpp <nl> ppp b / torch / csrc / jit / script / init . cpp <nl> void initJitScriptBindings ( PyObject * module ) { <nl> PythonPrint ( ss , self . function ( ) , true , tensors , classes , false ) ; <nl> return ss . str ( ) ; <nl> } ) ; <nl> + m . def ( <nl> + " _jit_recursive_script " , <nl> + [ ] ( ) { return getRecursiveScriptMode ( ) ; } ) ; <nl> m . def ( <nl> " _jit_recursive_script " , <nl> [ ] ( bool recurse ) { getRecursiveScriptMode ( ) = recurse ; } ) ; <nl> mmm a / torch / csrc / jit / script / python_sugared_value . cpp <nl> ppp b / torch / csrc / jit / script / python_sugared_value . cpp <nl> std : : shared_ptr < SugaredValue > PythonValue : : call ( <nl> m . graph ( ) - > createPythonOp ( THPObjectPtr ( func . release ( ) . ptr ( ) ) , cconv , { } ) ) ; <nl> <nl> / / Mark if function is ignored on export <nl> - if ( py : : cast < bool > ( <nl> - py : : module : : import ( " torch . jit " ) . attr ( " _is_ignored_function " ) ( self ) ) ) { <nl> + if ( py : : cast < bool > ( py : : module : : import ( " torch . _jit_internal " ) <nl> + . attr ( " should_drop_on_export " ) ( self ) ) ) { <nl> auto python_op = static_cast < PythonOp * > ( new_node ) ; <nl> python_op - > ignore_on_export = true ; <nl> } <nl> std : : shared_ptr < SugaredValue > ModuleValue : : attr ( <nl> throw ErrorReport ( loc ) < < " module has no attribute ' " < < field ; <nl> } <nl> py : : object attr = py : : getattr ( py_module_ , field . c_str ( ) ) ; <nl> + <nl> + / / HACK : This is used for rnn . py to get all the parameters of a Module as a <nl> + / / List [ Tensor ] <nl> if ( py : : isinstance < py : : function > ( attr ) & & <nl> py : : hasattr ( attr , " _parameter_names_fn " ) ) { <nl> / / Fetch the names of the parameters in the list so they ' re in the <nl> std : : shared_ptr < SugaredValue > ModuleValue : : attr ( <nl> auto list = g . insertNode ( g . createTuple ( params ) ) - > output ( ) ; <nl> return std : : make_shared < ConstantParameterList > ( list ) ; <nl> } <nl> + <nl> + / / If recursive script mode is on , create a ScriptModule and register it as <nl> + / / as submodule or register a python method as a script : : Method <nl> + if ( getRecursiveScriptMode ( ) ) { <nl> + if ( py : : isinstance ( attr , py : : module : : import ( " torch . nn " ) . attr ( " Module " ) ) ) { <nl> + / / If the module is a submodule of the py_module , convert it to a <nl> + / / ScriptModule and add it as a submodule to the script : : Module . This <nl> + / / enables lazy strong - ification of modules . <nl> + auto result = <nl> + py : : module : : import ( " torch . jit " ) <nl> + . attr ( " _make_strong_submodule " ) ( field , attr , py_module_ ) ; <nl> + if ( ! result . is_none ( ) ) { <nl> + auto submodule = as_module ( result ) ; <nl> + AT_CHECK ( <nl> + submodule , <nl> + " Result of torch . jit . _make_strong_submodule " <nl> + " was not a ScriptModule " ) ; <nl> + / / The module was a submodule of the nn . Module , so register it here <nl> + / / and return the submodule . <nl> + module_ - > register_module ( field , submodule ) ; <nl> + auto v = module_ - > find_module ( field ) ; <nl> + return std : : make_shared < ModuleValue > ( <nl> + m . graph ( ) - > insertGetAttr ( self_ , field ) , v , attr ) ; <nl> + } <nl> + } else if ( py : : isinstance < py : : function > ( attr ) ) { <nl> + auto stub = py : : module : : import ( " torch . jit " ) <nl> + . attr ( " _create_method_from_fn " ) ( py_module_ , attr ) ; <nl> + if ( ! stub . is_none ( ) ) { <nl> + return SimpleValue ( self_ ) . attr ( loc , m , field ) ; <nl> + } <nl> + } <nl> + } <nl> + <nl> if ( py : : isinstance < py : : function > ( attr ) | | <nl> py : : isinstance ( attr , py : : module : : import ( " torch . nn " ) . attr ( " Module " ) ) | | <nl> py_module_ . attr ( " _constants_set " ) . contains ( field . c_str ( ) ) ) { <nl> std : : shared_ptr < SugaredValue > toSugaredValue ( <nl> } <nl> } <nl> <nl> - if ( recurse_on_python_ops & & py : : isinstance < py : : function > ( obj ) ) { <nl> + if ( getRecursiveScriptMode ( ) & & py : : isinstance < py : : function > ( obj ) ) { <nl> auto compiled_fn = <nl> py : : module : : import ( " torch . jit " ) . attr ( " _try_compile_fn " ) ( obj ) ; <nl> if ( auto callee = as_function ( compiled_fn ) ) { <nl> mmm a / torch / jit / __init__ . py <nl> ppp b / torch / jit / __init__ . py <nl> <nl> import torch . _jit_internal as _jit_internal <nl> from torch . _six import PY2 , with_metaclass , get_function_from_type , \ <nl> string_classes , builtins <nl> - from torch . _jit_internal import ignore # noqa : F401 <nl> + from torch . _jit_internal import ignore , export # noqa : F401 <nl> from . . nn . modules . utils import _single , _pair , _triple , _quadruple , \ <nl> _list_with_default <nl> import torch . testing <nl> def env ( key ) : <nl> return env <nl> <nl> <nl> + def _make_strong_submodule ( field , module , parent ) : <nl> + if field not in parent . _modules : <nl> + # It ' s not a submodule , don ' t do anything <nl> + return None <nl> + return _convert_to_script_module ( module ) <nl> + <nl> + <nl> def _try_compile_fn ( fn ) : <nl> - if inspect . ismethod ( fn ) or _is_ignored_function ( fn ) : <nl> - # Skip methods <nl> + if _jit_internal . is_ignored_fn ( fn ) : <nl> + # Don ' t do anything for @ ignore ' d functions <nl> return None <nl> + <nl> + # We don ' t have the actual scope where the function was defined , but we can <nl> + # extract the necessary info from the closed over variables on the function <nl> + # object <nl> rcb = createResolutionCallbackFromClosure ( fn ) <nl> return torch . jit . script ( fn , _rcb = rcb ) <nl> <nl> + <nl> + def _create_method_from_fn ( module , fn ) : <nl> + if _jit_internal . is_ignored_fn ( fn ) : <nl> + return None <nl> + stub = script_method ( fn , createResolutionCallbackFromClosure ( fn ) ) <nl> + _create_methods_from_stubs ( self , ( stub , ) ) <nl> + <nl> + <nl> # ScriptClasses must be new - style classes because we construct them using their <nl> # __new__ method . <nl> def _is_new_style_class ( cls ) : <nl> def script ( obj , optimize = True , _frames_up = 0 , _rcb = None ) : <nl> return obj <nl> if _rcb is None : <nl> _rcb = _jit_internal . createResolutionCallback ( _frames_up + 1 ) <nl> + <nl> + if torch . _C . _jit_recursive_script ( ) : <nl> + if isinstance ( obj , torch . nn . Module ) : <nl> + return _convert_to_script_module ( obj ) <nl> + <nl> if inspect . isclass ( obj ) : <nl> if not _is_new_style_class ( obj ) : <nl> raise RuntimeError ( " TorchScript classes must be new - style classes . Please inherit from ' object ' " ) <nl> def _try_get_weak_module ( mod ) : <nl> return _jit_internal . weak_modules . get ( mod ) <nl> <nl> <nl> - def _is_ignored_function ( fn ) : <nl> - if not callable ( fn ) : <nl> - return False <nl> - if hasattr ( fn , ' __func__ ' ) : <nl> - fn = fn . __func__ <nl> - return fn in _jit_internal . ignored_fns <nl> - <nl> - <nl> def _is_weak_type ( cls ) : <nl> " " " <nl> Check if a type has been annotated with ` weak_module ` <nl> def __setattr__ ( self , attr , value ) : <nl> return super ( ScriptModule , self ) . __setattr__ ( attr , value ) <nl> <nl> if hasattr ( self , attr ) : <nl> - raise RuntimeError ( " attempting to re - assign constant ' { } ' " . format ( attr ) ) <nl> + raise RuntimeError ( " attempting to re - assign constant ' { } ' in { } " . format ( attr , type ( self ) . __name__ ) ) <nl> <nl> def conv_module_to_const ( module_value ) : <nl> if not isinstance ( module_value , ( ModuleList , Sequential ) ) : <nl> def graph_for ( self , * args , * * kwargs ) : <nl> return self . forward . graph_for ( * args , * * kwargs ) <nl> <nl> class WeakScriptModuleProxy ( ScriptModule ) : <nl> + " " " <nl> + Copies the parameters , buffers , constants , attributes , and submodules <nl> + of an nn . Module into itself . <nl> + " " " <nl> def __init__ ( self , original , stubs ) : <nl> # Guards behavior of __setattr__ and __getattr__ so ScriptModule <nl> # __init__ can run correctly <nl> self . __dict__ [ ' _initialized ' ] = False <nl> super ( WeakScriptModuleProxy , self ) . __init__ ( ) <nl> - <nl> # Store a weak reference to the original module <nl> self . __dict__ [ " _original " ] = weakref . ref ( original ) <nl> <nl> constants_set = set ( getattr ( original , " __constants__ " , [ ] ) ) <nl> self . __dict__ [ " _constants_set " ] = { } <nl> <nl> + if not hasattr ( original , ' _parameters ' ) : <nl> + raise RuntimeError ( " ' { } ' has not been initialized , did you forget to call ' super ( ) ' ? " <nl> + . format ( type ( original ) . __name__ ) ) <nl> + <nl> # Copy Parameters and Modules <nl> for name in dir ( original ) : <nl> item = getattr ( original , name ) <nl> def __init__ ( self , original , stubs ) : <nl> # XXX : treat None value simply as module attributes instead of adding them to the parameter list <nl> # TODO : need to handle this more generally when non - tensor attributes added to module <nl> object . __setattr__ ( self , name , item ) <nl> - elif isinstance ( item , Parameter ) or ( isinstance ( item , Module ) and item is not self ) : <nl> + elif item is self : <nl> + continue <nl> + elif isinstance ( item , ( Parameter , Module , Attribute ) ) : <nl> + if isinstance ( item , ( ModuleList , Sequential ) ) : <nl> + # These are in __constants__ , so ignore them here <nl> + continue <nl> ScriptModule . __setattr__ ( self , name , item ) <nl> <nl> # Copy buffers <nl> def __init__ ( self , original , stubs ) : <nl> self . __dict__ [ " _constants_set " ] = constants_set <nl> for name in self . __dict__ [ " _constants_set " ] : <nl> if hasattr ( original , name ) : <nl> - self . __dict__ [ name ] = getattr ( original , name ) <nl> + if ( name in original . _parameters or name in original . _buffers ) and item is not None : <nl> + # for ' None ' parameters / buffers , don ' t actually add their values if it exists <nl> + continue <nl> + ScriptModule . __setattr__ ( self , name , getattr ( original , name ) ) <nl> <nl> # Copy overloads <nl> self . __dict__ [ " _overloads " ] = dict ( getattr ( original , " __overloads__ " , { } ) ) <nl> def __getattr__ ( self , attr ) : <nl> # weak module itself <nl> try : <nl> return ScriptModule . __getattr__ ( self , attr ) <nl> - except AttributeError : <nl> + except AttributeError as e : <nl> # unwrap the original <nl> original_module = self . __dict__ [ " _original " ] ( ) <nl> if original_module and self . __dict__ [ " _initialized " ] : <nl> # get attr from original if it is still alive <nl> return getattr ( original_module , attr ) <nl> - else : <nl> - # Only fall back to original once __init__ ( ) is done <nl> - raise AttributeError ( " Weak module has no attribute ' { } ' " <nl> - . format ( attr ) ) <nl> + <nl> + # If it ' s not on this module and it wasn ' t on the original <nl> + # module ( or the original is dead ) , throw the exception <nl> + raise e <nl> <nl> def __setattr__ ( self , attr , value ) : <nl> # Once constructed , no new properties can be set <nl> def __init__ ( self , optimize = True ) : <nl> <nl> def _get_weak_stubs ( cls ) : <nl> " " " <nl> - Calls script_method for each method on the type of the object passed in and <nl> - returns the generated ScriptMethodStubs <nl> + Calls script_method for each method that has been annotated with @ weak_script <nl> + on the type of the object passed in and returns the generated ScriptMethodStubs . <nl> " " " <nl> stubs = [ ] <nl> for name in dir ( cls ) : <nl> def _get_weak_stubs ( cls ) : <nl> return stubs <nl> <nl> <nl> + def _convert_to_script_module ( mod , methods = None ) : <nl> + " " " <nl> + Makes a ScriptModule from an nn . Module . If ` _methods ` is provided , <nl> + these methods are treated as @ script_methods . If not , it defaults to <nl> + ` ( ' forward ' , ) ` . Methods accessed in forward are scripted on demand if <nl> + ` _enable_recursive_script ( ) ` is used . <nl> + " " " <nl> + if methods is None : <nl> + methods = ( ' forward ' , ) <nl> + exported = [ ] <nl> + for name in dir ( mod ) : <nl> + item = getattr ( mod , name ) <nl> + if callable ( item ) : <nl> + if _jit_internal . get_torchscript_modifier ( item ) is _jit_internal . FunctionModifiers . EXPORT : <nl> + exported . append ( name ) <nl> + methods = methods + tuple ( exported ) <nl> + <nl> + def make_stub ( method ) : <nl> + func = get_function_from_type ( type ( mod ) , method ) <nl> + return script_method ( func , createResolutionCallbackFromClosure ( func ) ) <nl> + <nl> + stubs = list ( map ( make_stub , methods ) ) <nl> + return WeakScriptModuleProxy ( mod , stubs ) <nl> + <nl> + <nl> def _make_strong ( mod ) : <nl> " " " <nl> - Converts a weak module into a subclass of ScriptModule <nl> + Converts a weak module into a subclass of ScriptModule . If ` _methods ` is <nl> + provided , only these methods are treated as @ script_methods . <nl> " " " <nl> if mod in _jit_internal . weak_modules : <nl> return _jit_internal . weak_modules [ mod ] <nl> <nl> - stubs = _jit_internal . weak_types . get ( type ( mod ) ) [ " method_stubs " ] <nl> - <nl> + cls = type ( mod ) <nl> + # Explicitly annotated weak script <nl> + stubs = _jit_internal . weak_types . get ( cls ) [ " method_stubs " ] <nl> if stubs is None : <nl> # Generate stubs and and store on weak_types in case this type is <nl> # used again <nl> - stubs = _get_weak_stubs ( type ( mod ) ) <nl> - _jit_internal . weak_types [ type ( mod ) ] [ " method_stubs " ] = stubs <nl> - <nl> - # Create proxy with stubs <nl> - original_type = type ( mod ) <nl> + stubs = _get_weak_stubs ( cls ) <nl> + _jit_internal . weak_types [ cls ] [ " method_stubs " ] = stubs <nl> <nl> # Construct a new type that inherits from both WeakScriptModuleProxy and <nl> # original_type so that isinstance checks work correctly <nl> - weak_type = type ( original_type . __name__ , ( WeakScriptModuleProxy , original_type ) , { } ) <nl> + weak_type = type ( cls . __name__ , ( WeakScriptModuleProxy , cls ) , { } ) <nl> proxy = weak_type ( mod , stubs ) <nl> <nl> _jit_internal . weak_modules [ mod ] = proxy <nl>
|
Add support for recursive compilation on Modules ( )
|
pytorch/pytorch
|
8d3388aef2b6b109e45d0c58da720601aa1e94cd
|
2019-05-30T01:52:36Z
|
mmm a / code / search / binary_search / binary_search . rs <nl> ppp b / code / search / binary_search / binary_search . rs <nl> fn main ( ) { <nl> let nums = vec ! [ 1 , 3 , 5 , 7 , 9 ] ; <nl> let find_me = 5 ; <nl> <nl> - let index = binary_search ( & nums , find_me , 0 , nums . len ( ) ) <nl> + let result = binary_search ( & nums , find_me , 0 , nums . len ( ) ) ; <nl> <nl> - println ! ( " Given Array : { : ? } \ n " , nums ) ; <nl> - println ! ( " Searched for { } and found index { } " , find_me , index ) ) ; <nl> + println ! ( " Given Array : { : ? } " , nums ) ; <nl> + match result { <nl> + Some ( index ) = > println ! ( " Searched for { } and found index { } . " , find_me , index ) , <nl> + None = > println ! ( " Searched for { } but found no occurrence . " , find_me ) , <nl> + } <nl> } <nl> <nl> - fn binary_search ( nums : & Vec < i64 > , search_value : i64 , left : usize , right : usize ) - > i64 { <nl> - let mut left = left ; <nl> - let mut right = right ; <nl> + fn binary_search ( nums : & [ i64 ] , search_value : i64 , left : usize , right : usize ) - > Option < usize > { <nl> + let mut left : usize = left ; <nl> + let mut right : usize = right ; <nl> <nl> while left < = right { <nl> let middle = ( left + right ) / 2 ; <nl> fn binary_search ( nums : & Vec < i64 > , search_value : i64 , left : usize , right : usize ) <nl> } <nl> <nl> if nums [ middle ] = = search_value { <nl> - return middle as i64 ; <nl> + return Some ( middle ) ; <nl> } else if nums [ middle ] < search_value { <nl> left = middle + 1 ; <nl> } else if nums [ middle ] > search_value & & middle ! = 0 { <nl> fn binary_search ( nums : & Vec < i64 > , search_value : i64 , left : usize , right : usize ) <nl> } <nl> } <nl> <nl> - - 1 <nl> + None <nl> } <nl>
|
Improved binary_search implementation written in rust
|
OpenGenus/cosmos
|
eaeeaf383eca91a7e9089632f2872c87aa3096f5
|
2017-10-15T09:31:08Z
|
mmm a / src / mongo / util / SConscript <nl> ppp b / src / mongo / util / SConscript <nl> if has_option ( ' gcov ' ) : <nl> ] , <nl> ) <nl> <nl> + if has_option ( ' use - cpu - profiler ' ) : <nl> + quick_exit_env . Append ( <nl> + CPPDEFINES = [ <nl> + ' MONGO_CPU_PROFILER ' , <nl> + ] , <nl> + ) <nl> + <nl> + if not use_system_version_of_library ( ' tcmalloc ' ) : <nl> + quick_exit_env . InjectThirdPartyIncludePaths ( <nl> + ' tcmalloc ' <nl> + ) <nl> + <nl> quick_exit_env . Library ( <nl> target = ' quick_exit ' , <nl> source = [ <nl> ' quick_exit . cpp ' , <nl> ] , <nl> LIBDEPS = [ <nl> - # NOTE : You * must not * add any library dependencies to the quick_exit library <nl> + # NOTE : You * must not * add any other library dependencies to <nl> + # the quick_exit library <nl> + " $ BUILD_DIR / third_party / shim_allocator " , <nl> ] <nl> ) <nl> <nl> mmm a / src / mongo / util / quick_exit . cpp <nl> ppp b / src / mongo / util / quick_exit . cpp <nl> <nl> # include < sanitizer / lsan_interface . h > <nl> # endif <nl> <nl> + # if defined ( MONGO_CPU_PROFILER ) <nl> + # include < gperftools / profiler . h > <nl> + # endif <nl> + <nl> # ifdef MONGO_GCOV <nl> extern " C " void __gcov_flush ( ) ; <nl> # endif <nl> void quickExit ( int code ) { <nl> if ( quickExitMutex ) <nl> quickExitMutex - > lock ( ) ; <nl> <nl> + # if defined ( MONGO_CPU_PROFILER ) <nl> + : : ProfilerStop ( ) ; <nl> + # endif <nl> + <nl> # ifdef MONGO_GCOV <nl> __gcov_flush ( ) ; <nl> # endif <nl> mmm a / src / third_party / gperftools - 2 . 2 / SConscript <nl> ppp b / src / third_party / gperftools - 2 . 2 / SConscript <nl> conf . CheckMallocHookVolatile ( ) <nl> if has_option ( ' use - cpu - profiler ' ) : <nl> if not conf . CheckLib ( ' unwind ' , autoadd = False ) : <nl> env . ConfError ( " Compiling with - - use - cpu - profiler requires having libunwind installed " ) <nl> - conf . env . AppendUnique ( <nl> + conf . env . Append ( <nl> CPPDEFINES = [ " NO_FRAME_POINTER " , ( " HAVE_LIBUNWIND_H " , " 1 " ) ] , <nl> SYSLIBDEPS = [ ' unwind ' ] <nl> ) <nl>
|
SERVER - 13476 Make the gperftools cpu profiler work again
|
mongodb/mongo
|
10b650835a78fbf7ebe9cf26926cc45556efd178
|
2016-03-24T23:12:16Z
|
mmm a / drivers / python / rethinkdb / _dump . py <nl> ppp b / drivers / python / rethinkdb / _dump . py <nl> def do_export ( temp_dir , options ) : <nl> def do_zip ( temp_dir , options ) : <nl> print ( " Zipping export directory . . . " ) <nl> start_time = time . time ( ) <nl> - with tarfile . open ( options [ " out_file " ] , " w : gz " ) as f : <nl> - export_dir = os . path . join ( temp_dir , options [ " temp_filename " ] ) <nl> - f . add ( export_dir , options [ " temp_filename " ] ) <nl> + original_dir = os . getcwd ( ) <nl> + <nl> + try : <nl> + os . chdir ( temp_dir ) <nl> + with tarfile . open ( options [ " out_file " ] , " w : gz " ) as f : <nl> + for curr , subdirs , files in os . walk ( options [ " temp_filename " ] ) : <nl> + for data_file in files : <nl> + path = os . path . join ( curr , data_file ) <nl> + f . add ( path ) <nl> + os . unlink ( path ) <nl> + finally : <nl> + os . chdir ( original_dir ) <nl> + <nl> print ( " Done ( % d seconds ) " % ( time . time ( ) - start_time ) ) <nl> <nl> def run_rethinkdb_export ( options ) : <nl>
|
removing export files as they are added to the archive
|
rethinkdb/rethinkdb
|
558be1b60dd7c9255013bc04602d25be82c8d7e1
|
2016-02-23T02:03:18Z
|
mmm a / tensorflow / compiler / mlir / tensorflow / transforms / fused_kernel_matcher . cc <nl> ppp b / tensorflow / compiler / mlir / tensorflow / transforms / fused_kernel_matcher . cc <nl> class FuseConv2DBiasAdd <nl> <nl> / / Performs a fusion of the following pattern ( s ) , if possible : <nl> / / MatMulOp + BiasAdd + < Activation > - > _FusedMatMulOp <nl> - using FuseMatMulBiasAdd = FuseContractionWithBiasAdd < MatMulOp , _FusedMatMulOp > ; <nl> + class FuseMatMulBiasAdd <nl> + : public FuseContractionWithBiasAdd < MatMulOp , _FusedMatMulOp > { <nl> + using FuseContractionWithBiasAdd < MatMulOp , <nl> + _FusedMatMulOp > : : FuseContractionWithBiasAdd ; <nl> + <nl> + bool AreFuseCompatible ( MatMulOp matmul , BiasAddOp bias_add , <nl> + PatternRewriter & rewriter ) const override { <nl> + return matmul . T ( ) . isF32 ( ) | | matmul . T ( ) . isBF16 ( ) ; <nl> + } <nl> + } ; <nl> <nl> void FusedKernelMatcherPass : : runOnFunction ( ) { <nl> OwningRewritePatternList patterns ; <nl>
|
[ TF : MLIR ] Verify MatMul datatype in fused kernel matcher
|
tensorflow/tensorflow
|
4e9a867e422e1bc2858c5ca7bd1199d1565d7e27
|
2020-11-24T22:42:02Z
|
mmm a / hphp / hack / src / errors / error_codes . ml <nl> ppp b / hphp / hack / src / errors / error_codes . ml <nl> module NastCheck = struct <nl> | ConflictingMutableAndMaybeMutableAttributes <nl> | MaybeMutableMethodsMustBeReactive <nl> | RequiresFinalClass <nl> + | InterfaceUsesTrait <nl> ( * EXTEND HERE WITH NEW VALUES IF NEEDED * ) <nl> [ @ @ deriving enum , show { with_path = false } ] <nl> let err_code = to_enum <nl> mmm a / hphp / hack / src / errors / errors . ml <nl> ppp b / hphp / hack / src / errors / errors . ml <nl> let await_in_sync_function p = <nl> add ( NastCheck . err_code NastCheck . AwaitInSyncFunction ) p <nl> " await can only be used inside async functions " <nl> <nl> + let interface_use_trait p = <nl> + add ( NastCheck . err_code NastCheck . InterfaceUsesTrait ) p <nl> + " Interfaces cannot use traits " <nl> + <nl> let await_not_allowed p = <nl> add ( NastCheck . err_code NastCheck . AwaitNotAllowed ) p <nl> " await is only permitted as a statement , expression in a return statement \ <nl> mmm a / hphp / hack / src / errors / errors_sig . ml <nl> ppp b / hphp / hack / src / errors / errors_sig . ml <nl> module type S = sig <nl> val misplaced_rx_of_scope : Pos . t - > unit <nl> val rx_of_scope_and_explicit_rx : Pos . t - > unit <nl> val lateinit_with_default : Pos . t - > unit <nl> + val interface_use_trait : Pos . t - > unit <nl> end <nl> mmm a / hphp / hack / src / typing / nastCheck . ml <nl> ppp b / hphp / hack / src / typing / nastCheck . ml <nl> and interface c = <nl> ( * make sure constructor has no body * ) <nl> Option . iter c . c_constructor enforce_no_body ; <nl> Option . iter c . c_constructor enforce_not_async ; <nl> + List . iter ( c . c_uses ) ( fun ( p , _ ) - > <nl> + Errors . interface_use_trait p <nl> + ) ; <nl> ( * make sure that interfaces don ' t have any member variables * ) <nl> match c . c_vars with <nl> | hd : : _ - > <nl> mmm a / hphp / hack / test / errors / error_map . ml <nl> ppp b / hphp / hack / test / errors / error_map . ml <nl> MaybeMutableAttributeOnFunction = 3069 <nl> ConflictingMutableAndMaybeMutableAttributes = 3070 <nl> MaybeMutableMethodsMustBeReactive = 3071 <nl> RequiresFinalClass = 3072 <nl> + InterfaceUsesTrait = 3073 <nl> <nl> Typing Errors : <nl> AbstractClassFinalDEPRECATED = 4001 <nl> new file mode 100644 <nl> index 00000000000 . . 6be070f08f0 <nl> mmm / dev / null <nl> ppp b / hphp / hack / test / typecheck / interface_use_trait . php <nl> <nl> + < ? hh <nl> + trait Hello { } <nl> + interface I { <nl> + use Hello ; <nl> + } <nl> new file mode 100644 <nl> index 00000000000 . . 81529fec58d <nl> mmm / dev / null <nl> ppp b / hphp / hack / test / typecheck / interface_use_trait . php . exp <nl> <nl> + File " interface_use_trait . php " , line 4 , characters 7 - 11 : <nl> + Interfaces cannot use traits ( NastCheck [ 3073 ] ) <nl>
|
Do not allow interfaces to use traits
|
facebook/hhvm
|
34fb87c9fed12369111f5c3f5b25e4721b758b71
|
2018-08-17T17:58:22Z
|
similarity index 74 % <nl> rename from code / sorting / comb_sort / comb_sort . py <nl> rename to code / sorting / src / comb_sort / comb_sort . py <nl> mmm a / code / sorting / comb_sort / comb_sort . py <nl> ppp b / code / sorting / src / comb_sort / comb_sort . py <nl> def combsort ( array ) : <nl> gap = len ( array ) <nl> swap = True <nl> while gap > 1 or swap : <nl> - gap = max ( 1 , int ( gap / 1 . 25 ) ) <nl> + gap = max ( 1 , int ( gap / 1 . 25 ) ) <nl> swap = False <nl> for i in range ( len ( array ) - gap ) : <nl> - j = i + gap <nl> + j = i + gap <nl> if array [ i ] > array [ j ] : <nl> array [ i ] , array [ j ] = array [ j ] , array [ i ] <nl> swap = True <nl> - <nl> - numbers = [ 3 , 4 , 7 , 2 , 4 , 1 , 6 , 8 , 9 , 10 ] <nl> + <nl> + <nl> + numbers = [ 3 , 4 , 7 , 2 , 4 , 1 , 6 , 8 , 9 , 10 ] <nl> print ( numbers ) <nl> - <nl> + <nl> combsort ( numbers ) <nl> print ( numbers ) <nl> - <nl>
|
Changed file location
|
OpenGenus/cosmos
|
d11053a890b7d3e19fec0ab611d865685b982ec5
|
2018-02-27T23:01:14Z
|
Binary files a / tools / sdk / lib / libaxtls . a and b / tools / sdk / lib / libaxtls . a differ <nl>
|
Update axTLS to e634adf ( )
|
esp8266/Arduino
|
8f438b18dbb863af3e1f8065cd75b720e9d12e4a
|
2018-09-12T14:49:42Z
|
mmm a / platform / iphone / app_delegate . mm <nl> ppp b / platform / iphone / app_delegate . mm <nl> <nl> # import " gl_view . h " <nl> # include " main / main . h " <nl> # include " os_iphone . h " <nl> + # include " audio_driver_iphone . h " <nl> <nl> # ifdef MODULE_FACEBOOKSCORER_IOS_ENABLED <nl> # include " modules / FacebookScorer_ios / FacebookScorer . h " <nl> - ( void ) applicationDidBecomeActive : ( UIApplication * ) application { <nl> if ( OSIPhone : : get_singleton ( ) - > native_video_is_playing ( ) ) { <nl> OSIPhone : : get_singleton ( ) - > native_video_unpause ( ) ; <nl> } ; <nl> + <nl> + / / Fixed audio can not resume if it is interrupted cause by an incoming phone call <nl> + if ( AudioDriverIphone : : get_singleton ( ) ! = NULL ) <nl> + AudioDriverIphone : : get_singleton ( ) - > start ( ) ; <nl> } <nl> <nl> - ( BOOL ) application : ( UIApplication * ) application handleOpenURL : ( NSURL * ) url { <nl> mmm a / platform / iphone / audio_driver_iphone . cpp <nl> ppp b / platform / iphone / audio_driver_iphone . cpp <nl> OSStatus AudioDriverIphone : : output_callback ( void * inRefCon , <nl> <nl> void AudioDriverIphone : : start ( ) { <nl> active = true ; <nl> + / / Resume audio <nl> + / / iOS audio - thread stoped if it is interrupted cause by an incoming phone call <nl> + / / Use AudioOutputUnitStart to re - create audio - thread <nl> + OSStatus result = AudioOutputUnitStart ( audio_unit ) ; <nl> + ERR_FAIL_COND ( result ! = noErr ) ; <nl> } ; <nl> <nl> int AudioDriverIphone : : get_mix_rate ( ) const { <nl>
|
Merge pull request from sanikoyes / Pr - fix_audio_stoped_iOS
|
godotengine/godot
|
8d9206516428ca55f0832db5f261516654929676
|
2017-05-26T14:01:30Z
|
mmm a / src / network / Manager . c <nl> ppp b / src / network / Manager . c <nl> static int swManager_loop_sync ( swFactory * factory ) <nl> } <nl> <nl> sw_free ( reload_workers ) ; <nl> - <nl> + swSignal_none ( ) ; <nl> / / kill all child process <nl> for ( i = 0 ; i < serv - > worker_num ; i + + ) <nl> { <nl> mmm a / src / network / ProcessPool . c <nl> ppp b / src / network / ProcessPool . c <nl> void swProcessPool_shutdown ( swProcessPool * pool ) <nl> swWorker * worker ; <nl> SwooleG . running = 0 ; <nl> <nl> + swSignal_none ( ) ; <nl> / / concurrent kill <nl> for ( i = 0 ; i < pool - > run_worker_num ; i + + ) <nl> { <nl>
|
fix shutdown waitpid error
|
swoole/swoole-src
|
f46f03299628b444f4410294f8350b85f476cdb4
|
2016-09-16T14:34:34Z
|
mmm a / src / Layout - test - utils . js <nl> ppp b / src / Layout - test - utils . js <nl> var layoutTestUtils = ( function ( ) { <nl> _cachedIframe = iframe ; <nl> return iframe ; <nl> } else { <nl> - setTimeout ( getIframe , 0 ) ; <nl> + setTimeout ( getIframe . bind ( null , iframe ) , 0 ) ; <nl> } <nl> } <nl> <nl>
|
Fix getIframe test helper
|
facebook/yoga
|
dda464cdb9866f464ef2277994f0e3c630df4f5e
|
2015-04-01T03:27:58Z
|
mmm a / eigen . BUILD <nl> ppp b / eigen . BUILD <nl> <nl> package ( default_visibility = [ " / / visibility : public " ] ) <nl> <nl> - archive_dir = " eigen - eigen - f1ce2528ee99 " <nl> + archive_dir = " eigen - eigen - 88444e025a5c " <nl> <nl> cc_library ( <nl> name = " eigen " , <nl> mmm a / tensorflow / contrib / linear_optimizer / kernels / BUILD <nl> ppp b / tensorflow / contrib / linear_optimizer / kernels / BUILD <nl> exports_files ( [ " LICENSE " ] ) <nl> package ( default_visibility = [ " / / tensorflow : __subpackages__ " ] ) <nl> <nl> cc_library ( <nl> - name = " losses " , <nl> + name = " loss_updaters " , <nl> hdrs = [ <nl> " hinge - loss . h " , <nl> " logistic - loss . h " , <nl> + " loss . h " , <nl> " squared - loss . h " , <nl> ] , <nl> deps = [ " / / tensorflow / core : lib " ] , <nl> ) <nl> <nl> - # TODO ( katsiapis ) : Add tests for losses . <nl> + cc_test ( <nl> + name = " loss_updaters_test " , <nl> + srcs = [ " loss_updaters_test . cc " ] , <nl> + deps = [ <nl> + " : loss_updaters " , <nl> + " / / tensorflow / core : framework " , <nl> + " / / tensorflow / core : lib " , <nl> + " / / tensorflow / core : test " , <nl> + " / / tensorflow / core : test_main " , <nl> + ] , <nl> + ) <nl> <nl> cc_library ( <nl> name = " resources " , <nl> cc_library ( <nl> name = " sdca_ops " , <nl> srcs = [ " sdca_ops . cc " ] , <nl> deps = [ <nl> - " : losses " , <nl> + " : loss_updaters " , <nl> " : resources " , <nl> " / / third_party / eigen3 " , <nl> " / / tensorflow / core : framework " , <nl> mmm a / tensorflow / contrib / linear_optimizer / kernels / hinge - loss . h <nl> ppp b / tensorflow / contrib / linear_optimizer / kernels / hinge - loss . h <nl> limitations under the License . <nl> # include < algorithm > <nl> # include < cmath > <nl> <nl> + # include " tensorflow / contrib / linear_optimizer / kernels / loss . h " <nl> + # include " tensorflow / core / lib / core / errors . h " <nl> + <nl> namespace tensorflow { <nl> - struct hinge_loss { <nl> + <nl> + class HingeLossUpdater : public DualLossUpdater { <nl> + public : <nl> / / Computes the updated dual variable ( corresponding ) to a single example . The <nl> / / updated dual value maximizes the objective function of the dual <nl> / / optimization problem associated with hinge loss ( conditioned on keeping the <nl> struct hinge_loss { <nl> / / and the particular form of conjugate function for hinge loss . <nl> / / TODO ( pmol ) : Write up a doc with concrete derivation and point to it from <nl> / / here . <nl> - inline static double ComputeUpdatedDual ( const double label , <nl> - const double example_weight , <nl> - const double current_dual , <nl> - const double wx , <nl> - const double weighted_example_norm , <nl> - const double primal_loss , <nl> - const double dual_loss ) { <nl> + double ComputeUpdatedDual ( const double label , const double example_weight , <nl> + const double current_dual , const double wx , <nl> + const double weighted_example_norm , <nl> + const double primal_loss , <nl> + const double dual_loss ) const final { <nl> / / Intutitvely there are 3 cases : <nl> / / a . new optimal value of the dual variable falls withing the admissible <nl> / / range [ 0 , 1 ] . In this case we set new dual to this value . <nl> struct hinge_loss { <nl> / / on its label . In particular : <nl> / / \ phi_y * ( z ) = y * z if y * z \ in [ - w , 0 ] and + infinity everywhere else where <nl> / / y \ in { - 1 , 1 } . The following method implements \ phi_y * ( - \ alpha / w ) . <nl> - inline static double ComputeDualLoss ( const double current_dual , <nl> - const double example_label , <nl> - const double example_weight ) { <nl> + double ComputeDualLoss ( const double current_dual , const double example_label , <nl> + const double example_weight ) const final { <nl> / / For binary classification , there are 2 conjugate functions , one per <nl> / / label value ( - 1 and 1 ) . <nl> const double y_alpha = current_dual * example_label ; / / y \ alpha <nl> struct hinge_loss { <nl> / / Hinge loss for binary classification for a single example . Hinge loss <nl> / / equals max ( 0 , 1 - y * wx ) ( see https : / / en . wikipedia . org / wiki / Hinge_loss ) . <nl> / / For weighted instances loss should be multiplied by the instance weight . <nl> - inline static double ComputePrimalLoss ( const double wx , <nl> - const double example_label , <nl> - const double example_weight ) { <nl> + double ComputePrimalLoss ( const double wx , const double example_label , <nl> + const double example_weight ) const final { <nl> const double y_wx = example_label * wx ; <nl> return std : : max ( 0 . 0 , 1 - y_wx ) * example_weight ; <nl> } <nl> + <nl> + / / Converts binary example labels from 0 . 0 or 1 . 0 to - 1 . 0 or 1 . 0 respectively <nl> + / / as expected by hinge loss . <nl> + Status ConvertLabel ( float * const example_label ) const final { <nl> + if ( * example_label = = 0 . 0 ) { <nl> + * example_label = - 1 ; <nl> + return Status : : OK ( ) ; <nl> + } <nl> + if ( * example_label = = 1 . 0 ) { <nl> + return Status : : OK ( ) ; <nl> + } <nl> + return errors : : InvalidArgument ( <nl> + " Only labels of 0 . 0 or 1 . 0 are supported right now . " <nl> + " Found example with label : " , <nl> + * example_label ) ; <nl> + } <nl> } ; <nl> + <nl> } / / namespace tensorflow <nl> <nl> # endif / / THIRD_PARTY_TENSORFLOW_CONTRIB_LINEAR_OPTIMIZER_KERNELS_HINGE_LOSS_H_ <nl> mmm a / tensorflow / contrib / linear_optimizer / kernels / logistic - loss . h <nl> ppp b / tensorflow / contrib / linear_optimizer / kernels / logistic - loss . h <nl> limitations under the License . <nl> # include < algorithm > <nl> # include < cmath > <nl> <nl> + # include " tensorflow / contrib / linear_optimizer / kernels / loss . h " <nl> # include " tensorflow / core / lib / core / errors . h " <nl> - # include " tensorflow / core / lib / core / status . h " <nl> <nl> namespace tensorflow { <nl> - struct logistic_loss { <nl> - / / Partial derivative of the logistic loss w . r . t ( 1 + exp ( - ywx ) ) . <nl> - inline static double PartialDerivativeLogisticLoss ( const double wx , <nl> - const double label ) { <nl> - / / To avoid overflow , we compute partial derivative of logistic loss as <nl> - / / follows . <nl> - const double ywx = label * wx ; <nl> - if ( ywx > 0 ) { <nl> - const double exp_minus_ywx = exp ( - ywx ) ; <nl> - return exp_minus_ywx / ( 1 + exp_minus_ywx ) ; <nl> - } <nl> - return 1 / ( 1 + exp ( ywx ) ) ; <nl> - } <nl> - <nl> - / / Smoothness constant for the logistic loss . <nl> - inline static double SmoothnessConstantLogisticLoss ( <nl> - const double partial_derivative_loss , const double wx , <nl> - const double label ) { <nl> - / / Upper bound on the smoothness constant of log loss . This is 0 . 25 i . e . <nl> - / / when log - odds is zero . <nl> - return ( wx = = 0 ) ? 0 . 25 <nl> - : ( 1 - 2 * partial_derivative_loss ) / ( 2 * label * wx ) ; <nl> - } <nl> <nl> + class LogisticLossUpdater : public DualLossUpdater { <nl> + public : <nl> / / Use an approximate step that is guaranteed to decrease the dual loss . <nl> / / Derivation of this is available in Page 14 Eq 16 of <nl> / / http : / / arxiv . org / pdf / 1211 . 2717v1 . pdf <nl> - inline static double ComputeUpdatedDual ( const double label , <nl> - const double example_weight , <nl> - const double current_dual , <nl> - const double wx , <nl> - const double weighted_example_norm , <nl> - const double primal_loss , <nl> - const double dual_loss ) { <nl> + double ComputeUpdatedDual ( const double label , const double example_weight , <nl> + const double current_dual , const double wx , <nl> + const double weighted_example_norm , <nl> + const double primal_loss , <nl> + const double dual_loss ) const final { <nl> const double partial_derivative_loss = <nl> PartialDerivativeLogisticLoss ( label , wx ) ; <nl> / / f ( a ) = sup ( a * x - f ( x ) ) then a = f ' ( x ) , where a is the aproximate dual . <nl> struct logistic_loss { <nl> <nl> / / Dual of logisitic loss function . <nl> / / https : / / en . wikipedia . org / wiki / Convex_conjugate <nl> - inline static double ComputeDualLoss ( const double current_dual , <nl> - const double example_label , <nl> - const double example_weight ) { <nl> + double ComputeDualLoss ( const double current_dual , const double example_label , <nl> + const double example_weight ) const final { <nl> / / Dual of the logistic loss function is <nl> / / ay * log ( ay ) + ( 1 - ay ) * log ( 1 - ay ) , where a is the dual variable . <nl> const double ay = current_dual * example_label ; <nl> struct logistic_loss { <nl> <nl> / / Logistic loss for binary classification . <nl> / / https : / / en . wikipedia . org / wiki / Loss_functions_for_classification <nl> - inline static double ComputePrimalLoss ( const double wx , <nl> - const double example_label , <nl> - const double example_weight ) { <nl> + double ComputePrimalLoss ( const double wx , const double example_label , <nl> + const double example_weight ) const final { <nl> / / Logistic loss : <nl> / / log ( 1 + e ^ ( - ywx ) ) <nl> / / log ( e ^ 0 + e ^ ( - ywx ) ) <nl> struct logistic_loss { <nl> <nl> / / Converts binary example labels from 0 . 0 or 1 . 0 to - 1 . 0 or 1 . 0 respectively <nl> / / as expected by logistic regression . <nl> - inline static Status ConvertLabel ( float * const example_label ) { <nl> + Status ConvertLabel ( float * const example_label ) const final { <nl> if ( * example_label = = 0 . 0 ) { <nl> * example_label = - 1 ; <nl> return Status : : OK ( ) ; <nl> struct logistic_loss { <nl> " Found example with label : " , <nl> * example_label ) ; <nl> } <nl> + <nl> + private : <nl> + / / Partial derivative of the logistic loss w . r . t ( 1 + exp ( - ywx ) ) . <nl> + static inline double PartialDerivativeLogisticLoss ( const double wx , <nl> + const double label ) { <nl> + / / To avoid overflow , we compute partial derivative of logistic loss as <nl> + / / follows . <nl> + const double ywx = label * wx ; <nl> + if ( ywx > 0 ) { <nl> + const double exp_minus_ywx = exp ( - ywx ) ; <nl> + return exp_minus_ywx / ( 1 + exp_minus_ywx ) ; <nl> + } <nl> + return 1 / ( 1 + exp ( ywx ) ) ; <nl> + } <nl> + <nl> + / / Smoothness constant for the logistic loss . <nl> + static inline double SmoothnessConstantLogisticLoss ( <nl> + const double partial_derivative_loss , const double wx , <nl> + const double label ) { <nl> + / / Upper bound on the smoothness constant of log loss . This is 0 . 25 i . e . <nl> + / / when log - odds is zero . <nl> + return ( wx = = 0 ) ? 0 . 25 <nl> + : ( 1 - 2 * partial_derivative_loss ) / ( 2 * label * wx ) ; <nl> + } <nl> } ; <nl> <nl> } / / namespace tensorflow <nl> new file mode 100644 <nl> index 0000000000000 . . d827d6f764914 <nl> mmm / dev / null <nl> ppp b / tensorflow / contrib / linear_optimizer / kernels / loss . h <nl> <nl> + / * Copyright 2016 Google Inc . All Rights Reserved . <nl> + <nl> + Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + you may not use this file except in compliance with the License . <nl> + You may obtain a copy of the License at <nl> + <nl> + http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + <nl> + Unless required by applicable law or agreed to in writing , software <nl> + distributed under the License is distributed on an " AS IS " BASIS , <nl> + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + See the License for the specific language governing permissions and <nl> + limitations under the License . <nl> + = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = * / <nl> + # ifndef THIRD_PARTY_TENSORFLOW_CONTRIB_LINEAR_OPTIMIZER_KERNELS_LOSS_H_ <nl> + # define THIRD_PARTY_TENSORFLOW_CONTRIB_LINEAR_OPTIMIZER_KERNELS_LOSS_H_ <nl> + <nl> + # include " tensorflow / core / lib / core / status . h " <nl> + <nl> + namespace tensorflow { <nl> + <nl> + class DualLossUpdater { <nl> + public : <nl> + virtual ~ DualLossUpdater ( ) { } <nl> + <nl> + / / Compute update dual ( alpha ) , based on a single example . Various strategies <nl> + / / can be employed here , like newton step and / or line search or approximate <nl> + / / step that decreases the dual sub - optimality . <nl> + virtual double ComputeUpdatedDual ( const double label , <nl> + const double example_weight , <nl> + const double current_dual , const double wx , <nl> + const double weighted_example_norm , <nl> + const double primal_loss , <nl> + const double dual_loss ) const = 0 ; <nl> + <nl> + / / Compute dual loss based on the current dual ( alpha ) , example label ( y ) <nl> + / / and example weight ( cost ) . <nl> + virtual double ComputeDualLoss ( const double current_dual , <nl> + const double example_label , <nl> + const double example_weight ) const = 0 ; <nl> + <nl> + / / Compute the primal loss based on current estimate of log - odds ( wx ) , <nl> + / / example label ( y ) and example weight ( cost ) . <nl> + virtual double ComputePrimalLoss ( const double wx , const double example_label , <nl> + const double example_weight ) const = 0 ; <nl> + <nl> + / / Converts binary example labels from 0 . 0 or 1 . 0 to appropriate range for <nl> + / / each loss function . <nl> + virtual Status ConvertLabel ( float * const example_label ) const = 0 ; <nl> + } ; <nl> + <nl> + } / / namespace tensorflow <nl> + # endif / / THIRD_PARTY_TENSORFLOW_CONTRIB_LINEAR_OPTIMIZER_KERNELS_LOSS_H_ <nl> new file mode 100644 <nl> index 0000000000000 . . 7d9f05609b17a <nl> mmm / dev / null <nl> ppp b / tensorflow / contrib / linear_optimizer / kernels / loss_updaters_test . cc <nl> <nl> + / * Copyright 2016 Google Inc . All Rights Reserved . <nl> + <nl> + Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + you may not use this file except in compliance with the License . <nl> + You may obtain a copy of the License at <nl> + <nl> + http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + <nl> + Unless required by applicable law or agreed to in writing , software <nl> + distributed under the License is distributed on an " AS IS " BASIS , <nl> + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + See the License for the specific language governing permissions and <nl> + limitations under the License . <nl> + = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = * / <nl> + <nl> + # include " tensorflow / contrib / linear_optimizer / kernels / logistic - loss . h " <nl> + # include " tensorflow / contrib / linear_optimizer / kernels / squared - loss . h " <nl> + <nl> + # include " tensorflow / core / platform / test . h " <nl> + <nl> + namespace tensorflow { <nl> + namespace { <nl> + <nl> + TEST ( LogisticLoss , ComputePrimalLoss ) { <nl> + LogisticLossUpdater loss_updater ; <nl> + EXPECT_NEAR ( 0 . 693147 , loss_updater . ComputePrimalLoss ( <nl> + 0 / * wx * / , 1 / * label * / , 1 / * example weight * / ) , <nl> + 1e - 3 ) ; <nl> + EXPECT_NEAR ( 0 . 0 , loss_updater . ComputePrimalLoss ( 70 / * wx * / , 1 / * label * / , <nl> + 1 / * example weight * / ) , <nl> + 1e - 3 ) ; <nl> + EXPECT_NEAR ( 0 . 0 , loss_updater . ComputePrimalLoss ( - 70 / * wx * / , - 1 / * label * / , <nl> + 1 / * example weight * / ) , <nl> + 1e - 3 ) ; <nl> + } <nl> + <nl> + TEST ( LogisticLoss , ComputeDualLoss ) { <nl> + LogisticLossUpdater loss_updater ; <nl> + EXPECT_NEAR ( 0 . 0 , <nl> + loss_updater . ComputeDualLoss ( 0 / * current dual * / , 1 / * label * / , <nl> + 1 / * example weight * / ) , <nl> + 1e - 3 ) ; <nl> + EXPECT_NEAR ( 0 . 0 , <nl> + loss_updater . ComputeDualLoss ( 1 / * current dual * / , 1 / * label * / , <nl> + 1 / * example weight * / ) , <nl> + 1e - 3 ) ; <nl> + EXPECT_NEAR ( - 0 . 693147 , loss_updater . ComputeDualLoss ( 0 . 5 / * current dual * / , <nl> + 1 / * label * / , <nl> + 1 / * example weight * / ) , <nl> + 1e - 3 ) ; <nl> + } <nl> + <nl> + / / TODO ( rohananil ) : Add tests for dual update . <nl> + / / TODO ( dbaylor ) : Add tests for squared loss . <nl> + / / TODO ( pmol ) : Add tests for hinge loss . <nl> + <nl> + } / / namespace <nl> + } / / namespace tensorflow <nl> mmm a / tensorflow / contrib / linear_optimizer / kernels / resources . cc <nl> ppp b / tensorflow / contrib / linear_optimizer / kernels / resources . cc <nl> DataByExample : : Key DataByExample : : MakeKey ( const string & example_id ) { <nl> Hash64 ( example_id . data ( ) , example_id . size ( ) , kSeed2 ) & 0xFFFFFFFF ) ; <nl> } <nl> <nl> + DataByExample : : Data DataByExample : : Get ( const Key & key ) { <nl> + mutex_lock l ( mu_ ) ; <nl> + return data_by_key_ [ key ] ; <nl> + } <nl> + <nl> + void DataByExample : : Set ( const Key & key , const Data & data ) { <nl> + mutex_lock l ( mu_ ) ; <nl> + data_by_key_ [ key ] = data ; <nl> + } <nl> + <nl> Status DataByExample : : Visit ( <nl> std : : function < void ( const Data & data ) > visitor ) const { <nl> struct State { <nl> Status DataByExample : : Visit ( <nl> / / be successful if and only if the size of the backing store hasn ' t <nl> / / changed ( since the body of this while - loop is under lock ) . <nl> if ( data_by_key_ . size ( ) ! = state . size ) { <nl> - return errors : : Aborted ( " The number of elements for " , solver_uuid_ , <nl> - " has changed which nullifies a visit . " ) ; <nl> + return errors : : Unavailable ( " The number of elements for " , solver_uuid_ , <nl> + " has changed which nullifies a visit . " ) ; <nl> } <nl> for ( size_t i = 0 ; i < kVisitChunkSize & & state . num_visited < state . size ; <nl> + + i , + + state . num_visited , + + state . it ) { <nl> mmm a / tensorflow / contrib / linear_optimizer / kernels / resources . h <nl> ppp b / tensorflow / contrib / linear_optimizer / kernels / resources . h <nl> class DataByExample : public ResourceBase { <nl> static Key MakeKey ( const string & example_id ) ; <nl> <nl> struct Data { <nl> - / / TODO ( rohananil ) : Add extra data needed for duality gap computation here . <nl> float dual = 0 ; <nl> + float primal_loss = 0 ; <nl> + float dual_loss = 0 ; <nl> + float example_weight = 0 ; <nl> <nl> / / Comparison operators for ease of testing . <nl> bool operator = = ( const Data & other ) const { return dual = = other . dual ; } <nl> class DataByExample : public ResourceBase { <nl> / / Accessor and mutator for the entry at Key . Accessor creates an entry with <nl> / / default value ( default constructed object ) if the key is not present and <nl> / / returns it . <nl> - inline Data Get ( const Key & key ) LOCKS_EXCLUDED ( mu_ ) { <nl> - mutex_lock l ( mu_ ) ; <nl> - return data_by_key_ [ key ] ; <nl> - } <nl> - inline void Set ( const Key & key , const Data & data ) LOCKS_EXCLUDED ( mu_ ) { <nl> - mutex_lock l ( mu_ ) ; <nl> - data_by_key_ [ key ] = data ; <nl> - } <nl> + Data Get ( const Key & key ) LOCKS_EXCLUDED ( mu_ ) ; <nl> + void Set ( const Key & key , const Data & data ) LOCKS_EXCLUDED ( mu_ ) ; <nl> <nl> / / Visits all elements in this resource . The view of each element ( Data ) is <nl> / / atomic , but the entirety of the visit is not ( ie the visitor might see <nl> / / different versions of the Data across elements ) . <nl> / / <nl> - / / Returns OK on success or ABORTED if the number of elements in this <nl> + / / Returns OK on success or UNAVAILABLE if the number of elements in this <nl> / / container has changed since the beginning of the visit ( in which case the <nl> - / / visit cannot be completed and is aborted early ) . <nl> + / / visit cannot be completed and is aborted early , and computation can be <nl> + / / restarted ) . <nl> Status Visit ( std : : function < void ( const Data & data ) > visitor ) const <nl> LOCKS_EXCLUDED ( mu_ ) ; <nl> <nl> class DataByExample : public ResourceBase { <nl> <nl> / / Backing container . <nl> / / <nl> - / / sizeof ( EntryPayload ) = sizeof ( Key ) + sizeof ( Data ) = 16 . <nl> - / / So on average we use ~ 35 bytes per entry in this table . <nl> + / / sizeof ( EntryPayload ) = <nl> + / / sizeof ( Key ) + sizeof ( Data ) = <nl> + / / 12 + 16 = 28 . <nl> + / / <nl> + / / So on average we use ~ 47 . 5 ( 28 + 19 . 5 ) bytes per entry in this table . <nl> using DataByKey = std : : unordered_map < Key , Data , KeyHash > ; <nl> <nl> / / TODO ( katsiapis ) : Benchmark and / or optimize this . <nl> mmm a / tensorflow / contrib / linear_optimizer / kernels / resources_test . cc <nl> ppp b / tensorflow / contrib / linear_optimizer / kernels / resources_test . cc <nl> TEST_F ( DataByExampleTest , VisitMany ) { <nl> ( kNumElements - 1 ) * kNumElements / 2 . 0 , total_dual ) ; <nl> } <nl> <nl> - TEST_F ( DataByExampleTest , VisitAborted ) { <nl> + TEST_F ( DataByExampleTest , VisitUnavailable ) { <nl> / / Populate enough entries so that Visiting will be chunked . <nl> for ( size_t i = 0 ; i < 2 * VisitChunkSize ( ) ; + + i ) { <nl> data_by_example_ - > Get ( DataByExample : : MakeKey ( strings : : StrCat ( i ) ) ) ; <nl> TEST_F ( DataByExampleTest , VisitAborted ) { <nl> } ) ; <nl> wait ( & completed_visit ) ; <nl> EXPECT_FALSE ( thread_pool . HasPendingClosures ( ) ) ; <nl> - EXPECT_TRUE ( errors : : IsAborted ( status ) ) ; <nl> + EXPECT_TRUE ( errors : : IsUnavailable ( status ) ) ; <nl> } <nl> <nl> } / / namespace tensorflow <nl> mmm a / tensorflow / contrib / linear_optimizer / kernels / sdca_ops . cc <nl> ppp b / tensorflow / contrib / linear_optimizer / kernels / sdca_ops . cc <nl> struct RegularizationLoss { <nl> } ; <nl> <nl> struct PerExampleData { <nl> - double old_wx = 0 ; <nl> double wx = 0 ; <nl> double norm = 0 ; <nl> } ; <nl> inline PerExampleData ComputeWxAndWeightedExampleNorm ( <nl> const int64 index = indices ( dim ) ; <nl> const double weight = weights ( index ) ; <nl> const double value = values ( dim ) ; <nl> - result . old_wx + = Shrink ( weight , shrink_by ) * value ; <nl> result . wx + = Shrink ( weight + delta_weights ( index ) , shrink_by ) * value ; <nl> } <nl> result . norm + = sparse_indices_values [ example_id ] - > norm ; <nl> inline PerExampleData ComputeWxAndWeightedExampleNorm ( <nl> for ( size_t i = 0 ; i < dense_features_by_group . size ( ) ; + + i ) { <nl> const double weight = dense_weights_by_group [ i ] ( 0 ) ; <nl> const double value = dense_features_by_group [ i ] ( example_id ) ; <nl> - result . old_wx + = Shrink ( weight , shrink_by ) * value ; <nl> result . wx + = <nl> Shrink ( weight + dense_delta_weights_by_group [ i ] ( 0 ) , shrink_by ) * value ; <nl> result . norm + = value * value ; <nl> void AddDeltaWeights ( const WeightsByGroup & src , WeightsByGroup * const dst ) { <nl> void ShrinkWeights ( const Regularizations & regularizations , <nl> WeightsByGroup * const sparse_weights_by_group , <nl> WeightsByGroup * const dense_weights_by_group ) { <nl> + / / TODO ( rohananil ) : Parallelize shrinking . <nl> const double shrink_by = ShrinkageFactor ( regularizations ) ; <nl> for ( TTypes < float > : : Vec weights : * sparse_weights_by_group ) { <nl> for ( int64 i = 0 ; i < weights . size ( ) ; + + i ) { <nl> WeightsByGroup MakeDeltaWeightsFrom ( std : : vector < Tensor > * const tensors ) { <nl> return result ; <nl> } <nl> <nl> + Status RunTrainStepsForMiniBatch ( <nl> + const std : : vector < int64 > & example_indices , <nl> + const TTypes < const string > : : Vec example_ids , <nl> + const TTypes < const float > : : Vec example_labels , <nl> + const TTypes < const float > : : Vec example_weights , <nl> + const DeviceBase : : CpuWorkerThreads & worker_threads , <nl> + const Regularizations & regularizations , <nl> + const WeightsByGroup & sparse_weights_by_group , <nl> + const SparseExamplesByGroup & sparse_examples_by_group , <nl> + const WeightsByGroup & dense_weights_by_group , <nl> + const DenseFeaturesByGroup & dense_features_by_group , <nl> + const DualLossUpdater & loss_updater , <nl> + WeightsByGroup * const sparse_delta_weights_by_group , <nl> + WeightsByGroup * const dense_delta_weights_by_group , <nl> + DataByExample * const data_by_example ) { <nl> + / / Process examples in parallel , in a partitioned fashion . <nl> + mutex mu ; <nl> + Status train_step_status GUARDED_BY ( mu ) ; <nl> + auto train_step = [ & ] ( const int64 begin , const int64 end ) { <nl> + for ( int64 offset = begin ; offset < end ; + + offset ) { <nl> + / / Get example id , label , and weight . <nl> + const int64 example_index = example_indices [ offset ] ; <nl> + const DataByExample : : Key example_key = <nl> + DataByExample : : MakeKey ( example_ids ( example_index ) ) ; <nl> + DataByExample : : Data data = data_by_example - > Get ( example_key ) ; <nl> + const double example_weight = example_weights ( example_index ) ; <nl> + float example_label = example_labels ( example_index ) ; <nl> + const Status conversion_status = <nl> + loss_updater . ConvertLabel ( & example_label ) ; <nl> + if ( ! conversion_status . ok ( ) ) { <nl> + mutex_lock l ( mu ) ; <nl> + train_step_status = conversion_status ; <nl> + / / Return from this worker thread - the calling thread is <nl> + / / responsible for checking context status and returning on error . <nl> + return ; <nl> + } <nl> + <nl> + / / Compute wx , example norm weighted by regularization , dual loss , <nl> + / / primal loss . <nl> + const PerExampleData per_example_data = ComputeWxAndWeightedExampleNorm ( <nl> + example_index , sparse_weights_by_group , <nl> + * sparse_delta_weights_by_group , sparse_examples_by_group , <nl> + dense_weights_by_group , * dense_delta_weights_by_group , <nl> + dense_features_by_group , regularizations ) ; <nl> + <nl> + const double primal_loss = loss_updater . ComputePrimalLoss ( <nl> + per_example_data . wx , example_label , example_weight ) ; <nl> + <nl> + const double dual_loss = loss_updater . ComputeDualLoss ( <nl> + data . dual , example_label , example_weight ) ; <nl> + <nl> + const double new_dual = loss_updater . ComputeUpdatedDual ( <nl> + example_label , example_weight , data . dual , per_example_data . wx , <nl> + per_example_data . norm , primal_loss , dual_loss ) ; <nl> + <nl> + / / Compute new weights . <nl> + const double bounded_dual_delta = ( new_dual - data . dual ) * example_weight ; <nl> + UpdateDeltaWeights ( <nl> + example_index , sparse_examples_by_group , dense_features_by_group , <nl> + bounded_dual_delta , regularizations . symmetric_l2 , <nl> + sparse_delta_weights_by_group , dense_delta_weights_by_group ) ; <nl> + <nl> + / / Update example data . <nl> + data . dual = new_dual ; <nl> + data . primal_loss = primal_loss ; <nl> + data . dual_loss = dual_loss ; <nl> + data . example_weight = example_weight ; <nl> + data_by_example - > Set ( example_key , data ) ; <nl> + } <nl> + / / TODO ( rohananil ) : We may in the future want to make the primal - dual <nl> + / / relationship consistent as our current updates are not <nl> + / / transactional . <nl> + } ; <nl> + / / TODO ( rohananil ) : Current multiplier 100000 works well empirically <nl> + / / but perhaps we can tune it better . <nl> + const int64 kCostPerUnit = 100000 * ( sparse_examples_by_group . size ( ) + <nl> + dense_features_by_group . size ( ) ) ; <nl> + Shard ( worker_threads . num_threads , worker_threads . workers , <nl> + example_indices . size ( ) , kCostPerUnit , train_step ) ; <nl> + return train_step_status ; <nl> + } <nl> + <nl> } / / namespace <nl> <nl> class SdcaSolver : public OpKernel { <nl> class SdcaSolver : public OpKernel { <nl> string loss_type ; <nl> OP_REQUIRES_OK ( context , context - > GetAttr ( " loss_type " , & loss_type ) ) ; <nl> if ( loss_type = = " logistic_loss " ) { <nl> - compute_dual_loss_ = logistic_loss : : ComputeDualLoss ; <nl> - compute_primal_loss_ = logistic_loss : : ComputePrimalLoss ; <nl> - compute_dual_update_ = logistic_loss : : ComputeUpdatedDual ; <nl> - convert_label_ = logistic_loss : : ConvertLabel ; <nl> + loss_updater_ . reset ( new LogisticLossUpdater ) ; <nl> } else if ( loss_type = = " squared_loss " ) { <nl> - compute_dual_loss_ = squared_loss : : ComputeDualLoss ; <nl> - compute_primal_loss_ = squared_loss : : ComputePrimalLoss ; <nl> - compute_dual_update_ = squared_loss : : ComputeUpdatedDual ; <nl> - convert_label_ = squared_loss : : ConvertLabel ; <nl> + loss_updater_ . reset ( new SquaredLossUpdater ) ; <nl> } else if ( loss_type = = " hinge_loss " ) { <nl> - compute_dual_loss_ = hinge_loss : : ComputeDualLoss ; <nl> - compute_primal_loss_ = hinge_loss : : ComputePrimalLoss ; <nl> - compute_dual_update_ = hinge_loss : : ComputeUpdatedDual ; <nl> - / / Label conversion is identical for hinge and logistic loss . <nl> - convert_label_ = logistic_loss : : ConvertLabel ; <nl> + loss_updater_ . reset ( new HingeLossUpdater ) ; <nl> } else { <nl> OP_REQUIRES ( context , false , errors : : InvalidArgument ( <nl> " Unsupported loss type : " , loss_type ) ) ; <nl> class SdcaSolver : public OpKernel { <nl> regularizations_ . symmetric_l2 = <nl> std : : max ( regularizations_ . symmetric_l2 , 1 . 0f ) ; <nl> <nl> - OP_REQUIRES_OK ( context , context - > GetAttr ( " duality_gap_threshold " , <nl> - & duality_gap_threshold_ ) ) ; <nl> + OP_REQUIRES_OK ( context , context - > GetAttr ( " num_inner_iterations " , <nl> + & num_inner_iterations_ ) ) ; <nl> + <nl> + / / TODO ( rohananil ) : Provide emperical evidence for this . It is better to run <nl> + / / more than one iteration on single mini - batch as we want to spend more <nl> + / / time in compute . SDCA works better with larger mini batches and there <nl> + / / is also recent work that shows its better to reuse old samples than train <nl> + / / on new samples . See : http : / / arxiv . org / abs / 1602 . 02136 . <nl> + num_inner_iterations_ = <nl> + std : : max ( num_inner_iterations_ , static_cast < int64 > ( 2 ) ) ; <nl> OP_REQUIRES_OK ( context , context - > GetAttr ( " container " , & container_ ) ) ; <nl> OP_REQUIRES_OK ( context , context - > GetAttr ( " solver_uuid " , & solver_uuid_ ) ) ; <nl> } <nl> class SdcaSolver : public OpKernel { <nl> } ) ) ; <nl> OP_REQUIRES ( <nl> context , ! data_by_example - > RefCountIsOne ( ) , <nl> - errors : : Internal ( " Expected shared - ownership of duals_by_example . " ) ) ; <nl> + errors : : Internal ( " Expected shared - ownership of data_by_example . " ) ) ; <nl> <nl> const Tensor * example_weights_t ; <nl> OP_REQUIRES_OK ( context , <nl> class SdcaSolver : public OpKernel { <nl> errors : : InvalidArgument ( " No weighted examples in " , <nl> num_examples , " training examples " ) ) ; <nl> <nl> - Tensor primal_loss_t ; <nl> - OP_REQUIRES_OK ( context , <nl> - context - > mutable_input ( " primal_loss " , & primal_loss_t , <nl> - / * lock_held = * / true ) ) ; <nl> - OP_REQUIRES ( context , TensorShapeUtils : : IsScalar ( primal_loss_t . shape ( ) ) , <nl> - errors : : InvalidArgument ( " primal_loss should be a scalar . " ) ) ; <nl> - auto primal_loss = primal_loss_t . scalar < double > ( ) ; <nl> - <nl> OpInputList dense_features_inputs ; <nl> OP_REQUIRES_OK ( <nl> context , context - > input_list ( " dense_features " , & dense_features_inputs ) ) ; <nl> class SdcaSolver : public OpKernel { <nl> OpMutableInputList sparse_weights_inputs ; <nl> OP_REQUIRES_OK ( context , context - > mutable_input_list ( <nl> " sparse_weights " , & sparse_weights_inputs ) ) ; <nl> + <nl> WeightsByGroup sparse_weights_by_group = <nl> MakeWeightsFrom ( & sparse_weights_inputs ) ; <nl> std : : vector < Tensor > sparse_delta_weights_by_group_backing_store = <nl> class SdcaSolver : public OpKernel { <nl> WeightsByGroup sparse_delta_weights_by_group = <nl> MakeDeltaWeightsFrom ( & sparse_delta_weights_by_group_backing_store ) ; <nl> <nl> - / / TODO ( rohananil ) : Remove the code duplication between sparse and <nl> - / / dense weights . <nl> OpMutableInputList dense_weights_inputs ; <nl> OP_REQUIRES_OK ( context , context - > mutable_input_list ( " dense_weights " , <nl> & dense_weights_inputs ) ) ; <nl> + <nl> WeightsByGroup dense_weights_by_group = <nl> MakeWeightsFrom ( & dense_weights_inputs ) ; <nl> std : : vector < Tensor > dense_delta_weights_by_group_backing_store = <nl> class SdcaSolver : public OpKernel { <nl> * context - > device ( ) - > tensorflow_cpu_worker_threads ( ) , <nl> & sparse_examples_by_group ) ) ; <nl> <nl> - / / Those will be shuffled below at each iteration and processed in a <nl> - / / partitioned fashion across multiple threads . <nl> - std : : vector < int64 > example_indices ( num_examples ) ; <nl> - std : : iota ( example_indices . begin ( ) , example_indices . end ( ) , 0 ) ; <nl> - <nl> - std : : random_device random_device ; <nl> - std : : mt19937 random_generator ( random_device ( ) ) ; <nl> - <nl> - / / Break when duality gap | P ( w ) - D ( alpha ) | is less than <nl> - / / duality_gap_threshold_ <nl> - double total_duality_gap = std : : numeric_limits < double > : : max ( ) ; <nl> - while ( ( total_duality_gap / weighted_examples ) > duality_gap_threshold_ ) { <nl> - std : : atomic < double > total_primal_loss ( 0 ) ; <nl> - std : : atomic < double > total_dual_loss ( 0 ) ; <nl> - SetZeroDeltaWeights ( & sparse_delta_weights_by_group , <nl> - & dense_delta_weights_by_group ) ; <nl> - <nl> - / / Compute regularization loss at the start of the iteration so that <nl> - / / we can compute an exact value of duality gap ( for the weights from <nl> - / / the previous iteration ) . <nl> - const RegularizationLoss regularization_loss = ComputeRegularizationLoss ( <nl> - sparse_weights_by_group , dense_weights_by_group , regularizations_ ) ; <nl> + SetZeroDeltaWeights ( & sparse_delta_weights_by_group , <nl> + & dense_delta_weights_by_group ) ; <nl> <nl> + / / Examples are shuffled below at each iteration and processed in a <nl> + / / partitioned fashion across multiple threads . <nl> + / / TODO ( rohananil ) : We may want to avoid shuffling inside the op <nl> + / / but instead shuffle outside as part of the input reader . Re - evaluate <nl> + / / once we have more data on how this op is used . <nl> + const std : : vector < int64 > example_indices = [ num_examples ] ( ) { <nl> + std : : vector < int64 > result ( num_examples ) ; <nl> + std : : iota ( result . begin ( ) , result . end ( ) , 0 ) ; <nl> + std : : random_device random_device ; <nl> + std : : mt19937 random_generator ( random_device ( ) ) ; <nl> / / Randomize the examples across iterations for faster convergence . <nl> - std : : shuffle ( example_indices . begin ( ) , example_indices . end ( ) , <nl> - random_generator ) ; <nl> - <nl> - { <nl> - / / Process examples in parallel , in a partitioned fashion . <nl> - mutex mu ; <nl> - Status update_status GUARDED_BY ( mu ) ; <nl> - auto update_partition = [ & ] ( const int64 begin , const int64 end ) { <nl> - double dual_loss_on_example_subset = 0 ; <nl> - double primal_loss_on_example_subset = 0 ; <nl> - for ( int64 offset = begin ; offset < end ; + + offset ) { <nl> - / / Get example id , label , and weight . <nl> - const int64 example_index = example_indices [ offset ] ; <nl> - const DataByExample : : Key example_key = <nl> - DataByExample : : MakeKey ( example_ids ( example_index ) ) ; <nl> - DataByExample : : Data data = data_by_example - > Get ( example_key ) ; <nl> - const double example_weight = example_weights ( example_index ) ; <nl> - float example_label = example_labels ( example_index ) ; <nl> - const Status conversion_status = convert_label_ ( & example_label ) ; <nl> - if ( ! conversion_status . ok ( ) ) { <nl> - mutex_lock l ( mu ) ; <nl> - update_status = conversion_status ; <nl> - / / Return from this worker thread - the calling thread is <nl> - / / responsible for checking context status and returning on error . <nl> - return ; <nl> - } <nl> - <nl> - / / Compute wx , example norm weighted by regularization , dual loss , <nl> - / / primal loss . <nl> - const PerExampleData per_example_data = <nl> - ComputeWxAndWeightedExampleNorm ( <nl> - example_index , sparse_weights_by_group , <nl> - sparse_delta_weights_by_group , sparse_examples_by_group , <nl> - dense_weights_by_group , dense_delta_weights_by_group , <nl> - dense_features_by_group , regularizations_ ) ; <nl> - / / Compute primal based on the previous iteration . <nl> - primal_loss_on_example_subset + = compute_primal_loss_ ( <nl> - per_example_data . old_wx , example_label , example_weight ) ; <nl> - <nl> - const double primal_loss = compute_primal_loss_ ( <nl> - per_example_data . wx , example_label , example_weight ) ; <nl> - <nl> - const double dual_loss = <nl> - compute_dual_loss_ ( data . dual , example_label , example_weight ) ; <nl> - dual_loss_on_example_subset + = dual_loss ; <nl> - <nl> - const double new_dual = compute_dual_update_ ( <nl> - example_label , example_weight , data . dual , per_example_data . wx , <nl> - per_example_data . norm , primal_loss , dual_loss ) ; <nl> - <nl> - / / Compute new weights . <nl> - const double bounded_dual_delta = <nl> - ( new_dual - data . dual ) * example_weight ; <nl> - UpdateDeltaWeights ( example_index , sparse_examples_by_group , <nl> - dense_features_by_group , bounded_dual_delta , <nl> - regularizations_ . symmetric_l2 , <nl> - & sparse_delta_weights_by_group , <nl> - & dense_delta_weights_by_group ) ; <nl> - <nl> - / / Update dual variable . <nl> - data . dual = new_dual ; <nl> - data_by_example - > Set ( example_key , data ) ; <nl> - } <nl> - AtomicAdd ( primal_loss_on_example_subset , & total_primal_loss ) ; <nl> - AtomicAdd ( dual_loss_on_example_subset , & total_dual_loss ) ; <nl> - / / TODO ( rohananil ) : We may in the future want to make the primal - dual <nl> - / / relationship consistent as our current updates are not <nl> - / / transactional . <nl> - } ; <nl> - const DeviceBase : : CpuWorkerThreads & worker_threads = <nl> - * context - > device ( ) - > tensorflow_cpu_worker_threads ( ) ; <nl> - / / TODO ( katsiapis ) : Current multiplier ( 100 , 000 ) works well empirically <nl> - / / but perhaps we can tune it better . <nl> - const int64 kCostPerUnit = <nl> - 100000 * ( num_sparse_features_ + num_dense_features_ ) ; <nl> - Shard ( worker_threads . num_threads , worker_threads . workers , num_examples , <nl> - kCostPerUnit , update_partition ) ; <nl> - OP_REQUIRES_OK ( context , update_status ) ; <nl> - } <nl> + std : : shuffle ( result . begin ( ) , result . end ( ) , random_generator ) ; <nl> + return result ; <nl> + } ( ) ; <nl> <nl> - total_duality_gap = total_primal_loss . load ( ) + total_dual_loss . load ( ) + <nl> - regularization_loss . l1_loss + <nl> - regularization_loss . l2_loss ; <nl> - primal_loss ( ) = ( total_primal_loss . load ( ) + regularization_loss . l1_loss + <nl> - regularization_loss . l2_loss ) / <nl> - weighted_examples ; <nl> - AddDeltaWeights ( sparse_delta_weights_by_group , & sparse_weights_by_group ) ; <nl> - AddDeltaWeights ( dense_delta_weights_by_group , & dense_weights_by_group ) ; <nl> + / / TODO ( rohananil ) : Provide emperical evidence for this . It is better to run <nl> + / / more than one iteration on single mini - batch as we want to spend more <nl> + / / time in compute . SDCA works better with larger mini batches and there <nl> + / / is also recent work that shows its better to reuse old samples than train <nl> + / / on new samples . See : http : / / arxiv . org / abs / 1602 . 02136 . <nl> + for ( int64 i = 0 ; i < num_inner_iterations_ ; + + i ) { <nl> + OP_REQUIRES_OK ( <nl> + context , <nl> + RunTrainStepsForMiniBatch ( <nl> + example_indices , example_ids , example_labels , example_weights , <nl> + * context - > device ( ) - > tensorflow_cpu_worker_threads ( ) , <nl> + regularizations_ , sparse_weights_by_group , <nl> + sparse_examples_by_group , dense_weights_by_group , <nl> + dense_features_by_group , * loss_updater_ , <nl> + & sparse_delta_weights_by_group , & dense_delta_weights_by_group , <nl> + data_by_example ) ) ; <nl> } <nl> - ShrinkWeights ( regularizations_ , & sparse_weights_by_group , <nl> - & dense_weights_by_group ) ; <nl> + <nl> + / / TODO ( rohananil ) : Change to atomic < float > as we are not exposing delta <nl> + / / weights to users . This will allows us to simplify the code that currently <nl> + / / keeps a backing store for the tensors . This also avoids losing updates <nl> + / / when done in a lockless way . <nl> + AddDeltaWeights ( sparse_delta_weights_by_group , & sparse_weights_by_group ) ; <nl> + AddDeltaWeights ( dense_delta_weights_by_group , & dense_weights_by_group ) ; <nl> <nl> / / TODO ( katsiapis ) : Use core : : ScopedUnref once it ' s moved out of internal . <nl> data_by_example - > Unref ( ) ; <nl> } <nl> <nl> private : <nl> - std : : function < decltype ( logistic_loss : : ComputeDualLoss ) > compute_dual_loss_ ; <nl> - std : : function < decltype ( logistic_loss : : ComputePrimalLoss ) > <nl> - compute_primal_loss_ ; <nl> - std : : function < decltype ( logistic_loss : : ComputeUpdatedDual ) > <nl> - compute_dual_update_ ; <nl> - std : : function < decltype ( logistic_loss : : ConvertLabel ) > convert_label_ ; <nl> + / / TODO ( rohananil ) : We could use the type - constraint on loss_type , and <nl> + / / template the entire class to avoid the virtual table lookup penalty in <nl> + / / the inner loop . <nl> + std : : unique_ptr < DualLossUpdater > loss_updater_ ; <nl> int64 num_sparse_features_ ; <nl> int64 num_dense_features_ ; <nl> Regularizations regularizations_ ; <nl> - float duality_gap_threshold_ ; <nl> + int64 num_inner_iterations_ ; <nl> string container_ ; <nl> string solver_uuid_ ; <nl> } ; <nl> REGISTER_KERNEL_BUILDER ( Name ( " SdcaSolver " ) . Device ( DEVICE_CPU ) , SdcaSolver ) ; <nl> <nl> + class SdcaShrinkL1 : public OpKernel { <nl> + public : <nl> + explicit SdcaShrinkL1 ( OpKernelConstruction * context ) : OpKernel ( context ) { <nl> + OP_REQUIRES_OK ( context , <nl> + context - > GetAttr ( " l1 " , & regularizations_ . symmetric_l1 ) ) ; <nl> + OP_REQUIRES_OK ( context , <nl> + context - > GetAttr ( " l2 " , & regularizations_ . symmetric_l2 ) ) ; <nl> + / / We enforce a minimal l2 , required by the algorithm . <nl> + regularizations_ . symmetric_l2 = <nl> + std : : max ( regularizations_ . symmetric_l2 , 1 . 0f ) ; <nl> + } <nl> + <nl> + void Compute ( OpKernelContext * context ) override { <nl> + OpMutableInputList sparse_weights_inputs ; <nl> + OP_REQUIRES_OK ( context , context - > mutable_input_list ( <nl> + " sparse_weights " , & sparse_weights_inputs ) ) ; <nl> + WeightsByGroup sparse_weights_by_group = <nl> + MakeWeightsFrom ( & sparse_weights_inputs ) ; <nl> + <nl> + OpMutableInputList dense_weights_inputs ; <nl> + OP_REQUIRES_OK ( context , context - > mutable_input_list ( " dense_weights " , <nl> + & dense_weights_inputs ) ) ; <nl> + WeightsByGroup dense_weights_by_group = <nl> + MakeWeightsFrom ( & dense_weights_inputs ) ; <nl> + <nl> + ShrinkWeights ( regularizations_ , & sparse_weights_by_group , <nl> + & dense_weights_by_group ) ; <nl> + } <nl> + <nl> + private : <nl> + Regularizations regularizations_ ; <nl> + } ; <nl> + REGISTER_KERNEL_BUILDER ( Name ( " SdcaShrinkL1 " ) . Device ( DEVICE_CPU ) , SdcaShrinkL1 ) ; <nl> + <nl> + class ComputeDualityGap : public OpKernel { <nl> + public : <nl> + explicit ComputeDualityGap ( OpKernelConstruction * context ) <nl> + : OpKernel ( context ) { <nl> + / / TODO ( rohananil ) : Refactor grabbing common attributes across ops related <nl> + / / to sdca . <nl> + OP_REQUIRES_OK ( context , <nl> + context - > GetAttr ( " l1 " , & regularizations_ . symmetric_l1 ) ) ; <nl> + OP_REQUIRES_OK ( context , <nl> + context - > GetAttr ( " l2 " , & regularizations_ . symmetric_l2 ) ) ; <nl> + / / We enforce a minimal l2 , required by the algorithm . <nl> + regularizations_ . symmetric_l2 = <nl> + std : : max ( regularizations_ . symmetric_l2 , 1 . 0f ) ; <nl> + OP_REQUIRES_OK ( context , context - > GetAttr ( " container " , & container_ ) ) ; <nl> + OP_REQUIRES_OK ( context , context - > GetAttr ( " solver_uuid " , & solver_uuid_ ) ) ; <nl> + } <nl> + <nl> + void Compute ( OpKernelContext * context ) override { <nl> + DataByExample * data_by_example = nullptr ; <nl> + OP_REQUIRES_OK ( context , context - > resource_manager ( ) - > Lookup < DataByExample > ( <nl> + container_ , solver_uuid_ , & data_by_example ) ) ; <nl> + OP_REQUIRES ( <nl> + context , ! data_by_example - > RefCountIsOne ( ) , <nl> + errors : : Internal ( " Expected shared - ownership of data_by_example . " ) ) ; <nl> + <nl> + OpMutableInputList sparse_weights_inputs ; <nl> + OP_REQUIRES_OK ( context , context - > mutable_input_list ( <nl> + " sparse_weights " , & sparse_weights_inputs ) ) ; <nl> + WeightsByGroup sparse_weights_by_group = <nl> + MakeWeightsFrom ( & sparse_weights_inputs ) ; <nl> + <nl> + OpMutableInputList dense_weights_inputs ; <nl> + OP_REQUIRES_OK ( context , context - > mutable_input_list ( " dense_weights " , <nl> + & dense_weights_inputs ) ) ; <nl> + WeightsByGroup dense_weights_by_group = <nl> + MakeWeightsFrom ( & dense_weights_inputs ) ; <nl> + <nl> + double example_weight_sum = 0 ; <nl> + double total_duality_gap = 0 ; <nl> + OP_REQUIRES_OK ( context , <nl> + data_by_example - > Visit ( [ & ] ( const DataByExample : : Data & data ) { <nl> + example_weight_sum + = data . example_weight ; <nl> + total_duality_gap + = data . primal_loss + data . dual_loss ; <nl> + } ) ) ; <nl> + <nl> + const RegularizationLoss regularization_loss = ComputeRegularizationLoss ( <nl> + sparse_weights_by_group , dense_weights_by_group , regularizations_ ) ; <nl> + total_duality_gap + = <nl> + regularization_loss . l2_loss + regularization_loss . l1_loss ; <nl> + <nl> + Tensor * duality_gap_t = nullptr ; <nl> + OP_REQUIRES_OK ( context , <nl> + context - > allocate_output ( " duality_gap " , { } , & duality_gap_t ) ) ; <nl> + duality_gap_t - > scalar < float > ( ) ( ) = total_duality_gap / example_weight_sum ; <nl> + <nl> + / / TODO ( katsiapis ) : Use core : : ScopedUnref once it ' s moved out of internal . <nl> + data_by_example - > Unref ( ) ; <nl> + } <nl> + <nl> + private : <nl> + Regularizations regularizations_ ; <nl> + string container_ ; <nl> + string solver_uuid_ ; <nl> + } ; <nl> + REGISTER_KERNEL_BUILDER ( Name ( " ComputeDualityGap " ) . Device ( DEVICE_CPU ) , <nl> + ComputeDualityGap ) ; <nl> } / / namespace tensorflow <nl> mmm a / tensorflow / contrib / linear_optimizer / kernels / squared - loss . h <nl> ppp b / tensorflow / contrib / linear_optimizer / kernels / squared - loss . h <nl> limitations under the License . <nl> # include < algorithm > <nl> # include < cmath > <nl> <nl> - # include " tensorflow / core / lib / core / status . h " <nl> + # include " tensorflow / contrib / linear_optimizer / kernels / loss . h " <nl> <nl> namespace tensorflow { <nl> - struct squared_loss { <nl> + <nl> + class SquaredLossUpdater : public DualLossUpdater { <nl> + public : <nl> / / Closed form solution that decreases the dual squared loss . <nl> / / See page 23 of http : / / arxiv . org / pdf / 1309 . 2375v2 . pdf <nl> - inline static double ComputeUpdatedDual ( const double label , <nl> - const double example_weight , <nl> - const double current_dual , <nl> - const double wx , <nl> - const double weighted_example_norm , <nl> - const double primal_loss_unused , <nl> - const double dual_loss_unused ) { <nl> + double ComputeUpdatedDual ( const double label , const double example_weight , <nl> + const double current_dual , const double wx , <nl> + const double weighted_example_norm , <nl> + const double primal_loss_unused , <nl> + const double dual_loss_unused ) const final { <nl> const double delta_numerator = ( label - current_dual - wx ) * example_weight ; <nl> const double delta_denominator = <nl> 1 + weighted_example_norm * example_weight * example_weight * 0 . 5 ; <nl> struct squared_loss { <nl> <nl> / / Dual of squared loss function . <nl> / / https : / / en . wikipedia . org / wiki / Convex_conjugate <nl> - inline static double ComputeDualLoss ( const double current_dual , <nl> - const double example_label , <nl> - const double example_weight ) { <nl> + double ComputeDualLoss ( const double current_dual , const double example_label , <nl> + const double example_weight ) const final { <nl> / / Dual of the squared loss function = b * ( y + b / 2 ) , where b is the <nl> / / dual variable and y is the label . This is Dual ( - b ) . <nl> return current_dual * ( 0 . 5 * current_dual - example_label ) * example_weight ; <nl> } <nl> <nl> / / Squared loss for linear regression . <nl> - inline static double ComputePrimalLoss ( const double wx , <nl> - const double example_label , <nl> - const double example_weight ) { <nl> + double ComputePrimalLoss ( const double wx , const double example_label , <nl> + const double example_weight ) const final { <nl> const double error = wx - example_label ; <nl> return error * error * example_weight * 0 . 5 ; <nl> } <nl> <nl> / / Labels don ' t require conversion for linear regression . <nl> - inline static Status ConvertLabel ( float * const example_label ) { <nl> + Status ConvertLabel ( float * const example_label ) const final { <nl> return Status : : OK ( ) ; <nl> } <nl> } ; <nl> + <nl> } / / namespace tensorflow <nl> <nl> # endif / / THIRD_PARTY_TENSORFLOW_CONTRIB_LINEAR_OPTIMIZER_KERNELS_SQUARED_LOSS_H_ <nl> mmm a / tensorflow / contrib / linear_optimizer / ops / sdca_ops . cc <nl> ppp b / tensorflow / contrib / linear_optimizer / ops / sdca_ops . cc <nl> REGISTER_OP ( " SdcaSolver " ) <nl> . Attr ( " num_sparse_features : int > = 0 " ) <nl> . Attr ( " num_dense_features : int > = 0 " ) <nl> . Attr ( " l1 : float > = 0 " ) <nl> - . Attr ( " l2 : float > = 0 " ) <nl> - . Attr ( " duality_gap_threshold : float = 0 . 01 " ) <nl> + . Attr ( " l2 : float > = 1 " ) <nl> + . Attr ( " num_inner_iterations : int > = 2 " ) <nl> . Attr ( " container : string " ) <nl> . Attr ( " solver_uuid : string " ) <nl> . Input ( " sparse_features_indices : num_sparse_features * int64 " ) <nl> REGISTER_OP ( " SdcaSolver " ) <nl> . Input ( " example_ids : string " ) <nl> . Input ( " sparse_weights : Ref ( num_sparse_features * float ) " ) <nl> . Input ( " dense_weights : Ref ( num_dense_features * float ) " ) <nl> - . Input ( " primal_loss : Ref ( double ) " ) <nl> . Doc ( R " doc ( <nl> Stochastic Dual Coordinate Ascent ( SDCA ) optimizer for linear models with <nl> L1 + L2 regularization . As global optimization objective is strongly - convex , the <nl> num_sparse_features : Number of sparse feature groups to train on . <nl> num_dense_features : Number of dense feature groups to train on . <nl> l1 : Symmetric l1 regularization strength . <nl> l2 : Symmetric l2 regularization strength . <nl> - duality_gap_threshold : Gap threshold at which we should stop training . <nl> + num_inner_iterations : Number of iterations per mini - batch . <nl> container : Name of the Container that stores data across invocations of this <nl> Kernel . Together with SolverUUID form an isolation unit for this solver . <nl> solver_uuid : Universally Unique Identifier for this solver . <nl> dense_weights : a list of vectors where the value is the weight associated with <nl> a dense feature group . <nl> ) doc " ) ; <nl> <nl> + REGISTER_OP ( " SdcaShrinkL1 " ) <nl> + . Attr ( " num_sparse_features : int > = 0 " ) <nl> + . Attr ( " num_dense_features : int > = 0 " ) <nl> + . Attr ( " l1 : float > = 0 " ) <nl> + . Attr ( " l2 : float > = 1 " ) <nl> + . Input ( " sparse_weights : Ref ( num_sparse_features * float ) " ) <nl> + . Input ( " dense_weights : Ref ( num_dense_features * float ) " ) <nl> + . Doc ( R " doc ( <nl> + Applies L1 regularization shrink step on the parameters . <nl> + <nl> + num_sparse_features : Number of sparse feature groups to train on . <nl> + num_dense_features : Number of dense feature groups to train on . <nl> + l1 : Symmetric l1 regularization strength . <nl> + l2 : Symmetric l2 regularization strength . <nl> + sparse_weights : a list of vectors where each value is the weight associated with <nl> + a feature index . <nl> + dense_weights : a list of vectors where the value is the weight associated with <nl> + a dense feature group . <nl> + ) doc " ) ; <nl> + <nl> + / / TODO ( katsiapis ) : We should expand this scope of this op to compute other <nl> + / / statistics about the data . <nl> + REGISTER_OP ( " ComputeDualityGap " ) <nl> + . Attr ( " num_sparse_features : int > = 0 " ) <nl> + . Attr ( " num_dense_features : int > = 0 " ) <nl> + . Attr ( " l1 : float > = 0 " ) <nl> + . Attr ( " l2 : float > = 1 " ) <nl> + . Attr ( " container : string " ) <nl> + . Attr ( " solver_uuid : string " ) <nl> + . Input ( " sparse_weights : Ref ( num_sparse_features * float ) " ) <nl> + . Input ( " dense_weights : Ref ( num_dense_features * float ) " ) <nl> + . Output ( " duality_gap : float " ) <nl> + . Doc ( R " doc ( <nl> + Computes duality gap over all examples seen by the optimizer . <nl> + <nl> + num_sparse_features : Number of sparse feature groups to train on . <nl> + num_dense_features : Number of dense feature groups to train on . <nl> + l1 : Symmetric l1 regularization strength . <nl> + l2 : Symmetric l2 regularization strength . <nl> + container : Name of the Container that stores data across invocations of this <nl> + Kernel . Together with SolverUUID form an isolation unit for this solver . <nl> + solver_uuid : Universally Unique Identifier for this solver . <nl> + sparse_weights : a list of vectors where each value is the weight associated with <nl> + a feature index . <nl> + dense_weights : a list of vectors where the value is the weight associated with <nl> + a dense feature group . <nl> + duality_gap : duality gap over all examples seen by the optimizer . <nl> + ) doc " ) ; <nl> + <nl> } / / namespace tensorflow <nl> mmm a / tensorflow / contrib / linear_optimizer / python / kernel_tests / sdca_ops_test . py <nl> ppp b / tensorflow / contrib / linear_optimizer / python / kernel_tests / sdca_ops_test . py <nl> def make_variable_dict ( max_age , max_gender ) : <nl> # examples_dict . <nl> age_weights = tf . Variable ( tf . zeros ( [ max_age + 1 ] , dtype = tf . float32 ) ) <nl> gender_weights = tf . Variable ( tf . zeros ( [ max_gender + 1 ] , dtype = tf . float32 ) ) <nl> - primal_loss = tf . Variable ( tf . zeros ( [ ] , dtype = tf . float64 ) ) <nl> return dict ( sparse_features_weights = [ age_weights , gender_weights ] , <nl> - dense_features_weights = [ ] , <nl> - primal_loss = primal_loss ) <nl> - <nl> + dense_features_weights = [ ] ) <nl> <nl> def make_dense_variable_dict ( num_dense_features , num_examples ) : <nl> feature_weights = ( [ <nl> def get_binary_predictions_for_hinge ( predictions ) : <nl> all_ones = tf . ones_like ( predictions ) <nl> return tf . add ( tf . sign ( predictions ) , all_ones ) / 2 <nl> <nl> + <nl> # Setup the single container shared across all tests . This is testing proper <nl> # isolation across optimizers instantiated in each of the tests below . <nl> CONTAINER = uuid . uuid4 ( ) . hex <nl> def testSimpleLogistic ( self ) : <nl> variables = make_variable_dict ( 1 , 1 ) <nl> options = dict ( symmetric_l2_regularization = 1 , <nl> symmetric_l1_regularization = 0 , <nl> - loss_type = ' logistic_loss ' , <nl> - prior = 0 . 0 ) <nl> - tf . initialize_all_variables ( ) . run ( ) <nl> + loss_type = ' logistic_loss ' ) <nl> + <nl> lr = SdcaModel ( CONTAINER , examples , variables , options ) <nl> + tf . initialize_all_variables ( ) . run ( ) <nl> unregularized_loss = lr . unregularized_loss ( examples ) <nl> loss = lr . regularized_loss ( examples ) <nl> predictions = lr . predictions ( examples ) <nl> self . assertAllClose ( 0 . 693147 , unregularized_loss . eval ( ) ) <nl> self . assertAllClose ( 0 . 693147 , loss . eval ( ) ) <nl> - lr . minimize ( ) . run ( ) <nl> - self . assertAllClose ( 0 . 395226 , unregularized_loss . eval ( ) , <nl> - rtol = 3e - 2 , atol = 3e - 2 ) <nl> - self . assertAllClose ( 0 . 657446 , loss . eval ( ) , <nl> - rtol = 3e - 2 , atol = 3e - 2 ) <nl> + for _ in xrange ( 5 ) : <nl> + lr . minimize ( ) . run ( ) <nl> + # The high tolerance in unregularized_loss comparisons is due to the <nl> + # fact that it ' s possible to trade off unregularized_loss vs . <nl> + # regularization and still have a sum that is quite close to the <nl> + # optimal regularized_loss value . SDCA ' s duality gap only ensures that <nl> + # the regularized_loss is within 0 . 01 of optimal . <nl> + # 0 . 525457 is the optimal regularized_loss . <nl> + # 0 . 411608 is the unregularized_loss at that optimum . <nl> + self . assertAllClose ( 0 . 411608 , unregularized_loss . eval ( ) , rtol = 0 . 11 ) <nl> + self . assertAllClose ( 0 . 525457 , loss . eval ( ) , atol = 0 . 01 ) <nl> predicted_labels = get_binary_predictions_for_logistic ( predictions ) <nl> self . assertAllEqual ( [ 0 , 1 ] , predicted_labels . eval ( ) ) <nl> + self . assertAllClose ( 0 . 01 , <nl> + lr . approximate_duality_gap ( ) . eval ( ) , <nl> + rtol = 1e - 2 , <nl> + atol = 1e - 2 ) <nl> <nl> def testSomeUnweightedExamples ( self ) : <nl> # Setup test data with 4 examples , but should produce the same <nl> def testSomeUnweightedExamples ( self ) : <nl> options = dict ( symmetric_l2_regularization = 1 , <nl> symmetric_l1_regularization = 0 , <nl> loss_type = ' logistic_loss ' ) <nl> - tf . initialize_all_variables ( ) . run ( ) <nl> + <nl> lr = SdcaModel ( CONTAINER , examples , variables , options ) <nl> + tf . initialize_all_variables ( ) . run ( ) <nl> unregularized_loss = lr . unregularized_loss ( examples ) <nl> loss = lr . regularized_loss ( examples ) <nl> predictions = lr . predictions ( examples ) <nl> - lr . minimize ( ) . run ( ) <nl> - self . assertAllClose ( 0 . 395226 , unregularized_loss . eval ( ) , <nl> - rtol = 3e - 2 , atol = 3e - 2 ) <nl> - self . assertAllClose ( 0 . 657446 , loss . eval ( ) , <nl> - rtol = 3e - 2 , atol = 3e - 2 ) <nl> + for _ in xrange ( 5 ) : <nl> + lr . minimize ( ) . run ( ) <nl> + self . assertAllClose ( 0 . 411608 , unregularized_loss . eval ( ) , rtol = 0 . 12 ) <nl> + self . assertAllClose ( 0 . 525457 , loss . eval ( ) , atol = 0 . 01 ) <nl> predicted_labels = get_binary_predictions_for_logistic ( predictions ) <nl> self . assertAllClose ( [ 0 , 1 , 1 , 1 ] , predicted_labels . eval ( ) ) <nl> + self . assertAllClose ( 0 . 01 , <nl> + lr . approximate_duality_gap ( ) . eval ( ) , <nl> + rtol = 1e - 2 , <nl> + atol = 1e - 2 ) <nl> <nl> def testFractionalLogisticExample ( self ) : <nl> # Setup test data with 1 positive , and 1 mostly - negative example . <nl> def testFractionalLogisticExample ( self ) : <nl> options = dict ( symmetric_l2_regularization = 1 , <nl> symmetric_l1_regularization = 0 , <nl> loss_type = ' logistic_loss ' ) <nl> + <nl> + lr = SdcaModel ( CONTAINER , examples , variables , options ) <nl> tf . initialize_all_variables ( ) . run ( ) <nl> with self . assertRaisesOpError ( <nl> ' Only labels of 0 . 0 or 1 . 0 are supported right now . ' ) : <nl> - SdcaModel ( CONTAINER , examples , variables , options ) . minimize ( ) . run ( ) <nl> + lr . minimize ( ) . run ( ) <nl> <nl> def testNoWeightedExamples ( self ) : <nl> # Setup test data with 1 positive , and 1 negative example . <nl> def testNoWeightedExamples ( self ) : <nl> options = dict ( symmetric_l2_regularization = 1 , <nl> symmetric_l1_regularization = 0 , <nl> loss_type = ' logistic_loss ' ) <nl> - tf . initialize_all_variables ( ) . run ( ) <nl> + <nl> lr = SdcaModel ( CONTAINER , examples , variables , options ) <nl> + tf . initialize_all_variables ( ) . run ( ) <nl> self . assertAllClose ( [ 0 . 5 , 0 . 5 ] , lr . predictions ( examples ) . eval ( ) ) <nl> with self . assertRaisesOpError ( <nl> ' No weighted examples in 2 training examples ' ) : <nl> def testDuplicateExampleIds ( self ) : <nl> options = dict ( symmetric_l2_regularization = 0 . 5 , <nl> symmetric_l1_regularization = 0 , <nl> loss_type = ' logistic_loss ' ) <nl> - tf . initialize_all_variables ( ) . run ( ) <nl> + <nl> lr = SdcaModel ( CONTAINER , examples , variables , options ) <nl> + tf . initialize_all_variables ( ) . run ( ) <nl> self . assertAllClose ( [ 0 . 5 , 0 . 5 ] , lr . predictions ( examples ) . eval ( ) ) <nl> with self . assertRaisesOpError ( ' Detected 1 duplicates in example_ids ' ) : <nl> lr . minimize ( ) . run ( ) <nl> def testImbalanced ( self ) : <nl> variables = make_variable_dict ( 3 , 1 ) <nl> options = dict ( symmetric_l2_regularization = 1 , <nl> symmetric_l1_regularization = 0 , <nl> - loss_type = ' logistic_loss ' , <nl> - prior = - 1 . 09861 ) <nl> - tf . initialize_all_variables ( ) . run ( ) <nl> + loss_type = ' logistic_loss ' ) <nl> + <nl> lr = SdcaModel ( CONTAINER , examples , variables , options ) <nl> + tf . initialize_all_variables ( ) . run ( ) <nl> unregularized_loss = lr . unregularized_loss ( examples ) <nl> loss = lr . regularized_loss ( examples ) <nl> predictions = lr . predictions ( examples ) <nl> - lr . minimize ( ) . run ( ) <nl> - self . assertAllClose ( 0 . 331710 , unregularized_loss . eval ( ) , <nl> - rtol = 3e - 2 , atol = 3e - 2 ) <nl> - self . assertAllClose ( 0 . 591295 , loss . eval ( ) , rtol = 3e - 2 , atol = 3e - 2 ) <nl> + for _ in xrange ( 5 ) : <nl> + lr . minimize ( ) . run ( ) <nl> + self . assertAllClose ( 0 . 226487 + 0 . 102902 , <nl> + unregularized_loss . eval ( ) , <nl> + rtol = 0 . 08 ) <nl> + self . assertAllClose ( 0 . 328394 + 0 . 131364 , loss . eval ( ) , atol = 0 . 01 ) <nl> predicted_labels = get_binary_predictions_for_logistic ( predictions ) <nl> self . assertAllEqual ( [ 0 , 0 , 0 , 1 ] , predicted_labels . eval ( ) ) <nl> + self . assertAllClose ( 0 . 01 , <nl> + lr . approximate_duality_gap ( ) . eval ( ) , <nl> + rtol = 1e - 2 , <nl> + atol = 1e - 2 ) <nl> <nl> def testImbalancedWithExampleWeights ( self ) : <nl> # Setup test data with 1 positive , and 1 negative example . <nl> def testImbalancedWithExampleWeights ( self ) : <nl> options = dict ( symmetric_l2_regularization = 1 , <nl> symmetric_l1_regularization = 0 , <nl> loss_type = ' logistic_loss ' ) <nl> - tf . initialize_all_variables ( ) . run ( ) <nl> + <nl> lr = SdcaModel ( CONTAINER , examples , variables , options ) <nl> + tf . initialize_all_variables ( ) . run ( ) <nl> unregularized_loss = lr . unregularized_loss ( examples ) <nl> loss = lr . regularized_loss ( examples ) <nl> predictions = lr . predictions ( examples ) <nl> - lr . minimize ( ) . run ( ) <nl> - self . assertAllClose ( 0 . 266189 , unregularized_loss . eval ( ) , <nl> - rtol = 3e - 2 , atol = 3e - 2 ) <nl> - self . assertAllClose ( 0 . 571912 , loss . eval ( ) , rtol = 3e - 2 , atol = 3e - 2 ) <nl> + for _ in xrange ( 5 ) : <nl> + lr . minimize ( ) . run ( ) <nl> + self . assertAllClose ( 0 . 284860 , unregularized_loss . eval ( ) , rtol = 0 . 08 ) <nl> + self . assertAllClose ( 0 . 408044 , loss . eval ( ) , atol = 0 . 012 ) <nl> predicted_labels = get_binary_predictions_for_logistic ( predictions ) <nl> self . assertAllEqual ( [ 0 , 1 ] , predicted_labels . eval ( ) ) <nl> + self . assertAllClose ( 0 . 01 , <nl> + lr . approximate_duality_gap ( ) . eval ( ) , <nl> + rtol = 1e - 2 , <nl> + atol = 1e - 2 ) <nl> <nl> def testInstancesOfOneClassOnly ( self ) : <nl> # Setup test data with 1 positive ( ignored ) , and 1 negative example . <nl> def testInstancesOfOneClassOnly ( self ) : <nl> with self . _single_threaded_test_session ( ) : <nl> examples = make_example_dict ( example_protos , example_weights ) <nl> variables = make_variable_dict ( 1 , 1 ) <nl> - options = dict ( symmetric_l2_regularization = 0 . 25 , <nl> + options = dict ( symmetric_l2_regularization = 1 , <nl> symmetric_l1_regularization = 0 , <nl> loss_type = ' logistic_loss ' ) <nl> - tf . initialize_all_variables ( ) . run ( ) <nl> + <nl> lr = SdcaModel ( CONTAINER , examples , variables , options ) <nl> + tf . initialize_all_variables ( ) . run ( ) <nl> unregularized_loss = lr . unregularized_loss ( examples ) <nl> loss = lr . regularized_loss ( examples ) <nl> - prediction = lr . predictions ( examples ) <nl> - lr . minimize ( ) . run ( ) <nl> - self . assertAllClose ( 0 . 395226 , <nl> - unregularized_loss . eval ( ) , <nl> - rtol = 3e - 2 , <nl> - atol = 3e - 2 ) <nl> - self . assertAllClose ( 0 . 460781 , loss . eval ( ) , rtol = 3e - 2 , atol = 3e - 2 ) <nl> - predicted_labels = tf . cast ( <nl> - tf . greater_equal ( prediction , <nl> - tf . ones_like ( prediction ) * 0 . 5 ) , tf . float32 ) <nl> + predictions = lr . predictions ( examples ) <nl> + for _ in xrange ( 5 ) : <nl> + lr . minimize ( ) . run ( ) <nl> + self . assertAllClose ( 0 . 411608 , unregularized_loss . eval ( ) , rtol = 0 . 12 ) <nl> + self . assertAllClose ( 0 . 525457 , loss . eval ( ) , atol = 0 . 01 ) <nl> + predicted_labels = get_binary_predictions_for_logistic ( predictions ) <nl> self . assertAllEqual ( [ 0 , 0 ] , predicted_labels . eval ( ) ) <nl> + self . assertAllClose ( 0 . 01 , <nl> + lr . approximate_duality_gap ( ) . eval ( ) , <nl> + rtol = 1e - 2 , <nl> + atol = 1e - 2 ) <nl> <nl> def testSimpleLinear ( self ) : <nl> # Setup test data <nl> def testSimpleLinear ( self ) : <nl> variables = make_variable_dict ( 1 , 1 ) <nl> options = dict ( symmetric_l2_regularization = 1 , <nl> symmetric_l1_regularization = 0 , <nl> - loss_type = ' squared_loss ' , <nl> - prior = 0 . 0 ) <nl> - tf . initialize_all_variables ( ) . run ( ) <nl> + loss_type = ' squared_loss ' ) <nl> + <nl> lr = SdcaModel ( CONTAINER , examples , variables , options ) <nl> - prediction = lr . predictions ( examples ) <nl> + tf . initialize_all_variables ( ) . run ( ) <nl> + predictions = lr . predictions ( examples ) <nl> <nl> - lr . minimize ( ) . run ( ) <nl> + for _ in xrange ( 20 ) : <nl> + lr . minimize ( ) . run ( ) <nl> <nl> # Predictions should be 2 / 3 of label due to minimizing regularized loss : <nl> # ( label - 2 * weight ) ^ 2 / 2 + L2 * 2 * weight ^ 2 <nl> self . assertAllClose ( [ - 20 . 0 / 3 . 0 , 28 . 0 / 3 . 0 ] , <nl> - prediction . eval ( ) , <nl> + predictions . eval ( ) , <nl> rtol = 0 . 005 ) <nl> + self . assertAllClose ( 0 . 01 , <nl> + lr . approximate_duality_gap ( ) . eval ( ) , <nl> + rtol = 1e - 2 , <nl> + atol = 1e - 2 ) <nl> <nl> - def testLinearRegularization ( self ) : <nl> + def testLinearL2Regularization ( self ) : <nl> # Setup test data <nl> example_protos = [ <nl> # 2 identical examples <nl> def testLinearRegularization ( self ) : <nl> variables = make_variable_dict ( 1 , 1 ) <nl> options = dict ( symmetric_l2_regularization = 16 , <nl> symmetric_l1_regularization = 0 , <nl> - loss_type = ' squared_loss ' , <nl> - prior = 0 . 0 ) <nl> - tf . initialize_all_variables ( ) . run ( ) <nl> + loss_type = ' squared_loss ' ) <nl> + <nl> lr = SdcaModel ( CONTAINER , examples , variables , options ) <nl> - prediction = lr . predictions ( examples ) <nl> + tf . initialize_all_variables ( ) . run ( ) <nl> + predictions = lr . predictions ( examples ) <nl> <nl> - lr . minimize ( ) . run ( ) <nl> + for _ in xrange ( 5 ) : <nl> + lr . minimize ( ) . run ( ) <nl> <nl> # Predictions should be 1 / 5 of label due to minimizing regularized loss : <nl> # ( label - 2 * weight ) ^ 2 + L2 * 16 * weight ^ 2 <nl> def testLinearRegularization ( self ) : <nl> optimal2 = 14 . 0 / 5 . 0 <nl> self . assertAllClose ( <nl> [ optimal1 , optimal1 , optimal2 , optimal2 ] , <nl> - prediction . eval ( ) , <nl> + predictions . eval ( ) , <nl> rtol = 0 . 01 ) <nl> <nl> + def testLinearL1Regularization ( self ) : <nl> + # Setup test data <nl> + example_protos = [ <nl> + make_example_proto ( <nl> + { ' age ' : [ 0 ] , <nl> + ' gender ' : [ 0 ] } , - 10 . 0 ) , <nl> + make_example_proto ( <nl> + { ' age ' : [ 1 ] , <nl> + ' gender ' : [ 1 ] } , 14 . 0 ) , <nl> + ] <nl> + example_weights = [ 1 . 0 , 1 . 0 ] <nl> + with self . _single_threaded_test_session ( ) : <nl> + examples = make_example_dict ( example_protos , example_weights ) <nl> + variables = make_variable_dict ( 1 , 1 ) <nl> + options = dict ( symmetric_l2_regularization = 1 . 0 , <nl> + symmetric_l1_regularization = 4 . 0 , <nl> + loss_type = ' squared_loss ' ) <nl> + lr = SdcaModel ( CONTAINER , examples , variables , options ) <nl> + tf . initialize_all_variables ( ) . run ( ) <nl> + prediction = lr . predictions ( examples ) <nl> + loss = lr . regularized_loss ( examples ) <nl> + <nl> + for _ in xrange ( 5 ) : <nl> + lr . minimize ( ) . run ( ) <nl> + <nl> + # Predictions should be - 4 . 0 , 48 / 5 due to minimizing regularized loss : <nl> + # ( label - 2 * weight ) ^ 2 / 2 + L2 * 2 * weight ^ 2 + L1 * 4 * weight <nl> + self . assertAllClose ( [ - 4 . 0 , 20 . 0 / 3 . 0 ] , prediction . eval ( ) , rtol = 0 . 08 ) <nl> + <nl> + # Loss should be the sum of the regularized loss value from above per <nl> + # example after plugging in the optimal weights . <nl> + self . assertAllClose ( 308 . 0 / 6 . 0 , loss . eval ( ) , atol = 0 . 01 ) <nl> + <nl> def testLinearFeatureValues ( self ) : <nl> # Setup test data <nl> example_protos = [ <nl> def testLinearFeatureValues ( self ) : <nl> variables = make_variable_dict ( 1 , 1 ) <nl> options = dict ( symmetric_l2_regularization = 1 , <nl> symmetric_l1_regularization = 0 , <nl> - loss_type = ' squared_loss ' , <nl> - prior = 0 . 0 ) <nl> - tf . initialize_all_variables ( ) . run ( ) <nl> + loss_type = ' squared_loss ' ) <nl> + <nl> lr = SdcaModel ( CONTAINER , examples , variables , options ) <nl> - prediction = lr . predictions ( examples ) <nl> + tf . initialize_all_variables ( ) . run ( ) <nl> + predictions = lr . predictions ( examples ) <nl> <nl> - lr . minimize ( ) . run ( ) <nl> + for _ in xrange ( 20 ) : <nl> + lr . minimize ( ) . run ( ) <nl> <nl> # Predictions should be 8 / 9 of label due to minimizing regularized loss : <nl> # ( label - 2 * 2 * weight ) ^ 2 / 2 + L2 * 2 * weight ^ 2 <nl> self . assertAllClose ( [ - 10 . 0 * 8 / 9 , 14 . 0 * 8 / 9 ] , <nl> - prediction . eval ( ) , <nl> + predictions . eval ( ) , <nl> rtol = 0 . 07 ) <nl> <nl> def testLinearDenseFeatures ( self ) : <nl> def testLinearDenseFeatures ( self ) : <nl> variables = make_dense_variable_dict ( 2 , 2 ) <nl> options = dict ( symmetric_l2_regularization = 1 , <nl> symmetric_l1_regularization = 0 , <nl> - loss_type = ' squared_loss ' , <nl> - prior = 0 . 0 ) <nl> - tf . initialize_all_variables ( ) . run ( ) <nl> + loss_type = ' squared_loss ' ) <nl> lr = SdcaModel ( CONTAINER , examples , variables , options ) <nl> - prediction = lr . predictions ( examples ) <nl> + tf . initialize_all_variables ( ) . run ( ) <nl> + predictions = lr . predictions ( examples ) <nl> <nl> - lr . minimize ( ) . run ( ) <nl> + for _ in xrange ( 20 ) : <nl> + lr . minimize ( ) . run ( ) <nl> <nl> # Predictions should be 4 / 5 of label due to minimizing regularized loss : <nl> # ( label - 2 * weight ) ^ 2 / 2 + L2 * weight ^ 2 <nl> self . assertAllClose ( [ - 10 . 0 * 4 / 5 , 14 . 0 * 4 / 5 ] , <nl> - prediction . eval ( ) , <nl> + predictions . eval ( ) , <nl> rtol = 0 . 01 ) <nl> <nl> loss = lr . regularized_loss ( examples ) <nl> - self . assertAllClose ( <nl> - ( 4 . 0 + 7 . 84 + 16 . 0 + 31 . 36 ) / 2 , <nl> - loss . eval ( ) , <nl> - rtol = 0 . 01 ) <nl> + self . assertAllClose ( 148 . 0 / 10 . 0 , loss . eval ( ) , atol = 0 . 01 ) <nl> <nl> def testSimpleHinge ( self ) : <nl> # Setup test data <nl> def testSimpleHinge ( self ) : <nl> variables = make_variable_dict ( 1 , 1 ) <nl> options = dict ( symmetric_l2_regularization = 1 . 0 , <nl> symmetric_l1_regularization = 0 , <nl> - loss_type = ' hinge_loss ' , <nl> - prior = 0 . 0 ) <nl> - tf . initialize_all_variables ( ) . run ( ) <nl> + loss_type = ' hinge_loss ' ) <nl> model = SdcaModel ( CONTAINER , examples , variables , options ) <nl> + tf . initialize_all_variables ( ) . run ( ) <nl> <nl> # Before minimization , the weights default to zero . There is no loss due <nl> # to regularization , only unregularized loss which is 0 . 5 * ( 1 + 1 ) = 1 . 0 . <nl> def testSimpleHinge ( self ) : <nl> # are 4 sparse weights : 2 for age ( say w1 , w2 ) and 2 for gender ( say w3 <nl> # and w4 ) . Solving the system w1 + w3 = 1 . 0 , w2 + w4 = - 1 . 0 and minimizing <nl> # wrt to \ | \ vec { w } \ | _2 , gives w1 = w3 = 1 / 2 and w2 = w4 = - 1 / 2 . This gives 0 . 0 <nl> - # unregularized loss and 0 . 5 L2 loss . <nl> - model . minimize ( ) . run ( ) <nl> + # unregularized loss and 0 . 25 L2 loss . <nl> + for _ in xrange ( 5 ) : <nl> + model . minimize ( ) . run ( ) <nl> + <nl> binary_predictions = get_binary_predictions_for_hinge ( predictions ) <nl> self . assertAllEqual ( [ - 1 . 0 , 1 . 0 ] , predictions . eval ( ) ) <nl> self . assertAllEqual ( [ 0 . 0 , 1 . 0 ] , binary_predictions . eval ( ) ) <nl> self . assertAllClose ( 0 . 0 , unregularized_loss . eval ( ) ) <nl> - self . assertAllClose ( 0 . 5 , regularized_loss . eval ( ) , atol = 0 . 05 ) <nl> + self . assertAllClose ( 0 . 25 , regularized_loss . eval ( ) , atol = 0 . 05 ) <nl> <nl> def testHingeDenseFeaturesPerfectlySeparable ( self ) : <nl> with self . _single_threaded_test_session ( ) : <nl> def testHingeDenseFeaturesPerfectlySeparable ( self ) : <nl> options = dict ( symmetric_l2_regularization = 1 . 0 , <nl> symmetric_l1_regularization = 0 , <nl> loss_type = ' hinge_loss ' ) <nl> - tf . initialize_all_variables ( ) . run ( ) <nl> model = SdcaModel ( CONTAINER , examples , variables , options ) <nl> + tf . initialize_all_variables ( ) . run ( ) <nl> predictions = model . predictions ( examples ) <nl> binary_predictions = get_binary_predictions_for_hinge ( predictions ) <nl> - model . minimize ( ) . run ( ) <nl> + <nl> + for _ in xrange ( 5 ) : <nl> + model . minimize ( ) . run ( ) <nl> + <nl> self . assertAllClose ( [ 1 . 0 , - 1 . 0 ] , predictions . eval ( ) , atol = 0 . 05 ) <nl> self . assertAllClose ( [ 1 . 0 , 0 . 0 ] , binary_predictions . eval ( ) ) <nl> <nl> # ( 1 . 0 , 1 . 0 ) and ( 1 . 0 , - 1 . 0 ) are perfectly separable by x - axis ( that is , <nl> # the SVM ' s functional margin > = 1 ) , so the unregularized loss is ~ 0 . 0 . <nl> # There is only loss due to l2 - regularization . For these datapoints , it <nl> - # turns out that w_1 ~ = 0 . 0 and w_2 ~ = 1 . 0 which means that l2 loss is ~ 0 . 5 . <nl> + # turns out that w_1 ~ = 0 . 0 and w_2 ~ = 1 . 0 which means that l2 loss is ~ 0 . 25 . <nl> unregularized_loss = model . unregularized_loss ( examples ) <nl> regularized_loss = model . regularized_loss ( examples ) <nl> self . assertAllClose ( 0 . 0 , unregularized_loss . eval ( ) , atol = 0 . 02 ) <nl> - self . assertAllClose ( 0 . 5 , regularized_loss . eval ( ) , atol = 0 . 02 ) <nl> + self . assertAllClose ( 0 . 25 , regularized_loss . eval ( ) , atol = 0 . 02 ) <nl> <nl> def testHingeDenseFeaturesSeparableWithinMargins ( self ) : <nl> with self . _single_threaded_test_session ( ) : <nl> def testHingeDenseFeaturesSeparableWithinMargins ( self ) : <nl> options = dict ( symmetric_l2_regularization = 1 . 0 , <nl> symmetric_l1_regularization = 0 , <nl> loss_type = ' hinge_loss ' ) <nl> - tf . initialize_all_variables ( ) . run ( ) <nl> model = SdcaModel ( CONTAINER , examples , variables , options ) <nl> + tf . initialize_all_variables ( ) . run ( ) <nl> predictions = model . predictions ( examples ) <nl> binary_predictions = get_binary_predictions_for_hinge ( predictions ) <nl> - model . minimize ( ) . run ( ) <nl> + <nl> + for _ in xrange ( 5 ) : <nl> + model . minimize ( ) . run ( ) <nl> <nl> # ( 1 . 0 , 0 . 5 ) and ( 1 . 0 , - 0 . 5 ) are separable by x - axis but the datapoints <nl> # are within the margins so there is unregularized loss ( 1 / 2 per example ) . <nl> # For these datapoints , optimal weights are w_1 ~ = 0 . 0 and w_2 ~ = 1 . 0 which <nl> - # gives an L2 loss of ~ 0 . 5 . <nl> + # gives an L2 loss of ~ 0 . 25 . <nl> self . assertAllClose ( [ 0 . 5 , - 0 . 5 ] , predictions . eval ( ) , rtol = 0 . 05 ) <nl> self . assertAllClose ( [ 1 . 0 , 0 . 0 ] , binary_predictions . eval ( ) ) <nl> unregularized_loss = model . unregularized_loss ( examples ) <nl> regularized_loss = model . regularized_loss ( examples ) <nl> self . assertAllClose ( 0 . 5 , unregularized_loss . eval ( ) , atol = 0 . 02 ) <nl> - self . assertAllClose ( 1 . 0 , regularized_loss . eval ( ) , atol = 0 . 02 ) <nl> + self . assertAllClose ( 0 . 75 , regularized_loss . eval ( ) , atol = 0 . 02 ) <nl> <nl> def testHingeDenseFeaturesWeightedExamples ( self ) : <nl> with self . _single_threaded_test_session ( ) : <nl> def testHingeDenseFeaturesWeightedExamples ( self ) : <nl> options = dict ( symmetric_l2_regularization = 1 . 0 , <nl> symmetric_l1_regularization = 0 , <nl> loss_type = ' hinge_loss ' ) <nl> - tf . initialize_all_variables ( ) . run ( ) <nl> model = SdcaModel ( CONTAINER , examples , variables , options ) <nl> + tf . initialize_all_variables ( ) . run ( ) <nl> predictions = model . predictions ( examples ) <nl> binary_predictions = get_binary_predictions_for_hinge ( predictions ) <nl> - model . minimize ( ) . run ( ) <nl> + for _ in xrange ( 5 ) : <nl> + model . minimize ( ) . run ( ) <nl> <nl> # Point ( 1 . 0 , 0 . 5 ) has higher weight than ( 1 . 0 , - 0 . 5 ) so the model will <nl> # try to increase the margin from ( 1 . 0 , 0 . 5 ) . Due to regularization , <nl> # ( 1 . 0 , - 0 . 5 ) will be within the margin . For these points and example <nl> # weights , the optimal weights are w_1 ~ = 0 . 4 and w_2 ~ = 1 . 2 which give an L2 <nl> - # loss of 0 . 25 * 1 . 6 = 0 . 4 . The binary predictions will be correct , but <nl> - # the boundary will be much closer to the 2nd point than the first one . <nl> + # loss of 0 . 5 * 0 . 25 * 0 . 25 * 1 . 6 = 0 . 2 . The binary predictions will be <nl> + # correct , but the boundary will be much closer to the 2nd point than the <nl> + # first one . <nl> self . assertAllClose ( [ 1 . 0 , - 0 . 2 ] , predictions . eval ( ) , atol = 0 . 05 ) <nl> self . assertAllClose ( [ 1 . 0 , 0 . 0 ] , binary_predictions . eval ( ) , atol = 0 . 05 ) <nl> unregularized_loss = model . unregularized_loss ( examples ) <nl> regularized_loss = model . regularized_loss ( examples ) <nl> self . assertAllClose ( 0 . 2 , unregularized_loss . eval ( ) , atol = 0 . 02 ) <nl> - self . assertAllClose ( 0 . 6 , regularized_loss . eval ( ) , atol = 0 . 02 ) <nl> + self . assertAllClose ( 0 . 4 , regularized_loss . eval ( ) , atol = 0 . 02 ) <nl> <nl> if __name__ = = ' __main__ ' : <nl> googletest . main ( ) <nl> mmm a / tensorflow / contrib / linear_optimizer / python / ops / sdca_ops . py <nl> ppp b / tensorflow / contrib / linear_optimizer / python / ops / sdca_ops . py <nl> <nl> import os . path <nl> import uuid <nl> <nl> + from tensorflow . python . framework import dtypes <nl> + from tensorflow . python . framework import ops <nl> from tensorflow . python . framework . load_library import load_op_library <nl> from tensorflow . python . framework . ops import convert_to_tensor <nl> from tensorflow . python . framework . ops import name_scope <nl> from tensorflow . python . ops import array_ops <nl> + from tensorflow . python . ops import control_flow_ops <nl> from tensorflow . python . ops import math_ops <nl> + from tensorflow . python . ops import state_ops <nl> + from tensorflow . python . ops import variables as var_ops <nl> from tensorflow . python . ops . nn import sigmoid_cross_entropy_with_logits <nl> from tensorflow . python . platform import resource_loader <nl> <nl> class SdcaModel ( object ) : <nl> the model , by resetting its ( possibly shared ) container . <nl> <nl> ` ` ` python <nl> - # Execute opt_op once to perform training , which continues until <nl> - convergence . <nl> - The op makes use of duality gap as a certificate for termination . Duality <nl> - gap is set to 0 . 01 as default . <nl> - opt_op . run ( ) <nl> + # Execute opt_op and train for num_steps . <nl> + for _ in xrange ( num_steps ) : <nl> + opt_op . run ( ) <nl> + <nl> + # You can also check for convergence by calling <nl> + # lr . approximate_duality_gap ( ) <nl> ` ` ` <nl> " " " <nl> <nl> def __init__ ( self , container , examples , variables , options ) : <nl> self . _assertList ( [ ' sparse_features ' , ' dense_features ' ] , examples ) <nl> <nl> self . _assertSpecified ( <nl> - [ ' sparse_features_weights ' , ' dense_features_weights ' , <nl> - ' primal_loss ' ] , variables ) <nl> + [ ' sparse_features_weights ' , ' dense_features_weights ' ] , variables ) <nl> self . _assertList ( <nl> [ ' sparse_features_weights ' , ' dense_features_weights ' ] , variables ) <nl> <nl> def __init__ ( self , container , examples , variables , options ) : <nl> self . _examples = examples <nl> self . _variables = variables <nl> self . _options = options <nl> - self . _primal_loss = convert_to_tensor ( self . _variables [ ' primal_loss ' ] , <nl> - as_ref = True ) <nl> self . _solver_uuid = uuid . uuid4 ( ) . hex <nl> + self . _create_slots ( variables ) <nl> + <nl> + # TODO ( rohananil ) : Use optimizer interface to make use of slot creation <nl> + # logic <nl> + def _create_slots ( self , variables ) : <nl> + self . _slots = { } <nl> + # TODO ( rohananil ) : Rename the slot keys to " unshrinked " weights . <nl> + self . _slots [ ' sparse_features_weights ' ] = [ ] <nl> + self . _slots [ ' dense_features_weights ' ] = [ ] <nl> + self . _assign_ops = [ ] <nl> + # Make an internal variable which has the updates before applying L1 <nl> + # regularization . <nl> + for var_type in [ ' sparse_features_weights ' , ' dense_features_weights ' ] : <nl> + for var in variables [ var_type ] : <nl> + if var is not None : <nl> + self . _slots [ var_type ] . append ( var_ops . Variable ( array_ops . zeros_like ( <nl> + var . initialized_value ( ) , dtypes . float32 ) ) ) <nl> + self . _assign_ops . append ( state_ops . assign ( var , self . _slots [ var_type ] [ <nl> + - 1 ] ) ) <nl> <nl> def _assertSpecified ( self , items , check_in ) : <nl> for x in items : <nl> def _l1_loss ( self ) : <nl> dense_weights = self . _convert_n_to_tensor ( self . _variables [ <nl> ' dense_features_weights ' ] ) <nl> l1 = self . _options [ ' symmetric_l1_regularization ' ] <nl> - loss = 0 <nl> + loss = 0 . 0 <nl> for w in sparse_weights : <nl> loss + = l1 * math_ops . reduce_sum ( abs ( w ) ) <nl> for w in dense_weights : <nl> def _l2_loss ( self ) : <nl> dense_weights = self . _convert_n_to_tensor ( self . _variables [ <nl> ' dense_features_weights ' ] ) <nl> l2 = self . _options [ ' symmetric_l2_regularization ' ] <nl> - loss = 0 <nl> + loss = 0 . 0 <nl> for w in sparse_weights : <nl> loss + = l2 * math_ops . reduce_sum ( math_ops . square ( w ) ) <nl> for w in dense_weights : <nl> loss + = l2 * math_ops . reduce_sum ( math_ops . square ( w ) ) <nl> - return loss <nl> + # SDCA L2 regularization cost is 1 / 2 * l2 * sum ( weights ^ 2 ) <nl> + return loss / 2 . 0 <nl> <nl> def _convert_n_to_tensor ( self , input_list , as_ref = False ) : <nl> " " " Converts input list to a set of tensors . " " " <nl> def minimize ( self ) : <nl> sparse_features_indices . append ( convert_to_tensor ( sf . indices ) ) <nl> sparse_features_weights . append ( convert_to_tensor ( sf . values ) ) <nl> <nl> - return _sdca_ops . sdca_solver ( <nl> + step_op = _sdca_ops . sdca_solver ( <nl> sparse_features_indices , <nl> sparse_features_weights , <nl> self . _convert_n_to_tensor ( self . _examples [ ' dense_features ' ] ) , <nl> convert_to_tensor ( self . _examples [ ' example_weights ' ] ) , <nl> convert_to_tensor ( self . _examples [ ' example_labels ' ] ) , <nl> convert_to_tensor ( self . _examples [ ' example_ids ' ] ) , <nl> - self . _convert_n_to_tensor ( self . _variables [ ' sparse_features_weights ' ] , <nl> + self . _convert_n_to_tensor ( self . _slots [ ' sparse_features_weights ' ] , <nl> as_ref = True ) , <nl> - self . _convert_n_to_tensor ( self . _variables [ ' dense_features_weights ' ] , <nl> + self . _convert_n_to_tensor ( self . _slots [ ' dense_features_weights ' ] , <nl> as_ref = True ) , <nl> - self . _primal_loss , <nl> l1 = self . _options [ ' symmetric_l1_regularization ' ] , <nl> l2 = self . _options [ ' symmetric_l2_regularization ' ] , <nl> + num_inner_iterations = 2 , <nl> loss_type = self . _options [ ' loss_type ' ] , <nl> container = self . _container , <nl> solver_uuid = self . _solver_uuid ) <nl> + with ops . control_dependencies ( [ step_op ] ) : <nl> + assign_ops = control_flow_ops . group ( * self . _assign_ops ) <nl> + with ops . control_dependencies ( [ assign_ops ] ) : <nl> + return _sdca_ops . sdca_shrink_l1 ( <nl> + self . _convert_n_to_tensor ( <nl> + self . _variables [ ' sparse_features_weights ' ] , <nl> + as_ref = True ) , <nl> + self . _convert_n_to_tensor ( <nl> + self . _variables [ ' dense_features_weights ' ] , <nl> + as_ref = True ) , <nl> + l1 = self . _options [ ' symmetric_l1_regularization ' ] , <nl> + l2 = self . _options [ ' symmetric_l2_regularization ' ] ) <nl> + <nl> + def approximate_duality_gap ( self ) : <nl> + " " " Add operations to compute the approximate duality gap . <nl> + <nl> + Returns : <nl> + An Operation that computes the approximate duality gap over all <nl> + examples . <nl> + " " " <nl> + return _sdca_ops . compute_duality_gap ( <nl> + self . _convert_n_to_tensor ( self . _slots [ ' sparse_features_weights ' ] , <nl> + as_ref = True ) , <nl> + self . _convert_n_to_tensor ( self . _slots [ ' dense_features_weights ' ] , <nl> + as_ref = True ) , <nl> + l1 = self . _options [ ' symmetric_l1_regularization ' ] , <nl> + l2 = self . _options [ ' symmetric_l2_regularization ' ] , <nl> + container = self . _container , <nl> + solver_uuid = self . _solver_uuid ) <nl> <nl> def unregularized_loss ( self , examples ) : <nl> " " " Add operations to compute the loss ( without the regularization loss ) . <nl> def unregularized_loss ( self , examples ) : <nl> err = math_ops . sub ( labels , predictions ) <nl> <nl> weighted_squared_err = math_ops . mul ( math_ops . square ( err ) , weights ) <nl> + # SDCA squared loss function is sum ( err ^ 2 ) / ( 2 * sum ( weights ) ) <nl> return ( math_ops . reduce_sum ( weighted_squared_err ) / <nl> - math_ops . reduce_sum ( weights ) ) <nl> + ( 2 . 0 * math_ops . reduce_sum ( weights ) ) ) <nl> <nl> def regularized_loss ( self , examples ) : <nl> " " " Add operations to compute the loss with regularization loss included . <nl> def regularized_loss ( self , examples ) : <nl> <nl> Returns : <nl> An Operation that computes mean ( regularized ) loss for given set of <nl> - examples . <nl> + examples . <nl> Raises : <nl> ValueError : if examples are not well defined . <nl> " " " <nl> mmm a / tensorflow / core / BUILD <nl> ppp b / tensorflow / core / BUILD <nl> <nl> # <nl> # filegroup " : android_proto_srcs " - Protos <nl> # filegroup " : android_srcs " - Core sources <nl> - # filegroup " : android_core_ops " - Essential kernels <nl> - # filegroup " : android_extended_ops " - Optional kernels <nl> - # filegroup " : android_extended_ops_group1 " - Optional kernels , first batch <nl> - # filegroup " : android_extended_ops_group2 " - Optional kernels , second batch <nl> # cc_library " : android_tensorflow_lib " - Native library <nl> # portable_proto_library " : android_proto_lib " ( Google - internal ) <nl> <nl> tf_proto_library_cc ( <nl> srcs = [ " protobuf / master . proto " ] , <nl> cc_api_version = 2 , <nl> cc_libs = [ " : protos_all_cc " ] , <nl> - py_api_version = 2 , <nl> visibility = [ <nl> " / / tensorflow : internal " , <nl> ] , <nl> tf_proto_library_cc ( <nl> cc_grpc_version = 1 , <nl> cc_libs = [ " : master_proto_cc " ] , <nl> cc_stubby_versions = [ " 2 " ] , <nl> - py_api_version = 2 , <nl> visibility = [ <nl> " / / tensorflow : internal " , <nl> ] , <nl> filegroup ( <nl> visibility = [ " / / visibility : public " ] , <nl> ) <nl> <nl> - # Core kernels we want on Android . Only a subset of kernels to keep <nl> - # base library small . <nl> - filegroup ( <nl> - name = " android_core_ops " , <nl> - srcs = [ <nl> - " / / tensorflow / core / kernels : android_core_ops " , <nl> - ] , <nl> - visibility = [ " / / visibility : public " ] , <nl> - ) <nl> - <nl> - # Other kernels we may want on Android . <nl> - # <nl> - # The kernels can be consumed as a whole or in two groups for <nl> - # supporting separate compilation . Note that the split into groups <nl> - # is entirely for improving compilation time , and not for <nl> - # organizational reasons ; you should not depend on any <nl> - # of those groups independently . <nl> - filegroup ( <nl> - name = " android_extended_ops " , <nl> - srcs = [ <nl> - " : android_extended_ops_group1 " , <nl> - " : android_extended_ops_group2 " , <nl> - ] , <nl> - visibility = [ " / / visibility : public " ] , <nl> - ) <nl> - <nl> - filegroup ( <nl> - name = " android_extended_ops_headers " , <nl> - srcs = [ <nl> - " / / tensorflow / core / kernels : android_extended_ops_headers " , <nl> - ] , <nl> - ) <nl> - <nl> - filegroup ( <nl> - name = " android_extended_ops_group1 " , <nl> - srcs = [ <nl> - " : android_extended_ops_headers " , <nl> - " / / tensorflow / core / kernels : android_extended_ops_group1 " , <nl> - ] , <nl> - visibility = [ " / / visibility : public " ] , <nl> - ) <nl> - <nl> - filegroup ( <nl> - name = " android_extended_ops_group2 " , <nl> - srcs = [ <nl> - " : android_extended_ops_headers " , <nl> - " / / tensorflow / core / kernels : android_extended_ops_group2 " , <nl> - ] , <nl> - visibility = [ " / / visibility : public " ] , <nl> - ) <nl> - <nl> # Config setting for determining if we are building for Android . <nl> config_setting ( <nl> name = " android " , <nl> cc_library ( <nl> cc_library ( <nl> name = " android_tensorflow_lib " , <nl> srcs = [ <nl> - " / / tensorflow / core : android_core_ops " , <nl> - " / / tensorflow / core : android_extended_ops " , <nl> + " / / tensorflow / core / kernels : android_core_ops " , <nl> + " / / tensorflow / core / kernels : android_extended_ops " , <nl> ] , <nl> copts = select ( { <nl> " : android " : ANDROID_TF_COPTS , <nl> cc_library ( <nl> ] , <nl> ) <nl> <nl> + # mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> # Libraries for GPU facilities that are useful for writing kernels . <nl> cc_library ( <nl> name = " gpu_lib " , <nl> tf_cuda_library ( <nl> ] , <nl> ) , <nl> copts = tf_copts ( ) , <nl> - cuda_deps = [ <nl> - " : core_gpu_internal " , <nl> - " : stream_executor " , <nl> - ] , <nl> deps = [ <nl> " : framework " , <nl> " : framework_internal " , <nl> tf_cuda_library ( <nl> alwayslink = 1 , <nl> ) <nl> <nl> - # This target should not link in any GPU runtime ( CUDA ) dependencies , <nl> - # only libraries for interfacing with GPUs that can be safely linked <nl> - # into CPU binaries . <nl> - cc_library ( <nl> - name = " core_gpu_internal " , <nl> - srcs = [ <nl> - " common_runtime / gpu / gpu_allocator_retry . cc " , <nl> - " common_runtime / gpu / gpu_bfc_allocator . cc " , <nl> - " common_runtime / gpu / gpu_debug_allocator . cc " , <nl> - " common_runtime / gpu / gpu_init . cc " , <nl> - " common_runtime / gpu / pool_allocator . cc " , <nl> - " common_runtime / gpu / process_state . cc " , <nl> - ] , <nl> - hdrs = [ <nl> - " common_runtime / gpu / gpu_allocator_retry . h " , <nl> - " common_runtime / gpu / gpu_bfc_allocator . h " , <nl> - " common_runtime / gpu / gpu_debug_allocator . h " , <nl> - " common_runtime / gpu / gpu_init . h " , <nl> - " common_runtime / gpu / pool_allocator . h " , <nl> - " common_runtime / gpu / process_state . h " , <nl> - " common_runtime / gpu / visitable_allocator . h " , <nl> - ] , <nl> - copts = tf_copts ( ) , <nl> - deps = [ <nl> - " : framework " , <nl> - " : framework_internal " , <nl> - " : lib " , <nl> - " : lib_internal " , <nl> - " : protos_all_cc " , <nl> - " : stream_executor " , <nl> - ] , <nl> - ) <nl> - <nl> cc_library ( <nl> name = " cuda " , <nl> deps = [ <nl> tf_cuda_library ( <nl> tf_cuda_library ( <nl> name = " gpu_runtime " , <nl> srcs = [ <nl> + " common_runtime / gpu / gpu_allocator_retry . cc " , <nl> + " common_runtime / gpu / gpu_bfc_allocator . cc " , <nl> + " common_runtime / gpu / gpu_debug_allocator . cc " , <nl> " common_runtime / gpu / gpu_device . cc " , <nl> " common_runtime / gpu / gpu_device_factory . cc " , <nl> + " common_runtime / gpu / gpu_init . cc " , <nl> " common_runtime / gpu / gpu_stream_util . cc " , <nl> " common_runtime / gpu / gpu_util . cc " , <nl> " common_runtime / gpu / gpu_util_platform_specific . cc " , <nl> + " common_runtime / gpu / pool_allocator . cc " , <nl> + " common_runtime / gpu / process_state . cc " , <nl> ] , <nl> hdrs = [ <nl> + " common_runtime / gpu / gpu_allocator_retry . h " , <nl> + " common_runtime / gpu / gpu_bfc_allocator . h " , <nl> + " common_runtime / gpu / gpu_debug_allocator . h " , <nl> " common_runtime / gpu / gpu_device . h " , <nl> + " common_runtime / gpu / gpu_init . h " , <nl> " common_runtime / gpu / gpu_stream_util . h " , <nl> " common_runtime / gpu / gpu_util . h " , <nl> + " common_runtime / gpu / pool_allocator . h " , <nl> + " common_runtime / gpu / process_state . h " , <nl> + " common_runtime / gpu / visitable_allocator . h " , <nl> ] , <nl> copts = tf_copts ( ) , <nl> cuda_deps = [ <nl> tf_cuda_library ( <nl> deps = [ <nl> " : core_cpu " , <nl> " : core_cpu_internal " , <nl> - " : core_gpu_internal " , <nl> " : framework " , <nl> " : framework_internal " , <nl> " : gpu_lib " , <nl> tf_cc_tests ( <nl> " : all_kernels " , <nl> " : core_cpu " , <nl> " : core_cpu_internal " , <nl> - " : core_gpu_internal " , <nl> " : direct_session " , <nl> " : framework " , <nl> " : framework_internal " , <nl> mmm a / tensorflow / core / common_runtime / gpu / gpu_device_factory . cc <nl> ppp b / tensorflow / core / common_runtime / gpu / gpu_device_factory . cc <nl> limitations under the License . <nl> <nl> # include " tensorflow / core / common_runtime / gpu / gpu_device . h " <nl> # include " tensorflow / core / common_runtime / gpu / process_state . h " <nl> + # include " tensorflow / core / common_runtime / threadpool_device . h " <nl> <nl> namespace tensorflow { <nl> <nl> class GPUDeviceFactory : public BaseGPUDeviceFactory { <nl> <nl> REGISTER_LOCAL_DEVICE_FACTORY ( " GPU " , GPUDeviceFactory ) ; <nl> <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> + / / A CPUDevice that optimizes for interaction with GPUs in the <nl> + / / process . <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + class GPUCompatibleCPUDevice : public ThreadPoolDevice { <nl> + public : <nl> + GPUCompatibleCPUDevice ( const SessionOptions & options , const string & name , <nl> + Bytes memory_limit , BusAdjacency bus_adjacency , <nl> + Allocator * allocator ) <nl> + : ThreadPoolDevice ( options , name , memory_limit , bus_adjacency , <nl> + allocator ) { } <nl> + ~ GPUCompatibleCPUDevice ( ) override { } <nl> + <nl> + Allocator * GetAllocator ( AllocatorAttributes attr ) override { <nl> + ProcessState * ps = ProcessState : : singleton ( ) ; <nl> + if ( attr . gpu_compatible ( ) ) { <nl> + return ps - > GetCUDAHostAllocator ( 0 ) ; <nl> + } else { <nl> + / / Call the parent ' s implementation . <nl> + return ThreadPoolDevice : : GetAllocator ( attr ) ; <nl> + } <nl> + } <nl> + } ; <nl> + <nl> + / / The associated factory . <nl> + class GPUCompatibleCPUDeviceFactory : public DeviceFactory { <nl> + public : <nl> + void CreateDevices ( const SessionOptions & options , const string & name_prefix , <nl> + std : : vector < Device * > * devices ) override { <nl> + int n = 1 ; <nl> + auto iter = options . config . device_count ( ) . find ( " CPU " ) ; <nl> + if ( iter ! = options . config . device_count ( ) . end ( ) ) { <nl> + n = iter - > second ; <nl> + } <nl> + for ( int i = 0 ; i < n ; i + + ) { <nl> + string name = strings : : StrCat ( name_prefix , " / cpu : " , i ) ; <nl> + devices - > push_back ( new GPUCompatibleCPUDevice ( <nl> + options , name , Bytes ( 256 < < 20 ) , BUS_ANY , cpu_allocator ( ) ) ) ; <nl> + } <nl> + } <nl> + } ; <nl> + REGISTER_LOCAL_DEVICE_FACTORY ( " CPU " , GPUCompatibleCPUDeviceFactory , 50 ) ; <nl> + <nl> } / / namespace tensorflow <nl> <nl> # endif / / GOOGLE_CUDA <nl> mmm a / tensorflow / core / common_runtime / threadpool_device . cc <nl> ppp b / tensorflow / core / common_runtime / threadpool_device . cc <nl> limitations under the License . <nl> # include " tensorflow / core / platform / types . h " <nl> # include " tensorflow / core / public / session_options . h " <nl> <nl> - # if GOOGLE_CUDA <nl> - # include " tensorflow / core / common_runtime / gpu / process_state . h " <nl> - # endif / / GOOGLE_CUDA <nl> - <nl> namespace tensorflow { <nl> <nl> ThreadPoolDevice : : ThreadPoolDevice ( const SessionOptions & options , <nl> void ThreadPoolDevice : : Compute ( OpKernel * op_kernel , OpKernelContext * context ) { <nl> } <nl> <nl> Allocator * ThreadPoolDevice : : GetAllocator ( AllocatorAttributes attr ) { <nl> - # if GOOGLE_CUDA <nl> - ProcessState * ps = ProcessState : : singleton ( ) ; <nl> - if ( attr . gpu_compatible ( ) ) { <nl> - return ps - > GetCUDAHostAllocator ( 0 ) ; <nl> - } <nl> - # endif / / GOOGLE_CUDA <nl> return allocator_ ; <nl> } <nl> <nl> mmm a / tensorflow / core / distributed_runtime / BUILD <nl> ppp b / tensorflow / core / distributed_runtime / BUILD <nl> cc_library ( <nl> ] , <nl> ) <nl> <nl> + cc_library ( <nl> + name = " server_lib " , <nl> + srcs = [ " server_lib . cc " ] , <nl> + hdrs = [ " server_lib . h " ] , <nl> + deps = [ <nl> + " / / tensorflow / core : framework " , <nl> + " / / tensorflow / core : framework_internal " , <nl> + " / / tensorflow / core : lib " , <nl> + " / / tensorflow / core : protos_all_cc " , <nl> + ] , <nl> + ) <nl> + <nl> # TODO ( mrry ) : Move executor_test . cc to . . / common_runtime when once it no longer depends <nl> # on grpc_testlib . <nl> tf_cc_tests ( <nl> mmm a / tensorflow / core / distributed_runtime / rpc / BUILD <nl> ppp b / tensorflow / core / distributed_runtime / rpc / BUILD <nl> cc_library ( <nl> srcs = [ <nl> " grpc_server_lib . cc " , <nl> ] , <nl> - hdrs = [ " grpc_server_lib . h " ] , <nl> + linkstatic = 1 , # Seems to be needed since alwayslink is broken in bazel <nl> deps = [ <nl> " @ grpc / / : grpc + + _unsecure " , <nl> " : async_service_interface " , <nl> cc_library ( <nl> " / / tensorflow / core / distributed_runtime : master_env " , <nl> " / / tensorflow / core / distributed_runtime : master_session " , <nl> " / / tensorflow / core / distributed_runtime : process_util " , <nl> + " / / tensorflow / core / distributed_runtime : server_lib " , <nl> " / / tensorflow / core / distributed_runtime : worker_env " , <nl> ] , <nl> + alwayslink = 1 , <nl> ) <nl> <nl> cc_binary ( <nl> cc_binary ( <nl> " / / tensorflow / core : framework_internal " , <nl> " / / tensorflow / core : lib " , <nl> " / / tensorflow / core : protos_all_cc " , <nl> + " / / tensorflow / core / distributed_runtime : server_lib " , <nl> ] , <nl> ) <nl> <nl> cc_binary ( <nl> " / / tensorflow / core : core_cpu " , <nl> " / / tensorflow / core : framework_internal " , <nl> " / / tensorflow / core : lib " , <nl> + " / / tensorflow / core / distributed_runtime : server_lib " , <nl> ] , <nl> ) <nl> <nl> tf_cc_tests ( <nl> " / / tensorflow / core : test_main " , <nl> " / / tensorflow / core : testlib " , <nl> " / / tensorflow / core / distributed_runtime : process_util " , <nl> + " / / tensorflow / core / distributed_runtime : server_lib " , <nl> ] , <nl> ) <nl> mmm a / tensorflow / core / distributed_runtime / rpc / grpc_server_lib . cc <nl> ppp b / tensorflow / core / distributed_runtime / rpc / grpc_server_lib . cc <nl> See the License for the specific language governing permissions and <nl> limitations under the License . <nl> = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = * / <nl> <nl> - # include " tensorflow / core / distributed_runtime / rpc / grpc_server_lib . h " <nl> - <nl> # include < memory > <nl> <nl> # include " grpc + + / grpc + + . h " <nl> limitations under the License . <nl> # include " tensorflow / core / distributed_runtime / rpc / grpc_worker_cache . h " <nl> # include " tensorflow / core / distributed_runtime / rpc / grpc_worker_service . h " <nl> # include " tensorflow / core / distributed_runtime / rpc / rpc_rendezvous_mgr . h " <nl> + # include " tensorflow / core / distributed_runtime / server_lib . h " <nl> # include " tensorflow / core / distributed_runtime / worker_env . h " <nl> # include " tensorflow / core / framework / op . h " <nl> # include " tensorflow / core / lib / strings / strcat . h " <nl> limitations under the License . <nl> # include " tensorflow / core / public / session_options . h " <nl> <nl> namespace tensorflow { <nl> - <nl> namespace { <nl> - class TensorFlowServer : public ServerInterface { <nl> + <nl> + class GrpcServer : public ServerInterface { <nl> public : <nl> - TensorFlowServer ( const ServerDef & server_def , Env * env ) <nl> + GrpcServer ( const ServerDef & server_def , Env * env ) <nl> : server_def_ ( server_def ) , env_ ( env ) , state_ ( NEW ) { } <nl> <nl> - ~ TensorFlowServer ( ) { <nl> + ~ GrpcServer ( ) { <nl> Stop ( ) ; <nl> Join ( ) ; <nl> <nl> class TensorFlowServer : public ServerInterface { <nl> / / to destroy them . <nl> delete master_env_ . worker_cache ; / / Shared with worker_env . worker_cache . <nl> <nl> - delete worker_env_ . device_mgr ; <nl> + / / We must delete graph_mgr before device_mgr , due to shared <nl> + / / ownership of OpKernels in the executors . ( The graph_mgr will <nl> + / / free all stateless OpKernels , and pass over borrowed stateful <nl> + / / OpKernels , which are also held in their respective devices ' <nl> + / / OpSegments . ) <nl> delete worker_env_ . graph_mgr ; <nl> + delete worker_env_ . device_mgr ; <nl> + <nl> delete worker_env_ . rendezvous_mgr ; <nl> <nl> / / Do not delete ( as these are not owned by the server ) : <nl> class TensorFlowServer : public ServerInterface { <nl> return errors : : Internal ( " Could not parse worker name . " ) ; <nl> } <nl> <nl> + / / Look up the port that has been requested for this task in ` server_def_ ` . <nl> + requested_port_ = - 1 ; <nl> + for ( const auto & job : server_def_ . cluster ( ) . job ( ) ) { <nl> + if ( job . name ( ) = = server_def_ . job_name ( ) ) { <nl> + auto iter = job . tasks ( ) . find ( server_def_ . task_index ( ) ) ; <nl> + if ( iter = = job . tasks ( ) . end ( ) ) { <nl> + return errors : : InvalidArgument ( " Task " , server_def_ . task_index ( ) , <nl> + " was not defined in job \ " " , <nl> + server_def_ . job_name ( ) , " \ " " ) ; <nl> + } else if ( ! str_util : : NumericParse32 ( <nl> + str_util : : Split ( iter - > second , ' : ' ) [ 1 ] , <nl> + & requested_port_ ) ) { <nl> + return errors : : Internal ( <nl> + " Could not parse port for local server from \ " " , iter - > second , <nl> + " \ " " ) ; <nl> + } else { <nl> + break ; <nl> + } <nl> + } <nl> + } <nl> + if ( requested_port_ = = - 1 ) { <nl> + return errors : : Internal ( " Job \ " " , server_def_ . job_name ( ) , <nl> + " \ " was not defined in cluster " ) ; <nl> + } <nl> + <nl> + / / N . B . The order of initialization here is intricate , because we <nl> + / / wish to allow ` requested_port_ = = 0 ` ( for choosing any port , <nl> + / / mostly for testing ) . Therefore , the construction of the channel <nl> + / / and worker caches depends on ` bound_port_ ` , which is not set <nl> + / / until we call ` builder . BuildAndStart ( ) ` . We must create the <nl> + / / service objects before calling ` builder . BuildAndStart ( ) ` , but <nl> + / / ` master_env_ ` and ` worker_env_ ` are only partially <nl> + / / configured . However , this is not dangerous , because we do not <nl> + / / start serving requests until ` this - > Start ( ) ` is called , which <nl> + / / happens after this method returns . <nl> + / / <nl> + / / TODO ( mrry ) : Provide a general mechanism for dynamically setting <nl> + / / the identities of tasks in the worker pool after the service is <nl> + / / running . <nl> + : : grpc : : ServerBuilder builder ; <nl> + builder . AddListeningPort ( strings : : StrCat ( " 0 . 0 . 0 . 0 : " , requested_port_ ) , <nl> + : : grpc : : InsecureServerCredentials ( ) , & bound_port_ ) ; <nl> + master_service_ = NewGrpcMasterService ( & master_env_ , & builder ) ; <nl> + worker_service_ = NewGrpcWorkerService ( & worker_env_ , & builder ) ; <nl> + server_ = builder . BuildAndStart ( ) ; <nl> + <nl> + if ( ! server_ ) { <nl> + return errors : : Internal ( " Could not start gRPC server " ) ; <nl> + } <nl> + <nl> GrpcChannelSpec channel_spec ; <nl> for ( const auto & job : server_def_ . cluster ( ) . job ( ) ) { <nl> int max_task_id = - 1 ; <nl> class TensorFlowServer : public ServerInterface { <nl> } <nl> std : : vector < string > host_ports ( max_task_id + 1 ) ; <nl> for ( const auto & task : job . tasks ( ) ) { <nl> - host_ports [ task . first ] = task . second ; <nl> + if ( job . name ( ) = = server_def_ . job_name ( ) & & <nl> + task . first = = server_def_ . task_index ( ) ) { <nl> + host_ports [ task . first ] = strings : : StrCat ( " localhost : " , bound_port_ ) ; <nl> + } else { <nl> + host_ports [ task . first ] = task . second ; <nl> + } <nl> } <nl> channel_spec . AddHostPortsJob ( job . name ( ) , host_ports , host_ports . size ( ) ) ; <nl> } <nl> class TensorFlowServer : public ServerInterface { <nl> mutex_lock l ( mu_ ) ; <nl> switch ( state_ ) { <nl> case NEW : { <nl> - : : grpc : : ServerBuilder builder ; <nl> - builder . AddListeningPort ( strings : : StrCat ( " 0 . 0 . 0 . 0 : " , requested_port_ ) , <nl> - : : grpc : : InsecureServerCredentials ( ) ) ; <nl> - master_service_ = NewGrpcMasterService ( & master_env_ , & builder ) ; <nl> - worker_service_ = NewGrpcWorkerService ( & worker_env_ , & builder ) ; <nl> - server_ = builder . BuildAndStart ( ) ; <nl> master_thread_ . reset ( <nl> env_ - > StartThread ( ThreadOptions ( ) , " TF_master_service " , <nl> [ this ] { master_service_ - > HandleRPCsLoop ( ) ; } ) ) ; <nl> class TensorFlowServer : public ServerInterface { <nl> } <nl> } <nl> <nl> - const string & target ( ) const override { return target_ ; } <nl> + const string target ( ) const override { <nl> + return strings : : StrCat ( " grpc : / / localhost : " , bound_port_ ) ; <nl> + } <nl> <nl> private : <nl> / / The overall server configuration . <nl> class TensorFlowServer : public ServerInterface { <nl> Env * env_ ; <nl> <nl> / / The port requested for this server . <nl> - / / TODO ( mrry ) : Support requested_port_ = = 0 to bind to any available port . <nl> int requested_port_ ; <nl> + / / The port to which this server is bound . <nl> + int bound_port_ = 0 ; <nl> <nl> / / The ` SessionOptions . target ` to be used when connecting to this <nl> / / server ( as a master ) . <nl> class TensorFlowServer : public ServerInterface { <nl> <nl> std : : unique_ptr < : : grpc : : Server > server_ GUARDED_BY ( mu_ ) ; <nl> } ; <nl> - } / / namespace <nl> <nl> - Status NewServer ( const ServerDef & server_def , <nl> - std : : unique_ptr < ServerInterface > * out_server ) { <nl> - std : : unique_ptr < TensorFlowServer > ret ( <nl> - new TensorFlowServer ( server_def , Env : : Default ( ) ) ) ; <nl> - TF_RETURN_IF_ERROR ( ret - > Init ( ) ) ; <nl> - * out_server = std : : move ( ret ) ; <nl> - return Status : : OK ( ) ; <nl> - } <nl> + class GrpcServerFactory : public ServerFactory { <nl> + public : <nl> + bool AcceptsOptions ( const ServerDef & server_def ) override { <nl> + return server_def . protocol ( ) = = " grpc " ; <nl> + } <nl> <nl> + Status NewServer ( const ServerDef & server_def , <nl> + std : : unique_ptr < ServerInterface > * out_server ) override { <nl> + std : : unique_ptr < GrpcServer > ret ( new GrpcServer ( server_def , Env : : Default ( ) ) ) ; <nl> + TF_RETURN_IF_ERROR ( ret - > Init ( ) ) ; <nl> + * out_server = std : : move ( ret ) ; <nl> + return Status : : OK ( ) ; <nl> + } <nl> + } ; <nl> + <nl> + / / Registers a ` ServerFactory ` for ` GrpcServer ` instances . <nl> + class GrpcServerRegistrar { <nl> + public : <nl> + GrpcServerRegistrar ( ) { <nl> + ServerFactory : : Register ( " GRPC_SERVER " , new GrpcServerFactory ( ) ) ; <nl> + } <nl> + } ; <nl> + static GrpcServerRegistrar registrar ; <nl> + <nl> + } / / namespace <nl> } / / namespace tensorflow <nl> deleted file mode 100644 <nl> index a06989d88c55d . . 0000000000000 <nl> mmm a / tensorflow / core / distributed_runtime / rpc / grpc_server_lib . h <nl> ppp / dev / null <nl> <nl> - / * Copyright 2016 Google Inc . All Rights Reserved . <nl> - <nl> - Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> - you may not use this file except in compliance with the License . <nl> - You may obtain a copy of the License at <nl> - <nl> - http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> - <nl> - Unless required by applicable law or agreed to in writing , software <nl> - distributed under the License is distributed on an " AS IS " BASIS , <nl> - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> - See the License for the specific language governing permissions and <nl> - limitations under the License . <nl> - = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = * / <nl> - <nl> - # ifndef THIRD_PARTY_TENSORFLOW_CORE_DISTRIBUTED_RUNTIME_RPC_GRPC_SERVER_LIB_H_ <nl> - # define THIRD_PARTY_TENSORFLOW_CORE_DISTRIBUTED_RUNTIME_RPC_GRPC_SERVER_LIB_H_ <nl> - <nl> - # include < memory > <nl> - <nl> - # include " tensorflow / core / lib / core / status . h " <nl> - # include " tensorflow / core / platform / macros . h " <nl> - # include " tensorflow / core / platform / types . h " <nl> - # include " tensorflow / core / protobuf / tensorflow_server . pb . h " <nl> - <nl> - namespace tensorflow { <nl> - <nl> - / / Represents a single TensorFlow server , which exports Master and Worker <nl> - / / services . <nl> - class ServerInterface { <nl> - public : <nl> - ServerInterface ( ) { } <nl> - virtual ~ ServerInterface ( ) { } <nl> - <nl> - / / Starts the server running asynchronously . Returns OK on success , otherwise <nl> - / / returns an error . <nl> - virtual Status Start ( ) = 0 ; <nl> - <nl> - / / Stops the server asynchronously . Returns OK on success , otherwise returns <nl> - / / an error . <nl> - / / <nl> - / / After calling ` Stop ( ) ` , the caller may call ` Join ( ) ` to block until the <nl> - / / server has stopped . <nl> - virtual Status Stop ( ) = 0 ; <nl> - <nl> - / / Blocks until the server has stopped . Returns OK on success , otherwise <nl> - / / returns an error . <nl> - virtual Status Join ( ) = 0 ; <nl> - <nl> - / / Returns a target string that can be used to connect to this server using <nl> - / / ` tensorflow : : NewSession ( ) ` . <nl> - virtual const string & target ( ) const = 0 ; <nl> - <nl> - private : <nl> - TF_DISALLOW_COPY_AND_ASSIGN ( ServerInterface ) ; <nl> - } ; <nl> - <nl> - / / Creates a server based on the given ` server_def ` , and stores it in <nl> - / / * out_server . Returns OK on success , otherwise returns an error . <nl> - Status NewServer ( const ServerDef & server_def , <nl> - std : : unique_ptr < ServerInterface > * out_server ) ; <nl> - <nl> - } / / namespace tensorflow <nl> - <nl> - # endif / / THIRD_PARTY_TENSORFLOW_CORE_DISTRIBUTED_RUNTIME_RPC_GRPC_SERVER_LIB_H_ <nl> mmm a / tensorflow / core / distributed_runtime / rpc / grpc_server_lib_test . cc <nl> ppp b / tensorflow / core / distributed_runtime / rpc / grpc_server_lib_test . cc <nl> See the License for the specific language governing permissions and <nl> limitations under the License . <nl> = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = * / <nl> <nl> - # include " tensorflow / core / distributed_runtime / rpc / grpc_server_lib . h " <nl> + # include " tensorflow / core / distributed_runtime / server_lib . h " <nl> <nl> # include " tensorflow / core / distributed_runtime / rpc / grpc_session . h " <nl> # include " tensorflow / core / lib / core / status_test_util . h " <nl> namespace tensorflow { <nl> / / when no calls are made against the server . <nl> TEST ( Server , StopAfterNoop ) { <nl> ServerDef def ; <nl> + def . set_protocol ( " grpc " ) ; <nl> def . set_job_name ( " localhost " ) ; <nl> def . set_task_index ( 0 ) ; <nl> JobDef * job_def = def . mutable_cluster ( ) - > add_job ( ) ; <nl> TEST ( Server , StopAfterNoop ) { <nl> / / when a simple call is made against the server . <nl> TEST ( Server , StopAfterCall ) { <nl> ServerDef def ; <nl> + def . set_protocol ( " grpc " ) ; <nl> def . set_job_name ( " localhost " ) ; <nl> def . set_task_index ( 0 ) ; <nl> JobDef * job_def = def . mutable_cluster ( ) - > add_job ( ) ; <nl> mmm a / tensorflow / core / distributed_runtime / rpc / grpc_tensorflow_server . cc <nl> ppp b / tensorflow / core / distributed_runtime / rpc / grpc_tensorflow_server . cc <nl> limitations under the License . <nl> # include " grpc + + / security / credentials . h " <nl> # include " grpc + + / server_builder . h " <nl> <nl> - # include " tensorflow / core / distributed_runtime / rpc / grpc_server_lib . h " <nl> + # include " tensorflow / core / distributed_runtime / server_lib . h " <nl> <nl> # include " tensorflow / core / lib / core / errors . h " <nl> # include " tensorflow / core / lib / core / status . h " <nl> limitations under the License . <nl> # include " tensorflow / core / util / command_line_flags . h " <nl> <nl> / / This binary starts a TensorFlow server ( master and worker ) . <nl> + / / <nl> + / / TODO ( mrry ) : Replace with a py_binary that uses ` tf . GrpcServer ( ) ` . <nl> namespace tensorflow { <nl> namespace { <nl> <nl> Status ParseFlagsForTask ( int argc , char * argv [ ] , ServerDef * options ) { <nl> + options - > set_protocol ( " grpc " ) ; <nl> string cluster_spec ; <nl> int task_index = 0 ; <nl> const bool parse_result = ParseFlags ( <nl> mmm a / tensorflow / core / distributed_runtime / rpc / grpc_testlib_server . cc <nl> ppp b / tensorflow / core / distributed_runtime / rpc / grpc_testlib_server . cc <nl> limitations under the License . <nl> # include " grpc + + / security / credentials . h " <nl> # include " grpc + + / server_builder . h " <nl> <nl> - # include " tensorflow / core / distributed_runtime / rpc / grpc_server_lib . h " <nl> + # include " tensorflow / core / distributed_runtime / server_lib . h " <nl> <nl> # include " tensorflow / core / lib / core / errors . h " <nl> # include " tensorflow / core / lib / core / status . h " <nl> namespace tensorflow { <nl> namespace { <nl> <nl> Status ParseFlagsForTask ( int argc , char * argv [ ] , ServerDef * options ) { <nl> + options - > set_protocol ( " grpc " ) ; <nl> string job_spec ; <nl> int num_cpus = 1 ; <nl> int num_gpus = 0 ; <nl> new file mode 100644 <nl> index 0000000000000 . . 45d4f70a3f542 <nl> mmm / dev / null <nl> ppp b / tensorflow / core / distributed_runtime / server_lib . cc <nl> <nl> + / * Copyright 2016 Google Inc . All Rights Reserved . <nl> + <nl> + Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + you may not use this file except in compliance with the License . <nl> + You may obtain a copy of the License at <nl> + <nl> + http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + <nl> + Unless required by applicable law or agreed to in writing , software <nl> + distributed under the License is distributed on an " AS IS " BASIS , <nl> + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + See the License for the specific language governing permissions and <nl> + limitations under the License . <nl> + = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = * / <nl> + <nl> + # include " tensorflow / core / distributed_runtime / server_lib . h " <nl> + <nl> + # include < unordered_map > <nl> + <nl> + # include " tensorflow / core / lib / core / errors . h " <nl> + # include " tensorflow / core / platform / mutex . h " <nl> + <nl> + namespace tensorflow { <nl> + <nl> + namespace { <nl> + mutex * get_server_factory_lock ( ) { <nl> + static mutex server_factory_lock ; <nl> + return & server_factory_lock ; <nl> + } <nl> + <nl> + typedef std : : unordered_map < string , ServerFactory * > ServerFactories ; <nl> + ServerFactories * server_factories ( ) { <nl> + static ServerFactories * factories = new ServerFactories ; <nl> + return factories ; <nl> + } <nl> + } / / namespace <nl> + <nl> + / * static * / <nl> + void ServerFactory : : Register ( const string & server_type , <nl> + ServerFactory * factory ) { <nl> + mutex_lock l ( * get_server_factory_lock ( ) ) ; <nl> + if ( ! server_factories ( ) - > insert ( { server_type , factory } ) . second ) { <nl> + LOG ( ERROR ) < < " Two server factories are being registered under " <nl> + < < server_type ; <nl> + } <nl> + } <nl> + <nl> + / * static * / <nl> + Status ServerFactory : : GetFactory ( const ServerDef & server_def , <nl> + ServerFactory * * out_factory ) { <nl> + mutex_lock l ( * get_server_factory_lock ( ) ) ; <nl> + / / TODO ( mrry ) : Improve the error reporting here . <nl> + for ( const auto & server_factory : * server_factories ( ) ) { <nl> + if ( server_factory . second - > AcceptsOptions ( server_def ) ) { <nl> + * out_factory = server_factory . second ; <nl> + return Status : : OK ( ) ; <nl> + } <nl> + } <nl> + return errors : : NotFound ( <nl> + " No server factory registered for the given ServerDef : " , <nl> + server_def . DebugString ( ) ) ; <nl> + } <nl> + <nl> + / / Creates a server based on the given ` server_def ` , and stores it in <nl> + / / ` * out_server ` . Returns OK on success , otherwise returns an error . <nl> + Status NewServer ( const ServerDef & server_def , <nl> + std : : unique_ptr < ServerInterface > * out_server ) { <nl> + ServerFactory * factory ; <nl> + TF_RETURN_IF_ERROR ( ServerFactory : : GetFactory ( server_def , & factory ) ) ; <nl> + return factory - > NewServer ( server_def , out_server ) ; <nl> + } <nl> + <nl> + } / / namespace tensorflow <nl> new file mode 100644 <nl> index 0000000000000 . . dea682795a398 <nl> mmm / dev / null <nl> ppp b / tensorflow / core / distributed_runtime / server_lib . h <nl> <nl> + / * Copyright 2016 Google Inc . All Rights Reserved . <nl> + <nl> + Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + you may not use this file except in compliance with the License . <nl> + You may obtain a copy of the License at <nl> + <nl> + http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + <nl> + Unless required by applicable law or agreed to in writing , software <nl> + distributed under the License is distributed on an " AS IS " BASIS , <nl> + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + See the License for the specific language governing permissions and <nl> + limitations under the License . <nl> + = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = * / <nl> + <nl> + # ifndef THIRD_PARTY_TENSORFLOW_CORE_DISTRIBUTED_RUNTIME_SERVER_LIB_H_ <nl> + # define THIRD_PARTY_TENSORFLOW_CORE_DISTRIBUTED_RUNTIME_SERVER_LIB_H_ <nl> + <nl> + # include < memory > <nl> + <nl> + # include " tensorflow / core / lib / core / status . h " <nl> + # include " tensorflow / core / platform / macros . h " <nl> + # include " tensorflow / core / protobuf / tensorflow_server . pb . h " <nl> + <nl> + namespace tensorflow { <nl> + <nl> + / / This library supports a registration / factory - based mechanism for <nl> + / / creating TensorFlow server objects . Each server implementation must <nl> + / / have an accompanying implementation of ServerFactory , and create a <nl> + / / static " registrar " object that calls ` ServerFactory : : Register ( ) ` <nl> + / / with an instance of the factory class . See " rpc / grpc_server_lib . cc " <nl> + / / for an example . <nl> + <nl> + / / Represents a single TensorFlow server that exports Master and Worker <nl> + / / services . <nl> + class ServerInterface { <nl> + public : <nl> + ServerInterface ( ) { } <nl> + virtual ~ ServerInterface ( ) { } <nl> + <nl> + / / Starts the server running asynchronously . Returns OK on success , otherwise <nl> + / / returns an error . <nl> + virtual Status Start ( ) = 0 ; <nl> + <nl> + / / Stops the server asynchronously . Returns OK on success , otherwise returns <nl> + / / an error . <nl> + / / <nl> + / / After calling ` Stop ( ) ` , the caller may call ` Join ( ) ` to block until the <nl> + / / server has stopped . <nl> + virtual Status Stop ( ) = 0 ; <nl> + <nl> + / / Blocks until the server has stopped . Returns OK on success , otherwise <nl> + / / returns an error . <nl> + virtual Status Join ( ) = 0 ; <nl> + <nl> + / / Returns a target string that can be used to connect to this server using <nl> + / / ` tensorflow : : NewSession ( ) ` . <nl> + virtual const string target ( ) const = 0 ; <nl> + <nl> + private : <nl> + TF_DISALLOW_COPY_AND_ASSIGN ( ServerInterface ) ; <nl> + } ; <nl> + <nl> + class ServerFactory { <nl> + public : <nl> + / / Creates a new server based on the given ` server_def ` , and stores <nl> + / / it in ` * out_server ` . Returns OK on success , otherwise returns an <nl> + / / error . <nl> + virtual Status NewServer ( const ServerDef & server_def , <nl> + std : : unique_ptr < ServerInterface > * out_server ) = 0 ; <nl> + <nl> + / / Returns true if and only if this factory can create a server <nl> + / / based on the given ` server_def ` . <nl> + virtual bool AcceptsOptions ( const ServerDef & server_def ) = 0 ; <nl> + <nl> + virtual ~ ServerFactory ( ) { } <nl> + <nl> + / / For each ` ServerFactory ` subclass , an instance of that class must <nl> + / / be registered by calling this method . <nl> + / / <nl> + / / The ` server_type ` must be unique to the server factory . <nl> + static void Register ( const string & server_type , ServerFactory * factory ) ; <nl> + <nl> + / / Looks up a factory that can create a server based on the given <nl> + / / ` server_def ` , and stores it in ` * out_factory ` . Returns OK on <nl> + / / success , otherwise returns an error . <nl> + static Status GetFactory ( const ServerDef & server_def , <nl> + ServerFactory * * out_factory ) ; <nl> + } ; <nl> + <nl> + / / Creates a server based on the given ` server_def ` , and stores it in <nl> + / / ` * out_server ` . Returns OK on success , otherwise returns an error . <nl> + Status NewServer ( const ServerDef & server_def , <nl> + std : : unique_ptr < ServerInterface > * out_server ) ; <nl> + <nl> + } / / namespace tensorflow <nl> + <nl> + # endif / / THIRD_PARTY_TENSORFLOW_CORE_DISTRIBUTED_RUNTIME_SERVER_LIB_H_ <nl> mmm a / tensorflow / core / framework / op_kernel . h <nl> ppp b / tensorflow / core / framework / op_kernel . h <nl> inline void OpOutputList : : set_ref ( int i , mutex * mu , Tensor * tensor_for_ref ) { <nl> } <nl> <nl> # define OP_REQUIRES ( CTX , EXP , STATUS ) \ <nl> - if ( ! ( EXP ) ) { \ <nl> + if ( ! TF_PREDICT_TRUE ( EXP ) ) { \ <nl> ( CTX ) - > CtxFailure ( ( STATUS ) ) ; \ <nl> return ; \ <nl> } <nl> inline void OpOutputList : : set_ref ( int i , mutex * mu , Tensor * tensor_for_ref ) { <nl> # define OP_REQUIRES_OK ( CTX , STATUS ) \ <nl> do { \ <nl> : : tensorflow : : Status _s ( STATUS ) ; \ <nl> - if ( ! _s . ok ( ) ) { \ <nl> + if ( ! TF_PREDICT_TRUE ( _s . ok ( ) ) ) { \ <nl> ( CTX ) - > CtxFailureWithWarning ( _s ) ; \ <nl> return ; \ <nl> } \ <nl> } while ( 0 ) <nl> <nl> # define OP_REQUIRES_ASYNC ( CTX , EXP , STATUS , CALLBACK ) \ <nl> - if ( ! ( EXP ) ) { \ <nl> + if ( ! TF_PREDICT_TRUE ( EXP ) ) { \ <nl> ( CTX ) - > CtxFailure ( ( STATUS ) ) ; \ <nl> ( CALLBACK ) ( ) ; \ <nl> return ; \ <nl> inline void OpOutputList : : set_ref ( int i , mutex * mu , Tensor * tensor_for_ref ) { <nl> # define OP_REQUIRES_OK_ASYNC ( CTX , STATUS , CALLBACK ) \ <nl> do { \ <nl> : : tensorflow : : Status _s ( STATUS ) ; \ <nl> - if ( ! _s . ok ( ) ) { \ <nl> + if ( ! TF_PREDICT_TRUE ( _s . ok ( ) ) ) { \ <nl> ( CTX ) - > CtxFailureWithWarning ( _s ) ; \ <nl> ( CALLBACK ) ( ) ; \ <nl> return ; \ <nl> mmm a / tensorflow / core / kernels / BUILD <nl> ppp b / tensorflow / core / kernels / BUILD <nl> cc_library ( <nl> ] , <nl> ) <nl> <nl> - cc_library ( <nl> - name = " bounds_check " , <nl> - hdrs = [ " bounds_check . h " ] , <nl> - visibility = [ " / / visibility : private " ] , <nl> - deps = [ <nl> - " / / tensorflow / core : framework " , <nl> - " / / third_party / eigen3 " , <nl> - ] , <nl> - ) <nl> - <nl> tf_kernel_library ( <nl> name = " concat_lib " , <nl> srcs = [ " concat_lib_cpu . cc " ] , <nl> tf_proto_library ( <nl> cc_api_version = 2 , <nl> go_api_version = 2 , <nl> java_api_version = 2 , <nl> - py_api_version = 2 , <nl> ) <nl> <nl> cc_library ( <nl> cc_library ( <nl> ] , <nl> ) <nl> <nl> + # Private support libraries mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> + <nl> + cc_library ( <nl> + name = " bounds_check " , <nl> + hdrs = [ " bounds_check . h " ] , <nl> + visibility = [ " / / visibility : private " ] , <nl> + deps = [ <nl> + " / / tensorflow / core : framework " , <nl> + " / / third_party / eigen3 " , <nl> + ] , <nl> + ) <nl> + <nl> # OpKernel libraries mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> <nl> tf_kernel_libraries ( <nl> tf_kernel_libraries ( <nl> " sparse_matmul_op " , <nl> ] , <nl> deps = [ <nl> + " : bounds_check " , <nl> " : fill_functor " , <nl> " : transpose_functor " , <nl> " / / tensorflow / core : core_cpu " , <nl> tf_kernel_libraries ( <nl> " xent_op " , <nl> ] , <nl> deps = [ <nl> + " : bounds_check " , <nl> " : conv_2d " , <nl> " : conv_ops " , <nl> " : depthwise_conv_op " , <nl> filegroup ( <nl> ] , <nl> ) <nl> <nl> + # Core kernels we want on Android . Only a subset of kernels to keep <nl> + # base library small . <nl> filegroup ( <nl> name = " android_core_ops " , <nl> srcs = [ <nl> filegroup ( <nl> ] , <nl> ) <nl> <nl> + # Other kernels we may want on Android . <nl> + # <nl> + # The kernels can be consumed as a whole or in two groups for <nl> + # supporting separate compilation . Note that the split into groups <nl> + # is entirely for improving compilation time , and not for <nl> + # organizational reasons ; you should not depend on any <nl> + # of those groups independently . <nl> + filegroup ( <nl> + name = " android_extended_ops " , <nl> + srcs = [ <nl> + " : android_extended_ops_group1 " , <nl> + " : android_extended_ops_group2 " , <nl> + ] , <nl> + visibility = [ " / / visibility : public " ] , <nl> + ) <nl> + <nl> filegroup ( <nl> name = " android_extended_ops_headers " , <nl> srcs = [ <nl> filegroup ( <nl> " cwise_op_sub . cc " , <nl> " cwise_op_tanh . cc " , <nl> " dynamic_partition_op . cc " , <nl> + " : android_extended_ops_headers " , <nl> ] , <nl> ) <nl> <nl> filegroup ( <nl> " transpose_op . cc " , <nl> " where_op . cc " , <nl> " xent_op . cc " , <nl> + " : android_extended_ops_headers " , <nl> ] , <nl> ) <nl> <nl> mmm a / tensorflow / core / kernels / bounds_check . h <nl> ppp b / tensorflow / core / kernels / bounds_check . h <nl> EIGEN_ALWAYS_INLINE bool FastBoundsCheck ( Index index , Index limit ) { <nl> static_cast < UIndex > ( limit ) ) ; <nl> } <nl> <nl> + / / Upcasting specializations when the index and bounds do not match ; <nl> + / / always move to the larger type . <nl> + <nl> + EIGEN_ALWAYS_INLINE bool FastBoundsCheck ( int64 index , int32 limit ) { <nl> + return TF_PREDICT_TRUE ( static_cast < uint64 > ( index ) < <nl> + static_cast < uint64 > ( limit ) ) ; <nl> + } <nl> + <nl> + EIGEN_ALWAYS_INLINE bool FastBoundsCheck ( int32 index , int64 limit ) { <nl> + return TF_PREDICT_TRUE ( static_cast < uint64 > ( index ) < <nl> + static_cast < uint64 > ( limit ) ) ; <nl> + } <nl> + <nl> namespace internal { <nl> / / Ensure that the compiler cannot elide a copy into a local , for <nl> / / bounds checking on source tensors that might be updated asynchronously . <nl> mmm a / tensorflow / core / kernels / decode_csv_op . cc <nl> ppp b / tensorflow / core / kernels / decode_csv_op . cc <nl> class DecodeCSVOp : public OpKernel { <nl> } <nl> <nl> OP_REQUIRES ( <nl> - ctx , input [ current_idx ] = = ' " ' & & <nl> - ( static_cast < size_t > ( current_idx ) = = input . size ( ) - 1 | | <nl> - input [ current_idx + 1 ] = = delim_ ) , <nl> + ctx , ( static_cast < size_t > ( current_idx ) < input . size ( ) & & <nl> + input [ current_idx ] = = ' " ' & & <nl> + ( static_cast < size_t > ( current_idx ) = = input . size ( ) - 1 | | <nl> + input [ current_idx + 1 ] = = delim_ ) ) , <nl> errors : : InvalidArgument ( " Quoted field has to end with quote " <nl> " followed by delim or end " ) ) ; <nl> <nl> mmm a / tensorflow / core / kernels / in_topk_op . cc <nl> ppp b / tensorflow / core / kernels / in_topk_op . cc <nl> limitations under the License . <nl> # include " tensorflow / core / framework / op_kernel . h " <nl> # include " tensorflow / core / framework / tensor . h " <nl> # include " tensorflow / core / framework / tensor_shape . h " <nl> + # include " tensorflow / core / kernels / bounds_check . h " <nl> <nl> namespace tensorflow { <nl> <nl> class InTopK : public OpKernel { <nl> const auto size = targets . size ( ) ; <nl> const auto num_classes = predictions . dimension ( 1 ) ; <nl> for ( int b = 0 ; b < size ; b + + ) { <nl> - T target_prediction = predictions ( b , targets ( b ) ) ; <nl> + auto target = internal : : SubtleMustCopy ( targets ( b ) ) ; <nl> + OP_REQUIRES ( context , FastBoundsCheck ( target , num_classes ) , <nl> + errors : : InvalidArgument ( " targets [ " , b , " ] is out of range " ) ) ; <nl> + T target_prediction = predictions ( b , target ) ; <nl> bool cannot_say = ! std : : isfinite ( target_prediction ) ; <nl> int more_probable_classes = 0 ; <nl> if ( ! cannot_say ) { <nl> mmm a / tensorflow / core / kernels / segment_reduction_ops . cc <nl> ppp b / tensorflow / core / kernels / segment_reduction_ops . cc <nl> limitations under the License . <nl> # include " tensorflow / core / framework / tensor . h " <nl> # include " tensorflow / core / framework / tensor_types . h " <nl> # include " tensorflow / core / framework / types . h " <nl> + # include " tensorflow / core / kernels / bounds_check . h " <nl> # include " tensorflow / core / lib / core / status . h " <nl> # include " tensorflow / core / platform / logging . h " <nl> # include " tensorflow / core / util / util . h " <nl> class SegmentReductionOp : public OpKernel { <nl> / / Note that the current implementation assumes that segment_vec values are <nl> / / sorted . <nl> const Index output_rows = <nl> - num_indices > 0 ? segment_vec ( num_indices - 1 ) + 1 : 0 ; <nl> + num_indices > 0 <nl> + ? internal : : SubtleMustCopy ( segment_vec ( num_indices - 1 ) ) + 1 <nl> + : 0 ; <nl> <nl> TensorShape output_shape = input . shape ( ) ; <nl> output_shape . set_dim ( 0 , output_rows ) ; <nl> class SegmentReductionOp : public OpKernel { <nl> typedef Eigen : : TensorMap < Eigen : : Tensor < T , 1 , Eigen : : RowMajor > , <nl> Eigen : : Unaligned > <nl> OutT ; <nl> - T * out_slice_ptr = & output_flat ( segment_vec ( start ) , 0 ) ; <nl> + <nl> + Index out_index = internal : : SubtleMustCopy ( segment_vec ( start ) ) ; <nl> + OP_REQUIRES ( <nl> + context , FastBoundsCheck ( out_index , output_rows ) , <nl> + errors : : InvalidArgument ( <nl> + " Segment id " , out_index , " out of range [ 0 , " , output_rows , <nl> + " ) , probably because ' segment_ids ' input is not sorted . " ) ) ; <nl> + T * out_slice_ptr = & output_flat ( out_index , 0 ) ; <nl> OutT out_slice ( out_slice_ptr , out_slice_shape ) ; <nl> / / We don ' t use out_slice . device ( context - > eigen_device < Device > ) <nl> / / because these pieces of work are likely to be very small and <nl> class UnsortedSegmentSumOp : public OpKernel { <nl> context , IsLegacyScalar ( num_segments . shape ( ) ) , <nl> errors : : InvalidArgument ( " num_segments should be a scalar , not shape " , <nl> num_segments . shape ( ) . DebugString ( ) ) ) ; <nl> - <nl> OP_REQUIRES ( <nl> context , <nl> TensorShapeUtils : : StartsWith ( data . shape ( ) , segment_ids . shape ( ) ) , <nl> class UnsortedSegmentSumOp : public OpKernel { <nl> <nl> const auto segment_flat = segment_ids . flat < Index > ( ) ; <nl> const int32 N = segment_flat . dimension ( 0 ) ; <nl> - const int32 output_rows = num_segments . scalar < int32 > ( ) ( ) ; <nl> - <nl> - for ( int i = 0 ; i < N ; i + + ) { <nl> - int j = segment_flat ( i ) ; <nl> - OP_REQUIRES ( context , 0 < = j & & j < output_rows , <nl> - errors : : InvalidArgument ( <nl> - " segment_ids " , SliceDebugString ( segment_ids . shape ( ) , i ) , <nl> - " = " , j , " is out of range [ 0 , " , output_rows , " ) " ) ) ; <nl> - } <nl> + const Index output_rows = <nl> + internal : : SubtleMustCopy ( num_segments . scalar < int32 > ( ) ( ) ) ; <nl> + OP_REQUIRES ( context , output_rows > = 0 , <nl> + errors : : InvalidArgument ( " Input num_segments = = " , output_rows , <nl> + " must not be negative . " ) ) ; <nl> <nl> TensorShape output_shape ; <nl> output_shape . AddDim ( output_rows ) ; <nl> class UnsortedSegmentSumOp : public OpKernel { <nl> if ( data . NumElements ( ) > 0 ) { <nl> auto data_flat = data . shaped < T , 2 > ( { N , data . NumElements ( ) / N } ) ; <nl> for ( int i = 0 ; i < N ; + + i ) { <nl> - output_flat . template chip < 0 > ( segment_flat ( i ) ) + = <nl> - data_flat . template chip < 0 > ( i ) ; <nl> + Index j = internal : : SubtleMustCopy ( segment_flat ( i ) ) ; <nl> + OP_REQUIRES ( context , FastBoundsCheck ( j , output_rows ) , <nl> + errors : : InvalidArgument ( <nl> + " segment_ids " , SliceDebugString ( segment_ids . shape ( ) , i ) , <nl> + " = " , j , " is out of range [ 0 , " , output_rows , " ) " ) ) ; <nl> + output_flat . template chip < 0 > ( j ) + = data_flat . template chip < 0 > ( i ) ; <nl> } <nl> } <nl> } <nl> mmm a / tensorflow / core / kernels / stack_ops . cc <nl> ppp b / tensorflow / core / kernels / stack_ops . cc <nl> class StackPushOp : public AsyncOpKernel { <nl> / / Push the tensor onto the stack . Swap the tensor to CPU if instructed . <nl> const Tensor & tensor = ctx - > input ( 1 ) ; <nl> AllocatorAttributes alloc_attrs = ctx - > input_alloc_attr ( 1 ) ; <nl> - DeviceContext * device_ctxt = ctx - > op_device_context ( ) ; <nl> - auto device = static_cast < tensorflow : : Device * > ( ctx - > device ( ) ) ; <nl> - Allocator * allocator = device - > GetAllocator ( alloc_attrs ) ; <nl> - AllocatorStats stats ; <nl> - allocator - > GetStats ( & stats ) ; <nl> + / / For now , we use a simple heuristic for swapping : A GPU tensor is moved <nl> + / / to CPU if the tensor has more than kCopyThreshold bytes and the GPU <nl> + / / allocator says more than kOccupancy of the memory is in use . <nl> static constexpr int kCopyThreshold = 2048 ; <nl> static constexpr double kOccupancy = 0 . 7 ; <nl> if ( swap_memory_ & & ! alloc_attrs . on_host ( ) & & <nl> std : : is_same < Device , GPUDevice > : : value & & <nl> - stats . bytes_in_use > ( stats . bytes_limit * kOccupancy ) & & <nl> tensor . TotalBytes ( ) > kCopyThreshold ) { <nl> - / / Asynchronously copy the tensor from GPU to CPU memory . <nl> - / / TODO ( yuanbyu ) : Swap the oldest tensor first . <nl> - AllocatorAttributes host_alloc_attrs ; <nl> - host_alloc_attrs . set_gpu_compatible ( true ) ; <nl> - host_alloc_attrs . set_on_host ( true ) ; <nl> - Allocator * cpu_allocator = device - > GetAllocator ( host_alloc_attrs ) ; <nl> - Tensor * cpu_tensor = <nl> - new Tensor ( cpu_allocator , tensor . dtype ( ) , tensor . shape ( ) ) ; <nl> - device_ctxt - > CopyDeviceTensorToCPU ( <nl> - & tensor , " StackPush " , device , cpu_tensor , <nl> - [ cpu_tensor , stack , ctx , done ] ( const Status & s ) { <nl> - ctx - > SetStatus ( s ) ; <nl> - if ( s . ok ( ) ) { <nl> - AllocatorAttributes alloc_attrs = ctx - > input_alloc_attr ( 1 ) ; <nl> - ctx - > SetStatus ( stack - > Push ( <nl> - { PersistentTensor ( * cpu_tensor ) , alloc_attrs , true } ) ) ; <nl> - } <nl> - if ( ctx - > status ( ) . ok ( ) ) { <nl> - ctx - > set_output ( 0 , * cpu_tensor ) ; <nl> - } <nl> - done ( ) ; <nl> - delete cpu_tensor ; <nl> - } ) ; <nl> - } else { <nl> - / / Execute synchronously if not swapped . <nl> - OP_REQUIRES_OK ( <nl> - ctx , stack - > Push ( { PersistentTensor ( tensor ) , alloc_attrs , false } ) ) ; <nl> - ctx - > set_output ( 0 , tensor ) ; <nl> - done ( ) ; <nl> + DeviceContext * device_ctxt = ctx - > op_device_context ( ) ; <nl> + auto device = static_cast < tensorflow : : Device * > ( ctx - > device ( ) ) ; <nl> + Allocator * allocator = device - > GetAllocator ( alloc_attrs ) ; <nl> + AllocatorStats stats ; <nl> + allocator - > GetStats ( & stats ) ; <nl> + if ( stats . bytes_in_use > ( stats . bytes_limit * kOccupancy ) ) { <nl> + / / Asynchronously copy the tensor from GPU to CPU memory . <nl> + / / TODO ( yuanbyu ) : Swap the oldest tensor first . <nl> + AllocatorAttributes host_alloc_attrs ; <nl> + host_alloc_attrs . set_gpu_compatible ( true ) ; <nl> + host_alloc_attrs . set_on_host ( true ) ; <nl> + Allocator * cpu_allocator = device - > GetAllocator ( host_alloc_attrs ) ; <nl> + Tensor * cpu_tensor = <nl> + new Tensor ( cpu_allocator , tensor . dtype ( ) , tensor . shape ( ) ) ; <nl> + device_ctxt - > CopyDeviceTensorToCPU ( <nl> + & tensor , " StackPush " , device , cpu_tensor , <nl> + [ cpu_tensor , stack , ctx , done ] ( const Status & s ) { <nl> + ctx - > SetStatus ( s ) ; <nl> + if ( s . ok ( ) ) { <nl> + AllocatorAttributes alloc_attrs = ctx - > input_alloc_attr ( 1 ) ; <nl> + ctx - > SetStatus ( stack - > Push ( <nl> + { PersistentTensor ( * cpu_tensor ) , alloc_attrs , true } ) ) ; <nl> + } <nl> + if ( ctx - > status ( ) . ok ( ) ) { <nl> + ctx - > set_output ( 0 , * cpu_tensor ) ; <nl> + } <nl> + done ( ) ; <nl> + delete cpu_tensor ; <nl> + } ) ; <nl> + return ; <nl> + } <nl> } <nl> + <nl> + / / Execute synchronously if not swapped . <nl> + OP_REQUIRES_OK ( ctx , <nl> + stack - > Push ( { PersistentTensor ( tensor ) , alloc_attrs , false } ) ) ; <nl> + ctx - > set_output ( 0 , tensor ) ; <nl> + done ( ) ; <nl> } <nl> <nl> bool IsExpensive ( ) override { return false ; } <nl> mmm a / tensorflow / core / kernels / transpose_op . cc <nl> ppp b / tensorflow / core / kernels / transpose_op . cc <nl> Status TransposeGpuOp : : DoTranspose ( OpKernelContext * ctx , const Tensor & in , <nl> . TypeConstraint < T > ( " T " ) \ <nl> . HostMemory ( " perm " ) , \ <nl> TransposeGpuOp ) ; <nl> - TF_CALL_NUMBER_TYPES ( REGISTER ) ; <nl> + TF_CALL_POD_TYPES ( REGISTER ) ; <nl> # undef REGISTER <nl> # endif <nl> <nl> mmm a / tensorflow / core / lib / random / philox_random . h <nl> ppp b / tensorflow / core / lib / random / philox_random . h <nl> limitations under the License . <nl> # include " tensorflow / core / platform / types . h " <nl> <nl> / / Function qualifiers that need to work on both CPU and GPU . <nl> - # ifdef __CUDA_ARCH__ <nl> + # if defined ( __CUDACC__ ) <nl> / / For nvcc . <nl> # define PHILOX_DEVICE_FUNC __host__ __device__ <nl> # define PHILOX_INLINE __inline__ <nl> mmm a / tensorflow / core / platform / macros . h <nl> ppp b / tensorflow / core / platform / macros . h <nl> limitations under the License . <nl> # define TF_PREDICT_FALSE ( x ) ( __builtin_expect ( x , 0 ) ) <nl> # define TF_PREDICT_TRUE ( x ) ( __builtin_expect ( ! ! ( x ) , 1 ) ) <nl> # else <nl> - # define TF_PREDICT_FALSE ( x ) x <nl> - # define TF_PREDICT_TRUE ( x ) x <nl> + # define TF_PREDICT_FALSE ( x ) ( x ) <nl> + # define TF_PREDICT_TRUE ( x ) ( x ) <nl> # endif <nl> <nl> / / A macro to disallow the copy constructor and operator = functions <nl> mmm a / tensorflow / core / protobuf / tensorflow_server . proto <nl> ppp b / tensorflow / core / protobuf / tensorflow_server . proto <nl> message ServerDef { <nl> <nl> / / The default configuration for sessions that run on this server . <nl> ConfigProto default_session_config = 4 ; <nl> + <nl> + / / The protocol to be used by this server . <nl> + / / <nl> + / / Acceptable values include : " grpc " . <nl> + string protocol = 5 ; <nl> } <nl> mmm a / tensorflow / examples / udacity / README . md <nl> ppp b / tensorflow / examples / udacity / README . md <nl> Course information can be found at https : / / www . udacity . com / course / deep - learning - <nl> Running the Docker container from the Google Cloud repository <nl> mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> <nl> - docker run - p 8888 : 8888 - it - - rm b . gcr . io / tensorflow - udacity / assignments <nl> + docker run - p 8888 : 8888 - it - - rm b . gcr . io / tensorflow - udacity / assignments : 0 . 3 . 0 <nl> <nl> Accessing the Notebooks <nl> mmmmmmmmmmmmmmmmmmmmm - - <nl> This will allow you to save work and have access to generated files on the host <nl> Pushing a Google Cloud release <nl> mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> <nl> - V = 0 . 2 . 0 <nl> + V = 0 . 3 . 0 <nl> docker tag $ USER / assignments b . gcr . io / tensorflow - udacity / assignments : $ V <nl> - docker tag $ USER / assignments b . gcr . io / tensorflow - udacity / assignments : latest <nl> + docker tag - f $ USER / assignments b . gcr . io / tensorflow - udacity / assignments : latest <nl> gcloud docker push b . gcr . io / tensorflow - udacity / assignments <nl> <nl> History <nl> History <nl> <nl> * 0 . 1 . 0 : Initial release . <nl> * 0 . 2 . 0 : Many fixes , including lower memory footprint and support for Python 3 . <nl> + * 0 . 3 . 0 : Use 0 . 7 . 1 release . <nl> mmm a / tensorflow / models / image / mnist / convolutional . py <nl> ppp b / tensorflow / models / image / mnist / convolutional . py <nl> def eval_in_batches ( data , sess ) : <nl> batch_data = train_data [ offset : ( offset + BATCH_SIZE ) , . . . ] <nl> batch_labels = train_labels [ offset : ( offset + BATCH_SIZE ) ] <nl> # This dictionary maps the batch data ( as a numpy array ) to the <nl> - # node in the graph is should be fed to . <nl> + # node in the graph it should be fed to . <nl> feed_dict = { train_data_node : batch_data , <nl> train_labels_node : batch_labels } <nl> # Run the graph and fetch some of the nodes . <nl> mmm a / tensorflow / python / BUILD <nl> ppp b / tensorflow / python / BUILD <nl> py_library ( <nl> deps = [ <nl> " : framework " , <nl> " : ops " , <nl> + " : server_lib " , <nl> " : session " , <nl> " : training_ops " , <nl> ] , <nl> tf_py_wrap_cc ( <nl> srcs = [ " tensorflow . i " ] , <nl> swig_includes = [ <nl> " client / events_writer . i " , <nl> + " client / server_lib . i " , <nl> " client / tf_session . i " , <nl> " framework / python_op_gen . i " , <nl> " lib / core / py_func . i " , <nl> tf_py_wrap_cc ( <nl> " : py_record_writer_lib " , <nl> " : python_op_gen " , <nl> " : tf_session_helper " , <nl> + " / / tensorflow / core / distributed_runtime : server_lib " , <nl> + " / / tensorflow / core / distributed_runtime / rpc : grpc_server_lib " , <nl> " / / tensorflow / core / distributed_runtime / rpc : grpc_session " , <nl> " / / util / python : python_headers " , <nl> ] , <nl> py_library ( <nl> ] , <nl> ) <nl> <nl> + py_library ( <nl> + name = " server_lib " , <nl> + srcs = [ " client / server_lib . py " ] , <nl> + srcs_version = " PY2AND3 " , <nl> + deps = [ <nl> + " : pywrap_tensorflow " , <nl> + ] , <nl> + ) <nl> + <nl> + py_test ( <nl> + name = " server_lib_test " , <nl> + srcs = [ " client / server_lib_test . py " ] , <nl> + srcs_version = " PY2AND3 " , <nl> + deps = [ <nl> + " : extra_py_tests_deps " , <nl> + " : framework " , <nl> + " : framework_test_lib " , <nl> + " : server_lib " , <nl> + " : session " , <nl> + ] , <nl> + ) <nl> + <nl> # Just used by tests . <nl> tf_cuda_library ( <nl> name = " construction_fails_op " , <nl> mmm a / tensorflow / python / __init__ . py <nl> ppp b / tensorflow / python / __init__ . py <nl> <nl> # documentation , or remove . <nl> __all__ . extend ( [ <nl> ' AttrValue ' , <nl> + ' ClusterDef ' , <nl> ' ConfigProto ' , <nl> ' Event ' , <nl> ' GPUOptions ' , <nl> <nl> ' GRAPH_DEF_VERSION_MIN_PRODUCER ' , <nl> ' GraphDef ' , <nl> ' GraphOptions ' , <nl> + ' GrpcServer ' , <nl> ' HistogramProto ' , <nl> + ' JobDef ' , <nl> ' LogMessage ' , <nl> ' NameAttrList ' , <nl> ' NodeDef ' , <nl> <nl> ' PaddingFIFOQueue ' , <nl> ' RunOptions ' , <nl> ' RunOutputs ' , <nl> + ' ServerDef ' , <nl> ' SessionLog ' , <nl> ' Summary ' , <nl> ' arg_max ' , <nl> mmm a / tensorflow / python / client / client_lib . py <nl> ppp b / tensorflow / python / client / client_lib . py <nl> <nl> from __future__ import division <nl> from __future__ import print_function <nl> <nl> + # NOTE ( mrry ) : Support for ` tf . GrpcServer ` is currently experimental . <nl> + from tensorflow . core . protobuf . tensorflow_server_pb2 import ClusterDef <nl> + from tensorflow . core . protobuf . tensorflow_server_pb2 import JobDef <nl> + from tensorflow . core . protobuf . tensorflow_server_pb2 import ServerDef <nl> + from tensorflow . python . client . server_lib import GrpcServer <nl> + <nl> from tensorflow . python . client . session import InteractiveSession <nl> from tensorflow . python . client . session import Session <nl> <nl> new file mode 100644 <nl> index 0000000000000 . . 835f883ef4589 <nl> mmm / dev / null <nl> ppp b / tensorflow / python / client / server_lib . i <nl> <nl> + / * Copyright 2016 Google Inc . All Rights Reserved . <nl> + <nl> + Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + you may not use this file except in compliance with the License . <nl> + You may obtain a copy of the License at <nl> + <nl> + http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + <nl> + Unless required by applicable law or agreed to in writing , software <nl> + distributed under the License is distributed on an " AS IS " BASIS , <nl> + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + See the License for the specific language governing permissions and <nl> + limitations under the License . <nl> + = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = * / <nl> + <nl> + % nothread tensorflow : : ServerInterface : : Join ; <nl> + <nl> + % include " tensorflow / python / platform / base . i " <nl> + <nl> + / / % newobject tensorflow : : NewServer ; <nl> + <nl> + % typemap ( in ) const ServerDef & ( tensorflow : : ServerDef temp ) { <nl> + char * c_string ; <nl> + Py_ssize_t py_size ; <nl> + if ( PyBytes_AsStringAndSize ( $ input , & c_string , & py_size ) = = - 1 ) { <nl> + / / Python has raised an error ( likely TypeError or UnicodeEncodeError ) . <nl> + SWIG_fail ; <nl> + } <nl> + <nl> + if ( ! temp . ParseFromString ( string ( c_string , py_size ) ) ) { <nl> + PyErr_SetString ( <nl> + PyExc_TypeError , <nl> + " The ServerDef could not be parsed as a valid protocol buffer " ) ; <nl> + SWIG_fail ; <nl> + } <nl> + $ 1 = & temp ; <nl> + } <nl> + <nl> + % typemap ( in , numinputs = 0 ) <nl> + std : : unique_ptr < tensorflow : : ServerInterface > * out_server ( <nl> + std : : unique_ptr < tensorflow : : ServerInterface > temp ) { <nl> + $ 1 = & temp ; <nl> + } <nl> + <nl> + % typemap ( out ) tensorflow : : Status tensorflow : : NewServer { <nl> + if ( ! $ 1 . ok ( ) ) { <nl> + RaiseStatusNotOK ( $ 1 , $ descriptor ( tensorflow : : Status * ) ) ; <nl> + SWIG_fail ; <nl> + } <nl> + } <nl> + <nl> + % typemap ( argout ) std : : unique_ptr < tensorflow : : ServerInterface > * out_server { <nl> + / / TODO ( mrry ) : Convert this to SWIG_POINTER_OWN when the issues with freeing <nl> + / / a server are fixed . <nl> + $ result = SWIG_NewPointerObj ( $ 1 - > release ( ) , <nl> + $ descriptor ( tensorflow : : ServerInterface * ) , <nl> + 0 ) ; <nl> + } <nl> + <nl> + % feature ( " except " ) tensorflow : : ServerInterface : : Join { <nl> + / / Let other threads run while we wait for the server to shut down . <nl> + Py_BEGIN_ALLOW_THREADS <nl> + $ action <nl> + Py_END_ALLOW_THREADS <nl> + } <nl> + <nl> + % { <nl> + # include " tensorflow / core / distributed_runtime / server_lib . h " <nl> + <nl> + using tensorflow : : ServerDef ; <nl> + % } <nl> + <nl> + % ignoreall <nl> + <nl> + % unignore tensorflow ; <nl> + % unignore tensorflow : : ServerDef ; <nl> + % unignore tensorflow : : ServerInterface ; <nl> + % unignore tensorflow : : ServerInterface : : ~ ServerInterface ; <nl> + % unignore tensorflow : : ServerInterface : : Start ; <nl> + % unignore tensorflow : : ServerInterface : : Stop ; <nl> + % unignore tensorflow : : ServerInterface : : Join ; <nl> + % unignore tensorflow : : ServerInterface : : target ; <nl> + <nl> + % unignore tensorflow : : NewServer ; <nl> + <nl> + % include " tensorflow / core / distributed_runtime / server_lib . h " <nl> + <nl> + % unignoreall <nl> new file mode 100644 <nl> index 0000000000000 . . 38612edf15830 <nl> mmm / dev / null <nl> ppp b / tensorflow / python / client / server_lib . py <nl> <nl> + # Copyright 2015 Google Inc . All Rights Reserved . <nl> + # <nl> + # Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + # you may not use this file except in compliance with the License . <nl> + # You may obtain a copy of the License at <nl> + # <nl> + # http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + # <nl> + # Unless required by applicable law or agreed to in writing , software <nl> + # distributed under the License is distributed on an " AS IS " BASIS , <nl> + # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + # See the License for the specific language governing permissions and <nl> + # limitations under the License . <nl> + # = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> + " " " A Python interface for creating TensorFlow servers . " " " <nl> + <nl> + from __future__ import absolute_import <nl> + from __future__ import division <nl> + from __future__ import print_function <nl> + <nl> + import six # pylint : disable = unused - import <nl> + <nl> + from tensorflow . core . protobuf import tensorflow_server_pb2 <nl> + from tensorflow . python import pywrap_tensorflow <nl> + <nl> + <nl> + class GrpcServer ( object ) : <nl> + " " " An in - process TensorFlow server . <nl> + <nl> + NOTE ( mrry ) : This class is experimental and not yet suitable for use . <nl> + " " " <nl> + <nl> + def __init__ ( self , server_def , start = True ) : <nl> + " " " Creates a new server with the given definition . <nl> + <nl> + Args : <nl> + server_def : A ` tf . ServerDef ` protocol buffer , describing the server to <nl> + be created ( and the cluster of which it is a member ) . <nl> + start : ( Optional . ) Boolean , indicating whether to start the server after <nl> + creating it . Defaults to ` True ` . <nl> + " " " <nl> + if not isinstance ( server_def , tensorflow_server_pb2 . ServerDef ) : <nl> + raise TypeError ( " server_def must be a tf . ServerDef " ) <nl> + <nl> + self . _server = pywrap_tensorflow . NewServer ( server_def . SerializeToString ( ) ) <nl> + if start : <nl> + self . start ( ) <nl> + <nl> + def start ( self ) : <nl> + " " " Starts this server . " " " <nl> + self . _server . Start ( ) <nl> + <nl> + def stop ( self ) : <nl> + " " " Stops this server . <nl> + <nl> + NOTE ( mrry ) : This method is currently not implemented . <nl> + " " " <nl> + # TODO ( mrry ) : Implement this . <nl> + raise NotImplementedError ( " GrpcServer . stop ( ) " ) <nl> + <nl> + def join ( self ) : <nl> + " " " Blocks until the server has shut down . <nl> + <nl> + NOTE ( mrry ) : Since ` GrpcServer . stop ( ) ` is not currently implemented , this <nl> + method blocks forever . <nl> + " " " <nl> + self . _server . Join ( ) <nl> + <nl> + @ property <nl> + def target ( self ) : <nl> + " " " Returns the target for a ` tf . Session ` to connect to this server . <nl> + <nl> + To create a <nl> + [ ` tf . Session ` ] ( . . / . . / api_docs / python / client . md # Session ) that <nl> + connects to this server , use the following snippet : <nl> + <nl> + ` ` ` python <nl> + server = tf . GrpcServer ( . . . ) <nl> + with tf . Session ( server . target ) : <nl> + # . . . <nl> + ` ` ` <nl> + <nl> + Returns : <nl> + A string containing a session target for this server . <nl> + " " " <nl> + return self . _server . target ( ) <nl> new file mode 100644 <nl> index 0000000000000 . . 5705f363d5346 <nl> mmm / dev / null <nl> ppp b / tensorflow / python / client / server_lib_test . py <nl> <nl> + # Copyright 2016 Google Inc . All Rights Reserved . <nl> + # <nl> + # Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + # you may not use this file except in compliance with the License . <nl> + # You may obtain a copy of the License at <nl> + # <nl> + # http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + # <nl> + # Unless required by applicable law or agreed to in writing , software <nl> + # distributed under the License is distributed on an " AS IS " BASIS , <nl> + # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + # See the License for the specific language governing permissions and <nl> + # limitations under the License . <nl> + # = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> + " " " Tests for tf . GrpcServer . " " " <nl> + from __future__ import absolute_import <nl> + from __future__ import division <nl> + from __future__ import print_function <nl> + <nl> + import tensorflow as tf <nl> + <nl> + <nl> + class GrpcServerTest ( tf . test . TestCase ) : <nl> + <nl> + def _localServer ( self ) : <nl> + server_def = tf . ServerDef ( protocol = " grpc " ) <nl> + job_def = server_def . cluster . job . add ( ) <nl> + job_def . name = " local " <nl> + job_def . tasks [ 0 ] = " localhost : 0 " <nl> + server_def . job_name = job_def . name <nl> + server_def . task_index = 0 <nl> + return server_def <nl> + <nl> + def testRunStep ( self ) : <nl> + server = tf . GrpcServer ( self . _localServer ( ) ) <nl> + server . start ( ) <nl> + <nl> + with tf . Session ( server . target ) as sess : <nl> + c = tf . constant ( [ [ 2 , 1 ] ] ) <nl> + d = tf . constant ( [ [ 1 ] , [ 2 ] ] ) <nl> + e = tf . matmul ( c , d ) <nl> + print ( sess . run ( e ) ) <nl> + # TODO ( mrry ) : Add ` server . stop ( ) ` and ` server . join ( ) ` when these work . <nl> + <nl> + def testMultipleSessions ( self ) : <nl> + server = tf . GrpcServer ( self . _localServer ( ) ) <nl> + server . start ( ) <nl> + <nl> + c = tf . constant ( [ [ 2 , 1 ] ] ) <nl> + d = tf . constant ( [ [ 1 ] , [ 2 ] ] ) <nl> + e = tf . matmul ( c , d ) <nl> + <nl> + sess_1 = tf . Session ( server . target ) <nl> + sess_2 = tf . Session ( server . target ) <nl> + <nl> + sess_1 . run ( e ) <nl> + sess_2 . run ( e ) <nl> + <nl> + sess_1 . close ( ) <nl> + sess_2 . close ( ) <nl> + # TODO ( mrry ) : Add ` server . stop ( ) ` and ` server . join ( ) ` when these work . <nl> + <nl> + <nl> + if __name__ = = " __main__ " : <nl> + tf . test . main ( ) <nl> mmm a / tensorflow / python / framework / gen_docs_combined . py <nl> ppp b / tensorflow / python / framework / gen_docs_combined . py <nl> def library ( name , title , module = None , * * args ) : <nl> " SessionInterface " , " BaseSession " , " NameAttrList " , <nl> " AttrValue " , " TensorArray " , " OptimizerOptions " , <nl> " CollectionDef " , " MetaGraphDef " , " QueueRunnerDef " , <nl> - " SaverDef " , " VariableDef " , " TestCase " , <nl> - ] <nl> + " SaverDef " , " VariableDef " , " TestCase " , " GrpcServer " , <nl> + " ClusterDef " , " JobDef " , " ServerDef " ] <nl> <nl> def main ( unused_argv ) : <nl> if not FLAGS . out_dir : <nl> mmm a / tensorflow / python / framework / ops . py <nl> ppp b / tensorflow / python / framework / ops . py <nl> def unique_name ( self , name , mark_as_used = True ) : <nl> return name <nl> <nl> @ contextlib . contextmanager <nl> - def colocate_with ( self , op ) : <nl> + def colocate_with ( self , op , ignore_existing = False ) : <nl> " " " Returns a context manager that specifies an op to colocate with . <nl> <nl> + Note : this function is not for public use , only for internal libraries . <nl> + <nl> For example : <nl> <nl> ` ` ` python <nl> def colocate_with ( self , op ) : <nl> <nl> Args : <nl> op : The op to colocate all created ops with . <nl> + ignore_existing : If true , only applies colocation of this op within <nl> + the context , rather than applying all colocation properties <nl> + on the stack . <nl> <nl> Raises : <nl> ValueError : if op is None . <nl> def colocate_with ( self , op ) : <nl> device_fn_tmp = self . _device_function_stack <nl> self . _device_function_stack = [ ] <nl> <nl> + if ignore_existing : <nl> + current_stack = self . _colocation_stack <nl> + self . _colocation_stack = [ ] <nl> + <nl> self . _colocation_stack . append ( op ) <nl> <nl> try : <nl> def colocate_with ( self , op ) : <nl> self . _device_function_stack = device_fn_tmp <nl> self . _colocation_stack . pop ( ) <nl> <nl> + # Reset the colocation stack if requested . <nl> + if ignore_existing : <nl> + self . _colocation_stack = current_stack <nl> + <nl> @ contextlib . contextmanager <nl> def device ( self , device_name_or_function ) : <nl> " " " Returns a context manager that specifies the default device to use . <nl> def device ( device_name_or_function ) : <nl> return get_default_graph ( ) . device ( device_name_or_function ) <nl> <nl> <nl> - def colocate_with ( op ) : <nl> - return get_default_graph ( ) . colocate_with ( op ) <nl> + def colocate_with ( op , ignore_existing = False ) : <nl> + return get_default_graph ( ) . colocate_with ( op , ignore_existing ) <nl> <nl> <nl> def name_scope ( name ) : <nl> mmm a / tensorflow / python / framework / ops_test . py <nl> ppp b / tensorflow / python / framework / ops_test . py <nl> def testMultiColocationGroups ( self ) : <nl> c = constant_op . constant ( 4 . 0 ) <nl> self . assertEqual ( set ( [ b " loc : @ a " , b " loc : @ b " ] ) , set ( c . op . colocation_groups ( ) ) ) <nl> <nl> + def testColocationIgnoreStack ( self ) : <nl> + a = constant_op . constant ( [ 2 . 0 ] , name = " a " ) <nl> + b = constant_op . constant ( 3 . 0 , name = " b " ) <nl> + with ops . colocate_with ( a . op ) : <nl> + with ops . colocate_with ( b . op , ignore_existing = True ) : <nl> + c = constant_op . constant ( 4 . 0 ) <nl> + self . assertEqual ( set ( [ " loc : @ b " ] ) , set ( c . op . colocation_groups ( ) ) ) <nl> + <nl> def testColocateVariables ( self ) : <nl> a = variables . Variable ( [ 2 . 0 ] , name = " a " ) <nl> with ops . colocate_with ( a . op ) : <nl> mmm a / tensorflow / python / kernel_tests / constant_op_test . py <nl> ppp b / tensorflow / python / kernel_tests / constant_op_test . py <nl> def testZerosLikePartialShape ( self ) : <nl> z = tf . zeros_like ( d ) <nl> self . assertEqual ( d . get_shape ( ) . as_list ( ) , z . get_shape ( ) . as_list ( ) ) <nl> <nl> + def testZerosLikeDtype ( self ) : <nl> + # Make sure zeros_like works even for dtypes that cannot be cast between <nl> + with self . test_session ( ) : <nl> + shape = ( 3 , 5 ) <nl> + dtypes = np . float32 , np . complex64 <nl> + for in_type in dtypes : <nl> + x = np . arange ( 15 ) . astype ( in_type ) . reshape ( * shape ) <nl> + for out_type in dtypes : <nl> + y = tf . zeros_like ( x , dtype = out_type ) . eval ( ) <nl> + self . assertEqual ( y . dtype , out_type ) <nl> + self . assertEqual ( y . shape , shape ) <nl> + self . assertAllEqual ( y , np . zeros ( shape , dtype = out_type ) ) <nl> + <nl> <nl> class OnesTest ( tf . test . TestCase ) : <nl> <nl> mmm a / tensorflow / python / kernel_tests / control_flow_ops_py_test . py <nl> ppp b / tensorflow / python / kernel_tests / control_flow_ops_py_test . py <nl> def testWhileGrad_Shape ( self ) : <nl> r = control_flow_ops . While ( c , b , [ n , v ] , parallel_iterations = 1 ) <nl> <nl> r = tf . gradients ( r [ 1 ] , x ) [ 0 ] <nl> - self . assertEqual ( r . get_shape ( ) . as_list ( ) , [ None ] ) <nl> + self . assertEqual ( r . get_shape ( ) , tensor_shape . unknown_shape ( ) ) <nl> self . assertAllClose ( [ 810 . 0 , 2560 . 0 ] , r . eval ( feed_dict = { x : [ 3 . 0 , 4 . 0 ] } ) ) <nl> <nl> def testWhileGrad_MultipleUses ( self ) : <nl> mmm a / tensorflow / python / kernel_tests / decode_csv_op_test . py <nl> ppp b / tensorflow / python / kernel_tests / decode_csv_op_test . py <nl> def testWrongFieldStringError ( self ) : <nl> args , <nl> expected_err_re = " Unquoted fields cannot have quotes / CRLFs inside " ) <nl> <nl> + def testWrongDefaults ( self ) : <nl> + args = { <nl> + " records " : [ " , 1 " , " 0 . 2 , 2 " , " 3 . 0adf , 3 " ] , <nl> + " record_defaults " : [ [ 1 . 0 ] ] <nl> + } <nl> + <nl> + self . _test ( args , <nl> + expected_err_re = " Expect 1 fields but have 2 in record 0 " ) <nl> + <nl> + def testShortQuotedString ( self ) : <nl> + args = { " records " : [ " \ " " ] , " record_defaults " : [ [ " default " ] ] , } <nl> + <nl> + self . _test ( args , <nl> + expected_err_re = " Quoted field has to end with quote followed . * " ) <nl> + <nl> <nl> if __name__ = = " __main__ " : <nl> tf . test . main ( ) <nl> mmm a / tensorflow / python / kernel_tests / in_topk_op_test . py <nl> ppp b / tensorflow / python / kernel_tests / in_topk_op_test . py <nl> def testInTopNan ( self ) : <nl> target = [ 0 , 2 ] <nl> self . _validateInTopK ( predictions , target , 2 , [ False , False ] ) <nl> <nl> + def testBadTarget ( self ) : <nl> + predictions = [ [ 0 . 1 , 0 . 3 , 0 . 2 , 0 . 4 ] , [ 0 . 1 , 0 . 2 , 0 . 3 , 0 . 4 ] ] <nl> + target = [ 0 , 80000 ] <nl> + with self . test_session ( ) : <nl> + with self . assertRaisesRegexp ( tf . errors . InvalidArgumentError , <nl> + " target . * out of range " ) : <nl> + tf . nn . in_top_k ( predictions , target , 2 ) . eval ( ) <nl> + <nl> <nl> if __name__ = = " __main__ " : <nl> tf . test . main ( ) <nl> mmm a / tensorflow / python / kernel_tests / rnn_test . py <nl> ppp b / tensorflow / python / kernel_tests / rnn_test . py <nl> def testSharingWeightsWithDifferentNamescope ( self ) : <nl> for out0 , out1 in zip ( outputs0_values , outputs1_values ) : <nl> self . assertAllEqual ( out0 , out1 ) <nl> <nl> - def _testDynamicEquivalentToStaticRNN ( self , use_gpu ) : <nl> + def _testDynamicEquivalentToStaticRNN ( self , use_gpu , use_sequence_length ) : <nl> time_steps = 8 <nl> num_units = 3 <nl> num_proj = 4 <nl> def _testDynamicEquivalentToStaticRNN ( self , use_gpu ) : <nl> <nl> input_values = np . random . randn ( time_steps , batch_size , input_size ) <nl> <nl> - sequence_length = np . random . randint ( 0 , time_steps , size = batch_size ) <nl> + if use_sequence_length : <nl> + sequence_length = np . random . randint ( 0 , time_steps , size = batch_size ) <nl> + else : <nl> + sequence_length = None <nl> <nl> # # # # # # # # # # # Step 1 : Run static graph and generate readouts <nl> with self . test_session ( use_gpu = use_gpu , graph = tf . Graph ( ) ) as sess : <nl> def testDoubleInputWithDropoutAndDynamicCalculation ( self ) : <nl> self . _testDoubleInputWithDropoutAndDynamicCalculation ( use_gpu = True ) <nl> <nl> def testDynamicEquivalentToStaticRNN ( self ) : <nl> - self . _testDynamicEquivalentToStaticRNN ( use_gpu = False ) <nl> - self . _testDynamicEquivalentToStaticRNN ( use_gpu = True ) <nl> + self . _testDynamicEquivalentToStaticRNN ( <nl> + use_gpu = False , use_sequence_length = False ) <nl> + self . _testDynamicEquivalentToStaticRNN ( <nl> + use_gpu = True , use_sequence_length = False ) <nl> + self . _testDynamicEquivalentToStaticRNN ( <nl> + use_gpu = False , use_sequence_length = True ) <nl> + self . _testDynamicEquivalentToStaticRNN ( <nl> + use_gpu = True , use_sequence_length = True ) <nl> <nl> <nl> class BidirectionalRNNTest ( tf . test . TestCase ) : <nl> def rnn_long_sequence_benchmark ( batch_size , seqlen , num_units , <nl> def main ( _ ) : <nl> print ( " Graph Creation : Static Unroll vs . Dynamic Unroll LSTM " ) <nl> print ( " max_t \ t dt ( static ) \ t dt ( dynamic ) \ t dt ( dynamic ) / dt ( static ) " ) <nl> - for max_time in ( 1 , 25 , 50 ) : <nl> + for max_time in ( 1 , 25 , 50 , 100 , 200 ) : <nl> graph_creation_static_vs_dynamic_rnn_benchmark ( max_time ) <nl> <nl> print ( " Calculation : Static Unroll with Dynamic Flow LSTM " <nl> mmm a / tensorflow / python / ops / array_ops . py <nl> ppp b / tensorflow / python / ops / array_ops . py <nl> def zeros_like ( tensor , dtype = None , name = None ) : <nl> " " " <nl> with ops . op_scope ( [ tensor ] , name , " zeros_like " ) as name : <nl> tensor = ops . convert_to_tensor ( tensor , name = " tensor " ) <nl> - ret = gen_array_ops . _zeros_like ( tensor ) <nl> - if ( dtype is not None ) and ( tensor . dtype ! = dtype ) : <nl> - ret = gen_math_ops . cast ( ret , dtype ) <nl> - return ret <nl> + if dtype is not None and tensor . dtype ! = dtype : <nl> + ret = zeros ( shape ( tensor ) , dtype , name = name ) <nl> + ret . set_shape ( tensor . get_shape ( ) ) <nl> + return ret <nl> + else : <nl> + return gen_array_ops . _zeros_like ( tensor , name = name ) <nl> <nl> <nl> def ones_like ( tensor , dtype = None , name = None ) : <nl> mmm a / tensorflow / python / ops / control_flow_grad . py <nl> ppp b / tensorflow / python / ops / control_flow_grad . py <nl> def _SwitchGrad ( op , * grad ) : <nl> the merge on the first visit , and update the other input of the merge <nl> on the second visit . A next_iteration is also added on second visit . <nl> " " " <nl> - real_op = GetRealOp ( op ) <nl> + graph = ops . get_default_graph ( ) <nl> # pylint : disable = protected - access <nl> - ctxt = real_op . _get_control_flow_context ( ) <nl> + op_ctxt = op . _get_control_flow_context ( ) <nl> + grad_ctxt = graph . _get_control_flow_context ( ) <nl> # pylint : enable = protected - access <nl> - if isinstance ( ctxt , WhileContext ) : <nl> - merge_op = op . grad_state . switch_map . get ( real_op ) <nl> + if isinstance ( op_ctxt , WhileContext ) : <nl> + merge_op = grad_ctxt . grad_state . switch_map . get ( op ) <nl> if merge_op : <nl> # This is the second time this Switch is visited . It comes from <nl> # the non - exit branch of the Switch , so update the second input <nl> # to the Merge . <nl> - # TODO : Need to perform shape inference with this new input . <nl> + # TODO : Perform shape inference with this new input . <nl> # pylint : disable = protected - access <nl> merge_op . _update_input ( 1 , control_flow_ops . _NextIteration ( grad [ 1 ] ) ) <nl> # pylint : enable = protected - access <nl> def _SwitchGrad ( op , * grad ) : <nl> # input of merge when we see this Switch the second time . <nl> merge_fn = control_flow_ops . _Merge # pylint : disable = protected - access <nl> merge_op = merge_fn ( [ grad [ 0 ] , grad [ 0 ] ] , name = " b_switch " ) [ 0 ] <nl> - op . grad_state . switch_map [ real_op ] = merge_op . op <nl> + grad_ctxt . grad_state . switch_map [ op ] = merge_op . op <nl> return merge_op , None <nl> - elif isinstance ( ctxt , CondContext ) : <nl> - good_grad = grad [ ctxt . branch ] <nl> - zero_grad = grad [ 1 - ctxt . branch ] <nl> - # If this Switch is wrapped , it is part of a cond within a loop . In <nl> - # this case , we have called ControlFlowState . ZeroLike ( ) so grad is <nl> - # ready for merge . Otherwise , we need a switch to control zero_grad . <nl> - if not isinstance ( op , ControlFlowOpWrapper ) : <nl> + elif isinstance ( op_ctxt , CondContext ) : <nl> + good_grad = grad [ op_ctxt . branch ] <nl> + zero_grad = grad [ 1 - op_ctxt . branch ] <nl> + # If we are in a grad context , this switch is part of a cond within a <nl> + # loop . In this case , we have called ControlFlowState . ZeroLike ( ) so grad <nl> + # is ready for merge . Otherwise , we need a switch to control zero_grad . <nl> + if not ( grad_ctxt and grad_ctxt . grad_state ) : <nl> dtype = good_grad . dtype <nl> - zero_grad = switch ( zero_grad , ctxt . pred , dtype = dtype ) [ 1 - ctxt . branch ] <nl> + branch = op_ctxt . branch <nl> + zero_grad = switch ( zero_grad , op_ctxt . pred , dtype = dtype ) [ 1 - branch ] <nl> return merge ( [ good_grad , zero_grad ] , name = " cond_grad " ) [ 0 ] , None <nl> else : <nl> - false_grad = switch ( grad [ 0 ] , real_op . inputs [ 1 ] ) [ 0 ] <nl> - true_grad = switch ( grad [ 1 ] , real_op . inputs [ 1 ] ) [ 1 ] <nl> + false_grad = switch ( grad [ 0 ] , op . inputs [ 1 ] ) [ 0 ] <nl> + true_grad = switch ( grad [ 1 ] , op . inputs [ 1 ] ) [ 1 ] <nl> return merge ( [ false_grad , true_grad ] ) [ 0 ] , None <nl> <nl> <nl> def _SwitchGrad ( op , * grad ) : <nl> @ ops . RegisterGradient ( " Merge " ) <nl> def _MergeGrad ( op , grad , _ ) : <nl> " " " Gradients for a Merge op are calculated using a Switch op . " " " <nl> - real_op = GetRealOp ( op ) <nl> - input_op = real_op . inputs [ 0 ] . op <nl> + input_op = op . inputs [ 0 ] . op <nl> + graph = ops . get_default_graph ( ) <nl> # pylint : disable = protected - access <nl> - ctxt = input_op . _get_control_flow_context ( ) <nl> + op_ctxt = input_op . _get_control_flow_context ( ) <nl> + grad_ctxt = graph . _get_control_flow_context ( ) <nl> # pylint : enable = protected - access <nl> - if isinstance ( ctxt , WhileContext ) : <nl> - grad_ctxt = op . grad_state . grad_context <nl> + if isinstance ( op_ctxt , WhileContext ) : <nl> # pylint : disable = protected - access <nl> return control_flow_ops . _SwitchRefOrTensor ( grad , grad_ctxt . pivot ) <nl> # pylint : enable = protected - access <nl> - elif isinstance ( ctxt , CondContext ) : <nl> - pred = ctxt . pred <nl> - if isinstance ( op , ControlFlowOpWrapper ) : <nl> + elif isinstance ( op_ctxt , CondContext ) : <nl> + pred = op_ctxt . pred <nl> + if grad_ctxt and grad_ctxt . grad_state : <nl> # This Merge node is part of a cond within a loop . <nl> # The backprop needs to have the value of this predicate for every <nl> # iteration . So we must have its values accumulated in the forward , and <nl> # use the accumulated values as the predicate for this backprop switch . <nl> - grad_state = op . grad_state <nl> + grad_state = grad_ctxt . grad_state <nl> real_pred = grad_state . history_map . get ( pred . name ) <nl> if not real_pred : <nl> # Remember the value of pred for every iteration . <nl> def _MergeGrad ( op , grad , _ ) : <nl> return control_flow_ops . _SwitchRefOrTensor ( grad , pred , name = " cond_grad " ) <nl> # pylint : enable = protected - access <nl> else : <nl> - num_inputs = len ( real_op . inputs ) <nl> - cond = [ math_ops . equal ( real_op . outputs [ 1 ] , i ) for i in xrange ( num_inputs ) ] <nl> + num_inputs = len ( op . inputs ) <nl> + cond = [ math_ops . equal ( op . outputs [ 1 ] , i ) for i in xrange ( num_inputs ) ] <nl> # pylint : disable = protected - access <nl> return [ control_flow_ops . _SwitchRefOrTensor ( grad , cond [ i ] ) [ 1 ] <nl> for i in xrange ( num_inputs ) ] <nl> def _RefMergeGrad ( op , grad , _ ) : <nl> <nl> <nl> @ ops . RegisterGradient ( " Exit " ) <nl> - def _ExitGrad ( op , grad ) : <nl> + def _ExitGrad ( _ , grad ) : <nl> " " " Gradients for an exit op are calculated using an Enter op . " " " <nl> - real_op = GetRealOp ( op ) <nl> + graph = ops . get_default_graph ( ) <nl> # pylint : disable = protected - access <nl> - forward_ctxt = real_op . _get_control_flow_context ( ) <nl> + grad_ctxt = graph . _get_control_flow_context ( ) <nl> # pylint : enable = protected - access <nl> - if not forward_ctxt . back_prop : <nl> - # No gradient computation for this loop . <nl> + if not grad_ctxt . back_prop : <nl> + # The flag ` back_prop ` is set by users to suppress gradient <nl> + # computation for this loop . If the flag ` back_prop ` is true , <nl> + # no gradient computation . <nl> return None <nl> - grad_ctxt = op . grad_state . grad_context <nl> grad_ctxt . AddName ( grad . name ) <nl> enter_fn = control_flow_ops . _Enter # pylint : disable = protected - access <nl> grad_ctxt . Enter ( ) <nl> def _EnterGrad ( op , grad ) : <nl> For loop variables , grad is the gradient so just add an exit . <nl> For loop invariants , we need to add an accumulator loop . <nl> " " " <nl> - real_op = GetRealOp ( op ) <nl> + graph = ops . get_default_graph ( ) <nl> # pylint : disable = protected - access <nl> - forward_ctxt = real_op . _get_control_flow_context ( ) <nl> + grad_ctxt = graph . _get_control_flow_context ( ) <nl> # pylint : enable = protected - access <nl> - if not forward_ctxt . back_prop : <nl> - # The flag ` back_prop ` is set by users to suppress gradient <nl> - # computation for this loop . If the flag ` back_prop ` is true , <nl> - # no gradient computation . <nl> + if not grad_ctxt . back_prop : <nl> + # If the flag ` back_prop ` is true , no gradient computation . <nl> return grad <nl> - grad_ctxt = op . grad_state . grad_context <nl> - if real_op . get_attr ( " is_constant " ) : <nl> + if op . get_attr ( " is_constant " ) : <nl> # Add a gradient accumulator for each loop invariant . <nl> result = grad_ctxt . AddBackPropAccumulator ( grad ) <nl> else : <nl> mmm a / tensorflow / python / ops / control_flow_ops . py <nl> ppp b / tensorflow / python / ops / control_flow_ops . py <nl> def _SwitchRefOrTensor ( data , pred , name = " Switch " ) : <nl> TypeError : if data is not a Tensor or IndexedSlices <nl> " " " <nl> data = ops . convert_to_tensor_or_indexed_slices ( data , name = " data " ) <nl> - # NOTE ( mrry ) : ops . device ( None ) below addresses the following scenario . <nl> + # NOTE ( vrv ) : ops . colocate_with ( data , ignore_existing = True ) below <nl> + # addresses the following scenario . <nl> # <nl> # Assume you execute Optimizer . apply_gradients ( ) in a branch of a cond ( ) . <nl> # <nl> - # 1 . The update op is created inside a ` with tf . device ( var . device ) : ` block <nl> - # say var . device = " / job : ps / task : 1 " . <nl> + # 1 . The update op is created inside a ` with ops . colocate ( var ) : ` block <nl> # <nl> # 2 . Some tensor ` data ` is captured and a switch is created in a <nl> - # ` with tf . device ( data . device ) : ` block ( data . device = " / job : worker_train " ) . <nl> + # ` with ops . colocate_with ( data ) : ` block . <nl> # <nl> - # with tf . device ( " / job : ps / task : 1 " ) : <nl> - # with tf . device ( " / job : worker_train " ) : <nl> + # with ops . colocate_with ( var ) : <nl> + # with ops . colocate_with ( data ) : <nl> # op = . . . <nl> # <nl> - # But then calling ` print op . device ` returns : <nl> - # = = > " / job : worker_train / task : 1 " - - a device that doesn ' t exist in this case ! <nl> - with ops . colocate_with ( data ) : <nl> + # var and data may be pinned to different devices , so we want to ops <nl> + # created within ops . colocate_with ( data ) to ignore the existing stack . <nl> + with ops . colocate_with ( data , ignore_existing = True ) : <nl> if isinstance ( data , ops . Tensor ) : <nl> if not data . dtype . is_ref_dtype : <nl> return switch ( data , pred , name = name ) <nl> def _convert_flows_to_tensorarrays ( tensors_or_tensorarrays , tensors_or_flows ) : <nl> for ( ta , t_or_flow ) in zip ( tensors_or_tensorarrays , tensors_or_flows ) ] <nl> <nl> <nl> - class ControlFlowOpWrapper ( object ) : <nl> - " " " A wrapper class for Operation . <nl> - <nl> - A wrapped op allows us to capture the uses of its inputs and outputs . In <nl> - gradients ( ) , right before calling the gradient function of an op , we wrap <nl> - the op by calling MakeWrapper . So during the exection of the gradient <nl> - function of an op , any time when one of its inputs / outputs is used , we <nl> - generate code to remember its values for all iterations . <nl> - " " " <nl> - <nl> - class _ControlFlowOpInputs ( object ) : <nl> - " " " An indirection to capture the input tensors needed in backprop . " " " <nl> - <nl> - def __init__ ( self , op , grad_state ) : <nl> - self . _op = op <nl> - self . _grad_state = grad_state <nl> - self . _inputs = None <nl> - <nl> - def __len__ ( self ) : <nl> - return len ( self . _op . _inputs ) <nl> - <nl> - def __getitem__ ( self , index ) : <nl> - if self . _inputs is None : <nl> - self . _inputs = [ None for _ in self . _op . inputs ] <nl> - if isinstance ( index , int ) : <nl> - val = self . _inputs [ index ] <nl> - if val is None : <nl> - f_val = self . _op . inputs [ index ] <nl> - val = self . _grad_state . GetRealValue ( f_val ) <nl> - self . _inputs [ index ] = val <nl> - return val <nl> - elif isinstance ( index , slice ) : <nl> - start , stop , step = index . indices ( len ( self ) ) <nl> - vals = [ self [ i ] for i in xrange ( start , stop , step ) ] <nl> - return vals <nl> - else : <nl> - raise TypeError ( " index must be an integer or slice " ) <nl> - <nl> - class _ControlFlowOpOutputs ( object ) : <nl> - " " " An indirection to capture the output tensors needed in backprop . " " " <nl> - <nl> - def __init__ ( self , op , grad_state ) : <nl> - self . _op = op <nl> - self . _grad_state = grad_state <nl> - self . _outputs = None <nl> - <nl> - def __len__ ( self ) : <nl> - return len ( self . _op . _outputs ) <nl> - <nl> - def __getitem__ ( self , index ) : <nl> - if self . _outputs is None : <nl> - self . _outputs = [ None for _ in self . _op . outputs ] <nl> - if isinstance ( index , int ) : <nl> - val = self . _outputs [ index ] <nl> - if val is None : <nl> - f_val = self . _op . outputs [ index ] <nl> - val = self . _grad_state . GetRealValue ( f_val ) <nl> - self . _outputs [ index ] = val <nl> - return val <nl> - elif isinstance ( index , slice ) : <nl> - start , stop , step = index . indices ( len ( self ) ) <nl> - vals = [ self [ i ] for i in xrange ( start , stop , step ) ] <nl> - return vals <nl> - else : <nl> - raise TypeError ( " index must be an integer or slice " ) <nl> - <nl> - def __init__ ( self , op , grad_state ) : <nl> - self . _grad_state = grad_state # The GradLoopState this op belongs to . <nl> - self . _op = op <nl> - self . _inputs = None <nl> - self . _outputs = None <nl> - <nl> - @ property <nl> - def grad_state ( self ) : <nl> - return self . _grad_state <nl> - <nl> - @ property <nl> - def inputs ( self ) : <nl> - if self . _inputs is None : <nl> - self . _inputs = self . _ControlFlowOpInputs ( self . _op , self . _grad_state ) <nl> - return self . _inputs <nl> - <nl> - @ property <nl> - def outputs ( self ) : <nl> - if self . _outputs is None : <nl> - self . _outputs = self . _ControlFlowOpOutputs ( self . _op , self . _grad_state ) <nl> - return self . _outputs <nl> - <nl> - @ property <nl> - def op ( self ) : <nl> - return self . _op <nl> - <nl> - @ property <nl> - def name ( self ) : <nl> - " " " Returns the name of this instance of op . " " " <nl> - return self . _op . name <nl> - <nl> - @ property <nl> - def _id ( self ) : <nl> - " " " Returns the unique id of this operation . " " " <nl> - return self . _op . _id <nl> - <nl> - @ property <nl> - def device ( self ) : <nl> - " " " Returns the device of this operation . <nl> - <nl> - Returns : <nl> - a string or None if the device was not set . <nl> - " " " <nl> - return self . _op . device <nl> - <nl> - @ property <nl> - def type ( self ) : <nl> - " " " Returns the type of the op . " " " <nl> - return self . _op . type <nl> - <nl> - @ property <nl> - def graph ( self ) : <nl> - " " " The ` Graph ` that contains this operation . " " " <nl> - return self . _op . graph <nl> - <nl> - def get_attr ( self , name ) : <nl> - " " " Returns the value of the attr of this op with the given ` name ` . " " " <nl> - return self . _op . get_attr ( name ) <nl> - <nl> - def _get_control_flow_context ( self ) : <nl> - " " " Returns the control flow context of this op . " " " <nl> - return self . _op . _get_control_flow_context ( ) <nl> - <nl> - <nl> def _IsLoopConstantEnter ( op ) : <nl> - " " " Returns true iff op is a loop invariant . " " " <nl> + " " " Return true iff op is a loop invariant . " " " <nl> is_enter = ( op . type = = " Enter " or op . type = = " RefEnter " ) <nl> return is_enter and op . get_attr ( " is_constant " ) <nl> <nl> <nl> + def _GetLoopConstantEnter ( value ) : <nl> + " " " Return the enter op if we can infer ` value ` to be a loop invariant . " " " <nl> + id_ops = { " Switch " , " RefSwitch " , " Identity " , " RefIdentity " } <nl> + op = value . op <nl> + while op . type in id_ops : <nl> + op = op . inputs [ 0 ] . op <nl> + return op if _IsLoopConstantEnter ( op ) else None <nl> + <nl> + <nl> def _IsLoopExit ( op ) : <nl> return op . type = = " Exit " or op . type = = " RefExit " <nl> <nl> def __init__ ( self , forward_ctxt , outer_grad_state ) : <nl> self . _grad_context = WhileContext ( forward_ctxt . parallel_iterations , <nl> forward_ctxt . back_prop , <nl> forward_ctxt . swap_memory , <nl> - forward_ctxt . name ) <nl> + forward_ctxt . name , <nl> + self ) <nl> real_cnt = outer_grad_state . AddBackPropAccumulatedValue ( history_cnt , cnt ) <nl> self . _grad_index = self . _grad_context . AddBackPropCounter ( real_cnt ) <nl> outer_grad_ctxt . Exit ( ) <nl> def __init__ ( self , forward_ctxt , outer_grad_state ) : <nl> self . _grad_context = WhileContext ( forward_ctxt . parallel_iterations , <nl> forward_ctxt . back_prop , <nl> forward_ctxt . swap_memory , <nl> - forward_ctxt . name ) <nl> + forward_ctxt . name , <nl> + self ) <nl> self . _grad_index = self . _grad_context . AddBackPropCounter ( cnt ) <nl> if outer_forward_ctxt : outer_forward_ctxt . Exit ( ) <nl> <nl> def AddForwardAccumulator ( self , value , dead_branch = False ) : <nl> edge from the push op to either ` forward_index . op ` or ` forward_sync ` . <nl> <nl> Args : <nl> - value : The tensor that is to be accumulated . <nl> + value : The source tensor in forward that is to be accumulated . <nl> dead_branch : True iff the tensor is on a dead branch of a cond . <nl> <nl> Returns : <nl> The stack that contains the accumulated history of the tensor . <nl> " " " <nl> - # TODO ( yuanbyu ) : Make sure the colocation of stack ops and value . <nl> - # pylint : disable = protected - access <nl> - acc = gen_data_flow_ops . _stack ( value . dtype . base_dtype , name = " f_acc " ) <nl> - # pylint : enable = protected - access <nl> - <nl> - # Make acc available in the forward context . <nl> - enter_acc = self . forward_context . AddValue ( acc ) <nl> - <nl> - # Add the stack_push op in the context of value . op . <nl> - swap_enabled = self . forward_context . swap_memory <nl> - value_ctxt = value . op . _get_control_flow_context ( ) <nl> - if _IsLoopExit ( value . op ) : <nl> - value_ctxt = value_ctxt . outer_context <nl> - if value_ctxt = = self . forward_context : <nl> - # value is not nested in the forward context . <nl> - self . forward_context . Enter ( ) <nl> - push = gen_data_flow_ops . _stack_push ( enter_acc , value , <nl> - swap_memory = swap_enabled ) <nl> - self . forward_context . Exit ( ) <nl> - # Protect stack push and order it before forward_index . <nl> - self . forward_index . op . _add_control_input ( push . op ) <nl> - else : <nl> - # value is in a cond context within the forward context . <nl> - assert isinstance ( value_ctxt , CondContext ) <nl> - if dead_branch : <nl> - # The special case for creating a zero tensor for a dead <nl> - # branch of a switch . See ControlFlowState . ZerosLike ( ) . <nl> - value_ctxt . outer_context . Enter ( ) <nl> - push = gen_data_flow_ops . _stack_push ( enter_acc , value , <nl> - swap_memory = swap_enabled ) <nl> - value_ctxt . outer_context . Exit ( ) <nl> - push . op . _set_control_flow_context ( value_ctxt ) <nl> + curr_ctxt = ops . get_default_graph ( ) . _get_control_flow_context ( ) <nl> + with ops . control_dependencies ( None ) : <nl> + if curr_ctxt : curr_ctxt . Enter ( ) <nl> + with ops . colocate_with ( value ) : <nl> + # pylint : disable = protected - access <nl> + acc = gen_data_flow_ops . _stack ( value . dtype . base_dtype , name = " f_acc " ) <nl> + # pylint : enable = protected - access <nl> + if curr_ctxt : curr_ctxt . Exit ( ) <nl> + <nl> + # Make acc available in the forward context . <nl> + enter_acc = self . forward_context . AddValue ( acc ) <nl> + <nl> + # Add the stack_push op in the context of value . op . <nl> + swap_enabled = self . forward_context . swap_memory <nl> + value_ctxt = value . op . _get_control_flow_context ( ) <nl> + if _IsLoopExit ( value . op ) : <nl> + value_ctxt = value_ctxt . outer_context <nl> + if value_ctxt = = self . forward_context : <nl> + # value is not nested in the forward context . <nl> + self . forward_context . Enter ( ) <nl> + push = gen_data_flow_ops . _stack_push ( <nl> + enter_acc , value , swap_memory = swap_enabled ) <nl> + self . forward_context . Exit ( ) <nl> + # Protect stack push and order it before forward_index . <nl> + self . forward_index . op . _add_control_input ( push . op ) <nl> else : <nl> - value_ctxt . Enter ( ) <nl> - push = gen_data_flow_ops . _stack_push ( enter_acc , value , <nl> - swap_memory = swap_enabled ) <nl> - value_ctxt . Exit ( ) <nl> - # Protect stack push and order it before forward_sync . <nl> - self . forward_sync . _add_control_input ( push . op ) <nl> - # Order stack push after the successor of forward_index <nl> - add_op = self . forward_index . op . inputs [ 0 ] . op <nl> - push . op . _add_control_input ( add_op ) <nl> - return acc <nl> + # value is in a cond context within the forward context . <nl> + assert isinstance ( value_ctxt , CondContext ) <nl> + if dead_branch : <nl> + # The special case for creating a zero tensor for a dead <nl> + # branch of a switch . See ControlFlowState . ZerosLike ( ) . <nl> + value_ctxt . outer_context . Enter ( ) <nl> + push = gen_data_flow_ops . _stack_push ( <nl> + enter_acc , value , swap_memory = swap_enabled ) <nl> + value_ctxt . outer_context . Exit ( ) <nl> + push . op . _set_control_flow_context ( value_ctxt ) <nl> + else : <nl> + value_ctxt . Enter ( ) <nl> + push = gen_data_flow_ops . _stack_push ( <nl> + enter_acc , value , swap_memory = swap_enabled ) <nl> + value_ctxt . Exit ( ) <nl> + # Protect stack push and order it before forward_sync . <nl> + self . forward_sync . _add_control_input ( push . op ) <nl> + # Order stack push after the successor of forward_index <nl> + add_op = self . forward_index . op . inputs [ 0 ] . op <nl> + push . op . _add_control_input ( add_op ) <nl> + return acc <nl> <nl> def AddBackPropAccumulatedValue ( self , history_value , value , <nl> dead_branch = False ) : <nl> def AddBackPropAccumulatedValue ( self , history_value , value , <nl> cond_ctxt = value_ctxt <nl> break <nl> value_ctxt = value_ctxt . outer_context <nl> - if cond_ctxt : <nl> - # Guard stack pop with a switch if it is controlled by a cond <nl> - grad_state = self <nl> - pred = None <nl> - while not pred and grad_state : <nl> - pred = grad_state . history_map . get ( cond_ctxt . pred . name ) <nl> - grad_state = grad_state . outer_grad_state <nl> - branch = ( 1 - cond_ctxt . branch ) if dead_branch else cond_ctxt . branch <nl> - history_value = _SwitchRefOrTensor ( history_value , pred ) [ branch ] <nl> - pop = gen_data_flow_ops . _stack_pop ( history_value , value . dtype . base_dtype ) <nl> + with ops . control_dependencies ( None ) : <nl> + self . grad_context . Enter ( ) <nl> + if cond_ctxt : <nl> + # Guard stack pop with a switch if it is controlled by a cond <nl> + grad_state = self <nl> + pred = None <nl> + while not pred and grad_state : <nl> + pred = grad_state . history_map . get ( cond_ctxt . pred . name ) <nl> + grad_state = grad_state . outer_grad_state <nl> + branch = ( 1 - cond_ctxt . branch ) if dead_branch else cond_ctxt . branch <nl> + history_value = _SwitchRefOrTensor ( history_value , pred ) [ branch ] <nl> + pop = gen_data_flow_ops . _stack_pop ( history_value , value . dtype . base_dtype ) <nl> + self . grad_context . Exit ( ) <nl> if self . grad_context . parallel_iterations > 1 : <nl> # All pops are ordered after pivot_for_body and before grad_sync . <nl> self . grad_sync . _add_control_input ( pop . op ) <nl> return pop <nl> <nl> def GetRealValue ( self , value ) : <nl> - " " " Get the real value . <nl> + " " " Get the real value of ` value ` . <nl> <nl> - If backprop " uses " a value produced by forward inference , an <nl> - accumulator is added in the forward loop to accumulate its values . <nl> - We use the accumulated value . <nl> + If backprop " uses " a value produced by forward inference , an accumulator <nl> + is added in the forward loop to accumulate its values . We use the <nl> + accumulated value . This method must be called in the grad loop context . <nl> + ` value ` must be in forward and needed for backprop . <nl> <nl> Args : <nl> value : A tensor to be captured . <nl> <nl> Returns : <nl> - The same tensor value from the saved history . <nl> + The same tensor obtained from the saved history . <nl> " " " <nl> assert value . op . type ! = " Variable " <nl> real_value = self . _history_map . get ( value . name ) <nl> if real_value is None : <nl> - if _IsLoopConstantEnter ( value . op ) : <nl> - # Special case for loop invariant . <nl> - if self . _outer_grad_state : <nl> - # This is a nested loop so we record the history of this <nl> - # value in outer_forward_ctxt . <nl> + cur_value = value <nl> + cur_grad_state = self <nl> + while True : <nl> + enter_op = _GetLoopConstantEnter ( cur_value ) <nl> + if enter_op : <nl> + # Special case : cur_value comes from a constant Enter node . <nl> + cur_value = enter_op . inputs [ 0 ] <nl> + if self . _outer_grad_state : <nl> + cur_grad_state = cur_grad_state . outer_grad_state <nl> + else : <nl> + # We are now outside all nested loops for this gradient ( ) , <nl> + # so ` value ` is a loop invariant and there is no need to <nl> + # save the history of value . <nl> + real_value = self . _grad_context . AddValue ( cur_value ) <nl> + break <nl> + else : <nl> + # Record the history of this value in forward_ctxt . <nl> + # TODO ( yuanbyu ) : Avoid recording constants . <nl> self . _grad_context . Exit ( ) <nl> - outer_value = value . op . inputs [ 0 ] <nl> - history_value = self . _outer_grad_state . AddForwardAccumulator ( <nl> - outer_value ) <nl> + h_value = cur_grad_state . AddForwardAccumulator ( cur_value ) <nl> self . _grad_context . Enter ( ) <nl> - else : <nl> - # Just use the input value of this Enter node . <nl> - real_value = GetRealOp ( value . op ) . inputs [ 0 ] <nl> - else : <nl> - # Record the history of this value in forward_ctxt . <nl> - # NOTE ( yuanbyu ) : Don ' t record for constants . <nl> - self . _grad_context . Exit ( ) <nl> - history_value = self . AddForwardAccumulator ( value ) <nl> - self . _grad_context . Enter ( ) <nl> + break <nl> <nl> if real_value is None : <nl> # Add the stack pop op in the grad context . <nl> - real_value = self . AddBackPropAccumulatedValue ( history_value , value ) <nl> + real_value = self . AddBackPropAccumulatedValue ( h_value , value ) <nl> self . _history_map [ value . name ] = real_value <nl> return real_value <nl> <nl> class ControlFlowState ( object ) : <nl> def __init__ ( self ) : <nl> self . _map = { } # maps forward loop context to GradLoopState <nl> <nl> - def _GetGradState ( self , op ) : <nl> - " " " Get the gradient loop state for this op if any . " " " <nl> - if _IsLoopExit ( op ) : <nl> + def _GetGradState ( self , op , before ) : <nl> + " " " Return the grad state for this op if it ' s in a forward loop context . " " " <nl> + if before and _IsLoopExit ( op ) : <nl> forward_ctxt = op . _get_control_flow_context ( ) <nl> forward_ctxt = forward_ctxt . outer_context <nl> if forward_ctxt : <nl> def _GetGradState ( self , op ) : <nl> return self . _map . get ( forward_ctxt ) <nl> return None <nl> <nl> - def MakeWrapper ( self , op ) : <nl> - " " " Make a wrapper for op if it is in a WhileContext . " " " <nl> - forward_ctxt = _GetWhileContext ( op ) <nl> - if forward_ctxt : <nl> - grad_state = self . _map . get ( forward_ctxt ) <nl> - if grad_state : <nl> - return ControlFlowOpWrapper ( op , grad_state ) <nl> - return op <nl> - <nl> def GetAllLoopExits ( self ) : <nl> " " " Return a list containing the exits of all the loops . " " " <nl> loop_exits = [ ] <nl> def GetAllLoopExits ( self ) : <nl> loop_exits . append ( loop_exit ) <nl> return loop_exits <nl> <nl> - def EnterGradWhileContext ( self , op ) : <nl> + def EnterGradWhileContext ( self , op , before ) : <nl> " " " Enter the WhileContext for gradient computation . " " " <nl> - grad_state = self . _GetGradState ( op ) <nl> + grad_state = self . _GetGradState ( op , before ) <nl> if grad_state : <nl> grad_state . grad_context . Enter ( ) <nl> <nl> - def ExitGradWhileContext ( self , op ) : <nl> + def ExitGradWhileContext ( self , op , before ) : <nl> " " " Exit the WhileContext for gradient computation . " " " <nl> - grad_state = self . _GetGradState ( op ) <nl> + grad_state = self . _GetGradState ( op , before ) <nl> if grad_state : <nl> grad_state . grad_context . Exit ( ) <nl> <nl> def ZerosLikeForExit ( self , val ) : <nl> result = array_ops . zeros ( val_shape . dims , val . dtype ) <nl> outer_grad_state . grad_context . Exit ( ) <nl> else : <nl> - history_val = outer_grad_state . AddForwardAccumulator ( val ) <nl> + # Only the shape of value is needed for backprop . <nl> + forward_ctxt . outer_context . Enter ( ) <nl> + shape = array_ops . shape ( value ) <nl> + forward_ctxt . outer_context . Exit ( ) <nl> + # Save the shape to a stack . <nl> + history_shape = outer_grad_state . AddForwardAccumulator ( shape ) <nl> + # Get the shape back from the stack . <nl> outer_grad_ctxt = outer_grad_state . grad_context <nl> outer_grad_ctxt . Enter ( ) <nl> - real_val = outer_grad_state . AddBackPropAccumulatedValue ( <nl> - history_val , val ) <nl> - result = array_ops . zeros_like ( real_val ) <nl> + real_shape = outer_grad_state . AddBackPropAccumulatedValue ( <nl> + history_shape , shape ) <nl> + result = array_ops . zeros ( real_shape , value . dtype ) <nl> outer_grad_ctxt . Exit ( ) <nl> else : <nl> # This is not a nested loop . <nl> def ZerosLike ( self , op , index ) : <nl> <nl> # Add forward accumulator for shape . <nl> grad_state . grad_context . Exit ( ) <nl> - history_shape = grad_state . AddForwardAccumulator ( zeros_shape , dead_branch ) <nl> + h_shape = grad_state . AddForwardAccumulator ( <nl> + zeros_shape , dead_branch = dead_branch ) <nl> grad_state . grad_context . Enter ( ) <nl> <nl> # Create a zero tensor with the right shape . <nl> shape = grad_state . AddBackPropAccumulatedValue ( <nl> - history_shape , zeros_shape , dead_branch ) <nl> + h_shape , zeros_shape , dead_branch ) <nl> result = array_ops . zeros ( shape , val . dtype ) <nl> return result <nl> <nl> <nl> - def GetRealOp ( op ) : <nl> - " " " Get the real op by removing the wrapper . " " " <nl> - while isinstance ( op , ControlFlowOpWrapper ) : <nl> - op = op . op <nl> - return op <nl> - <nl> - <nl> def MaybeCreateControlFlowState ( between_op_list , between_ops ) : <nl> " " " Create the state for all the while loops involved in one gradients ( ) . <nl> <nl> def AddValue ( self , val ) : <nl> return result <nl> <nl> def AddOp ( self , op ) : <nl> + self . _AddOpInternal ( op ) <nl> + <nl> + def _AddOpInternal ( self , op ) : <nl> " " " Add ` op ` to the current context . " " " <nl> if not op . inputs : <nl> # Add this op to the enclosing while context <nl> def f2 ( ) : return tf . add ( y , 23 ) <nl> class WhileContext ( ControlFlowContext ) : <nl> " " " The context for the loop construct . " " " <nl> <nl> - def __init__ ( self , parallel_iterations , back_prop , swap_memory , name ) : <nl> + def __init__ ( self , parallel_iterations , back_prop , swap_memory , name , <nl> + grad_state = None ) : <nl> ControlFlowContext . __init__ ( self ) <nl> self . _name = ops . get_default_graph ( ) . unique_name ( name ) <nl> self . _parallel_iterations = parallel_iterations <nl> def __init__ ( self , parallel_iterations , back_prop , swap_memory , name ) : <nl> self . _pivot = None <nl> # The list of exit tensors for loop variables . <nl> self . _loop_exits = None <nl> + # The gradient loop state <nl> + self . _grad_state = grad_state <nl> <nl> @ property <nl> def name ( self ) : <nl> def loop_exits ( self ) : <nl> " " " The list of exit tensors for loop variables . " " " <nl> return self . _loop_exits <nl> <nl> + @ property <nl> + def grad_state ( self ) : <nl> + " " " The gradient loop state . " " " <nl> + return self . _grad_state <nl> + <nl> def GetWhileContext ( self ) : <nl> return self <nl> <nl> def AddValue ( self , val ) : <nl> result = val <nl> if val . name not in self . _values : <nl> self . _values . add ( val . name ) <nl> + <nl> + # If we are in a grad context and val is from its forward context , <nl> + # use GetRealValue ( ) , which adds the logic to save the history of <nl> + # val in forward . <nl> + grad_ctxt = ops . get_default_graph ( ) . _get_control_flow_context ( ) <nl> + if grad_ctxt : <nl> + grad_ctxt = grad_ctxt . GetWhileContext ( ) <nl> + if grad_ctxt . grad_state : <nl> + forward_ctxt = _GetWhileContext ( val . op ) <nl> + if _IsLoopExit ( val . op ) : <nl> + forward_ctxt = forward_ctxt . outer_context <nl> + if forward_ctxt = = grad_ctxt . grad_state . forward_context : <nl> + real_val = grad_ctxt . grad_state . GetRealValue ( val ) <nl> + self . _external_values [ val . name ] = real_val <nl> + return real_val <nl> + <nl> if self . _outer_context is not None : <nl> result = self . _outer_context . AddValue ( val ) <nl> # Create an Enter to make ` result ` known to this loop context . <nl> def AddValue ( self , val ) : <nl> return result <nl> <nl> def AddOp ( self , op ) : <nl> - " " " Adds ` op ` to the current context . " " " <nl> + " " " Add ` op ` to the current context . " " " <nl> + # For a reduction op , if op is in a grad context and its input is from <nl> + # its forward context , moving op to the forward context means we would <nl> + # store the tensor after the reduction as opposed to the tensor before <nl> + # reduction , and therefore could significantly reduce memory consumption . <nl> + # For now , we do this only for a few ops . <nl> + if op . type in { " Shape " , " Size " , " Rank " } : <nl> + grad_ctxt = ops . get_default_graph ( ) . _get_control_flow_context ( ) <nl> + if grad_ctxt : <nl> + grad_ctxt = grad_ctxt . GetWhileContext ( ) <nl> + if grad_ctxt . grad_state : <nl> + op_input_forward_ctxt = _GetWhileContext ( op . inputs [ 0 ] . op ) <nl> + if op_input_forward_ctxt = = grad_ctxt . grad_state . forward_context : <nl> + op_input_ctxt = op . inputs [ 0 ] . op . _get_control_flow_context ( ) <nl> + op . _set_control_flow_context ( op_input_ctxt ) <nl> + op_input_ctxt . _AddOpInternal ( op ) <nl> + return <nl> + self . _AddOpInternal ( op ) <nl> + <nl> + def _AddOpInternal ( self , op ) : <nl> + " " " Add ` op ` to the current context . " " " <nl> if not op . inputs : <nl> if not op . control_inputs : <nl> # Add a control edge from the control pivot to this op . <nl> def foldr ( fn , elems , initializer = None , name = None ) : <nl> fn : The function to be performed . <nl> elems : A tensor that is unpacked into a sequence of tensors to apply ` fn ` . <nl> initializer : ( optional ) The initial value for the accumulator . <nl> - use_tensor_array : ( optional ) use tensor_array if true . <nl> name : ( optional ) Name prefix for the returned tensors . <nl> <nl> Returns : <nl> mmm a / tensorflow / python / ops / gradients . py <nl> ppp b / tensorflow / python / ops / gradients . py <nl> def gradients ( ys , <nl> op = queue . popleft ( ) <nl> with _maybe_colocate_with ( op , colocate_gradients_with_ops ) : <nl> if loop_state : <nl> - loop_state . EnterGradWhileContext ( op ) <nl> + loop_state . EnterGradWhileContext ( op , before = True ) <nl> out_grads = _AggregatedGrads ( grads , op , loop_state , aggregation_method ) <nl> - grad_fn = None <nl> + if loop_state : <nl> + loop_state . ExitGradWhileContext ( op , before = True ) <nl> <nl> + grad_fn = None <nl> # pylint : disable = protected - access <nl> is_func_call = ops . get_default_graph ( ) . _is_function ( op . type ) <nl> - # pylint : enable = protected - access <nl> - <nl> if not is_func_call and any ( out_grads ) and op . _id not in stop_ops : <nl> # pylint : enable = protected - access <nl> # A grad_fn must be defined , either as a function or as None <nl> def gradients ( ys , <nl> raise LookupError ( <nl> " No gradient defined for operation ' % s ' ( op type : % s ) " % <nl> ( op . name , op . type ) ) <nl> + <nl> + if loop_state : <nl> + loop_state . EnterGradWhileContext ( op , before = False ) <nl> if ( grad_fn or is_func_call ) and any ( out_grads ) : <nl> # NOTE : If _AggregatedGrads didn ' t compute a value for the i ' th <nl> # output , it means that the cost does not depend on output [ i ] , <nl> def gradients ( ys , <nl> # pylint : disable = protected - access <nl> with ops . get_default_graph ( ) . _original_op ( op ) : <nl> # pylint : enable = protected - access <nl> - wrapped_op = op <nl> - if loop_state : <nl> - wrapped_op = loop_state . MakeWrapper ( op ) <nl> if is_func_call : <nl> # For function call ops , we add a ' SymbolicGradient ' <nl> # node to the graph to compute gradients . <nl> def gradients ( ys , <nl> f_in , f_types , op . type ) ) <nl> # pylint : enable = protected - access <nl> else : <nl> - in_grads = _AsList ( grad_fn ( wrapped_op , * out_grads ) ) <nl> + in_grads = _AsList ( grad_fn ( op , * out_grads ) ) <nl> _VerifyGeneratedGradients ( in_grads , op ) <nl> if gate_gradients and len ( tuple ( filter ( None , in_grads ) ) ) > 1 : <nl> in_grads = control_flow_ops . tuple ( in_grads ) <nl> def gradients ( ys , <nl> if in_grad : <nl> _SetGrad ( grads , t_in , in_grad ) <nl> if loop_state : <nl> - loop_state . ExitGradWhileContext ( op ) <nl> + loop_state . ExitGradWhileContext ( op , before = False ) <nl> <nl> # update pending count for the inputs of op . <nl> # pylint : disable = protected - access <nl> mmm a / tensorflow / python / ops / image_ops . py <nl> ppp b / tensorflow / python / ops / image_ops . py <nl> def resize_images ( images , <nl> new_width_const = tensor_util . constant_value ( new_width ) <nl> new_height_const = tensor_util . constant_value ( new_height ) <nl> <nl> - if width = = new_width_const and height = = new_height_const : <nl> + if new_width_const is not None and new_height_const is not None and ( <nl> + width = = new_width_const and height = = new_height_const ) : <nl> if not is_batch : <nl> images = array_ops . squeeze ( images , squeeze_dims = [ 0 ] ) <nl> return images <nl> mmm a / tensorflow / python / ops / rnn . py <nl> ppp b / tensorflow / python / ops / rnn . py <nl> def _reverse_seq ( input_seq , lengths ) : <nl> # Join into ( time , batch_size , depth ) <nl> s_joined = array_ops . pack ( input_seq ) <nl> <nl> + # TODO ( schuster , ebrevdo ) : Remove cast when reverse_sequence takes int32 <nl> + if lengths is not None : <nl> + lengths = math_ops . to_int64 ( lengths ) <nl> + <nl> # Reverse along dimension 0 <nl> s_reversed = array_ops . reverse_sequence ( s_joined , lengths , 0 , 1 ) <nl> # Split again into list <nl> def bidirectional_rnn ( cell_fw , cell_bw , inputs , <nl> return ( outputs , output_state_fw , output_state_bw ) <nl> <nl> <nl> - def dynamic_rnn ( cell , inputs , sequence_length , initial_state = None , dtype = None , <nl> - parallel_iterations = None , swap_memory = False , time_major = False , <nl> - scope = None ) : <nl> + def dynamic_rnn ( cell , inputs , sequence_length = None , initial_state = None , <nl> + dtype = None , parallel_iterations = None , swap_memory = False , <nl> + time_major = False , scope = None ) : <nl> " " " Creates a recurrent neural network specified by RNNCell " cell " . <nl> <nl> This function is functionally identical to the function ` rnn ` above , but <nl> def dynamic_rnn ( cell , inputs , sequence_length , initial_state = None , dtype = None , <nl> ` [ batch_size , max_time , cell . input_size ] ` . <nl> If time_major = = True , this must be a tensor of shape : <nl> ` [ max_time , batch_size , cell . input_size ] ` . <nl> - sequence_length : An int32 / int64 vector ( tensor ) size [ batch_size ] . <nl> + sequence_length : ( optional ) An int32 / int64 vector sized ` [ batch_size ] ` . <nl> initial_state : ( optional ) An initial state for the RNN . This must be <nl> - a tensor of appropriate type and shape [ batch_size x cell . state_size ] . <nl> + a tensor of appropriate type and shape ` [ batch_size x cell . state_size ] ` . <nl> dtype : ( optional ) The data type for the initial state . Required if <nl> initial_state is not provided . <nl> parallel_iterations : ( Default : 32 ) . The number of iterations to run in <nl> def dynamic_rnn ( cell , inputs , sequence_length , initial_state = None , dtype = None , <nl> inputs = array_ops . transpose ( inputs , [ 1 , 0 , 2 ] ) # ( B , T , D ) = > ( T , B , D ) <nl> <nl> parallel_iterations = parallel_iterations or 32 <nl> - sequence_length = math_ops . to_int32 ( sequence_length ) <nl> - sequence_length = array_ops . identity ( sequence_length , name = " sequence_length " ) <nl> + if sequence_length is not None : <nl> + sequence_length = math_ops . to_int32 ( sequence_length ) <nl> + sequence_length = array_ops . identity ( # Just to find it in the graph . <nl> + sequence_length , name = " sequence_length " ) <nl> <nl> # Create a new scope in which the caching device is either <nl> # determined by the parent scope , or is set to place the cached <nl> def _assert_has_shape ( x , shape ) : <nl> [ " Expected shape for Tensor % s is " % x . name , <nl> packed_shape , " but saw shape : " , x_shape ] ) <nl> <nl> - # Perform some shape validation <nl> - with ops . control_dependencies ( <nl> - [ _assert_has_shape ( sequence_length , [ batch_size ] ) ] ) : <nl> - sequence_length = array_ops . identity ( sequence_length , name = " CheckSeqLen " ) <nl> + if sequence_length is not None : <nl> + # Perform some shape validation <nl> + with ops . control_dependencies ( <nl> + [ _assert_has_shape ( sequence_length , [ batch_size ] ) ] ) : <nl> + sequence_length = array_ops . identity ( <nl> + sequence_length , name = " CheckSeqLen " ) <nl> <nl> ( outputs , final_state ) = _dynamic_rnn_loop ( <nl> - cell , inputs , state , sequence_length , <nl> - parallel_iterations = parallel_iterations , <nl> - swap_memory = swap_memory ) <nl> + cell , inputs , state , parallel_iterations = parallel_iterations , <nl> + swap_memory = swap_memory , sequence_length = sequence_length ) <nl> <nl> # Outputs of _dynamic_rnn_loop are always shaped [ time , batch , depth ] . <nl> # If we are performing batch - major calculations , transpose output back <nl> def _assert_has_shape ( x , shape ) : <nl> return ( outputs , final_state ) <nl> <nl> <nl> - def _dynamic_rnn_loop ( cell , inputs , initial_state , sequence_length , <nl> - parallel_iterations , swap_memory ) : <nl> + def _dynamic_rnn_loop ( <nl> + cell , inputs , initial_state , parallel_iterations , swap_memory , <nl> + sequence_length = None ) : <nl> " " " Internal implementation of Dynamic RNN . <nl> <nl> Args : <nl> cell : An instance of RNNCell . <nl> inputs : A ` Tensor ` of shape [ time , batch_size , depth ] . <nl> initial_state : A ` Tensor ` of shape [ batch_size , depth ] . <nl> - sequence_length : An ` int32 ` ` Tensor ` of shape [ batch_size ] . <nl> parallel_iterations : Positive Python int . <nl> swap_memory : A Python boolean <nl> + sequence_length : ( optional ) An ` int32 ` ` Tensor ` of shape [ batch_size ] . <nl> <nl> Returns : <nl> Tuple ( final_outputs , final_state ) . <nl> def _dynamic_rnn_loop ( cell , inputs , initial_state , sequence_length , <nl> # Prepare dynamic conditional copying of state & output <nl> zero_output = array_ops . zeros ( <nl> array_ops . pack ( [ batch_size , cell . output_size ] ) , inputs . dtype ) <nl> - min_sequence_length = math_ops . reduce_min ( sequence_length ) <nl> - max_sequence_length = math_ops . reduce_max ( sequence_length ) <nl> + if sequence_length is not None : <nl> + min_sequence_length = math_ops . reduce_min ( sequence_length ) <nl> + max_sequence_length = math_ops . reduce_max ( sequence_length ) <nl> <nl> time = array_ops . constant ( 0 , dtype = dtypes . int32 , name = " time " ) <nl> <nl> def _time_step ( time , state , output_ta_t ) : <nl> # Restore some shape information <nl> input_t . set_shape ( [ const_batch_size , const_depth ] ) <nl> <nl> - ( output , new_state ) = _rnn_step ( <nl> - time , sequence_length , min_sequence_length , max_sequence_length , <nl> - zero_output , state , lambda : cell ( input_t , state ) ) <nl> + call_cell = lambda : cell ( input_t , state ) <nl> + <nl> + if sequence_length is not None : <nl> + ( output , new_state ) = _rnn_step ( <nl> + time , sequence_length , min_sequence_length , max_sequence_length , <nl> + zero_output , state , call_cell ) <nl> + else : <nl> + ( output , new_state ) = call_cell ( ) <nl> <nl> output_ta_t = output_ta_t . write ( time , output ) <nl> <nl> mmm a / tensorflow / python / tensorflow . i <nl> ppp b / tensorflow / python / tensorflow . i <nl> limitations under the License . <nl> % include " tensorflow / python / client / events_writer . i " <nl> <nl> % include " tensorflow / python / client / tf_session . i " <nl> + % include " tensorflow / python / client / server_lib . i " <nl> <nl> % include " tensorflow / python / framework / python_op_gen . i " <nl> mmm a / tensorflow / python / training / coordinator . py <nl> ppp b / tensorflow / python / training / coordinator . py <nl> def loop ( coord , timer_interval_secs , target , args = None ) : <nl> looper . start ( ) <nl> return looper <nl> <nl> - # pylint : disable = broad - except <nl> def run ( self ) : <nl> with self . _coord . stop_on_exception ( ) : <nl> self . start_loop ( ) <nl> def run ( self ) : <nl> while not self . _coord . wait_for_stop ( next_timer_time - time . time ( ) ) : <nl> next_timer_time + = self . _timer_interval_secs <nl> self . run_loop ( ) <nl> - # pylint : enable = broad - except <nl> + self . stop_loop ( ) <nl> <nl> def start_loop ( self ) : <nl> " " " Called when the thread starts . " " " <nl> pass <nl> <nl> + def stop_loop ( self ) : <nl> + " " " Called when the thread stops . " " " <nl> + pass <nl> + <nl> def run_loop ( self ) : <nl> " " " Called at ' timer_interval_secs ' boundaries . " " " <nl> if self . _target : <nl> mmm a / tensorflow / tensorboard / components / tf - categorizer / test / categorizerTest . ts <nl> ppp b / tensorflow / tensorboard / components / tf - categorizer / test / categorizerTest . ts <nl> WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> See the License for the specific language governing permissions and <nl> limitations under the License . <nl> = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = * / <nl> - <nl> - / / / < reference path = " . . / categorizer . ts " / > <nl> var assert = chai . assert ; <nl> <nl> module Categorizer { <nl> new file mode 100644 <nl> index 0000000000000 . . fd4a09770805f <nl> mmm / dev / null <nl> ppp b / tensorflow / tensorboard / components / tf - categorizer / test / index . html <nl> <nl> + < ! doctype html > <nl> + < html > <nl> + < head > <nl> + < meta charset = " utf - 8 " > <nl> + < script src = " . . / . . / webcomponentsjs / webcomponents - lite . min . js " > < / script > <nl> + < script src = " . . / . . / web - component - tester / browser . js " > < / script > <nl> + < link rel = " import " href = " . . / . . / tf - imports / d3 . html " > <nl> + < / head > <nl> + < body > <nl> + < script src = " . . / categorizer . js " > < / script > <nl> + < script src = " categorizerTest . js " > < / script > <nl> + < / body > <nl> + < / html > <nl> mmm a / tensorflow / tensorboard / components / tf - dashboard - common / urlGenerator . ts <nl> ppp b / tensorflow / tensorboard / components / tf - dashboard - common / urlGenerator . ts <nl> WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> See the License for the specific language governing permissions and <nl> limitations under the License . <nl> = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = * / <nl> - <nl> - / / / < reference path = " . . / plottable / plottable . d . ts " / > <nl> - <nl> module TF { <nl> export module Urls { <nl> export type RunTagUrlFn = ( tag : string , run : string ) = > string ; <nl> module TF { <nl> } ; <nl> } ; <nl> <nl> - export function demoRouter ( dataDir : string ) : Router { <nl> + export function demoRouter ( dataDir : string , <nl> + oldVersion = false ) : Router { <nl> + if ( oldVersion ) { <nl> + return { <nl> + runs : ( ) = > dataDir + " runs . json " , <nl> + graph : ( run ) = > dataDir + run + " - graph . pbtxt " , <nl> + scalars : ( tag , run ) = > { <nl> + return dataDir + run . split ( " _ " ) [ 0 ] + " . json " ; <nl> + } , <nl> + histograms : ( ) = > null , <nl> + compressedHistograms : ( ) = > null , <nl> + images : ( ) = > null , <nl> + individualImage : ( ) = > null <nl> + } ; <nl> + } <nl> / * Retrieves static . json data generated by demo_from_server . py * / <nl> function demoRoute ( route ) { <nl> return function ( tag , run ) { <nl> mmm a / tensorflow / tensorboard / components / tf - event - dashboard / dataCoordinator . ts <nl> ppp b / tensorflow / tensorboard / components / tf - event - dashboard / dataCoordinator . ts <nl> WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> See the License for the specific language governing permissions and <nl> limitations under the License . <nl> = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = * / <nl> - <nl> - / / / < reference path = " . . / plottable / plottable . d . ts " / > <nl> - <nl> module TF { <nl> <nl> / * The DataCoordinator generates TF . Datasets for each run / tag combination , <nl> mmm a / tensorflow / tensorboard / components / tf - event - dashboard / dataset . ts <nl> ppp b / tensorflow / tensorboard / components / tf - event - dashboard / dataset . ts <nl> WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> See the License for the specific language governing permissions and <nl> limitations under the License . <nl> = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = * / <nl> - <nl> - / / / < reference path = " . . / plottable / plottable . d . ts " / > <nl> - <nl> module TF { <nl> / * An extension of Plottable . Dataset that knows how to load data from a backend . <nl> * / <nl> mmm a / tensorflow / tensorboard / components / tf - event - dashboard / tf - chart . ts <nl> ppp b / tensorflow / tensorboard / components / tf - event - dashboard / tf - chart . ts <nl> WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> See the License for the specific language governing permissions and <nl> limitations under the License . <nl> = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = * / <nl> - <nl> - / / / < reference path = " . . / plottable / plottable . d . ts " / > <nl> - <nl> module TF { <nl> type TFDatum = [ number , number , number ] ; <nl> type tooltipMap = { [ run : string ] : string } ; <nl> mmm a / tensorflow / tensorboard / components / tf - graph - common / lib / graph . ts <nl> ppp b / tensorflow / tensorboard / components / tf - graph - common / lib / graph . ts <nl> WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> See the License for the specific language governing permissions and <nl> limitations under the License . <nl> = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = * / <nl> - <nl> - / / / < reference path = " common . ts " / > <nl> module tf . graph { <nl> <nl> / * * Delimiter used in node names to denote namespaces . * / <nl> mmm a / tensorflow / tensorboard / components / tf - graph - common / lib / hierarchy . ts <nl> ppp b / tensorflow / tensorboard / components / tf - graph - common / lib / hierarchy . ts <nl> WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> See the License for the specific language governing permissions and <nl> limitations under the License . <nl> = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = * / <nl> - <nl> - / / / < reference path = " graph . ts " / > <nl> - / / / < reference path = " template . ts " / > <nl> - <nl> / * * <nl> * Package for the Graph Hierarchy for TensorFlow graph . <nl> * / <nl> mmm a / tensorflow / tensorboard / components / tf - graph - common / lib / layout . ts <nl> ppp b / tensorflow / tensorboard / components / tf - graph - common / lib / layout . ts <nl> WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> See the License for the specific language governing permissions and <nl> limitations under the License . <nl> = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = * / <nl> - <nl> - / / / < reference path = " graph . ts " / > <nl> - / / / < reference path = " render . ts " / > <nl> - <nl> module tf . graph . layout { <nl> <nl> / * * Set of parameters that define the look and feel of the graph . * / <nl> mmm a / tensorflow / tensorboard / components / tf - graph - common / lib / parser . ts <nl> ppp b / tensorflow / tensorboard / components / tf - graph - common / lib / parser . ts <nl> WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> See the License for the specific language governing permissions and <nl> limitations under the License . <nl> = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = * / <nl> - <nl> - / / / < reference path = " common . ts " / > <nl> module tf . graph . parser { <nl> <nl> / * * <nl> mmm a / tensorflow / tensorboard / components / tf - graph - common / lib / render . ts <nl> ppp b / tensorflow / tensorboard / components / tf - graph - common / lib / render . ts <nl> WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> See the License for the specific language governing permissions and <nl> limitations under the License . <nl> = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = * / <nl> - <nl> - / / / < reference path = " graph . ts " / > <nl> - / / / < reference path = " hierarchy . ts " / > <nl> - <nl> / * * <nl> * Package for the Render Hierarchy for TensorFlow graph . <nl> * / <nl> - <nl> module tf . graph . render { <nl> <nl> export type Point = { x : number , y : number } ; <nl> mmm a / tensorflow / tensorboard / components / tf - graph - common / lib / scene / annotation . ts <nl> ppp b / tensorflow / tensorboard / components / tf - graph - common / lib / scene / annotation . ts <nl> WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> See the License for the specific language governing permissions and <nl> limitations under the License . <nl> = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = * / <nl> - <nl> - / / / < reference path = " . . / graph . ts " / > <nl> - / / / < reference path = " . . / render . ts " / > <nl> - / / / < reference path = " scene . ts " / > <nl> - / / / < reference path = " edge . ts " / > <nl> - / / / < reference path = " contextmenu . ts " / > <nl> - <nl> module tf . graph . scene . annotation { <nl> <nl> / * * <nl> mmm a / tensorflow / tensorboard / components / tf - graph - common / lib / scene / edge . ts <nl> ppp b / tensorflow / tensorboard / components / tf - graph - common / lib / scene / edge . ts <nl> WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> See the License for the specific language governing permissions and <nl> limitations under the License . <nl> = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = * / <nl> - <nl> - / / / < reference path = " . . / graph . ts " / > <nl> - / / / < reference path = " . . / render . ts " / > <nl> - / / / < reference path = " scene . ts " / > <nl> - <nl> module tf . graph . scene . edge { <nl> <nl> / * * Delimiter between dimensions when showing sizes of tensors . * / <nl> mmm a / tensorflow / tensorboard / components / tf - graph - common / lib / scene / minimap . ts <nl> ppp b / tensorflow / tensorboard / components / tf - graph - common / lib / scene / minimap . ts <nl> WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> See the License for the specific language governing permissions and <nl> limitations under the License . <nl> = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = * / <nl> - <nl> - / / / < reference path = " . . / common . ts " / > <nl> - <nl> module tf . scene { <nl> <nl> / * * Show minimap when the viewpoint area is less than X % of the whole area . * / <nl> mmm a / tensorflow / tensorboard / components / tf - graph - common / lib / scene / node . ts <nl> ppp b / tensorflow / tensorboard / components / tf - graph - common / lib / scene / node . ts <nl> WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> See the License for the specific language governing permissions and <nl> limitations under the License . <nl> = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = * / <nl> - <nl> - / / / < reference path = " . . / graph . ts " / > <nl> - / / / < reference path = " scene . ts " / > <nl> - / / / < reference path = " annotation . ts " / > <nl> - / / / < reference path = " contextmenu . ts " / > <nl> - <nl> module tf . graph . scene . node { <nl> <nl> / * * <nl> mmm a / tensorflow / tensorboard / components / tf - graph - common / lib / scene / scene . ts <nl> ppp b / tensorflow / tensorboard / components / tf - graph - common / lib / scene / scene . ts <nl> WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> See the License for the specific language governing permissions and <nl> limitations under the License . <nl> = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = * / <nl> - <nl> - / / / < reference path = " . . / graph . ts " / > <nl> - / / / < reference path = " edge . ts " / > <nl> - / / / < reference path = " node . ts " / > <nl> - / / / < reference path = " . . / layout . ts " / > <nl> - <nl> module tf . graph . scene { <nl> <nl> / * * Enums element class of objects in the scene * / <nl> mmm a / tensorflow / tensorboard / components / tf - graph - common / lib / template . ts <nl> ppp b / tensorflow / tensorboard / components / tf - graph - common / lib / template . ts <nl> WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> See the License for the specific language governing permissions and <nl> limitations under the License . <nl> = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = * / <nl> - <nl> - / / / < reference path = " graph . ts " / > <nl> - / / / < reference path = " hierarchy . ts " / > <nl> - <nl> module tf . graph . template { <nl> <nl> / * * <nl> mmm a / tensorflow / tensorboard / components / tf - tensorboard / demo / index . html <nl> ppp b / tensorflow / tensorboard / components / tf - tensorboard / demo / index . html <nl> <nl> < ! DOCTYPE html > <nl> < html > <nl> - < head > <nl> - < script src = " . . / . . / webcomponentsjs / webcomponents - lite . min . js " > < / script > <nl> - < link rel = " import " href = " . . / tf - tensorboard . html " > <nl> + < head > <nl> + < script src = " . . / . . / webcomponentsjs / webcomponents - lite . min . js " > < / script > <nl> + < link rel = " import " href = " . . / tf - tensorboard - demo . html " > <nl> < link rel = " stylesheet " type = " text / css " href = " . . / . . / . . / lib / css / global . css " > <nl> - < title > TensorBoard Demo < / title > <nl> - < / head > <nl> - < body > <nl> - < base href = " / " > <nl> - < dom - module id = " x - demo " > <nl> - < template > <nl> - < tf - tensorboard <nl> - id = " demo " <nl> - router = " [ [ demoRouter ] ] " > <nl> - < / tf - tensorboard > <nl> - < / template > <nl> - < script > <nl> - var dataDir = " components / tf - tensorboard / demo / data / " ; <nl> - var demoRouter = { <nl> - runs : function ( ) { return dataDir + " runs . json " ; } , <nl> - graph : function ( run ) { return dataDir + run + " - graph . pbtxt " ; } , <nl> - scalars : function ( tag , run ) { <nl> - return dataDir + run . split ( " _ " ) [ 0 ] + " . json " ; <nl> - } , <nl> - } ; <nl> - Polymer ( { <nl> - is : " x - demo " , <nl> - properties : { <nl> - demoRouter : { <nl> - type : Object , <nl> - value : demoRouter , <nl> - } , <nl> - } , <nl> - } ) ; <nl> - < / script > <nl> - < / dom - module > <nl> - < x - demo > < / x - demo > <nl> - < / body > <nl> + < / head > <nl> + < body > <nl> + < tf - tensorboard - demo old - version = " true " data - dir = " data / " > < / tf - tensorboard - demo > <nl> + < / body > <nl> < / html > <nl> mmm a / tensorflow / tensorboard / components / tf - tensorboard / tf - tensorboard - demo . html <nl> ppp b / tensorflow / tensorboard / components / tf - tensorboard / tf - tensorboard - demo . html <nl> <nl> < tf - tensorboard <nl> id = " tensorboard " <nl> router = " [ [ _demoRouter ] ] " <nl> + no - hash = " [ [ noHash ] ] " <nl> > < / tf - tensorboard > <nl> < style > <nl> : host { <nl> <nl> properties : { <nl> _demoRouter : { <nl> type : Object , <nl> - computed : " _makeDemoRouter ( dataDir ) " , <nl> + computed : " _makeDemoRouter ( dataDir , oldVersion ) " , <nl> } , <nl> dataDir : { <nl> type : String , <nl> value : " data " , <nl> } , <nl> + / / To use the old version of the router which can serve the <nl> + / / demo / data folder that is checked into the repository . <nl> + oldVersion : { <nl> + type : Boolean , <nl> + value : false <nl> + } , <nl> + / / If true , tab switching in TensorBoard will not update <nl> + / / location hash . Hash update interferes with selenium tests . <nl> + noHash : { <nl> + type : Boolean , <nl> + value : false <nl> + } <nl> } , <nl> - _makeDemoRouter : function ( dataDir ) { <nl> - return TF . Urls . demoRouter ( dataDir ) ; <nl> + _makeDemoRouter : function ( dataDir , oldVersion ) { <nl> + return TF . Urls . demoRouter ( dataDir , oldVersion ) ; <nl> } , <nl> } ) ; <nl> < / script > <nl> mmm a / tensorflow / tensorboard / components / tf - tensorboard / tf - tensorboard . html <nl> ppp b / tensorflow / tensorboard / components / tf - tensorboard / tf - tensorboard . html <nl> <nl> < paper - toolbar id = " toolbar " > <nl> < div id = " toolbar - content " > <nl> < div class = " toolbar - title " > TensorBoard < / div > <nl> - < paper - tabs selected = " 0 " noink class = " tabs " id = " tabs " > <nl> - < paper - tab data - mode = " events " on - click = " changeMode " > Events < / paper - tab > <nl> - < paper - tab data - mode = " images " on - click = " changeMode " > Images < / paper - tab > <nl> - < paper - tab data - mode = " graphs " on - click = " changeMode " > Graph < / paper - tab > <nl> - < paper - tab data - mode = " histograms " on - click = " changeMode " > Histograms < / paper - tab > <nl> + < paper - tabs selected = " { { modeIndex } } " noink class = " tabs " id = " tabs " > <nl> + < paper - tab data - mode = " events " > Events < / paper - tab > <nl> + < paper - tab data - mode = " images " > Images < / paper - tab > <nl> + < paper - tab data - mode = " graphs " > Graph < / paper - tab > <nl> + < paper - tab data - mode = " histograms " > Histograms < / paper - tab > <nl> < / paper - tabs > <nl> < / div > <nl> < / paper - toolbar > <nl> <nl> type : Object , <nl> value : TF . Urls . productionRouter ( ) , <nl> } , <nl> + / / Which tab is selected ( events , graph , images etc ) . <nl> mode : { <nl> type : String , <nl> - value : " events " , <nl> + computed : ' _getModeFromIndex ( modeIndex ) ' <nl> } , <nl> + / / If true , tab switching in TensorBoard will not update <nl> + / / location hash . Hash update interferes with selenium tests . <nl> + noHash : { <nl> + type : Boolean , <nl> + value : false <nl> + } <nl> } , <nl> - changeMode : function ( ev ) { <nl> - var mode = ev . target . parentElement . getAttribute ( ' data - mode ' ) ; <nl> - this . _changeMode ( mode , true ) ; <nl> + _getModeFromIndex : function ( modeIndex ) { <nl> + var mode = this . tabs [ modeIndex ] ; <nl> + if ( ! this . noHash ) { <nl> + window . location . hash = mode ; <nl> + } <nl> + return mode ; <nl> } , <nl> eventDashboard : function ( mode ) { <nl> return mode = = = " events " ; <nl> <nl> histogramDashboard : function ( mode ) { <nl> return mode = = = " histograms " ; <nl> } , <nl> - loadPreviousMode : function ( ) { <nl> - this . _changeMode ( this . _getMode ( ) , false ) ; <nl> - } , <nl> ready : function ( ) { <nl> - this . _changeMode ( this . _getMode ( ) , true ) ; <nl> - <nl> - var self = this ; <nl> - window . addEventListener ( ' hashchange ' , function ( ) { <nl> - self . loadPreviousMode ( ) ; <nl> + this . tabs = [ ] . slice . call ( this . querySelectorAll ( ' paper - tab ' ) ) . map ( function ( a ) { <nl> + return a . dataset . mode ; <nl> } ) ; <nl> + this . _getModeFromHash ( ) ; <nl> + window . addEventListener ( ' hashchange ' , function ( ) { <nl> + this . _getModeFromHash ( ) ; <nl> + } . bind ( this ) ) ; <nl> } , <nl> - _changeMode : function ( mode , isNewState ) { <nl> - this . mode = mode ; <nl> - <nl> - / / Change the selected tab <nl> - this . $ . tabs . selected = this . _tabs ( ) . indexOf ( mode ) ; <nl> - <nl> - if ( isNewState ) { <nl> - window . location . hash = mode ; <nl> - } <nl> - } , <nl> - _getMode : function ( ) { <nl> + _getModeFromHash : function ( ) { <nl> / / Return the mode as it is stored in the hash . <nl> - / / If no mode can be found , default to the first tab . <nl> - var hash = window . location . hash ; <nl> - return hash . length > 0 ? hash . slice ( 1 , hash . length ) : this . _tabs ( ) [ 0 ] ; <nl> - } , <nl> - _tabs : function ( ) { <nl> - var elts = Array . prototype . slice . call ( this . querySelectorAll ( ' paper - tab ' ) ) ; <nl> - return elts . map ( function ( elt ) { return elt . getAttribute ( ' data - mode ' ) } ) ; <nl> + var tabName = window . location . hash . trim ( ) . slice ( 1 ) ; <nl> + var modeIndex = this . tabs . indexOf ( tabName ) ; <nl> + if ( modeIndex = = - 1 & & this . modeIndex = = null ) { <nl> + / / Selecting the first tab as default . <nl> + this . set ( ' modeIndex ' , 0 ) ; <nl> + } <nl> + if ( modeIndex ! = - 1 & & modeIndex ! = this . modeIndex ) { <nl> + this . set ( ' modeIndex ' , modeIndex ) ; <nl> + } <nl> } , <nl> } ) ; <nl> < / script > <nl> deleted file mode 100644 <nl> index d551750e3c450 . . 0000000000000 <nl> mmm a / tensorflow / tensorboard / components / tf - test / index . html <nl> ppp / dev / null <nl> <nl> - < ! doctype html > <nl> - < html > <nl> - < head > <nl> - < meta charset = " utf - 8 " > <nl> - < script src = " . . / web - component - tester / browser . js " > < / script > <nl> - < / head > <nl> - < body > <nl> - < script > <nl> - / / Run the tests for each main component in tensorboard . <nl> - WCT . loadSuites ( [ <nl> - ' . . / tf - graph - common / test / index . html ' , <nl> - ' . . / tf - graph - loader / test / index . html ' , <nl> - ] ) ; <nl> - < / script > <nl> - < / body > <nl> - < / html > <nl> mmm a / tensorflow / tensorboard / gulpfile . js <nl> ppp b / tensorflow / tensorboard / gulpfile . js <nl> gulp . task ( ' compile . all ' , [ ' typings ' ] , function ( ) { <nl> } ) ; <nl> <nl> gulp . task ( ' test ' , [ ' tslint - strict ' , ' compile . all ' ] , function ( done ) { <nl> - tester ( { suites : [ ' components / tf - test / ' ] , <nl> - plugins : { local : { } , sauce : false } } , function ( error ) { <nl> + tester ( { } , function ( error ) { <nl> if ( error ) { <nl> / / Pretty error for gulp . <nl> error = new Error ( error . message | | error ) ; <nl> mmm a / tensorflow / tensorboard / lib / js / backend / test / index . html <nl> ppp b / tensorflow / tensorboard / lib / js / backend / test / index . html <nl> <nl> = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = - - > <nl> < ! doctype html > <nl> < html > <nl> - < ! - - This test file has import paths that are suitable for gulp test and <nl> - direct loading in the browser - - > <nl> < head > <nl> < meta charset = " utf - 8 " > <nl> - < script src = " . . / . . / . . / . . / . . / components / webcomponentsjs / webcomponents - lite . min . js " > < / script > <nl> - < script src = " . . / . . / . . / . . / components / web - component - tester / browser . js " > < / script > <nl> - <nl> + < script src = " . . / . . / web - component - tester / browser . js " > < / script > <nl> < / head > <nl> < body > <nl> < script src = " . . / . . / requestManager / requestManager . js " > < / script > <nl> mmm a / tensorflow / tensorboard / lib / js / nanite / test / index . html <nl> ppp b / tensorflow / tensorboard / lib / js / nanite / test / index . html <nl> <nl> < ! doctype html > <nl> < html > <nl> - < ! - - This test file has import paths that are suitable for gulp test and <nl> - direct loading in the browser - - > <nl> < head > <nl> < meta charset = " utf - 8 " > <nl> - < script src = " . . / . . / . . / . . / . . / components / webcomponentsjs / webcomponents - lite . min . js " > < / script > <nl> - < script src = " . . / . . / . . / . . / components / web - component - tester / browser . js " > < / script > <nl> - < link rel = " import " href = " . . / . . / . . / . . / . . / components / polymer / polymer . html " > <nl> - <nl> + < script src = " . . / . . / webcomponentsjs / webcomponents - lite . min . js " > < / script > <nl> + < script src = " . . / . . / web - component - tester / browser . js " > < / script > <nl> + < link rel = " import " href = " . . / . . / polymer / polymer . html " > <nl> < / head > <nl> < body > <nl> < script src = " . . / nanite . js " > < / script > <nl> mmm a / tensorflow / tensorboard / lib / js / nanite / test / naniteTest . ts <nl> ppp b / tensorflow / tensorboard / lib / js / nanite / test / naniteTest . ts <nl> limitations under the License . <nl> = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = * / <nl> var assert = chai . assert ; <nl> declare function fixture ( id : string ) : void ; <nl> - declare module HTMLImports { <nl> - export function whenReady ( f : Function ) : void ; <nl> - } <nl> + <nl> module TF . Nanite { <nl> - HTMLImports . whenReady ( function ( ) { <nl> + window . HTMLImports . whenReady ( function ( ) { <nl> Polymer ( { <nl> is : " test - element " , <nl> properties : { <nl> mmm a / tensorflow / tensorboard / lib / js / node - radar / test / index . html <nl> ppp b / tensorflow / tensorboard / lib / js / node - radar / test / index . html <nl> <nl> - <nl> < ! doctype html > <nl> < html > <nl> - < ! - - This test file has import paths that are suitable for gulp test and <nl> - direct loading in the browser - - > <nl> < head > <nl> < meta charset = " utf - 8 " > <nl> - < script src = " . . / . . / . . / . . / . . / components / webcomponentsjs / webcomponents - lite . min . js " > < / script > <nl> - < script src = " . . / . . / . . / . . / components / web - component - tester / browser . js " > < / script > <nl> + < script src = " . . / . . / web - component - tester / browser . js " > < / script > <nl> < / head > <nl> < body > <nl> < script src = " . . / nodeRadar . js " > < / script > <nl> mmm a / tensorflow / tensorboard / lib / js / requestManager / test / index . html <nl> ppp b / tensorflow / tensorboard / lib / js / requestManager / test / index . html <nl> <nl> < html > <nl> < head > <nl> < meta charset = " utf - 8 " > <nl> - < script src = " . . / . . / . . / . . / . . / components / webcomponentsjs / webcomponents - lite . min . js " > < / script > <nl> - < script src = " . . / . . / . . / . . / components / web - component - tester / browser . js " > < / script > <nl> + < script src = " . . / . . / web - component - tester / browser . js " > < / script > <nl> < / head > <nl> < body > <nl> < script src = " . . / requestManager . js " > < / script > <nl> mmm a / tensorflow / tensorboard / package . json <nl> ppp b / tensorflow / tensorboard / package . json <nl> <nl> " tslint " : " ^ 3 . 2 . 1 " , <nl> " typescript " : " 1 . 8 . 0 " , <nl> " vulcanize " : " ^ 1 . 14 . 0 " , <nl> - " web - component - tester " : " ~ 3 . 4 . 2 " , <nl> + " web - component - tester " : " 4 . 2 . 2 " , <nl> " gulp - header " : " ~ 1 . 7 . 1 " , <nl> " gulp - rename " : " ~ 1 . 2 . 2 " , <nl> " gulp - typings " : " ~ 1 . 1 . 0 " , <nl> new file mode 100644 <nl> index 0000000000000 . . 0a5c6c20b66bd <nl> mmm / dev / null <nl> ppp b / tensorflow / tensorboard / wct . conf . json <nl> <nl> + { <nl> + " suites " : [ <nl> + " components / tf - * / test " , <nl> + " lib / js / * / test " <nl> + ] , <nl> + " plugins " : [ " local " ] , <nl> + " webserver " : { <nl> + " pathMappings " : [ <nl> + { " / components / < basename > / lib / js " : " components " } <nl> + ] <nl> + } <nl> + } <nl> \ No newline at end of file <nl> mmm a / tensorflow / tools / docker / notebooks / 3_mnist_from_scratch . ipynb <nl> ppp b / tensorflow / tools / docker / notebooks / 3_mnist_from_scratch . ipynb <nl> <nl> " batch_labels = train_labels [ : BATCH_SIZE ] \ n " , <nl> " \ n " , <nl> " # This dictionary maps the batch data ( as a numpy array ) to the \ n " , <nl> - " # node in the graph is should be fed to . \ n " , <nl> + " # node in the graph it should be fed to . \ n " , <nl> " feed_dict = { train_data_node : batch_data , \ n " , <nl> " train_labels_node : batch_labels } \ n " , <nl> " \ n " , <nl> <nl> " batch_data = train_data [ offset : ( offset + BATCH_SIZE ) , : , : , : ] \ n " , <nl> " batch_labels = train_labels [ offset : ( offset + BATCH_SIZE ) ] \ n " , <nl> " # This dictionary maps the batch data ( as a numpy array ) to the \ n " , <nl> - " # node in the graph is should be fed to . \ n " , <nl> + " # node in the graph it should be fed to . \ n " , <nl> " feed_dict = { train_data_node : batch_data , \ n " , <nl> " train_labels_node : batch_labels } \ n " , <nl> " # Run the graph and fetch some of the nodes . \ n " , <nl> mmm a / tensorflow / workspace . bzl <nl> ppp b / tensorflow / workspace . bzl <nl> def tf_workspace ( path_prefix = " " ) : <nl> <nl> native . new_http_archive ( <nl> name = " eigen_archive " , <nl> - url = " https : / / bitbucket . org / eigen / eigen / get / f1ce2528ee99 . tar . gz " , <nl> - sha256 = " 2c4ce322d13a613bbc53de3381760cf56f1c9b03c409233b764a6434ee1db909 " , <nl> + url = " https : / / bitbucket . org / eigen / eigen / get / 88444e025a5c . tar . gz " , <nl> + sha256 = " 42e6f6de56b3ff010531a2bbf3e2db1db46be30d3965efb1eaa5634c5db013dd " , <nl> build_file = path_prefix + " eigen . BUILD " , <nl> ) <nl> <nl> mmm a / third_party / eigen3 / Eigen / Cholesky <nl> ppp b / third_party / eigen3 / Eigen / Cholesky <nl> @ @ - 1 + 1 @ @ <nl> - # include " eigen - eigen - f1ce2528ee99 / Eigen / Cholesky " <nl> + # include " eigen - eigen - 88444e025a5c / Eigen / Cholesky " <nl> mmm a / third_party / eigen3 / Eigen / Core <nl> ppp b / third_party / eigen3 / Eigen / Core <nl> @ @ - 1 + 1 @ @ <nl> - # include " eigen - eigen - f1ce2528ee99 / Eigen / Core " <nl> + # include " eigen - eigen - 88444e025a5c / Eigen / Core " <nl> mmm a / third_party / eigen3 / Eigen / Eigenvalues <nl> ppp b / third_party / eigen3 / Eigen / Eigenvalues <nl> @ @ - 1 + 1 @ @ <nl> - # include " eigen - eigen - f1ce2528ee99 / Eigen / Eigenvalues " <nl> + # include " eigen - eigen - 88444e025a5c / Eigen / Eigenvalues " <nl> mmm a / third_party / eigen3 / Eigen / LU <nl> ppp b / third_party / eigen3 / Eigen / LU <nl> @ @ - 1 + 1 @ @ <nl> - # include " eigen - eigen - f1ce2528ee99 / Eigen / LU " <nl> + # include " eigen - eigen - 88444e025a5c / Eigen / LU " <nl> mmm a / third_party / eigen3 / Eigen / QR <nl> ppp b / third_party / eigen3 / Eigen / QR <nl> @ @ - 1 + 1 @ @ <nl> - # include " eigen - eigen - f1ce2528ee99 / Eigen / QR " <nl> + # include " eigen - eigen - 88444e025a5c / Eigen / QR " <nl> mmm a / third_party / eigen3 / unsupported / Eigen / CXX11 / Tensor <nl> ppp b / third_party / eigen3 / unsupported / Eigen / CXX11 / Tensor <nl> @ @ - 1 + 1 @ @ <nl> - # include " eigen - eigen - f1ce2528ee99 / unsupported / Eigen / CXX11 / Tensor " <nl> + # include " eigen - eigen - 88444e025a5c / unsupported / Eigen / CXX11 / Tensor " <nl> mmm a / tools / bazel . rc . template <nl> ppp b / tools / bazel . rc . template <nl> build : cuda - - define = using_cuda = true <nl> <nl> build - - force_python = py $ PYTHON_MAJOR_VERSION <nl> build - - python $ PYTHON_MAJOR_VERSION_path = $ PYTHON_BINARY <nl> - build - - define = use_fast_cpp_protos = true <nl> - build - - define = allow_oversize_protos = true <nl> <nl> build - - spawn_strategy = standalone <nl> test - - spawn_strategy = standalone <nl>
|
Merge commit for internal changes
|
tensorflow/tensorflow
|
7022c01ac7282eed90db6b2c52195819264bc146
|
2016-03-09T01:54:13Z
|
mmm a / tests / runner . py <nl> ppp b / tests / runner . py <nl> def test_chunked_synchronous_xhr ( self ) : <nl> <nl> def chunked_server ( support_byte_ranges ) : <nl> class ChunkedServerHandler ( BaseHTTPServer . BaseHTTPRequestHandler ) : <nl> - @ staticmethod <nl> def sendheaders ( s , extra = [ ] , length = len ( data ) ) : <nl> s . send_response ( 200 ) <nl> s . send_header ( " Content - Length " , str ( length ) ) <nl> def sendheaders ( s , extra = [ ] , length = len ( data ) ) : <nl> s . end_headers ( ) <nl> <nl> def do_HEAD ( s ) : <nl> - ChunkedServerHandler . sendheaders ( s ) <nl> - <nl> + s . sendheaders ( ) <nl> + <nl> + def do_OPTIONS ( s ) : <nl> + s . sendheaders ( [ ( " Access - Control - Allow - Headers " , " Range " ) ] , 0 ) <nl> + <nl> def do_GET ( s ) : <nl> if not support_byte_ranges : <nl> - ChunkedServerHandler . sendheaders ( s ) <nl> + s . sendheaders ( ) <nl> s . wfile . write ( data ) <nl> else : <nl> ( start , end ) = s . headers . get ( " range " ) . split ( " = " ) [ 1 ] . split ( " - " ) <nl> def do_GET ( s ) : <nl> end = int ( end ) <nl> end = min ( len ( data ) - 1 , end ) <nl> length = end - start + 1 <nl> - ChunkedServerHandler . sendheaders ( s , [ ] , length ) <nl> + s . sendheaders ( [ ] , length ) <nl> s . wfile . write ( data [ start : end + 1 ] ) <nl> s . wfile . close ( ) <nl> httpd = BaseHTTPServer . HTTPServer ( ( ' localhost ' , 11111 ) , ChunkedServerHandler ) <nl>
|
add OPTIONS verb so that CORS works in Chrome . also use OOP
|
emscripten-core/emscripten
|
0aaf540cae8d36844b0aa683ab84fdc50ce3ceab
|
2013-02-24T21:26:23Z
|
old mode 100644 <nl> new mode 100755 <nl> old mode 100644 <nl> new mode 100755 <nl> old mode 100755 <nl> new mode 100644 <nl> old mode 100755 <nl> new mode 100644 <nl> old mode 100755 <nl> new mode 100644 <nl> old mode 100755 <nl> new mode 100644 <nl> old mode 100755 <nl> new mode 100644 <nl> old mode 100755 <nl> new mode 100644 <nl> old mode 100755 <nl> new mode 100644 <nl> old mode 100755 <nl> new mode 100644 <nl>
|
Tweak permissions
|
MarlinFirmware/Marlin
|
a89f4703df1eab36de5acafea0085d10263394a0
|
2019-11-06T22:10:14Z
|
mmm a / xbmc / utils / GroupUtils . cpp <nl> ppp b / xbmc / utils / GroupUtils . cpp <nl> <nl> # include " FileItem . h " <nl> # include " utils / StringUtils . h " <nl> # include " utils / Variant . h " <nl> + # include " video / VideoDbUrl . h " <nl> # include " video / VideoInfoTag . h " <nl> # include " utils / URIUtils . h " <nl> # include " filesystem / MultiPathDirectory . h " <nl> using namespace std ; <nl> <nl> typedef map < int , set < CFileItemPtr > > SetMap ; <nl> <nl> - bool GroupUtils : : Group ( GroupBy groupBy , const CFileItemList & items , CFileItemList & groupedItems , GroupAttribute groupAttributes / * = GroupAttributeNone * / ) <nl> + bool GroupUtils : : Group ( GroupBy groupBy , const std : : string & baseDir , const CFileItemList & items , CFileItemList & groupedItems , GroupAttribute groupAttributes / * = GroupAttributeNone * / ) <nl> { <nl> if ( items . Size ( ) < = 0 | | groupBy = = GroupByNone ) <nl> return false ; <nl> bool GroupUtils : : Group ( GroupBy groupBy , const CFileItemList & items , CFileItemLis <nl> <nl> if ( ( groupBy & GroupBySet ) & & setMap . size ( ) > 0 ) <nl> { <nl> + CVideoDbUrl itemsUrl ; <nl> + if ( ! itemsUrl . FromString ( baseDir ) ) <nl> + return false ; <nl> + <nl> for ( SetMap : : const_iterator set = setMap . begin ( ) ; set ! = setMap . end ( ) ; set + + ) <nl> { <nl> / / only one item in the set , so just re - add it <nl> bool GroupUtils : : Group ( GroupBy groupBy , const CFileItemList & items , CFileItemLis <nl> CFileItemPtr pItem ( new CFileItem ( ( * set - > second . begin ( ) ) - > GetVideoInfoTag ( ) - > m_strSet ) ) ; <nl> pItem - > GetVideoInfoTag ( ) - > m_iDbId = set - > first ; <nl> pItem - > GetVideoInfoTag ( ) - > m_type = " set " ; <nl> - pItem - > SetPath ( StringUtils : : Format ( " videodb : / / 1 / 7 / % ld / " , set - > first ) ) ; <nl> + <nl> + std : : string basePath = StringUtils : : Format ( " videodb : / / 1 / 7 / % ld / " , set - > first ) ; <nl> + CVideoDbUrl videoUrl ; <nl> + if ( ! videoUrl . FromString ( basePath ) ) <nl> + pItem - > SetPath ( basePath ) ; <nl> + else <nl> + { <nl> + videoUrl . AddOptions ( itemsUrl . GetOptionsString ( ) ) ; <nl> + pItem - > SetPath ( videoUrl . ToString ( ) ) ; <nl> + } <nl> pItem - > m_bIsFolder = true ; <nl> <nl> CVideoInfoTag * setInfo = pItem - > GetVideoInfoTag ( ) ; <nl> bool GroupUtils : : Group ( GroupBy groupBy , const CFileItemList & items , CFileItemLis <nl> return true ; <nl> } <nl> <nl> - bool GroupUtils : : GroupAndSort ( GroupBy groupBy , const CFileItemList & items , const SortDescription & sortDescription , CFileItemList & groupedItems , GroupAttribute groupAttributes / * = GroupAttributeNone * / ) <nl> + bool GroupUtils : : GroupAndSort ( GroupBy groupBy , const std : : string & baseDir , const CFileItemList & items , const SortDescription & sortDescription , CFileItemList & groupedItems , GroupAttribute groupAttributes / * = GroupAttributeNone * / ) <nl> { <nl> - if ( ! Group ( groupBy , items , groupedItems , groupAttributes ) ) <nl> + if ( ! Group ( groupBy , baseDir , items , groupedItems , groupAttributes ) ) <nl> return false ; <nl> <nl> groupedItems . Sort ( sortDescription ) ; <nl> mmm a / xbmc / utils / GroupUtils . h <nl> ppp b / xbmc / utils / GroupUtils . h <nl> typedef enum { <nl> class GroupUtils <nl> { <nl> public : <nl> - static bool Group ( GroupBy groupBy , const CFileItemList & items , CFileItemList & groupedItems , GroupAttribute groupAttributes = GroupAttributeNone ) ; <nl> - static bool GroupAndSort ( GroupBy groupBy , const CFileItemList & items , const SortDescription & sortDescription , CFileItemList & groupedItems , GroupAttribute groupAttributes = GroupAttributeNone ) ; <nl> + static bool Group ( GroupBy groupBy , const std : : string & baseDir , const CFileItemList & items , CFileItemList & groupedItems , GroupAttribute groupAttributes = GroupAttributeNone ) ; <nl> + static bool GroupAndSort ( GroupBy groupBy , const std : : string & baseDir , const CFileItemList & items , const SortDescription & sortDescription , CFileItemList & groupedItems , GroupAttribute groupAttributes = GroupAttributeNone ) ; <nl> } ; <nl> mmm a / xbmc / video / VideoDatabase . cpp <nl> ppp b / xbmc / video / VideoDatabase . cpp <nl> bool CVideoDatabase : : GetSetsByWhere ( const CStdString & strBaseDir , const Filter & <nl> return false ; <nl> <nl> CFileItemList sets ; <nl> - if ( ! GroupUtils : : Group ( GroupBySet , items , sets ) ) <nl> + if ( ! GroupUtils : : Group ( GroupBySet , strBaseDir , items , sets ) ) <nl> return false ; <nl> <nl> items . ClearItems ( ) ; <nl> mmm a / xbmc / video / windows / GUIWindowVideoBase . cpp <nl> ppp b / xbmc / video / windows / GUIWindowVideoBase . cpp <nl> void CGUIWindowVideoBase : : GetGroupedItems ( CFileItemList & items ) <nl> g_guiSettings . GetBool ( " videolibrary . groupmoviesets " ) ) <nl> { <nl> CFileItemList groupedItems ; <nl> - if ( GroupUtils : : Group ( GroupBySet , items , groupedItems , GroupAttributeIgnoreSingleItems ) ) <nl> + if ( GroupUtils : : Group ( GroupBySet , m_strFilterPath , items , groupedItems , GroupAttributeIgnoreSingleItems ) ) <nl> { <nl> items . ClearItems ( ) ; <nl> items . Append ( groupedItems ) ; <nl>
|
Merge pull request from Montellese / set_grouping_fix
|
xbmc/xbmc
|
31843b4682e684a4dd3c4d70e6692b3b011ebd36
|
2012-12-22T13:58:28Z
|
mmm a / . gitignore <nl> ppp b / . gitignore <nl> build - redis * <nl> redis - desktop - manager / Makefile * <nl> build / redis * <nl> redis - desktop - manager / connections . xml <nl> + * . deb <nl>
|
Added * . deb to ignore
|
uglide/RedisDesktopManager
|
3af1038ff9844f7e6d0baf7bd169d28dcc077843
|
2013-09-30T14:57:18Z
|
mmm a / caffe2 / core / stats . cc <nl> ppp b / caffe2 / core / stats . cc <nl> void StatRegistry : : publish ( ExportedStatList & exported , bool reset ) { <nl> <nl> void StatRegistry : : update ( const ExportedStatList & data ) { <nl> for ( const auto & stat : data ) { <nl> - add ( stat . key ) - > update ( stat . value ) ; <nl> + add ( stat . key ) - > increment ( stat . value ) ; <nl> } <nl> } <nl> <nl> mmm a / caffe2 / core / stats . h <nl> ppp b / caffe2 / core / stats . h <nl> class StatValue { <nl> std : : atomic < int64_t > v_ { 0 } ; <nl> <nl> public : <nl> - int64_t update ( int64_t inc ) { <nl> + int64_t increment ( int64_t inc ) { <nl> return v_ + = inc ; <nl> } <nl> <nl> struct Stat { <nl> Stat ( const std : : string & gn , const std : : string & n ) : groupName ( gn ) , name ( n ) { } <nl> <nl> template < typename . . . Unused > <nl> - int64_t operator ( ) ( Unused . . . ) { <nl> + int64_t increment ( Unused . . . ) { <nl> return - 1 ; <nl> } <nl> } ; <nl> class ExportedStat : public Stat { <nl> ExportedStat ( const std : : string & gn , const std : : string & n ) <nl> : Stat ( gn , n ) , value_ ( StatRegistry : : get ( ) . add ( gn + " / " + n ) ) { } <nl> <nl> - template < typename . . . Unused > <nl> - int64_t operator ( ) ( int64_t increment , Unused . . . ) { <nl> - return value_ - > update ( increment ) ; <nl> + int64_t increment ( int64_t value = 1 ) { <nl> + return value_ - > increment ( value ) ; <nl> + } <nl> + <nl> + template < typename T , typename Unused1 , typename . . . Unused > <nl> + int64_t increment ( T value , Unused1 , Unused . . . ) { <nl> + return increment ( value ) ; <nl> + } <nl> + } ; <nl> + <nl> + class AvgExportedStat : public ExportedStat { <nl> + private : <nl> + ExportedStat count_ ; <nl> + <nl> + public : <nl> + AvgExportedStat ( const std : : string & gn , const std : : string & n ) <nl> + : ExportedStat ( gn , n + " / sum " ) , count_ ( gn , n + " / count " ) { } <nl> + <nl> + int64_t increment ( int64_t value = 1 ) { <nl> + count_ . increment ( ) ; <nl> + return ExportedStat : : increment ( value ) ; <nl> + } <nl> + <nl> + template < typename T , typename Unused1 , typename . . . Unused > <nl> + int64_t increment ( T value , Unused1 , Unused . . . ) { <nl> + return increment ( value ) ; <nl> + } <nl> + } ; <nl> + <nl> + class DetailedExportedStat : public ExportedStat { <nl> + private : <nl> + std : : vector < ExportedStat > details_ ; <nl> + <nl> + public : <nl> + DetailedExportedStat ( const std : : string & gn , const std : : string & n ) <nl> + : ExportedStat ( gn , n ) { } <nl> + <nl> + void setDetails ( const std : : vector < std : : string > & detailNames ) { <nl> + details_ . clear ( ) ; <nl> + for ( const auto & detailName : detailNames ) { <nl> + details_ . emplace_back ( groupName , name + " / " + detailName ) ; <nl> + } <nl> + } <nl> + <nl> + template < typename T , typename . . . Unused > <nl> + int64_t increment ( T value , size_t detailIndex , Unused . . . ) { <nl> + if ( detailIndex < details_ . size ( ) ) { <nl> + details_ [ detailIndex ] . increment ( value ) ; <nl> + } <nl> + return ExportedStat : : increment ( value ) ; <nl> + } <nl> + } ; <nl> + <nl> + namespace detail { <nl> + <nl> + template < class T > <nl> + struct _ScopeGuard { <nl> + T f_ ; <nl> + std : : chrono : : high_resolution_clock : : time_point start_ ; <nl> + <nl> + explicit _ScopeGuard ( T f ) <nl> + : f_ ( f ) , start_ ( std : : chrono : : high_resolution_clock : : now ( ) ) { } <nl> + ~ _ScopeGuard ( ) { <nl> + using namespace std : : chrono ; <nl> + auto duration = high_resolution_clock : : now ( ) - start_ ; <nl> + int64_t nanos = duration_cast < nanoseconds > ( duration ) . count ( ) ; <nl> + f_ ( nanos ) ; <nl> } <nl> <nl> - int64_t operator ( ) ( ) { <nl> - return operator ( ) ( 1 ) ; <nl> + / / Using implicit cast to bool so that it can be used in an ' if ' condition <nl> + / / within CAFFE_DURATION macro below . <nl> + / * implicit * / operator bool ( ) { <nl> + return true ; <nl> } <nl> } ; <nl> <nl> + template < class T > <nl> + _ScopeGuard < T > ScopeGuard ( T f ) { <nl> + return _ScopeGuard < T > ( f ) ; <nl> + } <nl> + } <nl> + <nl> # define CAFFE_STAT_CTOR ( ClassName ) \ <nl> ClassName ( std : : string name ) : groupName ( name ) { } \ <nl> std : : string groupName <nl> class ExportedStat : public Stat { <nl> groupName , # name \ <nl> } <nl> <nl> + # define CAFFE_AVG_EXPORTED_STAT ( name ) \ <nl> + AvgExportedStat name { \ <nl> + groupName , # name \ <nl> + } <nl> + <nl> + # define CAFFE_DETAILED_EXPORTED_STAT ( name ) \ <nl> + DetailedExportedStat name { \ <nl> + groupName , # name \ <nl> + } <nl> + <nl> # define CAFFE_STAT ( name ) \ <nl> Stat name { \ <nl> groupName , # name \ <nl> } <nl> <nl> - # define CAFFE_EVENT ( stats , field , . . . ) \ <nl> - { \ <nl> - auto __caffe_event_value_ = stats . field ( __VA_ARGS__ ) ; \ <nl> - CAFFE_SDT ( \ <nl> - field , \ <nl> - stats . field . groupName . c_str ( ) , \ <nl> - __caffe_event_value_ , \ <nl> - # # __VA_ARGS__ ) ; \ <nl> + # define CAFFE_EVENT ( stats , field , . . . ) \ <nl> + { \ <nl> + auto __caffe_event_value_ = stats . field . increment ( __VA_ARGS__ ) ; \ <nl> + CAFFE_SDT ( \ <nl> + field , \ <nl> + stats . field . groupName . c_str ( ) , \ <nl> + __caffe_event_value_ , \ <nl> + # # __VA_ARGS__ ) ; \ <nl> } <nl> + <nl> + # define CAFFE_DURATION ( stats , field , . . . ) \ <nl> + if ( auto g = detail : : ScopeGuard ( [ & ] ( int64_t nanos ) { \ <nl> + CAFFE_EVENT ( stats , field , nanos , # # __VA_ARGS__ ) ; \ <nl> + } ) ) <nl> } <nl> mmm a / caffe2 / core / stats_test . cc <nl> ppp b / caffe2 / core / stats_test . cc <nl> TEST ( StatsTest , StatsTestClass ) { <nl> toMap ( StatRegistry : : get ( ) . publish ( ) ) ) ; <nl> } <nl> <nl> + TEST ( StatsTest , StatsTestDuration ) { <nl> + struct TestStats { <nl> + CAFFE_STAT_CTOR ( TestStats ) ; <nl> + CAFFE_STAT ( count ) ; <nl> + CAFFE_AVG_EXPORTED_STAT ( time_ns ) ; <nl> + } ; <nl> + TestStats stats ( " stats " ) ; <nl> + CAFFE_DURATION ( stats , time_ns ) { } <nl> + <nl> + ExportedStatList data ; <nl> + StatRegistry : : get ( ) . publish ( data ) ; <nl> + auto map = toMap ( data ) ; <nl> + auto countIt = map . find ( " stats / time_ns / count " ) ; <nl> + auto sumIt = map . find ( " stats / time_ns / sum " ) ; <nl> + EXPECT_TRUE ( countIt ! = map . end ( ) & & sumIt ! = map . end ( ) ) ; <nl> + EXPECT_EQ ( countIt - > second , 1 ) ; <nl> + EXPECT_GT ( sumIt - > second , 0 ) ; <nl> + } <nl> + <nl> TEST ( StatsTest , StatsTestSimple ) { <nl> struct TestStats { <nl> CAFFE_STAT_CTOR ( TestStats ) ; <nl>
|
Average and time spent counters
|
pytorch/pytorch
|
2f73a01b70ddb4e97351f983f9b72c18f4d32e6b
|
2017-03-24T20:34:27Z
|
mmm a / db / pdfile . cpp <nl> ppp b / db / pdfile . cpp <nl> namespace mongo { <nl> int Extent : : followupSize ( int len , int lastExtentLen ) { <nl> assert ( len < Extent : : maxSize ( ) ) ; <nl> int x = initialSize ( len ) ; <nl> - int y = ( int ) ( lastExtentLen < 4000000 ? lastExtentLen * 4 . 0 : lastExtentLen * 1 . 2 ) ; <nl> + / / changed from 1 . 20 to 1 . 35 in v2 . 1 . x to get to larger extent size faster <nl> + int y = ( int ) ( lastExtentLen < 4000000 ? lastExtentLen * 4 . 0 : lastExtentLen * 1 . 35 ) ; <nl> int sz = y > x ? y : x ; <nl> <nl> if ( sz < lastExtentLen ) { <nl>
|
increase the speed at which extent sizes within a collection grow so that it takes less long for them to become large
|
mongodb/mongo
|
ebc078b1505dd97638da576bdfa179751b225e4f
|
2011-11-12T20:55:57Z
|
mmm a / src / builtins / ppc / builtins - ppc . cc <nl> ppp b / src / builtins / ppc / builtins - ppc . cc <nl> void Builtins : : Generate_ResumeGeneratorTrampoline ( MacroAssembler * masm ) { <nl> / / undefined because generator functions are non - constructable . <nl> __ mr ( r6 , r4 ) ; <nl> __ mr ( r4 , r7 ) ; <nl> - __ LoadP ( ip , FieldMemOperand ( r4 , JSFunction : : kCodeEntryOffset ) ) ; <nl> + __ LoadP ( ip , FieldMemOperand ( r4 , JSFunction : : kCodeOffset ) ) ; <nl> + __ addi ( ip , ip , Operand ( Code : : kHeaderSize - kHeapObjectTag ) ) ; <nl> __ JumpToJSEntry ( ip ) ; <nl> } <nl> <nl> void Builtins : : Generate_JSConstructEntryTrampoline ( MacroAssembler * masm ) { <nl> Generate_JSEntryTrampolineHelper ( masm , true ) ; <nl> } <nl> <nl> - static void ReplaceClosureEntryWithOptimizedCode ( <nl> - MacroAssembler * masm , Register optimized_code_entry , Register closure , <nl> + static void ReplaceClosureCodeWithOptimizedCode ( <nl> + MacroAssembler * masm , Register optimized_code , Register closure , <nl> Register scratch1 , Register scratch2 , Register scratch3 ) { <nl> Register native_context = scratch1 ; <nl> / / Store code entry in the closure . <nl> - __ addi ( optimized_code_entry , optimized_code_entry , <nl> - Operand ( Code : : kHeaderSize - kHeapObjectTag ) ) ; <nl> - __ StoreP ( optimized_code_entry , <nl> - FieldMemOperand ( closure , JSFunction : : kCodeEntryOffset ) , r0 ) ; <nl> - __ RecordWriteCodeEntryField ( closure , optimized_code_entry , scratch2 ) ; <nl> + __ StoreP ( optimized_code , FieldMemOperand ( closure , JSFunction : : kCodeOffset ) , <nl> + r0 ) ; <nl> + __ mr ( scratch1 , optimized_code ) ; / / Write barrier clobbers scratch1 below . <nl> + __ RecordWriteField ( closure , JSFunction : : kCodeOffset , scratch1 , scratch2 , <nl> + kLRHasNotBeenSaved , kDontSaveFPRegs , OMIT_REMEMBERED_SET , <nl> + OMIT_SMI_CHECK ) ; <nl> <nl> / / Link the closure into the optimized function list . <nl> / / r7 : code entry <nl> static void MaybeTailCallOptimizedCodeSlot ( MacroAssembler * masm , <nl> / / the optimized functions list , then tail call the optimized code . <nl> / / The feedback vector is no longer used , so re - use it as a scratch <nl> / / register . <nl> - ReplaceClosureEntryWithOptimizedCode ( masm , optimized_code_entry , closure , <nl> - scratch2 , scratch3 , feedback_vector ) ; <nl> + ReplaceClosureCodeWithOptimizedCode ( masm , optimized_code_entry , closure , <nl> + scratch2 , scratch3 , feedback_vector ) ; <nl> + __ addi ( optimized_code_entry , optimized_code_entry , <nl> + Operand ( Code : : kHeaderSize - kHeapObjectTag ) ) ; <nl> __ mr ( ip , optimized_code_entry ) ; <nl> __ Jump ( optimized_code_entry ) ; <nl> <nl> void Builtins : : Generate_InterpreterEntryTrampoline ( MacroAssembler * masm ) { <nl> __ LeaveFrame ( StackFrame : : JAVA_SCRIPT ) ; <nl> __ LoadP ( r7 , FieldMemOperand ( closure , JSFunction : : kSharedFunctionInfoOffset ) ) ; <nl> __ LoadP ( r7 , FieldMemOperand ( r7 , SharedFunctionInfo : : kCodeOffset ) ) ; <nl> + <nl> + __ StoreP ( r7 , FieldMemOperand ( closure , JSFunction : : kCodeOffset ) , r0 ) ; <nl> + __ mr ( r9 , r7 ) ; / / Write barrier clobbers r9 below . <nl> + __ RecordWriteField ( closure , JSFunction : : kCodeOffset , r9 , r8 , <nl> + kLRHasNotBeenSaved , kDontSaveFPRegs , OMIT_REMEMBERED_SET , <nl> + OMIT_SMI_CHECK ) ; <nl> + <nl> __ addi ( r7 , r7 , Operand ( Code : : kHeaderSize - kHeapObjectTag ) ) ; <nl> - __ StoreP ( r7 , FieldMemOperand ( closure , JSFunction : : kCodeEntryOffset ) , r0 ) ; <nl> - __ RecordWriteCodeEntryField ( closure , r7 , r8 ) ; <nl> __ JumpToJSEntry ( r7 ) ; <nl> } <nl> <nl> void Builtins : : Generate_CompileLazy ( MacroAssembler * masm ) { <nl> __ beq ( & gotta_call_runtime ) ; <nl> <nl> / / Install the SFI ' s code entry . <nl> + __ StoreP ( entry , FieldMemOperand ( closure , JSFunction : : kCodeOffset ) , r0 ) ; <nl> + __ mr ( r9 , entry ) ; / / Write barrier clobbers ip below . <nl> + __ RecordWriteField ( closure , JSFunction : : kCodeOffset , r9 , r8 , <nl> + kLRHasNotBeenSaved , kDontSaveFPRegs , OMIT_REMEMBERED_SET , <nl> + OMIT_SMI_CHECK ) ; <nl> __ addi ( entry , entry , Operand ( Code : : kHeaderSize - kHeapObjectTag ) ) ; <nl> - __ StoreP ( entry , FieldMemOperand ( closure , JSFunction : : kCodeEntryOffset ) , r0 ) ; <nl> - __ RecordWriteCodeEntryField ( closure , entry , r8 ) ; <nl> __ JumpToJSEntry ( entry ) ; <nl> <nl> __ bind ( & gotta_call_runtime ) ; <nl> void Builtins : : Generate_ArgumentsAdaptorTrampoline ( MacroAssembler * masm ) { <nl> Label invoke , dont_adapt_arguments , stack_overflow ; <nl> <nl> Label enough , too_few ; <nl> - __ LoadP ( ip , FieldMemOperand ( r4 , JSFunction : : kCodeEntryOffset ) ) ; <nl> + __ LoadP ( ip , FieldMemOperand ( r4 , JSFunction : : kCodeOffset ) ) ; <nl> + __ addi ( ip , ip , Operand ( Code : : kHeaderSize - kHeapObjectTag ) ) ; <nl> __ cmp ( r3 , r5 ) ; <nl> __ blt ( & too_few ) ; <nl> __ cmpi ( r5 , Operand ( SharedFunctionInfo : : kDontAdaptArgumentsSentinel ) ) ; <nl> mmm a / src / builtins / s390 / builtins - s390 . cc <nl> ppp b / src / builtins / s390 / builtins - s390 . cc <nl> void Builtins : : Generate_ResumeGeneratorTrampoline ( MacroAssembler * masm ) { <nl> / / undefined because generator functions are non - constructable . <nl> __ LoadRR ( r5 , r3 ) ; <nl> __ LoadRR ( r3 , r6 ) ; <nl> - __ LoadP ( ip , FieldMemOperand ( r3 , JSFunction : : kCodeEntryOffset ) ) ; <nl> + __ LoadP ( ip , FieldMemOperand ( r3 , JSFunction : : kCodeOffset ) ) ; <nl> + __ AddP ( ip , ip , Operand ( Code : : kHeaderSize - kHeapObjectTag ) ) ; <nl> __ JumpToJSEntry ( ip ) ; <nl> } <nl> <nl> void Builtins : : Generate_JSConstructEntryTrampoline ( MacroAssembler * masm ) { <nl> Generate_JSEntryTrampolineHelper ( masm , true ) ; <nl> } <nl> <nl> - static void ReplaceClosureEntryWithOptimizedCode ( <nl> - MacroAssembler * masm , Register optimized_code_entry , Register closure , <nl> + static void ReplaceClosureCodeWithOptimizedCode ( <nl> + MacroAssembler * masm , Register optimized_code , Register closure , <nl> Register scratch1 , Register scratch2 , Register scratch3 ) { <nl> Register native_context = scratch1 ; <nl> / / Store code entry in the closure . <nl> - __ AddP ( optimized_code_entry , optimized_code_entry , <nl> - Operand ( Code : : kHeaderSize - kHeapObjectTag ) ) ; <nl> - __ StoreP ( optimized_code_entry , <nl> - FieldMemOperand ( closure , JSFunction : : kCodeEntryOffset ) , r0 ) ; <nl> - __ RecordWriteCodeEntryField ( closure , optimized_code_entry , scratch2 ) ; <nl> + __ StoreP ( optimized_code , FieldMemOperand ( closure , JSFunction : : kCodeOffset ) , <nl> + r0 ) ; <nl> + __ LoadRR ( scratch1 , <nl> + optimized_code ) ; / / Write barrier clobbers scratch1 below . <nl> + __ RecordWriteField ( closure , JSFunction : : kCodeOffset , scratch1 , scratch2 , <nl> + kLRHasNotBeenSaved , kDontSaveFPRegs , OMIT_REMEMBERED_SET , <nl> + OMIT_SMI_CHECK ) ; <nl> <nl> / / Link the closure into the optimized function list . <nl> / / r6 : code entry <nl> static void MaybeTailCallOptimizedCodeSlot ( MacroAssembler * masm , <nl> / / the optimized functions list , then tail call the optimized code . <nl> / / The feedback vector is no longer used , so re - use it as a scratch <nl> / / register . <nl> - ReplaceClosureEntryWithOptimizedCode ( masm , optimized_code_entry , closure , <nl> - scratch2 , scratch3 , feedback_vector ) ; <nl> + ReplaceClosureCodeWithOptimizedCode ( masm , optimized_code_entry , closure , <nl> + scratch2 , scratch3 , feedback_vector ) ; <nl> + __ AddP ( optimized_code_entry , optimized_code_entry , <nl> + Operand ( Code : : kHeaderSize - kHeapObjectTag ) ) ; <nl> __ Jump ( optimized_code_entry ) ; <nl> <nl> / / Optimized code slot contains deoptimized code , evict it and re - enter the <nl> void Builtins : : Generate_InterpreterEntryTrampoline ( MacroAssembler * masm ) { <nl> __ LeaveFrame ( StackFrame : : JAVA_SCRIPT ) ; <nl> __ LoadP ( r6 , FieldMemOperand ( closure , JSFunction : : kSharedFunctionInfoOffset ) ) ; <nl> __ LoadP ( r6 , FieldMemOperand ( r6 , SharedFunctionInfo : : kCodeOffset ) ) ; <nl> + __ StoreP ( r6 , FieldMemOperand ( closure , JSFunction : : kCodeOffset ) , r0 ) ; <nl> + __ LoadRR ( r8 , r6 ) ; / / Write barrier clobbers r8 below . <nl> + __ RecordWriteField ( closure , JSFunction : : kCodeOffset , r8 , r7 , <nl> + kLRHasNotBeenSaved , kDontSaveFPRegs , OMIT_REMEMBERED_SET , <nl> + OMIT_SMI_CHECK ) ; <nl> __ AddP ( r6 , r6 , Operand ( Code : : kHeaderSize - kHeapObjectTag ) ) ; <nl> - __ StoreP ( r6 , FieldMemOperand ( closure , JSFunction : : kCodeEntryOffset ) , r0 ) ; <nl> - __ RecordWriteCodeEntryField ( closure , r6 , r7 ) ; <nl> __ JumpToJSEntry ( r6 ) ; <nl> } <nl> <nl> void Builtins : : Generate_CompileLazy ( MacroAssembler * masm ) { <nl> __ beq ( & gotta_call_runtime ) ; <nl> <nl> / / Install the SFI ' s code entry . <nl> + __ StoreP ( entry , FieldMemOperand ( closure , JSFunction : : kCodeOffset ) , r0 ) ; <nl> + __ LoadRR ( r8 , entry ) ; / / Write barrier clobbers r8 below . <nl> + __ RecordWriteField ( closure , JSFunction : : kCodeOffset , r8 , r7 , <nl> + kLRHasNotBeenSaved , kDontSaveFPRegs , OMIT_REMEMBERED_SET , <nl> + OMIT_SMI_CHECK ) ; <nl> __ AddP ( entry , entry , Operand ( Code : : kHeaderSize - kHeapObjectTag ) ) ; <nl> - __ StoreP ( entry , FieldMemOperand ( closure , JSFunction : : kCodeEntryOffset ) , r0 ) ; <nl> - __ RecordWriteCodeEntryField ( closure , entry , r7 ) ; <nl> __ JumpToJSEntry ( entry ) ; <nl> <nl> __ bind ( & gotta_call_runtime ) ; <nl> void Builtins : : Generate_ArgumentsAdaptorTrampoline ( MacroAssembler * masm ) { <nl> Label invoke , dont_adapt_arguments , stack_overflow ; <nl> <nl> Label enough , too_few ; <nl> - __ LoadP ( ip , FieldMemOperand ( r3 , JSFunction : : kCodeEntryOffset ) ) ; <nl> + __ LoadP ( ip , FieldMemOperand ( r3 , JSFunction : : kCodeOffset ) ) ; <nl> + __ AddP ( ip , ip , Operand ( Code : : kHeaderSize - kHeapObjectTag ) ) ; <nl> __ CmpP ( r2 , r4 ) ; <nl> __ blt ( & too_few ) ; <nl> __ CmpP ( r4 , Operand ( SharedFunctionInfo : : kDontAdaptArgumentsSentinel ) ) ; <nl> mmm a / src / compiler / ppc / code - generator - ppc . cc <nl> ppp b / src / compiler / ppc / code - generator - ppc . cc <nl> CodeGenerator : : CodeGenResult CodeGenerator : : AssembleArchInstruction ( <nl> __ cmp ( cp , kScratchReg ) ; <nl> __ Assert ( eq , kWrongFunctionContext ) ; <nl> } <nl> - __ LoadP ( ip , FieldMemOperand ( func , JSFunction : : kCodeEntryOffset ) ) ; <nl> + __ LoadP ( ip , FieldMemOperand ( func , JSFunction : : kCodeOffset ) ) ; <nl> + __ addi ( ip , ip , Operand ( Code : : kHeaderSize - kHeapObjectTag ) ) ; <nl> __ Call ( ip ) ; <nl> RecordCallPosition ( instr ) ; <nl> DCHECK_EQ ( LeaveRC , i . OutputRCBit ( ) ) ; <nl> void CodeGenerator : : AssembleMove ( InstructionOperand * source , <nl> value = Double ( src . ToFloat64 ( ) ) ; <nl> } <nl> # else <nl> - value = Double ( ( src . type ( ) = = Constant : : kFloat32 ) <nl> - ? static_cast < double > ( src . ToFloat32 ( ) ) <nl> - : src . ToFloat64 ( ) ) ; <nl> + value = src . type ( ) = = Constant : : kFloat32 <nl> + ? Double ( static_cast < double > ( src . ToFloat32 ( ) ) ) <nl> + : Double ( src . ToFloat64 ( ) ) ; <nl> # endif <nl> __ LoadDoubleLiteral ( dst , value , kScratchReg ) ; <nl> if ( destination - > IsFPStackSlot ( ) ) { <nl> mmm a / src / compiler / s390 / code - generator - s390 . cc <nl> ppp b / src / compiler / s390 / code - generator - s390 . cc <nl> CodeGenerator : : CodeGenResult CodeGenerator : : AssembleArchInstruction ( <nl> __ CmpP ( cp , kScratchReg ) ; <nl> __ Assert ( eq , kWrongFunctionContext ) ; <nl> } <nl> - __ LoadP ( ip , FieldMemOperand ( func , JSFunction : : kCodeEntryOffset ) ) ; <nl> + __ LoadP ( ip , FieldMemOperand ( func , JSFunction : : kCodeOffset ) ) ; <nl> + __ AddP ( ip , ip , Operand ( Code : : kHeaderSize - kHeapObjectTag ) ) ; <nl> __ Call ( ip ) ; <nl> RecordCallPosition ( instr ) ; <nl> frame_access_state ( ) - > ClearSPDelta ( ) ; <nl> mmm a / src / ppc / macro - assembler - ppc . cc <nl> ppp b / src / ppc / macro - assembler - ppc . cc <nl> void MacroAssembler : : RecordWrite ( <nl> } <nl> } <nl> <nl> - void MacroAssembler : : RecordWriteCodeEntryField ( Register js_function , <nl> - Register code_entry , <nl> - Register scratch ) { <nl> - const int offset = JSFunction : : kCodeEntryOffset ; <nl> - <nl> - / / Since a code entry ( value ) is always in old space , we don ' t need to update <nl> - / / remembered set . If incremental marking is off , there is nothing for us to <nl> - / / do . <nl> - if ( ! FLAG_incremental_marking ) return ; <nl> - <nl> - DCHECK ( js_function . is ( r4 ) ) ; <nl> - DCHECK ( code_entry . is ( r7 ) ) ; <nl> - DCHECK ( scratch . is ( r8 ) ) ; <nl> - AssertNotSmi ( js_function ) ; <nl> - <nl> - if ( emit_debug_code ( ) ) { <nl> - addi ( scratch , js_function , Operand ( offset - kHeapObjectTag ) ) ; <nl> - LoadP ( ip , MemOperand ( scratch ) ) ; <nl> - cmp ( ip , code_entry ) ; <nl> - Check ( eq , kWrongAddressOrValuePassedToRecordWrite ) ; <nl> - } <nl> - <nl> - / / First , check if a write barrier is even needed . The tests below <nl> - / / catch stores of Smis and stores into young gen . <nl> - Label done ; <nl> - <nl> - CheckPageFlag ( code_entry , scratch , <nl> - MemoryChunk : : kPointersToHereAreInterestingMask , eq , & done ) ; <nl> - CheckPageFlag ( js_function , scratch , <nl> - MemoryChunk : : kPointersFromHereAreInterestingMask , eq , & done ) ; <nl> - <nl> - const Register dst = scratch ; <nl> - addi ( dst , js_function , Operand ( offset - kHeapObjectTag ) ) ; <nl> - <nl> - / / Save caller - saved registers . js_function and code_entry are in the <nl> - / / caller - saved register list . <nl> - DCHECK ( kJSCallerSaved & js_function . bit ( ) ) ; <nl> - DCHECK ( kJSCallerSaved & code_entry . bit ( ) ) ; <nl> - mflr ( r0 ) ; <nl> - MultiPush ( kJSCallerSaved | r0 . bit ( ) ) ; <nl> - <nl> - int argument_count = 3 ; <nl> - PrepareCallCFunction ( argument_count , code_entry ) ; <nl> - <nl> - mr ( r3 , js_function ) ; <nl> - mr ( r4 , dst ) ; <nl> - mov ( r5 , Operand ( ExternalReference : : isolate_address ( isolate ( ) ) ) ) ; <nl> - <nl> - { <nl> - AllowExternalCallThatCantCauseGC scope ( this ) ; <nl> - CallCFunction ( <nl> - ExternalReference : : incremental_marking_record_write_code_entry_function ( <nl> - isolate ( ) ) , <nl> - argument_count ) ; <nl> - } <nl> - <nl> - / / Restore caller - saved registers ( including js_function and code_entry ) . <nl> - MultiPop ( kJSCallerSaved | r0 . bit ( ) ) ; <nl> - mtlr ( r0 ) ; <nl> - <nl> - bind ( & done ) ; <nl> - } <nl> - <nl> void MacroAssembler : : RememberedSetHelper ( Register object , / / For debug tests . <nl> Register address , Register scratch , <nl> SaveFPRegsMode fp_mode , <nl> void MacroAssembler : : InvokeFunctionCode ( Register function , Register new_target , <nl> / / allow recompilation to take effect without changing any of the <nl> / / call sites . <nl> Register code = ip ; <nl> - LoadP ( code , FieldMemOperand ( function , JSFunction : : kCodeEntryOffset ) ) ; <nl> + LoadP ( code , FieldMemOperand ( function , JSFunction : : kCodeOffset ) ) ; <nl> + addi ( code , code , Operand ( Code : : kHeaderSize - kHeapObjectTag ) ) ; <nl> if ( flag = = CALL_FUNCTION ) { <nl> CallJSEntry ( code ) ; <nl> } else { <nl> mmm a / src / ppc / macro - assembler - ppc . h <nl> ppp b / src / ppc / macro - assembler - ppc . h <nl> class MacroAssembler : public TurboAssembler { <nl> pointers_to_here_check_for_value ) ; <nl> } <nl> <nl> - / / Notify the garbage collector that we wrote a code entry into a <nl> - / / JSFunction . Only scratch is clobbered by the operation . <nl> - void RecordWriteCodeEntryField ( Register js_function , Register code_entry , <nl> - Register scratch ) ; <nl> - <nl> void RecordWriteForMap ( Register object , Register map , Register dst , <nl> LinkRegisterStatus lr_status , SaveFPRegsMode save_fp ) ; <nl> <nl> mmm a / src / s390 / macro - assembler - s390 . cc <nl> ppp b / src / s390 / macro - assembler - s390 . cc <nl> void MacroAssembler : : RecordWrite ( <nl> } <nl> } <nl> <nl> - void MacroAssembler : : RecordWriteCodeEntryField ( Register js_function , <nl> - Register code_entry , <nl> - Register scratch ) { <nl> - const int offset = JSFunction : : kCodeEntryOffset ; <nl> - <nl> - / / Since a code entry ( value ) is always in old space , we don ' t need to update <nl> - / / remembered set . If incremental marking is off , there is nothing for us to <nl> - / / do . <nl> - if ( ! FLAG_incremental_marking ) return ; <nl> - <nl> - DCHECK ( js_function . is ( r3 ) ) ; <nl> - DCHECK ( code_entry . is ( r6 ) ) ; <nl> - DCHECK ( scratch . is ( r7 ) ) ; <nl> - AssertNotSmi ( js_function ) ; <nl> - <nl> - if ( emit_debug_code ( ) ) { <nl> - AddP ( scratch , js_function , Operand ( offset - kHeapObjectTag ) ) ; <nl> - LoadP ( ip , MemOperand ( scratch ) ) ; <nl> - CmpP ( ip , code_entry ) ; <nl> - Check ( eq , kWrongAddressOrValuePassedToRecordWrite ) ; <nl> - } <nl> - <nl> - / / First , check if a write barrier is even needed . The tests below <nl> - / / catch stores of Smis and stores into young gen . <nl> - Label done ; <nl> - <nl> - CheckPageFlag ( code_entry , scratch , <nl> - MemoryChunk : : kPointersToHereAreInterestingMask , eq , & done ) ; <nl> - CheckPageFlag ( js_function , scratch , <nl> - MemoryChunk : : kPointersFromHereAreInterestingMask , eq , & done ) ; <nl> - <nl> - const Register dst = scratch ; <nl> - AddP ( dst , js_function , Operand ( offset - kHeapObjectTag ) ) ; <nl> - <nl> - / / Save caller - saved registers . js_function and code_entry are in the <nl> - / / caller - saved register list . <nl> - DCHECK ( kJSCallerSaved & js_function . bit ( ) ) ; <nl> - / / DCHECK ( kJSCallerSaved & code_entry . bit ( ) ) ; <nl> - MultiPush ( kJSCallerSaved | code_entry . bit ( ) | r14 . bit ( ) ) ; <nl> - <nl> - int argument_count = 3 ; <nl> - PrepareCallCFunction ( argument_count , code_entry ) ; <nl> - <nl> - LoadRR ( r2 , js_function ) ; <nl> - LoadRR ( r3 , dst ) ; <nl> - mov ( r4 , Operand ( ExternalReference : : isolate_address ( isolate ( ) ) ) ) ; <nl> - <nl> - { <nl> - AllowExternalCallThatCantCauseGC scope ( this ) ; <nl> - CallCFunction ( <nl> - ExternalReference : : incremental_marking_record_write_code_entry_function ( <nl> - isolate ( ) ) , <nl> - argument_count ) ; <nl> - } <nl> - <nl> - / / Restore caller - saved registers ( including js_function and code_entry ) . <nl> - MultiPop ( kJSCallerSaved | code_entry . bit ( ) | r14 . bit ( ) ) ; <nl> - <nl> - bind ( & done ) ; <nl> - } <nl> - <nl> void MacroAssembler : : RememberedSetHelper ( Register object , / / For debug tests . <nl> Register address , Register scratch , <nl> SaveFPRegsMode fp_mode , <nl> void MacroAssembler : : InvokeFunctionCode ( Register function , Register new_target , <nl> / / allow recompilation to take effect without changing any of the <nl> / / call sites . <nl> Register code = ip ; <nl> - LoadP ( code , FieldMemOperand ( function , JSFunction : : kCodeEntryOffset ) ) ; <nl> + LoadP ( code , FieldMemOperand ( function , JSFunction : : kCodeOffset ) ) ; <nl> + AddP ( code , code , Operand ( Code : : kHeaderSize - kHeapObjectTag ) ) ; <nl> if ( flag = = CALL_FUNCTION ) { <nl> CallJSEntry ( code ) ; <nl> } else { <nl> mmm a / src / s390 / macro - assembler - s390 . h <nl> ppp b / src / s390 / macro - assembler - s390 . h <nl> class MacroAssembler : public TurboAssembler { <nl> / / Invoke the JavaScript function code by either calling or jumping . <nl> void InvokeFunctionCode ( Register function , Register new_target , <nl> const ParameterCount & expected , <nl> - const ParameterCount & actual , InvokeFlag flag , <nl> - const CallWrapper & call_wrapper ) ; <nl> + const ParameterCount & actual , InvokeFlag flag ) ; <nl> <nl> / / On function call , call into the debugger if necessary . <nl> void CheckDebugHook ( Register fun , Register new_target , <nl> class MacroAssembler : public TurboAssembler { <nl> / / Invoke the JavaScript function in the given register . Changes the <nl> / / current context to the context in the function before invoking . <nl> void InvokeFunction ( Register function , Register new_target , <nl> - const ParameterCount & actual , InvokeFlag flag , <nl> - const CallWrapper & call_wrapper ) ; <nl> + const ParameterCount & actual , InvokeFlag flag ) ; <nl> <nl> void InvokeFunction ( Register function , const ParameterCount & expected , <nl> - const ParameterCount & actual , InvokeFlag flag , <nl> - const CallWrapper & call_wrapper ) ; <nl> + const ParameterCount & actual , InvokeFlag flag ) ; <nl> <nl> void InvokeFunction ( Handle < JSFunction > function , <nl> const ParameterCount & expected , <nl> - const ParameterCount & actual , InvokeFlag flag , <nl> - const CallWrapper & call_wrapper ) ; <nl> + const ParameterCount & actual , InvokeFlag flag ) ; <nl> <nl> / / Frame restart support <nl> void MaybeDropFrames ( ) ; <nl> class MacroAssembler : public TurboAssembler { <nl> pointers_to_here_check_for_value ) ; <nl> } <nl> <nl> - / / Notify the garbage collector that we wrote a code entry into a <nl> - / / JSFunction . Only scratch is clobbered by the operation . <nl> - void RecordWriteCodeEntryField ( Register js_function , Register code_entry , <nl> - Register scratch ) ; <nl> - <nl> void RecordWriteForMap ( Register object , Register map , Register dst , <nl> LinkRegisterStatus lr_status , SaveFPRegsMode save_fp ) ; <nl> <nl> class MacroAssembler : public TurboAssembler { <nl> / / Helper functions for generating invokes . <nl> void InvokePrologue ( const ParameterCount & expected , <nl> const ParameterCount & actual , Label * done , <nl> - bool * definitely_mismatches , InvokeFlag flag , <nl> - const CallWrapper & call_wrapper ) ; <nl> + bool * definitely_mismatches , InvokeFlag flag ) ; <nl> <nl> / / Helper for implementing JumpIfNotInNewSpace and JumpIfInNewSpace . <nl> void InNewSpace ( Register object , Register scratch , <nl>
|
PPC / s390 : Switch JSFunction : : code to be a tagged value .
|
v8/v8
|
9836cdb1adc369542b13c326e6bfb4a6763668d0
|
2017-07-27T12:57:55Z
|
mmm a / 3rdParty / fuerte / src / VstConnection . cpp <nl> ppp b / 3rdParty / fuerte / src / VstConnection . cpp <nl> void VstConnection < ST > : : asyncReadCallback ( asio_ns : : error_code const & ec , <nl> default : <nl> throw std : : logic_error ( " Unknown VST version " ) ; <nl> } <nl> + <nl> + if ( available < chunk . chunkLength ( ) ) { / / prevent reading beyond buffer <nl> + FUERTE_LOG_ERROR < < " invalid chunk header " ; <nl> + shutdownConnection ( ErrorCondition : : ProtocolError ) ; <nl> + return ; <nl> + } <nl> + <nl> / / move cursors <nl> cursor + = chunk . chunkLength ( ) ; <nl> available - = chunk . chunkLength ( ) ; <nl> mmm a / 3rdParty / fuerte / src / types . cpp <nl> ppp b / 3rdParty / fuerte / src / types . cpp <nl> std : : string to_string ( ErrorCondition error ) { <nl> case ErrorCondition : : ConnectionClosed : <nl> return " Connection reset by peer " ; <nl> case ErrorCondition : : Timeout : <nl> - return " Timeout " ; <nl> + return " Request timeout " ; <nl> case ErrorCondition : : QueueCapacityExceeded : <nl> return " Request queue capacity exceeded " ; <nl> case ErrorCondition : : ReadError : <nl> mmm a / 3rdParty / fuerte / src / vst . cpp <nl> ppp b / 3rdParty / fuerte / src / vst . cpp <nl> std : : pair < ChunkHeader , asio_ns : : const_buffer > readChunkHeaderVST1_0 ( uint8_t cons <nl> hdrLen = maxChunkHeaderSize ; <nl> } <nl> <nl> - size_t contentLength = header . _chunkLength - hdrLen ; <nl> + size_t contentLength = 0 ; <nl> + if ( header . _chunkLength > = hdrLen ) { / / prevent underflow <nl> + contentLength = header . _chunkLength - hdrLen ; <nl> + } else { <nl> + FUERTE_LOG_ERROR < < " received invalid chunk length " ; <nl> + } <nl> FUERTE_LOG_VSTCHUNKTRACE < < " readChunkHeaderVST1_0 : got " < < contentLength <nl> < < " data bytes after " < < hdrLen < < " header bytes \ n " ; <nl> return std : : make_pair ( std : : move ( header ) , <nl> std : : pair < ChunkHeader , asio_ns : : const_buffer > readChunkHeaderVST1_1 ( uint8_t cons <nl> header . _chunkX = basics : : uintFromPersistentLittleEndian < uint32_t > ( hdr + 4 ) ; <nl> header . _messageID = basics : : uintFromPersistentLittleEndian < uint64_t > ( hdr + 8 ) ; <nl> header . _messageLength = basics : : uintFromPersistentLittleEndian < uint64_t > ( hdr + 16 ) ; <nl> - size_t contentLength = header . _chunkLength - maxChunkHeaderSize ; <nl> + size_t contentLength = 0 ; <nl> + if ( header . _chunkLength > = maxChunkHeaderSize ) { / / prevent underflow <nl> + contentLength = header . _chunkLength - maxChunkHeaderSize ; <nl> + } else { <nl> + FUERTE_LOG_ERROR < < " received invalid chunk length " ; <nl> + } <nl> FUERTE_LOG_VSTCHUNKTRACE < < " readChunkHeaderVST1_1 : got " < < contentLength <nl> < < " data bytes after " < < maxChunkHeaderSize < < " bytes \ n " ; <nl> return std : : make_pair ( std : : move ( header ) , <nl> mmm a / arangod / Aql / Ast . cpp <nl> ppp b / arangod / Aql / Ast . cpp <nl> void Ast : : validateAndOptimize ( ) { <nl> / / / @ brief determines the variables referenced in an expression <nl> void Ast : : getReferencedVariables ( AstNode const * node , <nl> std : : unordered_set < Variable const * > & result ) { <nl> - auto preVisitor = [ & result ] ( AstNode const * node ) - > bool { <nl> + auto preVisitor = [ ] ( AstNode const * node ) - > bool { <nl> return ! node - > isConstant ( ) ; <nl> } ; <nl> <nl> void Ast : : extractCollectionsFromGraph ( AstNode const * graphNode ) { <nl> std : : string graphName = graphNode - > getString ( ) ; <nl> auto graph = _query - > lookupGraphByName ( graphName ) ; <nl> if ( graph = = nullptr ) { <nl> - THROW_ARANGO_EXCEPTION ( TRI_ERROR_GRAPH_NOT_FOUND ) ; <nl> + THROW_ARANGO_EXCEPTION_PARAMS ( TRI_ERROR_GRAPH_NOT_FOUND , graphName . c_str ( ) ) ; <nl> } <nl> TRI_ASSERT ( graph ! = nullptr ) ; <nl> <nl> mmm a / arangod / Aql / GraphNode . cpp <nl> ppp b / arangod / Aql / GraphNode . cpp <nl> GraphNode : : GraphNode ( ExecutionPlan * plan , size_t id , TRI_vocbase_t * vocbase , <nl> _graphObj = plan - > getAst ( ) - > query ( ) - > lookupGraphByName ( graphName ) ; <nl> <nl> if ( _graphObj = = nullptr ) { <nl> - THROW_ARANGO_EXCEPTION ( TRI_ERROR_GRAPH_NOT_FOUND ) ; <nl> + THROW_ARANGO_EXCEPTION_PARAMS ( TRI_ERROR_GRAPH_NOT_FOUND , graphName . c_str ( ) ) ; <nl> } <nl> <nl> auto eColls = _graphObj - > edgeCollections ( ) ; <nl> GraphNode : : GraphNode ( ExecutionPlan * plan , <nl> _graphObj = plan - > getAst ( ) - > query ( ) - > lookupGraphByName ( graphName ) ; <nl> <nl> if ( _graphObj = = nullptr ) { <nl> - THROW_ARANGO_EXCEPTION ( TRI_ERROR_GRAPH_NOT_FOUND ) ; <nl> + THROW_ARANGO_EXCEPTION_PARAMS ( TRI_ERROR_GRAPH_NOT_FOUND , graphName . c_str ( ) ) ; <nl> } <nl> } else { <nl> THROW_ARANGO_EXCEPTION_MESSAGE ( TRI_ERROR_QUERY_BAD_JSON_PLAN , <nl> mmm a / arangod / Aql / ShortestPathNode . cpp <nl> ppp b / arangod / Aql / ShortestPathNode . cpp <nl> ShortestPathNode : : ShortestPathNode ( ExecutionPlan * plan , <nl> _graphObj = plan - > getAst ( ) - > query ( ) - > lookupGraphByName ( graphName ) ; <nl> <nl> if ( _graphObj = = nullptr ) { <nl> - THROW_ARANGO_EXCEPTION ( TRI_ERROR_GRAPH_NOT_FOUND ) ; <nl> + THROW_ARANGO_EXCEPTION_PARAMS ( TRI_ERROR_GRAPH_NOT_FOUND , graphName . c_str ( ) ) ; <nl> } <nl> <nl> auto const & eColls = _graphObj - > edgeCollections ( ) ; <nl> mmm a / arangod / GeneralServer / RestHandler . cpp <nl> ppp b / arangod / GeneralServer / RestHandler . cpp <nl> RequestPriority RestHandler : : priority ( RequestLane l ) const { <nl> case RequestLane : : AGENCY_INTERNAL : <nl> case RequestLane : : CLIENT_FAST : <nl> case RequestLane : : CLUSTER_INTERNAL : <nl> + case RequestLane : : SERVER_REPLICATION : <nl> p = RequestPriority : : HIGH ; <nl> break ; <nl> <nl> RequestPriority RestHandler : : priority ( RequestLane l ) const { <nl> case RequestLane : : CLIENT_SLOW : <nl> case RequestLane : : AGENCY_CLUSTER : <nl> case RequestLane : : CLUSTER_ADMIN : <nl> - case RequestLane : : SERVER_REPLICATION : <nl> case RequestLane : : CLIENT_V8 : <nl> case RequestLane : : CLUSTER_V8 : <nl> case RequestLane : : TASK_V8 : <nl> mmm a / arangod / Graph / GraphManager . cpp <nl> ppp b / arangod / Graph / GraphManager . cpp <nl> ResultT < std : : unique_ptr < Graph > > GraphManager : : lookupGraphByName ( <nl> <nl> if ( result . fail ( ) ) { <nl> if ( result . errorNumber ( ) = = TRI_ERROR_ARANGO_DOCUMENT_NOT_FOUND ) { <nl> - return { TRI_ERROR_GRAPH_NOT_FOUND } ; <nl> + std : : string msg = basics : : Exception : : FillExceptionString ( TRI_ERROR_GRAPH_NOT_FOUND , name . c_str ( ) ) ; <nl> + return Result { TRI_ERROR_GRAPH_NOT_FOUND , std : : move ( msg ) } ; <nl> } else { <nl> return Result { result . errorNumber ( ) , <nl> " while looking up graph ' " + name + " ' " } ; <nl> mmm a / arangod / IResearch / IResearchViewBlock . cpp <nl> ppp b / arangod / IResearch / IResearchViewBlock . cpp <nl> namespace { <nl> <nl> typedef std : : vector < arangodb : : iresearch : : DocumentPrimaryKey : : type > pks_t ; <nl> <nl> - constexpr size_t const BATCH_SIZE = 1024 ; <nl> - <nl> pks_t : : iterator readPKs ( <nl> irs : : doc_iterator & it , <nl> irs : : columnstore_reader : : values_reader_f const & values , <nl> mmm a / arangod / Indexes / IndexResult . h <nl> ppp b / arangod / Indexes / IndexResult . h <nl> class IndexResult : public Result { <nl> msg . append ( " over " ) ; <nl> msg . append ( fields . toJson ( ) ) ; <nl> } <nl> - reset ( errorNumber , msg ) ; <nl> + Result : : reset ( errorNumber , msg ) ; <nl> } <nl> } <nl> <nl> IndexResult ( int errorNumber , Index const * index , std : : string const & key ) <nl> - : IndexResult ( errorNumber , index ) { <nl> - / / provide conflicting key <nl> - if ( ! key . empty ( ) ) { <nl> + : Result ( ) { <nl> + IndexResult : : reset ( errorNumber , index , key ) ; <nl> + } <nl> + <nl> + IndexResult & reset ( int errorNumber , Index const * index , std : : string const & key ) { <nl> + Result : : reset ( errorNumber ) ; <nl> + if ( errorNumber ! = TRI_ERROR_NO_ERROR & & index ! = nullptr ) { <nl> + / / now provide more context based on index <nl> std : : string msg = errorMessage ( ) ; <nl> - msg . append ( " ; conflicting key : " ) ; <nl> - msg . append ( key ) ; <nl> - reset ( errorNumber , msg ) ; <nl> + msg . append ( " - in index " ) ; <nl> + msg . append ( std : : to_string ( index - > id ( ) ) ) ; <nl> + msg . append ( " of type " ) ; <nl> + msg . append ( index - > typeName ( ) ) ; <nl> + <nl> + / / build fields string <nl> + VPackBuilder builder ; <nl> + index - > toVelocyPack ( builder , Index : : makeFlags ( ) ) ; <nl> + VPackSlice fields = builder . slice ( ) . get ( " fields " ) ; <nl> + if ( ! fields . isNone ( ) ) { <nl> + msg . append ( " over " ) ; <nl> + msg . append ( fields . toJson ( ) ) ; <nl> + } <nl> + <nl> + / / provide conflicting key <nl> + if ( ! key . empty ( ) ) { <nl> + msg . append ( " ; conflicting key : " ) ; <nl> + msg . append ( key ) ; <nl> + } <nl> + Result : : reset ( errorNumber , msg ) ; <nl> } <nl> + return * this ; <nl> + } <nl> + <nl> + IndexResult & reset ( Result & res , Index const * index ) { <nl> + Result : : reset ( res ) ; <nl> + IndexResult : : reset ( res . errorNumber ( ) , index , StaticStrings : : Empty ) ; <nl> + return * this ; <nl> + } <nl> + <nl> + IndexResult & reset ( int res , std : : string const & msg ) { <nl> + Result : : reset ( res , msg ) ; <nl> + return * this ; <nl> } <nl> + <nl> } ; <nl> } / / namespace arangodb <nl> <nl> mmm a / arangod / MMFiles / MMFilesEngine . cpp <nl> ppp b / arangod / MMFiles / MMFilesEngine . cpp <nl> Result MMFilesEngine : : persistLocalDocumentIds ( TRI_vocbase_t & vocbase ) { <nl> LOG_TOPIC ( DEBUG , Logger : : ENGINES ) <nl> < < " processing collection ' " < < c - > name ( ) < < " ' " ; <nl> collection - > open ( false ) ; <nl> - auto guard = scopeGuard ( [ this , & collection ] ( ) - > void { <nl> + auto guard = scopeGuard ( [ & collection ] ( ) - > void { <nl> collection - > close ( ) ; <nl> } ) ; <nl> <nl> mmm a / arangod / MMFiles / MMFilesWalRecoverState . cpp <nl> ppp b / arangod / MMFiles / MMFilesWalRecoverState . cpp <nl> bool MMFilesWalRecoverState : : ReplayMarker ( MMFilesMarker const * marker , <nl> < < " was already renamed ; moving on " ; <nl> break ; <nl> } <nl> - vocbase - > dropView ( other - > id ( ) , true ) ; <nl> + other - > drop ( ) ; <nl> } <nl> <nl> auto res = view - > rename ( std : : string ( name ) ) ; <nl> bool MMFilesWalRecoverState : : ReplayMarker ( MMFilesMarker const * marker , <nl> / / ignore any potential error returned by this call <nl> std : : shared_ptr < arangodb : : LogicalView > view = <nl> vocbase - > lookupView ( viewId ) ; <nl> - <nl> if ( view ! = nullptr ) { <nl> - vocbase - > dropView ( view - > id ( ) , true ) ; <nl> + view - > drop ( ) ; <nl> } <nl> <nl> break ; <nl> mmm a / arangod / Replication / GlobalInitialSyncer . cpp <nl> ppp b / arangod / Replication / GlobalInitialSyncer . cpp <nl> Result GlobalInitialSyncer : : updateServerInventory ( <nl> <nl> for ( auto const & coll : VPackArrayIterator ( collections ) ) { <nl> if ( ! coll . isObject ( ) | | ! coll . hasKey ( " parameters " ) ) { <nl> - / / somehow invalid <nl> - continue ; <nl> + continue ; / / somehow invalid <nl> } <nl> <nl> VPackSlice const params = coll . get ( " parameters " ) ; <nl> Result GlobalInitialSyncer : : updateServerInventory ( <nl> / / collection should surive <nl> return ; <nl> } <nl> - <nl> - if ( collection - > system ( ) ) { <nl> - / / we will not drop system collections here <nl> - return ; <nl> + if ( ! collection - > system ( ) ) { / / we will not drop system collections here <nl> + toDrop . emplace_back ( collection ) ; <nl> } <nl> - <nl> - toDrop . emplace_back ( collection ) ; <nl> } , <nl> false ) ; <nl> <nl> mmm a / arangod / Replication / ReplicationApplier . cpp <nl> ppp b / arangod / Replication / ReplicationApplier . cpp <nl> void ReplicationApplier : : doStop ( Result const & r , bool joinThread ) { <nl> } <nl> <nl> if ( joinThread ) { <nl> + <nl> + auto start = std : : chrono : : steady_clock : : now ( ) ; <nl> while ( _state . isShuttingDown ( ) ) { <nl> writeLocker . unlock ( ) ; <nl> - std : : this_thread : : sleep_for ( std : : chrono : : microseconds ( 50 * 1000 ) ) ; <nl> + std : : this_thread : : sleep_for ( std : : chrono : : milliseconds ( 50 ) ) ; <nl> writeLocker . lock ( ) ; <nl> + if ( std : : chrono : : steady_clock : : now ( ) - start > std : : chrono : : minutes ( 1 ) ) { <nl> + LOG_TOPIC ( ERR , Logger : : REPLICATION ) < < " replication applier is not stopping " ; <nl> + TRI_ASSERT ( false ) ; <nl> + start = std : : chrono : : steady_clock : : now ( ) ; ; <nl> + } <nl> } <nl> <nl> TRI_ASSERT ( ! _state . isActive ( ) & & ! _state . isShuttingDown ( ) ) ; <nl> - <nl> / / wipe aborted flag . this will be passed on to the syncer <nl> static_cast < ApplierThread * > ( _thread . get ( ) ) - > setAborted ( false ) ; <nl> <nl> mmm a / arangod / Replication / Syncer . cpp <nl> ppp b / arangod / Replication / Syncer . cpp <nl> Result Syncer : : createView ( TRI_vocbase_t & vocbase , <nl> view = vocbase . lookupView ( nameSlice . copyString ( ) ) ; <nl> <nl> if ( view ) { / / resolve name conflict by deleting existing <nl> - Result res = vocbase . dropView ( view - > id ( ) , / * dropSytem * / false ) ; <nl> - <nl> + Result res = view - > drop ( ) ; <nl> if ( res . fail ( ) ) { <nl> return res ; <nl> } <nl> Result Syncer : : dropView ( arangodb : : velocypack : : Slice const & slice , <nl> } <nl> <nl> try { <nl> + TRI_ASSERT ( ! ServerState : : instance ( ) - > isCoordinator ( ) ) ; <nl> auto view = vocbase - > lookupView ( guidSlice . copyString ( ) ) ; <nl> - if ( view ! = nullptr ) { / / ignore non - existing <nl> - return vocbase - > dropView ( view - > id ( ) , false ) ; <nl> + if ( view ) { / / prevent dropping of system views ? <nl> + return view - > drop ( ) ; <nl> } <nl> } catch ( basics : : Exception const & ex ) { <nl> return Result ( ex . code ( ) , ex . what ( ) ) ; <nl> mmm a / arangod / RestHandler / RestViewHandler . cpp <nl> ppp b / arangod / RestHandler / RestViewHandler . cpp <nl> void RestViewHandler : : getView ( std : : string const & nameOrId , bool detailed ) { <nl> <nl> return ; <nl> } <nl> - <nl> + <nl> / / . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . <nl> / / end of parameter parsing <nl> / / . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . <nl> mmm a / arangod / RocksDBEngine / CMakeLists . txt <nl> ppp b / arangod / RocksDBEngine / CMakeLists . txt <nl> endif ( ) <nl> set ( ROCKSDB_SOURCES <nl> RocksDBEngine / RocksDBBackgroundThread . cpp <nl> RocksDBEngine / RocksDBCollection . cpp <nl> + RocksDBEngine / RocksDBCollectionMeta . cpp <nl> RocksDBEngine / RocksDBCommon . cpp <nl> RocksDBEngine / RocksDBComparator . cpp <nl> RocksDBEngine / RocksDBEdgeIndex . cpp <nl> mmm a / arangod / RocksDBEngine / RocksDBBackgroundThread . cpp <nl> ppp b / arangod / RocksDBEngine / RocksDBBackgroundThread . cpp <nl> void RocksDBBackgroundThread : : run ( ) { <nl> if ( _engine - > inRecovery ( ) ) { <nl> continue ; <nl> } <nl> + <nl> + TRI_IF_FAILURE ( " RocksDBBackgroundThread : : run " ) { continue ; } <nl> <nl> try { <nl> if ( ! isStopping ( ) ) { <nl> mmm a / arangod / RocksDBEngine / RocksDBCollection . cpp <nl> ppp b / arangod / RocksDBEngine / RocksDBCollection . cpp <nl> Result RocksDBCollection : : truncate ( transaction : : Methods * trx , <nl> RocksDBEngine * engine = rocksutils : : globalRocksEngine ( ) ; <nl> / / add the assertion again here , so we are sure we can use RangeDeletes <nl> TRI_ASSERT ( engine - > canUseRangeDeleteInWal ( ) ) ; <nl> + rocksdb : : DB * db = engine - > db ( ) - > GetRootDB ( ) ; <nl> + <nl> + TRI_IF_FAILURE ( " RocksDBCollection : : truncate : : forceSync " ) { <nl> + engine - > settingsManager ( ) - > sync ( false ) ; <nl> + } <nl> + <nl> + / / pre commit sequence needed to place a blocker <nl> + rocksdb : : SequenceNumber seq = rocksutils : : latestSequenceNumber ( ) ; <nl> + auto guard = scopeGuard ( [ & ] { / / remove blocker afterwards <nl> + _meta . removeBlocker ( state - > id ( ) ) ; <nl> + } ) ; <nl> + _meta . placeBlocker ( state - > id ( ) , seq ) ; <nl> <nl> rocksdb : : WriteBatch batch ; <nl> / / delete documents <nl> Result RocksDBCollection : : truncate ( transaction : : Methods * trx , <nl> if ( ! s . ok ( ) ) { <nl> return rocksutils : : convertStatus ( s ) ; <nl> } <nl> - <nl> - / / pre commit sequence needed to place a blocker <nl> - rocksdb : : SequenceNumber seq = rocksutils : : latestSequenceNumber ( ) ; <nl> - auto guard = scopeGuard ( [ & ] { / / remove blocker afterwards <nl> - READ_LOCKER ( guard , _indexesLock ) ; <nl> - for ( std : : shared_ptr < Index > const & idx : _indexes ) { <nl> - auto * est = static_cast < RocksDBIndex * > ( idx . get ( ) ) - > estimator ( ) ; <nl> - if ( est ) { <nl> - est - > removeBlocker ( state - > id ( ) ) ; <nl> - } <nl> - } <nl> - } ) ; <nl> <nl> / / delete indexes , place estimator blockers <nl> { <nl> Result RocksDBCollection : : truncate ( transaction : : Methods * trx , <nl> if ( ! s . ok ( ) ) { <nl> return rocksutils : : convertStatus ( s ) ; <nl> } <nl> - RocksDBCuckooIndexEstimator < uint64_t > * est = ridx - > estimator ( ) ; <nl> - if ( est ) { <nl> - est - > placeBlocker ( state - > id ( ) , seq ) ; <nl> - } <nl> } <nl> } <nl> <nl> - / / now add the log entry so we can recover the correct count <nl> + / / add the log entry so we can recover the correct count <nl> auto log = RocksDBLogValue : : CollectionTruncate ( trx - > vocbase ( ) . id ( ) , <nl> _logicalCollection . id ( ) , _objectId ) ; <nl> s = batch . PutLogData ( log . slice ( ) ) ; <nl> Result RocksDBCollection : : truncate ( transaction : : Methods * trx , <nl> } <nl> <nl> rocksdb : : WriteOptions wo ; <nl> - s = rocksutils : : globalRocksDB ( ) - > Write ( wo , & batch ) ; <nl> + s = db - > Write ( wo , & batch ) ; <nl> if ( ! s . ok ( ) ) { <nl> return rocksutils : : convertStatus ( s ) ; <nl> } <nl> - seq = rocksutils : : latestSequenceNumber ( ) ; / / post commit sequence <nl> + seq = db - > GetLatestSequenceNumber ( ) - 1 ; / / post commit sequence <nl> <nl> + uint64_t numDocs = _numberDocuments . exchange ( 0 ) ; <nl> + _meta . adjustNumberDocuments ( seq , / * revision * / newRevisionId ( ) , - static_cast < int64_t > ( numDocs ) ) ; <nl> { <nl> READ_LOCKER ( guard , _indexesLock ) ; <nl> for ( std : : shared_ptr < Index > const & idx : _indexes ) { <nl> idx - > afterTruncate ( seq ) ; / / clears caches / clears links ( if applicable ) <nl> } <nl> } <nl> + <nl> guard . fire ( ) ; / / remove blocker <nl> <nl> - uint64_t numDocs = _numberDocuments . exchange ( 0 ) ; <nl> - RocksDBSettingsManager : : CounterAdjustment update ( seq , / * numInserts * / 0 , <nl> - / * numRemoves * / numDocs , / * rev * / 0 ) ; <nl> - engine - > settingsManager ( ) - > updateCounter ( _objectId , update ) ; <nl> - <nl> if ( numDocs > 64 * 1024 ) { <nl> / / also compact the ranges in order to speed up all further accesses <nl> compact ( ) ; <nl> void RocksDBCollection : : adjustNumberDocuments ( TRI_voc_rid_t revId , <nl> if ( revId ! = 0 ) { <nl> _revisionId = revId ; <nl> } <nl> - if ( adjustment < 0 ) { <nl> + if ( adjustment < 0 ) { <nl> + TRI_ASSERT ( _numberDocuments > = static_cast < uint64_t > ( - adjustment ) ) ; <nl> _numberDocuments - = static_cast < uint64_t > ( - adjustment ) ; <nl> } else if ( adjustment > 0 ) { <nl> _numberDocuments + = static_cast < uint64_t > ( adjustment ) ; <nl> void RocksDBCollection : : adjustNumberDocuments ( TRI_voc_rid_t revId , <nl> <nl> / / / load the number of docs from storage , use careful <nl> void RocksDBCollection : : loadInitialNumberDocuments ( ) { <nl> - auto * engine = static_cast < RocksDBEngine * > ( EngineSelectorFeature : : ENGINE ) ; <nl> - auto counterValue = engine - > settingsManager ( ) - > loadCounter ( _objectId ) ; <nl> - _numberDocuments = counterValue . added ( ) - counterValue . removed ( ) ; <nl> - _revisionId = counterValue . revisionId ( ) ; <nl> + RocksDBCollectionMeta : : DocCount count = _meta . currentCount ( ) ; <nl> + TRI_ASSERT ( count . _added > = count . _removed ) ; <nl> + _numberDocuments = count . _added - count . _removed ; <nl> + _revisionId = count . _revisionId ; <nl> } <nl> <nl> / / / @ brief write locks a collection , with a timeout <nl> int RocksDBCollection : : unlockRead ( ) { <nl> <nl> / / rescans the collection to update document count <nl> uint64_t RocksDBCollection : : recalculateCounts ( ) { <nl> + <nl> + RocksDBEngine * engine = rocksutils : : globalRocksEngine ( ) ; <nl> + rocksdb : : TransactionDB * db = engine - > db ( ) ; <nl> + const rocksdb : : Snapshot * snapshot = nullptr ; <nl> / / start transaction to get a collection lock <nl> - auto ctx = <nl> - transaction : : StandaloneContext : : Create ( _logicalCollection . vocbase ( ) ) ; <nl> - SingleCollectionTransaction trx ( <nl> - ctx , _logicalCollection , AccessMode : : Type : : EXCLUSIVE <nl> - ) ; <nl> - auto res = trx . begin ( ) ; <nl> - <nl> - if ( res . fail ( ) ) { <nl> + TRI_vocbase_t & vocbase = _logicalCollection . vocbase ( ) ; <nl> + if ( ! vocbase . use ( ) ) { / / someone dropped the database <nl> + return numberDocuments ( ) ; <nl> + } <nl> + auto useGuard = scopeGuard ( [ & ] { <nl> + if ( snapshot ) { <nl> + db - > ReleaseSnapshot ( snapshot ) ; <nl> + } <nl> + vocbase . release ( ) ; <nl> + } ) ; <nl> + <nl> + TRI_vocbase_col_status_e status ; <nl> + int res = vocbase . useCollection ( & _logicalCollection , status ) ; <nl> + if ( res ! = TRI_ERROR_NO_ERROR ) { <nl> THROW_ARANGO_EXCEPTION ( res ) ; <nl> } <nl> + auto collGuard = scopeGuard ( [ & ] { <nl> + vocbase . releaseCollection ( & _logicalCollection ) ; <nl> + } ) ; <nl> <nl> - RocksDBEngine * engine = rocksutils : : globalRocksEngine ( ) ; <nl> + uint64_t snapNumberOfDocuments = 0 ; <nl> + { <nl> + / / fetch number docs and snapshot under exclusive lock <nl> + / / this should enable us to correct the count later <nl> + auto lockGuard = scopeGuard ( [ this ] { unlockWrite ( ) ; } ) ; <nl> + res = lockWrite ( transaction : : Options : : defaultLockTimeout ) ; <nl> + if ( res ! = TRI_ERROR_NO_ERROR ) { <nl> + lockGuard . cancel ( ) ; <nl> + THROW_ARANGO_EXCEPTION ( res ) ; <nl> + } <nl> + <nl> + snapNumberOfDocuments = numberDocuments ( ) ; <nl> + snapshot = engine - > db ( ) - > GetSnapshot ( ) ; <nl> + TRI_ASSERT ( snapshot ) ; <nl> + } <nl> + <nl> / / count documents <nl> - auto documentBounds = RocksDBKeyBounds : : CollectionDocuments ( _objectId ) ; <nl> - _numberDocuments = <nl> - rocksutils : : countKeyRange ( engine - > db ( ) , documentBounds , true ) ; <nl> + auto bounds = RocksDBKeyBounds : : CollectionDocuments ( _objectId ) ; <nl> + rocksdb : : Slice upper ( bounds . end ( ) ) ; <nl> + <nl> + rocksdb : : ReadOptions ro ; <nl> + ro . prefix_same_as_start = true ; <nl> + ro . iterate_upper_bound = & upper ; <nl> + ro . verify_checksums = false ; <nl> + ro . fill_cache = false ; <nl> + <nl> + rocksdb : : ColumnFamilyHandle * cf = bounds . columnFamily ( ) ; <nl> + std : : unique_ptr < rocksdb : : Iterator > it ( db - > NewIterator ( ro , cf ) ) ; <nl> + std : : size_t count = 0 ; <nl> + <nl> + it - > Seek ( bounds . start ( ) ) ; <nl> + while ( it - > Valid ( ) & & it - > key ( ) . compare ( upper ) < 0 ) { <nl> + + + count ; <nl> + it - > Next ( ) ; <nl> + } <nl> <nl> - / / update counter manager value <nl> - res = engine - > settingsManager ( ) - > setAbsoluteCounter ( _objectId , engine - > currentTick ( ) , <nl> - _numberDocuments ) ; <nl> - if ( res . ok ( ) ) { <nl> - / / in case of fail the counter has never been written and hence does not <nl> - / / need correction . The value is not changed and does not need to be synced <nl> - engine - > settingsManager ( ) - > sync ( true ) ; <nl> + int64_t adjustment = snapNumberOfDocuments - count ; <nl> + if ( adjustment ! = 0 ) { <nl> + LOG_TOPIC ( WARN , Logger : : REPLICATION ) < < " inconsistent collection count detected , " <nl> + < < " an offet of " < < adjustment < < " will be applied " ; <nl> + adjustNumberDocuments ( static_cast < TRI_voc_rid_t > ( 0 ) , adjustment ) ; <nl> } <nl> - trx . commit ( ) ; <nl> <nl> - return _numberDocuments ; <nl> + return numberDocuments ( ) ; <nl> } <nl> <nl> void RocksDBCollection : : compact ( ) { <nl> void RocksDBCollection : : estimateSize ( velocypack : : Builder & builder ) { <nl> builder . close ( ) ; <nl> } <nl> <nl> - std : : pair < arangodb : : Result , rocksdb : : SequenceNumber > <nl> - RocksDBCollection : : serializeIndexEstimates ( <nl> - rocksdb : : Transaction * rtrx , rocksdb : : SequenceNumber inputSeq ) const { <nl> - auto outputSeq = inputSeq ; <nl> - std : : string output ; <nl> - RocksDBKey key ; <nl> - <nl> - for ( auto index : getIndexes ( ) ) { <nl> - output . clear ( ) ; <nl> - RocksDBIndex * cindex = static_cast < RocksDBIndex * > ( index . get ( ) ) ; <nl> - TRI_ASSERT ( cindex ! = nullptr ) ; <nl> - <nl> - if ( cindex - > needToPersistEstimate ( ) ) { <nl> - LOG_TOPIC ( TRACE , Logger : : ENGINES ) <nl> - < < " beginning estimate serialization for index ' " <nl> - < < cindex - > objectId ( ) < < " ' " ; <nl> - auto committedSeq = cindex - > serializeEstimate ( output , inputSeq ) ; <nl> - outputSeq = std : : min ( outputSeq , committedSeq ) ; <nl> - LOG_TOPIC ( TRACE , Logger : : ENGINES ) <nl> - < < " serialized estimate for index ' " < < cindex - > objectId ( ) <nl> - < < " ' valid through seq " < < outputSeq ; <nl> - if ( output . size ( ) > sizeof ( uint64_t ) ) { <nl> - key . constructIndexEstimateValue ( cindex - > objectId ( ) ) ; <nl> - rocksdb : : Slice value ( output ) ; <nl> - rocksdb : : Status s = <nl> - rtrx - > Put ( RocksDBColumnFamily : : definitions ( ) , key . string ( ) , value ) ; <nl> - <nl> - if ( ! s . ok ( ) ) { <nl> - LOG_TOPIC ( WARN , Logger : : ENGINES ) < < " writing index estimates failed " ; <nl> - rtrx - > Rollback ( ) ; <nl> - return std : : make_pair ( rocksutils : : convertStatus ( s ) , outputSeq ) ; <nl> - } <nl> - } <nl> - } <nl> - } <nl> - return std : : make_pair ( Result ( ) , outputSeq ) ; <nl> - } <nl> - <nl> - void RocksDBCollection : : deserializeIndexEstimates ( RocksDBSettingsManager * mgr ) { <nl> - std : : vector < std : : shared_ptr < Index > > toRecalculate ; <nl> - for ( auto const & it : getIndexes ( ) ) { <nl> - auto idx = static_cast < RocksDBIndex * > ( it . get ( ) ) ; <nl> - if ( ! idx - > deserializeEstimate ( mgr ) ) { <nl> - toRecalculate . push_back ( it ) ; <nl> - } <nl> - } <nl> - if ( ! toRecalculate . empty ( ) ) { <nl> - recalculateIndexEstimates ( toRecalculate ) ; <nl> - } <nl> - } <nl> - <nl> - void RocksDBCollection : : recalculateIndexEstimates ( ) { <nl> - auto idxs = getIndexes ( ) ; <nl> - recalculateIndexEstimates ( idxs ) ; <nl> - } <nl> - <nl> - void RocksDBCollection : : recalculateIndexEstimates ( <nl> - std : : vector < std : : shared_ptr < Index > > const & indexes ) { <nl> - / / IMPORTANT if this method is called outside of startup / recovery , we may have <nl> - / / issues with estimate integrity ; please do not expose via a user - facing <nl> - / / method or endpoint unless the implementation changes <nl> - <nl> - / / intentionally do not use transactions here , as we will only be called <nl> - / / during recovery <nl> - RocksDBEngine * engine = <nl> - static_cast < RocksDBEngine * > ( EngineSelectorFeature : : ENGINE ) ; <nl> - TRI_ASSERT ( engine ! = nullptr ) ; <nl> - TRI_ASSERT ( engine - > inRecovery ( ) ) ; <nl> - <nl> - for ( auto const & it : indexes ) { <nl> - auto idx = static_cast < RocksDBIndex * > ( it . get ( ) ) ; <nl> - <nl> - TRI_ASSERT ( idx ! = nullptr ) ; <nl> - idx - > recalculateEstimates ( ) ; <nl> - } <nl> - } <nl> - <nl> - arangodb : : Result RocksDBCollection : : serializeKeyGenerator ( <nl> - rocksdb : : Transaction * rtrx ) const { <nl> - if ( ! _logicalCollection . keyGenerator ( ) - > hasDynamicState ( ) ) { <nl> - / / the key generator will not produce any dynamic data , <nl> - / / so it does not need to be serialized ( nor recovered ) <nl> - return Result ( ) ; <nl> - } <nl> - <nl> - VPackBuilder builder ; <nl> - <nl> - builder . openObject ( ) ; <nl> - _logicalCollection . keyGenerator ( ) - > toVelocyPack ( builder ) ; <nl> - builder . close ( ) ; <nl> - <nl> - RocksDBKey key ; <nl> - <nl> - key . constructKeyGeneratorValue ( _objectId ) ; <nl> - <nl> - RocksDBValue value = RocksDBValue : : KeyGeneratorValue ( builder . slice ( ) ) ; <nl> - rocksdb : : Status s = rtrx - > Put ( RocksDBColumnFamily : : definitions ( ) , <nl> - key . string ( ) , value . string ( ) ) ; <nl> - <nl> - if ( ! s . ok ( ) ) { <nl> - LOG_TOPIC ( WARN , Logger : : ENGINES ) < < " writing key generator data failed " ; <nl> - rtrx - > Rollback ( ) ; <nl> - return rocksutils : : convertStatus ( s ) ; <nl> - } <nl> - <nl> - return Result ( ) ; <nl> - } <nl> - <nl> - void RocksDBCollection : : deserializeKeyGenerator ( RocksDBSettingsManager * mgr ) { <nl> - uint64_t value = mgr - > stealKeyGenerator ( _objectId ) ; <nl> - <nl> - if ( value > 0 ) { <nl> - std : : string k ( basics : : StringUtils : : itoa ( value ) ) ; <nl> - _logicalCollection . keyGenerator ( ) - > track ( k . data ( ) , k . size ( ) ) ; <nl> - } <nl> - } <nl> - <nl> void RocksDBCollection : : createCache ( ) const { <nl> if ( ! _cacheEnabled | | _cachePresent | | _logicalCollection . isAStub ( ) | | <nl> ServerState : : instance ( ) - > isCoordinator ( ) ) { <nl> mmm a / arangod / RocksDBEngine / RocksDBCollection . h <nl> ppp b / arangod / RocksDBEngine / RocksDBCollection . h <nl> <nl> <nl> # include " Basics / Common . h " <nl> # include " Basics / ReadWriteLock . h " <nl> - # include " Indexes / IndexLookupContext . h " <nl> # include " RocksDBEngine / RocksDBCommon . h " <nl> + # include " RocksDBEngine / RocksDBCollectionMeta . h " <nl> # include " StorageEngine / PhysicalCollection . h " <nl> # include " VocBase / LogicalCollection . h " <nl> <nl> class RocksDBCollection final : public PhysicalCollection { <nl> void adjustNumberDocuments ( TRI_voc_rid_t revisionId , int64_t adjustment ) ; <nl> / / / load the number of docs from storage <nl> void loadInitialNumberDocuments ( ) ; <nl> - <nl> + <nl> uint64_t objectId ( ) const { return _objectId ; } <nl> <nl> int lockWrite ( double timeout = 0 . 0 ) ; <nl> class RocksDBCollection final : public PhysicalCollection { <nl> void compact ( ) ; <nl> void estimateSize ( velocypack : : Builder & builder ) ; <nl> <nl> - std : : pair < Result , rocksdb : : SequenceNumber > serializeIndexEstimates ( <nl> - rocksdb : : Transaction * , rocksdb : : SequenceNumber ) const ; <nl> - void deserializeIndexEstimates ( arangodb : : RocksDBSettingsManager * mgr ) ; <nl> - <nl> - void recalculateIndexEstimates ( ) ; <nl> - <nl> - Result serializeKeyGenerator ( rocksdb : : Transaction * ) const ; <nl> - void deserializeKeyGenerator ( arangodb : : RocksDBSettingsManager * mgr ) ; <nl> - <nl> inline bool cacheEnabled ( ) const { return _cacheEnabled ; } <nl> + <nl> + RocksDBCollectionMeta & meta ( ) { return _meta ; } <nl> <nl> private : <nl> / / / @ brief track the usage of waitForSync option in an operation <nl> class RocksDBCollection final : public PhysicalCollection { <nl> LocalDocumentId const & documentId , transaction : : Methods * , <nl> IndexIterator : : DocumentCallback const & cb , bool withCache ) const ; <nl> <nl> - void recalculateIndexEstimates ( <nl> - std : : vector < std : : shared_ptr < Index > > const & indexes ) ; <nl> - <nl> void createCache ( ) const ; <nl> <nl> void destroyCache ( ) const ; <nl> class RocksDBCollection final : public PhysicalCollection { <nl> <nl> private : <nl> uint64_t const _objectId ; / / rocksdb - specific object id for collection <nl> + RocksDBCollectionMeta _meta ; / / / collection metadata <nl> + <nl> std : : atomic < uint64_t > _numberDocuments ; <nl> std : : atomic < TRI_voc_rid_t > _revisionId ; <nl> <nl> - / / / cache the primary index for performance , do not delete <nl> + / / / @ brief cached ptr to primary index for performance , never delete <nl> RocksDBPrimaryIndex * _primaryIndex ; <nl> - <nl> + / / / @ brief collection lock used for write access <nl> mutable basics : : ReadWriteLock _exclusiveLock ; <nl> + / / / @ brief document cache ( optional ) <nl> mutable std : : shared_ptr < cache : : Cache > _cache ; <nl> - <nl> / / we use this boolean for testing whether _cache is set . <nl> / / it ' s quicker than accessing the shared_ptr each time <nl> mutable bool _cachePresent ; <nl> new file mode 100644 <nl> index 00000000000 . . 8dcf299e686 <nl> mmm / dev / null <nl> ppp b / arangod / RocksDBEngine / RocksDBCollectionMeta . cpp <nl> <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / DISCLAIMER <nl> + / / / <nl> + / / / Copyright 2018 ArangoDB GmbH , Cologne , Germany <nl> + / / / <nl> + / / / Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + / / / you may not use this file except in compliance with the License . <nl> + / / / You may obtain a copy of the License at <nl> + / / / <nl> + / / / http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + / / / <nl> + / / / Unless required by applicable law or agreed to in writing , software <nl> + / / / distributed under the License is distributed on an " AS IS " BASIS , <nl> + / / / WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + / / / See the License for the specific language governing permissions and <nl> + / / / limitations under the License . <nl> + / / / <nl> + / / / Copyright holder is ArangoDB GmbH , Cologne , Germany <nl> + / / / <nl> + / / / @ author Simon Grätzer <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + # include " RocksDBCollectionMeta . h " <nl> + <nl> + # include " Basics / ReadLocker . h " <nl> + # include " Basics / WriteLocker . h " <nl> + # include " RocksDBEngine / RocksDBColumnFamily . h " <nl> + # include " RocksDBEngine / RocksDBCollection . h " <nl> + # include " RocksDBEngine / RocksDBCuckooIndexEstimator . h " <nl> + # include " RocksDBEngine / RocksDBIndex . h " <nl> + # include " VocBase / KeyGenerator . h " <nl> + # include " VocBase / LogicalCollection . h " <nl> + <nl> + # include < rocksdb / db . h > <nl> + # include < rocksdb / utilities / transaction . h > <nl> + <nl> + # include < velocypack / Iterator . h > <nl> + # include < velocypack / velocypack - aliases . h > <nl> + <nl> + using namespace arangodb ; <nl> + <nl> + RocksDBCollectionMeta : : DocCount : : DocCount ( VPackSlice const & slice ) <nl> + : _committedSeq ( 0 ) , _added ( 0 ) , _removed ( 0 ) , _revisionId ( 0 ) { <nl> + if ( ! slice . isArray ( ) ) { <nl> + / / got a somewhat invalid slice . probably old data from before the key <nl> + / / structure changes <nl> + return ; <nl> + } <nl> + <nl> + VPackArrayIterator array ( slice ) ; <nl> + if ( array . valid ( ) ) { <nl> + this - > _committedSeq = ( * array ) . getUInt ( ) ; <nl> + / / versions pre 3 . 4 stored only a single " count " value <nl> + / / 3 . 4 and higher store " added " and " removed " seperately <nl> + this - > _added = ( * ( + + array ) ) . getUInt ( ) ; <nl> + if ( array . size ( ) > 3 ) { <nl> + TRI_ASSERT ( array . size ( ) = = 4 ) ; <nl> + this - > _removed = ( * ( + + array ) ) . getUInt ( ) ; <nl> + } <nl> + this - > _revisionId = ( * ( + + array ) ) . getUInt ( ) ; <nl> + } <nl> + } <nl> + <nl> + void RocksDBCollectionMeta : : DocCount : : toVelocyPack ( VPackBuilder & b ) const { <nl> + b . openArray ( ) ; <nl> + b . add ( VPackValue ( _committedSeq ) ) ; <nl> + b . add ( VPackValue ( _added ) ) ; <nl> + b . add ( VPackValue ( _removed ) ) ; <nl> + b . add ( VPackValue ( _revisionId ) ) ; <nl> + b . close ( ) ; <nl> + } <nl> + <nl> + RocksDBCollectionMeta : : RocksDBCollectionMeta ( ) <nl> + : _count ( 0 , 0 , 0 , 0 ) { } <nl> + <nl> + / * * <nl> + * @ brief Place a blocker to allow proper commit / serialize semantics <nl> + * <nl> + * Should be called immediately prior to internal RocksDB commit . If the <nl> + * commit succeeds , any inserts / removals should be buffered , then the blocker <nl> + * removed ; otherwise simply remove the blocker . <nl> + * <nl> + * @ param trxId The identifier for the active transaction <nl> + * @ param seq The sequence number immediately prior to call <nl> + * @ return May return error if we fail to allocate and place blocker <nl> + * / <nl> + Result RocksDBCollectionMeta : : placeBlocker ( uint64_t trxId , rocksdb : : SequenceNumber seq ) { <nl> + return basics : : catchToResult ( [ & ] ( ) - > Result { <nl> + Result res ; <nl> + WRITE_LOCKER ( locker , _blockerLock ) ; <nl> + <nl> + TRI_ASSERT ( _blockers . end ( ) = = _blockers . find ( trxId ) ) ; <nl> + TRI_ASSERT ( _blockersBySeq . end ( ) = = <nl> + _blockersBySeq . find ( std : : make_pair ( seq , trxId ) ) ) ; <nl> + <nl> + auto insert = _blockers . emplace ( trxId , seq ) ; <nl> + auto crosslist = _blockersBySeq . emplace ( seq , trxId ) ; <nl> + if ( ! insert . second | | ! crosslist . second ) { <nl> + return res . reset ( TRI_ERROR_INTERNAL ) ; <nl> + } <nl> + return res ; <nl> + } ) ; <nl> + } <nl> + <nl> + / * * <nl> + * @ brief Removes an existing transaction blocker <nl> + * <nl> + * Should be called after transaction abort / rollback , or after buffering any <nl> + * updates in case of successful commit . If no blocker exists with the <nl> + * specified transaction identifier , then this will simply do nothing . <nl> + * <nl> + * @ param trxId Identifier for active transaction ( should match input to <nl> + * earlier ` placeBlocker ` call ) <nl> + * / <nl> + void RocksDBCollectionMeta : : removeBlocker ( uint64_t trxId ) { <nl> + WRITE_LOCKER ( locker , _blockerLock ) ; <nl> + auto it = _blockers . find ( trxId ) ; <nl> + if ( ADB_LIKELY ( _blockers . end ( ) ! = it ) ) { <nl> + auto cross = _blockersBySeq . find ( std : : make_pair ( it - > second , it - > first ) ) ; <nl> + TRI_ASSERT ( _blockersBySeq . end ( ) ! = cross ) ; <nl> + if ( ADB_LIKELY ( _blockersBySeq . end ( ) ! = cross ) ) { <nl> + _blockersBySeq . erase ( cross ) ; <nl> + } <nl> + _blockers . erase ( it ) ; <nl> + } <nl> + } <nl> + <nl> + / / / @ brief updates and returns the largest safe seq to squash updated against <nl> + rocksdb : : SequenceNumber RocksDBCollectionMeta : : committableSeq ( ) const { <nl> + READ_LOCKER ( locker , _blockerLock ) ; <nl> + / / if we have a blocker use the lowest counter <nl> + if ( ! _blockersBySeq . empty ( ) ) { <nl> + auto it = _blockersBySeq . begin ( ) ; <nl> + return it - > first ; <nl> + } <nl> + return std : : numeric_limits < rocksdb : : SequenceNumber > : : max ( ) ; <nl> + } <nl> + <nl> + rocksdb : : SequenceNumber RocksDBCollectionMeta : : applyAdjustments ( rocksdb : : SequenceNumber commitSeq , <nl> + bool & didWork ) { <nl> + rocksdb : : SequenceNumber appliedSeq = _count . _committedSeq ; <nl> + <nl> + decltype ( _bufferedAdjs ) swapper ; <nl> + { <nl> + std : : lock_guard < std : : mutex > guard ( _countLock ) ; <nl> + if ( _stagedAdjs . empty ( ) ) { <nl> + _stagedAdjs . swap ( _bufferedAdjs ) ; <nl> + } else { <nl> + swapper . swap ( _bufferedAdjs ) ; <nl> + } <nl> + } <nl> + if ( ! swapper . empty ( ) ) { <nl> + _stagedAdjs . insert ( swapper . begin ( ) , swapper . end ( ) ) ; <nl> + } <nl> + <nl> + auto it = _stagedAdjs . begin ( ) ; <nl> + while ( it ! = _stagedAdjs . end ( ) & & it - > first < commitSeq ) { <nl> + appliedSeq = std : : max ( appliedSeq , it - > first ) ; <nl> + if ( it - > second . adjustment > 0 ) { <nl> + _count . _added + = it - > second . adjustment ; <nl> + } else if ( it - > second . adjustment < 0 ) { <nl> + _count . _removed + = - ( it - > second . adjustment ) ; <nl> + } <nl> + if ( it - > second . revisionId ! = 0 ) { <nl> + _count . _revisionId = it - > second . revisionId ; <nl> + } <nl> + it = _stagedAdjs . erase ( it ) ; <nl> + didWork = true ; <nl> + } <nl> + _count . _committedSeq = appliedSeq ; <nl> + return appliedSeq ; <nl> + } <nl> + <nl> + / / / @ brief get the current count <nl> + RocksDBCollectionMeta : : DocCount RocksDBCollectionMeta : : currentCount ( ) { <nl> + <nl> + bool didWork = false ; <nl> + const rocksdb : : SequenceNumber commitSeq = committableSeq ( ) ; <nl> + rocksdb : : SequenceNumber seq = applyAdjustments ( commitSeq , didWork ) ; <nl> + if ( didWork ) { / / make sure serializeMeta has something to do <nl> + std : : lock_guard < std : : mutex > guard ( _countLock ) ; <nl> + _bufferedAdjs . emplace ( seq , Adjustment { 0 , 0 } ) ; <nl> + } <nl> + <nl> + return _count ; <nl> + } <nl> + <nl> + / / / @ brief buffer a counter adjustment <nl> + void RocksDBCollectionMeta : : adjustNumberDocuments ( rocksdb : : SequenceNumber seq , <nl> + TRI_voc_rid_t revId , int64_t adj ) { <nl> + TRI_ASSERT ( seq ! = 0 & & ( adj | | revId ) ) ; <nl> + std : : lock_guard < std : : mutex > guard ( _countLock ) ; <nl> + _bufferedAdjs . emplace ( seq , Adjustment { revId , adj } ) ; <nl> + } <nl> + <nl> + / / / @ brief serialize the collection metadata <nl> + Result RocksDBCollectionMeta : : serializeMeta ( rocksdb : : WriteBatch & batch , LogicalCollection & coll , <nl> + bool force , VPackBuilder & tmp , <nl> + rocksdb : : SequenceNumber & appliedSeq ) { <nl> + Result res ; <nl> + <nl> + bool didWork = false ; <nl> + const rocksdb : : SequenceNumber maxCommitSeq = committableSeq ( ) ; <nl> + rocksdb : : SequenceNumber seq = applyAdjustments ( maxCommitSeq , didWork ) ; <nl> + if ( didWork ) { <nl> + appliedSeq = std : : min ( appliedSeq , seq ) ; <nl> + } else { / / maxCommitSeq is = = UINT64_MAX without any blockers <nl> + appliedSeq = std : : min ( appliedSeq , maxCommitSeq ) ; <nl> + } <nl> + <nl> + RocksDBKey key ; <nl> + rocksdb : : ColumnFamilyHandle * const cf = RocksDBColumnFamily : : definitions ( ) ; <nl> + RocksDBCollection * const rcoll = static_cast < RocksDBCollection * > ( coll . getPhysical ( ) ) ; <nl> + <nl> + / / Step 1 . store the document count <nl> + tmp . clear ( ) ; <nl> + if ( didWork | | force ) { <nl> + _count . toVelocyPack ( tmp ) ; <nl> + key . constructCounterValue ( rcoll - > objectId ( ) ) ; <nl> + rocksdb : : Slice value ( ( char * ) tmp . start ( ) , tmp . size ( ) ) ; <nl> + rocksdb : : Status s = batch . Put ( cf , key . string ( ) , value ) ; <nl> + if ( ! s . ok ( ) ) { <nl> + LOG_TOPIC ( WARN , Logger : : ENGINES ) <nl> + < < " writing counter for collection with objectId ' " < < rcoll - > objectId ( ) <nl> + < < " ' failed : " < < s . ToString ( ) ; <nl> + return res . reset ( rocksutils : : convertStatus ( s ) ) ; <nl> + } <nl> + } <nl> + <nl> + if ( coll . deleted ( ) ) { <nl> + return Result ( ) ; <nl> + } <nl> + <nl> + / / Step 2 . store the key generator <nl> + KeyGenerator * keyGen = coll . keyGenerator ( ) ; <nl> + if ( ( didWork | | force ) & & keyGen - > hasDynamicState ( ) ) { <nl> + / / only a key generator with dynamic data needs to be recovered <nl> + key . constructKeyGeneratorValue ( rcoll - > objectId ( ) ) ; <nl> + <nl> + tmp . clear ( ) ; <nl> + tmp . openObject ( ) ; <nl> + keyGen - > toVelocyPack ( tmp ) ; <nl> + tmp . close ( ) ; <nl> + <nl> + RocksDBValue value = RocksDBValue : : KeyGeneratorValue ( tmp . slice ( ) ) ; <nl> + rocksdb : : Status s = batch . Put ( cf , key . string ( ) , value . string ( ) ) ; <nl> + LOG_TOPIC ( TRACE , Logger : : ENGINES ) < < " writing key generator coll " < < coll . name ( ) ; <nl> + <nl> + if ( ! s . ok ( ) ) { <nl> + LOG_TOPIC ( WARN , Logger : : ENGINES ) < < " writing key generator data failed " ; <nl> + return res . reset ( rocksutils : : convertStatus ( s ) ) ; <nl> + } <nl> + } <nl> + <nl> + if ( coll . deleted ( ) ) { <nl> + return Result ( ) ; <nl> + } <nl> + <nl> + / / Step 3 . store the index estimates <nl> + std : : string output ; <nl> + auto indexes = coll . getIndexes ( ) ; <nl> + for ( std : : shared_ptr < arangodb : : Index > & index : indexes ) { <nl> + RocksDBIndex * idx = static_cast < RocksDBIndex * > ( index . get ( ) ) ; <nl> + RocksDBCuckooIndexEstimator < uint64_t > * est = idx - > estimator ( ) ; <nl> + if ( est = = nullptr ) { / / does not have an estimator <nl> + continue ; <nl> + } <nl> + if ( coll . deleted ( ) ) { <nl> + return Result ( ) ; <nl> + } <nl> + <nl> + if ( est - > needToPersist ( ) | | force ) { <nl> + LOG_TOPIC ( TRACE , Logger : : ENGINES ) <nl> + < < " beginning estimate serialization for index ' " < < idx - > objectId ( ) < < " ' " ; <nl> + output . clear ( ) ; <nl> + <nl> + seq = est - > serialize ( output , maxCommitSeq ) ; <nl> + / / calculate retention sequence number <nl> + appliedSeq = std : : min ( appliedSeq , seq ) ; <nl> + TRI_ASSERT ( output . size ( ) > sizeof ( uint64_t ) ) ; <nl> + <nl> + LOG_TOPIC ( TRACE , Logger : : ENGINES ) <nl> + < < " serialized estimate for index ' " < < idx - > objectId ( ) <nl> + < < " ' valid through seq " < < seq ; <nl> + <nl> + key . constructIndexEstimateValue ( idx - > objectId ( ) ) ; <nl> + rocksdb : : Slice value ( output ) ; <nl> + rocksdb : : Status s = batch . Put ( cf , key . string ( ) , value ) ; <nl> + if ( ! s . ok ( ) ) { <nl> + LOG_TOPIC ( WARN , Logger : : ENGINES ) < < " writing index estimates failed " ; <nl> + return res . reset ( rocksutils : : convertStatus ( s ) ) ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + return res ; <nl> + } <nl> + <nl> + / / / @ brief deserialize collection metadata , only called on startup <nl> + Result RocksDBCollectionMeta : : deserializeMeta ( rocksdb : : DB * db , LogicalCollection & coll ) { <nl> + RocksDBCollection * rcoll = static_cast < RocksDBCollection * > ( coll . getPhysical ( ) ) ; <nl> + <nl> + / / Step 1 . load the counter <nl> + auto cf = RocksDBColumnFamily : : definitions ( ) ; <nl> + rocksdb : : ReadOptions ro ; <nl> + ro . fill_cache = false ; <nl> + <nl> + RocksDBKey key ; <nl> + key . constructCounterValue ( rcoll - > objectId ( ) ) ; <nl> + <nl> + rocksdb : : PinnableSlice value ; <nl> + rocksdb : : Status s = db - > Get ( ro , cf , key . string ( ) , & value ) ; <nl> + if ( s . ok ( ) ) { <nl> + VPackSlice countSlice = RocksDBValue : : data ( value ) ; <nl> + _count = RocksDBCollectionMeta : : DocCount ( countSlice ) ; <nl> + } else if ( ! s . IsNotFound ( ) ) { <nl> + return rocksutils : : convertStatus ( s ) ; <nl> + } <nl> + <nl> + / / Step 2 . load the key generator <nl> + KeyGenerator * keyGen = coll . keyGenerator ( ) ; <nl> + if ( keyGen - > hasDynamicState ( ) ) { <nl> + / / only a key generator with dynamic data needs to be recovered <nl> + key . constructKeyGeneratorValue ( rcoll - > objectId ( ) ) ; <nl> + s = db - > Get ( ro , cf , key . string ( ) , & value ) ; <nl> + if ( s . ok ( ) ) { <nl> + <nl> + VPackSlice keyGenProps = RocksDBValue : : data ( value ) ; <nl> + TRI_ASSERT ( keyGenProps . isObject ( ) ) ; <nl> + / / simon : wtf who decided this is a good deserialization routine ? ! <nl> + VPackSlice val = keyGenProps . get ( StaticStrings : : LastValue ) ; <nl> + if ( val . isString ( ) ) { <nl> + VPackValueLength size ; <nl> + const char * data = val . getString ( size ) ; <nl> + keyGen - > track ( data , size ) ; <nl> + } else if ( val . isInteger ( ) ) { <nl> + uint64_t lastValue = val . getUInt ( ) ; <nl> + std : : string str = std : : to_string ( lastValue ) ; <nl> + keyGen - > track ( str . data ( ) , str . size ( ) ) ; <nl> + } <nl> + <nl> + } else if ( ! s . IsNotFound ( ) ) { <nl> + return rocksutils : : convertStatus ( s ) ; <nl> + } <nl> + } <nl> + <nl> + / / Step 3 . load the index estimates <nl> + auto indexes = coll . getIndexes ( ) ; <nl> + for ( std : : shared_ptr < arangodb : : Index > & index : indexes ) { <nl> + RocksDBIndex * idx = static_cast < RocksDBIndex * > ( index . get ( ) ) ; <nl> + if ( idx - > estimator ( ) = = nullptr ) { <nl> + continue ; <nl> + } <nl> + <nl> + key . constructIndexEstimateValue ( idx - > objectId ( ) ) ; <nl> + s = db - > Get ( ro , cf , key . string ( ) , & value ) ; <nl> + if ( ! s . ok ( ) & & ! s . IsNotFound ( ) ) { <nl> + return rocksutils : : convertStatus ( s ) ; <nl> + } else if ( s . IsNotFound ( ) ) { / / expected with nosync recovery tests <nl> + LOG_TOPIC ( WARN , Logger : : ROCKSDB ) < < " recalculating index estimate for index " <nl> + < < " type ' " < < idx - > typeName ( ) < < " ' with id ' " < < idx - > id ( ) < < " ' " ; <nl> + idx - > recalculateEstimates ( ) ; <nl> + continue ; <nl> + } <nl> + <nl> + StringRef estimateInput ( value . data ( ) + sizeof ( uint64_t ) , <nl> + value . size ( ) - sizeof ( uint64_t ) ) ; <nl> + <nl> + uint64_t committedSeq = rocksutils : : uint64FromPersistent ( value . data ( ) ) ; <nl> + if ( RocksDBCuckooIndexEstimator < uint64_t > : : isFormatSupported ( estimateInput ) ) { <nl> + TRI_ASSERT ( committedSeq < = db - > GetLatestSequenceNumber ( ) ) ; <nl> + <nl> + auto est = std : : make_unique < RocksDBCuckooIndexEstimator < uint64_t > > ( committedSeq , estimateInput ) ; <nl> + LOG_TOPIC ( ERR , Logger : : ENGINES ) <nl> + < < " found index estimator for objectId ' " < < idx - > objectId ( ) <nl> + < < " ' committed seqNr ' " < < committedSeq < < " ' with estimate " <nl> + < < est - > computeEstimate ( ) ; <nl> + <nl> + idx - > setEstimator ( std : : move ( est ) ) ; <nl> + } else { <nl> + LOG_TOPIC ( ERR , Logger : : ENGINES ) < < " unsupported index estimator format in index " <nl> + < < " with objectId ' " < < idx - > objectId ( ) < < " ' " ; <nl> + } <nl> + } <nl> + <nl> + return Result ( ) ; <nl> + } <nl> + <nl> + / / / @ brief load collection <nl> + / * static * / RocksDBCollectionMeta : : DocCount <nl> + RocksDBCollectionMeta : : loadCollectionCount ( rocksdb : : DB * db , uint64_t objectId ) { <nl> + <nl> + auto cf = RocksDBColumnFamily : : definitions ( ) ; <nl> + rocksdb : : ReadOptions ro ; <nl> + ro . fill_cache = false ; <nl> + <nl> + RocksDBKey key ; <nl> + key . constructCounterValue ( objectId ) ; <nl> + <nl> + rocksdb : : PinnableSlice value ; <nl> + rocksdb : : Status s = db - > Get ( ro , cf , key . string ( ) , & value ) ; <nl> + if ( s . ok ( ) ) { <nl> + VPackSlice countSlice = RocksDBValue : : data ( value ) ; <nl> + return RocksDBCollectionMeta : : DocCount ( countSlice ) ; <nl> + } <nl> + return DocCount ( 0 , 0 , 0 , 0 ) ; <nl> + } <nl> + <nl> + / / / @ brief remove collection metadata <nl> + / * static * / Result RocksDBCollectionMeta : : deleteCollectionMeta ( rocksdb : : DB * db , uint64_t objectId ) { <nl> + <nl> + <nl> + rocksdb : : ColumnFamilyHandle * const cf = RocksDBColumnFamily : : definitions ( ) ; <nl> + rocksdb : : WriteOptions wo ; <nl> + <nl> + / / Step 1 . delete the document count <nl> + RocksDBKey key ; <nl> + key . constructCounterValue ( objectId ) ; <nl> + rocksdb : : Status s = db - > Delete ( wo , cf , key . string ( ) ) ; <nl> + if ( ! s . ok ( ) ) { <nl> + LOG_TOPIC ( ERR , Logger : : ENGINES ) < < " could not delete counter value : " < < s . ToString ( ) ; <nl> + / / try to remove the key generator value regardless <nl> + } <nl> + <nl> + key . constructKeyGeneratorValue ( objectId ) ; <nl> + s = db - > Delete ( wo , cf , key . string ( ) ) ; <nl> + if ( ! s . ok ( ) & & ! s . IsNotFound ( ) ) { <nl> + LOG_TOPIC ( ERR , Logger : : ENGINES ) < < " could not delete key generator value : " < < s . ToString ( ) ; <nl> + return rocksutils : : convertStatus ( s ) ; <nl> + } <nl> + <nl> + return Result ( ) ; <nl> + } <nl> + <nl> + / / / @ brief remove collection index estimate <nl> + / * static * / Result RocksDBCollectionMeta : : deleteIndexEstimate ( rocksdb : : DB * db , uint64_t objectId ) { <nl> + <nl> + rocksdb : : ColumnFamilyHandle * const cf = RocksDBColumnFamily : : definitions ( ) ; <nl> + rocksdb : : WriteOptions wo ; <nl> + <nl> + RocksDBKey key ; <nl> + key . constructIndexEstimateValue ( objectId ) ; <nl> + rocksdb : : Status s = db - > Delete ( wo , cf , key . string ( ) ) ; <nl> + if ( ! s . ok ( ) & & ! s . IsNotFound ( ) ) { <nl> + return rocksutils : : convertStatus ( s ) ; <nl> + } <nl> + return Result ( ) ; <nl> + } <nl> new file mode 100644 <nl> index 00000000000 . . bff1e6a946e <nl> mmm / dev / null <nl> ppp b / arangod / RocksDBEngine / RocksDBCollectionMeta . h <nl> <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / DISCLAIMER <nl> + / / / <nl> + / / / Copyright 2018 ArangoDB GmbH , Cologne , Germany <nl> + / / / <nl> + / / / Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + / / / you may not use this file except in compliance with the License . <nl> + / / / You may obtain a copy of the License at <nl> + / / / <nl> + / / / http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + / / / <nl> + / / / Unless required by applicable law or agreed to in writing , software <nl> + / / / distributed under the License is distributed on an " AS IS " BASIS , <nl> + / / / WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + / / / See the License for the specific language governing permissions and <nl> + / / / limitations under the License . <nl> + / / / <nl> + / / / Copyright holder is ArangoDB GmbH , Cologne , Germany <nl> + / / / <nl> + / / / @ author Simon Grätzer <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + # ifndef ARANGOD_ROCKSDB_ENGINE_ROCKSDB_COLLECTION_META_H <nl> + # define ARANGOD_ROCKSDB_ENGINE_ROCKSDB_COLLECTION_META_H 1 <nl> + <nl> + # include " Basics / Result . h " <nl> + # include " Basics / ReadWriteLock . h " <nl> + # include " VocBase / voc - types . h " <nl> + <nl> + # include < mutex > <nl> + <nl> + # include < rocksdb / types . h > <nl> + <nl> + # include < velocypack / Builder . h > <nl> + # include < velocypack / Slice . h > <nl> + <nl> + namespace rocksdb { <nl> + class DB ; <nl> + class WriteBatch ; <nl> + } <nl> + <nl> + namespace arangodb { <nl> + <nl> + class LogicalCollection ; <nl> + class RocksDBCollection ; <nl> + class RocksDBRecoveryManager ; <nl> + <nl> + / / / @ brief metadata used by the index estimates and collection counts <nl> + / / / transaction to verify <nl> + struct RocksDBCollectionMeta final { <nl> + friend class RocksDBRecoveryManager ; <nl> + <nl> + / / / @ brief collection count <nl> + struct DocCount { <nl> + / / / @ brief safe sequence number for recovery <nl> + rocksdb : : SequenceNumber _committedSeq ; <nl> + / / / @ brief number of added documents <nl> + uint64_t _added ; <nl> + / / / @ brief number of removed documents <nl> + uint64_t _removed ; <nl> + / / / @ brief last used revision id <nl> + TRI_voc_rid_t _revisionId ; <nl> + <nl> + DocCount ( rocksdb : : SequenceNumber sq , uint64_t added , <nl> + uint64_t removed , TRI_voc_rid_t rid ) <nl> + : _committedSeq ( sq ) , _added ( added ) , _removed ( removed ) , _revisionId ( rid ) { } <nl> + <nl> + explicit DocCount ( arangodb : : velocypack : : Slice const & ) ; <nl> + void toVelocyPack ( arangodb : : velocypack : : Builder & ) const ; <nl> + } ; <nl> + <nl> + public : <nl> + <nl> + RocksDBCollectionMeta ( ) ; <nl> + <nl> + public : <nl> + / * * <nl> + * @ brief Place a blocker to allow proper commit / serialize semantics <nl> + * <nl> + * Should be called immediately prior to internal RocksDB commit . If the <nl> + * commit succeeds , any inserts / removals should be buffered , then the blocker <nl> + * removed ; otherwise simply remove the blocker . <nl> + * <nl> + * @ param trxId The identifier for the active transaction <nl> + * @ param seq The sequence number immediately prior to call <nl> + * @ return May return error if we fail to allocate and place blocker <nl> + * / <nl> + Result placeBlocker ( uint64_t trxId , rocksdb : : SequenceNumber seq ) ; <nl> + <nl> + / * * <nl> + * @ brief Removes an existing transaction blocker <nl> + * <nl> + * Should be called after transaction abort / rollback , or after buffering any <nl> + * updates in case of successful commit . If no blocker exists with the <nl> + * specified transaction identifier , then this will simply do nothing . <nl> + * <nl> + * @ param trxId Identifier for active transaction ( should match input to <nl> + * earlier ` placeBlocker ` call ) <nl> + * / <nl> + void removeBlocker ( uint64_t trxId ) ; <nl> + <nl> + / / / @ brief updates and returns the largest safe seq to squash updated against <nl> + rocksdb : : SequenceNumber committableSeq ( ) const ; <nl> + <nl> + / / / @ brief get the current count <nl> + DocCount currentCount ( ) ; <nl> + / / / @ brief get the current count , ONLY use in recovery <nl> + DocCount & countRefUnsafe ( ) { return _count ; } <nl> + <nl> + / / / @ brief buffer a counter adjustment <nl> + void adjustNumberDocuments ( rocksdb : : SequenceNumber seq , <nl> + TRI_voc_rid_t revId , int64_t adj ) ; <nl> + <nl> + / / / @ brief serialize the collection metadata <nl> + arangodb : : Result serializeMeta ( rocksdb : : WriteBatch & , LogicalCollection & , <nl> + bool force , arangodb : : velocypack : : Builder & , <nl> + rocksdb : : SequenceNumber & appliedSeq ) ; <nl> + <nl> + / / / @ brief deserialize collection metadata , only called on startup <nl> + arangodb : : Result deserializeMeta ( rocksdb : : DB * , LogicalCollection & ) ; <nl> + <nl> + / / / @ brief load collection <nl> + static DocCount loadCollectionCount ( rocksdb : : DB * , uint64_t objectId ) ; <nl> + <nl> + / / / @ brief remove collection metadata <nl> + static Result deleteCollectionMeta ( rocksdb : : DB * , uint64_t objectId ) ; <nl> + <nl> + / / / @ brief remove collection index estimate <nl> + static Result deleteIndexEstimate ( rocksdb : : DB * , uint64_t objectId ) ; <nl> + <nl> + private : <nl> + <nl> + / / / @ brief apply counter adjustments , only call from sync thread <nl> + rocksdb : : SequenceNumber applyAdjustments ( rocksdb : : SequenceNumber commitSeq , <nl> + bool & didWork ) ; <nl> + <nl> + private : <nl> + <nl> + / / TODO we should probably use flat_map or abseils Swiss Tables <nl> + <nl> + mutable arangodb : : basics : : ReadWriteLock _blockerLock ; <nl> + / / / @ brief blocker identifies a transaction being committed <nl> + std : : map < uint64_t , rocksdb : : SequenceNumber > _blockers ; <nl> + std : : set < std : : pair < rocksdb : : SequenceNumber , uint64_t > > _blockersBySeq ; <nl> + <nl> + mutable std : : mutex _countLock ; <nl> + DocCount _count ; / / / @ brief document count struct <nl> + <nl> + / / / document counter adjustment <nl> + struct Adjustment { <nl> + / / / @ brief last used revision id <nl> + TRI_voc_rid_t revisionId ; <nl> + / / / @ brief number of added / removed documents <nl> + int64_t adjustment ; <nl> + } ; <nl> + <nl> + / / / @ brief buffered counter adjustments <nl> + std : : map < rocksdb : : SequenceNumber , Adjustment > _bufferedAdjs ; <nl> + / / / @ brief internal buffer for adjustments <nl> + std : : map < rocksdb : : SequenceNumber , Adjustment > _stagedAdjs ; <nl> + } ; <nl> + } <nl> + <nl> + # endif <nl> mmm a / arangod / RocksDBEngine / RocksDBCommon . cpp <nl> ppp b / arangod / RocksDBEngine / RocksDBCommon . cpp <nl> std : : pair < TRI_voc_tick_t , TRI_voc_cid_t > mapObjectToCollection ( <nl> return rocks - > mapObjectToCollection ( objectId ) ; <nl> } <nl> <nl> - std : : tuple < TRI_voc_tick_t , TRI_voc_cid_t , TRI_idx_iid_t > mapObjectToIndex ( <nl> - uint64_t objectId ) { <nl> + std : : tuple < TRI_voc_tick_t , TRI_voc_cid_t , TRI_idx_iid_t > mapObjectToIndex ( uint64_t objectId ) { <nl> StorageEngine * engine = EngineSelectorFeature : : ENGINE ; <nl> TRI_ASSERT ( engine ! = nullptr ) ; <nl> RocksDBEngine * rocks = static_cast < RocksDBEngine * > ( engine ) ; <nl> std : : size_t countKeyRange ( rocksdb : : DB * db , <nl> <nl> / / / @ brief helper method to remove large ranges of data <nl> / / / Should mainly be used to implement the drop ( ) call <nl> - Result removeLargeRange ( rocksdb : : TransactionDB * db , <nl> + Result removeLargeRange ( rocksdb : : DB * db , <nl> RocksDBKeyBounds const & bounds , <nl> bool prefixSameAsStart , <nl> bool useRangeDelete ) { <nl> LOG_TOPIC ( DEBUG , Logger : : ENGINES ) < < " removing large range : " < < bounds ; <nl> <nl> rocksdb : : ColumnFamilyHandle * cf = bounds . columnFamily ( ) ; <nl> - rocksdb : : DB * bDB = db - > GetBaseDB ( ) ; <nl> + rocksdb : : DB * bDB = db - > GetRootDB ( ) ; <nl> TRI_ASSERT ( bDB ! = nullptr ) ; <nl> <nl> try { <nl> mmm a / arangod / RocksDBEngine / RocksDBCommon . h <nl> ppp b / arangod / RocksDBEngine / RocksDBCommon . h <nl> std : : size_t countKeyRange ( rocksdb : : DB * , RocksDBKeyBounds const & , <nl> <nl> / / / @ brief helper method to remove large ranges of data <nl> / / / Should mainly be used to implement the drop ( ) call <nl> - Result removeLargeRange ( rocksdb : : TransactionDB * db , <nl> + Result removeLargeRange ( rocksdb : : DB * db , <nl> RocksDBKeyBounds const & bounds , <nl> bool prefixSameAsStart , <nl> bool useRangeDelete ) ; <nl> void iterateBounds ( RocksDBKeyBounds const & bounds , T callback , <nl> options . iterate_upper_bound = & end ; / / save to use on rocksb : : DB directly <nl> options . prefix_same_as_start = true ; <nl> options . verify_checksums = false ; <nl> + options . fill_cache = false ; <nl> std : : unique_ptr < rocksdb : : Iterator > it ( <nl> globalRocksDB ( ) - > NewIterator ( options , bounds . columnFamily ( ) ) ) ; <nl> for ( it - > Seek ( bounds . start ( ) ) ; it - > Valid ( ) ; it - > Next ( ) ) { <nl> mmm a / arangod / RocksDBEngine / RocksDBCuckooIndexEstimator . h <nl> ppp b / arangod / RocksDBEngine / RocksDBCuckooIndexEstimator . h <nl> template < class Key , class HashKey = HashWithSeed < Key , 0xdeadbeefdeadbeefULL > , <nl> class CompKey = std : : equal_to < Key > > <nl> class RocksDBCuckooIndexEstimator { <nl> / / Note that the following has to be a power of two and at least 4 ! <nl> - static constexpr uint32_t SlotsPerBucket = 4 ; <nl> + static constexpr uint32_t kSlotsPerBucket = 4 ; <nl> + / / total size of a slot <nl> + static constexpr size_t kSlotSize = sizeof ( uint16_t ) ; <nl> + / / total size of a counter <nl> + static constexpr size_t kCounterSize = sizeof ( uint32_t ) ; <nl> + / / maximum number of cuckoo rounds on insertion <nl> + static constexpr unsigned kMaxRounds = 16 ; <nl> + <nl> <nl> private : <nl> / / Helper class to hold the finger prints . <nl> class RocksDBCuckooIndexEstimator { <nl> <nl> RocksDBCuckooIndexEstimator ( uint64_t size ) <nl> : _randState ( 0x2636283625154737ULL ) , <nl> - _slotSize ( sizeof ( uint16_t ) ) , / / Sort out offsets and alignments <nl> - _counterSize ( sizeof ( uint32_t ) ) , / / Sort out offsets and alignments <nl> _logSize ( 0 ) , <nl> _size ( 0 ) , <nl> _niceSize ( 0 ) , <nl> class RocksDBCuckooIndexEstimator { <nl> _nrUsed ( 0 ) , <nl> _nrCuckood ( 0 ) , <nl> _nrTotal ( 0 ) , <nl> - _maxRounds ( 16 ) , <nl> _committedSeq ( 0 ) , <nl> _needToPersist ( true ) { <nl> / / Inflate size so that we have some padding to avoid failure <nl> class RocksDBCuckooIndexEstimator { <nl> size = ( size > = 1024 ) ? size : 1024 ; / / want 256 buckets minimum <nl> <nl> / / First find the smallest power of two that is not smaller than size : <nl> - size / = SlotsPerBucket ; <nl> + size / = kSlotsPerBucket ; <nl> _size = size ; <nl> initializeDefault ( ) ; <nl> } <nl> class RocksDBCuckooIndexEstimator { <nl> RocksDBCuckooIndexEstimator ( rocksdb : : SequenceNumber commitSeq , <nl> arangodb : : StringRef const serialized ) <nl> : _randState ( 0x2636283625154737ULL ) , <nl> - _slotSize ( sizeof ( uint16_t ) ) , / / Sort out offsets and alignments <nl> - _counterSize ( sizeof ( uint32_t ) ) , / / Sort out offsets and alignments <nl> _logSize ( 0 ) , <nl> _size ( 0 ) , <nl> _niceSize ( 0 ) , <nl> class RocksDBCuckooIndexEstimator { <nl> _nrUsed ( 0 ) , <nl> _nrCuckood ( 0 ) , <nl> _nrTotal ( 0 ) , <nl> - _maxRounds ( 16 ) , <nl> _committedSeq ( commitSeq ) , <nl> _needToPersist ( false ) { <nl> switch ( serialized . front ( ) ) { <nl> class RocksDBCuckooIndexEstimator { <nl> * Applies any buffered updates and updates the " committed " seq / tick state . <nl> * <nl> * @ param serialized String for output <nl> - * @ param inputSeq The current seq / tick at beginning of sync <nl> - * @ return The committed seq / tick <nl> + * @ param commitSeq Above that are still uncommited operations <nl> + * @ return The committed seq / tick ( safe tick to keep in WAL ) <nl> * / <nl> rocksdb : : SequenceNumber serialize ( std : : string & serialized , <nl> - rocksdb : : SequenceNumber inputSeq ) { <nl> + rocksdb : : SequenceNumber commitSeq ) { <nl> / / We always have to start with the commit seq , type and then the length <nl> <nl> - / / commit seq <nl> - auto outputSeq = committableSeq ( inputSeq ) ; <nl> - rocksutils : : uint64ToPersistent ( serialized , outputSeq ) ; <nl> - <nl> - / / must apply updates first to be valid <nl> - applyUpdates ( outputSeq ) ; <nl> - <nl> + / / commit seq , above that is an uncommited operations <nl> + / / rocksdb : : SequenceNumber commitSeq = committableSeq ( ) ; <nl> + / / must apply updates first to be valid , WAL needs to preserve <nl> + rocksdb : : SequenceNumber appliedSeq = applyUpdates ( commitSeq ) ; <nl> + TRI_ASSERT ( appliedSeq < = commitSeq ) ; <nl> + <nl> { <nl> / / Sorry we need a consistent state , so we have to read - lock <nl> READ_LOCKER ( locker , _lock ) ; <nl> <nl> + / / / appliedSeq might be 0 if we did not applie any operations <nl> + appliedSeq = std : : max ( appliedSeq , this - > committedSeq ( ) ) ; <nl> + TRI_ASSERT ( appliedSeq ! = std : : numeric_limits < rocksdb : : SequenceNumber > : : max ( ) ) ; <nl> + rocksutils : : uint64ToPersistent ( serialized , appliedSeq ) ; <nl> + <nl> / / type <nl> serialized + = SerializeFormat : : NOCOMPRESSION ; <nl> <nl> class RocksDBCuckooIndexEstimator { <nl> ( sizeof ( SerializeFormat ) + sizeof ( uint64_t ) + sizeof ( _size ) + <nl> sizeof ( _nrUsed ) + sizeof ( _nrCuckood ) + sizeof ( _nrTotal ) + <nl> sizeof ( _niceSize ) + sizeof ( _logSize ) + <nl> - ( _size * _slotSize * SlotsPerBucket ) ) + <nl> - ( _size * _counterSize * SlotsPerBucket ) ; <nl> + ( _size * kSlotSize * kSlotsPerBucket ) ) + <nl> + ( _size * kCounterSize * kSlotsPerBucket ) ; <nl> <nl> serialized . reserve ( sizeof ( uint64_t ) + serialLength ) ; <nl> / / We always prepend the length , so parsing is easier <nl> class RocksDBCuckooIndexEstimator { <nl> rocksutils : : uint64ToPersistent ( serialized , _logSize ) ; <nl> <nl> / / Add the data blob <nl> - / / Size is as follows : nrOfBuckets * SlotsPerBucket * SlotSize <nl> - TRI_ASSERT ( ( _size * _slotSize * SlotsPerBucket ) < = _slotAllocSize ) ; <nl> + / / Size is as follows : nrOfBuckets * kSlotsPerBucket * SlotSize <nl> + TRI_ASSERT ( ( _size * kSlotSize * kSlotsPerBucket ) < = _slotAllocSize ) ; <nl> <nl> - for ( uint64_t i = 0 ; i < ( _size * _slotSize * SlotsPerBucket ) ; <nl> - i + = _slotSize ) { <nl> + for ( uint64_t i = 0 ; i < ( _size * kSlotSize * kSlotsPerBucket ) ; <nl> + i + = kSlotSize ) { <nl> rocksutils : : uint16ToPersistent ( <nl> serialized , * ( reinterpret_cast < uint16_t * > ( _base + i ) ) ) ; <nl> } <nl> <nl> - TRI_ASSERT ( ( _size * _counterSize * SlotsPerBucket ) < = _counterAllocSize ) ; <nl> + TRI_ASSERT ( ( _size * kCounterSize * kSlotsPerBucket ) < = _counterAllocSize ) ; <nl> <nl> - for ( uint64_t i = 0 ; i < ( _size * _counterSize * SlotsPerBucket ) ; <nl> - i + = _counterSize ) { <nl> + for ( uint64_t i = 0 ; i < ( _size * kCounterSize * kSlotsPerBucket ) ; <nl> + i + = kCounterSize ) { <nl> rocksutils : : uint32ToPersistent ( <nl> serialized , * ( reinterpret_cast < uint32_t * > ( _counters + i ) ) ) ; <nl> } <nl> <nl> - bool havePendingUpdates = ! _blockers . empty ( ) | | ! _insertBuffers . empty ( ) | | <nl> - ! _removalBuffers . empty ( ) | | ! _truncateBuffer . empty ( ) ; <nl> + bool havePendingUpdates = ! _insertBuffers . empty ( ) | | ! _removalBuffers . empty ( ) | | <nl> + ! _truncateBuffer . empty ( ) ; <nl> _needToPersist . store ( havePendingUpdates ) ; <nl> } <nl> <nl> - { <nl> - WRITE_LOCKER ( locker , _lock ) ; <nl> - _committedSeq = outputSeq ; <nl> - } <nl> - <nl> - return outputSeq ; <nl> + _committedSeq . store ( appliedSeq , std : : memory_order_release ) ; <nl> + return appliedSeq ; <nl> } <nl> <nl> / / / @ brief only call directly during startup / recovery ; otherwise buffer <nl> class RocksDBCuckooIndexEstimator { <nl> / / Reset filter content <nl> / / Now initialize all slots in all buckets with zero data : <nl> for ( uint32_t b = 0 ; b < _size ; + + b ) { <nl> - for ( size_t i = 0 ; i < SlotsPerBucket ; + + i ) { <nl> + for ( size_t i = 0 ; i < kSlotsPerBucket ; + + i ) { <nl> Slot f = findSlot ( b , i ) ; <nl> f . injectCounter ( findCounter ( b , i ) ) ; <nl> f . reset ( ) ; <nl> class RocksDBCuckooIndexEstimator { <nl> return false ; <nl> } <nl> <nl> - uint64_t capacity ( ) const { return _size * SlotsPerBucket ; } <nl> + uint64_t capacity ( ) const { return _size * kSlotsPerBucket ; } <nl> <nl> / / not thread safe . called only during tests <nl> uint64_t nrTotal ( ) const { return _nrTotal ; } <nl> class RocksDBCuckooIndexEstimator { <nl> return _needToPersist . load ( ) ; <nl> } <nl> <nl> - / * * <nl> - * @ brief Place a blocker to allow proper commit / serialize semantics <nl> - * <nl> - * Should be called immediately prior to internal RocksDB commit . If the <nl> - * commit succeeds , any inserts / removals should be buffered , then the blocker <nl> - * removed ; otherwise simply remove the blocker . <nl> - * <nl> - * @ param trxId The identifier for the active transaction <nl> - * @ param seq The sequence number immediately prior to call <nl> - * @ return May return error if we fail to allocate and place blocker <nl> - * / <nl> - Result placeBlocker ( uint64_t trxId , rocksdb : : SequenceNumber seq ) { <nl> - Result res = basics : : catchToResult ( [ & ] ( ) - > Result { <nl> - TRI_ASSERT ( _blockers . end ( ) = = _blockers . find ( trxId ) ) ; <nl> - TRI_ASSERT ( _blockersBySeq . end ( ) = = <nl> - _blockersBySeq . find ( std : : make_pair ( seq , trxId ) ) ) ; <nl> - Result res ; <nl> - WRITE_LOCKER ( locker , _lock ) ; <nl> - auto insert = _blockers . emplace ( trxId , seq ) ; <nl> - auto crosslist = _blockersBySeq . emplace ( seq , trxId ) ; <nl> - if ( ! insert . second | | ! crosslist . second ) { <nl> - return { TRI_ERROR_INTERNAL } ; <nl> - } <nl> - _needToPersist . store ( true ) ; <nl> - return { TRI_ERROR_NO_ERROR } ; <nl> - } ) ; <nl> - return res ; <nl> - } <nl> - <nl> - / * * <nl> - * @ brief Removes an existing transaction blocker <nl> - * <nl> - * Should be called after transaction abort / rollback , or after buffering any <nl> - * updates in case of successful commit . If no blocker exists with the <nl> - * specified transaction identifier , then this will simply do nothing . <nl> - * <nl> - * @ param trxId Identifier for active transaction ( should match input to <nl> - * earlier ` placeBlocker ` call ) <nl> - * / <nl> - void removeBlocker ( uint64_t trxId ) { <nl> - WRITE_LOCKER ( locker , _lock ) ; <nl> - auto it = _blockers . find ( trxId ) ; <nl> - if ( ADB_LIKELY ( _blockers . end ( ) ! = it ) ) { <nl> - auto cross = _blockersBySeq . find ( std : : make_pair ( it - > second , it - > first ) ) ; <nl> - TRI_ASSERT ( _blockersBySeq . end ( ) ! = cross ) ; <nl> - if ( ADB_LIKELY ( _blockersBySeq . end ( ) ! = cross ) ) { <nl> - _blockersBySeq . erase ( cross ) ; <nl> - } <nl> - _blockers . erase ( it ) ; <nl> - } <nl> - } <nl> - <nl> / * * <nl> * @ brief Buffer updates to this estimator to be applied when appropriate <nl> * <nl> class RocksDBCuckooIndexEstimator { <nl> * / <nl> Result bufferUpdates ( rocksdb : : SequenceNumber seq , std : : vector < Key > & & inserts , <nl> std : : vector < Key > & & removals ) { <nl> + TRI_ASSERT ( ! inserts . empty ( ) | | ! removals . empty ( ) ) ; <nl> Result res = basics : : catchVoidToResult ( [ & ] ( ) - > void { <nl> WRITE_LOCKER ( locker , _lock ) ; <nl> bool foundSomething = false ; <nl> class RocksDBCuckooIndexEstimator { <nl> * <nl> * @ return The latest seq / tick through which the estimate is valid <nl> * / <nl> - rocksdb : : SequenceNumber commitSeq ( ) const { <nl> - READ_LOCKER ( locker , _lock ) ; <nl> - return _committedSeq ; <nl> + rocksdb : : SequenceNumber committedSeq ( ) const { <nl> + return _committedSeq . load ( std : : memory_order_acquire ) ; <nl> } <nl> <nl> + / / / @ brief set the most recently set " committed " seq / tick <nl> + / / / only set when recalculating the index estimate <nl> + void setCommitSeq ( rocksdb : : SequenceNumber seq ) { <nl> + _committedSeq . store ( seq , std : : memory_order_release ) ; <nl> + } <nl> + <nl> private : / / methods <nl> / / / @ brief call with output from committableSeq ( current ) , and before serialize <nl> - Result applyUpdates ( rocksdb : : SequenceNumber commitSeq ) { <nl> + rocksdb : : SequenceNumber applyUpdates ( rocksdb : : SequenceNumber commitSeq ) { <nl> + rocksdb : : SequenceNumber appliedSeq = 0 ; <nl> Result res = basics : : catchVoidToResult ( [ & ] ( ) - > void { <nl> std : : vector < Key > inserts ; <nl> std : : vector < Key > removals ; <nl> - <nl> + <nl> / / truncate will increase this sequence <nl> rocksdb : : SequenceNumber ignoreSeq = 0 ; <nl> while ( true ) { <nl> class RocksDBCuckooIndexEstimator { <nl> ignoreSeq = * it ; <nl> TRI_ASSERT ( ignoreSeq ! = 0 ) ; <nl> foundTruncate = true ; <nl> + appliedSeq = std : : max ( appliedSeq , ignoreSeq ) ; <nl> it = _truncateBuffer . erase ( it ) ; <nl> } <nl> <nl> class RocksDBCuckooIndexEstimator { <nl> inserts = std : : move ( it - > second ) ; <nl> TRI_ASSERT ( ! inserts . empty ( ) ) ; <nl> } <nl> + appliedSeq = std : : max ( appliedSeq , it - > first ) ; <nl> _insertBuffers . erase ( it ) ; <nl> } <nl> } <nl> class RocksDBCuckooIndexEstimator { <nl> removals = std : : move ( it - > second ) ; <nl> TRI_ASSERT ( ! removals . empty ( ) ) ; <nl> } <nl> + appliedSeq = std : : max ( appliedSeq , it - > first ) ; <nl> _removalBuffers . erase ( it ) ; <nl> } <nl> } <nl> class RocksDBCuckooIndexEstimator { <nl> } <nl> } / / < / while ( true ) > <nl> } ) ; <nl> - return res ; <nl> - } <nl> - <nl> - / / / @ brief updates and returns the largest safe seq to consider committed <nl> - rocksdb : : SequenceNumber committableSeq ( rocksdb : : SequenceNumber current ) { <nl> - WRITE_LOCKER ( locker , _lock ) ; <nl> - auto minSeq = current ; <nl> - <nl> - / / if we have a blocker with a lower value than current , compare it <nl> - if ( ! _blockersBySeq . empty ( ) ) { <nl> - auto it = _blockersBySeq . begin ( ) ; <nl> - minSeq = std : : min ( minSeq , it - > first ) ; <nl> - } <nl> - <nl> - return minSeq ; <nl> + return appliedSeq ; <nl> } <nl> <nl> uint64_t memoryUsage ( ) const { <nl> class RocksDBCuckooIndexEstimator { <nl> Slot firstEmpty ( nullptr ) ; <nl> bool foundEmpty = false ; <nl> <nl> - for ( uint64_t i = 0 ; i < SlotsPerBucket ; + + i ) { <nl> + for ( uint64_t i = 0 ; i < kSlotsPerBucket ; + + i ) { <nl> Slot slot = findSlot ( pos1 , i ) ; <nl> if ( slot . isEqual ( fp ) ) { <nl> / / Found we are done , short - circuit . <nl> class RocksDBCuckooIndexEstimator { <nl> } <nl> } <nl> <nl> - for ( uint64_t i = 0 ; i < SlotsPerBucket ; + + i ) { <nl> + for ( uint64_t i = 0 ; i < kSlotsPerBucket ; + + i ) { <nl> Slot slot = findSlot ( pos2 , i ) ; <nl> if ( slot . isEqual ( fp ) ) { <nl> / / Found we are done , short - circuit . <nl> class RocksDBCuckooIndexEstimator { <nl> / / and place our own into it . <nl> / / We have to keep the reference to the cuckood slot here . <nl> r = pseudoRandomChoice ( ) ; <nl> - uint64_t i = r & ( SlotsPerBucket - 1 ) ; <nl> + uint64_t i = r & ( kSlotsPerBucket - 1 ) ; <nl> firstEmpty = findSlot ( pos1 , i ) ; <nl> firstEmpty . injectCounter ( findCounter ( pos1 , i ) ) ; <nl> firstEmpty . swap ( fp , counter ) ; <nl> class RocksDBCuckooIndexEstimator { <nl> <nl> / / Now let the cuckoo fly and find a place for the poor one we just took <nl> / / out . <nl> - for ( uint64_t i = 0 ; i < SlotsPerBucket ; + + i ) { <nl> + for ( uint64_t i = 0 ; i < kSlotsPerBucket ; + + i ) { <nl> Slot slot = findSlot ( pos2 , i ) ; <nl> if ( slot . isEmpty ( ) ) { <nl> slot . injectCounter ( findCounter ( pos2 , i ) ) ; <nl> class RocksDBCuckooIndexEstimator { <nl> } <nl> <nl> / / Bad luck , let us try to move to a different slot . <nl> - for ( unsigned attempt = 1 ; attempt < _maxRounds ; attempt + + ) { <nl> + for ( unsigned attempt = 1 ; attempt < kMaxRounds ; attempt + + ) { <nl> std : : swap ( pos1 , pos2 ) ; <nl> / / Now expunge a random element from any of these slots : <nl> r = pseudoRandomChoice ( ) ; <nl> - uint64_t i = r & ( SlotsPerBucket - 1 ) ; <nl> + uint64_t i = r & ( kSlotsPerBucket - 1 ) ; <nl> / / We expunge the element at position pos1 and slot i : <nl> Slot slot = findSlot ( pos1 , i ) ; <nl> if ( slot = = firstEmpty ) { <nl> / / We have to keep this one in place . <nl> / / Take a different one <nl> - i = ( i + 1 ) % SlotsPerBucket ; <nl> + i = ( i + 1 ) % kSlotsPerBucket ; <nl> slot = findSlot ( pos1 , i ) ; <nl> } <nl> slot . injectCounter ( findCounter ( pos1 , i ) ) ; <nl> class RocksDBCuckooIndexEstimator { <nl> hash2 = _hasherPosFingerprint ( pos1 , fp ) ; <nl> pos2 = hashToPos ( hash2 ) ; <nl> <nl> - for ( uint64_t i = 0 ; i < SlotsPerBucket ; + + i ) { <nl> + for ( uint64_t i = 0 ; i < kSlotsPerBucket ; + + i ) { <nl> Slot slot = findSlot ( pos2 , i ) ; <nl> if ( slot . isEmpty ( ) ) { <nl> slot . injectCounter ( findCounter ( pos2 , i ) ) ; <nl> class RocksDBCuckooIndexEstimator { <nl> / / Do not use the output if found = = false <nl> Slot findSlotNoCuckoo ( uint64_t pos , uint16_t fp , bool & found ) const { <nl> found = false ; <nl> - for ( uint64_t i = 0 ; i < SlotsPerBucket ; + + i ) { <nl> + for ( uint64_t i = 0 ; i < kSlotsPerBucket ; + + i ) { <nl> Slot slot = findSlot ( pos , i ) ; <nl> if ( fp = = * slot . fingerprint ( ) ) { <nl> slot . injectCounter ( findCounter ( pos , i ) ) ; <nl> class RocksDBCuckooIndexEstimator { <nl> } <nl> <nl> Slot findSlot ( uint64_t pos , uint64_t slot ) const { <nl> - TRI_ASSERT ( _slotSize * ( pos * SlotsPerBucket + slot ) < = _slotAllocSize ) ; <nl> - char * address = _base + _slotSize * ( pos * SlotsPerBucket + slot ) ; <nl> + TRI_ASSERT ( kSlotSize * ( pos * kSlotsPerBucket + slot ) < = _slotAllocSize ) ; <nl> + char * address = _base + kSlotSize * ( pos * kSlotsPerBucket + slot ) ; <nl> auto ret = reinterpret_cast < uint16_t * > ( address ) ; <nl> return Slot ( ret ) ; <nl> } <nl> <nl> uint32_t * findCounter ( uint64_t pos , uint64_t slot ) const { <nl> - TRI_ASSERT ( _counterSize * ( pos * SlotsPerBucket + slot ) < = <nl> + TRI_ASSERT ( kCounterSize * ( pos * kSlotsPerBucket + slot ) < = <nl> _counterAllocSize ) ; <nl> - char * address = _counters + _counterSize * ( pos * SlotsPerBucket + slot ) ; <nl> + char * address = _counters + kCounterSize * ( pos * kSlotsPerBucket + slot ) ; <nl> return reinterpret_cast < uint32_t * > ( address ) ; <nl> } <nl> <nl> class RocksDBCuckooIndexEstimator { <nl> ( sizeof ( SerializeFormat ) + sizeof ( uint64_t ) + sizeof ( _size ) + <nl> sizeof ( _nrUsed ) + sizeof ( _nrCuckood ) + sizeof ( _nrTotal ) + <nl> sizeof ( _niceSize ) + sizeof ( _logSize ) + <nl> - ( _size * _slotSize * SlotsPerBucket ) ) + <nl> - ( _size * _counterSize * SlotsPerBucket ) ) ; <nl> + ( _size * kSlotSize * kSlotsPerBucket ) ) + <nl> + ( _size * kCounterSize * kSlotsPerBucket ) ) ; <nl> <nl> / / Insert the raw data <nl> - / / Size is as follows : nrOfBuckets * SlotsPerBucket * SlotSize <nl> - TRI_ASSERT ( ( _size * _slotSize * SlotsPerBucket ) < = _slotAllocSize ) ; <nl> + / / Size is as follows : nrOfBuckets * kSlotsPerBucket * SlotSize <nl> + TRI_ASSERT ( ( _size * kSlotSize * kSlotsPerBucket ) < = _slotAllocSize ) ; <nl> <nl> - for ( uint64_t i = 0 ; i < ( _size * _slotSize * SlotsPerBucket ) ; <nl> - i + = _slotSize ) { <nl> + for ( uint64_t i = 0 ; i < ( _size * kSlotSize * kSlotsPerBucket ) ; <nl> + i + = kSlotSize ) { <nl> * ( reinterpret_cast < uint16_t * > ( _base + i ) ) = <nl> rocksutils : : uint16FromPersistent ( current ) ; <nl> - current + = _slotSize ; <nl> + current + = kSlotSize ; <nl> } <nl> <nl> - TRI_ASSERT ( ( _size * _counterSize * SlotsPerBucket ) < = _counterAllocSize ) ; <nl> + TRI_ASSERT ( ( _size * kCounterSize * kSlotsPerBucket ) < = _counterAllocSize ) ; <nl> <nl> - for ( uint64_t i = 0 ; i < ( _size * _counterSize * SlotsPerBucket ) ; <nl> - i + = _counterSize ) { <nl> + for ( uint64_t i = 0 ; i < ( _size * kCounterSize * kSlotsPerBucket ) ; <nl> + i + = kCounterSize ) { <nl> * ( reinterpret_cast < uint32_t * > ( _counters + i ) ) = <nl> rocksutils : : uint32FromPersistent ( current ) ; <nl> - current + = _counterSize ; <nl> + current + = kCounterSize ; <nl> } <nl> } <nl> <nl> class RocksDBCuckooIndexEstimator { <nl> <nl> / / Now initialize all slots in all buckets with zero data : <nl> for ( uint32_t b = 0 ; b < _size ; + + b ) { <nl> - for ( size_t i = 0 ; i < SlotsPerBucket ; + + i ) { <nl> + for ( size_t i = 0 ; i < kSlotsPerBucket ; + + i ) { <nl> Slot f = findSlot ( b , i ) ; <nl> f . injectCounter ( findCounter ( b , i ) ) ; <nl> f . reset ( ) ; <nl> class RocksDBCuckooIndexEstimator { <nl> _sizeShift = static_cast < uint32_t > ( ( 64 - _logSize ) / 2 ) ; <nl> <nl> / / give 64 bytes padding to enable 64 - byte alignment <nl> - _slotAllocSize = _size * _slotSize * SlotsPerBucket + 64 ; <nl> + _slotAllocSize = _size * kSlotSize * kSlotsPerBucket + 64 ; <nl> <nl> _slotBase = new char [ _slotAllocSize ] ; <nl> <nl> class RocksDBCuckooIndexEstimator { <nl> / / 64 - byte boundary <nl> <nl> / / give 64 bytes padding to enable 64 - byte alignment <nl> - _counterAllocSize = _size * _counterSize * SlotsPerBucket + 64 ; <nl> + _counterAllocSize = _size * kCounterSize * kSlotsPerBucket + 64 ; <nl> _counterBase = new char [ _counterAllocSize ] ; <nl> <nl> _counters = reinterpret_cast < char * > ( <nl> class RocksDBCuckooIndexEstimator { <nl> } <nl> <nl> private : / / member variables <nl> + <nl> uint64_t _randState ; / / pseudo random state for expunging <nl> <nl> - size_t _slotSize ; / / total size of a slot <nl> - size_t _counterSize ; / / total size of a counter <nl> - <nl> uint64_t _logSize ; / / logarithm ( base 2 ) of number of buckets <nl> uint64_t _size ; / / actual number of buckets <nl> uint64_t _niceSize ; / / smallest power of 2 at least number of buckets , = = <nl> class RocksDBCuckooIndexEstimator { <nl> uint64_t _sizeMask ; / / used to mask out some bits from the hash <nl> uint32_t _sizeShift ; / / used to shift the bits down to get a position <nl> uint64_t _slotAllocSize ; / / number of allocated bytes for the slots , <nl> - / / = = _size * SlotsPerBucket * _slotSize + 64 <nl> + / / = = _size * kSlotsPerBucket * kSlotSize + 64 <nl> uint64_t _counterAllocSize ; / / number of allocated bytes ofr the counters , <nl> - / / = = _size * SlotsPerBucket * _counterSize + 64 <nl> + / / = = _size * kSlotsPerBucket * kCounterSize + 64 <nl> char * _base ; / / pointer to allocated space , 64 - byte aligned <nl> char * _slotBase ; / / base of original allocation <nl> char * _counters ; / / pointer to allocated space , 64 - byte aligned <nl> class RocksDBCuckooIndexEstimator { <nl> uint64_t _nrUsed ; / / number of pairs stored in the table <nl> uint64_t _nrCuckood ; / / number of elements that have been removed by cuckoo <nl> uint64_t _nrTotal ; / / number of elements included in total ( not cuckood ) <nl> - unsigned _maxRounds ; / / maximum number of cuckoo rounds on insertion <nl> <nl> - rocksdb : : SequenceNumber mutable _committedSeq ; <nl> + std : : atomic < rocksdb : : SequenceNumber > _committedSeq ; <nl> std : : atomic < bool > _needToPersist ; <nl> <nl> - std : : map < uint64_t , rocksdb : : SequenceNumber > _blockers ; <nl> - std : : set < std : : pair < rocksdb : : SequenceNumber , uint64_t > > _blockersBySeq ; <nl> std : : map < rocksdb : : SequenceNumber , std : : vector < Key > > _insertBuffers ; <nl> std : : map < rocksdb : : SequenceNumber , std : : vector < Key > > _removalBuffers ; <nl> std : : set < rocksdb : : SequenceNumber > _truncateBuffer ; <nl> mmm a / arangod / RocksDBEngine / RocksDBEdgeIndex . cpp <nl> ppp b / arangod / RocksDBEngine / RocksDBEdgeIndex . cpp <nl> Result RocksDBEdgeIndex : : removeInternal ( transaction : : Methods * trx , <nl> } <nl> } <nl> <nl> - RocksDBCuckooIndexEstimator < uint64_t > * RocksDBEdgeIndex : : estimator ( ) { <nl> - return _estimator . get ( ) ; <nl> - } <nl> - <nl> - bool RocksDBEdgeIndex : : needToPersistEstimate ( ) const { <nl> - return _estimator - > needToPersist ( ) ; <nl> - } <nl> - <nl> void RocksDBEdgeIndex : : batchInsert ( <nl> transaction : : Methods * trx , <nl> std : : vector < std : : pair < LocalDocumentId , VPackSlice > > const & documents , <nl> void RocksDBEdgeIndex : : warmupInternal ( transaction : : Methods * trx , <nl> auto * mthds = RocksDBTransactionState : : toMethods ( trx ) ; <nl> rocksdb : : Slice const end = upper ; <nl> rocksdb : : ReadOptions options = mthds - > iteratorReadOptions ( ) ; <nl> - options . iterate_upper_bound = & end ; / / save to use on rocksb : : DB directly <nl> + options . iterate_upper_bound = & end ; / / safe to use on rocksb : : DB directly <nl> options . prefix_same_as_start = false ; / / key - prefix includes edge <nl> options . total_order_seek = true ; / / otherwise full - index - scan does not work <nl> options . verify_checksums = false ; <nl> void RocksDBEdgeIndex : : handleValNode ( <nl> } <nl> } <nl> <nl> - rocksdb : : SequenceNumber RocksDBEdgeIndex : : serializeEstimate ( <nl> - std : : string & output , rocksdb : : SequenceNumber seq ) const { <nl> + void RocksDBEdgeIndex : : afterTruncate ( TRI_voc_tick_t tick ) { <nl> TRI_ASSERT ( _estimator ! = nullptr ) ; <nl> - return _estimator - > serialize ( output , seq ) ; <nl> + _estimator - > bufferTruncate ( tick ) ; <nl> + RocksDBIndex : : afterTruncate ( tick ) ; <nl> } <nl> <nl> - bool RocksDBEdgeIndex : : deserializeEstimate ( RocksDBSettingsManager * mgr ) { <nl> - TRI_ASSERT ( ! ServerState : : instance ( ) - > isCoordinator ( ) ) ; <nl> - / / We simply drop the current estimator and steal the one from recovery <nl> - / / We are than save for resizing issues in our _estimator format <nl> - / / and will use the old size . <nl> - <nl> - TRI_ASSERT ( mgr ! = nullptr ) ; <nl> - auto tmp = mgr - > stealIndexEstimator ( _objectId ) ; <nl> - if ( tmp = = nullptr ) { <nl> - / / We expected to receive a stored index estimate , however we got none . <nl> - / / We use the freshly created estimator but have to recompute it . <nl> - return false ; <nl> - } <nl> - _estimator . swap ( tmp ) ; <nl> - TRI_ASSERT ( _estimator ! = nullptr ) ; <nl> - return true ; <nl> + RocksDBCuckooIndexEstimator < uint64_t > * RocksDBEdgeIndex : : estimator ( ) { <nl> + return _estimator . get ( ) ; <nl> } <nl> <nl> - void RocksDBEdgeIndex : : afterTruncate ( TRI_voc_tick_t tick ) { <nl> - TRI_ASSERT ( _estimator ! = nullptr ) ; <nl> - _estimator - > bufferTruncate ( tick ) ; <nl> - RocksDBIndex : : afterTruncate ( tick ) ; <nl> + void RocksDBEdgeIndex : : setEstimator ( std : : unique_ptr < RocksDBCuckooIndexEstimator < uint64_t > > est ) { <nl> + _estimator = std : : move ( est ) ; <nl> } <nl> <nl> + <nl> void RocksDBEdgeIndex : : recalculateEstimates ( ) { <nl> - TRI_ASSERT ( ! ServerState : : instance ( ) - > isCoordinator ( ) ) ; <nl> TRI_ASSERT ( _estimator ! = nullptr ) ; <nl> _estimator - > clear ( ) ; <nl> - <nl> + <nl> + rocksdb : : TransactionDB * db = rocksutils : : globalRocksDB ( ) ; <nl> + rocksdb : : SequenceNumber seq = db - > GetLatestSequenceNumber ( ) ; <nl> + <nl> auto bounds = RocksDBKeyBounds : : EdgeIndex ( _objectId ) ; <nl> rocksdb : : Slice const end = bounds . end ( ) ; <nl> rocksdb : : ReadOptions options ; <nl> - options . iterate_upper_bound = & end ; / / save to use on rocksb : : DB directly <nl> + options . iterate_upper_bound = & end ; / / safe to use on rocksb : : DB directly <nl> options . prefix_same_as_start = false ; / / key - prefix includes edge <nl> options . total_order_seek = true ; / / otherwise full scan fails <nl> options . verify_checksums = false ; <nl> options . fill_cache = false ; <nl> - std : : unique_ptr < rocksdb : : Iterator > it ( <nl> - rocksutils : : globalRocksDB ( ) - > NewIterator ( options , _cf ) ) ; <nl> + std : : unique_ptr < rocksdb : : Iterator > it ( db - > NewIterator ( options , _cf ) ) ; <nl> for ( it - > Seek ( bounds . start ( ) ) ; it - > Valid ( ) ; it - > Next ( ) ) { <nl> uint64_t hash = RocksDBEdgeIndex : : HashForKey ( it - > key ( ) ) ; <nl> _estimator - > insert ( hash ) ; <nl> } <nl> + _estimator - > setCommitSeq ( seq ) ; <nl> } <nl> mmm a / arangod / RocksDBEngine / RocksDBEdgeIndex . h <nl> ppp b / arangod / RocksDBEngine / RocksDBEdgeIndex . h <nl> class RocksDBEdgeIndex final : public RocksDBIndex { <nl> double selectivityEstimate ( arangodb : : StringRef const & = arangodb : : StringRef ( ) ) const override ; <nl> <nl> RocksDBCuckooIndexEstimator < uint64_t > * estimator ( ) override ; <nl> - bool needToPersistEstimate ( ) const override ; <nl> + void setEstimator ( std : : unique_ptr < RocksDBCuckooIndexEstimator < uint64_t > > ) override ; <nl> + void recalculateEstimates ( ) override ; <nl> <nl> void toVelocyPack ( VPackBuilder & , <nl> std : : underlying_type < Index : : Serialize > : : type ) const override ; <nl> class RocksDBEdgeIndex final : public RocksDBIndex { <nl> void warmup ( arangodb : : transaction : : Methods * trx , <nl> std : : shared_ptr < basics : : LocalTaskQueue > queue ) override ; <nl> <nl> - rocksdb : : SequenceNumber serializeEstimate ( <nl> - std : : string & output , rocksdb : : SequenceNumber seq ) const override ; <nl> - <nl> - bool deserializeEstimate ( arangodb : : RocksDBSettingsManager * mgr ) override ; <nl> - <nl> void afterTruncate ( TRI_voc_tick_t tick ) override ; <nl> - void recalculateEstimates ( ) override ; <nl> <nl> Result insertInternal ( transaction : : Methods * , RocksDBMethods * , <nl> LocalDocumentId const & documentId , <nl> mmm a / arangod / RocksDBEngine / RocksDBEngine . cpp <nl> ppp b / arangod / RocksDBEngine / RocksDBEngine . cpp <nl> Result RocksDBEngine : : writeDatabaseMarker ( TRI_voc_tick_t id , <nl> rocksdb : : WriteBatch batch ; <nl> batch . PutLogData ( logValue . slice ( ) ) ; <nl> batch . Put ( RocksDBColumnFamily : : definitions ( ) , key . string ( ) , value . string ( ) ) ; <nl> - rocksdb : : Status res = _db - > Write ( wo , & batch ) ; <nl> + rocksdb : : Status res = _db - > GetRootDB ( ) - > Write ( wo , & batch ) ; <nl> return rocksutils : : convertStatus ( res ) ; <nl> } <nl> <nl> int RocksDBEngine : : writeCreateCollectionMarker ( TRI_voc_tick_t databaseId , <nl> RocksDBKey key ; <nl> key . constructCollection ( databaseId , cid ) ; <nl> auto value = RocksDBValue : : Collection ( slice ) ; <nl> + <nl> rocksdb : : WriteOptions wo ; <nl> - <nl> / / Write marker + key into RocksDB inside one batch <nl> rocksdb : : WriteBatch batch ; <nl> batch . PutLogData ( logValue . slice ( ) ) ; <nl> batch . Put ( RocksDBColumnFamily : : definitions ( ) , key . string ( ) , value . string ( ) ) ; <nl> - rocksdb : : Status res = _db - > Write ( wo , & batch ) ; <nl> + rocksdb : : Status res = _db - > GetRootDB ( ) - > Write ( wo , & batch ) ; <nl> <nl> auto result = rocksutils : : convertStatus ( res ) ; <nl> return result . errorNumber ( ) ; <nl> bool RocksDBEngine : : inRecovery ( ) { <nl> } <nl> <nl> void RocksDBEngine : : recoveryDone ( TRI_vocbase_t & vocbase ) { <nl> - / / nothing to do here <nl> - settingsManager ( ) - > clearIndexEstimators ( ) ; <nl> - settingsManager ( ) - > clearKeyGenerators ( ) ; <nl> } <nl> <nl> std : : string RocksDBEngine : : createCollection ( <nl> arangodb : : Result RocksDBEngine : : dropCollection ( <nl> bool const prefixSameAsStart = true ; <nl> bool const useRangeDelete = coll - > numberDocuments ( ) > = 32 * 1024 ; <nl> <nl> - rocksdb : : WriteOptions wo ; <nl> + rocksdb : : DB * db = _db - > GetRootDB ( ) ; <nl> <nl> / / If we get here the collection is safe to drop . <nl> / / <nl> arangodb : : Result RocksDBEngine : : dropCollection ( <nl> key . constructCollection ( vocbase . id ( ) , collection . id ( ) ) ; <nl> batch . Delete ( RocksDBColumnFamily : : definitions ( ) , key . string ( ) ) ; <nl> <nl> - rocksdb : : Status res = _db - > Write ( wo , & batch ) ; <nl> + rocksdb : : WriteOptions wo ; <nl> + rocksdb : : Status s = db - > Write ( wo , & batch ) ; <nl> <nl> / / TODO FAILURE Simulate ! res . ok ( ) <nl> - if ( ! res . ok ( ) ) { <nl> + if ( ! s . ok ( ) ) { <nl> / / Persisting the drop failed . Do NOT drop collection . <nl> - return rocksutils : : convertStatus ( res ) ; <nl> + return rocksutils : : convertStatus ( s ) ; <nl> } <nl> <nl> / / Now Collection is gone . <nl> / / Cleanup data - mess <nl> <nl> - / / Unregister counter <nl> - _settingsManager - > removeCounter ( coll - > objectId ( ) ) ; <nl> - <nl> + / / Unregister collection metadata <nl> + Result res = RocksDBCollectionMeta : : deleteCollectionMeta ( db , coll - > objectId ( ) ) ; <nl> + if ( res . fail ( ) ) { <nl> + LOG_TOPIC ( ERR , Logger : : ENGINES ) < < " error removing collection meta - data : " <nl> + < < res . errorMessage ( ) ; / / continue regardless <nl> + } <nl> + <nl> / / remove from map <nl> { <nl> WRITE_LOCKER ( guard , _mapLock ) ; <nl> _collectionMap . erase ( collection . id ( ) ) ; <nl> } <nl> + <nl> + / / delete indexes , RocksDBIndex : : drop ( ) has its own check <nl> + std : : vector < std : : shared_ptr < Index > > vecShardIndex = coll - > getIndexes ( ) ; <nl> + TRI_ASSERT ( ! vecShardIndex . empty ( ) ) ; <nl> + for ( auto & index : vecShardIndex ) { <nl> + RocksDBIndex * ridx = static_cast < RocksDBIndex * > ( index . get ( ) ) ; <nl> + res = RocksDBCollectionMeta : : deleteIndexEstimate ( db , ridx - > objectId ( ) ) ; <nl> + if ( res . fail ( ) ) { <nl> + LOG_TOPIC ( WARN , Logger : : ENGINES ) < < " could not delete index estimate : " <nl> + < < res . errorMessage ( ) ; <nl> + } <nl> + <nl> + int dropRes = index - > drop ( ) ; <nl> + if ( dropRes ! = TRI_ERROR_NO_ERROR ) { <nl> + / / We try to remove all indexed values . <nl> + / / If it does not work they cannot be accessed any more and leaked . <nl> + / / User View remains consistent . <nl> + LOG_TOPIC ( ERR , Logger : : ENGINES ) < < " unable to drop index : " <nl> + < < TRI_errno_string ( dropRes ) ; <nl> + / / return TRI_ERROR_NO_ERROR ; <nl> + } <nl> + } <nl> <nl> / / delete documents <nl> RocksDBKeyBounds bounds = <nl> RocksDBKeyBounds : : CollectionDocuments ( coll - > objectId ( ) ) ; <nl> - auto result = rocksutils : : removeLargeRange ( _db , bounds , prefixSameAsStart , useRangeDelete ) ; <nl> + auto result = rocksutils : : removeLargeRange ( db , bounds , prefixSameAsStart , useRangeDelete ) ; <nl> <nl> if ( result . fail ( ) ) { <nl> / / We try to remove all documents . <nl> arangodb : : Result RocksDBEngine : : dropCollection ( <nl> } <nl> # endif <nl> <nl> - / / delete indexes , RocksDBIndex : : drop ( ) has its own check <nl> - std : : vector < std : : shared_ptr < Index > > vecShardIndex = coll - > getIndexes ( ) ; <nl> - TRI_ASSERT ( ! vecShardIndex . empty ( ) ) ; <nl> - for ( auto & index : vecShardIndex ) { <nl> - int dropRes = index - > drop ( ) ; <nl> - <nl> - if ( dropRes ! = TRI_ERROR_NO_ERROR ) { <nl> - / / We try to remove all indexed values . <nl> - / / If it does not work they cannot be accessed any more and leaked . <nl> - / / User View remains consistent . <nl> - LOG_TOPIC ( ERR , Logger : : ENGINES ) < < " unable to drop index : " <nl> - < < TRI_errno_string ( dropRes ) ; <nl> - return TRI_ERROR_NO_ERROR ; <nl> - } <nl> - } <nl> - <nl> / / run compaction for data only if collection contained a considerable <nl> / / amount of documents . otherwise don ' t run compaction , because it will <nl> / / slow things down a lot , especially during tests that create / drop LOTS <nl> arangodb : : Result RocksDBEngine : : dropView ( <nl> key . constructView ( vocbase . id ( ) , view . id ( ) ) ; <nl> <nl> rocksdb : : WriteBatch batch ; <nl> - rocksdb : : WriteOptions wo ; / / TODO : check which options would make sense <nl> - auto db = rocksutils : : globalRocksDB ( ) ; <nl> - <nl> batch . PutLogData ( logValue . slice ( ) ) ; <nl> batch . Delete ( RocksDBColumnFamily : : definitions ( ) , key . string ( ) ) ; <nl> <nl> - auto res = db - > Write ( wo , & batch ) ; <nl> + rocksdb : : WriteOptions wo ; <nl> + auto res = _db - > GetRootDB ( ) - > Write ( wo , & batch ) ; <nl> LOG_TOPIC_IF ( TRACE , Logger : : VIEWS , ! res . ok ( ) ) <nl> < < " could not create view : " < < res . ToString ( ) ; <nl> return rocksutils : : convertStatus ( res ) ; <nl> void RocksDBEngine : : addCollectionMapping ( uint64_t objectId , TRI_voc_tick_t did , <nl> _collectionMap [ objectId ] = std : : make_pair ( did , cid ) ; <nl> } <nl> } <nl> + <nl> + std : : vector < std : : pair < TRI_voc_tick_t , TRI_voc_cid_t > > RocksDBEngine : : collectionMappings ( ) const { <nl> + std : : vector < std : : pair < TRI_voc_tick_t , TRI_voc_cid_t > > res ; <nl> + READ_LOCKER ( guard , _mapLock ) ; <nl> + for ( auto const & it : _collectionMap ) { <nl> + res . emplace_back ( it . second . first , it . second . second ) ; <nl> + } <nl> + return res ; <nl> + } <nl> <nl> void RocksDBEngine : : addIndexMapping ( uint64_t objectId , TRI_voc_tick_t did , <nl> TRI_voc_cid_t cid , TRI_idx_iid_t iid ) { <nl> void RocksDBEngine : : waitForEstimatorSync ( <nl> std : : chrono : : milliseconds maxWaitTime ) { <nl> auto start = std : : chrono : : high_resolution_clock : : now ( ) ; <nl> auto beginSeq = _db - > GetLatestSequenceNumber ( ) ; <nl> + <nl> while ( std : : chrono : : high_resolution_clock : : now ( ) - start < maxWaitTime ) { <nl> if ( _settingsManager - > earliestSeqNeeded ( ) > = beginSeq ) { <nl> / / all synced up ! <nl> void RocksDBEngine : : determinePrunableWalFiles ( TRI_voc_tick_t minTickExternal ) { <nl> <nl> auto status = _db - > GetSortedWalFiles ( files ) ; <nl> if ( ! status . ok ( ) ) { <nl> - return ; / / TODO : error here ? <nl> + LOG_TOPIC ( INFO , Logger : : ENGINES ) < < " could not get WAL files " <nl> + < < status . ToString ( ) ; <nl> + return ; <nl> } <nl> <nl> size_t lastLess = files . size ( ) ; <nl> void RocksDBEngine : : pruneWalFiles ( ) { <nl> <nl> Result RocksDBEngine : : dropDatabase ( TRI_voc_tick_t id ) { <nl> using namespace rocksutils ; <nl> - Result res ; <nl> + arangodb : : Result res ; <nl> rocksdb : : WriteOptions wo ; <nl> + rocksdb : : DB * db = _db - > GetRootDB ( ) ; <nl> <nl> / / remove view definitions <nl> - iterateBounds ( RocksDBKeyBounds : : DatabaseViews ( id ) , <nl> - [ & ] ( rocksdb : : Iterator * it ) { <nl> - RocksDBKey key ( it - > key ( ) ) ; <nl> - res = globalRocksDBRemove ( RocksDBColumnFamily : : definitions ( ) , <nl> - key . string ( ) , wo ) ; <nl> - if ( res . fail ( ) ) { <nl> - return ; <nl> - } <nl> - } ) ; <nl> - <nl> + res = rocksutils : : removeLargeRange ( db , RocksDBKeyBounds : : DatabaseViews ( id ) , <nl> + true , / * rangeDel * / false ) ; <nl> if ( res . fail ( ) ) { <nl> return res ; <nl> } <nl> Result RocksDBEngine : : dropDatabase ( TRI_voc_tick_t id ) { <nl> # endif <nl> <nl> / / remove collections <nl> - RocksDBKeyBounds bounds = RocksDBKeyBounds : : DatabaseCollections ( id ) ; <nl> - iterateBounds ( bounds , [ & ] ( rocksdb : : Iterator * it ) { <nl> + auto dbBounds = RocksDBKeyBounds : : DatabaseCollections ( id ) ; <nl> + iterateBounds ( dbBounds , [ & ] ( rocksdb : : Iterator * it ) { <nl> RocksDBKey key ( it - > key ( ) ) ; <nl> RocksDBValue value ( RocksDBEntryType : : Collection , it - > value ( ) ) ; <nl> <nl> uint64_t const objectId = <nl> basics : : VelocyPackHelper : : stringUInt64 ( value . slice ( ) , " objectId " ) ; <nl> - auto const cnt = _settingsManager - > loadCounter ( objectId ) ; <nl> - uint64_t const numberDocuments = cnt . added ( ) - cnt . removed ( ) ; <nl> + <nl> + auto const cnt = RocksDBCollectionMeta : : loadCollectionCount ( _db , objectId ) ; <nl> + uint64_t const numberDocuments = cnt . _added - cnt . _removed ; <nl> bool const useRangeDelete = numberDocuments > = 32 * 1024 ; <nl> <nl> / / remove indexes <nl> Result RocksDBEngine : : dropDatabase ( TRI_voc_tick_t id ) { <nl> / / delete index documents <nl> uint64_t objectId = <nl> basics : : VelocyPackHelper : : stringUInt64 ( it , " objectId " ) ; <nl> + res = RocksDBCollectionMeta : : deleteIndexEstimate ( db , objectId ) ; <nl> + if ( res . fail ( ) ) { <nl> + return ; <nl> + } <nl> + <nl> TRI_ASSERT ( it . get ( StaticStrings : : IndexType ) . isString ( ) ) ; <nl> auto type = Index : : type ( it . get ( StaticStrings : : IndexType ) . copyString ( ) ) ; <nl> bool unique = basics : : VelocyPackHelper : : getBooleanValue ( <nl> Result RocksDBEngine : : dropDatabase ( TRI_voc_tick_t id ) { <nl> RocksDBIndex : : getBounds ( type , objectId , unique ) ; <nl> / / edge index drop fails otherwise <nl> bool const prefixSameAsStart = type ! = Index : : TRI_IDX_TYPE_EDGE_INDEX ; <nl> - res = rocksutils : : removeLargeRange ( _db , bounds , prefixSameAsStart , useRangeDelete ) ; <nl> + res = rocksutils : : removeLargeRange ( db , bounds , prefixSameAsStart , useRangeDelete ) ; <nl> if ( res . fail ( ) ) { <nl> return ; <nl> } <nl> <nl> # ifdef ARANGODB_ENABLE_MAINTAINER_MODE <nl> / / check if documents have been deleted <nl> - numDocsLeft + = rocksutils : : countKeyRange ( rocksutils : : globalRocksDB ( ) , <nl> - bounds , prefixSameAsStart ) ; <nl> + numDocsLeft + = rocksutils : : countKeyRange ( db , bounds , prefixSameAsStart ) ; <nl> # endif <nl> } <nl> } <nl> <nl> - <nl> / / delete documents <nl> RocksDBKeyBounds bounds = RocksDBKeyBounds : : CollectionDocuments ( objectId ) ; <nl> - res = rocksutils : : removeLargeRange ( _db , bounds , true , useRangeDelete ) ; <nl> + res = rocksutils : : removeLargeRange ( db , bounds , true , useRangeDelete ) ; <nl> if ( res . fail ( ) ) { <nl> + LOG_TOPIC ( WARN , Logger : : ENGINES ) < < " error deleting collection documents : ' " <nl> + < < res . errorMessage ( ) < < " ' " ; <nl> return ; <nl> } <nl> / / delete collection meta - data <nl> - _settingsManager - > removeCounter ( objectId ) ; <nl> - res = globalRocksDBRemove ( RocksDBColumnFamily : : definitions ( ) , value . string ( ) , wo ) ; <nl> + res = RocksDBCollectionMeta : : deleteCollectionMeta ( db , objectId ) ; <nl> if ( res . fail ( ) ) { <nl> + LOG_TOPIC ( WARN , Logger : : ENGINES ) < < " error deleting collection metadata : ' " <nl> + < < res . errorMessage ( ) < < " ' " ; <nl> + return ; <nl> + } <nl> + / / remove collection entry <nl> + rocksdb : : Status s = db - > Delete ( wo , RocksDBColumnFamily : : definitions ( ) , value . string ( ) ) ; <nl> + if ( ! s . ok ( ) ) { <nl> + LOG_TOPIC ( WARN , Logger : : ENGINES ) < < " error deleting collection definition : " < < s . ToString ( ) ; <nl> return ; <nl> } <nl> <nl> # ifdef ARANGODB_ENABLE_MAINTAINER_MODE <nl> / / check if documents have been deleted <nl> numDocsLeft + = <nl> - rocksutils : : countKeyRange ( rocksutils : : globalRocksDB ( ) , bounds , true ) ; <nl> + rocksutils : : countKeyRange ( db , bounds , true ) ; <nl> # endif <nl> } ) ; <nl> <nl> Result RocksDBEngine : : dropDatabase ( TRI_voc_tick_t id ) { <nl> return res ; <nl> } <nl> <nl> - <nl> / / remove database meta - data <nl> RocksDBKey key ; <nl> key . constructDatabase ( id ) ; <nl> - res = rocksutils : : globalRocksDBRemove ( RocksDBColumnFamily : : definitions ( ) , <nl> - key . string ( ) , wo ) ; <nl> + rocksdb : : Status s = db - > Delete ( wo , RocksDBColumnFamily : : definitions ( ) , key . string ( ) ) ; <nl> + if ( ! s . ok ( ) ) { <nl> + LOG_TOPIC ( WARN , Logger : : ENGINES ) < < " error deleting database definition : " < < s . ToString ( ) ; <nl> + } <nl> <nl> / / remove VERSION file for database . it ' s not a problem when this fails <nl> / / because it will simply remain there and be ignored on subsequent starts <nl> std : : unique_ptr < TRI_vocbase_t > RocksDBEngine : : openExistingDatabase ( <nl> std : : make_shared < arangodb : : LogicalCollection > ( * vocbase , it , false ) ; <nl> auto collection = uniqCol . get ( ) ; <nl> TRI_ASSERT ( collection ! = nullptr ) ; <nl> - StorageEngine : : registerCollection ( * vocbase , uniqCol ) ; <nl> - auto physical = <nl> - static_cast < RocksDBCollection * > ( collection - > getPhysical ( ) ) ; <nl> - TRI_ASSERT ( physical ! = nullptr ) ; <nl> <nl> - physical - > deserializeIndexEstimates ( settingsManager ( ) ) ; <nl> - physical - > deserializeKeyGenerator ( settingsManager ( ) ) ; <nl> + auto phy = static_cast < RocksDBCollection * > ( collection - > getPhysical ( ) ) ; <nl> + TRI_ASSERT ( phy ! = nullptr ) ; <nl> + phy - > meta ( ) . deserializeMeta ( _db , * collection ) ; <nl> + <nl> + StorageEngine : : registerCollection ( * vocbase , uniqCol ) ; <nl> LOG_TOPIC ( DEBUG , arangodb : : Logger : : ENGINES ) <nl> < < " added document collection ' " < < collection - > name ( ) < < " ' " ; <nl> } <nl> bool RocksDBEngine : : canUseRangeDeleteInWal ( ) const { <nl> <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> / / - - SECTION - - END - OF - FILE <nl> - / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> \ No newline at end of file <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> mmm a / arangod / RocksDBEngine / RocksDBEngine . h <nl> ppp b / arangod / RocksDBEngine / RocksDBEngine . h <nl> class RocksDBEngine final : public StorageEngine { <nl> RocksDBLogValue & & logValue ) ; <nl> <nl> void addCollectionMapping ( uint64_t , TRI_voc_tick_t , TRI_voc_cid_t ) ; <nl> + std : : vector < std : : pair < TRI_voc_tick_t , TRI_voc_cid_t > > collectionMappings ( ) const ; <nl> void addIndexMapping ( uint64_t objectId , TRI_voc_tick_t , <nl> TRI_voc_cid_t , TRI_idx_iid_t ) ; <nl> void removeIndexMapping ( uint64_t ) ; <nl> mmm a / arangod / RocksDBEngine / RocksDBGeoIndex . cpp <nl> ppp b / arangod / RocksDBEngine / RocksDBGeoIndex . cpp <nl> <nl> # include " Basics / StringRef . h " <nl> # include " Basics / VelocyPackHelper . h " <nl> # include " GeoIndex / Near . h " <nl> - # include " Indexes / IndexResult . h " <nl> # include " Logger / Logger . h " <nl> # include " RocksDBEngine / RocksDBCommon . h " <nl> # include " RocksDBEngine / RocksDBMethods . h " <nl> Result RocksDBGeoIndex : : insertInternal ( transaction : : Methods * trx , <nl> LocalDocumentId const & documentId , <nl> velocypack : : Slice const & doc , <nl> OperationMode mode ) { <nl> + Result res ; <nl> + <nl> / / covering and centroid of coordinate / polygon / . . . <nl> size_t reserve = _variant = = Variant : : GEOJSON ? 8 : 1 ; <nl> std : : vector < S2CellId > cells ; <nl> cells . reserve ( reserve ) ; <nl> S2Point centroid ; <nl> - Result res = geo_index : : Index : : indexCells ( doc , cells , centroid ) ; <nl> + res = geo_index : : Index : : indexCells ( doc , cells , centroid ) ; <nl> if ( res . fail ( ) ) { <nl> - / / Invalid , no insert . Index is sparse <nl> - return res . is ( TRI_ERROR_BAD_PARAMETER ) ? IndexResult ( ) : res ; <nl> + if ( res . is ( TRI_ERROR_BAD_PARAMETER ) ) { <nl> + res . reset ( ) ; / / Invalid , no insert . Index is sparse <nl> + } <nl> + return res ; <nl> } <nl> TRI_ASSERT ( ! cells . empty ( ) ) ; <nl> TRI_ASSERT ( S2 : : IsUnitLength ( centroid ) ) ; <nl> Result RocksDBGeoIndex : : insertInternal ( transaction : : Methods * trx , <nl> RocksDBKeyLeaser key ( trx ) ; <nl> for ( S2CellId cell : cells ) { <nl> key - > constructGeoIndexValue ( _objectId , cell . id ( ) , documentId ) ; <nl> - Result r = mthd - > Put ( RocksDBColumnFamily : : geo ( ) , key . ref ( ) , val . string ( ) ) ; <nl> - if ( r . fail ( ) ) { <nl> - return r ; <nl> + res = mthd - > Put ( RocksDBColumnFamily : : geo ( ) , key . ref ( ) , val . string ( ) ) ; <nl> + if ( res . fail ( ) ) { <nl> + return res ; <nl> } <nl> } <nl> <nl> - return IndexResult ( ) ; <nl> + return res ; <nl> } <nl> <nl> / / / internal remove function , set batch or trx before calling <nl> Result RocksDBGeoIndex : : removeInternal ( transaction : : Methods * trx , <nl> LocalDocumentId const & documentId , <nl> VPackSlice const & doc , <nl> OperationMode mode ) { <nl> + Result res ; <nl> + <nl> / / covering and centroid of coordinate / polygon / . . . <nl> std : : vector < S2CellId > cells ; <nl> S2Point centroid ; <nl> - Result res = geo_index : : Index : : indexCells ( doc , cells , centroid ) ; <nl> + res = geo_index : : Index : : indexCells ( doc , cells , centroid ) ; <nl> if ( res . fail ( ) ) { / / might occur if insert is rolled back <nl> - / / Invalid , no insert . Index is sparse <nl> - return res . is ( TRI_ERROR_BAD_PARAMETER ) ? IndexResult ( ) : res ; <nl> + if ( res . is ( TRI_ERROR_BAD_PARAMETER ) ) { <nl> + res . reset ( ) ; / / Invalid , no insert . Index is sparse <nl> + } <nl> + return res ; <nl> } <nl> TRI_ASSERT ( ! cells . empty ( ) ) ; <nl> <nl> Result RocksDBGeoIndex : : removeInternal ( transaction : : Methods * trx , <nl> / / the same cells everytime for the same parameters ? <nl> for ( S2CellId cell : cells ) { <nl> key - > constructGeoIndexValue ( _objectId , cell . id ( ) , documentId ) ; <nl> - Result r = mthd - > Delete ( RocksDBColumnFamily : : geo ( ) , key . ref ( ) ) ; <nl> - if ( r . fail ( ) ) { <nl> - return r ; <nl> + res = mthd - > Delete ( RocksDBColumnFamily : : geo ( ) , key . ref ( ) ) ; <nl> + if ( res . fail ( ) ) { <nl> + return res ; <nl> } <nl> } <nl> - return IndexResult ( ) ; <nl> + return res ; <nl> } <nl> mmm a / arangod / RocksDBEngine / RocksDBIndex . cpp <nl> ppp b / arangod / RocksDBEngine / RocksDBIndex . cpp <nl> void RocksDBIndex : : destroyCache ( ) { <nl> _cachePresent = false ; <nl> } <nl> <nl> - rocksdb : : SequenceNumber RocksDBIndex : : serializeEstimate ( <nl> - std : : string & , rocksdb : : SequenceNumber seq ) const { <nl> - / / All indexes that do not have an estimator do not serialize anything . <nl> - return seq ; <nl> - } <nl> - <nl> - bool RocksDBIndex : : deserializeEstimate ( RocksDBSettingsManager * ) { <nl> - / / All indexes that do not have an estimator do not deserialize anything . <nl> - / / So the estimate is always recreatable . <nl> - / / We do not advance anything here . <nl> - return true ; <nl> - } <nl> - <nl> - void RocksDBIndex : : recalculateEstimates ( ) { <nl> - / / Nothing to do . <nl> - return ; <nl> - } <nl> - <nl> int RocksDBIndex : : drop ( ) { <nl> auto * coll = toRocksDBCollection ( _collection ) ; <nl> / / edge index needs to be dropped with prefixSameAsStart = false <nl> RocksDBCuckooIndexEstimator < uint64_t > * RocksDBIndex : : estimator ( ) { <nl> return nullptr ; <nl> } <nl> <nl> - bool RocksDBIndex : : needToPersistEstimate ( ) const { <nl> - return false ; <nl> + void RocksDBIndex : : setEstimator ( std : : unique_ptr < RocksDBCuckooIndexEstimator < uint64_t > > ) { <nl> + / / Nothing to do . <nl> } <nl> mmm a / arangod / RocksDBEngine / RocksDBIndex . h <nl> ppp b / arangod / RocksDBEngine / RocksDBIndex . h <nl> class RocksDBIndex : public Index { <nl> void createCache ( ) ; <nl> void destroyCache ( ) ; <nl> <nl> - virtual rocksdb : : SequenceNumber serializeEstimate ( <nl> - std : : string & output , rocksdb : : SequenceNumber seq ) const ; <nl> - <nl> - virtual bool deserializeEstimate ( RocksDBSettingsManager * mgr ) ; <nl> - <nl> - virtual void recalculateEstimates ( ) ; <nl> - <nl> / / / insert index elements into the specified write batch . <nl> virtual Result insertInternal ( transaction : : Methods * trx , RocksDBMethods * , <nl> LocalDocumentId const & documentId , <nl> class RocksDBIndex : public Index { <nl> bool unique ) ; <nl> <nl> virtual RocksDBCuckooIndexEstimator < uint64_t > * estimator ( ) ; <nl> - virtual bool needToPersistEstimate ( ) const ; <nl> + virtual void setEstimator ( std : : unique_ptr < RocksDBCuckooIndexEstimator < uint64_t > > ) ; <nl> + virtual void recalculateEstimates ( ) { } <nl> <nl> protected : <nl> RocksDBIndex ( <nl> mmm a / arangod / RocksDBEngine / RocksDBMethods . cpp <nl> ppp b / arangod / RocksDBEngine / RocksDBMethods . cpp <nl> RocksDBTrxMethods : : RocksDBTrxMethods ( RocksDBTransactionState * state ) <nl> bool RocksDBTrxMethods : : Exists ( rocksdb : : ColumnFamilyHandle * cf , <nl> RocksDBKey const & key ) { <nl> TRI_ASSERT ( cf ! = nullptr ) ; <nl> - std : : string val ; <nl> + rocksdb : : PinnableSlice val ; <nl> rocksdb : : Status s = _state - > _rocksTransaction - > Get ( _state - > _rocksReadOptions , <nl> cf , key . string ( ) , & val ) ; <nl> return ! s . IsNotFound ( ) ; <nl> bool RocksDBBatchedMethods : : Exists ( rocksdb : : ColumnFamilyHandle * cf , <nl> RocksDBKey const & key ) { <nl> TRI_ASSERT ( cf ! = nullptr ) ; <nl> rocksdb : : ReadOptions ro ; <nl> - std : : string val ; / / do not care about value <nl> + rocksdb : : PinnableSlice val ; <nl> rocksdb : : Status s = _wb - > GetFromBatchAndDB ( _db , ro , cf , key . string ( ) , & val ) ; <nl> return ! s . IsNotFound ( ) ; <nl> } <nl> mmm a / arangod / RocksDBEngine / RocksDBPrimaryIndex . cpp <nl> ppp b / arangod / RocksDBEngine / RocksDBPrimaryIndex . cpp <nl> Result RocksDBPrimaryIndex : : insertInternal ( transaction : : Methods * trx , <nl> LocalDocumentId const & documentId , <nl> VPackSlice const & slice , <nl> OperationMode mode ) { <nl> + IndexResult res ; <nl> + <nl> VPackSlice keySlice = transaction : : helpers : : extractKeyFromDocument ( slice ) ; <nl> RocksDBKeyLeaser key ( trx ) ; <nl> key - > constructPrimaryIndexValue ( _objectId , StringRef ( keySlice ) ) ; <nl> <nl> if ( mthd - > Exists ( _cf , key . ref ( ) ) ) { <nl> std : : string existingId ( slice . get ( StaticStrings : : KeyString ) . copyString ( ) ) ; <nl> - <nl> if ( mode = = OperationMode : : internal ) { <nl> - return IndexResult ( TRI_ERROR_ARANGO_UNIQUE_CONSTRAINT_VIOLATED , <nl> - std : : move ( existingId ) ) ; <nl> + return res . reset ( TRI_ERROR_ARANGO_UNIQUE_CONSTRAINT_VIOLATED , std : : move ( existingId ) ) ; <nl> } <nl> - return IndexResult ( TRI_ERROR_ARANGO_UNIQUE_CONSTRAINT_VIOLATED , this , <nl> - existingId ) ; <nl> + return res . reset ( TRI_ERROR_ARANGO_UNIQUE_CONSTRAINT_VIOLATED , this , existingId ) ; <nl> } <nl> <nl> blackListKey ( key - > string ( ) . data ( ) , static_cast < uint32_t > ( key - > string ( ) . size ( ) ) ) ; <nl> Result RocksDBPrimaryIndex : : insertInternal ( transaction : : Methods * trx , <nl> auto value = RocksDBValue : : PrimaryIndexValue ( documentId , revision ) ; <nl> <nl> Result status = mthd - > Put ( _cf , key . ref ( ) , value . string ( ) , rocksutils : : index ) ; <nl> - return IndexResult ( status . errorNumber ( ) , this ) ; <nl> + return res . reset ( status , this ) ; <nl> } <nl> <nl> Result RocksDBPrimaryIndex : : updateInternal ( transaction : : Methods * trx , <nl> mmm a / arangod / RocksDBEngine / RocksDBRecoveryManager . cpp <nl> ppp b / arangod / RocksDBEngine / RocksDBRecoveryManager . cpp <nl> class WBReader final : public rocksdb : : WriteBatch : : Handler { <nl> bool mustTruncate = false ; <nl> } ; <nl> <nl> - rocksdb : : SequenceNumber currentSeqNum ; <nl> - <nl> private : <nl> <nl> / / contains the operations we counted <nl> - std : : unordered_map < uint64_t , WBReader : : Operations > _deltas ; <nl> + std : : map < uint64_t , WBReader : : Operations > _deltas ; <nl> / / used to track used IDs for key - generators <nl> - std : : unordered_map < uint64_t , uint64_t > _generators ; <nl> + std : : map < uint64_t , uint64_t > _generators ; <nl> <nl> / / max tick found <nl> uint64_t _maxTick = 0 ; <nl> uint64_t _maxHLC = 0 ; <nl> / / / @ brief last document removed <nl> TRI_voc_rid_t _lastRemovedDocRid = 0 ; <nl> + <nl> + rocksdb : : SequenceNumber _startSequence ; / / / start of batch sequence nr <nl> + rocksdb : : SequenceNumber _currentSequence ; / / / current sequence nr <nl> + bool _startOfBatch = false ; <nl> <nl> public : <nl> <nl> / / / @ param seqs sequence number from which to count operations <nl> - explicit WBReader ( std : : unordered_map < uint64_t , rocksdb : : SequenceNumber > const & seqs ) <nl> - : currentSeqNum ( 0 ) { <nl> + explicit WBReader ( std : : map < uint64_t , rocksdb : : SequenceNumber > const & seqs ) <nl> + : _startSequence ( 0 ) , <nl> + _currentSequence ( 0 ) { <nl> for ( auto const & pair : seqs ) { <nl> try { <nl> _deltas . emplace ( pair . first , Operations ( pair . second ) ) ; <nl> class WBReader final : public rocksdb : : WriteBatch : : Handler { <nl> } <nl> } <nl> <nl> + void startNewBatch ( rocksdb : : SequenceNumber startSequence ) { <nl> + / / starting new write batch <nl> + _startSequence = startSequence ; <nl> + _currentSequence = startSequence ; <nl> + _startOfBatch = true ; <nl> + } <nl> + <nl> Result shutdownWBReader ( ) { <nl> Result rv = basics : : catchVoidToResult ( [ & ] ( ) - > void { <nl> / / update ticks after parsing wal <nl> class WBReader final : public rocksdb : : WriteBatch : : Handler { <nl> <nl> LOG_TOPIC ( TRACE , Logger : : ENGINES ) < < " finished WAL scan with " < < _deltas . size ( ) < < " entries " ; <nl> <nl> - RocksDBEngine * engine = static_cast < RocksDBEngine * > ( EngineSelectorFeature : : ENGINE ) ; <nl> - RocksDBSettingsManager * mgr = engine - > settingsManager ( ) ; <nl> for ( auto & pair : _deltas ) { <nl> WBReader : : Operations const & ops = pair . second ; <nl> - if ( ops . mustTruncate ) { / / first we must reset the counter <nl> - mgr - > setAbsoluteCounter ( pair . first , ops . lastSequenceNumber , 0 ) ; <nl> - } <nl> - RocksDBSettingsManager : : CounterAdjustment adj { } ; <nl> - adj . _sequenceNum = ops . lastSequenceNumber ; <nl> - adj . _added = ops . added ; <nl> - adj . _removed = ops . removed ; <nl> - adj . _revisionId = ops . lastRevisionId ; <nl> - <nl> - mgr - > updateCounter ( pair . first , adj ) ; <nl> - LOG_TOPIC ( TRACE , Logger : : ENGINES ) <nl> - < < " WAL recovered " < < adj . added ( ) < < " PUTs and " <nl> - < < adj . removed ( ) < < " DELETEs for objectID " < < pair . first ; <nl> - <nl> / / now adjust the counter in collections which are already loaded <nl> auto dbColPair = rocksutils : : mapObjectToCollection ( pair . first ) ; <nl> if ( dbColPair . second = = 0 & & dbColPair . first = = 0 ) { <nl> class WBReader final : public rocksdb : : WriteBatch : : Handler { <nl> if ( collection = = nullptr ) { <nl> continue ; <nl> } <nl> - if ( collection - > status ( ) = = TRI_VOC_COL_STATUS_LOADED ) { <nl> - auto * rcoll = static_cast < RocksDBCollection * > ( collection - > getPhysical ( ) ) ; <nl> - rcoll - > loadInitialNumberDocuments ( ) ; <nl> + <nl> + auto * rcoll = static_cast < RocksDBCollection * > ( collection - > getPhysical ( ) ) ; <nl> + if ( ops . mustTruncate ) { / / first we must reset the counter <nl> + rcoll - > meta ( ) . countRefUnsafe ( ) . _added = 0 ; <nl> + rcoll - > meta ( ) . countRefUnsafe ( ) . _removed = 0 ; <nl> + } <nl> + rcoll - > meta ( ) . countRefUnsafe ( ) . _added + = ops . added ; <nl> + rcoll - > meta ( ) . countRefUnsafe ( ) . _removed + = ops . removed ; <nl> + if ( ops . lastRevisionId ) { <nl> + rcoll - > meta ( ) . countRefUnsafe ( ) . _revisionId = ops . lastRevisionId ; <nl> + } <nl> + TRI_ASSERT ( rcoll - > meta ( ) . countRefUnsafe ( ) . _added > = rcoll - > meta ( ) . countRefUnsafe ( ) . _removed ) ; <nl> + rcoll - > loadInitialNumberDocuments ( ) ; <nl> + <nl> + auto const & it = _generators . find ( rcoll - > objectId ( ) ) ; <nl> + if ( it ! = _generators . end ( ) ) { <nl> + std : : string k ( basics : : StringUtils : : itoa ( it - > second ) ) ; <nl> + collection - > keyGenerator ( ) - > track ( k . data ( ) , k . size ( ) ) ; <nl> + _generators . erase ( it ) ; <nl> } <nl> } <nl> - <nl> + / / make sure we collect all the other generators <nl> for ( auto gen : _generators ) { <nl> if ( gen . second > 0 ) { <nl> auto dbColPair = rocksutils : : mapObjectToCollection ( gen . first ) ; <nl> class WBReader final : public rocksdb : : WriteBatch : : Handler { <nl> } ) ; <nl> return rv ; <nl> } <nl> + <nl> + private : <nl> <nl> bool shouldHandleCollection ( uint64_t objectId , Operations * * ops ) { <nl> auto it = _deltas . find ( objectId ) ; <nl> if ( it ! = _deltas . end ( ) ) { <nl> * ops = & ( it - > second ) ; <nl> - return it - > second . startSequenceNumber < = currentSeqNum ; <nl> + return it - > second . startSequenceNumber < _currentSequence ; <nl> } <nl> - auto res = _deltas . emplace ( objectId , currentSeqNum ) ; / / do not ignore unknown counters <nl> + auto res = _deltas . emplace ( objectId , _currentSequence ) ; / / do not ignore unknown counters <nl> * ops = & ( res . first - > second ) ; <nl> return true ; <nl> } <nl> class WBReader final : public rocksdb : : WriteBatch : : Handler { <nl> return false ; <nl> } <nl> <nl> - for ( auto const & idx : coll - > getIndexes ( ) ) { <nl> - LOG_DEVEL < < " truncating index : " < < idx - > typeName ( ) ; <nl> + for ( std : : shared_ptr < arangodb : : Index > const & idx : coll - > getIndexes ( ) ) { <nl> RocksDBIndex * ridx = static_cast < RocksDBIndex * > ( idx . get ( ) ) ; <nl> RocksDBCuckooIndexEstimator < uint64_t > * est = ridx - > estimator ( ) ; <nl> - if ( est & & est - > commitSeq ( ) < currentSeqNum ) { <nl> - est - > bufferTruncate ( currentSeqNum ) ; <nl> + if ( est & & est - > committedSeq ( ) < _currentSequence ) { <nl> + est - > clear ( ) ; <nl> } <nl> } <nl> <nl> class WBReader final : public rocksdb : : WriteBatch : : Handler { <nl> } <nl> } <nl> } <nl> + <nl> + / / tick function that is called before each new WAL entry <nl> + void incTick ( ) { <nl> + if ( _startOfBatch ) { <nl> + / / we are at the start of a batch . do NOT increase sequence number <nl> + _startOfBatch = false ; <nl> + } else { <nl> + / / we are inside a batch already . now increase sequence number <nl> + + + _currentSequence ; <nl> + } <nl> + } <nl> + <nl> + public : <nl> <nl> rocksdb : : Status PutCF ( uint32_t column_family_id , const rocksdb : : Slice & key , <nl> const rocksdb : : Slice & value ) override { <nl> LOG_TOPIC ( TRACE , Logger : : ENGINES ) < < " recovering PUT " < < RocksDBKey ( key ) ; <nl> + incTick ( ) ; <nl> <nl> updateMaxTick ( column_family_id , key , value ) ; <nl> if ( column_family_id = = RocksDBColumnFamily : : documents ( ) - > GetID ( ) ) { <nl> class WBReader final : public rocksdb : : WriteBatch : : Handler { <nl> Operations * ops = nullptr ; <nl> if ( shouldHandleCollection ( objectId , & ops ) ) { <nl> TRI_ASSERT ( ops ! = nullptr ) ; <nl> - ops - > lastSequenceNumber = currentSeqNum ; <nl> + ops - > lastSequenceNumber = _currentSequence ; <nl> ops - > added + + ; <nl> ops - > lastRevisionId = transaction : : helpers : : extractRevFromDocument ( RocksDBValue : : data ( value ) ) ; <nl> } <nl> class WBReader final : public rocksdb : : WriteBatch : : Handler { <nl> if ( hash ! = 0 ) { <nl> uint64_t objectId = RocksDBKey : : objectId ( key ) ; <nl> auto est = findEstimator ( objectId ) ; <nl> - if ( est ! = nullptr & & est - > commitSeq ( ) < currentSeqNum ) { <nl> + if ( est ! = nullptr & & est - > committedSeq ( ) < _currentSequence ) { <nl> / / We track estimates for this index <nl> est - > insert ( hash ) ; <nl> } <nl> class WBReader final : public rocksdb : : WriteBatch : : Handler { <nl> <nl> void handleDeleteCF ( uint32_t cfId , <nl> const rocksdb : : Slice & key ) { <nl> + incTick ( ) ; <nl> <nl> if ( cfId = = RocksDBColumnFamily : : documents ( ) - > GetID ( ) ) { <nl> uint64_t objectId = RocksDBKey : : objectId ( key ) ; <nl> class WBReader final : public rocksdb : : WriteBatch : : Handler { <nl> Operations * ops = nullptr ; <nl> if ( shouldHandleCollection ( objectId , & ops ) ) { <nl> TRI_ASSERT ( ops ! = nullptr ) ; <nl> - ops - > lastSequenceNumber = currentSeqNum ; <nl> + ops - > lastSequenceNumber = _currentSequence ; <nl> ops - > removed + + ; <nl> if ( _lastRemovedDocRid ! = 0 ) { <nl> ops - > lastRevisionId = _lastRemovedDocRid ; <nl> class WBReader final : public rocksdb : : WriteBatch : : Handler { <nl> if ( hash ! = 0 ) { <nl> uint64_t objectId = RocksDBKey : : objectId ( key ) ; <nl> auto est = findEstimator ( objectId ) ; <nl> - if ( est ! = nullptr & & est - > commitSeq ( ) < currentSeqNum ) { <nl> + if ( est ! = nullptr & & est - > committedSeq ( ) < _currentSequence ) { <nl> / / We track estimates for this index <nl> est - > remove ( hash ) ; <nl> } <nl> class WBReader final : public rocksdb : : WriteBatch : : Handler { <nl> const rocksdb : : Slice & key ) override { <nl> LOG_TOPIC ( TRACE , Logger : : ENGINES ) <nl> < < " recovering DELETE " < < RocksDBKey ( key ) ; <nl> - <nl> handleDeleteCF ( column_family_id , key ) ; <nl> RocksDBEngine * engine = <nl> static_cast < RocksDBEngine * > ( EngineSelectorFeature : : ENGINE ) ; <nl> class WBReader final : public rocksdb : : WriteBatch : : Handler { <nl> const rocksdb : : Slice & key ) override { <nl> LOG_TOPIC ( TRACE , Logger : : ENGINES ) <nl> < < " recovering SINGLE DELETE " < < RocksDBKey ( key ) ; <nl> - <nl> handleDeleteCF ( column_family_id , key ) ; <nl> <nl> RocksDBEngine * engine = <nl> class WBReader final : public rocksdb : : WriteBatch : : Handler { <nl> LOG_TOPIC ( TRACE , Logger : : ENGINES ) <nl> < < " recovering DELETE RANGE from " < < RocksDBKey ( begin_key ) <nl> < < " to " < < RocksDBKey ( end_key ) ; <nl> + incTick ( ) ; <nl> / / drop and truncate can use this , truncate is handled via a Log marker <nl> RocksDBEngine * engine = <nl> static_cast < RocksDBEngine * > ( EngineSelectorFeature : : ENGINE ) ; <nl> class WBReader final : public rocksdb : : WriteBatch : : Handler { <nl> Operations * ops = nullptr ; <nl> if ( shouldHandleCollection ( objectId , & ops ) ) { <nl> TRI_ASSERT ( ops ! = nullptr ) ; <nl> - ops - > lastSequenceNumber = currentSeqNum ; <nl> + ops - > lastSequenceNumber = _currentSequence ; <nl> ops - > removed = 0 ; <nl> ops - > added = 0 ; <nl> ops - > mustTruncate = true ; <nl> class WBReader final : public rocksdb : : WriteBatch : : Handler { <nl> helper - > LogData ( blob ) ; <nl> } <nl> } <nl> + <nl> + / / MergeCF is not used <nl> } ; <nl> <nl> / / / parse the WAL with the above handler parser class <nl> Result RocksDBRecoveryManager : : parseRocksWAL ( ) { <nl> for ( auto & helper : engine - > recoveryHelpers ( ) ) { <nl> helper - > prepare ( ) ; <nl> } <nl> + <nl> + std : : map < uint64_t , rocksdb : : SequenceNumber > startSeqs ; <nl> + auto dbfeature = arangodb : : DatabaseFeature : : DATABASE ; <nl> + dbfeature - > enumerateDatabases ( [ & ] ( TRI_vocbase_t & vocbase ) { <nl> + vocbase . processCollections ( [ & ] ( LogicalCollection * coll ) { <nl> + RocksDBCollection * rcoll = static_cast < RocksDBCollection * > ( coll - > getPhysical ( ) ) ; <nl> + rocksdb : : SequenceNumber seq = rcoll - > meta ( ) . currentCount ( ) . _committedSeq ; <nl> + startSeqs . emplace ( rcoll - > objectId ( ) , seq ) ; <nl> + } , / * includeDeleted * / false ) ; <nl> + } ) ; <nl> <nl> / / Tell the WriteBatch reader the transaction markers to look for <nl> - WBReader handler ( engine - > settingsManager ( ) - > counterSeqs ( ) ) ; <nl> - <nl> - auto minTick = std : : min ( engine - > settingsManager ( ) - > earliestSeqNeeded ( ) , <nl> - engine - > releasedTick ( ) ) ; <nl> + WBReader handler ( startSeqs ) ; <nl> + rocksdb : : SequenceNumber earliest = engine - > settingsManager ( ) - > earliestSeqNeeded ( ) ; <nl> + auto minTick = std : : min ( earliest , engine - > releasedTick ( ) ) ; <nl> + <nl> std : : unique_ptr < rocksdb : : TransactionLogIterator > iterator ; / / reader ( ) ; <nl> rocksdb : : Status s = _db - > GetUpdatesSince ( <nl> minTick , & iterator , rocksdb : : TransactionLogIterator : : ReadOptions ( true ) ) ; <nl> Result RocksDBRecoveryManager : : parseRocksWAL ( ) { <nl> s = iterator - > status ( ) ; <nl> if ( s . ok ( ) ) { <nl> rocksdb : : BatchResult batch = iterator - > GetBatch ( ) ; <nl> - handler . currentSeqNum = batch . sequence ; <nl> + handler . startNewBatch ( batch . sequence ) ; <nl> s = batch . writeBatchPtr - > Iterate ( & handler ) ; <nl> } <nl> <nl> mmm a / arangod / RocksDBEngine / RocksDBSettingsManager . cpp <nl> ppp b / arangod / RocksDBEngine / RocksDBSettingsManager . cpp <nl> <nl> # include " RocksDBEngine / RocksDBCommon . h " <nl> # include " RocksDBEngine / RocksDBCuckooIndexEstimator . h " <nl> # include " RocksDBEngine / RocksDBEdgeIndex . h " <nl> + # include " RocksDBEngine / RocksDBEngine . h " <nl> # include " RocksDBEngine / RocksDBKey . h " <nl> # include " RocksDBEngine / RocksDBKeyBounds . h " <nl> # include " RocksDBEngine / RocksDBRecoveryHelper . h " <nl> <nl> # include < velocypack / velocypack - aliases . h > <nl> <nl> namespace { <nl> - std : : pair < arangodb : : Result , rocksdb : : SequenceNumber > <nl> - writeCounterValue ( std : : unordered_map < uint64_t , rocksdb : : SequenceNumber > const & syncedSeqNums , <nl> - rocksdb : : Transaction * rtrx , VPackBuilder & b , <nl> - std : : pair < uint64_t , arangodb : : RocksDBSettingsManager : : CMValue > const & pair , <nl> - rocksdb : : SequenceNumber baseSeq ) { <nl> - using arangodb : : Logger ; <nl> - using arangodb : : Result ; <nl> - using arangodb : : RocksDBColumnFamily ; <nl> - using arangodb : : RocksDBKey ; <nl> - using arangodb : : rocksutils : : convertStatus ; <nl> - <nl> - rocksdb : : SequenceNumber returnSeq = baseSeq ; <nl> - <nl> - / / Skip values which we did not change <nl> - auto const & it = syncedSeqNums . find ( pair . first ) ; <nl> - if ( it ! = syncedSeqNums . end ( ) & & it - > second = = pair . second . _sequenceNum ) { <nl> - / / implication : no - one update the collection since the last sync , <nl> - / / we do not need to keep the log entries for this counter <nl> - return std : : make_pair ( Result ( ) , returnSeq ) ; <nl> - } <nl> - <nl> - b . clear ( ) ; <nl> - pair . second . serialize ( b ) ; <nl> - <nl> - RocksDBKey key ; <nl> - key . constructCounterValue ( pair . first ) ; <nl> - rocksdb : : Slice value ( ( char * ) b . start ( ) , b . size ( ) ) ; <nl> - rocksdb : : Status s = <nl> - rtrx - > Put ( RocksDBColumnFamily : : definitions ( ) , key . string ( ) , value ) ; <nl> - if ( ! s . ok ( ) ) { <nl> - LOG_TOPIC ( WARN , Logger : : ENGINES ) <nl> - < < " writing counter for collection with objectId ' " < < pair . first < < " ' failed : " <nl> - < < s . ToString ( ) ; <nl> - return std : : make_pair ( convertStatus ( s ) , returnSeq ) ; <nl> - } <nl> - <nl> - returnSeq = std : : min ( returnSeq , pair . second . _sequenceNum ) ; <nl> - return std : : make_pair ( Result ( ) , returnSeq ) ; <nl> - } <nl> - } / / namespace <nl> - <nl> - namespace { <nl> - arangodb : : Result writeSettings ( rocksdb : : Transaction * rtrx , VPackBuilder & b , <nl> + arangodb : : Result writeSettings ( rocksdb : : WriteBatch & batch , VPackBuilder & b , <nl> uint64_t seqNumber ) { <nl> using arangodb : : EngineSelectorFeature ; <nl> using arangodb : : Logger ; <nl> arangodb : : Result writeSettings ( rocksdb : : Transaction * rtrx , VPackBuilder & b , <nl> key . constructSettingsValue ( RocksDBSettingsType : : ServerTick ) ; <nl> rocksdb : : Slice value ( slice . startAs < char > ( ) , slice . byteSize ( ) ) ; <nl> <nl> - rocksdb : : Status s = <nl> - rtrx - > Put ( RocksDBColumnFamily : : definitions ( ) , key . string ( ) , value ) ; <nl> - <nl> + rocksdb : : Status s = batch . Put ( RocksDBColumnFamily : : definitions ( ) , key . string ( ) , value ) ; <nl> if ( ! s . ok ( ) ) { <nl> LOG_TOPIC ( WARN , Logger : : ENGINES ) < < " writing settings failed : " < < s . ToString ( ) ; <nl> return arangodb : : rocksutils : : convertStatus ( s ) ; <nl> arangodb : : Result writeSettings ( rocksdb : : Transaction * rtrx , VPackBuilder & b , <nl> } <nl> } / / namespace <nl> <nl> - namespace { <nl> - std : : pair < arangodb : : Result , rocksdb : : SequenceNumber > <nl> - writeIndexEstimatorsAndKeyGenerator ( <nl> - rocksdb : : Transaction * rtrx , <nl> - std : : pair < uint64_t , arangodb : : RocksDBSettingsManager : : CMValue > const & pair , <nl> - rocksdb : : SequenceNumber baseSeq ) { <nl> - using arangodb : : DatabaseFeature ; <nl> - using arangodb : : Logger ; <nl> - using arangodb : : Result ; <nl> - using arangodb : : RocksDBCollection ; <nl> - using arangodb : : application_features : : ApplicationServer ; <nl> - using arangodb : : rocksutils : : mapObjectToCollection ; <nl> - <nl> - auto returnSeq = baseSeq ; <nl> - auto dbColPair = mapObjectToCollection ( pair . first ) ; <nl> - if ( dbColPair . second = = 0 & & dbColPair . first = = 0 ) { <nl> - / / collection with this objectID not known . Skip . <nl> - return std : : make_pair ( Result ( ) , returnSeq ) ; <nl> - } <nl> - auto dbfeature = ApplicationServer : : getFeature < DatabaseFeature > ( " Database " ) ; <nl> - TRI_ASSERT ( dbfeature ! = nullptr ) ; <nl> - auto vocbase = dbfeature - > useDatabase ( dbColPair . first ) ; <nl> - if ( vocbase = = nullptr ) { <nl> - / / Bad state , we have references to a database that is not known <nl> - / / anymore . <nl> - / / However let ' s just skip in production . Not allowed to crash . <nl> - / / If we cannot find this infos during recovery we can either recompute <nl> - / / or start fresh . <nl> - return std : : make_pair ( Result ( ) , returnSeq ) ; <nl> - } <nl> - <nl> - TRI_DEFER ( vocbase - > release ( ) ) ; <nl> - <nl> - auto collection = vocbase - > lookupCollection ( dbColPair . second ) ; <nl> - if ( collection = = nullptr ) { <nl> - / / Bad state , we have references to a collection that is not known <nl> - / / anymore . <nl> - / / However let ' s just skip in production . Not allowed to crash . <nl> - / / If we cannot find this infos during recovery we can either recompute <nl> - / / or start fresh . <nl> - return std : : make_pair ( Result ( ) , returnSeq ) ; <nl> - } <nl> - auto rocksCollection = <nl> - static_cast < RocksDBCollection * > ( collection - > getPhysical ( ) ) ; <nl> - TRI_ASSERT ( rocksCollection ! = nullptr ) ; <nl> - auto serializeResult = <nl> - rocksCollection - > serializeIndexEstimates ( rtrx , baseSeq ) ; <nl> - if ( ! serializeResult . first . ok ( ) ) { <nl> - LOG_TOPIC ( WARN , Logger : : ENGINES ) < < " writing index estimates failed : " <nl> - < < serializeResult . first . errorMessage ( ) ; <nl> - return std : : make_pair ( serializeResult . first , returnSeq ) ; <nl> - } <nl> - returnSeq = std : : min ( returnSeq , serializeResult . second ) ; <nl> - <nl> - Result res = rocksCollection - > serializeKeyGenerator ( rtrx ) ; <nl> - if ( ! res . ok ( ) ) { <nl> - LOG_TOPIC ( WARN , Logger : : ENGINES ) <nl> - < < " writing key generators failed : " < < res . errorMessage ( ) ; <nl> - return std : : make_pair ( res , returnSeq ) ; <nl> - } <nl> - <nl> - return std : : make_pair ( Result ( ) , returnSeq ) ; <nl> - } <nl> - } / / namespace <nl> - <nl> namespace arangodb { <nl> <nl> - RocksDBSettingsManager : : CMValue : : CMValue ( VPackSlice const & slice ) <nl> - : _sequenceNum ( 0 ) , _added ( 0 ) , _removed ( 0 ) , _revisionId ( 0 ) { <nl> - if ( ! slice . isArray ( ) ) { <nl> - / / got a somewhat invalid slice . probably old data from before the key <nl> - / / structure changes <nl> - return ; <nl> - } <nl> - <nl> - velocypack : : ArrayIterator array ( slice ) ; <nl> - if ( array . valid ( ) ) { <nl> - this - > _sequenceNum = ( * array ) . getUInt ( ) ; <nl> - / / versions pre 3 . 4 stored only a single " count " value <nl> - / / 3 . 4 and higher store " added " and " removed " seperately <nl> - this - > _added = ( * ( + + array ) ) . getUInt ( ) ; <nl> - if ( array . size ( ) > 3 ) { <nl> - TRI_ASSERT ( array . size ( ) = = 4 ) ; <nl> - this - > _removed = ( * ( + + array ) ) . getUInt ( ) ; <nl> - } <nl> - this - > _revisionId = ( * ( + + array ) ) . getUInt ( ) ; <nl> - } <nl> - } <nl> - <nl> - void RocksDBSettingsManager : : CMValue : : serialize ( VPackBuilder & b ) const { <nl> - b . openArray ( ) ; <nl> - b . add ( VPackValue ( _sequenceNum ) ) ; <nl> - b . add ( VPackValue ( _added ) ) ; <nl> - b . add ( VPackValue ( _removed ) ) ; <nl> - b . add ( VPackValue ( _revisionId ) ) ; <nl> - b . close ( ) ; <nl> - } <nl> - <nl> / / / Constructor needs to be called synchrunously , <nl> / / / will load counts from the db and scan the WAL <nl> RocksDBSettingsManager : : RocksDBSettingsManager ( rocksdb : : TransactionDB * db ) <nl> : _lastSync ( 0 ) , <nl> _syncing ( false ) , <nl> - _db ( db ) , <nl> - _initialReleasedTick ( 0 ) , <nl> - _maxUpdateSeqNo ( 1 ) , <nl> - _lastSyncedSeqNo ( 0 ) { } <nl> - <nl> - / / / bump up the value of the last rocksdb : : SequenceNumber we have seen <nl> - / / / and that is pending a sync update <nl> - void RocksDBSettingsManager : : setMaxUpdateSequenceNumber ( rocksdb : : SequenceNumber seqNo ) { <nl> - if ( seqNo = = 0 ) { <nl> - / / we don ' t care about this <nl> - return ; <nl> - } <nl> - <nl> - auto current = _maxUpdateSeqNo . load ( std : : memory_order_acquire ) ; <nl> - <nl> - while ( current < seqNo & & <nl> - ! _maxUpdateSeqNo . compare_exchange_strong ( current , seqNo , std : : memory_order_release ) ) { <nl> - / / someone else has updated the max sequence number , simply try again <nl> - } <nl> - <nl> - / / current sequence number is now at least as high as we want it to be <nl> - # ifdef ARANGODB_ENABLE_MAINTAINER_MODE <nl> - TRI_ASSERT ( _maxUpdateSeqNo . load ( ) > = seqNo ) ; <nl> - # endif <nl> - } <nl> + _db ( db - > GetRootDB ( ) ) , <nl> + _initialReleasedTick ( 0 ) { } <nl> <nl> / / / retrieve initial values from the database <nl> void RocksDBSettingsManager : : retrieveInitialValues ( ) { <nl> loadSettings ( ) ; <nl> - loadIndexEstimates ( ) ; <nl> - loadCounterValues ( ) ; <nl> - loadKeyGenerators ( ) ; <nl> - <nl> EngineSelectorFeature : : ENGINE - > releaseTick ( _initialReleasedTick ) ; <nl> } <nl> <nl> - RocksDBSettingsManager : : CounterAdjustment RocksDBSettingsManager : : loadCounter ( <nl> - uint64_t objectId ) const { <nl> - TRI_ASSERT ( objectId ! = 0 ) ; / / TODO fix this <nl> - <nl> - READ_LOCKER ( guard , _rwLock ) ; <nl> - <nl> - auto const & it = _counters . find ( objectId ) ; <nl> - if ( it ! = _counters . end ( ) ) { <nl> - return CounterAdjustment ( it - > second . _sequenceNum , <nl> - it - > second . _added , <nl> - it - > second . _removed , <nl> - it - > second . _revisionId ) ; <nl> - } <nl> - <nl> - return CounterAdjustment ( ) ; / / do not create <nl> - } <nl> - <nl> - / / / collections / views / indexes can call this method to update <nl> - / / / their total counts . Thread - Safe needs the snapshot so we know <nl> - / / / the sequence number used <nl> - void RocksDBSettingsManager : : updateCounter ( uint64_t objectId , <nl> - CounterAdjustment const & update ) { <nl> - bool needsSync = false ; <nl> - auto seqNo = update . sequenceNumber ( ) ; <nl> - { <nl> - WRITE_LOCKER ( guard , _rwLock ) ; <nl> - <nl> - auto it = _counters . find ( objectId ) ; <nl> - if ( it ! = _counters . end ( ) ) { <nl> - it - > second . _added + = update . added ( ) ; <nl> - it - > second . _removed + = update . removed ( ) ; <nl> - / / just use the latest trx info <nl> - if ( seqNo > it - > second . _sequenceNum ) { <nl> - it - > second . _sequenceNum = seqNo ; <nl> - if ( update . revisionId ( ) ! = 0 ) { <nl> - it - > second . _revisionId = update . revisionId ( ) ; <nl> - } <nl> - } <nl> - } else { <nl> - / / insert new counter <nl> - _counters . emplace ( std : : make_pair ( <nl> - objectId , <nl> - CMValue ( update . sequenceNumber ( ) , update . added ( ) , update . removed ( ) , <nl> - update . revisionId ( ) ) ) ) ; <nl> - needsSync = true ; / / only count values from WAL if they are in the DB <nl> - } <nl> - } <nl> - <nl> - setMaxUpdateSequenceNumber ( seqNo ) ; <nl> - <nl> - if ( needsSync ) { <nl> - sync ( true ) ; <nl> - } <nl> - } <nl> - <nl> - arangodb : : Result RocksDBSettingsManager : : setAbsoluteCounter ( uint64_t objectId , <nl> - rocksdb : : SequenceNumber seq , <nl> - uint64_t value ) { <nl> - arangodb : : Result res ; <nl> - rocksdb : : SequenceNumber seqNo = 0 ; <nl> - <nl> - { <nl> - WRITE_LOCKER ( guard , _rwLock ) ; <nl> - <nl> - auto it = _counters . find ( objectId ) ; <nl> - <nl> - if ( it ! = _counters . end ( ) ) { <nl> - LOG_TOPIC ( DEBUG , Logger : : ROCKSDB ) < < " resetting counter value to " < < value ; <nl> - it - > second . _sequenceNum = std : : max ( seq , it - > second . _sequenceNum ) ; <nl> - it - > second . _added = value ; <nl> - it - > second . _removed = 0 ; <nl> - } else { <nl> - / / nothing to do as the counter has never been written it can not be set to <nl> - / / a value that would require correction . but we use the return value to <nl> - / / signal that no sync is rquired <nl> - res . reset ( TRI_ERROR_INTERNAL , " counter value not found - no sync required " ) ; <nl> - } <nl> - } <nl> - <nl> - setMaxUpdateSequenceNumber ( seqNo ) ; <nl> - <nl> - return res ; <nl> - } <nl> - <nl> - void RocksDBSettingsManager : : removeCounter ( uint64_t objectId ) { <nl> - WRITE_LOCKER ( guard , _rwLock ) ; <nl> - <nl> - auto it = _counters . find ( objectId ) ; <nl> - <nl> - if ( it ! = _counters . end ( ) ) { <nl> - RocksDBKey key ; <nl> - key . constructCounterValue ( it - > first ) ; <nl> - rocksdb : : WriteOptions options ; <nl> - rocksdb : : Status s = <nl> - _db - > Delete ( options , RocksDBColumnFamily : : definitions ( ) , key . string ( ) ) ; <nl> - if ( ! s . ok ( ) ) { <nl> - LOG_TOPIC ( ERR , Logger : : ENGINES ) < < " deleting counter failed " ; <nl> - } <nl> - _counters . erase ( it ) ; <nl> - } <nl> - } <nl> - <nl> - std : : unordered_map < uint64_t , rocksdb : : SequenceNumber > <nl> - RocksDBSettingsManager : : counterSeqs ( ) { <nl> - std : : unordered_map < uint64_t , rocksdb : : SequenceNumber > seqs ; <nl> - { / / block all updates while we copy <nl> - READ_LOCKER ( guard , _rwLock ) ; <nl> - for ( auto it : _counters ) { <nl> - seqs . emplace ( it . first , it . second . _sequenceNum ) ; <nl> - } <nl> - } <nl> - return seqs ; <nl> - } <nl> - <nl> bool RocksDBSettingsManager : : lockForSync ( bool force ) { <nl> if ( force ) { <nl> while ( true ) { <nl> bool RocksDBSettingsManager : : lockForSync ( bool force ) { <nl> / / / Thread - Safe force sync <nl> Result RocksDBSettingsManager : : sync ( bool force ) { <nl> TRI_IF_FAILURE ( " RocksDBSettingsManagerSync " ) { return Result ( ) ; } <nl> + if ( ! _db ) { <nl> + return Result ( ) ; <nl> + } <nl> <nl> if ( ! lockForSync ( force ) ) { <nl> return Result ( ) ; <nl> Result RocksDBSettingsManager : : sync ( bool force ) { <nl> / / only one thread can enter here at a time <nl> <nl> / / make sure we give up our lock when we exit this function <nl> - auto guard = scopeGuard ( [ this ] ( ) { _syncing = false ; } ) ; <nl> + auto guard = scopeGuard ( [ this ] ( ) { _syncing . store ( false , std : : memory_order_release ) ; } ) ; <nl> <nl> - auto maxUpdateSeqNo = _maxUpdateSeqNo . load ( std : : memory_order_acquire ) ; <nl> - <nl> - if ( ! force & & maxUpdateSeqNo < = _lastSyncedSeqNo ) { <nl> - / / if noone has updated any counters etc . since we were here last , <nl> - / / there is no need to do anything ! <nl> - return Result ( ) ; <nl> - } <nl> - <nl> - / / ok , when we are here , we will write out something back to the database <nl> - <nl> - std : : unordered_map < uint64_t , CMValue > copy ; <nl> - { / / block all updates <nl> - WRITE_LOCKER ( guard , _rwLock ) ; <nl> - copy = _counters ; <nl> - } <nl> - <nl> / / fetch the seq number prior to any writes ; this guarantees that we save <nl> / / any subsequent updates in the WAL to replay if we crash in the middle <nl> - auto seqNumber = _db - > GetLatestSequenceNumber ( ) ; <nl> - <nl> - rocksdb : : WriteOptions writeOptions ; <nl> - std : : unique_ptr < rocksdb : : Transaction > rtrx ( <nl> - _db - > BeginTransaction ( writeOptions ) ) ; <nl> - <nl> - / / recycle our builder <nl> - _builder . clear ( ) ; <nl> + auto maxSeqNr = _db - > GetLatestSequenceNumber ( ) ; <nl> + auto minSeqNr = maxSeqNr ; <nl> <nl> - for ( std : : pair < uint64_t , CMValue > const & pair : copy ) { <nl> - Result res ; <nl> - rocksdb : : SequenceNumber returnSeq ; <nl> + rocksdb : : TransactionOptions opts ; <nl> + opts . lock_timeout = 0 . 05 ; / / do not wait for locking keys <nl> + <nl> + rocksdb : : WriteOptions wo ; <nl> + rocksdb : : WriteBatch batch ; <nl> + _tmpBuilder . clear ( ) ; / / recycle our builder <nl> + <nl> + RocksDBEngine * engine = rocksutils : : globalRocksEngine ( ) ; <nl> + auto dbfeature = arangodb : : DatabaseFeature : : DATABASE ; <nl> + <nl> + bool didWork = false ; <nl> + auto mappings = engine - > collectionMappings ( ) ; <nl> + for ( auto const & pair : mappings ) { <nl> <nl> - std : : tie ( res , returnSeq ) = writeCounterValue ( _syncedSeqNums , rtrx . get ( ) , <nl> - _builder , pair , seqNumber ) ; <nl> - if ( res . fail ( ) ) { <nl> - return res ; <nl> + TRI_voc_tick_t dbid = pair . first ; <nl> + TRI_voc_cid_t cid = pair . second ; <nl> + TRI_vocbase_t * vocbase = dbfeature - > useDatabase ( dbid ) ; <nl> + if ( ! vocbase ) { <nl> + continue ; <nl> } <nl> - seqNumber = std : : min ( seqNumber , returnSeq ) ; <nl> - <nl> - std : : tie ( res , returnSeq ) = <nl> - writeIndexEstimatorsAndKeyGenerator ( rtrx . get ( ) , pair , seqNumber ) ; <nl> + TRI_ASSERT ( ! vocbase - > isDangling ( ) ) ; <nl> + TRI_DEFER ( vocbase - > release ( ) ) ; <nl> + <nl> + / / intentionally do not ` useCollection ` , tends to break CI tests <nl> + TRI_vocbase_col_status_e status ; <nl> + std : : shared_ptr < LogicalCollection > coll = vocbase - > useCollection ( cid , status ) ; <nl> + if ( ! coll ) { <nl> + continue ; <nl> + } <nl> + TRI_DEFER ( vocbase - > releaseCollection ( coll . get ( ) ) ) ; <nl> + <nl> + auto * rcoll = static_cast < RocksDBCollection * > ( coll - > getPhysical ( ) ) ; <nl> + rocksdb : : SequenceNumber appliedSeq = minSeqNr ; <nl> + Result res = rcoll - > meta ( ) . serializeMeta ( batch , * coll , force , _tmpBuilder , appliedSeq ) ; <nl> + minSeqNr = std : : min ( minSeqNr , appliedSeq ) ; <nl> + <nl> + const std : : string err = " could not sync metadata for collection ' " ; <nl> if ( res . fail ( ) ) { <nl> + LOG_TOPIC ( WARN , Logger : : ENGINES ) < < err < < coll - > name ( ) < < " ' " ; <nl> return res ; <nl> } <nl> - seqNumber = std : : min ( seqNumber , returnSeq ) ; <nl> + <nl> + if ( batch . Count ( ) > 0 ) { <nl> + auto s = _db - > Write ( wo , & batch ) ; <nl> + if ( ! s . ok ( ) ) { <nl> + LOG_TOPIC ( WARN , Logger : : ENGINES ) < < err < < coll - > name ( ) < < " ' " ; <nl> + return rocksutils : : convertStatus ( s ) ; <nl> + } <nl> + didWork = true ; <nl> + } <nl> + batch . Clear ( ) ; <nl> } <nl> - <nl> - Result res = writeSettings ( rtrx . get ( ) , _builder , seqNumber ) ; <nl> - <nl> + <nl> + if ( ! didWork ) { <nl> + WRITE_LOCKER ( guard , _rwLock ) ; <nl> + _lastSync = minSeqNr ; <nl> + return Result ( ) ; / / nothing was written <nl> + } <nl> + <nl> + _tmpBuilder . clear ( ) ; <nl> + Result res = writeSettings ( batch , _tmpBuilder , minSeqNr ) ; <nl> if ( res . fail ( ) ) { <nl> + LOG_TOPIC ( WARN , Logger : : ENGINES ) < < " could not store metadata settings " <nl> + < < res . errorMessage ( ) ; <nl> return res ; <nl> } <nl> <nl> / / we have to commit all counters in one batch <nl> - auto s = rtrx - > Commit ( ) ; <nl> - <nl> + auto s = _db - > Write ( wo , & batch ) ; <nl> if ( s . ok ( ) ) { <nl> - _lastSyncedSeqNo = maxUpdateSeqNo ; <nl> - <nl> - { <nl> - WRITE_LOCKER ( guard , _rwLock ) ; <nl> - _lastSync = seqNumber ; <nl> - } <nl> - for ( std : : pair < uint64_t , CMValue > const & pair : copy ) { <nl> - _syncedSeqNums [ pair . first ] = pair . second . _sequenceNum ; <nl> - } <nl> + WRITE_LOCKER ( guard , _rwLock ) ; <nl> + _lastSync = minSeqNr ; <nl> } <nl> <nl> return rocksutils : : convertStatus ( s ) ; <nl> void RocksDBSettingsManager : : loadSettings ( ) { <nl> } <nl> } <nl> <nl> - void RocksDBSettingsManager : : loadIndexEstimates ( ) { <nl> - RocksDBKeyBounds bounds = RocksDBKeyBounds : : IndexEstimateValues ( ) ; <nl> - <nl> - auto cf = RocksDBColumnFamily : : definitions ( ) ; <nl> - rocksdb : : Comparator const * cmp = cf - > GetComparator ( ) ; <nl> - rocksdb : : ReadOptions readOptions ; <nl> - std : : unique_ptr < rocksdb : : Iterator > iter ( _db - > NewIterator ( readOptions , cf ) ) ; <nl> - iter - > Seek ( bounds . start ( ) ) ; <nl> - <nl> - for ( ; iter - > Valid ( ) & & cmp - > Compare ( iter - > key ( ) , bounds . end ( ) ) < 0 ; <nl> - iter - > Next ( ) ) { <nl> - uint64_t objectId = RocksDBKey : : definitionsObjectId ( iter - > key ( ) ) ; <nl> - uint64_t lastSeqNumber = <nl> - rocksutils : : uint64FromPersistent ( iter - > value ( ) . data ( ) ) ; <nl> - <nl> - StringRef estimateSerialization ( iter - > value ( ) . data ( ) + sizeof ( uint64_t ) , <nl> - iter - > value ( ) . size ( ) - sizeof ( uint64_t ) ) ; <nl> - <nl> - WRITE_LOCKER ( guard , _rwLock ) ; <nl> - / / If this hits we have two estimates for the same index <nl> - TRI_ASSERT ( _estimators . find ( objectId ) = = _estimators . end ( ) ) ; <nl> - try { <nl> - if ( RocksDBCuckooIndexEstimator < uint64_t > : : isFormatSupported ( <nl> - estimateSerialization ) ) { <nl> - auto it = _estimators . emplace ( <nl> - objectId , std : : make_unique < RocksDBCuckooIndexEstimator < uint64_t > > ( <nl> - lastSeqNumber , estimateSerialization ) ) ; <nl> - if ( it . second ) { <nl> - auto estimator = it . first - > second . get ( ) ; <nl> - LOG_TOPIC ( TRACE , Logger : : ENGINES ) <nl> - < < " found index estimator for objectId ' " < < objectId <nl> - < < " ' last synced at " < < lastSeqNumber < < " with estimate " <nl> - < < estimator - > computeEstimate ( ) ; <nl> - } <nl> - } <nl> - } catch ( . . . ) { <nl> - / / Nothing to do , if the estimator fails to create we let it be recreated . <nl> - / / Just validate that no corrupted memory was produced . <nl> - TRI_ASSERT ( _estimators . find ( objectId ) = = _estimators . end ( ) ) ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - void RocksDBSettingsManager : : loadKeyGenerators ( ) { <nl> - RocksDBKeyBounds bounds = RocksDBKeyBounds : : KeyGenerators ( ) ; <nl> - <nl> - auto cf = RocksDBColumnFamily : : definitions ( ) ; <nl> - rocksdb : : Comparator const * cmp = cf - > GetComparator ( ) ; <nl> - rocksdb : : ReadOptions readOptions ; <nl> - std : : unique_ptr < rocksdb : : Iterator > iter ( _db - > NewIterator ( readOptions , cf ) ) ; <nl> - iter - > Seek ( bounds . start ( ) ) ; <nl> - <nl> - for ( ; iter - > Valid ( ) & & cmp - > Compare ( iter - > key ( ) , bounds . end ( ) ) < 0 ; <nl> - iter - > Next ( ) ) { <nl> - uint64_t objectId = RocksDBKey : : definitionsObjectId ( iter - > key ( ) ) ; <nl> - auto properties = RocksDBValue : : data ( iter - > value ( ) ) ; <nl> - <nl> - VPackSlice s = properties . get ( StaticStrings : : LastValue ) ; <nl> - if ( ! s . isNone ( ) ) { <nl> - uint64_t lastValue = properties . get ( StaticStrings : : LastValue ) . getUInt ( ) ; <nl> - <nl> - WRITE_LOCKER ( guard , _rwLock ) ; <nl> - / / If this hits we have two generators for the same collection <nl> - TRI_ASSERT ( _generators . find ( objectId ) = = _generators . end ( ) ) ; <nl> - try { <nl> - _generators . emplace ( objectId , lastValue ) ; <nl> - } catch ( . . . ) { <nl> - / / Nothing to do , just validate that no corrupted memory was produced . <nl> - TRI_ASSERT ( _generators . find ( objectId ) = = _generators . end ( ) ) ; <nl> - } <nl> - } <nl> - } <nl> - } <nl> - <nl> - std : : unique_ptr < RocksDBCuckooIndexEstimator < uint64_t > > <nl> - RocksDBSettingsManager : : stealIndexEstimator ( uint64_t objectId ) { <nl> - std : : unique_ptr < RocksDBCuckooIndexEstimator < uint64_t > > res ; <nl> - <nl> - WRITE_LOCKER ( guard , _rwLock ) ; <nl> - <nl> - auto it = _estimators . find ( objectId ) ; <nl> - <nl> - if ( it ! = _estimators . end ( ) ) { <nl> - / / We swap out the stored estimate in order to move it to the caller <nl> - res . swap ( it - > second ) ; <nl> - / / Drop the now empty estimator <nl> - _estimators . erase ( objectId ) ; <nl> - } <nl> - <nl> - return res ; <nl> - } <nl> - <nl> - uint64_t RocksDBSettingsManager : : stealKeyGenerator ( uint64_t objectId ) { <nl> - uint64_t res = 0 ; <nl> - <nl> - { <nl> - WRITE_LOCKER ( guard , _rwLock ) ; <nl> - <nl> - auto it = _generators . find ( objectId ) ; <nl> - <nl> - if ( it ! = _generators . end ( ) ) { <nl> - / / We swap out the stored generator state in order to move it to the caller <nl> - res = it - > second ; <nl> - / / we are now not responsible for the generator anymore <nl> - _generators . erase ( objectId ) ; <nl> - } <nl> - } <nl> - <nl> - return res ; <nl> - } <nl> - <nl> - void RocksDBSettingsManager : : clearIndexEstimators ( ) { <nl> - / / We call this to remove all index estimators that have been stored but are <nl> - / / no longer read by recovery . <nl> - <nl> - / / TODO REMOVE RocksDB Keys of all not stolen values ? <nl> - WRITE_LOCKER ( guard , _rwLock ) ; <nl> - _estimators . clear ( ) ; <nl> - } <nl> - <nl> - void RocksDBSettingsManager : : clearKeyGenerators ( ) { <nl> - WRITE_LOCKER ( guard , _rwLock ) ; <nl> - _generators . clear ( ) ; <nl> - } <nl> - <nl> - / / / Parse counter values from rocksdb <nl> - void RocksDBSettingsManager : : loadCounterValues ( ) { <nl> - RocksDBKeyBounds bounds = RocksDBKeyBounds : : CounterValues ( ) ; <nl> - <nl> - auto cf = RocksDBColumnFamily : : definitions ( ) ; <nl> - rocksdb : : Comparator const * cmp = cf - > GetComparator ( ) ; <nl> - rocksdb : : ReadOptions readOptions ; <nl> - std : : unique_ptr < rocksdb : : Iterator > iter ( _db - > NewIterator ( readOptions , cf ) ) ; <nl> - iter - > Seek ( bounds . start ( ) ) ; <nl> - <nl> - while ( iter - > Valid ( ) & & cmp - > Compare ( iter - > key ( ) , bounds . end ( ) ) < 0 ) { <nl> - uint64_t objectId = RocksDBKey : : definitionsObjectId ( iter - > key ( ) ) ; <nl> - <nl> - { <nl> - WRITE_LOCKER ( guard , _rwLock ) ; <nl> - auto const & it = <nl> - _counters . emplace ( objectId , CMValue ( VPackSlice ( iter - > value ( ) . data ( ) ) ) ) ; <nl> - _syncedSeqNums [ objectId ] = it . first - > second . _sequenceNum ; <nl> - LOG_TOPIC ( TRACE , Logger : : ENGINES ) <nl> - < < " found count marker for objectId ' " < < objectId <nl> - < < " ' last synced at " < < it . first - > first < < " with added " <nl> - < < it . first - > second . _added < < " , removed " < < it . first - > second . _removed ; <nl> - } <nl> - <nl> - iter - > Next ( ) ; <nl> - } <nl> - } <nl> - <nl> / / / earliest safe sequence number to throw away from wal <nl> rocksdb : : SequenceNumber RocksDBSettingsManager : : earliestSeqNeeded ( ) const { <nl> READ_LOCKER ( guard , _rwLock ) ; <nl> mmm a / arangod / RocksDBEngine / RocksDBSettingsManager . h <nl> ppp b / arangod / RocksDBEngine / RocksDBSettingsManager . h <nl> class RocksDBSettingsManager { <nl> / / / will load counts from the db and scan the WAL <nl> explicit RocksDBSettingsManager ( rocksdb : : TransactionDB * db ) ; <nl> <nl> - public : <nl> - struct CounterAdjustment { <nl> - rocksdb : : SequenceNumber _sequenceNum = 0 ; <nl> - uint64_t _added = 0 ; <nl> - uint64_t _removed = 0 ; <nl> - TRI_voc_rid_t _revisionId = 0 ; / / used for revision id <nl> - <nl> - CounterAdjustment ( ) { } <nl> - CounterAdjustment ( rocksdb : : SequenceNumber seq , uint64_t added , <nl> - uint64_t removed , TRI_voc_rid_t revisionId ) <nl> - : _sequenceNum ( seq ) , <nl> - _added ( added ) , <nl> - _removed ( removed ) , <nl> - _revisionId ( revisionId ) { } <nl> - <nl> - rocksdb : : SequenceNumber sequenceNumber ( ) const { return _sequenceNum ; } ; <nl> - uint64_t added ( ) const { return _added ; } <nl> - uint64_t removed ( ) const { return _removed ; } <nl> - TRI_voc_rid_t revisionId ( ) const { return _revisionId ; } <nl> - } ; <nl> - <nl> - struct CMValue { <nl> - / / / ArangoDB transaction ID <nl> - rocksdb : : SequenceNumber _sequenceNum ; <nl> - / / / used for number of documents <nl> - uint64_t _added ; <nl> - uint64_t _removed ; <nl> - / / / used for revision id <nl> - TRI_voc_rid_t _revisionId ; <nl> - <nl> - CMValue ( rocksdb : : SequenceNumber sq , uint64_t added , uint64_t removed , TRI_voc_rid_t rid ) <nl> - : _sequenceNum ( sq ) , _added ( added ) , _removed ( removed ) , _revisionId ( rid ) { } <nl> - explicit CMValue ( arangodb : : velocypack : : Slice const & ) ; <nl> - void serialize ( arangodb : : velocypack : : Builder & ) const ; <nl> - } ; <nl> - <nl> public : <nl> / / / Retrieve initial settings values from database on engine startup <nl> void retrieveInitialValues ( ) ; <nl> <nl> - / / / Thread - Safe load a counter <nl> - CounterAdjustment loadCounter ( uint64_t objectId ) const ; <nl> - <nl> - / / / collections / views / indexes can call this method to update <nl> - / / / their total counts . Thread - Safe needs the snapshot so we know <nl> - / / / the sequence number used <nl> - void updateCounter ( uint64_t objectId , CounterAdjustment const & ) ; <nl> - <nl> - / / does not modify seq or revisionid <nl> - arangodb : : Result setAbsoluteCounter ( uint64_t objectId , <nl> - rocksdb : : SequenceNumber , <nl> - uint64_t absouluteCount ) ; <nl> - <nl> - / / / Thread - Safe remove a counter <nl> - void removeCounter ( uint64_t objectId ) ; <nl> - <nl> - / / / Return copy of full list of counters <nl> - std : : unordered_map < uint64_t , rocksdb : : SequenceNumber > counterSeqs ( ) ; <nl> - <nl> / / / Thread - Safe force sync <nl> Result sync ( bool force ) ; <nl> <nl> - / / Steal the index estimator that the recovery has built up to inject it into <nl> - / / an index . <nl> - / / NOTE : If this returns nullptr the recovery was not able to find any <nl> - / / estimator <nl> - / / for this index . <nl> - / / SHOULD ONLY BE CALLED DURING STARTUP <nl> - std : : unique_ptr < RocksDBCuckooIndexEstimator < uint64_t > > stealIndexEstimator ( <nl> - uint64_t indexObjectId ) ; <nl> - <nl> - / / Steal the key genenerator state that recovery has detected . <nl> - / / SHOULD ONLY BE CALLED DURING STARTUP <nl> - uint64_t stealKeyGenerator ( uint64_t indexObjectId ) ; <nl> - <nl> - / / Free up all index estimators that were not read by any index . <nl> - / / This is to save some memory . <nl> - / / NOTE : After calling this the stored estimate of all not yet <nl> - / / read index estimators will be dropped and no attempt <nl> - / / to reread it will be done . <nl> - / / So call it after ALL indexes for all databases <nl> - / / have been created in memory . <nl> - / / SHOULD ONLY BE CALLED DURING STARTUP <nl> - void clearIndexEstimators ( ) ; <nl> - <nl> - / / Clear out key generator map for values not read by any collection . <nl> - / / SHOULD ONLY BE CALLED DURING STARTUP <nl> - void clearKeyGenerators ( ) ; <nl> - <nl> / / Earliest sequence number needed for recovery ( don ' t throw out newer WALs ) <nl> rocksdb : : SequenceNumber earliestSeqNeeded ( ) const ; <nl> <nl> private : <nl> - / / / bump up the value of the last rocksdb : : SequenceNumber we have seen <nl> - / / / and that is pending a sync update <nl> - void setMaxUpdateSequenceNumber ( rocksdb : : SequenceNumber seqNo ) ; <nl> - <nl> - void loadCounterValues ( ) ; <nl> + <nl> void loadSettings ( ) ; <nl> - void loadIndexEstimates ( ) ; <nl> - void loadKeyGenerators ( ) ; <nl> <nl> bool lockForSync ( bool force ) ; <nl> + <nl> + private : <nl> <nl> + / / / @ brief protect _syncing and _counters <nl> + mutable basics : : ReadWriteLock _rwLock ; <nl> + <nl> / / / @ brief a reusable builder , used inside sync ( ) to serialize objects <nl> - arangodb : : velocypack : : Builder _builder ; <nl> - <nl> - / / / @ brief counter values <nl> - std : : unordered_map < uint64_t , CMValue > _counters ; <nl> - <nl> - / / / @ brief Key generator container <nl> - std : : unordered_map < uint64_t , uint64_t > _generators ; <nl> - <nl> - / / / @ brief Index Estimator contianer . <nl> - / / / Note the elements in this container will be moved into the <nl> - / / / index classes and are only temporarily stored here during recovery . <nl> - std : : unordered_map < uint64_t , <nl> - std : : unique_ptr < RocksDBCuckooIndexEstimator < uint64_t > > > <nl> - _estimators ; <nl> - <nl> - / / / @ brief synced sequence numbers <nl> - std : : unordered_map < uint64_t , rocksdb : : SequenceNumber > _syncedSeqNums ; <nl> + arangodb : : velocypack : : Builder _tmpBuilder ; <nl> <nl> / / / @ brief last sync sequence number <nl> rocksdb : : SequenceNumber _lastSync ; <nl> class RocksDBSettingsManager { <nl> std : : atomic < bool > _syncing ; <nl> <nl> / / / @ brief rocksdb instance <nl> - rocksdb : : TransactionDB * _db ; <nl> - <nl> - / / / @ brief protect _syncing and _counters <nl> - mutable basics : : ReadWriteLock _rwLock ; <nl> + rocksdb : : DB * _db ; <nl> <nl> TRI_voc_tick_t _initialReleasedTick ; <nl> - <nl> - / / / @ brief the maximum sequence number that we have encountered <nl> - / / / when updating a counter value <nl> - std : : atomic < rocksdb : : SequenceNumber > _maxUpdateSeqNo ; <nl> - <nl> - / / / @ brief the last maximum sequence number we stored when we last synced <nl> - / / / all counters back to persistent storage <nl> - / / / if this is identical to _maxUpdateSeqNo , we do not need to write <nl> - / / / back any counter values to disk and can save I / O <nl> - rocksdb : : SequenceNumber _lastSyncedSeqNo ; <nl> } ; <nl> } / / namespace arangodb <nl> <nl> mmm a / arangod / RocksDBEngine / RocksDBTransactionCollection . cpp <nl> ppp b / arangod / RocksDBEngine / RocksDBTransactionCollection . cpp <nl> void RocksDBTransactionCollection : : addOperation ( <nl> void RocksDBTransactionCollection : : prepareCommit ( uint64_t trxId , <nl> uint64_t preCommitSeq ) { <nl> TRI_ASSERT ( _collection ! = nullptr ) ; <nl> - for ( auto const & pair : _trackedIndexOperations ) { <nl> - auto idx = _collection - > lookupIndex ( pair . first ) ; <nl> - if ( idx = = nullptr ) { <nl> - TRI_ASSERT ( false ) ; / / Index reported estimates , but does not exist <nl> - continue ; <nl> - } <nl> - auto ridx = static_cast < RocksDBIndex * > ( idx . get ( ) ) ; <nl> - auto estimator = ridx - > estimator ( ) ; <nl> - if ( estimator ) { <nl> - estimator - > placeBlocker ( trxId , preCommitSeq ) ; <nl> - } <nl> + if ( hasOperations ( ) | | ! _trackedIndexOperations . empty ( ) ) { <nl> + RocksDBCollection * coll = static_cast < RocksDBCollection * > ( _collection - > getPhysical ( ) ) ; <nl> + coll - > meta ( ) . placeBlocker ( trxId , preCommitSeq ) ; <nl> } <nl> } <nl> <nl> void RocksDBTransactionCollection : : abortCommit ( uint64_t trxId ) { <nl> TRI_ASSERT ( _collection ! = nullptr ) ; <nl> - for ( auto const & pair : _trackedIndexOperations ) { <nl> - auto idx = _collection - > lookupIndex ( pair . first ) ; <nl> - if ( idx = = nullptr ) { <nl> - TRI_ASSERT ( false ) ; / / Index reported estimates , but does not exist <nl> - continue ; <nl> - } <nl> - auto ridx = static_cast < RocksDBIndex * > ( idx . get ( ) ) ; <nl> - auto estimator = ridx - > estimator ( ) ; <nl> - if ( estimator ) { <nl> - estimator - > removeBlocker ( trxId ) ; <nl> - } <nl> + if ( hasOperations ( ) | | ! _trackedIndexOperations . empty ( ) ) { <nl> + RocksDBCollection * coll = static_cast < RocksDBCollection * > ( _collection - > getPhysical ( ) ) ; <nl> + coll - > meta ( ) . removeBlocker ( trxId ) ; <nl> } <nl> } <nl> <nl> void RocksDBTransactionCollection : : commitCounts ( uint64_t trxId , <nl> <nl> / / Update the collection count <nl> int64_t const adjustment = _numInserts - _numRemoves ; <nl> - if ( commitSeq ! = 0 ) { / / is ' 0 ' for filling new indexes <nl> - if ( _numInserts ! = 0 | | _numRemoves ! = 0 | | _revision ! = 0 ) { <nl> - RocksDBCollection * coll = static_cast < RocksDBCollection * > ( _collection - > getPhysical ( ) ) ; <nl> - coll - > adjustNumberDocuments ( _revision , adjustment ) ; <nl> - <nl> - RocksDBEngine * engine = rocksutils : : globalRocksEngine ( ) ; <nl> - RocksDBSettingsManager : : CounterAdjustment update ( commitSeq , _numInserts , _numRemoves , <nl> - _revision ) ; <nl> - engine - > settingsManager ( ) - > updateCounter ( coll - > objectId ( ) , update ) ; <nl> - } <nl> + if ( hasOperations ( ) ) { <nl> + TRI_ASSERT ( _revision ! = 0 & & commitSeq ! = 0 ) ; <nl> + RocksDBCollection * coll = static_cast < RocksDBCollection * > ( _collection - > getPhysical ( ) ) ; <nl> + coll - > adjustNumberDocuments ( _revision , adjustment ) ; / / update online count <nl> + coll - > meta ( ) . adjustNumberDocuments ( commitSeq , _revision , adjustment ) ; / / buffer for recovery <nl> } <nl> <nl> / / Update the index estimates . <nl> for ( auto & pair : _trackedIndexOperations ) { <nl> auto idx = _collection - > lookupIndex ( pair . first ) ; <nl> - <nl> if ( idx = = nullptr ) { <nl> TRI_ASSERT ( false ) ; / / Index reported estimates , but does not exist <nl> continue ; <nl> } <nl> auto ridx = static_cast < RocksDBIndex * > ( idx . get ( ) ) ; <nl> - auto estimator = ridx - > estimator ( ) ; <nl> - if ( estimator ) { <nl> - estimator - > bufferUpdates ( commitSeq , std : : move ( pair . second . inserts ) , <nl> - std : : move ( pair . second . removals ) ) ; <nl> - estimator - > removeBlocker ( trxId ) ; <nl> + auto est = ridx - > estimator ( ) ; <nl> + if ( ADB_LIKELY ( est ! = nullptr ) ) { <nl> + est - > bufferUpdates ( commitSeq , std : : move ( pair . second . inserts ) , <nl> + std : : move ( pair . second . removals ) ) ; <nl> + } else { <nl> + TRI_ASSERT ( false ) ; <nl> } <nl> } <nl> + <nl> + if ( hasOperations ( ) | | ! _trackedIndexOperations . empty ( ) ) { <nl> + RocksDBCollection * coll = static_cast < RocksDBCollection * > ( _collection - > getPhysical ( ) ) ; <nl> + coll - > meta ( ) . removeBlocker ( trxId ) ; <nl> + } <nl> <nl> _initialNumberDocuments + = adjustment ; <nl> _numInserts = 0 ; <nl> mmm a / arangod / RocksDBEngine / RocksDBTransactionState . cpp <nl> ppp b / arangod / RocksDBEngine / RocksDBTransactionState . cpp <nl> arangodb : : Result RocksDBTransactionState : : internalCommit ( ) { <nl> / / prepare for commit on each collection , e . g . place blockers for estimators <nl> rocksdb : : SequenceNumber preCommitSeq = <nl> rocksutils : : globalRocksDB ( ) - > GetLatestSequenceNumber ( ) ; <nl> - for ( auto & trxCollection : _collections ) { <nl> - RocksDBTransactionCollection * collection = <nl> - static_cast < RocksDBTransactionCollection * > ( trxCollection ) ; <nl> - collection - > prepareCommit ( id ( ) , preCommitSeq ) ; <nl> + for ( auto & trxColl : _collections ) { <nl> + auto * coll = static_cast < RocksDBTransactionCollection * > ( trxColl ) ; <nl> + coll - > prepareCommit ( id ( ) , preCommitSeq ) ; <nl> } <nl> bool committed = false ; <nl> auto cleanupCollectionTransactions = scopeGuard ( [ this , & committed ] ( ) { <nl> / / if we didn ' t commit , make sure we remove blockers , etc . <nl> if ( ! committed ) { <nl> - for ( auto & trxCollection : _collections ) { <nl> - RocksDBTransactionCollection * collection = <nl> - static_cast < RocksDBTransactionCollection * > ( trxCollection ) ; <nl> - collection - > abortCommit ( id ( ) ) ; <nl> + for ( auto & trxColl : _collections ) { <nl> + auto * coll = static_cast < RocksDBTransactionCollection * > ( trxColl ) ; <nl> + coll - > abortCommit ( id ( ) ) ; <nl> } <nl> } <nl> } ) ; <nl> arangodb : : Result RocksDBTransactionState : : internalCommit ( ) { <nl> } <nl> TRI_ASSERT ( postCommitSeq < = rocksutils : : globalRocksDB ( ) - > GetLatestSequenceNumber ( ) ) ; <nl> <nl> - for ( auto & trxCollection : _collections ) { <nl> - RocksDBTransactionCollection * collection = <nl> - static_cast < RocksDBTransactionCollection * > ( trxCollection ) ; <nl> + for ( auto & trxColl : _collections ) { <nl> + auto * coll = static_cast < RocksDBTransactionCollection * > ( trxColl ) ; <nl> / / we need this in case of an intermediate commit . The number of <nl> / / initial documents is adjusted and numInserts / removes is set to 0 <nl> / / index estimator updates are buffered <nl> arangodb : : Result RocksDBTransactionState : : internalCommit ( ) { <nl> committed = true ; <nl> continue ; <nl> } <nl> - collection - > commitCounts ( id ( ) , postCommitSeq ) ; <nl> + coll - > commitCounts ( id ( ) , postCommitSeq ) ; <nl> committed = true ; <nl> } <nl> <nl> arangodb : : Result RocksDBTransactionState : : internalCommit ( ) { <nl> TRI_ASSERT ( _rocksTransaction - > GetNumKeys ( ) = = 0 & & <nl> _rocksTransaction - > GetNumPuts ( ) = = 0 & & <nl> _rocksTransaction - > GetNumDeletes ( ) = = 0 ) ; <nl> + <nl> + rocksdb : : SequenceNumber seq = 0 ; <nl> + if ( _rocksTransaction ) { <nl> + seq = _rocksTransaction - > GetSnapshot ( ) - > GetSequenceNumber ( ) ; <nl> + } else { <nl> + TRI_ASSERT ( _readSnapshot ) ; <nl> + seq = _readSnapshot - > GetSequenceNumber ( ) ; <nl> + } <nl> <nl> - for ( auto & trxCollection : _collections ) { <nl> + for ( auto & trxColl : _collections ) { <nl> TRI_IF_FAILURE ( " RocksDBCommitCounts " ) { <nl> continue ; <nl> } <nl> - RocksDBTransactionCollection * collection = <nl> - static_cast < RocksDBTransactionCollection * > ( trxCollection ) ; <nl> + auto * rcoll = static_cast < RocksDBTransactionCollection * > ( trxColl ) ; <nl> + rcoll - > prepareCommit ( id ( ) , seq ) ; <nl> / / We get here if we have filled indexes . So let us commit counts and <nl> / / any buffered index estimator updates <nl> - collection - > commitCounts ( id ( ) , 0 ) ; <nl> + rcoll - > commitCounts ( id ( ) , seq + 1 ) ; <nl> } <nl> / / don ' t write anything if the transaction is empty <nl> result = rocksutils : : convertStatus ( _rocksTransaction - > Rollback ( ) ) ; <nl> mmm a / arangod / RocksDBEngine / RocksDBVPackIndex . cpp <nl> ppp b / arangod / RocksDBEngine / RocksDBVPackIndex . cpp <nl> IndexIterator * RocksDBVPackIndex : : iteratorForCondition ( <nl> return lookup ( trx , searchSlice , ! opts . ascending ) ; <nl> } <nl> <nl> - rocksdb : : SequenceNumber RocksDBVPackIndex : : serializeEstimate ( <nl> - std : : string & output , rocksdb : : SequenceNumber seq ) const { <nl> - TRI_ASSERT ( ! ServerState : : instance ( ) - > isCoordinator ( ) ) ; <nl> - if ( ! _unique ) { <nl> - TRI_ASSERT ( _estimator ! = nullptr ) ; <nl> - return _estimator - > serialize ( output , seq ) ; <nl> - } <nl> - return seq ; <nl> - } <nl> - <nl> - bool RocksDBVPackIndex : : deserializeEstimate ( RocksDBSettingsManager * mgr ) { <nl> - TRI_ASSERT ( ! ServerState : : instance ( ) - > isCoordinator ( ) ) ; <nl> - if ( _unique ) { <nl> - return true ; <nl> - } <nl> - / / We simply drop the current estimator and steal the one from recovery <nl> - / / We are then safe for resizing issues in our _estimator format <nl> - / / and will use the old size . <nl> - <nl> - TRI_ASSERT ( mgr ! = nullptr ) ; <nl> - auto tmp = mgr - > stealIndexEstimator ( _objectId ) ; <nl> - if ( tmp = = nullptr ) { <nl> - / / We expected to receive a stored index estimate , however we got none . <nl> - / / We use the freshly created estimator but have to recompute it . <nl> - return false ; <nl> - } <nl> - _estimator . swap ( tmp ) ; <nl> - TRI_ASSERT ( _estimator ! = nullptr ) ; <nl> - return true ; <nl> - } <nl> - <nl> - void RocksDBVPackIndex : : recalculateEstimates ( ) { <nl> - TRI_ASSERT ( ! ServerState : : instance ( ) - > isCoordinator ( ) ) ; <nl> - if ( unique ( ) ) { <nl> - return ; <nl> - } <nl> - TRI_ASSERT ( _estimator ! = nullptr ) ; <nl> - _estimator - > clear ( ) ; <nl> - <nl> - RocksDBKeyBounds bounds = getBounds ( ) ; <nl> - rocksutils : : iterateBounds ( bounds , <nl> - [ this ] ( rocksdb : : Iterator * it ) { <nl> - uint64_t hash = <nl> - RocksDBVPackIndex : : HashForKey ( it - > key ( ) ) ; <nl> - _estimator - > insert ( hash ) ; <nl> - } ) ; <nl> - } <nl> - <nl> void RocksDBVPackIndex : : afterTruncate ( TRI_voc_tick_t tick ) { <nl> if ( unique ( ) ) { <nl> return ; <nl> RocksDBCuckooIndexEstimator < uint64_t > * RocksDBVPackIndex : : estimator ( ) { <nl> return _estimator . get ( ) ; <nl> } <nl> <nl> - bool RocksDBVPackIndex : : needToPersistEstimate ( ) const { <nl> - if ( _estimator ) { <nl> - return _estimator - > needToPersist ( ) ; <nl> + void RocksDBVPackIndex : : setEstimator ( std : : unique_ptr < RocksDBCuckooIndexEstimator < uint64_t > > est ) { <nl> + TRI_ASSERT ( ! _unique ) ; <nl> + _estimator = std : : move ( est ) ; <nl> + } <nl> + <nl> + void RocksDBVPackIndex : : recalculateEstimates ( ) { <nl> + if ( unique ( ) ) { <nl> + return ; <nl> } <nl> - return false ; <nl> + <nl> + TRI_ASSERT ( _estimator ! = nullptr ) ; <nl> + _estimator - > clear ( ) ; <nl> + <nl> + rocksdb : : TransactionDB * db = rocksutils : : globalRocksDB ( ) ; <nl> + rocksdb : : SequenceNumber seq = db - > GetLatestSequenceNumber ( ) ; <nl> + <nl> + auto bounds = getBounds ( ) ; <nl> + rocksdb : : Slice const end = bounds . end ( ) ; <nl> + rocksdb : : ReadOptions options ; <nl> + options . iterate_upper_bound = & end ; / / safe to use on rocksb : : DB directly <nl> + options . prefix_same_as_start = true ; / / key - prefix includes edge <nl> + options . verify_checksums = false ; <nl> + options . fill_cache = false ; <nl> + std : : unique_ptr < rocksdb : : Iterator > it ( db - > NewIterator ( options , _cf ) ) ; <nl> + for ( it - > Seek ( bounds . start ( ) ) ; it - > Valid ( ) ; it - > Next ( ) ) { <nl> + uint64_t hash = RocksDBVPackIndex : : HashForKey ( it - > key ( ) ) ; <nl> + _estimator - > insert ( hash ) ; <nl> + } <nl> + _estimator - > setCommitSeq ( seq ) ; <nl> } <nl> mmm a / arangod / RocksDBEngine / RocksDBVPackIndex . h <nl> ppp b / arangod / RocksDBEngine / RocksDBVPackIndex . h <nl> class RocksDBVPackIndex : public RocksDBIndex { <nl> double selectivityEstimate ( arangodb : : StringRef const & = arangodb : : StringRef ( ) ) const override ; <nl> <nl> RocksDBCuckooIndexEstimator < uint64_t > * estimator ( ) override ; <nl> - bool needToPersistEstimate ( ) const override ; <nl> + void setEstimator ( std : : unique_ptr < RocksDBCuckooIndexEstimator < uint64_t > > ) override ; <nl> + void recalculateEstimates ( ) override ; <nl> <nl> void toVelocyPack ( VPackBuilder & , <nl> std : : underlying_type < Index : : Serialize > : : type ) const override ; <nl> class RocksDBVPackIndex : public RocksDBIndex { <nl> arangodb : : aql : : AstNode const * , <nl> arangodb : : aql : : Variable const * , <nl> IndexIteratorOptions const & ) override ; <nl> - <nl> - <nl> - rocksdb : : SequenceNumber serializeEstimate ( <nl> - std : : string & output , rocksdb : : SequenceNumber seq ) const override ; <nl> - <nl> - bool deserializeEstimate ( arangodb : : RocksDBSettingsManager * mgr ) override ; <nl> - <nl> - void recalculateEstimates ( ) override ; <nl> <nl> void afterTruncate ( TRI_voc_tick_t tick ) override ; <nl> <nl> mmm a / arangod / RocksDBEngine / RocksDBValue . cpp <nl> ppp b / arangod / RocksDBEngine / RocksDBValue . cpp <nl> <nl> # include " Basics / StringUtils . h " <nl> # include " RocksDBEngine / RocksDBFormat . h " <nl> <nl> + # include " Transaction / Helpers . h " <nl> + <nl> using namespace arangodb ; <nl> using namespace arangodb : : rocksutils ; <nl> <nl> VPackSlice RocksDBValue : : data ( std : : string const & s ) { <nl> return data ( s . data ( ) , s . size ( ) ) ; <nl> } <nl> <nl> - uint64_t RocksDBValue : : keyValue ( RocksDBValue const & value ) { <nl> - return keyValue ( value . _buffer . data ( ) , value . _buffer . size ( ) ) ; <nl> - } <nl> - <nl> uint64_t RocksDBValue : : keyValue ( rocksdb : : Slice const & slice ) { <nl> return keyValue ( slice . data ( ) , slice . size ( ) ) ; <nl> } <nl> <nl> - uint64_t RocksDBValue : : keyValue ( std : : string const & s ) { <nl> - return keyValue ( s . data ( ) , s . size ( ) ) ; <nl> - } <nl> - <nl> S2Point RocksDBValue : : centroid ( rocksdb : : Slice const & s ) { <nl> TRI_ASSERT ( s . size ( ) = = sizeof ( double ) * 3 ) ; <nl> return S2Point ( intToDouble ( uint64FromPersistent ( s . data ( ) ) ) , <nl> VPackSlice RocksDBValue : : data ( char const * data , size_t size ) { <nl> uint64_t RocksDBValue : : keyValue ( char const * data , size_t size ) { <nl> TRI_ASSERT ( data ! = nullptr ) ; <nl> TRI_ASSERT ( size > = sizeof ( char ) ) ; <nl> - VPackSlice slice ( data ) ; <nl> - VPackSlice key = slice . get ( StaticStrings : : KeyString ) ; <nl> + VPackSlice key = transaction : : helpers : : extractKeyFromDocument ( VPackSlice ( data ) ) ; <nl> if ( key . isString ( ) ) { <nl> VPackValueLength l ; <nl> char const * p = key . getString ( l ) ; <nl> mmm a / arangod / RocksDBEngine / RocksDBValue . h <nl> ppp b / arangod / RocksDBEngine / RocksDBValue . h <nl> class RocksDBValue { <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / / @ brief Extracts the numeric value from the key field of a VPackSlice <nl> - / / / <nl> - / / / May be called only on values of the following types : KeyGeneratorValue . <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - static uint64_t keyValue ( RocksDBValue const & ) ; <nl> static uint64_t keyValue ( rocksdb : : Slice const & ) ; <nl> - static uint64_t keyValue ( std : : string const & ) ; <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / / @ brief Centroid of shape or point on the sphere surface in degrees <nl> mmm a / arangod / RocksDBEngine / RocksDBWalAccess . cpp <nl> ppp b / arangod / RocksDBEngine / RocksDBWalAccess . cpp <nl> class MyWALDumper final : public rocksdb : : WriteBatch : : Handler , public WalAccessC <nl> / / rocksdb does not count LogData towards sequence - number <nl> RocksDBLogType type = RocksDBLogValue : : type ( blob ) ; <nl> <nl> - / / LOG_TOPIC ( WARN , Logger : : REPLICATION ) < < " [ LOG ] " < < _currentSequence <nl> + / / LOG_TOPIC ( WARN , Logger : : REPLICATION ) < < " [ LOG ] " < < _currentSequence <nl> / / < < " " < < rocksDBLogTypeName ( type ) ; <nl> switch ( type ) { <nl> case RocksDBLogType : : DatabaseCreate : <nl> mmm a / arangod / StorageEngine / PhysicalCollection . h <nl> ppp b / arangod / StorageEngine / PhysicalCollection . h <nl> class PhysicalCollection { <nl> <nl> / / / @ brief Find index by iid <nl> std : : shared_ptr < Index > lookupIndex ( TRI_idx_iid_t ) const ; <nl> - <nl> std : : vector < std : : shared_ptr < Index > > getIndexes ( ) const ; <nl> + template < typename F > <nl> + void enumerateIndexes ( F & & f ) { <nl> + _indexesLock . readLock ( ) ; / / avoid including ReadLocker . h <nl> + try { <nl> + for ( auto & idx : _indexes ) { <nl> + std : : forward < F > ( f ) ( idx ) ; <nl> + } <nl> + } catch ( . . . ) { } <nl> + _indexesLock . unlockRead ( ) ; <nl> + } <nl> <nl> void getIndexesVPack ( velocypack : : Builder & , unsigned flags , <nl> std : : function < bool ( arangodb : : Index const * ) > const & filter ) const ; <nl> class PhysicalCollection { <nl> LogicalCollection & collection , <nl> arangodb : : velocypack : : Slice const & info <nl> ) ; <nl> - <nl> + <nl> / / / @ brief Inject figures that are specific to StorageEngine <nl> virtual void figuresSpecific ( std : : shared_ptr < arangodb : : velocypack : : Builder > & ) = 0 ; <nl> <nl> mmm a / arangod / Utils / CollectionNameResolver . h <nl> ppp b / arangod / Utils / CollectionNameResolver . h <nl> class CollectionNameResolver { <nl> <nl> } <nl> <nl> - # endif <nl> \ No newline at end of file <nl> + # endif <nl> mmm a / arangosh / Shell / V8ShellFeature . cpp <nl> ppp b / arangosh / Shell / V8ShellFeature . cpp <nl> void V8ShellFeature : : copyInstallationFiles ( ) { <nl> std : : string const versionAppendix = std : : regex_replace ( rest : : Version : : getServerVersion ( ) , std : : regex ( " - . * $ " ) , " " ) ; <nl> std : : string const nodeModulesPath = FileUtils : : buildFilename ( " js " , " node " , " node_modules " ) ; <nl> std : : string const nodeModulesPathVersioned = basics : : FileUtils : : buildFilename ( " js " , versionAppendix , " node " , " node_modules " ) ; <nl> - auto filter = [ & nodeModulesPath , & nodeModulesPathVersioned , this ] ( std : : string const & filename ) - > bool { <nl> + auto filter = [ & nodeModulesPath , & nodeModulesPathVersioned ] ( std : : string const & filename ) - > bool { <nl> if ( filename . size ( ) > = nodeModulesPath . size ( ) ) { <nl> std : : string normalized = filename ; <nl> FileUtils : : normalizePath ( normalized ) ; <nl> mmm a / js / client / modules / @ arangodb / arango - database . js <nl> ppp b / js / client / modules / @ arangodb / arango - database . js <nl> ArangoDatabase . prototype . _flushCache = function ( ) { <nl> <nl> for ( name in this ) { <nl> if ( this . hasOwnProperty ( name ) ) { <nl> - var collection = this [ name ] ; <nl> + var collOrView = this [ name ] ; <nl> <nl> - if ( collection instanceof this . _collectionConstructor ) { <nl> + if ( collOrView instanceof this . _collectionConstructor | | <nl> + collOrView instanceof this . _viewConstructor ) { <nl> / / reset the collection status <nl> - collection . _status = null ; <nl> + collOrView . _status = null ; <nl> this [ name ] = undefined ; <nl> } <nl> } <nl> mmm a / js / common / bootstrap / errors . js <nl> ppp b / js / common / bootstrap / errors . js <nl> <nl> " ERROR_GRAPH_COLLECTION_USE_IN_MULTI_GRAPHS " : { " code " : 1921 , " message " : " edge collection already used in edge def " } , <nl> " ERROR_GRAPH_CREATE_MISSING_NAME " : { " code " : 1922 , " message " : " missing graph name " } , <nl> " ERROR_GRAPH_CREATE_MALFORMED_EDGE_DEFINITION " : { " code " : 1923 , " message " : " malformed edge definition " } , <nl> - " ERROR_GRAPH_NOT_FOUND " : { " code " : 1924 , " message " : " graph not found " } , <nl> + " ERROR_GRAPH_NOT_FOUND " : { " code " : 1924 , " message " : " graph ' % s ' not found " } , <nl> " ERROR_GRAPH_DUPLICATE " : { " code " : 1925 , " message " : " graph already exists " } , <nl> " ERROR_GRAPH_VERTEX_COL_DOES_NOT_EXIST " : { " code " : 1926 , " message " : " vertex collection does not exist or is not part of the graph " } , <nl> " ERROR_GRAPH_WRONG_COLLECTION_TYPE_VERTEX " : { " code " : 1927 , " message " : " not a vertex collection " } , <nl> mmm a / lib / Basics / StaticStrings . cpp <nl> ppp b / lib / Basics / StaticStrings . cpp <nl> std : : string const StaticStrings : : Location ( " location " ) ; <nl> std : : string const StaticStrings : : NoSniff ( " nosniff " ) ; <nl> std : : string const StaticStrings : : Origin ( " origin " ) ; <nl> std : : string const StaticStrings : : PotentialDirtyRead ( " x - arango - potential - dirty - read " ) ; <nl> - std : : string const StaticStrings : : Queue ( " x - arango - queue " ) ; <nl> std : : string const StaticStrings : : RequestForwardedTo ( <nl> " x - arango - request - forwarded - to " ) ; <nl> std : : string const StaticStrings : : ResponseCode ( " x - arango - response - code " ) ; <nl> mmm a / lib / Basics / StaticStrings . h <nl> ppp b / lib / Basics / StaticStrings . h <nl> class StaticStrings { <nl> static std : : string const NoSniff ; <nl> static std : : string const Origin ; <nl> static std : : string const PotentialDirtyRead ; <nl> - static std : : string const Queue ; <nl> static std : : string const RequestForwardedTo ; <nl> static std : : string const ResponseCode ; <nl> static std : : string const Server ; <nl> mmm a / lib / Basics / errors . dat <nl> ppp b / lib / Basics / errors . dat <nl> ERROR_GRAPH_COLLECTION_MULTI_USE , 1920 , " multi use of edge collection in edge def " <nl> ERROR_GRAPH_COLLECTION_USE_IN_MULTI_GRAPHS , 1921 , " edge collection already used in edge def " , " is already used by another graph in a different edge definition . " , <nl> ERROR_GRAPH_CREATE_MISSING_NAME , 1922 , " missing graph name " , " a graph name is required to create a graph . " , <nl> ERROR_GRAPH_CREATE_MALFORMED_EDGE_DEFINITION , 1923 , " malformed edge definition " , " the edge definition is malformed . It has to be an array of objects . " , <nl> - ERROR_GRAPH_NOT_FOUND , 1924 , " graph not found " , " a graph with this name could not be found . " , <nl> + ERROR_GRAPH_NOT_FOUND , 1924 , " graph ' % s ' not found " , " a graph with this name could not be found . " , <nl> ERROR_GRAPH_DUPLICATE , 1925 , " graph already exists " , " a graph with this name already exists . " , <nl> ERROR_GRAPH_VERTEX_COL_DOES_NOT_EXIST , 1926 , " vertex collection does not exist or is not part of the graph " , " the specified vertex collection does not exist or is not part of the graph . " , <nl> ERROR_GRAPH_WRONG_COLLECTION_TYPE_VERTEX , 1927 , " not a vertex collection " , " the collection is not a vertex collection . " , <nl> mmm a / lib / Basics / voc - errors . cpp <nl> ppp b / lib / Basics / voc - errors . cpp <nl> void TRI_InitializeErrorMessages ( ) { <nl> REG_ERROR ( ERROR_GRAPH_COLLECTION_USE_IN_MULTI_GRAPHS , " edge collection already used in edge def " ) ; <nl> REG_ERROR ( ERROR_GRAPH_CREATE_MISSING_NAME , " missing graph name " ) ; <nl> REG_ERROR ( ERROR_GRAPH_CREATE_MALFORMED_EDGE_DEFINITION , " malformed edge definition " ) ; <nl> - REG_ERROR ( ERROR_GRAPH_NOT_FOUND , " graph not found " ) ; <nl> + REG_ERROR ( ERROR_GRAPH_NOT_FOUND , " graph ' % s ' not found " ) ; <nl> REG_ERROR ( ERROR_GRAPH_DUPLICATE , " graph already exists " ) ; <nl> REG_ERROR ( ERROR_GRAPH_VERTEX_COL_DOES_NOT_EXIST , " vertex collection does not exist or is not part of the graph " ) ; <nl> REG_ERROR ( ERROR_GRAPH_WRONG_COLLECTION_TYPE_VERTEX , " not a vertex collection " ) ; <nl> mmm a / lib / Basics / voc - errors . h <nl> ppp b / lib / Basics / voc - errors . h <nl> constexpr int TRI_ERROR_GRAPH_CREATE_MISSING_NAME <nl> constexpr int TRI_ERROR_GRAPH_CREATE_MALFORMED_EDGE_DEFINITION = 1923 ; <nl> <nl> / / / 1924 : ERROR_GRAPH_NOT_FOUND <nl> - / / / " graph not found " <nl> + / / / " graph ' % s ' not found " <nl> / / / a graph with this name could not be found . <nl> constexpr int TRI_ERROR_GRAPH_NOT_FOUND = 1924 ; <nl> <nl> mmm a / tests / RocksDBEngine / IndexEstimatorTest . cpp <nl> ppp b / tests / RocksDBEngine / IndexEstimatorTest . cpp <nl> <nl> # include " catch . hpp " <nl> <nl> # include " RocksDBEngine / RocksDBCuckooIndexEstimator . h " <nl> + # include " RocksDBEngine / RocksDBCollectionMeta . h " <nl> # include " RocksDBEngine / RocksDBFormat . h " <nl> # include " RocksDBEngine / RocksDBTypes . h " <nl> <nl> TEST_CASE ( " IndexEstimator " , " [ rocksdb ] [ indexestimator ] " ) { <nl> for ( auto it : toInsert ) { <nl> est . insert ( it ) ; <nl> } <nl> - uint64_t seq = 42 ; <nl> <nl> - est . serialize ( serialization , seq ) ; <nl> + uint64_t seq = 42 ; <nl> + uint64_t applied = est . serialize ( serialization , 1 ) ; <nl> + CHECK ( applied = = 0 ) ; <nl> <nl> / / Test that the serialization first reports the correct length <nl> uint64_t length = serialization . size ( ) - 8 ; / / don ' t count the seq <nl> TEST_CASE ( " IndexEstimator " , " [ rocksdb ] [ indexestimator ] " ) { <nl> CHECK ( est . nrUsed ( ) = = copy . nrUsed ( ) ) ; <nl> CHECK ( est . nrCuckood ( ) = = copy . nrCuckood ( ) ) ; <nl> CHECK ( est . computeEstimate ( ) = = copy . computeEstimate ( ) ) ; <nl> - CHECK ( seq = = copy . commitSeq ( ) ) ; <nl> + CHECK ( seq = = copy . committedSeq ( ) ) ; <nl> <nl> / / Now let us remove the same elements in both <nl> bool coin = false ; <nl> TEST_CASE ( " IndexEstimator " , " [ rocksdb ] [ indexestimator ] " ) { <nl> rocksdb : : SequenceNumber expected = currentSeq ; <nl> std : : string serialization ; <nl> RocksDBCuckooIndexEstimator < uint64_t > est ( 2048 ) ; <nl> + RocksDBCollectionMeta meta ; <nl> <nl> / / test basic insertion buffering <nl> for ( size_t iteration = 0 ; iteration < 10 ; iteration + + ) { <nl> TEST_CASE ( " IndexEstimator " , " [ rocksdb ] [ indexestimator ] " ) { <nl> std : : vector < uint64_t > toRemove ( 0 ) ; <nl> std : : generate ( toInsert . begin ( ) , toInsert . end ( ) , <nl> [ & index ] { return + + index ; } ) ; <nl> - auto res = est . placeBlocker ( iteration , + + currentSeq ) ; <nl> - expected = currentSeq ; <nl> + expected = currentSeq ; / / only commit up to blocker <nl> + auto res = meta . placeBlocker ( iteration , + + currentSeq ) ; <nl> REQUIRE ( res . ok ( ) ) ; <nl> est . bufferUpdates ( + + currentSeq , std : : move ( toInsert ) , std : : move ( toRemove ) ) ; <nl> <nl> / / make sure we don ' t apply yet <nl> - auto actual = est . serialize ( serialization , + + currentSeq ) ; <nl> + auto actual = est . serialize ( serialization , meta . committableSeq ( ) ) ; <nl> serialization . clear ( ) ; <nl> REQUIRE ( actual = = expected ) ; <nl> REQUIRE ( ( 1 . 0 / std : : max ( 1 . 0 , static_cast < double > ( iteration ) ) ) = = <nl> est . computeEstimate ( ) ) ; <nl> <nl> - est . removeBlocker ( iteration ) ; <nl> + meta . removeBlocker ( iteration ) ; <nl> <nl> / / now make sure we apply it <nl> - actual = est . serialize ( serialization , + + currentSeq ) ; <nl> + actual = est . serialize ( serialization , meta . committableSeq ( ) ) ; <nl> expected = currentSeq ; <nl> serialization . clear ( ) ; <nl> REQUIRE ( actual = = expected ) ; <nl> REQUIRE ( ( 1 . 0 / std : : max ( 1 . 0 , static_cast < double > ( iteration + 1 ) ) ) = = <nl> est . computeEstimate ( ) ) ; <nl> + REQUIRE ( est . committedSeq ( ) = = expected ) ; <nl> } <nl> <nl> / / test basic removal buffering <nl> TEST_CASE ( " IndexEstimator " , " [ rocksdb ] [ indexestimator ] " ) { <nl> std : : vector < uint64_t > toRemove ( 10 ) ; <nl> std : : generate ( toRemove . begin ( ) , toRemove . end ( ) , <nl> [ & index ] { return + + index ; } ) ; <nl> - auto res = est . placeBlocker ( iteration , + + currentSeq ) ; <nl> - expected = currentSeq ; <nl> + expected = currentSeq ; / / only commit up to blocker <nl> + auto res = meta . placeBlocker ( iteration , + + currentSeq ) ; <nl> REQUIRE ( res . ok ( ) ) ; <nl> est . bufferUpdates ( + + currentSeq , std : : move ( toInsert ) , std : : move ( toRemove ) ) ; <nl> <nl> / / make sure we don ' t apply yet <nl> - auto actual = est . serialize ( serialization , + + currentSeq ) ; <nl> + auto actual = est . serialize ( serialization , meta . committableSeq ( ) ) ; <nl> serialization . clear ( ) ; <nl> REQUIRE ( actual = = expected ) ; <nl> REQUIRE ( ( 1 . 0 / std : : max ( 1 . 0 , static_cast < double > ( 10 - iteration ) ) ) = = <nl> est . computeEstimate ( ) ) ; <nl> <nl> - est . removeBlocker ( iteration ) ; <nl> + meta . removeBlocker ( iteration ) ; <nl> <nl> / / now make sure we apply it <nl> - actual = est . serialize ( serialization , + + currentSeq ) ; <nl> + actual = est . serialize ( serialization , meta . committableSeq ( ) ) ; <nl> serialization . clear ( ) ; <nl> expected = currentSeq ; <nl> REQUIRE ( actual = = expected ) ; <nl> REQUIRE ( <nl> ( 1 . 0 / std : : max ( 1 . 0 , static_cast < double > ( 10 - ( iteration + 1 ) ) ) ) = = <nl> est . computeEstimate ( ) ) ; <nl> + REQUIRE ( est . committedSeq ( ) = = expected ) ; <nl> } <nl> } <nl> <nl> TEST_CASE ( " IndexEstimator " , " [ rocksdb ] [ indexestimator ] " ) { <nl> rocksdb : : SequenceNumber currentSeq ( 0 ) ; <nl> std : : string serialization ; <nl> RocksDBCuckooIndexEstimator < uint64_t > est ( 2048 ) ; <nl> + RocksDBCollectionMeta meta ; <nl> <nl> / / test buffering with multiple blockers , but remove blockers in order <nl> for ( size_t iteration = 0 ; iteration < 10 ; iteration + + ) { <nl> TEST_CASE ( " IndexEstimator " , " [ rocksdb ] [ indexestimator ] " ) { <nl> std : : vector < uint64_t > toRemove ( 0 ) ; <nl> std : : generate ( toInsert . begin ( ) , toInsert . end ( ) , <nl> [ & index ] { return + + index ; } ) ; <nl> - auto res = est . placeBlocker ( iteration , + + currentSeq ) ; <nl> + <nl> + auto expected = currentSeq ; / / only commit up to blocker <nl> + auto res = meta . placeBlocker ( iteration , + + currentSeq ) ; <nl> REQUIRE ( res . ok ( ) ) ; <nl> - auto expected = currentSeq ; <nl> est . bufferUpdates ( + + currentSeq , std : : move ( toInsert ) , std : : move ( toRemove ) ) ; <nl> <nl> / / remove previous blocker <nl> - est . removeBlocker ( iteration - 1 ) ; <nl> + meta . removeBlocker ( iteration - 1 ) ; <nl> <nl> / / now make sure we applied last batch , but not this one <nl> - auto actual = est . serialize ( serialization , + + currentSeq ) ; <nl> + auto actual = est . serialize ( serialization , meta . committableSeq ( ) ) ; <nl> serialization . clear ( ) ; <nl> REQUIRE ( actual = = expected ) ; <nl> REQUIRE ( ( 1 . 0 / std : : max ( 1 . 0 , static_cast < double > ( iteration ) ) ) = = <nl> TEST_CASE ( " IndexEstimator " , " [ rocksdb ] [ indexestimator ] " ) { <nl> rocksdb : : SequenceNumber expected ; <nl> std : : string serialization ; <nl> RocksDBCuckooIndexEstimator < uint64_t > est ( 2048 ) ; <nl> - <nl> + RocksDBCollectionMeta meta ; <nl> + <nl> / / test buffering where we keep around one old blocker <nl> for ( size_t iteration = 0 ; iteration < 10 ; iteration + + ) { <nl> uint64_t index = 0 ; <nl> TEST_CASE ( " IndexEstimator " , " [ rocksdb ] [ indexestimator ] " ) { <nl> std : : vector < uint64_t > toRemove ( 0 ) ; <nl> std : : generate ( toInsert . begin ( ) , toInsert . end ( ) , <nl> [ & index ] { return + + index ; } ) ; <nl> - auto res = est . placeBlocker ( iteration , + + currentSeq ) ; <nl> - REQUIRE ( res . ok ( ) ) ; <nl> if ( 0 = = iteration ) { <nl> - expected = currentSeq ; <nl> + expected = currentSeq ; / / only commit up to blocker <nl> } <nl> + auto res = meta . placeBlocker ( iteration , + + currentSeq ) ; <nl> + REQUIRE ( res . ok ( ) ) ; <nl> est . bufferUpdates ( + + currentSeq , std : : move ( toInsert ) , std : : move ( toRemove ) ) ; <nl> / / remove only if not first blocker <nl> - est . removeBlocker ( std : : max ( static_cast < size_t > ( 1 ) , iteration ) ) ; <nl> + meta . removeBlocker ( std : : max ( static_cast < size_t > ( 1 ) , iteration ) ) ; <nl> <nl> / / now make sure we haven ' t applied anything <nl> - auto actual = est . serialize ( serialization , + + currentSeq ) ; <nl> + auto actual = est . serialize ( serialization , meta . committableSeq ( ) ) ; <nl> serialization . clear ( ) ; <nl> REQUIRE ( actual = = expected ) ; <nl> REQUIRE ( 1 . 0 = = est . computeEstimate ( ) ) ; <nl> } <nl> <nl> / / now remove first blocker and make sure we apply everything <nl> - est . removeBlocker ( 0 ) ; <nl> - auto actual = est . serialize ( serialization , + + currentSeq ) ; <nl> + meta . removeBlocker ( 0 ) ; <nl> + auto actual = est . serialize ( serialization , meta . committableSeq ( ) ) ; <nl> expected = currentSeq ; <nl> serialization . clear ( ) ; <nl> REQUIRE ( actual = = expected ) ; <nl> mmm a / tests / js / common / shell / shell - general - graph . js <nl> ppp b / tests / js / common / shell / shell - general - graph . js <nl> function GeneralGraphCreationSuite ( ) { <nl> fail ( ) ; <nl> } catch ( e ) { <nl> assertEqual ( e . errorNum , ERRORS . ERROR_GRAPH_NOT_FOUND . code ) ; <nl> - assertEqual ( e . errorMessage , ERRORS . ERROR_GRAPH_NOT_FOUND . message ) ; <nl> + assertEqual ( e . errorMessage , " graph ' UnitTestGraphUnknownExtension ' not found " ) ; <nl> } <nl> } , <nl> <nl> mmm a / tests / js / server / recovery / collection - keygen - rocksdb . js <nl> ppp b / tests / js / server / recovery / collection - keygen - rocksdb . js <nl> function recoverySuite ( ) { <nl> var c , d ; <nl> <nl> c = db . _collection ( ' UnitTestsRecovery1 ' ) ; <nl> + assertEqual ( c . count ( ) , 1000 ) ; <nl> d = c . save ( { value : 1001 } ) ; <nl> assertEqual ( " 10010 " , d . _key ) ; <nl> } <nl> new file mode 100644 <nl> index 00000000000 . . a5d43e01ba1 <nl> mmm / dev / null <nl> ppp b / tests / js / server / recovery / nosync - collection - keygen - rocksdb . js <nl> <nl> + / * jshint globalstrict : false , strict : false , unused : false * / <nl> + / * global assertTrue , assertFalse , assertEqual , assertMatch * / <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief tests for key generators <nl> + / / / <nl> + / / / @ file <nl> + / / / <nl> + / / / DISCLAIMER <nl> + / / / <nl> + / / / Copyright 2010 - 2012 triagens GmbH , Cologne , Germany <nl> + / / / <nl> + / / / Licensed under the Apache License , Version 2 . 0 ( the " License " ) <nl> + / / / you may not use this file except in compliance with the License . <nl> + / / / You may obtain a copy of the License at <nl> + / / / <nl> + / / / http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + / / / <nl> + / / / Unless required by applicable law or agreed to in writing , software <nl> + / / / distributed under the License is distributed on an " AS IS " BASIS , <nl> + / / / WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + / / / See the License for the specific language governing permissions and <nl> + / / / limitations under the License . <nl> + / / / <nl> + / / / Copyright holder is triAGENS GmbH , Cologne , Germany <nl> + / / / <nl> + / / / @ author Jan Steemann <nl> + / / / @ author Copyright 2013 , triAGENS GmbH , Cologne , Germany <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + var db = require ( ' @ arangodb ' ) . db ; <nl> + var internal = require ( ' internal ' ) ; <nl> + var jsunity = require ( ' jsunity ' ) ; <nl> + <nl> + function runSetup ( ) { <nl> + ' use strict ' ; <nl> + internal . debugClearFailAt ( ) ; <nl> + <nl> + var c ; <nl> + db . _drop ( ' UnitTestsRecovery1 ' ) ; <nl> + c = db . _create ( ' UnitTestsRecovery1 ' , { keyOptions : { type : ' autoincrement ' , <nl> + offset : 0 , increment : 1 } } ) ; <nl> + c . save ( { name : ' a ' } ) ; <nl> + c . save ( { name : ' b ' } ) ; <nl> + c . save ( { name : ' c ' } ) ; <nl> + <nl> + db . _drop ( ' UnitTestsRecovery2 ' ) ; <nl> + c = db . _create ( ' UnitTestsRecovery2 ' , { keyOptions : { type : ' autoincrement ' , <nl> + offset : 10 , increment : 5 } } ) ; <nl> + c . save ( { name : ' a ' } ) ; <nl> + c . save ( { name : ' b ' } ) ; <nl> + c . save ( { name : ' c ' } ) ; <nl> + <nl> + internal . debugSetFailAt ( " RocksDBSettingsManagerSync " ) ; <nl> + <nl> + db . _drop ( ' UnitTestsRecovery3 ' ) ; <nl> + c = db . _create ( ' UnitTestsRecovery3 ' , { keyOptions : { type : ' uuid ' } } ) ; <nl> + c . save ( { name : ' a ' } ) ; <nl> + c . save ( { name : ' b ' } ) ; <nl> + c . save ( { name : ' c ' } ) ; <nl> + <nl> + db . _drop ( ' UnitTestsRecovery4 ' ) ; <nl> + c = db . _create ( ' UnitTestsRecovery4 ' , { keyOptions : { type : ' padded ' } } ) ; <nl> + c . save ( { name : ' a ' } ) ; <nl> + c . save ( { name : ' b ' } ) ; <nl> + c . save ( { name : ' c ' } , { waitForSync : true } ) ; <nl> + <nl> + db . _drop ( ' UnitTestsRecovery5 ' ) ; <nl> + c = db . _create ( ' UnitTestsRecovery5 ' , { keyOptions : { type : ' autoincrement ' , <nl> + offset : 0 , increment : 1 } } ) ; <nl> + let docs = [ ] ; <nl> + for ( let i = 0 ; i < 50000 ; i + + ) { <nl> + docs . push ( { value : i } ) ; <nl> + if ( docs . length = = = 10000 ) { <nl> + c . insert ( docs ) ; <nl> + docs = [ ] ; <nl> + } <nl> + } <nl> + <nl> + internal . debugSegfault ( ' crashing server ' ) ; <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief test suite <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + function recoverySuite ( ) { <nl> + ' use strict ' ; <nl> + jsunity . jsUnity . attachAssertions ( ) ; <nl> + <nl> + return { <nl> + setUp : function ( ) { } , <nl> + tearDown : function ( ) { } , <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief test whether we can restore the trx data <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + testCollectionKeyGen : function ( ) { <nl> + var c , d ; <nl> + <nl> + c = db . _collection ( ' UnitTestsRecovery1 ' ) ; <nl> + assertEqual ( " autoincrement " , c . properties ( ) [ " keyOptions " ] [ " type " ] ) ; <nl> + assertEqual ( [ " 1 " , " 2 " , " 3 " ] , c . toArray ( ) . map ( function ( doc ) { return doc . _key ; } ) . sort ( ) ) ; <nl> + d = c . save ( { name : " d " } ) ; <nl> + assertEqual ( " 4 " , d . _key ) ; <nl> + <nl> + c = db . _collection ( ' UnitTestsRecovery2 ' ) ; <nl> + assertEqual ( " autoincrement " , c . properties ( ) [ " keyOptions " ] [ " type " ] ) ; <nl> + assertEqual ( [ " 10 " , " 15 " , " 20 " ] , c . toArray ( ) . map ( function ( doc ) { return doc . _key ; } ) . sort ( ) ) ; <nl> + d = c . save ( { name : " d " } ) ; <nl> + assertEqual ( " 25 " , d . _key ) ; <nl> + <nl> + c = db . _collection ( ' UnitTestsRecovery3 ' ) ; <nl> + assertEqual ( " uuid " , c . properties ( ) [ " keyOptions " ] [ " type " ] ) ; <nl> + c . toArray ( ) . forEach ( function ( doc ) { <nl> + assertMatch ( / ^ [ 0 - 9a - f ] { 8 } - [ 0 - 9a - f ] { 4 } - [ 0 - 9a - f ] { 4 } - [ 0 - 9a - f ] { 4 } - [ 0 - 9a - f ] { 12 } $ / , doc . _key ) ; <nl> + } ) ; <nl> + <nl> + c = db . _collection ( ' UnitTestsRecovery4 ' ) ; <nl> + assertEqual ( " padded " , c . properties ( ) [ " keyOptions " ] [ " type " ] ) ; <nl> + c . toArray ( ) . forEach ( function ( doc ) { <nl> + assertMatch ( / ^ [ 0 - 9a - f ] { 16 } $ / , doc . _key ) ; <nl> + } ) ; <nl> + <nl> + c = db . _collection ( ' UnitTestsRecovery5 ' ) ; <nl> + assertEqual ( " autoincrement " , c . properties ( ) [ " keyOptions " ] [ " type " ] ) ; <nl> + d = c . save ( { name : " d " } ) ; <nl> + assertEqual ( " 50001 " , d . _key ) ; <nl> + } <nl> + <nl> + } ; <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief executes the test suite <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + function main ( argv ) { <nl> + ' use strict ' ; <nl> + if ( argv [ 1 ] = = = ' setup ' ) { <nl> + runSetup ( ) ; <nl> + return 0 ; <nl> + } else { <nl> + jsunity . run ( recoverySuite ) ; <nl> + return jsunity . writeDone ( ) . status ? 0 : 1 ; <nl> + } <nl> + } <nl> new file mode 100644 <nl> index 00000000000 . . 6ac0aed1491 <nl> mmm / dev / null <nl> ppp b / tests / js / server / recovery / nosync - indexes - hash - rocksdb . js <nl> <nl> + / * jshint globalstrict : false , strict : false , unused : false * / <nl> + / * global assertEqual , assertFalse , assertTrue * / <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief tests for dump / reload <nl> + / / / <nl> + / / / @ file <nl> + / / / <nl> + / / / DISCLAIMER <nl> + / / / <nl> + / / / Copyright 2010 - 2012 triagens GmbH , Cologne , Germany <nl> + / / / <nl> + / / / Licensed under the Apache License , Version 2 . 0 ( the " License " ) <nl> + / / / you may not use this file except in compliance with the License . <nl> + / / / You may obtain a copy of the License at <nl> + / / / <nl> + / / / http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + / / / <nl> + / / / Unless required by applicable law or agreed to in writing , software <nl> + / / / distributed under the License is distributed on an " AS IS " BASIS , <nl> + / / / WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + / / / See the License for the specific language governing permissions and <nl> + / / / limitations under the License . <nl> + / / / <nl> + / / / Copyright holder is triAGENS GmbH , Cologne , Germany <nl> + / / / <nl> + / / / @ author Jan Steemann <nl> + / / / @ author Copyright 2012 , triAGENS GmbH , Cologne , Germany <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + const db = require ( ' @ arangodb ' ) . db ; <nl> + const internal = require ( ' internal ' ) ; <nl> + const jsunity = require ( ' jsunity ' ) ; <nl> + <nl> + const colName1 = ' UnitTestsRecovery1 ' ; <nl> + const colName2 = ' UnitTestsRecovery2 ' ; <nl> + const colName3 = ' UnitTestsRecovery3 ' ; <nl> + const est1 = 1 ; / / The index is de - facto unique so estimate 1 <nl> + const est2 = 1 ; / / This index is unique . Estimate 1 <nl> + const est3 = 4 / 1000 ; / / This index has 4 different values and stores 1000 documents <nl> + <nl> + function runSetup ( ) { <nl> + ' use strict ' ; <nl> + internal . debugClearFailAt ( ) ; <nl> + <nl> + / / turn off syncing of counters etc . <nl> + internal . debugSetFailAt ( " RocksDBSettingsManagerSync " ) ; <nl> + <nl> + db . _drop ( colName1 ) ; <nl> + var c = db . _create ( colName1 ) , i ; <nl> + c . ensureHashIndex ( ' value ' ) ; <nl> + <nl> + for ( i = 0 ; i < 1000 ; + + i ) { <nl> + c . save ( { value : i } ) ; <nl> + } <nl> + <nl> + db . _drop ( colName2 ) ; <nl> + c = db . _create ( colName2 ) ; <nl> + c . ensureUniqueConstraint ( ' a . value ' ) ; <nl> + <nl> + for ( i = 0 ; i < 1000 ; + + i ) { <nl> + c . save ( { a : { value : i } } ) ; <nl> + } <nl> + <nl> + db . _drop ( colName3 ) ; <nl> + c = db . _create ( colName3 ) ; <nl> + c . ensureHashIndex ( ' a ' , ' b ' ) ; <nl> + <nl> + for ( i = 0 ; i < 500 ; + + i ) { <nl> + c . save ( { a : ( i % 2 ) + 1 , b : 1 } ) ; <nl> + c . save ( { a : ( i % 2 ) + 1 , b : 2 } ) ; <nl> + } <nl> + <nl> + db . _drop ( ' test ' ) ; <nl> + c = db . _create ( ' test ' ) ; <nl> + c . save ( { _key : ' crashme ' } , true ) ; <nl> + <nl> + internal . debugSegfault ( ' crashing server ' ) ; <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief test suite <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + function recoverySuite ( ) { <nl> + ' use strict ' ; <nl> + jsunity . jsUnity . attachAssertions ( ) ; <nl> + <nl> + return { <nl> + setUp : function ( ) { <nl> + internal . waitForEstimatorSync ( ) ; / / make sure estimates are consistent <nl> + } , <nl> + tearDown : function ( ) { } , <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief test whether we can restore the trx data <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + testNoSyncSingleAttributeHashIndexInfo : function ( ) { <nl> + let c = db . _collection ( colName1 ) ; <nl> + assertEqual ( c . count ( ) , 1000 ) ; <nl> + let idx = c . getIndexes ( ) [ 1 ] ; <nl> + assertFalse ( idx . unique ) ; <nl> + assertFalse ( idx . sparse ) ; <nl> + assertEqual ( [ ' value ' ] , idx . fields ) ; <nl> + } , <nl> + <nl> + testNoSyncSingleAttributeHashIndexByExample : function ( ) { <nl> + let c = db . _collection ( colName1 ) ; <nl> + for ( let i = 0 ; i < 1000 ; + + i ) { <nl> + assertEqual ( 1 , c . byExample ( { value : i } ) . toArray ( ) . length ) ; <nl> + } <nl> + } , <nl> + <nl> + testNoSyncSingleAttributeHashIndexAql : function ( ) { <nl> + assertEqual ( 1 , db . _query ( ` FOR doc IN $ { colName1 } FILTER doc . value = = 0 RETURN doc ` ) . toArray ( ) . length ) ; <nl> + } , <nl> + <nl> + testNoSyncSingleAttributeHashIndexEstimate : function ( ) { <nl> + let c = db . _collection ( colName1 ) ; <nl> + let idx = c . getIndexes ( ) [ 1 ] ; <nl> + assertEqual ( est1 , idx . selectivityEstimate ) ; <nl> + } , <nl> + <nl> + testNoSyncNestedAttributeHashIndexInfo : function ( ) { <nl> + let c = db . _collection ( colName2 ) ; <nl> + assertEqual ( c . count ( ) , 1000 ) ; <nl> + let idx = c . getIndexes ( ) [ 1 ] ; <nl> + assertTrue ( idx . unique ) ; <nl> + assertFalse ( idx . sparse ) ; <nl> + assertEqual ( [ ' a . value ' ] , idx . fields ) ; <nl> + } , <nl> + <nl> + testNoSyncNestedAttributeHashIndexByExample : function ( ) { <nl> + let c = db . _collection ( colName2 ) ; <nl> + for ( let i = 0 ; i < 1000 ; + + i ) { <nl> + assertEqual ( 1 , c . byExample ( { ' a . value ' : i } ) . toArray ( ) . length ) ; <nl> + } <nl> + } , <nl> + <nl> + testNoSyncNestedAttributeHashIndexAql : function ( ) { <nl> + assertEqual ( 1 , db . _query ( ` FOR doc IN $ { colName2 } FILTER doc . a . value = = 0 RETURN doc ` ) . toArray ( ) . length ) ; <nl> + } , <nl> + <nl> + testNoSyncNestedAttributeHashIndexEstimate : function ( ) { <nl> + let c = db . _collection ( colName2 ) ; <nl> + let idx = c . getIndexes ( ) [ 1 ] ; <nl> + assertEqual ( est2 , idx . selectivityEstimate ) ; <nl> + } , <nl> + <nl> + testNoSyncManyAttributesHashIndexInfo : function ( ) { <nl> + let c = db . _collection ( colName3 ) ; <nl> + let idx = c . getIndexes ( ) [ 1 ] ; <nl> + assertFalse ( idx . unique ) ; <nl> + assertFalse ( idx . sparse ) ; <nl> + assertEqual ( [ ' a ' , ' b ' ] , idx . fields ) ; <nl> + } , <nl> + <nl> + testNoSyncManyAttributesHashIndexByExample : function ( ) { <nl> + let c = db . _collection ( colName3 ) ; <nl> + assertEqual ( 250 , c . byExample ( { a : 1 , b : 1 } ) . toArray ( ) . length ) ; <nl> + assertEqual ( 250 , c . byExample ( { a : 1 , b : 2 } ) . toArray ( ) . length ) ; <nl> + assertEqual ( 250 , c . byExample ( { a : 2 , b : 1 } ) . toArray ( ) . length ) ; <nl> + assertEqual ( 250 , c . byExample ( { a : 2 , b : 2 } ) . toArray ( ) . length ) ; <nl> + } , <nl> + <nl> + testNoSyncManyAttributesHashIndexAql : function ( ) { <nl> + assertEqual ( 250 , db . _query ( ` FOR doc IN $ { colName3 } FILTER doc . a = = 1 & & doc . b = = 1 RETURN doc ` ) . toArray ( ) . length ) ; <nl> + } , <nl> + <nl> + testNoSyncManyAttributesHashIndexEstimate : function ( ) { <nl> + let c = db . _collection ( colName3 ) ; <nl> + assertEqual ( c . count ( ) , 1000 ) ; <nl> + let idx = c . getIndexes ( ) [ 1 ] ; <nl> + assertEqual ( est3 , idx . selectivityEstimate ) ; <nl> + } , <nl> + <nl> + } ; <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief executes the test suite <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + function main ( argv ) { <nl> + ' use strict ' ; <nl> + if ( argv [ 1 ] = = = ' setup ' ) { <nl> + runSetup ( ) ; <nl> + return 0 ; <nl> + } else { <nl> + jsunity . run ( recoverySuite ) ; <nl> + return jsunity . writeDone ( ) . status ? 0 : 1 ; <nl> + } <nl> + } <nl> mmm a / tests / js / server / recovery / nosync - rangedelete - truncate - indexes - rocksdb . js <nl> ppp b / tests / js / server / recovery / nosync - rangedelete - truncate - indexes - rocksdb . js <nl> <nl> / * jshint globalstrict : false , strict : false , unused : false * / <nl> - / * global assertEqual , assertFalse , assertNull , assertNotNull * / <nl> + / * global assertEqual , assertFalse , assertNotNull , fail * / <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / / @ brief tests for transactions <nl> / / / <nl> function runSetup ( ) { <nl> internal . debugSetFailAt ( " RocksDBSettingsManagerSync " ) ; <nl> <nl> db . _drop ( ' UnitTestsRecovery1 ' ) ; <nl> + db . _drop ( ' UnitTestsRecovery2 ' ) ; <nl> + <nl> let c = db . _createEdgeCollection ( ' UnitTestsRecovery1 ' ) ; <nl> + let c2 = db . _create ( ' UnitTestsRecovery2 ' ) ; <nl> + c2 . insert ( { } ) ; / / make sure count is initalized <nl> + <nl> let docs = [ ] ; <nl> for ( let i = 0 ; i < 100000 ; i + + ) { <nl> docs . push ( { _key : " test " + i , _from : " test / 1 " , _to : " test / " + i , value : i } ) ; <nl> function runSetup ( ) { <nl> / / should trigger range deletion <nl> c . truncate ( ) ; <nl> <nl> - c = db . _create ( ' UnitTestsRecovery2 ' ) ; <nl> - c . insert ( { } , { waitForSync : true } ) ; <nl> - <nl> + c2 . insert ( { } , { waitForSync : true } ) ; <nl> internal . debugSegfault ( ' crashing server ' ) ; <nl> } <nl> <nl> function recoverySuite ( ) { <nl> setUp : function ( ) { } , <nl> tearDown : function ( ) { } , <nl> <nl> - testNosyncRangeDeleteTruncateIndexes : function ( ) { <nl> + testNosyncRangeDeleteTruncateIndexes1 : function ( ) { <nl> let c = db . _collection ( ' UnitTestsRecovery1 ' ) ; <nl> assertEqual ( 0 , c . count ( ) ) ; <nl> assertNotNull ( db . _collection ( ' UnitTestsRecovery2 ' ) ) ; <nl> function recoverySuite ( ) { <nl> assertEqual ( [ ] , db . _query ( query , { " @ collection " : c . name ( ) , value : i } ) . toArray ( ) ) ; <nl> assertEqual ( [ ] , c . edges ( " test / " + i ) ) ; <nl> } <nl> + <nl> + internal . waitForEstimatorSync ( ) ; / / make sure estimates are consistent <nl> + let indexes = c . getIndexes ( true ) ; <nl> + for ( let i of indexes ) { <nl> + switch ( i . type ) { <nl> + case ' primary ' : <nl> + case ' hash ' : <nl> + case ' edge ' : <nl> + assertEqual ( i . selectivityEstimate , 1 , JSON . stringify ( indexes ) ) ; <nl> + break ; <nl> + default : <nl> + fail ( ) ; <nl> + } <nl> + } <nl> } <nl> <nl> } ; <nl> new file mode 100644 <nl> index 00000000000 . . b1699627919 <nl> mmm / dev / null <nl> ppp b / tests / js / server / recovery / nosync - rangedelete - truncate - indexes2 - rocksdb . js <nl> <nl> + / * jshint globalstrict : false , strict : false , unused : false * / <nl> + / * global assertEqual , assertFalse , assertNull , assertNotNull , fail * / <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief tests for transactions <nl> + / / / <nl> + / / / @ file <nl> + / / / <nl> + / / / DISCLAIMER <nl> + / / / <nl> + / / / Copyright 2010 - 2012 triagens GmbH , Cologne , Germany <nl> + / / / <nl> + / / / Licensed under the Apache License , Version 2 . 0 ( the " License " ) <nl> + / / / you may not use this file except in compliance with the License . <nl> + / / / You may obtain a copy of the License at <nl> + / / / <nl> + / / / http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + / / / <nl> + / / / Unless required by applicable law or agreed to in writing , software <nl> + / / / distributed under the License is distributed on an " AS IS " BASIS , <nl> + / / / WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + / / / See the License for the specific language governing permissions and <nl> + / / / limitations under the License . <nl> + / / / <nl> + / / / Copyright holder is triAGENS GmbH , Cologne , Germany <nl> + / / / <nl> + / / / @ author Jan Steemann <nl> + / / / @ author Copyright 2013 , triAGENS GmbH , Cologne , Germany <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + var db = require ( ' @ arangodb ' ) . db ; <nl> + var internal = require ( ' internal ' ) ; <nl> + var jsunity = require ( ' jsunity ' ) ; <nl> + <nl> + function runSetup ( ) { <nl> + ' use strict ' ; <nl> + <nl> + db . _drop ( ' UnitTestsRecovery1 ' ) ; <nl> + db . _drop ( ' UnitTestsRecovery2 ' ) ; <nl> + <nl> + let c = db . _createEdgeCollection ( ' UnitTestsRecovery1 ' ) ; <nl> + let c2 = db . _create ( ' UnitTestsRecovery2 ' ) ; <nl> + c2 . insert ( { } ) ; / / make sure count is initalized <nl> + <nl> + let docs = [ ] ; <nl> + for ( let i = 0 ; i < 100000 ; i + + ) { <nl> + docs . push ( { _key : " test " + i , _from : " test / 1 " , _to : " test / " + i , value : i } ) ; <nl> + if ( docs . length = = = 10000 ) { <nl> + c . insert ( docs ) ; <nl> + docs = [ ] ; <nl> + } <nl> + } <nl> + <nl> + c . ensureIndex ( { type : " hash " , fields : [ " value " ] } ) ; <nl> + c . ensureIndex ( { type : " hash " , fields : [ " value " , " _to " ] , unique : true } ) ; <nl> + <nl> + / / should trigger range deletion <nl> + c . truncate ( ) ; <nl> + <nl> + / / turn off syncing of counters etc . <nl> + internal . debugSetFailAt ( " RocksDBSettingsManagerSync " ) ; <nl> + <nl> + c2 . insert ( { } , { waitForSync : true } ) ; <nl> + internal . debugSegfault ( ' crashing server ' ) ; <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief test suite <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + function recoverySuite ( ) { <nl> + ' use strict ' ; <nl> + jsunity . jsUnity . attachAssertions ( ) ; <nl> + <nl> + return { <nl> + setUp : function ( ) { } , <nl> + tearDown : function ( ) { } , <nl> + <nl> + testNosyncRangeDeleteTruncateIndexes2 : function ( ) { <nl> + let c = db . _collection ( ' UnitTestsRecovery1 ' ) ; <nl> + assertEqual ( 0 , c . count ( ) ) ; <nl> + assertNotNull ( db . _collection ( ' UnitTestsRecovery2 ' ) ) ; <nl> + <nl> + assertEqual ( [ ] , c . edges ( " test / 1 " ) ) ; <nl> + let query = " FOR doc IN @ @ collection FILTER doc . value = = @ value RETURN doc " ; <nl> + <nl> + for ( let i = 0 ; i < 100000 ; i + = 1000 ) { <nl> + assertFalse ( c . exists ( " key " + i ) ) ; <nl> + assertEqual ( [ ] , db . _query ( query , { " @ collection " : c . name ( ) , value : i } ) . toArray ( ) ) ; <nl> + assertEqual ( [ ] , c . edges ( " test / " + i ) ) ; <nl> + } <nl> + <nl> + internal . waitForEstimatorSync ( ) ; / / make sure estimates are consistent <nl> + let indexes = c . getIndexes ( true ) ; <nl> + for ( let i of indexes ) { <nl> + switch ( i . type ) { <nl> + case ' primary ' : <nl> + case ' hash ' : <nl> + case ' edge ' : <nl> + assertEqual ( i . selectivityEstimate , 1 , JSON . stringify ( indexes ) ) ; <nl> + break ; <nl> + default : <nl> + fail ( ) ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + } ; <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief executes the test suite <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + function main ( argv ) { <nl> + ' use strict ' ; <nl> + if ( argv [ 1 ] = = = ' setup ' ) { <nl> + runSetup ( ) ; <nl> + return 0 ; <nl> + } else { <nl> + jsunity . run ( recoverySuite ) ; <nl> + return jsunity . writeDone ( ) . status ? 0 : 1 ; <nl> + } <nl> + } <nl> new file mode 100644 <nl> index 00000000000 . . 2649d413daa <nl> mmm / dev / null <nl> ppp b / tests / js / server / recovery / nosync - rangedelete - truncate - indexes3 - rocksdb . js <nl> <nl> + / * jshint globalstrict : false , strict : false , unused : false * / <nl> + / * global assertEqual , assertFalse , assertNull , assertNotNull , fail * / <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief tests for transactions <nl> + / / / <nl> + / / / @ file <nl> + / / / <nl> + / / / DISCLAIMER <nl> + / / / <nl> + / / / Copyright 2010 - 2012 triagens GmbH , Cologne , Germany <nl> + / / / <nl> + / / / Licensed under the Apache License , Version 2 . 0 ( the " License " ) <nl> + / / / you may not use this file except in compliance with the License . <nl> + / / / You may obtain a copy of the License at <nl> + / / / <nl> + / / / http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + / / / <nl> + / / / Unless required by applicable law or agreed to in writing , software <nl> + / / / distributed under the License is distributed on an " AS IS " BASIS , <nl> + / / / WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + / / / See the License for the specific language governing permissions and <nl> + / / / limitations under the License . <nl> + / / / <nl> + / / / Copyright holder is triAGENS GmbH , Cologne , Germany <nl> + / / / <nl> + / / / @ author Jan Steemann <nl> + / / / @ author Copyright 2013 , triAGENS GmbH , Cologne , Germany <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + var db = require ( ' @ arangodb ' ) . db ; <nl> + var internal = require ( ' internal ' ) ; <nl> + var jsunity = require ( ' jsunity ' ) ; <nl> + <nl> + function runSetup ( ) { <nl> + ' use strict ' ; <nl> + <nl> + db . _drop ( ' UnitTestsRecovery1 ' ) ; <nl> + db . _drop ( ' UnitTestsRecovery2 ' ) ; <nl> + <nl> + let c = db . _create ( ' UnitTestsRecovery1 ' ) ; <nl> + let c2 = db . _create ( ' UnitTestsRecovery2 ' ) ; <nl> + c2 . insert ( { } ) ; / / make sure count is initalized <nl> + <nl> + c . ensureIndex ( { type : " hash " , fields : [ " value " ] } ) ; <nl> + let docs = [ ] ; <nl> + for ( let i = 0 ; i < 100000 ; i + + ) { <nl> + docs . push ( { _key : " test " + i , value : i % 1000 } ) ; <nl> + if ( docs . length = = = 10000 ) { <nl> + c . insert ( docs ) ; <nl> + docs = [ ] ; <nl> + } <nl> + } <nl> + <nl> + / / make sure the estimate is synced once <nl> + internal . waitForEstimatorSync ( ) ; <nl> + / / turn off any background op like sync <nl> + internal . debugSetFailAt ( " RocksDBBackgroundThread : : run " ) ; <nl> + / / force a sync right before truncate <nl> + internal . debugSetFailAt ( " RocksDBCollection : : truncate : : forceSync " ) ; <nl> + <nl> + / / should trigger range deletion <nl> + c . truncate ( ) ; <nl> + <nl> + c2 . insert ( { } , { waitForSync : true } ) ; <nl> + internal . debugSegfault ( ' crashing server ' ) ; <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief test suite <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + function recoverySuite ( ) { <nl> + ' use strict ' ; <nl> + jsunity . jsUnity . attachAssertions ( ) ; <nl> + <nl> + return { <nl> + setUp : function ( ) { } , <nl> + tearDown : function ( ) { } , <nl> + <nl> + testNosyncRangeDeleteTruncateIndexes3 : function ( ) { <nl> + let c = db . _collection ( ' UnitTestsRecovery1 ' ) ; <nl> + assertEqual ( 0 , c . count ( ) ) ; <nl> + assertNotNull ( db . _collection ( ' UnitTestsRecovery2 ' ) ) ; <nl> + <nl> + let query = " FOR doc IN @ @ collection FILTER doc . value = = @ value RETURN doc " ; <nl> + <nl> + for ( let i = 0 ; i < 100000 ; i + = 1000 ) { <nl> + assertFalse ( c . exists ( " key " + i ) ) ; <nl> + assertEqual ( [ ] , db . _query ( query , { " @ collection " : c . name ( ) , value : i } ) . toArray ( ) ) ; <nl> + } <nl> + <nl> + internal . waitForEstimatorSync ( ) ; / / make sure estimates are consistent <nl> + let indexes = c . getIndexes ( true ) ; <nl> + for ( let i of indexes ) { <nl> + switch ( i . type ) { <nl> + case ' primary ' : <nl> + case ' hash ' : <nl> + assertEqual ( i . selectivityEstimate , 1 , JSON . stringify ( indexes ) ) ; <nl> + break ; <nl> + default : <nl> + fail ( ) ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + } ; <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief executes the test suite <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + function main ( argv ) { <nl> + ' use strict ' ; <nl> + if ( argv [ 1 ] = = = ' setup ' ) { <nl> + runSetup ( ) ; <nl> + return 0 ; <nl> + } else { <nl> + jsunity . run ( recoverySuite ) ; <nl> + return jsunity . writeDone ( ) . status ? 0 : 1 ; <nl> + } <nl> + } <nl> mmm a / tests / js / server / recovery / nosync - rangedelete - truncate - multi - rocksdb . js <nl> ppp b / tests / js / server / recovery / nosync - rangedelete - truncate - multi - rocksdb . js <nl> <nl> / * jshint globalstrict : false , strict : false , unused : false * / <nl> - / * global assertEqual , assertFalse , assertNull , assertNotNull , fail * / <nl> + / * global assertEqual , assertFalse , assertNull , assertNotNull * / <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / / @ brief tests for transactions <nl> / / / <nl> var jsunity = require ( ' jsunity ' ) ; <nl> <nl> function runSetup ( ) { <nl> ' use strict ' ; <nl> - <nl> + / / turn off syncing of counters etc . <nl> + internal . debugSetFailAt ( " RocksDBSettingsManagerSync " ) ; <nl> + <nl> db . _drop ( ' UnitTestsRecovery1 ' ) ; <nl> - let c = db . _createEdgeCollection ( ' UnitTestsRecovery1 ' ) ; <nl> + let c = db . _create ( ' UnitTestsRecovery1 ' ) ; <nl> let docs = [ ] ; <nl> for ( let i = 0 ; i < 100000 ; i + + ) { <nl> - docs . push ( { _key : " test " + i , _from : " test / 1 " , _to : " test / " + i , value : i } ) ; <nl> + docs . push ( { value : i } ) ; <nl> if ( docs . length = = = 10000 ) { <nl> c . insert ( docs ) ; <nl> docs = [ ] ; <nl> } <nl> } <nl> <nl> - c . ensureIndex ( { type : " hash " , fields : [ " value " ] } ) ; <nl> - c . ensureIndex ( { type : " hash " , fields : [ " value " , " _to " ] , unique : true } ) ; <nl> - <nl> / / should trigger range deletion <nl> c . truncate ( ) ; <nl> <nl> - / / turn off syncing of counters etc . <nl> - internal . debugSetFailAt ( " RocksDBSettingsManagerSync " ) ; <nl> - <nl> - c = db . _create ( ' UnitTestsRecovery2 ' ) ; <nl> + for ( let i = 0 ; i < 90000 ; i + + ) { <nl> + docs . push ( { value : i } ) ; <nl> + if ( docs . length = = = 10000 ) { <nl> + c . insert ( docs ) ; <nl> + docs = [ ] ; <nl> + } <nl> + } <nl> + <nl> + c . truncate ( ) ; <nl> c . insert ( { } , { waitForSync : true } ) ; <nl> <nl> internal . debugSegfault ( ' crashing server ' ) ; <nl> function recoverySuite ( ) { <nl> setUp : function ( ) { } , <nl> tearDown : function ( ) { } , <nl> <nl> - testNosyncRangeDeleteTruncateMulti : function ( ) { <nl> + testNosyncRangeDeleteTruncateMulti1 : function ( ) { <nl> let c = db . _collection ( ' UnitTestsRecovery1 ' ) ; <nl> - assertEqual ( 0 , c . count ( ) ) ; <nl> - assertNotNull ( db . _collection ( ' UnitTestsRecovery2 ' ) ) ; <nl> - <nl> - assertEqual ( [ ] , c . edges ( " test / 1 " ) ) ; <nl> - let query = " FOR doc IN @ @ collection FILTER doc . value = = @ value RETURN doc " ; <nl> - <nl> - for ( let i = 0 ; i < 100000 ; i + = 1000 ) { <nl> - assertFalse ( c . exists ( " key " + i ) ) ; <nl> - assertEqual ( [ ] , db . _query ( query , { " @ collection " : c . name ( ) , value : i } ) . toArray ( ) ) ; <nl> - assertEqual ( [ ] , c . edges ( " test / " + i ) ) ; <nl> - } <nl> - <nl> - internal . waitForEstimatorSync ( ) ; / / make sure estimates are consistent <nl> - let indexes = c . getIndexes ( true ) ; <nl> - for ( let i of indexes ) { <nl> - switch ( i . type ) { <nl> - case ' primary ' : <nl> - case ' hash ' : <nl> - case ' edge ' : <nl> - assertEqual ( i . selectivityEstimate , 1 , JSON . stringify ( i ) ) ; <nl> - break ; <nl> - default : <nl> - fail ( ) ; <nl> - } <nl> - } <nl> + assertEqual ( 1 , c . count ( ) ) ; <nl> } <nl> <nl> } ; <nl> mmm a / tests / js / server / recovery / nosync - rangedelete - truncate - multi2 - rocksdb . js <nl> ppp b / tests / js / server / recovery / nosync - rangedelete - truncate - multi2 - rocksdb . js <nl> var jsunity = require ( ' jsunity ' ) ; <nl> function runSetup ( ) { <nl> ' use strict ' ; <nl> <nl> - / / turn off syncing of counters etc . <nl> - internal . debugSetFailAt ( " RocksDBSettingsManagerSync " ) ; <nl> - <nl> db . _drop ( ' UnitTestsRecovery1 ' ) ; <nl> let c = db . _create ( ' UnitTestsRecovery1 ' ) ; <nl> let docs = [ ] ; <nl> function runSetup ( ) { <nl> } <nl> <nl> c . truncate ( ) ; <nl> - c . insert ( { } , { waitForSync : true } ) ; <nl> <nl> + / / turn off syncing of counters etc . <nl> + internal . debugSetFailAt ( " RocksDBSettingsManagerSync " ) ; <nl> + <nl> + c . insert ( { } , { waitForSync : true } ) ; <nl> internal . debugSegfault ( ' crashing server ' ) ; <nl> } <nl> <nl> function recoverySuite ( ) { <nl> setUp : function ( ) { } , <nl> tearDown : function ( ) { } , <nl> <nl> - testNosyncRangeDeleteTruncate2 : function ( ) { <nl> + testNosyncRangeDeleteTruncateMulti2 : function ( ) { <nl> let c = db . _collection ( ' UnitTestsRecovery1 ' ) ; <nl> assertEqual ( 1 , c . count ( ) ) ; <nl> } <nl> mmm a / tests / js / server / recovery / nosync - rangedelete - truncate - multi3 - rocksdb . js <nl> ppp b / tests / js / server / recovery / nosync - rangedelete - truncate - multi3 - rocksdb . js <nl> var jsunity = require ( ' jsunity ' ) ; <nl> <nl> function runSetup ( ) { <nl> ' use strict ' ; <nl> - / / turn off syncing of counters etc . <nl> - internal . debugSetFailAt ( " RocksDBSettingsManagerSync " ) ; <nl> <nl> db . _drop ( ' UnitTestsRecovery1 ' ) ; <nl> let c = db . _create ( ' UnitTestsRecovery1 ' ) ; <nl> function runSetup ( ) { <nl> <nl> / / should trigger range deletion <nl> c . truncate ( ) ; <nl> + <nl> + / / turn off syncing of counters etc . <nl> + internal . debugSetFailAt ( " RocksDBSettingsManagerSync " ) ; <nl> <nl> for ( let i = 0 ; i < 90000 ; i + + ) { <nl> docs . push ( { value : i } ) ; <nl> function runSetup ( ) { <nl> } <nl> <nl> c . truncate ( ) ; <nl> - c . insert ( { } , { waitForSync : true } ) ; <nl> <nl> + c . insert ( { } , { waitForSync : true } ) ; <nl> internal . debugSegfault ( ' crashing server ' ) ; <nl> } <nl> <nl> function recoverySuite ( ) { <nl> setUp : function ( ) { } , <nl> tearDown : function ( ) { } , <nl> <nl> - testNosyncRangeDeleteTruncate3 : function ( ) { <nl> + testNosyncRangeDeleteTruncateMulti3 : function ( ) { <nl> let c = db . _collection ( ' UnitTestsRecovery1 ' ) ; <nl> assertEqual ( 1 , c . count ( ) ) ; <nl> } <nl> similarity index 67 % <nl> rename from tests / js / server / recovery / rangedelete - truncate - multi2 - rocksdb . js <nl> rename to tests / js / server / recovery / nosync - rangedelete - truncate - multi4 - rocksdb . js <nl> mmm a / tests / js / server / recovery / rangedelete - truncate - multi2 - rocksdb . js <nl> ppp b / tests / js / server / recovery / nosync - rangedelete - truncate - multi4 - rocksdb . js <nl> <nl> / * jshint globalstrict : false , strict : false , unused : false * / <nl> - / * global assertEqual , assertFalse , assertNull , assertNotNull * / <nl> + / * global assertEqual , assertFalse , assertNotNull , fail * / <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / / @ brief tests for transactions <nl> / / / <nl> var jsunity = require ( ' jsunity ' ) ; <nl> <nl> function runSetup ( ) { <nl> ' use strict ' ; <nl> - <nl> + <nl> db . _drop ( ' UnitTestsRecovery1 ' ) ; <nl> + db . _drop ( ' UnitTestsRecovery2 ' ) ; <nl> + <nl> let c = db . _create ( ' UnitTestsRecovery1 ' ) ; <nl> + c . ensureIndex ( { type : " hash " , fields : [ " value " ] } ) ; <nl> + <nl> let docs = [ ] ; <nl> for ( let i = 0 ; i < 100000 ; i + + ) { <nl> - docs . push ( { value : i } ) ; <nl> + docs . push ( { _key : " test " + i , value : i % 1000 } ) ; <nl> if ( docs . length = = = 10000 ) { <nl> c . insert ( docs ) ; <nl> docs = [ ] ; <nl> } <nl> } <nl> <nl> + / / turn off syncing of counters etc . <nl> + internal . debugSetFailAt ( " RocksDBSettingsManagerSync " ) ; <nl> + <nl> / / should trigger range deletion <nl> c . truncate ( ) ; <nl> <nl> for ( let i = 0 ; i < 90000 ; i + + ) { <nl> - docs . push ( { value : i } ) ; <nl> + docs . push ( { _key : " test " + i , value : i % 1000 } ) ; <nl> if ( docs . length = = = 10000 ) { <nl> c . insert ( docs ) ; <nl> docs = [ ] ; <nl> function runSetup ( ) { <nl> } <nl> <nl> c . truncate ( ) ; <nl> - c . insert ( { } , { waitForSync : true } ) ; <nl> <nl> + c = db . _create ( ' UnitTestsRecovery2 ' ) ; <nl> + c . insert ( { } , { waitForSync : true } ) ; <nl> internal . debugSegfault ( ' crashing server ' ) ; <nl> } <nl> <nl> function recoverySuite ( ) { <nl> setUp : function ( ) { } , <nl> tearDown : function ( ) { } , <nl> <nl> - testRangeDeleteTruncateMulti2 : function ( ) { <nl> + testNosyncRangeDeleteTruncateMulti4 : function ( ) { <nl> + <nl> let c = db . _collection ( ' UnitTestsRecovery1 ' ) ; <nl> - assertEqual ( 1 , c . count ( ) ) ; <nl> + assertEqual ( 0 , c . count ( ) ) ; <nl> + assertNotNull ( db . _collection ( ' UnitTestsRecovery2 ' ) ) ; <nl> + <nl> + let query = " FOR doc IN @ @ collection FILTER doc . value = = @ value RETURN doc " ; <nl> + for ( let i = 0 ; i < 100000 ; i + = 1000 ) { <nl> + assertFalse ( c . exists ( " key " + i ) ) ; <nl> + assertEqual ( [ ] , db . _query ( query , { " @ collection " : c . name ( ) , value : i } ) . toArray ( ) ) ; <nl> + } <nl> + <nl> + internal . waitForEstimatorSync ( ) ; / / make sure estimates are consistent <nl> + let indexes = c . getIndexes ( true ) ; <nl> + for ( let i of indexes ) { <nl> + switch ( i . type ) { <nl> + case ' primary ' : <nl> + case ' hash ' : <nl> + assertEqual ( i . selectivityEstimate , 1 , JSON . stringify ( indexes ) ) ; <nl> + break ; <nl> + default : <nl> + fail ( ) ; <nl> + } <nl> + } <nl> } <nl> <nl> } ; <nl> new file mode 100644 <nl> index 00000000000 . . a7aff73df97 <nl> mmm / dev / null <nl> ppp b / tests / js / server / recovery / nosync - rangedelete - truncate - multi5 - rocksdb . js <nl> <nl> + / * jshint globalstrict : false , strict : false , unused : false * / <nl> + / * global assertEqual , assertFalse , assertNotNull , fail * / <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief tests for transactions <nl> + / / / <nl> + / / / @ file <nl> + / / / <nl> + / / / DISCLAIMER <nl> + / / / <nl> + / / / Copyright 2010 - 2012 triagens GmbH , Cologne , Germany <nl> + / / / <nl> + / / / Licensed under the Apache License , Version 2 . 0 ( the " License " ) <nl> + / / / you may not use this file except in compliance with the License . <nl> + / / / You may obtain a copy of the License at <nl> + / / / <nl> + / / / http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + / / / <nl> + / / / Unless required by applicable law or agreed to in writing , software <nl> + / / / distributed under the License is distributed on an " AS IS " BASIS , <nl> + / / / WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + / / / See the License for the specific language governing permissions and <nl> + / / / limitations under the License . <nl> + / / / <nl> + / / / Copyright holder is triAGENS GmbH , Cologne , Germany <nl> + / / / <nl> + / / / @ author Jan Steemann <nl> + / / / @ author Copyright 2013 , triAGENS GmbH , Cologne , Germany <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + var db = require ( ' @ arangodb ' ) . db ; <nl> + var internal = require ( ' internal ' ) ; <nl> + var jsunity = require ( ' jsunity ' ) ; <nl> + <nl> + function runSetup ( ) { <nl> + ' use strict ' ; <nl> + <nl> + db . _drop ( ' UnitTestsRecovery1 ' ) ; <nl> + db . _drop ( ' UnitTestsRecovery2 ' ) ; <nl> + <nl> + let c = db . _create ( ' UnitTestsRecovery1 ' ) ; <nl> + c . ensureIndex ( { type : " hash " , fields : [ " value " ] } ) ; <nl> + <nl> + let docs = [ ] ; <nl> + for ( let i = 0 ; i < 100000 ; i + + ) { <nl> + docs . push ( { _key : " test " + i , value : i % 1000 } ) ; <nl> + if ( docs . length = = = 10000 ) { <nl> + c . insert ( docs ) ; <nl> + docs = [ ] ; <nl> + } <nl> + } <nl> + <nl> + / / should trigger range deletion <nl> + c . truncate ( ) ; <nl> + <nl> + / / turn off syncing of counters etc . <nl> + internal . debugSetFailAt ( " RocksDBSettingsManagerSync " ) ; <nl> + <nl> + for ( let i = 0 ; i < 90000 ; i + + ) { <nl> + docs . push ( { _key : " test " + i , value : i % 1000 } ) ; <nl> + if ( docs . length = = = 10000 ) { <nl> + c . insert ( docs ) ; <nl> + docs = [ ] ; <nl> + } <nl> + } <nl> + <nl> + c . truncate ( ) ; <nl> + <nl> + c = db . _create ( ' UnitTestsRecovery2 ' ) ; <nl> + c . insert ( { } , { waitForSync : true } ) ; <nl> + internal . debugSegfault ( ' crashing server ' ) ; <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief test suite <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + function recoverySuite ( ) { <nl> + ' use strict ' ; <nl> + jsunity . jsUnity . attachAssertions ( ) ; <nl> + <nl> + return { <nl> + setUp : function ( ) { } , <nl> + tearDown : function ( ) { } , <nl> + <nl> + testNosyncRangeDeleteTruncateMulti5 : function ( ) { <nl> + <nl> + let c = db . _collection ( ' UnitTestsRecovery1 ' ) ; <nl> + assertEqual ( 0 , c . count ( ) ) ; <nl> + assertNotNull ( db . _collection ( ' UnitTestsRecovery2 ' ) ) ; <nl> + <nl> + let query = " FOR doc IN @ @ collection FILTER doc . value = = @ value RETURN doc " ; <nl> + for ( let i = 0 ; i < 100000 ; i + = 1000 ) { <nl> + assertFalse ( c . exists ( " key " + i ) ) ; <nl> + assertEqual ( [ ] , db . _query ( query , { " @ collection " : c . name ( ) , value : i } ) . toArray ( ) ) ; <nl> + } <nl> + <nl> + internal . waitForEstimatorSync ( ) ; / / make sure estimates are consistent <nl> + let indexes = c . getIndexes ( true ) ; <nl> + for ( let i of indexes ) { <nl> + switch ( i . type ) { <nl> + case ' primary ' : <nl> + case ' hash ' : <nl> + assertEqual ( i . selectivityEstimate , 1 , JSON . stringify ( indexes ) ) ; <nl> + break ; <nl> + default : <nl> + fail ( ) ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + } ; <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief executes the test suite <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + function main ( argv ) { <nl> + ' use strict ' ; <nl> + if ( argv [ 1 ] = = = ' setup ' ) { <nl> + runSetup ( ) ; <nl> + return 0 ; <nl> + } else { <nl> + jsunity . run ( recoverySuite ) ; <nl> + return jsunity . writeDone ( ) . status ? 0 : 1 ; <nl> + } <nl> + } <nl> new file mode 100644 <nl> index 00000000000 . . 22c1124acb9 <nl> mmm / dev / null <nl> ppp b / tests / js / server / recovery / nosync - rangedelete - truncate - multi6 - rocksdb . js <nl> <nl> + / * jshint globalstrict : false , strict : false , unused : false * / <nl> + / * global assertEqual , assertFalse , assertNotNull , fail * / <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief tests for transactions <nl> + / / / <nl> + / / / @ file <nl> + / / / <nl> + / / / DISCLAIMER <nl> + / / / <nl> + / / / Copyright 2010 - 2012 triagens GmbH , Cologne , Germany <nl> + / / / <nl> + / / / Licensed under the Apache License , Version 2 . 0 ( the " License " ) <nl> + / / / you may not use this file except in compliance with the License . <nl> + / / / You may obtain a copy of the License at <nl> + / / / <nl> + / / / http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + / / / <nl> + / / / Unless required by applicable law or agreed to in writing , software <nl> + / / / distributed under the License is distributed on an " AS IS " BASIS , <nl> + / / / WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + / / / See the License for the specific language governing permissions and <nl> + / / / limitations under the License . <nl> + / / / <nl> + / / / Copyright holder is triAGENS GmbH , Cologne , Germany <nl> + / / / <nl> + / / / @ author Jan Steemann <nl> + / / / @ author Copyright 2013 , triAGENS GmbH , Cologne , Germany <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + var db = require ( ' @ arangodb ' ) . db ; <nl> + var internal = require ( ' internal ' ) ; <nl> + var jsunity = require ( ' jsunity ' ) ; <nl> + <nl> + function runSetup ( ) { <nl> + ' use strict ' ; <nl> + <nl> + db . _drop ( ' UnitTestsRecovery1 ' ) ; <nl> + db . _drop ( ' UnitTestsRecovery2 ' ) ; <nl> + <nl> + let c = db . _create ( ' UnitTestsRecovery1 ' ) ; <nl> + c . ensureIndex ( { type : " hash " , fields : [ " value " ] } ) ; <nl> + <nl> + let docs = [ ] ; <nl> + for ( let i = 0 ; i < 100000 ; i + + ) { <nl> + docs . push ( { _key : " test " + i , value : i % 1000 } ) ; <nl> + if ( docs . length = = = 10000 ) { <nl> + c . insert ( docs ) ; <nl> + docs = [ ] ; <nl> + } <nl> + } <nl> + <nl> + / / should trigger range deletion <nl> + c . truncate ( ) ; <nl> + <nl> + for ( let i = 0 ; i < 90000 ; i + + ) { <nl> + docs . push ( { _key : " test " + i , value : i % 1000 } ) ; <nl> + if ( docs . length = = = 10000 ) { <nl> + c . insert ( docs ) ; <nl> + docs = [ ] ; <nl> + } <nl> + } <nl> + <nl> + c . truncate ( ) ; <nl> + <nl> + / / turn off syncing of counters etc . <nl> + internal . debugSetFailAt ( " RocksDBSettingsManagerSync " ) ; <nl> + <nl> + c = db . _create ( ' UnitTestsRecovery2 ' ) ; <nl> + c . insert ( { } , { waitForSync : true } ) ; <nl> + internal . debugSegfault ( ' crashing server ' ) ; <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief test suite <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + function recoverySuite ( ) { <nl> + ' use strict ' ; <nl> + jsunity . jsUnity . attachAssertions ( ) ; <nl> + <nl> + return { <nl> + setUp : function ( ) { } , <nl> + tearDown : function ( ) { } , <nl> + <nl> + testNosyncRangeDeleteTruncateMulti6 : function ( ) { <nl> + <nl> + let c = db . _collection ( ' UnitTestsRecovery1 ' ) ; <nl> + assertEqual ( 0 , c . count ( ) ) ; <nl> + assertNotNull ( db . _collection ( ' UnitTestsRecovery2 ' ) ) ; <nl> + <nl> + let query = " FOR doc IN @ @ collection FILTER doc . value = = @ value RETURN doc " ; <nl> + for ( let i = 0 ; i < 100000 ; i + = 1000 ) { <nl> + assertFalse ( c . exists ( " key " + i ) ) ; <nl> + assertEqual ( [ ] , db . _query ( query , { " @ collection " : c . name ( ) , value : i } ) . toArray ( ) ) ; <nl> + } <nl> + <nl> + internal . waitForEstimatorSync ( ) ; / / make sure estimates are consistent <nl> + let indexes = c . getIndexes ( true ) ; <nl> + for ( let i of indexes ) { <nl> + switch ( i . type ) { <nl> + case ' primary ' : <nl> + case ' hash ' : <nl> + assertEqual ( i . selectivityEstimate , 1 , JSON . stringify ( indexes ) ) ; <nl> + break ; <nl> + default : <nl> + fail ( ) ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + } ; <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief executes the test suite <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + function main ( argv ) { <nl> + ' use strict ' ; <nl> + if ( argv [ 1 ] = = = ' setup ' ) { <nl> + runSetup ( ) ; <nl> + return 0 ; <nl> + } else { <nl> + jsunity . run ( recoverySuite ) ; <nl> + return jsunity . writeDone ( ) . status ? 0 : 1 ; <nl> + } <nl> + } <nl> mmm a / tests / js / server / recovery / rangedelete - truncate - indexes - rocksdb . js <nl> ppp b / tests / js / server / recovery / rangedelete - truncate - indexes - rocksdb . js <nl> <nl> / * jshint globalstrict : false , strict : false , unused : false * / <nl> - / * global assertEqual , assertFalse , assertNull , assertNotNull * / <nl> + / * global assertEqual , assertFalse , assertNotNull , fail * / <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / / @ brief tests for transactions <nl> / / / <nl> function recoverySuite ( ) { <nl> assertEqual ( [ ] , db . _query ( query , { " @ collection " : c . name ( ) , value : i } ) . toArray ( ) ) ; <nl> assertEqual ( [ ] , c . edges ( " test / " + i ) ) ; <nl> } <nl> + <nl> + internal . waitForEstimatorSync ( ) ; / / make sure estimates are consistent <nl> + let indexes = c . getIndexes ( true ) ; <nl> + for ( let i of indexes ) { <nl> + switch ( i . type ) { <nl> + case ' primary ' : <nl> + case ' hash ' : <nl> + case ' edge ' : <nl> + assertEqual ( i . selectivityEstimate , 1 , JSON . stringify ( indexes ) ) ; <nl> + break ; <nl> + default : <nl> + fail ( ) ; <nl> + } <nl> + } <nl> } <nl> <nl> } ; <nl> mmm a / tests / js / server / recovery / rangedelete - truncate - multi - rocksdb . js <nl> ppp b / tests / js / server / recovery / rangedelete - truncate - multi - rocksdb . js <nl> var jsunity = require ( ' jsunity ' ) ; <nl> <nl> function runSetup ( ) { <nl> ' use strict ' ; <nl> - <nl> + <nl> db . _drop ( ' UnitTestsRecovery1 ' ) ; <nl> - let c = db . _createEdgeCollection ( ' UnitTestsRecovery1 ' ) ; <nl> + let c = db . _create ( ' UnitTestsRecovery1 ' ) ; <nl> let docs = [ ] ; <nl> for ( let i = 0 ; i < 100000 ; i + + ) { <nl> - docs . push ( { _key : " test " + i , _from : " test / 1 " , _to : " test / " + i , value : i } ) ; <nl> + docs . push ( { value : i } ) ; <nl> if ( docs . length = = = 10000 ) { <nl> c . insert ( docs ) ; <nl> docs = [ ] ; <nl> } <nl> } <nl> <nl> - c . ensureIndex ( { type : " hash " , fields : [ " value " ] } ) ; <nl> - c . ensureIndex ( { type : " hash " , fields : [ " value " , " _to " ] , unique : true } ) ; <nl> - <nl> / / should trigger range deletion <nl> c . truncate ( ) ; <nl> - <nl> - c = db . _create ( ' UnitTestsRecovery2 ' ) ; <nl> + <nl> + for ( let i = 0 ; i < 90000 ; i + + ) { <nl> + docs . push ( { value : i } ) ; <nl> + if ( docs . length = = = 10000 ) { <nl> + c . insert ( docs ) ; <nl> + docs = [ ] ; <nl> + } <nl> + } <nl> + <nl> + c . truncate ( ) ; <nl> c . insert ( { } , { waitForSync : true } ) ; <nl> <nl> internal . debugSegfault ( ' crashing server ' ) ; <nl> function recoverySuite ( ) { <nl> setUp : function ( ) { } , <nl> tearDown : function ( ) { } , <nl> <nl> - testRangeDeleteTruncateMulti : function ( ) { <nl> + testRangeDeleteTruncateMulti2 : function ( ) { <nl> let c = db . _collection ( ' UnitTestsRecovery1 ' ) ; <nl> - assertEqual ( 0 , c . count ( ) ) ; <nl> - assertNotNull ( db . _collection ( ' UnitTestsRecovery2 ' ) ) ; <nl> - <nl> - assertEqual ( [ ] , c . edges ( " test / 1 " ) ) ; <nl> - let query = " FOR doc IN @ @ collection FILTER doc . value = = @ value RETURN doc " ; <nl> - <nl> - for ( let i = 0 ; i < 100000 ; i + = 1000 ) { <nl> - assertFalse ( c . exists ( " key " + i ) ) ; <nl> - assertEqual ( [ ] , db . _query ( query , { " @ collection " : c . name ( ) , value : i } ) . toArray ( ) ) ; <nl> - assertEqual ( [ ] , c . edges ( " test / " + i ) ) ; <nl> - } <nl> + assertEqual ( 1 , c . count ( ) ) ; <nl> } <nl> - <nl> } ; <nl> } <nl> <nl> mmm a / tests / js / server / replication / replication - ongoing - global . js <nl> ppp b / tests / js / server / replication / replication - ongoing - global . js <nl> function BaseTestConfig ( ) { <nl> } , <nl> <nl> function ( state ) { <nl> - assertEqual ( db . _collection ( cn ) . count ( ) , 0 ) ; <nl> - assertEqual ( db . _collection ( cn ) . all ( ) . toArray ( ) . length , 0 ) ; <nl> + const c = db . _collection ( cn ) ; <nl> + let x = 10 ; <nl> + while ( c . count ( ) > 0 & & x - - > 0 ) { <nl> + internal . sleep ( 1 ) ; <nl> + } <nl> + assertEqual ( c . count ( ) , 0 ) ; <nl> + assertEqual ( c . all ( ) . toArray ( ) . length , 0 ) ; <nl> } <nl> ) ; <nl> } , <nl> function BaseTestConfig ( ) { <nl> if ( ! state . arangoSearchEnabled ) { <nl> return ; <nl> } <nl> - / / drop view on master <nl> + / / rename view on master <nl> let view = db . _view ( ' UnitTestsSyncView ' ) ; <nl> view . rename ( ' UnitTestsSyncViewRenamed ' ) ; <nl> view = db . _view ( ' UnitTestsSyncViewRenamed ' ) ; <nl> function BaseTestConfig ( ) { <nl> if ( ! state . arangoSearchEnabled ) { <nl> return ; <nl> } <nl> - / / rename view on master <nl> + / / drop view on master <nl> let view = db . _view ( ' UnitTestsSyncView ' ) ; <nl> view . drop ( ) ; <nl> } , <nl> function BaseTestConfig ( ) { <nl> } <nl> <nl> let view = db . _view ( ' UnitTestsSyncView ' ) ; <nl> - assertTrue ( view = = = null ) ; <nl> + let x = 10 ; <nl> + while ( view & & x - - > 0 ) { <nl> + internal . sleep ( 1 ) ; <nl> + db . _flushCache ( ) ; <nl> + view = db . _view ( ' UnitTestsSyncView ' ) ; <nl> + } <nl> + assertNull ( view ) ; <nl> } , <nl> { } <nl> ) ; <nl> mmm a / tests / js / server / replication / replication - ongoing . js <nl> ppp b / tests / js / server / replication / replication - ongoing . js <nl> function BaseTestConfig ( ) { <nl> } , <nl> <nl> function ( state ) { <nl> - assertEqual ( db . _collection ( cn ) . count ( ) , 0 ) ; <nl> - assertEqual ( db . _collection ( cn ) . all ( ) . toArray ( ) . length , 0 ) ; <nl> + const c = db . _collection ( cn ) ; <nl> + let x = 10 ; <nl> + while ( c . count ( ) > 0 & & x - - > 0 ) { <nl> + internal . sleep ( 1 ) ; <nl> + } <nl> + assertEqual ( c . count ( ) , 0 ) ; <nl> + assertEqual ( c . all ( ) . toArray ( ) . length , 0 ) ; <nl> } <nl> ) ; <nl> } , <nl> function BaseTestConfig ( ) { <nl> } <nl> <nl> let view = db . _view ( ' UnitTestsSyncView ' ) ; <nl> - assertTrue ( view = = = null ) ; <nl> + let x = 10 ; <nl> + while ( view & & x - - > 0 ) { <nl> + internal . sleep ( 1 ) ; <nl> + db . _flushCache ( ) ; <nl> + view = db . _view ( ' UnitTestsSyncView ' ) ; <nl> + } <nl> + assertNull ( view ) ; <nl> } , <nl> { } <nl> ) ; <nl> mmm a / tests / rb / HttpInterface / api - general - graph - spec . rb <nl> ppp b / tests / rb / HttpInterface / api - general - graph - spec . rb <nl> def delete_edge ( waitForSync , graph_name , collection , key , options = { } ) <nl> doc = drop_graph ( sync , graph_name ) <nl> doc . code . should eq ( 404 ) <nl> doc . parsed_response [ ' error ' ] . should eq ( true ) <nl> - doc . parsed_response [ ' errorMessage ' ] . should eq ( " graph not found " ) <nl> + doc . parsed_response [ ' errorMessage ' ] . should eq ( " graph ' UnitTestGraph ' not found " ) <nl> doc . parsed_response [ ' code ' ] . should eq ( 404 ) <nl> end <nl> <nl> def check404 ( doc ) <nl> doc . parsed_response [ ' error ' ] . should eq ( true ) <nl> doc . parsed_response [ ' code ' ] . should eq ( 404 ) <nl> doc . parsed_response [ ' errorNum ' ] . should eq ( 1924 ) <nl> - doc . parsed_response [ ' errorMessage ' ] . should eq ( " graph not found " ) <nl> + doc . parsed_response [ ' errorMessage ' ] . should eq ( " graph ' UnitTestUnknown ' not found " ) <nl> end <nl> <nl> it " get graph " do <nl>
|
Make recovery more reliable ( )
|
arangodb/arangodb
|
0dd1776467a425c08ff91b1d8362a68bad5598b3
|
2018-11-19T12:59:18Z
|
mmm a / tensorflow / go / op / wrappers . go <nl> ppp b / tensorflow / go / op / wrappers . go <nl> func RandomUniformInt ( scope * Scope , shape tf . Output , minval tf . Output , maxval tf <nl> return op . Output ( 0 ) <nl> } <nl> <nl> - / / ArgAttr is an optional argument to Arg . <nl> - type ArgAttr func ( optionalAttr ) <nl> - <nl> - / / ArgTout sets the optional Tout attribute to value . <nl> - / / If not specified , defaults to DT_FLOAT <nl> - func ArgTout ( value tf . DataType ) ArgAttr { <nl> - return func ( m optionalAttr ) { <nl> - m [ " Tout " ] = value <nl> - } <nl> - } <nl> - <nl> - / / Returns the argument of a complex number . <nl> - / / <nl> - / / Given a tensor ` input ` of complex numbers , this operation returns a tensor of <nl> - / / type ` float ` that is the argument of each element in ` input ` . All elements in <nl> - / / ` input ` must be complex numbers of the form \ \ ( a + bj \ \ ) , where * a * <nl> - / / is the real part and * b * is the imaginary part . <nl> - / / <nl> - / / <nl> - / / The argument returned by this operation is of the form \ \ ( atan2 ( b , a ) \ \ ) . <nl> - / / <nl> - / / For example : <nl> - / / <nl> - / / ` ` ` <nl> - / / # tensor ' input ' is [ - 2 . 25 + 4 . 75j , 3 . 25 + 5 . 75j ] <nl> - / / tf . angle ( input ) = = > [ 2 . 0132 , 1 . 056 ] <nl> - / / ` ` ` <nl> - func Angle ( scope * Scope , input tf . Output , optional . . . ArgAttr ) ( output tf . Output ) { <nl> - if scope . Err ( ) ! = nil { <nl> - return <nl> - } <nl> - attrs : = map [ string ] interface { } { } <nl> - for _ , a : = range optional { <nl> - a ( attrs ) <nl> - } <nl> - opspec : = tf . OpSpec { <nl> - Type : " Angle " , <nl> - Input : [ ] tf . Input { <nl> - input , <nl> - } , <nl> - Attrs : attrs , <nl> - } <nl> - op : = scope . AddOperation ( opspec ) <nl> - return op . Output ( 0 ) <nl> - } <nl> - <nl> / / Computes fingerprints of the input strings . <nl> / / <nl> / / Arguments : <nl>
|
Fix wrappers . go
|
tensorflow/tensorflow
|
044a063d7d593a05d212aa03f21805797093a2a8
|
2017-08-23T23:49:45Z
|
mmm a / tensorflow / api_template . __init__ . py <nl> ppp b / tensorflow / api_template . __init__ . py <nl> <nl> import os as _os <nl> <nl> # pylint : disable = g - bad - import - order <nl> - from tensorflow . python import pywrap_tensorflow # pylint : disable = unused - import <nl> - <nl> from tensorflow . python . tools import component_api_helper as _component_api_helper <nl> _component_api_helper . package_hook ( <nl> parent_package_str = __name__ , <nl> mmm a / tensorflow / tools / api / golden / v2 / tensorflow . pbtxt <nl> ppp b / tensorflow / tools / api / golden / v2 / tensorflow . pbtxt <nl> tf_module { <nl> name : " ones_initializer " <nl> mtype : " < type \ ' type \ ' > " <nl> } <nl> - member { <nl> - name : " pywrap_tensorflow " <nl> - mtype : " < type \ ' module \ ' > " <nl> - } <nl> member { <nl> name : " qint16 " <nl> mtype : " < class \ ' tensorflow . python . framework . dtypes . DType \ ' > " <nl> mmm a / tensorflow / tools / compatibility / tf_upgrade_v2 . py <nl> ppp b / tensorflow / tools / compatibility / tf_upgrade_v2 . py <nl> def __init__ ( self ) : <nl> " tf . multinomial " : " tf . random . categorical " , <nl> " tf . random . multinomial " : " tf . random . categorical " , <nl> " tf . load_file_system_library " : " tf . load_library " , <nl> + " tf . pywrap_tensorflow " : " tf . compat . v1 . pywrap_tensorflow " , <nl> } ) <nl> # pylint : enable = line - too - long <nl> <nl>
|
Remove pywrap_tensorflow from available symbols in Tensorflow v2
|
tensorflow/tensorflow
|
781a8f2e2093c38ff8e7dff94eb432cd948e54b0
|
2018-11-21T20:49:59Z
|
mmm a / tools / jenkins / run_jenkins . sh <nl> ppp b / tools / jenkins / run_jenkins . sh <nl> <nl> # NOTE : No empty lines should appear in this file before igncr is set ! <nl> set - ex - o igncr | | set - ex <nl> <nl> - # Grabbing the machine ' s architecture <nl> - arch = ` uname - m ` <nl> - <nl> - case $ platform in <nl> - i386 ) <nl> - arch = " i386 " <nl> - platform = " linux " <nl> - docker_suffix = _32bits <nl> - ; ; <nl> - esac <nl> - <nl> if [ " $ platform " = = " linux " ] <nl> then <nl> - echo " building $ language on Linux " <nl> - <nl> - . / tools / run_tests / run_tests . py - - use_docker - t - l $ language - c $ config - x report . xml - j 3 $ @ | | TESTS_FAILED = " true " <nl> - <nl> - elif [ " $ platform " = = " windows " ] <nl> - then <nl> - echo " building $ language on Windows " <nl> - <nl> - # Prevent msbuild from picking up " platform " env variable , which would break the build <nl> - unset platform <nl> - <nl> - python tools / run_tests / run_tests . py - t - l $ language - c $ config - x report . xml - j 3 $ @ | | TESTS_FAILED = " true " <nl> - <nl> - elif [ " $ platform " = = " macos " ] <nl> - then <nl> - echo " building $ language on MacOS " <nl> - <nl> - # Prevent msbuild from picking up " platform " env variable , which would break the build <nl> - unset platform <nl> - <nl> - . / tools / run_tests / run_tests . py - t - l $ language - c $ config - x report . xml - j 3 $ @ | | TESTS_FAILED = " true " <nl> - <nl> + USE_DOCKER_MAYBE = " - - use_docker " <nl> elif [ " $ platform " = = " freebsd " ] <nl> - then <nl> - echo " building $ language on FreeBSD " <nl> + export MAKE = gmake <nl> + fi <nl> <nl> - MAKE = gmake . / tools / run_tests / run_tests . py - t - l $ language - c $ config - x report . xml - j 3 $ @ | | TESTS_FAILED = " true " <nl> + unset platform # variable named ' platform ' breaks the windows build <nl> <nl> - else <nl> - echo " Unknown platform $ platform " <nl> - exit 1 <nl> - fi <nl> + python tools / run_tests / run_tests . py $ USE_DOCKER_MAYBE - t - l $ language - c $ config - x report . xml - j 3 $ @ | | TESTS_FAILED = " true " <nl> <nl> if [ ! - e reports / index . html ] <nl> then <nl>
|
simplify scripts
|
grpc/grpc
|
1961a80e2810f9b778a81725a860eae31a994956
|
2016-01-27T15:29:28Z
|
mmm a / project / cmake / addons / addons / pvr . wmc / pvr . wmc . txt <nl> ppp b / project / cmake / addons / addons / pvr . wmc / pvr . wmc . txt <nl> @ @ - 1 + 1 @ @ <nl> - pvr . wmc https : / / github . com / kodi - pvr / pvr . wmc cf28e4c <nl> + pvr . wmc https : / / github . com / kodi - pvr / pvr . wmc 37b4b29 <nl>
|
Merge pull request from scarecrow420 / pvr . wmc_bump0 . 5 . 3
|
xbmc/xbmc
|
6f708b3f2d70951f5d28139dd6b2d4168218946f
|
2015-04-20T13:20:42Z
|
mmm a / java / Makefile <nl> ppp b / java / Makefile <nl> test : java <nl> java - ea - Djava . library . path = . : . . / - cp " $ ( ROCKSDB_JAR ) : . : . / * " org . rocksdb . test . ComparatorOptionsTest <nl> java - ea - Djava . library . path = . : . . / - cp " $ ( ROCKSDB_JAR ) : . : . / * " org . rocksdb . test . ComparatorTest <nl> java - ea - Djava . library . path = . : . . / - cp " $ ( ROCKSDB_JAR ) : . : . / * " org . rocksdb . test . DirectComparatorTest <nl> + @ rm - rf / tmp / rocksdbjni_ * <nl> <nl> db_bench : java <nl> javac org / rocksdb / benchmark / * . java <nl> mmm a / java / crossbuild / build - linux - centos . sh <nl> ppp b / java / crossbuild / build - linux - centos . sh <nl> <nl> # ! / usr / bin / env bash <nl> # install all required packages for rocksdb that are available through yum <nl> ARCH = $ ( uname - i ) <nl> - sudo yum - y install java - 1 . 6 . 0 - openjdk - devel . $ ARCH zlib zlib - devel bzip2 bzip2 - devel <nl> + sudo yum - y install java - 1 . 7 . 0 - openjdk - devel . $ ARCH zlib zlib - devel bzip2 bzip2 - devel <nl> <nl> # install gcc / g + + 4 . 7 via CERN ( http : / / linux . web . cern . ch / linux / devtoolset / ) <nl> sudo wget - O / etc / yum . repos . d / slc5 - devtoolset . repo http : / / linuxsoft . cern . ch / cern / devtoolset / slc5 - devtoolset . repo <nl> tar xvfz gflags - 1 . 6 . tar . gz ; cd gflags - 1 . 6 ; scl enable devtoolset - 1 . 1 . / configure <nl> export LD_LIBRARY_PATH = $ LD_LIBRARY_PATH : / usr / local / lib <nl> <nl> # set java home so we can build rocksdb jars <nl> - export JAVA_HOME = / usr / lib / jvm / java - 1 . 6 . 0 <nl> + export JAVA_HOME = / usr / lib / jvm / java - 1 . 7 . 0 <nl> <nl> # build rocksdb <nl> cd / rocksdb <nl>
|
Merge pull request from fyrz / JavaTest - Fix
|
facebook/rocksdb
|
bc3bc4bc2fe74594756ad689f697ebe800ad4a4e
|
2014-10-25T00:08:10Z
|
mmm a / include / swift / Parse / Lexer . h <nl> ppp b / include / swift / Parse / Lexer . h <nl> class Lexer { <nl> <nl> Lexer ( llvm : : SourceMgr & SourceMgr , llvm : : StringRef Buffer , <nl> DiagnosticEngine * Diags , const char * CurrentPosition , <nl> - bool InSILMode , bool KeepComments ) ; <nl> + bool InSILMode , bool KeepComments , bool Prime ) ; <nl> + <nl> + void primeLexer ( ) ; <nl> <nl> public : <nl> Lexer ( llvm : : StringRef Buffer , llvm : : SourceMgr & SourceMgr , <nl> DiagnosticEngine * Diags , bool InSILMode , bool KeepComments = false ) <nl> - : Lexer ( SourceMgr , Buffer , Diags , Buffer . begin ( ) , InSILMode , KeepComments ) { } <nl> + : Lexer ( SourceMgr , Buffer , Diags , Buffer . begin ( ) , InSILMode , <nl> + KeepComments , / * Prime = * / true ) { <nl> + } <nl> <nl> / / / \ brief Lexer state can be saved / restored to / from objects of this class . <nl> class State { <nl> class Lexer { <nl> llvm : : SourceMgr & SourceMgr , DiagnosticEngine * Diags , bool InSILMode ) <nl> : Lexer ( SourceMgr , <nl> StringRef ( BeginState . CurPtr , Parent . BufferEnd - BeginState . CurPtr ) , <nl> - Diags , BeginState . CurPtr , InSILMode , Parent . isKeepingComments ( ) ) { <nl> + Diags , BeginState . CurPtr , InSILMode , Parent . isKeepingComments ( ) , <nl> + / * Prime = * / false ) { <nl> assert ( BeginState . CurPtr > = Parent . BufferStart & & <nl> BeginState . CurPtr < = Parent . BufferEnd & & <nl> " Begin position out of range " ) ; <nl> class Lexer { <nl> Parent . CodeCompletionPtr > = BufferStart & & <nl> Parent . CodeCompletionPtr < = BufferEnd ) <nl> CodeCompletionPtr = Parent . CodeCompletionPtr ; <nl> + <nl> + primeLexer ( ) ; <nl> } <nl> <nl> bool isKeepingComments ( ) const { return KeepComments ; } <nl> class Lexer { <nl> } <nl> <nl> State getStateForEndOfTokenLoc ( SourceLoc Loc ) const { <nl> - return getStateForBeginningOfTokenLoc ( getLocForEndOfToken ( SourceMgr , Loc ) ) ; <nl> + return State ( getLocForEndOfToken ( SourceMgr , Loc ) . Value . getPointer ( ) ) ; <nl> } <nl> <nl> / / / \ brief Restore the lexer state to a given one , that can be located either <nl> mmm a / include / swift / Parse / Token . h <nl> ppp b / include / swift / Parse / Token . h <nl> class Token { <nl> StringRef Text ; <nl> <nl> public : <nl> - Token ( ) : Kind ( tok : : unknown ) , AtStartOfLine ( false ) { } <nl> + Token ( ) : Kind ( tok : : NUM_TOKENS ) , AtStartOfLine ( false ) { } <nl> <nl> tok getKind ( ) const { return Kind ; } <nl> void setKind ( tok K ) { Kind = K ; } <nl> mmm a / lib / Parse / Lexer . cpp <nl> ppp b / lib / Parse / Lexer . cpp <nl> static uint32_t validateUTF8CharacterAndAdvance ( const char * & Ptr , <nl> <nl> Lexer : : Lexer ( llvm : : SourceMgr & SourceMgr , StringRef Buffer , <nl> DiagnosticEngine * Diags , const char * CurrentPosition , <nl> - bool InSILMode , bool KeepComments ) <nl> + bool InSILMode , bool KeepComments , bool Prime ) <nl> : SourceMgr ( SourceMgr ) , Diags ( Diags ) , ArtificialEOF ( nullptr ) , <nl> InSILMode ( InSILMode ) , KeepComments ( KeepComments ) { <nl> BufferStart = Buffer . begin ( ) ; <nl> Lexer : : Lexer ( llvm : : SourceMgr & SourceMgr , StringRef Buffer , <nl> CurPtr = CurrentPosition ; <nl> assert ( CurPtr > = BufferStart & & CurPtr < = BufferEnd & & <nl> " Current position is out - of - range " ) ; <nl> - <nl> - / / Prime the lexer . <nl> + <nl> + if ( Prime ) <nl> + primeLexer ( ) ; <nl> + } <nl> + <nl> + void Lexer : : primeLexer ( ) { <nl> + assert ( NextToken . is ( tok : : NUM_TOKENS ) ) ; <nl> lexImpl ( ) ; <nl> - assert ( ( NextToken . isAtStartOfLine ( ) | | CurrentPosition ! = BufferStart ) & & <nl> + assert ( ( NextToken . isAtStartOfLine ( ) | | CurPtr ! = BufferStart ) & & <nl> " The token should be at the beginning of the line , " <nl> " or we should be lexing from the middle of the buffer " ) ; <nl> } <nl> tok Lexer : : getTokenKind ( StringRef Text ) { <nl> assert ( Text . data ( ) > = BufferStart & & Text . data ( ) < = BufferEnd & & <nl> " Text string does not fall within lexer ' s buffer " ) ; <nl> Lexer L ( SourceMgr , StringRef ( BufferStart , BufferEnd - BufferStart ) , Diags , <nl> - Text . data ( ) , / * not SIL mode * / false , isKeepingComments ( ) ) ; <nl> + Text . data ( ) , / * not SIL mode * / false , isKeepingComments ( ) , <nl> + / * Prime = * / true ) ; <nl> Token Result ; <nl> L . lex ( Result ) ; <nl> return Result . getKind ( ) ; <nl> SourceLoc Lexer : : getLocForEndOfToken ( llvm : : SourceMgr & SM , SourceLoc Loc ) { <nl> / / KeepComments irrelevant ) , or the caller lexed comments and KeepComments <nl> / / must be true . <nl> Lexer L ( SM , Buffer - > getBuffer ( ) , nullptr , Loc . Value . getPointer ( ) , false , <nl> - / * KeepComments = * / true ) ; <nl> + / * KeepComments = * / true , / * Prime = * / true ) ; <nl> unsigned Length = L . peekNextToken ( ) . getLength ( ) ; <nl> return Loc . getAdvancedLoc ( Length ) ; <nl> } <nl> new file mode 100644 <nl> index 000000000000 . . 966fb0ab7d10 <nl> mmm / dev / null <nl> ppp b / test / CodeCompletion / code_complete_at_eof_no_newline_1 . swift <nl> <nl> + / / RUN : % swift - ide - test - code - completion - source - filename % s - code - completion - token = A | FileCheck % s - check - prefix = A <nl> + <nl> + / / Make sure we can code complete at EOF when there is no newline in the last <nl> + / / line . <nl> + / / <nl> + / / Don ' t add any tests at the end of the file ! <nl> + / / <nl> + / / A : Begin completions <nl> + / / A - DAG : SwiftDecl : f ( ) [ # Void # ] { { $ } } <nl> + / / A : End completions <nl> + struct FooStruct { <nl> + func f ( ) { } <nl> + } <nl> + var fooObject : FooStruct <nl> + / / There is no newline on the following line . Don ' t fix this ! <nl> + fooObject . # ^ A ^ # <nl> \ No newline at end of file <nl> new file mode 100644 <nl> index 000000000000 . . d4ac74d3d6b0 <nl> mmm / dev / null <nl> ppp b / test / CodeCompletion / code_complete_at_eof_no_newline_2 . swift <nl> <nl> + / / RUN : % swift - ide - test - code - completion - source - filename % s - code - completion - token = A | FileCheck % s - check - prefix = A <nl> + <nl> + / / Make sure we can code complete at EOF when there is no newline in the last <nl> + / / line . <nl> + / / <nl> + / / Don ' t add any tests at the end of the file ! <nl> + / / <nl> + / / A : Begin completions <nl> + / / A - DAG : SwiftDecl : f ( ) [ # Void # ] { { $ } } <nl> + / / A : End completions <nl> + func f ( ) { } <nl> + / / There is no newline on the following line . Don ' t fix this ! <nl> + # ^ A ^ # <nl> \ No newline at end of file <nl>
|
Lexer : don ' t consume the first token before we apply all code completion
|
apple/swift
|
a0cd8e93aea485760308efac01565ffd921d62a0
|
2013-07-26T03:48:20Z
|
mmm a / hphp / runtime / ext / ext_xmlwriter . cpp <nl> ppp b / hphp / runtime / ext / ext_xmlwriter . cpp <nl> String f_xmlwriter_output_memory ( CObjRef xmlwriter , bool flush / * = true * / ) { <nl> / / helpers <nl> <nl> static int write_file ( void * context , const char * buffer , int len ) { <nl> - return ( ( c_XMLWriter * ) context ) - > m_uri - > writeImpl ( buffer , len ) ; <nl> + return len > 0 ? ( ( c_XMLWriter * ) context ) - > m_uri - > writeImpl ( buffer , len ) : 0 ; <nl> } <nl> <nl> static int close_file ( void * context ) { <nl> static xmlChar * xmls ( const String & s ) { <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> c_XMLWriter : : c_XMLWriter ( Class * cb ) : <nl> - ExtObjectData ( cb ) , m_ptr ( NULL ) , m_output ( NULL ) , m_uri_output ( NULL ) { <nl> + ExtObjectData ( cb ) , m_ptr ( nullptr ) , m_output ( nullptr ) { <nl> } <nl> <nl> - c_XMLWriter : : ~ c_XMLWriter ( ) { <nl> + void c_XMLWriter : : sweep ( ) { <nl> if ( m_ptr ) { <nl> + assert ( m_ptr ! = xmlTextWriterPtr ( - 1 ) ) ; <nl> xmlFreeTextWriter ( m_ptr ) ; <nl> + if ( debug ) { <nl> + m_ptr = xmlTextWriterPtr ( - 1 ) ; <nl> + } <nl> } <nl> if ( m_output ) { <nl> + assert ( m_output ! = xmlBufferPtr ( - 1 ) ) ; <nl> xmlBufferFree ( m_output ) ; <nl> + if ( debug ) { <nl> + m_output = xmlBufferPtr ( - 1 ) ; <nl> + } <nl> } <nl> - if ( m_uri_output ) { <nl> - xmlOutputBufferClose ( m_uri_output ) ; <nl> - } <nl> + } <nl> + <nl> + c_XMLWriter : : ~ c_XMLWriter ( ) { <nl> + sweep ( ) ; <nl> } <nl> <nl> void c_XMLWriter : : t___construct ( ) { <nl> bool c_XMLWriter : : t_openuri ( const String & uri ) { <nl> } <nl> m_uri = file . toResource ( ) . getTyped < File > ( ) ; <nl> <nl> - m_uri_output = xmlOutputBufferCreateIO ( write_file , close_file , this , NULL ) ; <nl> - if ( m_uri_output = = NULL ) { <nl> + xmlOutputBufferPtr uri_output = xmlOutputBufferCreateIO ( <nl> + write_file , close_file , this , nullptr ) ; <nl> + if ( uri_output = = nullptr ) { <nl> raise_warning ( " Unable to create output buffer " ) ; <nl> return false ; <nl> } <nl> - m_ptr = xmlNewTextWriter ( m_uri_output ) ; <nl> + m_ptr = xmlNewTextWriter ( uri_output ) ; <nl> return true ; <nl> } <nl> <nl> mmm a / hphp / runtime / ext / ext_xmlwriter . h <nl> ppp b / hphp / runtime / ext / ext_xmlwriter . h <nl> class c_XMLWriter : public ExtObjectData , public Sweepable { <nl> public : <nl> DECLARE_CLASS ( XMLWriter ) <nl> <nl> - / / need to implement <nl> public : c_XMLWriter ( Class * cls = c_XMLWriter : : classof ( ) ) ; <nl> public : ~ c_XMLWriter ( ) ; <nl> public : void t___construct ( ) ; <nl> class c_XMLWriter : public ExtObjectData , public Sweepable { <nl> private : <nl> xmlTextWriterPtr m_ptr ; <nl> xmlBufferPtr m_output ; <nl> - xmlOutputBufferPtr m_uri_output ; <nl> } ; <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> mmm a / hphp / system / idl / xmlwriter . idl . json <nl> ppp b / hphp / system / idl / xmlwriter . idl . json <nl> <nl> ] , <nl> " desc " : " " , <nl> " flags " : [ <nl> + " NoDefaultSweep " <nl> ] , <nl> " footer " : " \ n public : \ n SmartObject < File > m_uri ; \ n private : \ n xmlTextWriterPtr m_ptr ; \ n xmlBufferPtr m_output ; \ n xmlOutputBufferPtr m_uri_output ; " , <nl> " funcs " : [ <nl> new file mode 100644 <nl> index 00000000000 . . b974276d793 <nl> mmm / dev / null <nl> ppp b / hphp / test / slow / ext_xml / empty_write . php <nl> <nl> + < ? php <nl> + $ fname = tempnam ( __DIR__ , ' xmlout ' ) ; <nl> + $ writer = xmlwriter_open_uri ( $ fname ) ; <nl> + xmlwriter_flush ( $ writer ) ; <nl> + print file_exists ( $ fname ) ? " written \ n " : " no file \ n " ; <nl> + unlink ( $ fname ) ; <nl> new file mode 100644 <nl> index 00000000000 . . 90c53c03c37 <nl> mmm / dev / null <nl> ppp b / hphp / test / slow / ext_xml / empty_write . php . expect <nl> @ @ - 0 , 0 + 1 @ @ <nl> + written <nl>
|
Fix xmlwriter_open_uri with no actual output
|
facebook/hhvm
|
5bb1d221ffac62b47ad8ae6bd67f42246be976b5
|
2014-01-09T19:22:02Z
|
mmm a / tensorflow / contrib / opt / python / training / variable_clipping_optimizer . py <nl> ppp b / tensorflow / contrib / opt / python / training / variable_clipping_optimizer . py <nl> def apply_gradients ( self , grads_and_vars , global_step = None , name = None ) : <nl> <nl> def _clip_dense ( self , var ) : <nl> with self . _maybe_colocate_with ( var ) : <nl> - updated_var_value = var . _ref ( ) # pylint : disable = protected - access <nl> + updated_var_value = var . read_value ( ) <nl> normalized_var = clip_ops . clip_by_norm ( <nl> updated_var_value , self . _max_norm , self . _vars_to_clip_dims [ var ] ) <nl> delta = updated_var_value - normalized_var <nl>
|
Replace private method call _ref ( ) with read_value ( )
|
tensorflow/tensorflow
|
65ac3dfa9a48d209edd50178b7477bbfe0435633
|
2018-02-20T19:11:35Z
|
mmm a / modules / highgui / src / window_gtk . cpp <nl> ppp b / modules / highgui / src / window_gtk . cpp <nl> cvImageWidget_get_preferred_width ( GtkWidget * widget , gint * minimal_width , gint <nl> CvImageWidget * image_widget = CV_IMAGE_WIDGET ( widget ) ; <nl> <nl> if ( image_widget - > original_image ! = NULL ) { <nl> - * minimal_width = image_widget - > flags & CV_WINDOW_AUTOSIZE ? <nl> + * minimal_width = ( image_widget - > flags & CV_WINDOW_AUTOSIZE ) ! = CV_WINDOW_AUTOSIZE ? <nl> gdk_window_get_width ( gtk_widget_get_window ( widget ) ) : image_widget - > original_image - > cols ; <nl> } <nl> else { <nl> cvImageWidget_get_preferred_height ( GtkWidget * widget , gint * minimal_height , gin <nl> CvImageWidget * image_widget = CV_IMAGE_WIDGET ( widget ) ; <nl> <nl> if ( image_widget - > original_image ! = NULL ) { <nl> - * minimal_height = image_widget - > flags & CV_WINDOW_AUTOSIZE ? <nl> + * minimal_height = ( image_widget - > flags & CV_WINDOW_AUTOSIZE ) ! = CV_WINDOW_AUTOSIZE ? <nl> gdk_window_get_height ( gtk_widget_get_window ( widget ) ) : image_widget - > original_image - > rows ; <nl> } <nl> else { <nl>
|
highgui : CV_WINDOW_AUTOSIZE does not resize with GTK3
|
opencv/opencv
|
514b202d7b6f09f38c5cb9c5a7c8a8469477880b
|
2015-10-06T15:01:28Z
|
mmm a / arangod / Aql / ExecutionBlock . cpp <nl> ppp b / arangod / Aql / ExecutionBlock . cpp <nl> void AggregatorGroup : : addValues ( AqlItemBlock const * src , <nl> / / / @ brief batch size value <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> - size_t const ExecutionBlock : : DefaultBatchSize = 11 ; <nl> + size_t const ExecutionBlock : : DefaultBatchSize = 1000 ; <nl> <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> / / - - SECTION - - constructors / destructors <nl>
|
reset the defaultbatchsize to 1000
|
arangodb/arangodb
|
fb1fe3e8b1a59aca67172fc1fdcddbc34236c824
|
2014-11-13T11:21:07Z
|
mmm a / configure . ac <nl> ppp b / configure . ac <nl> if test " x $ have_appletls " = " xyes " ; then <nl> use_md = " apple " <nl> AC_DEFINE ( [ USE_APPLE_MD ] , [ 1 ] , [ What message digest implementation to use ] ) <nl> else <nl> - if test " x $ have_wintls " = " xyes " ; then <nl> - use_md = " windows " <nl> - AC_DEFINE ( [ USE_WINDOWS_MD ] , [ 1 ] , [ What message digest implementation to use ] ) <nl> + if test " x $ have_libnettle " = " xyes " ; then <nl> + AC_DEFINE ( [ USE_LIBNETTLE_MD ] , [ 1 ] , [ What message digest implementation to use ] ) <nl> + use_md = " libnettle " <nl> else <nl> - if test " x $ have_libnettle " = " xyes " ; then <nl> - AC_DEFINE ( [ USE_LIBNETTLE_MD ] , [ 1 ] , [ What message digest implementation to use ] ) <nl> - use_md = " libnettle " <nl> + if test " x $ have_libgcrypt " = " xyes " ; then <nl> + AC_DEFINE ( [ USE_LIBGCRYPT_MD ] , [ 1 ] , [ What message digest implementation to use ] ) <nl> + use_md = " libgcrypt " <nl> else <nl> - if test " x $ have_libgcrypt " = " xyes " ; then <nl> - AC_DEFINE ( [ USE_LIBGCRYPT_MD ] , [ 1 ] , [ What message digest implementation to use ] ) <nl> - use_md = " libgcrypt " <nl> + if test " x $ have_openssl " = " xyes " ; then <nl> + AC_DEFINE ( [ USE_OPENSSL_MD ] , [ 1 ] , [ What message digest implementation to use ] ) <nl> + use_md = " openssl " <nl> else <nl> - if test " x $ have_openssl " = " xyes " ; then <nl> - AC_DEFINE ( [ USE_OPENSSL_MD ] , [ 1 ] , [ What message digest implementation to use ] ) <nl> - use_md = " openssl " <nl> - else <nl> - AC_DEFINE ( [ USE_INTERNAL_MD ] , [ 1 ] , [ What message digest implementation to use ] ) <nl> - use_md = " internal " <nl> - fi <nl> + AC_DEFINE ( [ USE_INTERNAL_MD ] , [ 1 ] , [ What message digest implementation to use ] ) <nl> + use_md = " internal " <nl> fi <nl> fi <nl> fi <nl> mmm a / src / Makefile . am <nl> ppp b / src / Makefile . am <nl> SRCS + = \ <nl> AppleTLSSession . cc AppleTLSSession . h <nl> endif # HAVE_APPLETLS <nl> <nl> - if USE_WINDOWS_MD <nl> - SRCS + = WinMessageDigestImpl . cc <nl> - endif # USE_WINDOWS_MD <nl> - <nl> if HAVE_WINTLS <nl> SRCS + = \ <nl> WinTLSContext . cc WinTLSContext . h \ <nl> deleted file mode 100644 <nl> index 28407f4c1 . . 000000000 <nl> mmm a / src / WinMessageDigestImpl . cc <nl> ppp / dev / null <nl> <nl> - / * < ! - - copyright * / <nl> - / * <nl> - * aria2 - The high speed download utility <nl> - * <nl> - * Copyright ( C ) 2013 Nils Maier <nl> - * <nl> - * This program is free software ; you can redistribute it and / or modify <nl> - * it under the terms of the GNU General Public License as published by <nl> - * the Free Software Foundation ; either version 2 of the License , or <nl> - * ( at your option ) any later version . <nl> - * <nl> - * This program is distributed in the hope that it will be useful , <nl> - * but WITHOUT ANY WARRANTY ; without even the implied warranty of <nl> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the <nl> - * GNU General Public License for more details . <nl> - * <nl> - * You should have received a copy of the GNU General Public License <nl> - * along with this program ; if not , write to the Free Software <nl> - * Foundation , Inc . , 51 Franklin Street , Fifth Floor , Boston , MA 02110 - 1301 USA <nl> - * <nl> - * In addition , as a special exception , the copyright holders give <nl> - * permission to link the code of portions of this program with the <nl> - * OpenSSL library under certain conditions as described in each <nl> - * individual source file , and distribute linked combinations <nl> - * including the two . <nl> - * You must obey the GNU General Public License in all respects <nl> - * for all of the code used other than OpenSSL . If you modify <nl> - * file ( s ) with this exception , you may extend this exception to your <nl> - * version of the file ( s ) , but you are not obligated to do so . If you <nl> - * do not wish to do so , delete this exception statement from your <nl> - * version . If you delete this exception statement from all source <nl> - * files in the program , then also delete it here . <nl> - * / <nl> - / * copyright - - > * / <nl> - <nl> - # include " MessageDigestImpl . h " <nl> - <nl> - # include < wincrypt . h > <nl> - <nl> - # include " fmt . h " <nl> - # include " DlAbortEx . h " <nl> - # include " LogFactory . h " <nl> - <nl> - namespace { <nl> - using namespace aria2 ; <nl> - <nl> - class Context { <nl> - private : <nl> - HCRYPTPROV provider_ ; <nl> - public : <nl> - Context ( ) { <nl> - if ( ! : : CryptAcquireContext ( & provider_ , nullptr , nullptr , <nl> - PROV_RSA_AES , CRYPT_VERIFYCONTEXT ) ) { <nl> - if ( ! : : CryptAcquireContext ( & provider_ , nullptr , nullptr , PROV_RSA_AES , <nl> - CRYPT_VERIFYCONTEXT ) ) { <nl> - throw DL_ABORT_EX ( " Failed to get cryptographic provider " ) ; <nl> - } <nl> - } <nl> - } <nl> - ~ Context ( ) { <nl> - : : CryptReleaseContext ( provider_ , 0 ) ; <nl> - } <nl> - <nl> - HCRYPTPROV get ( ) { <nl> - return provider_ ; <nl> - } <nl> - } ; <nl> - <nl> - / / XXX static OK ? <nl> - static Context context_ ; <nl> - <nl> - inline size_t getAlgLength ( ALG_ID id ) <nl> - { <nl> - Context context ; <nl> - HCRYPTHASH hash ; <nl> - if ( ! : : CryptCreateHash ( context . get ( ) , id , 0 , 0 , & hash ) ) { <nl> - throw DL_ABORT_EX ( fmt ( " Failed to initialize hash % d " , id ) ) ; <nl> - } <nl> - <nl> - DWORD rv = 0 ; <nl> - DWORD len = sizeof ( rv ) ; <nl> - if ( ! : : CryptGetHashParam ( hash , HP_HASHSIZE , reinterpret_cast < BYTE * > ( & rv ) , <nl> - & len , 0 ) ) { <nl> - throw DL_ABORT_EX ( " Failed to initialize hash ( 2 ) " ) ; <nl> - } <nl> - : : CryptDestroyHash ( hash ) ; <nl> - <nl> - return rv ; <nl> - } <nl> - <nl> - } / / namespace <nl> - <nl> - namespace aria2 { <nl> - <nl> - <nl> - template < ALG_ID id > <nl> - class MessageDigestBase : public MessageDigestImpl { <nl> - private : <nl> - HCRYPTHASH hash_ ; <nl> - DWORD len_ ; <nl> - <nl> - void destroy ( ) { <nl> - if ( hash_ ) { <nl> - : : CryptDestroyHash ( hash_ ) ; <nl> - hash_ = 0 ; <nl> - } <nl> - } <nl> - <nl> - public : <nl> - MessageDigestBase ( ) : hash_ ( 0 ) , len_ ( 0 ) { reset ( ) ; } <nl> - virtual ~ MessageDigestBase ( ) { destroy ( ) ; } <nl> - <nl> - static size_t length ( ) { <nl> - MessageDigestBase < id > rv ; <nl> - return rv . getDigestLength ( ) ; <nl> - } <nl> - virtual size_t getDigestLength ( ) const CXX11_OVERRIDE { <nl> - return len_ ; <nl> - } <nl> - virtual void reset ( ) CXX11_OVERRIDE { <nl> - destroy ( ) ; <nl> - if ( ! : : CryptCreateHash ( context_ . get ( ) , id , 0 , 0 , & hash_ ) ) { <nl> - throw DL_ABORT_EX ( " Failed to create hash " ) ; <nl> - } <nl> - DWORD len = sizeof ( len_ ) ; <nl> - if ( ! : : CryptGetHashParam ( hash_ , HP_HASHSIZE , reinterpret_cast < BYTE * > ( & len_ ) , <nl> - & len , 0 ) ) { <nl> - throw DL_ABORT_EX ( " Failed to initialize hash " ) ; <nl> - } <nl> - } <nl> - virtual void update ( const void * data , size_t length ) CXX11_OVERRIDE { <nl> - auto bytes = reinterpret_cast < const unsigned char * > ( data ) ; <nl> - while ( length ) { <nl> - DWORD l = std : : min ( length , ( size_t ) std : : numeric_limits < uint32_t > : : max ( ) ) ; <nl> - if ( ! : : CryptHashData ( hash_ , bytes , l , 0 ) ) { <nl> - throw DL_ABORT_EX ( " Failed to update hash " ) ; <nl> - } <nl> - length - = l ; <nl> - bytes + = l ; <nl> - } <nl> - } <nl> - virtual void digest ( unsigned char * md ) CXX11_OVERRIDE { <nl> - DWORD len = len_ ; <nl> - if ( ! : : CryptGetHashParam ( hash_ , HP_HASHVAL , md , & len , 0 ) ) { <nl> - throw DL_ABORT_EX ( " Failed to create hash digest " ) ; <nl> - } <nl> - } <nl> - } ; <nl> - <nl> - typedef MessageDigestBase < CALG_MD5 > MessageDigestMD5 ; <nl> - typedef MessageDigestBase < CALG_SHA1 > MessageDigestSHA1 ; <nl> - typedef MessageDigestBase < CALG_SHA_256 > MessageDigestSHA256 ; <nl> - typedef MessageDigestBase < CALG_SHA_384 > MessageDigestSHA384 ; <nl> - typedef MessageDigestBase < CALG_SHA_512 > MessageDigestSHA512 ; <nl> - <nl> - std : : unique_ptr < MessageDigestImpl > MessageDigestImpl : : sha1 ( ) <nl> - { <nl> - return std : : unique_ptr < MessageDigestImpl > ( new MessageDigestSHA1 ( ) ) ; <nl> - } <nl> - <nl> - namespace { <nl> - MessageDigestImpl : : hashes_t initialize ( ) { <nl> - MessageDigestImpl : : hashes_t rv = { <nl> - { " sha - 1 " , MessageDigestImpl : : make_hi < MessageDigestSHA1 > ( ) } , <nl> - { " md5 " , MessageDigestImpl : : make_hi < MessageDigestMD5 > ( ) } , <nl> - } ; <nl> - <nl> - try { <nl> - rv . insert ( { " sha - 256 " , MessageDigestImpl : : make_hi < MessageDigestSHA256 > ( ) } ) ; <nl> - } <nl> - catch ( RecoverableException & ex ) { <nl> - printf ( " SHA - 256 is not supported on this machine " ) ; <nl> - } <nl> - try { <nl> - rv . insert ( { " sha - 384 " , MessageDigestImpl : : make_hi < MessageDigestSHA384 > ( ) } ) ; <nl> - } <nl> - catch ( RecoverableException & ex ) { <nl> - printf ( " SHA - 384 is not supported on this machine " ) ; <nl> - } <nl> - try { <nl> - rv . insert ( { " sha - 512 " , MessageDigestImpl : : make_hi < MessageDigestSHA512 > ( ) } ) ; <nl> - } <nl> - catch ( RecoverableException & ex ) { <nl> - printf ( " SHA - 512 is not supported on this machine " ) ; <nl> - } <nl> - <nl> - return rv ; <nl> - } ; <nl> - } / / namespace <nl> - <nl> - MessageDigestImpl : : hashes_t MessageDigestImpl : : hashes = initialize ( ) ; <nl> - <nl> - } / / namespace aria2 <nl>
|
Drop WinMessageDigestImpl .
|
aria2/aria2
|
0c8a2659ea8c52f0e91f0eec28c3250c54a6460a
|
2014-06-24T18:45:12Z
|
mmm a / qa / pull - tester / rpc - tests . py <nl> ppp b / qa / pull - tester / rpc - tests . py <nl> <nl> ' bip68 - 112 - 113 - p2p . py ' , <nl> ' wallet . py ' , <nl> ' wallet - hd . py ' , <nl> + ' wallet - dump . py ' , <nl> ' listtransactions . py ' , <nl> ' receivedby . py ' , <nl> ' mempool_resurrect_test . py ' , <nl> new file mode 100755 <nl> index 000000000000 . . dd675f57fc46 <nl> mmm / dev / null <nl> ppp b / qa / rpc - tests / wallet - dump . py <nl> <nl> + # ! / usr / bin / env python3 <nl> + # Copyright ( c ) 2016 The Bitcoin Core developers <nl> + # Distributed under the MIT software license , see the accompanying <nl> + # file COPYING or http : / / www . opensource . org / licenses / mit - license . php . <nl> + <nl> + from test_framework . test_framework import BitcoinTestFramework <nl> + from test_framework . util import * <nl> + import os <nl> + import shutil <nl> + <nl> + <nl> + class WalletDumpTest ( BitcoinTestFramework ) : <nl> + <nl> + def __init__ ( self ) : <nl> + super ( ) . __init__ ( ) <nl> + self . setup_clean_chain = False <nl> + self . num_nodes = 1 <nl> + <nl> + def setup_network ( self , split = False ) : <nl> + extra_args = [ [ " - keypool = 100 " ] ] <nl> + self . nodes = start_nodes ( self . num_nodes , self . options . tmpdir , extra_args ) <nl> + <nl> + def run_test ( self ) : <nl> + tmpdir = self . options . tmpdir <nl> + <nl> + # generate 20 addresses to compare against the dump <nl> + test_addr_count = 20 <nl> + addrs = [ ] <nl> + for i in range ( 0 , test_addr_count ) : <nl> + addr = self . nodes [ 0 ] . getnewaddress ( ) <nl> + vaddr = self . nodes [ 0 ] . validateaddress ( addr ) # required to get hd keypath <nl> + addrs . append ( vaddr ) <nl> + <nl> + # dump unencrypted wallet <nl> + self . nodes [ 0 ] . dumpwallet ( tmpdir + " / node0 / wallet . unencrypted . dump " ) <nl> + <nl> + # open file <nl> + inputfile = open ( tmpdir + " / node0 / wallet . unencrypted . dump " ) <nl> + found_addr = 0 <nl> + found_addr_chg = 0 <nl> + found_addr_rsv = 0 <nl> + hdmasteraddr = " " <nl> + for line in inputfile : <nl> + # only read non comment lines <nl> + if line [ 0 ] ! = " # " and len ( line ) > 10 : <nl> + # split out some data <nl> + keyLabel , comment = line . split ( " # " ) <nl> + key = keyLabel . split ( " " ) [ 0 ] <nl> + keytype = keyLabel . split ( " " ) [ 2 ] <nl> + if len ( comment ) > 1 : <nl> + addrKeypath = comment . split ( " addr = " ) [ 1 ] <nl> + addr = addrKeypath . split ( " " ) [ 0 ] <nl> + keypath = " " <nl> + if keytype ! = " hdmaster = 1 " : <nl> + keypath = addrKeypath . rstrip ( ) . split ( " hdkeypath = " ) [ 1 ] <nl> + else : <nl> + # keep hd master for later comp . <nl> + hdmasteraddr = addr <nl> + <nl> + # count key types <nl> + for addrObj in addrs : <nl> + if ( addrObj [ ' address ' ] = = addr and addrObj [ ' hdkeypath ' ] = = keypath and keytype = = " label = " ) : <nl> + found_addr + = 1 <nl> + break <nl> + elif ( keytype = = " change = 1 " ) : <nl> + found_addr_chg + = 1 <nl> + break <nl> + elif ( keytype = = " reserve = 1 " ) : <nl> + found_addr_rsv + = 1 <nl> + break <nl> + assert ( found_addr = = test_addr_count ) # all keys must be in the dump <nl> + assert ( found_addr_chg = = 50 ) # 50 blocks where mined <nl> + assert ( found_addr_rsv = = 100 ) # 100 reserve keys ( keypool ) <nl> + <nl> + # encrypt wallet , restart , unlock and dump <nl> + self . nodes [ 0 ] . encryptwallet ( ' test ' ) <nl> + bitcoind_processes [ 0 ] . wait ( ) <nl> + self . nodes [ 0 ] = start_node ( 0 , self . options . tmpdir ) <nl> + self . nodes [ 0 ] . walletpassphrase ( ' test ' , 10 ) <nl> + self . nodes [ 0 ] . dumpwallet ( tmpdir + " / node0 / wallet . encrypted . dump " ) <nl> + <nl> + # open dump done with an encrypted wallet <nl> + inputfile = open ( tmpdir + " / node0 / wallet . encrypted . dump " ) <nl> + found_addr = 0 <nl> + found_addr_chg = 0 <nl> + found_addr_rsv = 0 <nl> + for line in inputfile : <nl> + if line [ 0 ] ! = " # " and len ( line ) > 10 : <nl> + keyLabel , comment = line . split ( " # " ) <nl> + key = keyLabel . split ( " " ) [ 0 ] <nl> + keytype = keyLabel . split ( " " ) [ 2 ] <nl> + if len ( comment ) > 1 : <nl> + addrKeypath = comment . split ( " addr = " ) [ 1 ] <nl> + addr = addrKeypath . split ( " " ) [ 0 ] <nl> + keypath = " " <nl> + if keytype ! = " hdmaster = 1 " : <nl> + keypath = addrKeypath . rstrip ( ) . split ( " hdkeypath = " ) [ 1 ] <nl> + else : <nl> + # ensure we have generated a new hd master key <nl> + assert ( hdmasteraddr ! = addr ) <nl> + if keytype = = " inactivehdmaster = 1 " : <nl> + # ensure the old master is still available <nl> + assert ( hdmasteraddr = = addr ) <nl> + for addrObj in addrs : <nl> + if ( addrObj [ ' address ' ] = = addr and addrObj [ ' hdkeypath ' ] = = keypath and keytype = = " label = " ) : <nl> + found_addr + = 1 <nl> + break <nl> + elif ( keytype = = " change = 1 " ) : <nl> + found_addr_chg + = 1 <nl> + break <nl> + elif ( keytype = = " reserve = 1 " ) : <nl> + found_addr_rsv + = 1 <nl> + break <nl> + <nl> + assert ( found_addr = = test_addr_count ) <nl> + assert ( found_addr_chg = = 150 ) # old reserve keys are marked as change now <nl> + assert ( found_addr_rsv = = 100 ) # keypool size <nl> + <nl> + if __name__ = = ' __main__ ' : <nl> + WalletDumpTest ( ) . main ( ) <nl>
|
[ QA ] Add walletdump RPC test ( including HD - & encryption - tests )
|
bitcoin/bitcoin
|
54af51d98d0b38f08c58dd589bff81883aee2854
|
2016-07-28T13:05:35Z
|
mmm a / README . md <nl> ppp b / README . md <nl> around . It was designed for network playback , so you can stream your multimedia <nl> from anywhere in the house or directly from the internet using practically any <nl> protocol available . <nl> <nl> - Use your media as - is : Kodi can play CD ' s and DVD ' s directly <nl> + Use your media as - is : Kodi can play CDs and DVDs directly <nl> from the disk or image file , almost all popular archive formats from your hard <nl> drive , and even files inside ZIP and RAR archives . It will even scan all of <nl> your media and automatically create a personalized library complete with box <nl>
|
Merge pull request from sjetha / master
|
xbmc/xbmc
|
16dfe736da501b9d357cbd5106f74f13a4ca4137
|
2016-06-20T15:51:02Z
|
mmm a / src / gui / Src / BasicView / StdTable . cpp <nl> ppp b / src / gui / Src / BasicView / StdTable . cpp <nl> StdTable : : StdTable ( QWidget * parent ) : AbstractTableView ( parent ) <nl> <nl> QString StdTable : : paintContent ( QPainter * painter , dsint rowBase , int rowOffset , int col , int x , int y , int w , int h ) <nl> { <nl> - if ( isSelected ( rowBase , rowOffset ) = = true ) <nl> + if ( isSelected ( rowBase , rowOffset ) ) <nl> painter - > fillRect ( QRect ( x , y , w , h ) , QBrush ( selectionColor ) ) ; <nl> return getCellContent ( rowBase + rowOffset , col ) ; <nl> } <nl> void StdTable : : mouseMoveEvent ( QMouseEvent * event ) <nl> <nl> if ( wRowIndex < getRowCount ( ) ) <nl> { <nl> - if ( mIsMultiSelctionAllowed = = true ) <nl> + if ( mIsMultiSelctionAllowed ) <nl> expandSelectionUpTo ( wRowIndex ) ; <nl> else <nl> setSingleSelection ( wRowIndex ) ; <nl> void StdTable : : mouseMoveEvent ( QMouseEvent * event ) <nl> } <nl> } <nl> <nl> - if ( wAccept = = true ) <nl> + if ( wAccept ) <nl> AbstractTableView : : mouseMoveEvent ( event ) ; <nl> } <nl> <nl> void StdTable : : mousePressEvent ( QMouseEvent * event ) <nl> } <nl> } <nl> <nl> - if ( wAccept = = false ) <nl> + if ( ! wAccept ) <nl> AbstractTableView : : mousePressEvent ( event ) ; <nl> } <nl> <nl> void StdTable : : mouseReleaseEvent ( QMouseEvent * event ) <nl> } <nl> } <nl> <nl> - if ( wAccept = = true ) <nl> + if ( wAccept ) <nl> AbstractTableView : : mouseReleaseEvent ( event ) ; <nl> } <nl> <nl> void StdTable : : addColumnAt ( int width , QString title , bool isClickable , QString c <nl> <nl> / / append empty column to list of rows <nl> for ( int i = 0 ; i < mData . size ( ) ; i + + ) <nl> - mData [ i ] . append ( " " ) ; <nl> + mData [ i ] . push_back ( CellData ( ) ) ; <nl> <nl> / / Append copy title <nl> if ( ! copyTitle . length ( ) ) <nl> - mCopyTitles . append ( title ) ; <nl> + mCopyTitles . push_back ( title ) ; <nl> else <nl> - mCopyTitles . append ( copyTitle ) ; <nl> + mCopyTitles . push_back ( copyTitle ) ; <nl> } <nl> <nl> void StdTable : : setRowCount ( int count ) <nl> { <nl> - int wRowToAddOrRemove = count - mData . size ( ) ; <nl> + int wRowToAddOrRemove = count - int ( mData . size ( ) ) ; <nl> for ( int i = 0 ; i < qAbs ( wRowToAddOrRemove ) ; i + + ) <nl> { <nl> if ( wRowToAddOrRemove > 0 ) <nl> { <nl> - mData . append ( QList < QString > ( ) ) ; <nl> + mData . push_back ( std : : vector < CellData > ( ) ) ; <nl> for ( int j = 0 ; j < getColumnCount ( ) ; j + + ) <nl> - mData . last ( ) . append ( " " ) ; <nl> + mData [ mData . size ( ) - 1 ] . push_back ( CellData ( ) ) ; <nl> } <nl> else <nl> - mData . removeLast ( ) ; <nl> + mData . pop_back ( ) ; <nl> } <nl> AbstractTableView : : setRowCount ( count ) ; <nl> } <nl> void StdTable : : deleteAllColumns ( ) <nl> <nl> void StdTable : : setCellContent ( int r , int c , QString s ) <nl> { <nl> - if ( isValidIndex ( r , c ) = = true ) <nl> - mData [ r ] . replace ( c , s ) ; <nl> + if ( isValidIndex ( r , c ) ) <nl> + mData [ r ] [ c ] . text = s ; <nl> } <nl> <nl> QString StdTable : : getCellContent ( int r , int c ) <nl> { <nl> - if ( isValidIndex ( r , c ) = = true ) <nl> - return mData [ r ] [ c ] . left ( mData [ r ] [ c ] . indexOf ( ' \ 1 ' ) ) ; <nl> + if ( isValidIndex ( r , c ) ) <nl> + return mData [ r ] [ c ] . text ; <nl> else <nl> return QString ( " " ) ; <nl> } <nl> <nl> + void StdTable : : setCellUserdata ( int r , int c , duint userdata ) <nl> + { <nl> + if ( isValidIndex ( r , c ) ) <nl> + mData [ r ] [ c ] . userdata = userdata ; <nl> + } <nl> + <nl> + duint StdTable : : getCellUserdata ( int r , int c ) <nl> + { <nl> + return isValidIndex ( r , c ) ? mData [ r ] [ c ] . userdata : 0 ; <nl> + } <nl> + <nl> bool StdTable : : isValidIndex ( int r , int c ) <nl> { <nl> if ( r < 0 | | c < 0 | | r > = mData . size ( ) ) <nl> void StdTable : : headerButtonPressedSlot ( int col ) <nl> void StdTable : : reloadData ( ) <nl> { <nl> if ( mSort . first ! = - 1 ) / / re - sort if the user wants to sort <nl> - std : : stable_sort ( mData . begin ( ) , mData . end ( ) , ColumnCompare ( mSort . first , mSort . second , getColumnSortBy ( mSort . first ) ) ) ; <nl> + { <nl> + auto sortFn = getColumnSortBy ( mSort . first ) ; <nl> + std : : stable_sort ( mData . begin ( ) , mData . end ( ) , [ this , & sortFn ] ( const std : : vector < CellData > & a , const std : : vector < CellData > & b ) <nl> + { <nl> + auto less = sortFn ( a . at ( mSort . first ) . text , b . at ( mSort . first ) . text ) ; <nl> + return mSort . second ? ! less : less ; <nl> + } ) ; <nl> + } <nl> AbstractTableView : : reloadData ( ) ; <nl> } <nl> mmm a / src / gui / Src / BasicView / StdTable . h <nl> ppp b / src / gui / Src / BasicView / StdTable . h <nl> class StdTable : public AbstractTableView <nl> void deleteAllColumns ( ) ; <nl> void setCellContent ( int r , int c , QString s ) ; <nl> QString getCellContent ( int r , int c ) ; <nl> + void setCellUserdata ( int r , int c , duint userdata ) ; <nl> + duint getCellUserdata ( int r , int c ) ; <nl> bool isValidIndex ( int r , int c ) ; <nl> <nl> / / context menu helpers <nl> public slots : <nl> protected : <nl> QString copyTable ( const std : : vector < int > & colWidths ) ; <nl> <nl> + struct CellData <nl> + { <nl> + QString text ; <nl> + duint userdata = 0 ; <nl> + } ; <nl> + <nl> class ColumnCompare <nl> { <nl> public : <nl> public slots : <nl> mSortFn = fn ; <nl> } <nl> <nl> - inline bool operator ( ) ( const QList < QString > & a , const QList < QString > & b ) const <nl> + inline bool operator ( ) ( const std : : vector < CellData > & a , const std : : vector < CellData > & b ) const <nl> { <nl> - bool less = mSortFn ( a . at ( mCol ) , b . at ( mCol ) ) ; <nl> + bool less = mSortFn ( a . at ( mCol ) . text , b . at ( mCol ) . text ) ; <nl> if ( mGreater ) <nl> return ! less ; <nl> return less ; <nl> public slots : <nl> bool mCopyMenuDebugOnly ; <nl> bool mIsColumnSortingAllowed ; <nl> <nl> - QList < QList < QString > > mData ; / / listof ( row ) where row = ( listof ( col ) where col = string ) <nl> - QList < QString > mCopyTitles ; <nl> + std : : vector < std : : vector < CellData > > mData ; / / listof ( row ) where row = ( listof ( col ) where col = string ) <nl> + std : : vector < QString > mCopyTitles ; <nl> QPair < int , bool > mSort ; <nl> } ; <nl> <nl> mmm a / src / gui / Src / Gui / BreakpointsView . cpp <nl> ppp b / src / gui / Src / Gui / BreakpointsView . cpp <nl> void BreakpointsView : : reloadData ( ) <nl> { <nl> auto col = mSort . first ; <nl> auto greater = mSort . second ; <nl> - std : : stable_sort ( mData . begin ( ) , mData . end ( ) , [ this , col , greater ] ( const QList < QString > & a , const QList < QString > & b ) <nl> + std : : stable_sort ( mData . begin ( ) , mData . end ( ) , [ this , col , greater ] ( const std : : vector < CellData > & a , const std : : vector < CellData > & b ) <nl> { <nl> / / this function sorts on header type first and then on column content <nl> - auto aHeader = ! a . at ( ColAddr ) . isEmpty ( ) , bHeader = ! b . at ( ColAddr ) . isEmpty ( ) ; <nl> - auto aData = & a . at ( ColType ) , bData = & b . at ( ColType ) ; <nl> - auto aType = aData - > rightRef ( aData - > indexOf ( ' \ 1 ' ) ) . at ( 0 ) . unicode ( ) , bType = bData - > rightRef ( bData - > indexOf ( ' \ 1 ' ) ) . at ( 0 ) . unicode ( ) ; <nl> + auto aBp = & mBps . at ( a . at ( ColAddr ) . userdata ) , bBp = & mBps . at ( b . at ( ColAddr ) . userdata ) ; <nl> + auto aType = aBp - > type , bType = bBp - > type ; <nl> + auto aHeader = aBp - > addr | | aBp - > active , bHeader = bBp - > addr | | bBp - > active ; <nl> struct Hax <nl> { <nl> const bool & greater ; <nl> void BreakpointsView : : reloadData ( ) <nl> { <nl> return greater ? this - > s > b . s : this - > s < b . s ; <nl> } <nl> - } aHax ( greater , a . at ( col ) ) , bHax ( greater , b . at ( col ) ) ; <nl> + } aHax ( greater , a . at ( col ) . text ) , bHax ( greater , b . at ( col ) . text ) ; <nl> return std : : tie ( aType , aHeader , aHax ) < std : : tie ( bType , bHeader , bHax ) ; <nl> } ) ; <nl> } <nl> QString BreakpointsView : : paintContent ( QPainter * painter , dsint rowBase , int rowO <nl> painter - > fillRect ( QRect ( x , y , w , h ) , QBrush ( col = = ColDisasm ? mDisasmSelectionColor : selectionColor ) ) ; <nl> else if ( col = = ColDisasm ) <nl> painter - > fillRect ( QRect ( x , y , w , h ) , QBrush ( mDisasmBackgroundColor ) ) ; <nl> - auto & bp = mBps . at ( rowBase + rowOffset ) ; <nl> + auto & bp = mBps . at ( bpIndex ( rowBase + rowOffset ) ) ; <nl> auto cellContent = getCellContent ( rowBase + rowOffset , col ) ; <nl> if ( col > ColType & & ! bp . addr & & ! bp . active ) <nl> { <nl> void BreakpointsView : : updateBreakpointsSlot ( ) <nl> { <nl> lasttype = bp . type ; <nl> setRowCount ( getRowCount ( ) + 1 ) ; <nl> - setCellContent ( row , ColType , QString ( " % 1 \ 1 % 2 " ) . arg ( bpTypeName ( bp . type ) , QString ( QChar ( bp . type ) ) ) ) ; <nl> + setCellContent ( row , ColType , bpTypeName ( bp . type ) ) ; <nl> + setCellUserdata ( row , ColType , bp . type ) ; <nl> setCellContent ( row , ColHits , QString ( ) ) ; <nl> setCellContent ( row , ColAddr , QString ( ) ) ; <nl> + setCellUserdata ( row , ColAddr , row ) ; <nl> setCellContent ( row , ColModLabel , QString ( ) ) ; <nl> setCellContent ( row , ColState , QString ( ) ) ; <nl> setCellContent ( row , ColDisasm , QString ( ) ) ; <nl> void BreakpointsView : : updateBreakpointsSlot ( ) <nl> return result ; <nl> } ; <nl> <nl> - setCellContent ( row , ColType , QString ( " \ 1 % 1 " ) . arg ( QChar ( bp . type ) ) ) ; <nl> + setCellContent ( row , ColType , QString ( ) ) ; <nl> + setCellUserdata ( row , ColType , bp . type ) ; <nl> setCellContent ( row , ColAddr , addrText ( ) ) ; <nl> + setCellUserdata ( row , ColAddr , row ) ; <nl> setCellContent ( row , ColModLabel , modLabelText ( ) ) ; <nl> setCellContent ( row , ColState , stateName ( ) ) ; <nl> setCellContent ( row , ColDisasm , disasmText ( ) ) ; <nl> mmm a / src / gui / Src / Gui / BreakpointsView . h <nl> ppp b / src / gui / Src / Gui / BreakpointsView . h <nl> private slots : <nl> QAction * mEnableDisableAction ; <nl> QBeaEngine * mDisasm ; <nl> <nl> + const int bpIndex ( int i ) <nl> + { <nl> + return mData . at ( i ) . at ( ColAddr ) . userdata ; <nl> + } <nl> + <nl> const BRIDGEBP & selectedBp ( ) <nl> { <nl> - return mBps . at ( getInitialSelection ( ) ) ; <nl> + return mBps . at ( bpIndex ( getInitialSelection ( ) ) ) ; <nl> } <nl> <nl> bool isValidBp ( ) <nl> { <nl> - return DbgIsDebugging ( ) & & ! mBps . empty ( ) & & ( selectedBp ( ) . addr ! = 0 | | selectedBp ( ) . active ) ; <nl> + auto & bp = selectedBp ( ) ; <nl> + return DbgIsDebugging ( ) & & ! mBps . empty ( ) & & ( bp . addr ! = 0 | | bp . active ) ; <nl> } <nl> <nl> QString bpTypeName ( BPXTYPE type ) <nl>
|
GUI : refactor StdTable to allow userdata ( fixes )
|
x64dbg/x64dbg
|
4982de948c87f31b08cb0a5521f8cd157b3aacd9
|
2017-08-13T19:56:52Z
|
new file mode 100644 <nl> index 00000000000 . . dc389b600b6 <nl> mmm / dev / null <nl> ppp b / hphp / test / slow / hack_arr_compat / array_slice . php <nl> <nl> + < ? hh <nl> + <nl> + var_dump ( array_slice ( dict [ " 1 " = > 1 ] , 0 , 1 , true ) ) ; <nl> + var_dump ( array_slice ( Map { " 1 " = > 1 } , 0 , 1 , true ) ) ; <nl> new file mode 100644 <nl> index 00000000000 . . 32d1fcee044 <nl> mmm / dev / null <nl> ppp b / hphp / test / slow / hack_arr_compat / array_slice . php . expect <nl> <nl> + array ( 1 ) { <nl> + [ 1 ] = > <nl> + int ( 1 ) <nl> + } <nl> + array ( 1 ) { <nl> + [ 1 ] = > <nl> + int ( 1 ) <nl> + } <nl> new file mode 100644 <nl> index 00000000000 . . 97cf8d1d9b0 <nl> mmm / dev / null <nl> ppp b / hphp / test / slow / hack_arr_compat / array_slice . php . hphp_opts <nl> <nl> + - vRuntime . Eval . HackArrCompatNotices = 1 <nl> + - vRuntime . Eval . HackArrCompatCheckIntishCast = 1 <nl> new file mode 100644 <nl> index 00000000000 . . 62703507366 <nl> mmm / dev / null <nl> ppp b / hphp / test / slow / hack_arr_compat / array_slice . php . opts <nl> <nl> + - vEval . HackArrCompatNotices = 1 <nl> + - vEval . HackArrCompatCheckIntishCast = 1 <nl>
|
Add unit test forgotten in D9874438
|
facebook/hhvm
|
154513d77f8c784bb0d7da4b5a8756188059de1f
|
2018-09-20T18:44:08Z
|
mmm a / CHANGELOG <nl> ppp b / CHANGELOG <nl> v1 . 4 . 1 ( 2013 - 11 - 08 ) <nl> v1 . 4 . 2 ( XXXX - XX - XX ) <nl> mmmmmmmmmmmmmmmmmm - <nl> <nl> + * fixed a segfault in the AQL optimiser <nl> + <nl> * issue # 671 : Method graph . measurement does not exist <nl> <nl> * changed Windows condition variable implementation to use Windows native <nl> mmm a / arangod / Ahuacatl / ahuacatl - access - optimiser . c <nl> ppp b / arangod / Ahuacatl / ahuacatl - access - optimiser . c <nl> static TRI_vector_pointer_t * ProcessNode ( TRI_aql_context_t * const context , <nl> } <nl> } <nl> else if ( ( rhs - > _type = = TRI_AQL_NODE_REFERENCE | | rhs - > _type = = TRI_AQL_NODE_ATTRIBUTE_ACCESS | | rhs - > _type = = TRI_AQL_NODE_FCALL ) & & <nl> - ( TRI_IsConstantValueNodeAql ( lhs ) | | lhs - > _type = = TRI_AQL_NODE_REFERENCE | | lhs - > _type = = TRI_AQL_NODE_ATTRIBUTE_ACCESS | | lhs - > _type = = TRI_AQL_NODE_FCALL ) ) { <nl> + ( TRI_IsConstantValueNodeAql ( lhs ) | | lhs - > _type = = TRI_AQL_NODE_REFERENCE | | lhs - > _type = = TRI_AQL_NODE_ATTRIBUTE_ACCESS | | lhs - > _type = = TRI_AQL_NODE_FCALL ) & & <nl> + node - > _type ! = TRI_AQL_NODE_OPERATOR_BINARY_IN ) { <nl> / / const value | reference | attribute | fcall access operator collection . attribute | reference | fcall <nl> node1 = rhs ; <nl> node2 = lhs ; <nl>
|
fixed a segfault in the AQL optimiser
|
arangodb/arangodb
|
9a5a11c1462b094c42c8e2c5531e1ed31de7a10b
|
2013-11-18T13:17:16Z
|
mmm a / arangod / VocBase / headers . cpp <nl> ppp b / arangod / VocBase / headers . cpp <nl> static inline size_t GetBlockSize ( size_t blockNumber ) { <nl> <nl> TRI_headers_t : : TRI_headers_t ( ) <nl> : _freelist ( nullptr ) , <nl> - _begin ( nullptr ) , <nl> - _end ( nullptr ) , <nl> _nrAllocated ( 0 ) , <nl> _nrLinked ( 0 ) , <nl> _totalSize ( 0 ) , <nl> void TRI_headers_t : : moveBack ( TRI_doc_mptr_t * header , TRI_doc_mptr_t const * old ) <nl> return ; <nl> } <nl> <nl> - validate ( " before moveback " , header , old ) ; <nl> - <nl> TRI_ASSERT ( _nrAllocated > 0 ) ; <nl> TRI_ASSERT ( _nrLinked > 0 ) ; <nl> TRI_ASSERT ( _totalSize > 0 ) ; <nl> <nl> / / we have at least one element in the list <nl> - TRI_ASSERT ( _begin ! = nullptr ) ; <nl> - TRI_ASSERT ( _end ! = nullptr ) ; <nl> - TRI_ASSERT ( header - > _prev ! = header ) ; <nl> - TRI_ASSERT ( header - > _next ! = header ) ; <nl> - <nl> TRI_ASSERT ( old ! = nullptr ) ; <nl> TRI_ASSERT ( old - > getDataPtr ( ) ! = <nl> nullptr ) ; / / ONLY IN HEADERS , PROTECTED by RUNTIME <nl> void TRI_headers_t : : moveBack ( TRI_doc_mptr_t * header , TRI_doc_mptr_t const * old ) <nl> / / we must adjust the size of the collection <nl> _totalSize + = ( TRI_DF_ALIGN_BLOCK ( newSize ) - TRI_DF_ALIGN_BLOCK ( oldSize ) ) ; <nl> <nl> - if ( _end = = header ) { <nl> - / / header is already at the end <nl> - TRI_ASSERT ( header - > _next = = nullptr ) ; <nl> - return ; <nl> - } <nl> - <nl> - TRI_ASSERT ( _begin ! = _end ) ; <nl> - <nl> - / / unlink the element <nl> - if ( header - > _prev ! = nullptr ) { <nl> - header - > _prev - > _next = header - > _next ; <nl> - } <nl> - if ( header - > _next ! = nullptr ) { <nl> - header - > _next - > _prev = header - > _prev ; <nl> - } <nl> - <nl> - if ( _begin = = header ) { <nl> - TRI_ASSERT ( header - > _next ! = nullptr ) ; <nl> - _begin = header - > _next ; <nl> - } <nl> - <nl> - header - > _prev = _end ; <nl> - header - > _next = nullptr ; <nl> - _end = header ; <nl> - header - > _prev - > _next = header ; <nl> - <nl> - TRI_ASSERT ( _begin ! = nullptr ) ; <nl> - TRI_ASSERT ( _end ! = nullptr ) ; <nl> - TRI_ASSERT ( header - > _prev ! = header ) ; <nl> - TRI_ASSERT ( header - > _next ! = header ) ; <nl> - <nl> TRI_ASSERT ( _totalSize > 0 ) ; <nl> - <nl> - validate ( " after moveback " , header , old ) ; <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> void TRI_headers_t : : moveBack ( TRI_doc_mptr_t * header , TRI_doc_mptr_t const * old ) <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> void TRI_headers_t : : unlink ( TRI_doc_mptr_t * header ) { <nl> - validate ( " before unlink " , header , nullptr ) ; <nl> - <nl> TRI_ASSERT ( header ! = nullptr ) ; <nl> TRI_ASSERT ( header - > getDataPtr ( ) ! = <nl> nullptr ) ; / / ONLY IN HEADERS , PROTECTED by RUNTIME <nl> - TRI_ASSERT ( header - > _prev ! = header ) ; <nl> - TRI_ASSERT ( header - > _next ! = header ) ; <nl> <nl> int64_t size = ( int64_t ) ( ( TRI_df_marker_t * ) header - > getDataPtr ( ) ) <nl> - > _size ; / / ONLY IN HEADERS , PROTECTED by RUNTIME <nl> TRI_ASSERT ( size > 0 ) ; <nl> <nl> - / / unlink the header <nl> - if ( header - > _prev ! = nullptr ) { <nl> - header - > _prev - > _next = header - > _next ; <nl> - } <nl> - <nl> - if ( header - > _next ! = nullptr ) { <nl> - header - > _next - > _prev = header - > _prev ; <nl> - } <nl> - <nl> - / / adjust begin & end pointers <nl> - if ( _begin = = header ) { <nl> - _begin = header - > _next ; <nl> - } <nl> - <nl> - if ( _end = = header ) { <nl> - _end = header - > _prev ; <nl> - } <nl> - <nl> - TRI_ASSERT ( _begin ! = header ) ; <nl> - TRI_ASSERT ( _end ! = header ) ; <nl> - <nl> TRI_ASSERT ( _nrLinked > 0 ) ; <nl> _nrLinked - - ; <nl> _totalSize - = TRI_DF_ALIGN_BLOCK ( size ) ; <nl> <nl> if ( _nrLinked = = 0 ) { <nl> - TRI_ASSERT ( _begin = = nullptr ) ; <nl> - TRI_ASSERT ( _end = = nullptr ) ; <nl> TRI_ASSERT ( _totalSize = = 0 ) ; <nl> } else { <nl> - TRI_ASSERT ( _begin ! = nullptr ) ; <nl> - TRI_ASSERT ( _end ! = nullptr ) ; <nl> TRI_ASSERT ( _totalSize > 0 ) ; <nl> } <nl> - <nl> - TRI_ASSERT ( header - > _prev ! = header ) ; <nl> - TRI_ASSERT ( header - > _next ! = header ) ; <nl> - <nl> - validate ( " after unlink " , header , nullptr ) ; <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> void TRI_headers_t : : move ( TRI_doc_mptr_t * header , TRI_doc_mptr_t const * old ) { <nl> return ; <nl> } <nl> <nl> - validate ( " before move " , header , old ) ; <nl> - <nl> TRI_ASSERT ( _nrAllocated > 0 ) ; <nl> - TRI_ASSERT ( header - > _prev ! = header ) ; <nl> - TRI_ASSERT ( header - > _next ! = header ) ; <nl> TRI_ASSERT ( header - > getDataPtr ( ) ! = <nl> nullptr ) ; / / ONLY IN HEADERS , PROTECTED by RUNTIME <nl> TRI_ASSERT ( ( ( TRI_df_marker_t * ) header - > getDataPtr ( ) ) - > _size > <nl> void TRI_headers_t : : move ( TRI_doc_mptr_t * header , TRI_doc_mptr_t const * old ) { <nl> / / one is used once more . Therefore , the signs in the following statement <nl> / / are actually OK : <nl> _totalSize - = ( TRI_DF_ALIGN_BLOCK ( newSize ) - TRI_DF_ALIGN_BLOCK ( oldSize ) ) ; <nl> - <nl> - / / first unlink <nl> - if ( header - > _prev ! = nullptr ) { <nl> - header - > _prev - > _next = header - > _next ; <nl> - } <nl> - if ( header - > _next ! = nullptr ) { <nl> - header - > _next - > _prev = header - > _prev ; <nl> - } <nl> - / / adjust begin & end pointers <nl> - if ( _begin = = header ) { <nl> - _begin = header - > _next ; <nl> - } <nl> - if ( _end = = header ) { <nl> - _end = header - > _prev ; <nl> - } <nl> - <nl> - / / now header is unlinked <nl> - <nl> - header - > _prev = old - > _prev ; <nl> - header - > _next = old - > _next ; <nl> - <nl> - if ( old - > _prev ! = nullptr ) { <nl> - old - > _prev - > _next = header ; <nl> - } <nl> - if ( old - > _next ! = nullptr ) { <nl> - old - > _next - > _prev = header ; <nl> - } <nl> - <nl> - if ( old - > _prev = = nullptr ) { <nl> - _begin = header ; <nl> - } <nl> - if ( old - > _next = = nullptr ) { <nl> - _end = header ; <nl> - } <nl> - <nl> - TRI_ASSERT ( _begin ! = nullptr ) ; <nl> - TRI_ASSERT ( _end ! = nullptr ) ; <nl> - TRI_ASSERT ( header - > _prev ! = header ) ; <nl> - TRI_ASSERT ( header - > _next ! = header ) ; <nl> - <nl> - validate ( " after move " , header , old ) ; <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> void TRI_headers_t : : relink ( TRI_doc_mptr_t * header , TRI_doc_mptr_t const * old ) { <nl> return ; <nl> } <nl> <nl> - validate ( " before relink " , header , old ) ; <nl> - <nl> TRI_ASSERT ( header - > getDataPtr ( ) ! = <nl> nullptr ) ; / / ONLY IN HEADERS , PROTECTED by RUNTIME <nl> <nl> void TRI_headers_t : : relink ( TRI_doc_mptr_t * header , TRI_doc_mptr_t const * old ) { <nl> - > _size ; / / ONLY IN HEADERS , PROTECTED by RUNTIME <nl> TRI_ASSERT ( size > 0 ) ; <nl> <nl> - TRI_ASSERT ( _begin ! = header ) ; <nl> - TRI_ASSERT ( _end ! = header ) ; <nl> - <nl> this - > move ( header , old ) ; <nl> _nrLinked + + ; <nl> _totalSize + = TRI_DF_ALIGN_BLOCK ( size ) ; <nl> TRI_ASSERT ( _totalSize > 0 ) ; <nl> - <nl> - TRI_ASSERT ( header - > _prev ! = header ) ; <nl> - TRI_ASSERT ( header - > _next ! = header ) ; <nl> - <nl> - validate ( " after relink " , header , old ) ; <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> TRI_doc_mptr_t * TRI_headers_t : : request ( size_t size ) { <nl> try { <nl> begin = new TRI_doc_mptr_t [ blockSize ] ; <nl> } catch ( std : : exception & ) { <nl> - begin = nullptr ; <nl> - } <nl> - <nl> - / / out of memory <nl> - if ( begin = = nullptr ) { <nl> TRI_set_errno ( TRI_ERROR_OUT_OF_MEMORY ) ; <nl> return nullptr ; <nl> } <nl> TRI_doc_mptr_t * TRI_headers_t : : request ( size_t size ) { <nl> result - > getDataPtr ( ) ) ; / / ONLY IN HEADERS , PROTECTED by RUNTIME <nl> result - > setDataPtr ( nullptr ) ; / / ONLY IN HEADERS <nl> <nl> - / / put new header at the end of the list <nl> - if ( _begin = = nullptr ) { <nl> - / / list of headers is empty <nl> - TRI_ASSERT ( _nrLinked = = 0 ) ; <nl> - TRI_ASSERT ( _totalSize = = 0 ) ; <nl> - <nl> - _begin = result ; <nl> - _end = result ; <nl> - <nl> - result - > _prev = nullptr ; <nl> - result - > _next = nullptr ; <nl> - } else { <nl> - / / list is not empty <nl> - TRI_ASSERT ( _nrLinked > 0 ) ; <nl> - TRI_ASSERT ( _totalSize > 0 ) ; <nl> - TRI_ASSERT ( _nrAllocated > 0 ) ; <nl> - TRI_ASSERT ( _begin ! = nullptr ) ; <nl> - TRI_ASSERT ( _end ! = nullptr ) ; <nl> - <nl> - _end - > _next = result ; <nl> - result - > _prev = _end ; <nl> - result - > _next = nullptr ; <nl> - _end = result ; <nl> - } <nl> - <nl> _nrAllocated + + ; <nl> _nrLinked + + ; <nl> _totalSize + = ( int64_t ) TRI_DF_ALIGN_BLOCK ( size ) ; <nl> void TRI_headers_t : : release ( TRI_doc_mptr_t * header , bool unlinkHeader ) { <nl> return ; <nl> } <nl> <nl> - validate ( " before release " , header , nullptr ) ; <nl> - <nl> if ( unlinkHeader ) { <nl> this - > unlink ( header ) ; <nl> } <nl> void TRI_headers_t : : release ( TRI_doc_mptr_t * header , bool unlinkHeader ) { <nl> _blocks . clear ( ) ; <nl> <nl> _freelist = nullptr ; <nl> - _begin = nullptr ; <nl> - _end = nullptr ; <nl> } <nl> - <nl> - validate ( " after release " , header , nullptr ) ; <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> void TRI_headers_t : : adjustTotalSize ( int64_t oldSize , int64_t newSize ) { <nl> _totalSize - = ( TRI_DF_ALIGN_BLOCK ( oldSize ) - TRI_DF_ALIGN_BLOCK ( newSize ) ) ; <nl> } <nl> <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief validates the linked list <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - # ifdef VALIDATE_MASTER_POINTERS <nl> - void TRI_headers_t : : validate ( char const * msg , <nl> - TRI_doc_mptr_t const * header , <nl> - TRI_doc_mptr_t const * old ) { <nl> - LOG ( TRACE ) < < " validating master pointers for " < < ( void * ) this < < " , stage : " < < msg ; <nl> - LOG ( TRACE ) < < " begin : " < < ( void * ) _begin < < " , end : " < < ( void * ) _end < < " , nrLinked : " < < _nrLinked ; <nl> - <nl> - if ( header ! = nullptr ) { <nl> - LOG ( TRACE ) < < " header : " < < ( void * ) header < < " , rid : " < < header - > _rid < < " , fid : " < < header - > _fid < < " , prev : " < < ( void * ) header - > _prev < < " , next : " < < ( void * ) header - > _next < < " , data : " < < ( void * ) header - > getDataPtr ( ) < < " , key : " < < TRI_EXTRACT_MARKER_KEY ( header ) ; <nl> - } <nl> - if ( old ! = nullptr ) { <nl> - LOG ( TRACE ) < < " old : " < < ( void * ) old < < " , rid : " < < old - > _rid < < " , fid : " < < old - > _fid < < " , prev : " < < ( void * ) old - > _prev < < " , next : " < < ( void * ) old - > _next < < " , data : " < < ( void * ) old - > getDataPtr ( ) < < " , key : " < < TRI_EXTRACT_MARKER_KEY ( old ) ; <nl> - } <nl> - <nl> - auto current = _begin ; <nl> - size_t i = 0 ; <nl> - while ( current ! = nullptr ) { <nl> - LOG ( TRACE ) < < " - mptr # " < < + + i < < " , current : " < < ( void * ) current < < " , rid : " < < current - > _rid < < " , fid : " < < current - > _fid < < " , prev : " < < ( void * ) current - > _prev < < " , next : " < < ( void * ) current - > _next < < " , data : " < < ( void * ) current - > getDataPtr ( ) < < " , key : " < < TRI_EXTRACT_MARKER_KEY ( current ) ; <nl> - <nl> - if ( current - > _next = = nullptr ) { <nl> - / / last element <nl> - break ; <nl> - } <nl> - TRI_ASSERT ( current = = current - > _next - > _prev ) ; <nl> - decltype ( current ) last = current ; <nl> - current = current - > _next ; <nl> - TRI_ASSERT ( last = = current - > _prev ) ; <nl> - } <nl> - TRI_ASSERT ( current = = _end ) ; <nl> - } <nl> - # endif <nl> - <nl> mmm a / arangod / VocBase / headers . h <nl> ppp b / arangod / VocBase / headers . h <nl> class TRI_headers_t { <nl> <nl> void adjustTotalSize ( int64_t , int64_t ) ; <nl> <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief return the element at the head of the list <nl> - / / / <nl> - / / / note : the element returned might be nullptr <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - inline TRI_doc_mptr_t * front ( ) const { return _begin ; } <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief return the element at the tail of the list <nl> - / / / <nl> - / / / note : the element returned might be nullptr <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - inline TRI_doc_mptr_t * back ( ) const { return _end ; } <nl> - <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / / @ brief return the number of active headers <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> class TRI_headers_t { <nl> <nl> private : <nl> <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief validates the linked list <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - # ifdef VALIDATE_MASTER_POINTERS <nl> - void validate ( char const * , TRI_doc_mptr_t const * , TRI_doc_mptr_t const * ) ; <nl> - # else <nl> - inline void validate ( char const * , TRI_doc_mptr_t const * , TRI_doc_mptr_t const * ) { } <nl> - # endif <nl> - <nl> - private : <nl> TRI_doc_mptr_t const * _freelist ; / / free headers <nl> <nl> - TRI_doc_mptr_t * _begin ; / / start pointer to list of allocated headers <nl> - TRI_doc_mptr_t * _end ; / / end pointer to list of allocated headers <nl> size_t _nrAllocated ; / / number of allocated headers <nl> size_t _nrLinked ; / / number of linked headers <nl> int64_t _totalSize ; / / total size of markers for linked headers <nl>
|
removed references to _begin , _end
|
arangodb/arangodb
|
e9f3fffc95e5e62e10f63d4aea5d81586f790b46
|
2016-02-25T17:46:11Z
|
mmm a / lib / Sema / CSDiagnostics . cpp <nl> ppp b / lib / Sema / CSDiagnostics . cpp <nl> ASTNode FailureDiagnostic : : getAnchor ( ) const { <nl> } <nl> <nl> Type FailureDiagnostic : : getType ( ASTNode node , bool wantRValue ) const { <nl> - return resolveType ( S . getType ( node ) , / * reconstituteSugar = * / false , wantRValue ) ; <nl> + return resolveType ( getRawType ( node ) , / * reconstituteSugar = * / false , wantRValue ) ; <nl> + } <nl> + <nl> + Type FailureDiagnostic : : getRawType ( ASTNode node ) const { <nl> + return S . getType ( node ) ; <nl> } <nl> <nl> template < typename . . . ArgTypes > <nl> bool MissingMemberFailure : : diagnoseInLiteralCollectionContext ( ) const { <nl> return false ; <nl> } <nl> <nl> - if ( auto * defaultableVar = getType ( parentExpr ) - > getAs < TypeVariableType > ( ) ) { <nl> + if ( auto * defaultableVar = <nl> + getRawType ( parentExpr ) - > getAs < TypeVariableType > ( ) ) { <nl> if ( solution . DefaultedConstraints . count ( <nl> defaultableVar - > getImpl ( ) . getLocator ( ) ) ! = 0 ) { <nl> emitDiagnostic ( diag : : unresolved_member_no_inference , getName ( ) ) ; <nl> mmm a / lib / Sema / CSDiagnostics . h <nl> ppp b / lib / Sema / CSDiagnostics . h <nl> class FailureDiagnostic { <nl> <nl> Type getType ( ASTNode node , bool wantRValue = true ) const ; <nl> <nl> + / / / Get type associated with a given ASTNode without resolving it , <nl> + / / / which means that returned type would have type variables . <nl> + Type getRawType ( ASTNode node ) const ; <nl> + <nl> / / / Resolve type variables present in the raw type , if any . <nl> Type resolveType ( Type rawType , bool reconstituteSugar = false , <nl> bool wantRValue = true ) const { <nl> class FailureDiagnostic { <nl> <nl> bool isCollectionType ( Type type ) const { <nl> auto & cs = getConstraintSystem ( ) ; <nl> - return bool ( cs . isCollectionType ( type ) ) ; <nl> + return cs . isCollectionType ( type ) ; <nl> } <nl> <nl> bool isArrayType ( Type type ) const { <nl>
|
[ Diagnostics ] Add ` getRawType ` which allows to retrieve type associated with ASTNode
|
apple/swift
|
db6801b4b540699d5d865c5e9708d225d17cd78b
|
2020-05-01T19:44:34Z
|
mmm a / include / envoy / upstream / load_balancer . h <nl> ppp b / include / envoy / upstream / load_balancer . h <nl> class LoadBalancer { <nl> <nl> typedef std : : unique_ptr < LoadBalancer > LoadBalancerPtr ; <nl> <nl> + / * * <nl> + * Factory for load balancers . <nl> + * / <nl> + class LoadBalancerFactory { <nl> + public : <nl> + virtual ~ LoadBalancerFactory ( ) { } <nl> + <nl> + / * * <nl> + * @ return LoadBalancerPtr a new load balancer . <nl> + * / <nl> + virtual LoadBalancerPtr create ( ) PURE ; <nl> + } ; <nl> + <nl> + typedef std : : shared_ptr < LoadBalancerFactory > LoadBalancerFactorySharedPtr ; <nl> + <nl> + / * * <nl> + * A thread aware load balancer is a load balancer that is global to all workers on behalf of a <nl> + * cluster . These load balancers are harder to write so not every load balancer has to be one . <nl> + * If a load balancer is a thread aware load balancer , the following semantics are used : <nl> + * 1 ) A single instance is created on the main thread . <nl> + * 2 ) The shared factory is passed to all workers . <nl> + * 3 ) Every time there is a host set update on the main thread , all workers will create a new <nl> + * worker local load balancer via the factory . <nl> + * <nl> + * The above semantics mean that any global state in the factory must be protected by appropriate <nl> + * locks . Additionally , the factory * must not * refer back to the owning thread aware load <nl> + * balancer . If a cluster is removed via CDS , the thread aware load balancer can be destroyed <nl> + * before cluster destruction reaches each worker . See the ring hash load balancer for one <nl> + * example of how this pattern is used in practice . The common expected pattern is that the <nl> + * factory will be consuming shared immutable state from the main thread <nl> + * <nl> + * TODO ( mattklein123 ) : The reason that locking is used in the above threading model vs . pure TLS <nl> + * has to do with the lack of a TLS function that does the following : <nl> + * 1 ) Create a per - worker data structure on the main thread . E . g . , allocate 4 objects for 4 <nl> + * workers . <nl> + * 2 ) Then fan those objects out to each worker . <nl> + * With the existence of a function like that , the callback locking from the worker to the main <nl> + * thread could be removed . We can look at this in a follow up . The reality though is that the <nl> + * locking is currently only used to protect some small bits of data on host set update and will <nl> + * never be contended . <nl> + * / <nl> + class ThreadAwareLoadBalancer { <nl> + public : <nl> + virtual ~ ThreadAwareLoadBalancer ( ) { } <nl> + <nl> + / * * <nl> + * @ return LoadBalancerFactorySharedPtr the shared factory to use for creating new worker local <nl> + * load balancers . <nl> + * / <nl> + virtual LoadBalancerFactorySharedPtr factory ( ) PURE ; <nl> + <nl> + / * * <nl> + * When a thread aware load balancer is constructed , it should return nullptr for any created <nl> + * load balancer chooseHost ( ) calls . Once initialize is called , the load balancer should <nl> + * instantiate any needed structured and prepare for further updates . The cluster manager <nl> + * will do this at the appropriate time . <nl> + * / <nl> + virtual void initialize ( ) PURE ; <nl> + } ; <nl> + <nl> + typedef std : : unique_ptr < ThreadAwareLoadBalancer > ThreadAwareLoadBalancerPtr ; <nl> + <nl> } / / namespace Upstream <nl> } / / namespace Envoy <nl> mmm a / source / common / upstream / cluster_manager_impl . cc <nl> ppp b / source / common / upstream / cluster_manager_impl . cc <nl> namespace Upstream { <nl> <nl> void ClusterManagerInitHelper : : addCluster ( Cluster & cluster ) { <nl> if ( state_ = = State : : AllClustersInitialized ) { <nl> - cluster . initialize ( [ ] { } ) ; <nl> + cluster . initialize ( [ this , & cluster ] { per_cluster_init_callback_ ( cluster ) ; } ) ; <nl> return ; <nl> } <nl> <nl> - const auto initialize_cb = [ & cluster , this ] { <nl> - ASSERT ( state_ ! = State : : AllClustersInitialized ) ; <nl> - removeCluster ( cluster ) ; <nl> - } ; <nl> - <nl> + const auto initialize_cb = [ & cluster , this ] { onClusterInit ( cluster ) ; } ; <nl> if ( cluster . initializePhase ( ) = = Cluster : : InitializePhase : : Primary ) { <nl> primary_init_clusters_ . push_back ( & cluster ) ; <nl> cluster . initialize ( initialize_cb ) ; <nl> void ClusterManagerInitHelper : : addCluster ( Cluster & cluster ) { <nl> primary_init_clusters_ . size ( ) , secondary_init_clusters_ . size ( ) ) ; <nl> } <nl> <nl> + void ClusterManagerInitHelper : : onClusterInit ( Cluster & cluster ) { <nl> + ASSERT ( state_ ! = State : : AllClustersInitialized ) ; <nl> + per_cluster_init_callback_ ( cluster ) ; <nl> + removeCluster ( cluster ) ; <nl> + } <nl> + <nl> void ClusterManagerInitHelper : : removeCluster ( Cluster & cluster ) { <nl> if ( state_ = = State : : AllClustersInitialized ) { <nl> return ; <nl> void ClusterManagerInitHelper : : maybeFinishInitialize ( ) { <nl> for ( auto iter = secondary_init_clusters_ . begin ( ) ; iter ! = secondary_init_clusters_ . end ( ) ; ) { <nl> Cluster * cluster = * iter ; <nl> + + iter ; <nl> - cluster - > initialize ( [ cluster , this ] { <nl> - ASSERT ( state_ ! = State : : AllClustersInitialized ) ; <nl> - removeCluster ( * cluster ) ; <nl> - } ) ; <nl> + cluster - > initialize ( [ cluster , this ] { onClusterInit ( * cluster ) ; } ) ; <nl> } <nl> } <nl> <nl> ClusterManagerImpl : : ClusterManagerImpl ( const envoy : : api : : v2 : : Bootstrap & bootstra <nl> AccessLog : : AccessLogManager & log_manager , <nl> Event : : Dispatcher & primary_dispatcher ) <nl> : factory_ ( factory ) , runtime_ ( runtime ) , stats_ ( stats ) , tls_ ( tls . allocateSlot ( ) ) , <nl> - random_ ( random ) , local_info_ ( local_info ) , cm_stats_ ( generateStats ( stats ) ) { <nl> + random_ ( random ) , local_info_ ( local_info ) , cm_stats_ ( generateStats ( stats ) ) , <nl> + init_helper_ ( [ this ] ( Cluster & cluster ) { onClusterInit ( cluster ) ; } ) { <nl> const auto & ads_config = bootstrap . dynamic_resources ( ) . ads_config ( ) ; <nl> if ( ads_config . cluster_name ( ) . empty ( ) ) { <nl> ENVOY_LOG ( debug , " No ADS clusters defined , ADS will not be initialized . " ) ; <nl> ClusterManagerImpl : : ClusterManagerImpl ( const envoy : : api : : v2 : : Bootstrap & bootstra <nl> } <nl> } <nl> <nl> + / / Once the initial set of static bootstrap clusters are created ( including the local cluster ) , <nl> + / / we can instantiate the thread local cluster manager . <nl> tls_ - > set ( [ this , local_cluster_name ] ( <nl> Event : : Dispatcher & dispatcher ) - > ThreadLocal : : ThreadLocalObjectSharedPtr { <nl> - return ThreadLocal : : ThreadLocalObjectSharedPtr { <nl> - new ThreadLocalClusterManagerImpl ( * this , dispatcher , local_cluster_name ) } ; <nl> + return std : : make_shared < ThreadLocalClusterManagerImpl > ( * this , dispatcher , local_cluster_name ) ; <nl> } ) ; <nl> <nl> - init_helper_ . onStaticLoadComplete ( ) ; <nl> - <nl> - / / To avoid threading issues , for those clusters that start with hosts already in them ( like the <nl> - / / static cluster ) , we need to post an update onto each thread to notify them of the update . We <nl> - / / also require this for dynamic clusters where an immediate resolve occurred in the cluster <nl> - / / constructor , prior to the member update callback being configured . <nl> + / / Proceed to add all static bootstrap clusters to the init manager . This will immediately <nl> + / / initialize any primary clusters . Post - init processing further initializes any thread <nl> + / / aware load balancer and sets up the per - worker host set updates . <nl> for ( auto & cluster : primary_clusters_ ) { <nl> - postInitializeCluster ( * cluster . second . cluster_ ) ; <nl> + init_helper_ . addCluster ( * cluster . second . cluster_ ) ; <nl> } <nl> <nl> + / / Potentially move to secondary initialization on the static bootstrap clusters if all primary <nl> + / / clusters have already initialized . ( E . g . , if all static ) . <nl> + init_helper_ . onStaticLoadComplete ( ) ; <nl> + <nl> ads_mux_ - > start ( ) ; <nl> <nl> if ( cm_config . has_load_stats_config ( ) ) { <nl> ClusterManagerStats ClusterManagerImpl : : generateStats ( Stats : : Scope & scope ) { <nl> POOL_GAUGE_PREFIX ( scope , final_prefix ) ) } ; <nl> } <nl> <nl> - void ClusterManagerImpl : : postInitializeCluster ( Cluster & cluster ) { <nl> + void ClusterManagerImpl : : onClusterInit ( Cluster & cluster ) { <nl> + / / This routine is called when a cluster has finished initializing . The cluster has not yet <nl> + / / been setup for cross - thread updates to avoid needless updates during initialization . The order <nl> + / / of operations here is important . We start by initializing the thread aware load balancer if <nl> + / / needed . This must happen first so cluster updates are heard first by the load balancer . <nl> + auto primary_cluster_data = primary_clusters_ . find ( cluster . info ( ) - > name ( ) ) ; <nl> + if ( primary_cluster_data - > second . thread_aware_lb_ ! = nullptr ) { <nl> + primary_cluster_data - > second . thread_aware_lb_ - > initialize ( ) ; <nl> + } <nl> + <nl> + / / Now setup for cross - thread updates . <nl> + cluster . prioritySet ( ) . addMemberUpdateCb ( <nl> + [ & cluster , this ] ( uint32_t priority , const std : : vector < HostSharedPtr > & hosts_added , <nl> + const std : : vector < HostSharedPtr > & hosts_removed ) { <nl> + / / This fires when a cluster is about to have an updated member set . We need to send this <nl> + / / out to all of the thread local configurations . <nl> + postThreadLocalClusterUpdate ( cluster , priority , hosts_added , hosts_removed ) ; <nl> + } ) ; <nl> + <nl> + / / Finally , if the cluster has any hosts , post updates cross - thread so the per - thread load <nl> + / / balancers are ready . <nl> for ( auto & host_set : cluster . prioritySet ( ) . hostSetsPerPriority ( ) ) { <nl> if ( host_set - > hosts ( ) . empty ( ) ) { <nl> continue ; <nl> bool ClusterManagerImpl : : addOrUpdatePrimaryCluster ( const envoy : : api : : v2 : : Cluster <nl> } <nl> <nl> loadCluster ( cluster , true ) ; <nl> - ClusterInfoConstSharedPtr new_cluster = primary_clusters_ . at ( cluster_name ) . cluster_ - > info ( ) ; <nl> + auto & primary_cluster_entry = primary_clusters_ . at ( cluster_name ) ; <nl> ENVOY_LOG ( info , " add / update cluster { } " , cluster_name ) ; <nl> - tls_ - > runOnAllThreads ( [ this , new_cluster ] ( ) - > void { <nl> - ThreadLocalClusterManagerImpl & cluster_manager = <nl> - tls_ - > getTyped < ThreadLocalClusterManagerImpl > ( ) ; <nl> - <nl> - if ( cluster_manager . thread_local_clusters_ . count ( new_cluster - > name ( ) ) > 0 ) { <nl> - ENVOY_LOG ( debug , " updating TLS cluster { } " , new_cluster - > name ( ) ) ; <nl> - } else { <nl> - ENVOY_LOG ( debug , " adding TLS cluster { } " , new_cluster - > name ( ) ) ; <nl> - } <nl> - <nl> - cluster_manager . thread_local_clusters_ [ new_cluster - > name ( ) ] . reset ( <nl> - new ThreadLocalClusterManagerImpl : : ClusterEntry ( cluster_manager , new_cluster ) ) ; <nl> - } ) ; <nl> - <nl> - postInitializeCluster ( * primary_clusters_ . at ( cluster_name ) . cluster_ ) ; <nl> + tls_ - > runOnAllThreads ( <nl> + [ <nl> + this , new_cluster = primary_cluster_entry . cluster_ - > info ( ) , <nl> + thread_aware_lb_factory = primary_cluster_entry . loadBalancerFactory ( ) <nl> + ] ( ) <nl> + - > void { <nl> + ThreadLocalClusterManagerImpl & cluster_manager = <nl> + tls_ - > getTyped < ThreadLocalClusterManagerImpl > ( ) ; <nl> + <nl> + if ( cluster_manager . thread_local_clusters_ . count ( new_cluster - > name ( ) ) > 0 ) { <nl> + ENVOY_LOG ( debug , " updating TLS cluster { } " , new_cluster - > name ( ) ) ; <nl> + } else { <nl> + ENVOY_LOG ( debug , " adding TLS cluster { } " , new_cluster - > name ( ) ) ; <nl> + } <nl> + <nl> + cluster_manager . thread_local_clusters_ [ new_cluster - > name ( ) ] . reset ( <nl> + new ThreadLocalClusterManagerImpl : : ClusterEntry ( cluster_manager , new_cluster , <nl> + thread_aware_lb_factory ) ) ; <nl> + } ) ; <nl> + <nl> + init_helper_ . addCluster ( * primary_cluster_entry . cluster_ ) ; <nl> return true ; <nl> } <nl> <nl> void ClusterManagerImpl : : loadCluster ( const envoy : : api : : v2 : : Cluster & cluster , boo <nl> ClusterSharedPtr new_cluster = <nl> factory_ . clusterFromProto ( cluster , * this , outlier_event_logger_ , added_via_api ) ; <nl> <nl> - init_helper_ . addCluster ( * new_cluster ) ; <nl> if ( ! added_via_api ) { <nl> if ( primary_clusters_ . find ( new_cluster - > info ( ) - > name ( ) ) ! = primary_clusters_ . end ( ) ) { <nl> throw EnvoyException ( <nl> void ClusterManagerImpl : : loadCluster ( const envoy : : api : : v2 : : Cluster & cluster , boo <nl> } <nl> } <nl> <nl> - const Cluster & primary_cluster_reference = * new_cluster ; <nl> - new_cluster - > prioritySet ( ) . addMemberUpdateCb ( <nl> - [ & primary_cluster_reference , this ] ( uint32_t priority , <nl> - const std : : vector < HostSharedPtr > & hosts_added , <nl> - const std : : vector < HostSharedPtr > & hosts_removed ) { <nl> - / / This fires when a cluster is about to have an updated member set . We need to send this <nl> - / / out to all of the thread local configurations . <nl> - postThreadLocalClusterUpdate ( primary_cluster_reference , priority , hosts_added , <nl> - hosts_removed ) ; <nl> - } ) ; <nl> - <nl> + Cluster & primary_cluster_reference = * new_cluster ; <nl> if ( new_cluster - > healthChecker ( ) ! = nullptr ) { <nl> new_cluster - > healthChecker ( ) - > addHostCheckCompleteCb ( <nl> [ this ] ( HostSharedPtr host , bool changed_state ) { <nl> void ClusterManagerImpl : : loadCluster ( const envoy : : api : : v2 : : Cluster & cluster , boo <nl> <nl> / / emplace ( ) will do nothing if the key already exists . Always erase first . <nl> size_t num_erased = primary_clusters_ . erase ( primary_cluster_reference . info ( ) - > name ( ) ) ; <nl> - primary_clusters_ . emplace ( <nl> - primary_cluster_reference . info ( ) - > name ( ) , <nl> - PrimaryClusterData { MessageUtil : : hash ( cluster ) , added_via_api , std : : move ( new_cluster ) } ) ; <nl> + auto cluster_entry_it = primary_clusters_ <nl> + . emplace ( primary_cluster_reference . info ( ) - > name ( ) , <nl> + PrimaryClusterData { MessageUtil : : hash ( cluster ) , added_via_api , <nl> + std : : move ( new_cluster ) } ) <nl> + . first ; <nl> + <nl> + / / If an LB is thread aware , create it here . The LB is not initialized until cluster pre - init <nl> + / / finishes . <nl> + if ( primary_cluster_reference . info ( ) - > lbType ( ) = = LoadBalancerType : : RingHash ) { <nl> + cluster_entry_it - > second . thread_aware_lb_ = std : : make_unique < RingHashLoadBalancer > ( <nl> + primary_cluster_reference . prioritySet ( ) , primary_cluster_reference . info ( ) - > stats ( ) , <nl> + runtime_ , random_ , primary_cluster_reference . info ( ) - > lbRingHashConfig ( ) ) ; <nl> + } <nl> <nl> cm_stats_ . total_clusters_ . set ( primary_clusters_ . size ( ) ) ; <nl> if ( num_erased ) { <nl> void ClusterManagerImpl : : postThreadLocalClusterUpdate ( <nl> const Cluster & primary_cluster , uint32_t priority , <nl> const std : : vector < HostSharedPtr > & hosts_added , <nl> const std : : vector < HostSharedPtr > & hosts_removed ) { <nl> - if ( init_helper_ . state ( ) = = ClusterManagerInitHelper : : State : : Loading ) { <nl> - / / A cluster may try to post updates before we are ready for multi - threading . Block this case <nl> - / / since we will post the update in postInitializeCluster ( ) . <nl> - return ; <nl> - } <nl> - <nl> const auto & host_set = primary_cluster . prioritySet ( ) . hostSetsPerPriority ( ) [ priority ] ; <nl> <nl> HostVectorConstSharedPtr hosts_copy ( new std : : vector < HostSharedPtr > ( host_set - > hosts ( ) ) ) ; <nl> ClusterManagerImpl : : ThreadLocalClusterManagerImpl : : ThreadLocalClusterManagerImpl <nl> / / If local cluster is defined then we need to initialize it first . <nl> if ( local_cluster_name . valid ( ) ) { <nl> ENVOY_LOG ( debug , " adding TLS local cluster { } " , local_cluster_name . value ( ) ) ; <nl> - auto & local_cluster = parent . primary_clusters_ . at ( local_cluster_name . value ( ) ) . cluster_ ; <nl> - thread_local_clusters_ [ local_cluster_name . value ( ) ] . reset ( <nl> - new ClusterEntry ( * this , local_cluster - > info ( ) ) ) ; <nl> + auto & local_cluster = parent . primary_clusters_ . at ( local_cluster_name . value ( ) ) ; <nl> + thread_local_clusters_ [ local_cluster_name . value ( ) ] . reset ( new ClusterEntry ( <nl> + * this , local_cluster . cluster_ - > info ( ) , local_cluster . loadBalancerFactory ( ) ) ) ; <nl> } <nl> <nl> local_priority_set_ = local_cluster_name . valid ( ) <nl> ClusterManagerImpl : : ThreadLocalClusterManagerImpl : : ThreadLocalClusterManagerImpl <nl> <nl> ENVOY_LOG ( debug , " adding TLS initial cluster { } " , cluster . first ) ; <nl> ASSERT ( thread_local_clusters_ . count ( cluster . first ) = = 0 ) ; <nl> - thread_local_clusters_ [ cluster . first ] . reset ( <nl> - new ClusterEntry ( * this , cluster . second . cluster_ - > info ( ) ) ) ; <nl> + thread_local_clusters_ [ cluster . first ] . reset ( new ClusterEntry ( <nl> + * this , cluster . second . cluster_ - > info ( ) , cluster . second . loadBalancerFactory ( ) ) ) ; <nl> } <nl> } <nl> <nl> void ClusterManagerImpl : : ThreadLocalClusterManagerImpl : : updateClusterMembership ( <nl> ThreadLocalClusterManagerImpl & config = tls . getTyped < ThreadLocalClusterManagerImpl > ( ) ; <nl> <nl> ASSERT ( config . thread_local_clusters_ . find ( name ) ! = config . thread_local_clusters_ . end ( ) ) ; <nl> - config . thread_local_clusters_ [ name ] - > priority_set_ . getOrCreateHostSet ( priority ) . updateHosts ( <nl> + const auto & cluster_entry = config . thread_local_clusters_ [ name ] ; <nl> + ENVOY_LOG ( debug , " membership update for TLS cluster { } " , name ) ; <nl> + cluster_entry - > priority_set_ . getOrCreateHostSet ( priority ) . updateHosts ( <nl> std : : move ( hosts ) , std : : move ( healthy_hosts ) , std : : move ( hosts_per_locality ) , <nl> std : : move ( healthy_hosts_per_locality ) , hosts_added , hosts_removed ) ; <nl> + <nl> + / / If an LB is thread aware , create a new worker local LB on membership changes . <nl> + if ( cluster_entry - > lb_factory_ ! = nullptr ) { <nl> + ENVOY_LOG ( debug , " re - creating local LB for TLS cluster { } " , name ) ; <nl> + cluster_entry - > lb_ = cluster_entry - > lb_factory_ - > create ( ) ; <nl> + } <nl> } <nl> <nl> void ClusterManagerImpl : : ThreadLocalClusterManagerImpl : : onHostHealthFailure ( <nl> void ClusterManagerImpl : : ThreadLocalClusterManagerImpl : : onHostHealthFailure ( <nl> } <nl> <nl> ClusterManagerImpl : : ThreadLocalClusterManagerImpl : : ClusterEntry : : ClusterEntry ( <nl> - ThreadLocalClusterManagerImpl & parent , ClusterInfoConstSharedPtr cluster ) <nl> - : parent_ ( parent ) , cluster_info_ ( cluster ) , <nl> + ThreadLocalClusterManagerImpl & parent , ClusterInfoConstSharedPtr cluster , <nl> + const LoadBalancerFactorySharedPtr & lb_factory ) <nl> + : parent_ ( parent ) , lb_factory_ ( lb_factory ) , cluster_info_ ( cluster ) , <nl> http_async_client_ ( * cluster , parent . parent_ . stats_ , parent . thread_local_dispatcher_ , <nl> parent . parent_ . local_info_ , parent . parent_ , parent . parent_ . runtime_ , <nl> parent . parent_ . random_ , <nl> Router : : ShadowWriterPtr { new Router : : ShadowWriterImpl ( parent . parent_ ) } ) { <nl> priority_set_ . getOrCreateHostSet ( 0 ) ; <nl> <nl> + / / TODO ( mattklein123 ) : Consider converting other LBs over to thread local . All of them could <nl> + / / benefit given the healthy panic , locality , and priority calculations that take place . <nl> if ( cluster - > lbSubsetInfo ( ) . isEnabled ( ) ) { <nl> + ASSERT ( lb_factory_ = = nullptr ) ; <nl> lb_ . reset ( new SubsetLoadBalancer ( cluster - > lbType ( ) , priority_set_ , parent_ . local_priority_set_ , <nl> cluster - > stats ( ) , parent . parent_ . runtime_ , <nl> parent . parent_ . random_ , cluster - > lbSubsetInfo ( ) , <nl> ClusterManagerImpl : : ThreadLocalClusterManagerImpl : : ClusterEntry : : ClusterEntry ( <nl> } else { <nl> switch ( cluster - > lbType ( ) ) { <nl> case LoadBalancerType : : LeastRequest : { <nl> + ASSERT ( lb_factory_ = = nullptr ) ; <nl> lb_ . reset ( new LeastRequestLoadBalancer ( priority_set_ , parent_ . local_priority_set_ , <nl> cluster - > stats ( ) , parent . parent_ . runtime_ , <nl> parent . parent_ . random_ ) ) ; <nl> break ; <nl> } <nl> case LoadBalancerType : : Random : { <nl> + ASSERT ( lb_factory_ = = nullptr ) ; <nl> lb_ . reset ( new RandomLoadBalancer ( priority_set_ , parent_ . local_priority_set_ , cluster - > stats ( ) , <nl> parent . parent_ . runtime_ , parent . parent_ . random_ ) ) ; <nl> break ; <nl> } <nl> case LoadBalancerType : : RoundRobin : { <nl> + ASSERT ( lb_factory_ = = nullptr ) ; <nl> lb_ . reset ( new RoundRobinLoadBalancer ( priority_set_ , parent_ . local_priority_set_ , <nl> cluster - > stats ( ) , parent . parent_ . runtime_ , <nl> parent . parent_ . random_ ) ) ; <nl> break ; <nl> } <nl> case LoadBalancerType : : RingHash : { <nl> - lb_ . reset ( new RingHashLoadBalancer ( priority_set_ , cluster - > stats ( ) , parent . parent_ . runtime_ , <nl> - parent . parent_ . random_ , cluster - > lbRingHashConfig ( ) ) ) ; <nl> + ASSERT ( lb_factory_ ! = nullptr ) ; <nl> + lb_ = lb_factory_ - > create ( ) ; <nl> break ; <nl> } <nl> case LoadBalancerType : : OriginalDst : { <nl> + ASSERT ( lb_factory_ = = nullptr ) ; <nl> lb_ . reset ( new OriginalDstCluster : : LoadBalancer ( <nl> priority_set_ , parent . parent_ . primary_clusters_ . at ( cluster - > name ( ) ) . cluster_ ) ) ; <nl> break ; <nl> mmm a / source / common / upstream / cluster_manager_impl . h <nl> ppp b / source / common / upstream / cluster_manager_impl . h <nl> class ProdClusterManagerFactory : public ClusterManagerFactory { <nl> * / <nl> class ClusterManagerInitHelper : Logger : : Loggable < Logger : : Id : : upstream > { <nl> public : <nl> + / * * <nl> + * @ param per_cluster_init_callback supplies the callback to call when a cluster has itself <nl> + * initialized . The cluster manager can use this for post - init processing . <nl> + * / <nl> + ClusterManagerInitHelper ( const std : : function < void ( Cluster & ) > & per_cluster_init_callback ) <nl> + : per_cluster_init_callback_ ( per_cluster_init_callback ) { } <nl> + <nl> enum class State { <nl> / / Initial state . During this state all static clusters are loaded . Any phase 1 clusters <nl> / / are immediately initialized . <nl> class ClusterManagerInitHelper : Logger : : Loggable < Logger : : Id : : upstream > { <nl> <nl> private : <nl> void maybeFinishInitialize ( ) ; <nl> + void onClusterInit ( Cluster & cluster ) ; <nl> <nl> + std : : function < void ( Cluster & cluster ) > per_cluster_init_callback_ ; <nl> CdsApi * cds_ { } ; <nl> std : : function < void ( ) > initialized_callback_ ; <nl> std : : list < Cluster * > primary_init_clusters_ ; <nl> class ClusterManagerImpl : public ClusterManager , Logger : : Loggable < Logger : : Id : : u <nl> } ; <nl> <nl> struct ClusterEntry : public ThreadLocalCluster { <nl> - ClusterEntry ( ThreadLocalClusterManagerImpl & parent , ClusterInfoConstSharedPtr cluster ) ; <nl> + ClusterEntry ( ThreadLocalClusterManagerImpl & parent , ClusterInfoConstSharedPtr cluster , <nl> + const LoadBalancerFactorySharedPtr & lb_factory ) ; <nl> ~ ClusterEntry ( ) ; <nl> <nl> Http : : ConnectionPool : : Instance * connPool ( ResourcePriority priority , <nl> class ClusterManagerImpl : public ClusterManager , Logger : : Loggable < Logger : : Id : : u <nl> <nl> ThreadLocalClusterManagerImpl & parent_ ; <nl> PrioritySetImpl priority_set_ ; <nl> + / / LB factory if applicable . Not all load balancer types have a factory . LB types that have <nl> + / / a factory will create a new LB on every membership update . LB types that don ' t have a <nl> + / / factory will create an LB on construction and use it forever . <nl> + LoadBalancerFactorySharedPtr lb_factory_ ; <nl> + / / Current active LB . <nl> LoadBalancerPtr lb_ ; <nl> ClusterInfoConstSharedPtr cluster_info_ ; <nl> Http : : AsyncClientImpl http_async_client_ ; <nl> class ClusterManagerImpl : public ClusterManager , Logger : : Loggable < Logger : : Id : : u <nl> PrimaryClusterData ( uint64_t config_hash , bool added_via_api , ClusterSharedPtr & & cluster ) <nl> : config_hash_ ( config_hash ) , added_via_api_ ( added_via_api ) , cluster_ ( std : : move ( cluster ) ) { } <nl> <nl> + LoadBalancerFactorySharedPtr loadBalancerFactory ( ) { <nl> + if ( thread_aware_lb_ ! = nullptr ) { <nl> + return thread_aware_lb_ - > factory ( ) ; <nl> + } else { <nl> + return nullptr ; <nl> + } <nl> + } <nl> + <nl> const uint64_t config_hash_ ; <nl> const bool added_via_api_ ; <nl> ClusterSharedPtr cluster_ ; <nl> + / / Optional thread aware LB depending on the LB type . Not all clusters have one . <nl> + ThreadAwareLoadBalancerPtr thread_aware_lb_ ; <nl> } ; <nl> <nl> static ClusterManagerStats generateStats ( Stats : : Scope & scope ) ; <nl> void loadCluster ( const envoy : : api : : v2 : : Cluster & cluster , bool added_via_api ) ; <nl> - void postInitializeCluster ( Cluster & cluster ) ; <nl> + void onClusterInit ( Cluster & cluster ) ; <nl> void postThreadLocalClusterUpdate ( const Cluster & cluster , uint32_t priority , <nl> const std : : vector < HostSharedPtr > & hosts_added , <nl> const std : : vector < HostSharedPtr > & hosts_removed ) ; <nl> mmm a / source / common / upstream / ring_hash_lb . cc <nl> ppp b / source / common / upstream / ring_hash_lb . cc <nl> RingHashLoadBalancer : : RingHashLoadBalancer ( <nl> PrioritySet & priority_set , ClusterStats & stats , Runtime : : Loader & runtime , <nl> Runtime : : RandomGenerator & random , <nl> const Optional < envoy : : api : : v2 : : Cluster : : RingHashLbConfig > & config ) <nl> - : LoadBalancerBase ( priority_set , stats , runtime , random ) , config_ ( config ) { <nl> - priority_set . addMemberUpdateCb ( <nl> - [ this ] ( uint32_t priority , const std : : vector < HostSharedPtr > & , <nl> - const std : : vector < HostSharedPtr > & ) - > void { refresh ( priority ) ; } ) ; <nl> + : LoadBalancerBase ( priority_set , stats , runtime , random ) , config_ ( config ) , <nl> + factory_ ( new LoadBalancerFactoryImpl ( stats , random ) ) { <nl> + / / Make sure we correctly return nullptr for any early chooseHost ( ) calls . <nl> + factory_ - > current_ring_ = std : : make_shared < Ring > ( config_ , std : : vector < HostSharedPtr > { } ) ; <nl> + } <nl> <nl> - for ( auto & host_set : priority_set_ . hostSetsPerPriority ( ) ) { <nl> - refresh ( host_set - > priority ( ) ) ; <nl> - } <nl> + void RingHashLoadBalancer : : initialize ( ) { <nl> + / / TODO ( mattklein123 ) : In the future , once initialized and the initial ring is built , it would be <nl> + / / better to use a background thread for computing ring updates . This has the substantial benefit <nl> + / / that if the ring computation thread falls behind , host set updates can be trivially collapsed . <nl> + / / I will look into doing this in a follow up . Doing everything using a background thread heavily <nl> + / / complicated initialization as the load balancer would need its own initialized callback . I <nl> + / / think the synchronous / asynchronous split is probably the best option . <nl> + priority_set_ . addMemberUpdateCb ( [ this ] ( uint32_t , const std : : vector < HostSharedPtr > & , <nl> + const std : : vector < HostSharedPtr > & ) - > void { refresh ( ) ; } ) ; <nl> + <nl> + refresh ( ) ; <nl> } <nl> <nl> - HostConstSharedPtr RingHashLoadBalancer : : chooseHost ( LoadBalancerContext * context ) { <nl> - const HostSet & host_set = chooseHostSet ( ) ; <nl> - if ( isGlobalPanic ( host_set , runtime_ ) ) { <nl> + HostConstSharedPtr <nl> + RingHashLoadBalancer : : LoadBalancerImpl : : chooseHost ( LoadBalancerContext * context ) { <nl> + if ( global_panic_ ) { <nl> stats_ . lb_healthy_panic_ . inc ( ) ; <nl> - return per_priority_state_ [ host_set . priority ( ) ] - > all_hosts_ring_ . chooseHost ( context , random_ ) ; <nl> - } else { <nl> - return per_priority_state_ [ host_set . priority ( ) ] - > healthy_hosts_ring_ . chooseHost ( context , <nl> - random_ ) ; <nl> } <nl> + return ring_ - > chooseHost ( context , random_ ) ; <nl> + } <nl> + <nl> + LoadBalancerPtr RingHashLoadBalancer : : LoadBalancerFactoryImpl : : create ( ) { <nl> + / / We must protect current_ring_ via a RW lock since it is accessed and written to by multiple <nl> + / / threads . All complex processing happens outside of locking however . <nl> + RingConstSharedPtr ring_to_use ; <nl> + bool global_panic_to_use ; <nl> + { <nl> + std : : shared_lock < std : : shared_timed_mutex > lock ( mutex_ ) ; <nl> + ring_to_use = current_ring_ ; <nl> + global_panic_to_use = global_panic_ ; <nl> + } <nl> + <nl> + return std : : make_unique < LoadBalancerImpl > ( stats_ , random_ , ring_to_use , global_panic_to_use ) ; <nl> } <nl> <nl> HostConstSharedPtr RingHashLoadBalancer : : Ring : : chooseHost ( LoadBalancerContext * context , <nl> - Runtime : : RandomGenerator & random ) { <nl> + Runtime : : RandomGenerator & random ) const { <nl> if ( ring_ . empty ( ) ) { <nl> return nullptr ; <nl> } <nl> HostConstSharedPtr RingHashLoadBalancer : : Ring : : chooseHost ( LoadBalancerContext * c <nl> } <nl> } <nl> <nl> - void RingHashLoadBalancer : : Ring : : create ( <nl> - const Optional < envoy : : api : : v2 : : Cluster : : RingHashLbConfig > & config , <nl> - const std : : vector < HostSharedPtr > & hosts ) { <nl> + RingHashLoadBalancer : : Ring : : Ring ( const Optional < envoy : : api : : v2 : : Cluster : : RingHashLbConfig > & config , <nl> + const std : : vector < HostSharedPtr > & hosts ) { <nl> ENVOY_LOG ( trace , " ring hash : building ring " ) ; <nl> - ring_ . clear ( ) ; <nl> if ( hosts . empty ( ) ) { <nl> return ; <nl> } <nl> void RingHashLoadBalancer : : Ring : : create ( <nl> # endif <nl> } <nl> <nl> - void RingHashLoadBalancer : : refresh ( uint32_t priority ) { <nl> - while ( per_priority_state_ . size ( ) < priority + 1 ) { <nl> - per_priority_state_ . push_back ( PerPriorityStatePtr { new PerPriorityState } ) ; <nl> + void RingHashLoadBalancer : : refresh ( ) { <nl> + / / Note that we only compute global panic on host set refresh . Given that the runtime setting will <nl> + / / rarely change , this is a reasonable compromise to avoid creating multiple rings when we only <nl> + / / need to create one for LB . <nl> + RingConstSharedPtr new_ring ; <nl> + bool new_global_panic ; <nl> + const auto & host_set = chooseHostSet ( ) ; <nl> + if ( isGlobalPanic ( host_set , runtime_ ) ) { <nl> + new_ring = std : : make_shared < Ring > ( config_ , host_set . hosts ( ) ) ; <nl> + new_global_panic = true ; <nl> + } else { <nl> + new_ring = std : : make_shared < Ring > ( config_ , host_set . healthyHosts ( ) ) ; <nl> + new_global_panic = false ; <nl> } <nl> - auto & host_set = priority_set_ . hostSetsPerPriority ( ) [ priority ] ; <nl> - per_priority_state_ [ priority ] - > all_hosts_ring_ . create ( config_ , host_set - > hosts ( ) ) ; <nl> - per_priority_state_ [ priority ] - > healthy_hosts_ring_ . create ( config_ , host_set - > healthyHosts ( ) ) ; <nl> + <nl> + std : : unique_lock < std : : shared_timed_mutex > lock ( factory_ - > mutex_ ) ; <nl> + factory_ - > current_ring_ = new_ring ; <nl> + factory_ - > global_panic_ = new_global_panic ; <nl> } <nl> <nl> } / / namespace Upstream <nl> mmm a / source / common / upstream / ring_hash_lb . h <nl> ppp b / source / common / upstream / ring_hash_lb . h <nl> <nl> # pragma once <nl> <nl> # include < cstdint > <nl> + # include < shared_mutex > <nl> # include < vector > <nl> <nl> # include " envoy / runtime / runtime . h " <nl> <nl> # include " common / common / logger . h " <nl> # include " common / upstream / load_balancer_impl . h " <nl> <nl> + # include " absl / base / thread_annotations . h " <nl> + <nl> namespace Envoy { <nl> namespace Upstream { <nl> <nl> namespace Upstream { <nl> * 3 ) Max request fallback to support hot shards ( not all applications will want this ) . <nl> * / <nl> class RingHashLoadBalancer : public LoadBalancerBase , <nl> - public LoadBalancer , <nl> + public ThreadAwareLoadBalancer , <nl> Logger : : Loggable < Logger : : Id : : upstream > { <nl> public : <nl> RingHashLoadBalancer ( PrioritySet & priority_set , ClusterStats & stats , Runtime : : Loader & runtime , <nl> Runtime : : RandomGenerator & random , <nl> const Optional < envoy : : api : : v2 : : Cluster : : RingHashLbConfig > & config ) ; <nl> <nl> - / / Upstream : : LoadBalancer <nl> - HostConstSharedPtr chooseHost ( LoadBalancerContext * context ) override ; <nl> + / / Upstream : : ThreadAwareLoadBalancer <nl> + LoadBalancerFactorySharedPtr factory ( ) override { return factory_ ; } <nl> + void initialize ( ) override ; <nl> <nl> private : <nl> struct RingEntry { <nl> class RingHashLoadBalancer : public LoadBalancerBase , <nl> } ; <nl> <nl> struct Ring { <nl> - HostConstSharedPtr chooseHost ( LoadBalancerContext * context , Runtime : : RandomGenerator & random ) ; <nl> - void create ( const Optional < envoy : : api : : v2 : : Cluster : : RingHashLbConfig > & config , <nl> - const std : : vector < HostSharedPtr > & hosts ) ; <nl> + Ring ( const Optional < envoy : : api : : v2 : : Cluster : : RingHashLbConfig > & config , <nl> + const std : : vector < HostSharedPtr > & hosts ) ; <nl> + HostConstSharedPtr chooseHost ( LoadBalancerContext * context , <nl> + Runtime : : RandomGenerator & random ) const ; <nl> <nl> std : : vector < RingEntry > ring_ ; <nl> } ; <nl> <nl> - void refresh ( uint32_t priority ) ; <nl> + typedef std : : shared_ptr < const Ring > RingConstSharedPtr ; <nl> <nl> - const Optional < envoy : : api : : v2 : : Cluster : : RingHashLbConfig > & config_ ; <nl> - struct PerPriorityState { <nl> - Ring all_hosts_ring_ ; <nl> - Ring healthy_hosts_ring_ ; <nl> + struct LoadBalancerImpl : public LoadBalancer { <nl> + LoadBalancerImpl ( ClusterStats & stats , Runtime : : RandomGenerator & random , <nl> + const RingConstSharedPtr & ring , bool global_panic ) <nl> + : stats_ ( stats ) , random_ ( random ) , ring_ ( ring ) , global_panic_ ( global_panic ) { } <nl> + <nl> + / / Upstream : : LoadBalancer <nl> + HostConstSharedPtr chooseHost ( LoadBalancerContext * context ) override ; <nl> + <nl> + ClusterStats & stats_ ; <nl> + Runtime : : RandomGenerator & random_ ; <nl> + const RingConstSharedPtr ring_ ; <nl> + const bool global_panic_ ; <nl> } ; <nl> - typedef std : : unique_ptr < PerPriorityState > PerPriorityStatePtr ; <nl> - std : : vector < PerPriorityStatePtr > per_priority_state_ ; <nl> + <nl> + struct LoadBalancerFactoryImpl : public LoadBalancerFactory { <nl> + LoadBalancerFactoryImpl ( ClusterStats & stats , Runtime : : RandomGenerator & random ) <nl> + : stats_ ( stats ) , random_ ( random ) { } <nl> + <nl> + / / Upstream : : LoadBalancerFactory <nl> + LoadBalancerPtr create ( ) override ; <nl> + <nl> + ClusterStats & stats_ ; <nl> + Runtime : : RandomGenerator & random_ ; <nl> + std : : shared_timed_mutex mutex_ ; <nl> + / / TOOD ( mattklein123 ) : Added GUARDED_BY ( mutex_ ) to to the following variables . OSX clang <nl> + / / seems to not like them with shared mutexes so we need to ifdef them out on OSX . I don ' t <nl> + / / have time to do this right now . <nl> + RingConstSharedPtr current_ring_ ; <nl> + bool global_panic_ { } ; <nl> + } ; <nl> + <nl> + void refresh ( ) ; <nl> + <nl> + const Optional < envoy : : api : : v2 : : Cluster : : RingHashLbConfig > & config_ ; <nl> + std : : shared_ptr < LoadBalancerFactoryImpl > factory_ ; <nl> } ; <nl> <nl> } / / namespace Upstream <nl> mmm a / source / common / upstream / subset_lb . cc <nl> ppp b / source / common / upstream / subset_lb . cc <nl> HostConstSharedPtr SubsetLoadBalancer : : chooseHost ( LoadBalancerContext * context ) <nl> } <nl> <nl> stats_ . lb_subsets_fallback_ . inc ( ) ; <nl> - return fallback_subset_ - > lb_ - > chooseHost ( context ) ; <nl> + return fallback_subset_ - > priority_subset_ - > lb_ - > chooseHost ( context ) ; <nl> } <nl> <nl> / / Find a host from the subsets . Sets host_chosen to false and returns nullptr if the context has <nl> HostConstSharedPtr SubsetLoadBalancer : : tryChooseHostFromContext ( LoadBalancerCont <nl> <nl> host_chosen = true ; <nl> stats_ . lb_subsets_selected_ . inc ( ) ; <nl> - return entry - > lb_ - > chooseHost ( context ) ; <nl> + return entry - > priority_subset_ - > lb_ - > chooseHost ( context ) ; <nl> } <nl> <nl> / / Iterates over the given metadata match criteria ( which must be lexically sorted by key ) and find <nl> void SubsetLoadBalancer : : updateFallbackSubset ( uint32_t priority , <nl> if ( fallback_subset_ = = nullptr ) { <nl> / / First update : create the default host subset . <nl> fallback_subset_ . reset ( new LbSubsetEntry ( ) ) ; <nl> - fallback_subset_ - > initLoadBalancer ( * this , predicate ) ; <nl> + fallback_subset_ - > priority_subset_ . reset ( new PrioritySubsetImpl ( * this , predicate ) ) ; <nl> } else { <nl> / / Subsequent updates : add / remove hosts . <nl> fallback_subset_ - > priority_subset_ - > update ( priority , hosts_added , hosts_removed , predicate ) ; <nl> void SubsetLoadBalancer : : update ( uint32_t priority , const std : : vector < HostSharedP <nl> / / Initialize new entry with hosts and update stats . ( An uninitialized entry <nl> / / with only removed hosts is a degenerate case and we leave the entry <nl> / / uninitialized . ) <nl> - entry - > initLoadBalancer ( * this , predicate ) ; <nl> + entry - > priority_subset_ . reset ( new PrioritySubsetImpl ( * this , predicate ) ) ; <nl> stats_ . lb_subsets_active_ . inc ( ) ; <nl> stats_ . lb_subsets_created_ . inc ( ) ; <nl> } <nl> SubsetLoadBalancer : : findOrCreateSubset ( LbSubsetMap & subsets , const SubsetMetadat <nl> <nl> / / Initialize a new HostSubsetImpl and LoadBalancer from the SubsetLoadBalancer , filtering hosts <nl> / / with the given predicate . <nl> - void SubsetLoadBalancer : : LbSubsetEntry : : initLoadBalancer ( const SubsetLoadBalancer & subset_lb , <nl> - HostPredicate predicate ) { <nl> - priority_subset_ . reset ( new PrioritySubsetImpl ( subset_lb . original_priority_set_ ) ) ; <nl> + SubsetLoadBalancer : : PrioritySubsetImpl : : PrioritySubsetImpl ( const SubsetLoadBalancer & subset_lb , <nl> + HostPredicate predicate ) <nl> + : PrioritySetImpl ( ) , original_priority_set_ ( subset_lb . original_priority_set_ ) { <nl> + <nl> + for ( size_t i = 0 ; i < original_priority_set_ . hostSetsPerPriority ( ) . size ( ) ; + + i ) { <nl> + empty_ & = getOrCreateHostSet ( i ) . hosts ( ) . empty ( ) ; <nl> + } <nl> + <nl> for ( size_t i = 0 ; i < subset_lb . original_priority_set_ . hostSetsPerPriority ( ) . size ( ) ; + + i ) { <nl> - priority_subset_ - > update ( i , subset_lb . original_priority_set_ . hostSetsPerPriority ( ) [ i ] - > hosts ( ) , <nl> - { } , predicate ) ; <nl> + update ( i , subset_lb . original_priority_set_ . hostSetsPerPriority ( ) [ i ] - > hosts ( ) , { } , predicate ) ; <nl> } <nl> <nl> switch ( subset_lb . lb_type_ ) { <nl> case LoadBalancerType : : LeastRequest : <nl> - lb_ . reset ( new LeastRequestLoadBalancer ( * priority_subset_ , <nl> - subset_lb . original_local_priority_set_ , subset_lb . stats_ , <nl> - subset_lb . runtime_ , subset_lb . random_ ) ) ; <nl> + lb_ . reset ( new LeastRequestLoadBalancer ( * this , subset_lb . original_local_priority_set_ , <nl> + subset_lb . stats_ , subset_lb . runtime_ , <nl> + subset_lb . random_ ) ) ; <nl> break ; <nl> <nl> case LoadBalancerType : : Random : <nl> - lb_ . reset ( new RandomLoadBalancer ( * priority_subset_ , subset_lb . original_local_priority_set_ , <nl> + lb_ . reset ( new RandomLoadBalancer ( * this , subset_lb . original_local_priority_set_ , <nl> subset_lb . stats_ , subset_lb . runtime_ , subset_lb . random_ ) ) ; <nl> break ; <nl> <nl> case LoadBalancerType : : RoundRobin : <nl> - lb_ . reset ( new RoundRobinLoadBalancer ( * priority_subset_ , subset_lb . original_local_priority_set_ , <nl> + lb_ . reset ( new RoundRobinLoadBalancer ( * this , subset_lb . original_local_priority_set_ , <nl> subset_lb . stats_ , subset_lb . runtime_ , subset_lb . random_ ) ) ; <nl> break ; <nl> <nl> case LoadBalancerType : : RingHash : <nl> - lb_ . reset ( new RingHashLoadBalancer ( * priority_subset_ , subset_lb . stats_ , subset_lb . runtime_ , <nl> - subset_lb . random_ , subset_lb . lb_ring_hash_config_ ) ) ; <nl> + / / TODO ( mattklein123 ) : The ring hash LB is thread aware , but currently the subset LB is not . <nl> + / / We should make the subset LB thread aware since the calculations are costly , and then we <nl> + / / can also use a thread aware sub - LB properly . The following works fine but is not optimal . <nl> + thread_aware_lb_ . reset ( new RingHashLoadBalancer ( * this , subset_lb . stats_ , subset_lb . runtime_ , <nl> + subset_lb . random_ , <nl> + subset_lb . lb_ring_hash_config_ ) ) ; <nl> + thread_aware_lb_ - > initialize ( ) ; <nl> + lb_ = thread_aware_lb_ - > factory ( ) - > create ( ) ; <nl> break ; <nl> <nl> case LoadBalancerType : : OriginalDst : <nl> NOT_REACHED ; <nl> } <nl> <nl> - priority_subset_ - > triggerCallbacks ( ) ; <nl> + triggerCallbacks ( ) ; <nl> } <nl> <nl> / / Given hosts_added and hosts_removed , update the underlying HostSet . The hosts_added Hosts must <nl> void SubsetLoadBalancer : : HostSubsetImpl : : update ( const std : : vector < HostSharedPtr > <nl> filtered_added , filtered_removed ) ; <nl> } <nl> <nl> - SubsetLoadBalancer : : PrioritySubsetImpl : : PrioritySubsetImpl ( const PrioritySet & original_priority_set ) <nl> - : PrioritySetImpl ( ) , original_priority_set_ ( original_priority_set ) { <nl> - for ( size_t i = 0 ; i < original_priority_set_ . hostSetsPerPriority ( ) . size ( ) ; + + i ) { <nl> - empty_ & = getOrCreateHostSet ( i ) . hosts ( ) . empty ( ) ; <nl> - } <nl> - } <nl> - <nl> HostSetImplPtr SubsetLoadBalancer : : PrioritySubsetImpl : : createHostSet ( uint32_t priority ) { <nl> RELEASE_ASSERT ( priority < original_priority_set_ . hostSetsPerPriority ( ) . size ( ) ) ; <nl> return HostSetImplPtr { <nl> void SubsetLoadBalancer : : PrioritySubsetImpl : : update ( uint32_t priority , <nl> empty_ & = host_set - > hosts ( ) . empty ( ) ; <nl> } <nl> } <nl> + <nl> + / / Create a new worker local LB if needed . <nl> + / / TODO ( mattklein123 ) : See the PrioritySubsetImpl constructor for additional comments on how <nl> + / / we can do better here . <nl> + if ( thread_aware_lb_ ! = nullptr ) { <nl> + lb_ = thread_aware_lb_ - > factory ( ) - > create ( ) ; <nl> + } <nl> } <nl> <nl> } / / namespace Upstream <nl> mmm a / source / common / upstream / subset_lb . h <nl> ppp b / source / common / upstream / subset_lb . h <nl> class SubsetLoadBalancer : public LoadBalancer , Logger : : Loggable < Logger : : Id : : ups <nl> / / Represents a subset of an original PrioritySet . <nl> class PrioritySubsetImpl : public PrioritySetImpl { <nl> public : <nl> - PrioritySubsetImpl ( const PrioritySet & original_priority_set ) ; <nl> + PrioritySubsetImpl ( const SubsetLoadBalancer & subset_lb , HostPredicate predicate ) ; <nl> <nl> void update ( uint32_t priority , const std : : vector < HostSharedPtr > & hosts_added , <nl> const std : : vector < HostSharedPtr > & hosts_removed , HostPredicate predicate ) ; <nl> class SubsetLoadBalancer : public LoadBalancer , Logger : : Loggable < Logger : : Id : : ups <nl> } <nl> } <nl> <nl> + / / Thread aware LB if applicable . <nl> + ThreadAwareLoadBalancerPtr thread_aware_lb_ ; <nl> + / / Current active LB . <nl> + LoadBalancerPtr lb_ ; <nl> + <nl> protected : <nl> HostSetImplPtr createHostSet ( uint32_t priority ) override ; <nl> <nl> class SubsetLoadBalancer : public LoadBalancer , Logger : : Loggable < Logger : : Id : : ups <nl> public : <nl> LbSubsetEntry ( ) { } <nl> <nl> - bool initialized ( ) const { return lb_ ! = nullptr & & priority_subset_ ! = nullptr ; } <nl> + bool initialized ( ) const { return priority_subset_ ! = nullptr ; } <nl> bool active ( ) const { return initialized ( ) & & ! priority_subset_ - > empty ( ) ; } <nl> <nl> - void initLoadBalancer ( const SubsetLoadBalancer & subset_lb , HostPredicate predicate ) ; <nl> - <nl> LbSubsetMap children_ ; <nl> <nl> / / Only initialized if a match exists at this level . <nl> PrioritySubsetImplPtr priority_subset_ ; <nl> - LoadBalancerPtr lb_ ; <nl> } ; <nl> <nl> / / Called by HostSet : : MemberUpdateCb <nl> mmm a / test / common / upstream / cluster_manager_impl_test . cc <nl> ppp b / test / common / upstream / cluster_manager_impl_test . cc <nl> envoy : : api : : v2 : : Bootstrap parseBootstrapFromV2Yaml ( const std : : string & yaml ) { <nl> } <nl> <nl> TEST_F ( ClusterManagerImplTest , VersionInfoStatic ) { <nl> - const std : : string json = fmt : : sprintf ( <nl> - R " EOF ( <nl> - { <nl> - % s <nl> - } <nl> - ) EOF " , <nl> - clustersJson ( { defaultStaticClusterJson ( " cluster_0 " ) } ) ) ; <nl> + const std : : string json = <nl> + fmt : : sprintf ( " { % s } " , clustersJson ( { defaultStaticClusterJson ( " cluster_0 " ) } ) ) ; <nl> <nl> create ( parseBootstrapFromJson ( json ) ) ; <nl> EXPECT_EQ ( " static " , cluster_manager_ - > versionInfo ( ) ) ; <nl> TEST_F ( ClusterManagerImplTest , RingHashLoadBalancerV2Initialization ) { <nl> create ( parseBootstrapFromV2Yaml ( yaml ) ) ; <nl> } <nl> <nl> + / / Test that the cluster manager correctly re - creates the worker local LB when there is a host <nl> + / / set change . <nl> + TEST_F ( ClusterManagerImplTest , RingHashLoadBalancerThreadAwareUpdate ) { <nl> + const std : : string json = <nl> + fmt : : sprintf ( " { % s } " , clustersJson ( { defaultStaticClusterJson ( " cluster_0 " ) } ) ) ; <nl> + <nl> + std : : shared_ptr < MockCluster > cluster1 ( new NiceMock < MockCluster > ( ) ) ; <nl> + cluster1 - > info_ - > name_ = " cluster_0 " ; <nl> + cluster1 - > info_ - > lb_type_ = LoadBalancerType : : RingHash ; <nl> + <nl> + InSequence s ; <nl> + EXPECT_CALL ( factory_ , clusterFromProto_ ( _ , _ , _ , _ ) ) . WillOnce ( Return ( cluster1 ) ) ; <nl> + ON_CALL ( * cluster1 , initializePhase ( ) ) . WillByDefault ( Return ( Cluster : : InitializePhase : : Primary ) ) ; <nl> + create ( parseBootstrapFromJson ( json ) ) ; <nl> + <nl> + EXPECT_EQ ( nullptr , cluster_manager_ - > get ( " cluster_0 " ) - > loadBalancer ( ) . chooseHost ( nullptr ) ) ; <nl> + <nl> + cluster1 - > prioritySet ( ) . getMockHostSet ( 0 ) - > hosts_ = { <nl> + makeTestHost ( cluster1 - > info_ , " tcp : / / 127 . 0 . 0 . 1 : 80 " ) } ; <nl> + cluster1 - > prioritySet ( ) . getMockHostSet ( 0 ) - > runCallbacks ( <nl> + cluster1 - > prioritySet ( ) . getMockHostSet ( 0 ) - > hosts_ , { } ) ; <nl> + cluster1 - > initialize_callback_ ( ) ; <nl> + EXPECT_EQ ( cluster1 - > prioritySet ( ) . getMockHostSet ( 0 ) - > hosts_ [ 0 ] , <nl> + cluster_manager_ - > get ( " cluster_0 " ) - > loadBalancer ( ) . chooseHost ( nullptr ) ) ; <nl> + } <nl> + <nl> TEST_F ( ClusterManagerImplTest , TcpHealthChecker ) { <nl> const std : : string json = R " EOF ( <nl> { <nl> TEST_F ( ClusterManagerImplTest , InitializeOrder ) { <nl> InSequence s ; <nl> EXPECT_CALL ( factory_ , clusterFromProto_ ( _ , _ , _ , _ ) ) . WillOnce ( Return ( cluster1 ) ) ; <nl> ON_CALL ( * cluster1 , initializePhase ( ) ) . WillByDefault ( Return ( Cluster : : InitializePhase : : Primary ) ) ; <nl> - EXPECT_CALL ( * cluster1 , initialize ( _ ) ) ; <nl> EXPECT_CALL ( factory_ , clusterFromProto_ ( _ , _ , _ , _ ) ) . WillOnce ( Return ( cluster2 ) ) ; <nl> ON_CALL ( * cluster2 , initializePhase ( ) ) . WillByDefault ( Return ( Cluster : : InitializePhase : : Secondary ) ) ; <nl> EXPECT_CALL ( factory_ , clusterFromProto_ ( _ , _ , _ , _ ) ) . WillOnce ( Return ( cds_cluster ) ) ; <nl> ON_CALL ( * cds_cluster , initializePhase ( ) ) . WillByDefault ( Return ( Cluster : : InitializePhase : : Primary ) ) ; <nl> - EXPECT_CALL ( * cds_cluster , initialize ( _ ) ) ; <nl> EXPECT_CALL ( factory_ , createCds_ ( ) ) . WillOnce ( Return ( cds ) ) ; <nl> EXPECT_CALL ( * cds , setInitializedCb ( _ ) ) ; <nl> + EXPECT_CALL ( * cds_cluster , initialize ( _ ) ) ; <nl> + EXPECT_CALL ( * cluster1 , initialize ( _ ) ) ; <nl> <nl> create ( parseBootstrapFromJson ( json ) ) ; <nl> <nl> TEST_F ( ClusterManagerImplTest , DynamicAddRemove ) { <nl> EXPECT_CALL ( * cluster1 , initializePhase ( ) ) . Times ( 0 ) ; <nl> EXPECT_CALL ( * cluster1 , initialize ( _ ) ) ; <nl> EXPECT_TRUE ( cluster_manager_ - > addOrUpdatePrimaryCluster ( defaultStaticCluster ( " fake_cluster " ) ) ) ; <nl> + cluster1 - > initialize_callback_ ( ) ; <nl> <nl> EXPECT_EQ ( cluster1 - > info_ , cluster_manager_ - > get ( " fake_cluster " ) - > info ( ) ) ; <nl> EXPECT_EQ ( 1UL , factory_ . stats_ . gauge ( " cluster_manager . total_clusters " ) . value ( ) ) ; <nl> TEST_F ( ClusterManagerImplTest , DynamicAddRemove ) { <nl> makeTestHost ( cluster2 - > info_ , " tcp : / / 127 . 0 . 0 . 1 : 80 " ) } ; <nl> EXPECT_CALL ( factory_ , clusterFromProto_ ( _ , _ , _ , _ ) ) . WillOnce ( Return ( cluster2 ) ) ; <nl> EXPECT_CALL ( * cluster2 , initializePhase ( ) ) . Times ( 0 ) ; <nl> - EXPECT_CALL ( * cluster2 , initialize ( _ ) ) ; <nl> + EXPECT_CALL ( * cluster2 , initialize ( _ ) ) <nl> + . WillOnce ( Invoke ( [ cluster1 ] ( std : : function < void ( ) > initialize_callback ) { <nl> + / / Test inline init . <nl> + initialize_callback ( ) ; <nl> + } ) ) ; <nl> EXPECT_TRUE ( cluster_manager_ - > addOrUpdatePrimaryCluster ( update_cluster ) ) ; <nl> <nl> EXPECT_EQ ( cluster2 - > info_ , cluster_manager_ - > get ( " fake_cluster " ) - > info ( ) ) ; <nl> TEST_F ( ClusterManagerImplTest , CloseConnectionsOnHealthFailure ) { <nl> ON_CALL ( * cluster1 , outlierDetector ( ) ) . WillByDefault ( Return ( & outlier_detector ) ) ; <nl> <nl> EXPECT_CALL ( factory_ , clusterFromProto_ ( _ , _ , _ , _ ) ) . WillOnce ( Return ( cluster1 ) ) ; <nl> - EXPECT_CALL ( * cluster1 , initialize ( _ ) ) ; <nl> EXPECT_CALL ( health_checker , addHostCheckCompleteCb ( _ ) ) ; <nl> EXPECT_CALL ( outlier_detector , addChangedStateCb ( _ ) ) ; <nl> + EXPECT_CALL ( * cluster1 , initialize ( _ ) ) <nl> + . WillOnce ( Invoke ( [ cluster1 ] ( std : : function < void ( ) > initialize_callback ) { <nl> + / / Test inline init . <nl> + initialize_callback ( ) ; <nl> + } ) ) ; <nl> <nl> create ( parseBootstrapFromJson ( json ) ) ; <nl> <nl> TEST_F ( ClusterManagerImplTest , OriginalDstInitialization ) { <nl> " lb_type " : " original_dst_lb " <nl> } ] <nl> } <nl> - ) EOF " ; / / " <nl> + ) EOF " ; <nl> <nl> ReadyWatcher initialized ; <nl> EXPECT_CALL ( initialized , ready ( ) ) ; <nl> TEST_F ( ClusterManagerImplTest , OriginalDstInitialization ) { <nl> factory_ . tls_ . shutdownThread ( ) ; <nl> } <nl> <nl> - TEST ( ClusterManagerInitHelper , ImmediateInitialize ) { <nl> + class ClusterManagerInitHelperTest : public testing : : Test { <nl> + public : <nl> + MOCK_METHOD1 ( onClusterInit , void ( Cluster & cluster ) ) ; <nl> + <nl> + ClusterManagerInitHelper init_helper_ { [ this ] ( Cluster & cluster ) { onClusterInit ( cluster ) ; } } ; <nl> + } ; <nl> + <nl> + TEST_F ( ClusterManagerInitHelperTest , ImmediateInitialize ) { <nl> InSequence s ; <nl> - ClusterManagerInitHelper init_helper ; <nl> <nl> NiceMock < MockCluster > cluster1 ; <nl> ON_CALL ( cluster1 , initializePhase ( ) ) . WillByDefault ( Return ( Cluster : : InitializePhase : : Primary ) ) ; <nl> EXPECT_CALL ( cluster1 , initialize ( _ ) ) ; <nl> - init_helper . addCluster ( cluster1 ) ; <nl> + init_helper_ . addCluster ( cluster1 ) ; <nl> + EXPECT_CALL ( * this , onClusterInit ( Ref ( cluster1 ) ) ) ; <nl> cluster1 . initialize_callback_ ( ) ; <nl> <nl> - init_helper . onStaticLoadComplete ( ) ; <nl> + init_helper_ . onStaticLoadComplete ( ) ; <nl> <nl> ReadyWatcher cm_initialized ; <nl> EXPECT_CALL ( cm_initialized , ready ( ) ) ; <nl> - init_helper . setInitializedCb ( [ & ] ( ) - > void { cm_initialized . ready ( ) ; } ) ; <nl> + init_helper_ . setInitializedCb ( [ & ] ( ) - > void { cm_initialized . ready ( ) ; } ) ; <nl> } <nl> <nl> - TEST ( ClusterManagerInitHelper , StaticSdsInitialize ) { <nl> + TEST_F ( ClusterManagerInitHelperTest , StaticSdsInitialize ) { <nl> InSequence s ; <nl> - ClusterManagerInitHelper init_helper ; <nl> <nl> NiceMock < MockCluster > sds ; <nl> ON_CALL ( sds , initializePhase ( ) ) . WillByDefault ( Return ( Cluster : : InitializePhase : : Primary ) ) ; <nl> EXPECT_CALL ( sds , initialize ( _ ) ) ; <nl> - init_helper . addCluster ( sds ) ; <nl> + init_helper_ . addCluster ( sds ) ; <nl> + EXPECT_CALL ( * this , onClusterInit ( Ref ( sds ) ) ) ; <nl> sds . initialize_callback_ ( ) ; <nl> <nl> NiceMock < MockCluster > cluster1 ; <nl> ON_CALL ( cluster1 , initializePhase ( ) ) . WillByDefault ( Return ( Cluster : : InitializePhase : : Secondary ) ) ; <nl> - init_helper . addCluster ( cluster1 ) ; <nl> + init_helper_ . addCluster ( cluster1 ) ; <nl> <nl> EXPECT_CALL ( cluster1 , initialize ( _ ) ) ; <nl> - init_helper . onStaticLoadComplete ( ) ; <nl> + init_helper_ . onStaticLoadComplete ( ) ; <nl> <nl> ReadyWatcher cm_initialized ; <nl> - init_helper . setInitializedCb ( [ & ] ( ) - > void { cm_initialized . ready ( ) ; } ) ; <nl> + init_helper_ . setInitializedCb ( [ & ] ( ) - > void { cm_initialized . ready ( ) ; } ) ; <nl> <nl> + EXPECT_CALL ( * this , onClusterInit ( Ref ( cluster1 ) ) ) ; <nl> EXPECT_CALL ( cm_initialized , ready ( ) ) ; <nl> cluster1 . initialize_callback_ ( ) ; <nl> } <nl> <nl> - TEST ( ClusterManagerInitHelper , UpdateAlreadyInitialized ) { <nl> + TEST_F ( ClusterManagerInitHelperTest , UpdateAlreadyInitialized ) { <nl> InSequence s ; <nl> - ClusterManagerInitHelper init_helper ; <nl> <nl> ReadyWatcher cm_initialized ; <nl> - init_helper . setInitializedCb ( [ & ] ( ) - > void { cm_initialized . ready ( ) ; } ) ; <nl> + init_helper_ . setInitializedCb ( [ & ] ( ) - > void { cm_initialized . ready ( ) ; } ) ; <nl> <nl> NiceMock < MockCluster > cluster1 ; <nl> ON_CALL ( cluster1 , initializePhase ( ) ) . WillByDefault ( Return ( Cluster : : InitializePhase : : Primary ) ) ; <nl> EXPECT_CALL ( cluster1 , initialize ( _ ) ) ; <nl> - init_helper . addCluster ( cluster1 ) ; <nl> + init_helper_ . addCluster ( cluster1 ) ; <nl> <nl> NiceMock < MockCluster > cluster2 ; <nl> ON_CALL ( cluster2 , initializePhase ( ) ) . WillByDefault ( Return ( Cluster : : InitializePhase : : Primary ) ) ; <nl> EXPECT_CALL ( cluster2 , initialize ( _ ) ) ; <nl> - init_helper . addCluster ( cluster2 ) ; <nl> + init_helper_ . addCluster ( cluster2 ) ; <nl> <nl> - init_helper . onStaticLoadComplete ( ) ; <nl> + init_helper_ . onStaticLoadComplete ( ) ; <nl> <nl> + EXPECT_CALL ( * this , onClusterInit ( Ref ( cluster1 ) ) ) ; <nl> cluster1 . initialize_callback_ ( ) ; <nl> - init_helper . removeCluster ( cluster1 ) ; <nl> + init_helper_ . removeCluster ( cluster1 ) ; <nl> <nl> + EXPECT_CALL ( * this , onClusterInit ( Ref ( cluster2 ) ) ) ; <nl> EXPECT_CALL ( cm_initialized , ready ( ) ) ; <nl> cluster2 . initialize_callback_ ( ) ; <nl> } <nl> <nl> - TEST ( ClusterManagerInitHelper , AddSecondaryAfterSecondaryInit ) { <nl> + TEST_F ( ClusterManagerInitHelperTest , AddSecondaryAfterSecondaryInit ) { <nl> InSequence s ; <nl> - ClusterManagerInitHelper init_helper ; <nl> <nl> ReadyWatcher cm_initialized ; <nl> - init_helper . setInitializedCb ( [ & ] ( ) - > void { cm_initialized . ready ( ) ; } ) ; <nl> + init_helper_ . setInitializedCb ( [ & ] ( ) - > void { cm_initialized . ready ( ) ; } ) ; <nl> <nl> NiceMock < MockCluster > cluster1 ; <nl> ON_CALL ( cluster1 , initializePhase ( ) ) . WillByDefault ( Return ( Cluster : : InitializePhase : : Primary ) ) ; <nl> EXPECT_CALL ( cluster1 , initialize ( _ ) ) ; <nl> - init_helper . addCluster ( cluster1 ) ; <nl> + init_helper_ . addCluster ( cluster1 ) ; <nl> <nl> NiceMock < MockCluster > cluster2 ; <nl> ON_CALL ( cluster2 , initializePhase ( ) ) . WillByDefault ( Return ( Cluster : : InitializePhase : : Secondary ) ) ; <nl> - init_helper . addCluster ( cluster2 ) ; <nl> + init_helper_ . addCluster ( cluster2 ) ; <nl> <nl> - init_helper . onStaticLoadComplete ( ) ; <nl> + init_helper_ . onStaticLoadComplete ( ) ; <nl> <nl> + EXPECT_CALL ( * this , onClusterInit ( Ref ( cluster1 ) ) ) ; <nl> EXPECT_CALL ( cluster2 , initialize ( _ ) ) ; <nl> cluster1 . initialize_callback_ ( ) ; <nl> <nl> NiceMock < MockCluster > cluster3 ; <nl> ON_CALL ( cluster3 , initializePhase ( ) ) . WillByDefault ( Return ( Cluster : : InitializePhase : : Secondary ) ) ; <nl> EXPECT_CALL ( cluster3 , initialize ( _ ) ) ; <nl> - init_helper . addCluster ( cluster3 ) ; <nl> + init_helper_ . addCluster ( cluster3 ) ; <nl> <nl> + EXPECT_CALL ( * this , onClusterInit ( Ref ( cluster3 ) ) ) ; <nl> cluster3 . initialize_callback_ ( ) ; <nl> + EXPECT_CALL ( * this , onClusterInit ( Ref ( cluster2 ) ) ) ; <nl> EXPECT_CALL ( cm_initialized , ready ( ) ) ; <nl> cluster2 . initialize_callback_ ( ) ; <nl> } <nl> <nl> - TEST ( ClusterManagerInitHelper , RemoveClusterWithinInitLoop ) { <nl> - / / Tests the scenario encountered in Issue 903 : The cluster was removed from <nl> - / / the secondary init list while traversing the list . <nl> - <nl> + / / Tests the scenario encountered in Issue 903 : The cluster was removed from <nl> + / / the secondary init list while traversing the list . <nl> + TEST_F ( ClusterManagerInitHelperTest , RemoveClusterWithinInitLoop ) { <nl> InSequence s ; <nl> - ClusterManagerInitHelper init_helper ; <nl> NiceMock < MockCluster > cluster ; <nl> ON_CALL ( cluster , initializePhase ( ) ) . WillByDefault ( Return ( Cluster : : InitializePhase : : Secondary ) ) ; <nl> - init_helper . addCluster ( cluster ) ; <nl> + init_helper_ . addCluster ( cluster ) ; <nl> <nl> / / Set up the scenario seen in Issue 903 where initialize ( ) ultimately results <nl> / / in the removeCluster ( ) call . In the real bug this was a long and complex call <nl> / / chain . <nl> EXPECT_CALL ( cluster , initialize ( _ ) ) . WillOnce ( Invoke ( [ & ] ( std : : function < void ( ) > ) - > void { <nl> - init_helper . removeCluster ( cluster ) ; <nl> + init_helper_ . removeCluster ( cluster ) ; <nl> } ) ) ; <nl> <nl> / / Now call onStaticLoadComplete which will exercise maybeFinishInitialize ( ) <nl> / / which calls initialize ( ) on the members of the secondary init list . <nl> - init_helper . onStaticLoadComplete ( ) ; <nl> + init_helper_ . onStaticLoadComplete ( ) ; <nl> } <nl> <nl> } / / namespace <nl> mmm a / test / common / upstream / ring_hash_lb_test . cc <nl> ppp b / test / common / upstream / ring_hash_lb_test . cc <nl> class RingHashLoadBalancerTest : public : : testing : : TestWithParam < bool > { <nl> <nl> void init ( ) { <nl> lb_ . reset ( new RingHashLoadBalancer ( priority_set_ , stats_ , runtime_ , random_ , config_ ) ) ; <nl> + lb_ - > initialize ( ) ; <nl> } <nl> <nl> / / Run all tests aginst both priority 0 and priority 1 host sets , to ensure <nl> INSTANTIATE_TEST_CASE_P ( PrimaryOrFailover , RingHashLoadBalancerTest , <nl> <nl> TEST_F ( RingHashLoadBalancerTest , NoHost ) { <nl> init ( ) ; <nl> - EXPECT_EQ ( nullptr , lb_ - > chooseHost ( nullptr ) ) ; <nl> + EXPECT_EQ ( nullptr , lb_ - > factory ( ) - > create ( ) - > chooseHost ( nullptr ) ) ; <nl> } ; <nl> <nl> TEST_F ( RingHashLoadBalancerTest , Basic ) { <nl> TEST_F ( RingHashLoadBalancerTest , Basic ) { <nl> / / : 94 | 15516499411664133160 <nl> / / : 90 | 16117243373044804889 <nl> <nl> + LoadBalancerPtr lb = lb_ - > factory ( ) - > create ( ) ; <nl> { <nl> TestLoadBalancerContext context ( 0 ) ; <nl> - EXPECT_EQ ( host_set_ . hosts_ [ 4 ] , lb_ - > chooseHost ( & context ) ) ; <nl> + EXPECT_EQ ( host_set_ . hosts_ [ 4 ] , lb - > chooseHost ( & context ) ) ; <nl> } <nl> { <nl> TestLoadBalancerContext context ( std : : numeric_limits < uint64_t > : : max ( ) ) ; <nl> - EXPECT_EQ ( host_set_ . hosts_ [ 4 ] , lb_ - > chooseHost ( & context ) ) ; <nl> + EXPECT_EQ ( host_set_ . hosts_ [ 4 ] , lb - > chooseHost ( & context ) ) ; <nl> } <nl> { <nl> TestLoadBalancerContext context ( 3551244743356806947 ) ; <nl> - EXPECT_EQ ( host_set_ . hosts_ [ 5 ] , lb_ - > chooseHost ( & context ) ) ; <nl> + EXPECT_EQ ( host_set_ . hosts_ [ 5 ] , lb - > chooseHost ( & context ) ) ; <nl> } <nl> { <nl> TestLoadBalancerContext context ( 3551244743356806948 ) ; <nl> - EXPECT_EQ ( host_set_ . hosts_ [ 3 ] , lb_ - > chooseHost ( & context ) ) ; <nl> + EXPECT_EQ ( host_set_ . hosts_ [ 3 ] , lb - > chooseHost ( & context ) ) ; <nl> } <nl> { <nl> EXPECT_CALL ( random_ , random ( ) ) . WillOnce ( Return ( 16117243373044804880UL ) ) ; <nl> - EXPECT_EQ ( host_set_ . hosts_ [ 0 ] , lb_ - > chooseHost ( nullptr ) ) ; <nl> + EXPECT_EQ ( host_set_ . hosts_ [ 0 ] , lb - > chooseHost ( nullptr ) ) ; <nl> } <nl> EXPECT_EQ ( 0UL , stats_ . lb_healthy_panic_ . value ( ) ) ; <nl> <nl> host_set_ . healthy_hosts_ . clear ( ) ; <nl> host_set_ . runCallbacks ( { } , { } ) ; <nl> + lb = lb_ - > factory ( ) - > create ( ) ; <nl> { <nl> TestLoadBalancerContext context ( 0 ) ; <nl> - EXPECT_EQ ( host_set_ . hosts_ [ 4 ] , lb_ - > chooseHost ( & context ) ) ; <nl> + EXPECT_EQ ( host_set_ . hosts_ [ 4 ] , lb - > chooseHost ( & context ) ) ; <nl> } <nl> EXPECT_EQ ( 1UL , stats_ . lb_healthy_panic_ . value ( ) ) ; <nl> } <nl> TEST_P ( RingHashLoadBalancerTest , BasicFailover ) { <nl> config_ . value ( ) . mutable_deprecated_v1 ( ) - > mutable_use_std_hash ( ) - > set_value ( false ) ; <nl> init ( ) ; <nl> <nl> - EXPECT_EQ ( failover_host_set_ . healthy_hosts_ [ 0 ] , lb_ - > chooseHost ( nullptr ) ) ; <nl> + LoadBalancerPtr lb = lb_ - > factory ( ) - > create ( ) ; <nl> + EXPECT_EQ ( failover_host_set_ . healthy_hosts_ [ 0 ] , lb - > chooseHost ( nullptr ) ) ; <nl> <nl> / / Add a healthy host at P = 0 and it will be chosen . <nl> host_set_ . healthy_hosts_ = host_set_ . hosts_ ; <nl> host_set_ . runCallbacks ( { } , { } ) ; <nl> - EXPECT_EQ ( host_set_ . healthy_hosts_ [ 0 ] , lb_ - > chooseHost ( nullptr ) ) ; <nl> + lb = lb_ - > factory ( ) - > create ( ) ; <nl> + EXPECT_EQ ( host_set_ . healthy_hosts_ [ 0 ] , lb - > chooseHost ( nullptr ) ) ; <nl> <nl> / / Remove the healthy host and ensure we fail back over to the failover_host_set_ <nl> host_set_ . healthy_hosts_ = { } ; <nl> host_set_ . runCallbacks ( { } , { } ) ; <nl> - EXPECT_EQ ( failover_host_set_ . healthy_hosts_ [ 0 ] , lb_ - > chooseHost ( nullptr ) ) ; <nl> + lb = lb_ - > factory ( ) - > create ( ) ; <nl> + EXPECT_EQ ( failover_host_set_ . healthy_hosts_ [ 0 ] , lb - > chooseHost ( nullptr ) ) ; <nl> } <nl> <nl> # ifndef __APPLE__ <nl> TEST_F ( RingHashLoadBalancerTest , BasicWithStdHash ) { <nl> / / ring hash : host = 127 . 0 . 0 . 1 : 80 hash = 15427156902705414897 <nl> / / ring hash : host = 127 . 0 . 0 . 1 : 85 hash = 16375050414328759093 <nl> / / ring hash : host = 127 . 0 . 0 . 1 : 80 hash = 17613279263364193813 <nl> + LoadBalancerPtr lb = lb_ - > factory ( ) - > create ( ) ; <nl> { <nl> TestLoadBalancerContext context ( 0 ) ; <nl> - EXPECT_EQ ( host_set_ . hosts_ [ 5 ] , lb_ - > chooseHost ( & context ) ) ; <nl> + EXPECT_EQ ( host_set_ . hosts_ [ 5 ] , lb - > chooseHost ( & context ) ) ; <nl> } <nl> { <nl> TestLoadBalancerContext context ( std : : numeric_limits < uint64_t > : : max ( ) ) ; <nl> - EXPECT_EQ ( host_set_ . hosts_ [ 5 ] , lb_ - > chooseHost ( & context ) ) ; <nl> + EXPECT_EQ ( host_set_ . hosts_ [ 5 ] , lb - > chooseHost ( & context ) ) ; <nl> } <nl> { <nl> TestLoadBalancerContext context ( 1358027074129602068 ) ; <nl> - EXPECT_EQ ( host_set_ . hosts_ [ 5 ] , lb_ - > chooseHost ( & context ) ) ; <nl> + EXPECT_EQ ( host_set_ . hosts_ [ 5 ] , lb - > chooseHost ( & context ) ) ; <nl> } <nl> { <nl> TestLoadBalancerContext context ( 1358027074129602069 ) ; <nl> - EXPECT_EQ ( host_set_ . hosts_ [ 3 ] , lb_ - > chooseHost ( & context ) ) ; <nl> + EXPECT_EQ ( host_set_ . hosts_ [ 3 ] , lb - > chooseHost ( & context ) ) ; <nl> } <nl> { <nl> EXPECT_CALL ( random_ , random ( ) ) . WillOnce ( Return ( 10150910876324007730UL ) ) ; <nl> - EXPECT_EQ ( host_set_ . hosts_ [ 2 ] , lb_ - > chooseHost ( nullptr ) ) ; <nl> + EXPECT_EQ ( host_set_ . hosts_ [ 2 ] , lb - > chooseHost ( nullptr ) ) ; <nl> } <nl> EXPECT_EQ ( 0UL , stats_ . lb_healthy_panic_ . value ( ) ) ; <nl> } <nl> TEST_F ( RingHashLoadBalancerTest , UnevenHosts ) { <nl> / / : 80 | 13838424394637650569 <nl> / / : 81 | 16064866803292627174 <nl> <nl> + LoadBalancerPtr lb = lb_ - > factory ( ) - > create ( ) ; <nl> { <nl> TestLoadBalancerContext context ( 0 ) ; <nl> - EXPECT_EQ ( host_set_ . hosts_ [ 0 ] , lb_ - > chooseHost ( & context ) ) ; <nl> + EXPECT_EQ ( host_set_ . hosts_ [ 0 ] , lb - > chooseHost ( & context ) ) ; <nl> } <nl> <nl> host_set_ . hosts_ = { makeTestHost ( info_ , " tcp : / / 127 . 0 . 0 . 1 : 81 " ) , <nl> TEST_F ( RingHashLoadBalancerTest , UnevenHosts ) { <nl> / / : 82 | 12882406409176325258 <nl> / / : 81 | 16064866803292627174 <nl> <nl> + lb = lb_ - > factory ( ) - > create ( ) ; <nl> { <nl> TestLoadBalancerContext context ( 0 ) ; <nl> - EXPECT_EQ ( host_set_ . hosts_ [ 0 ] , lb_ - > chooseHost ( & context ) ) ; <nl> + EXPECT_EQ ( host_set_ . hosts_ [ 0 ] , lb - > chooseHost ( & context ) ) ; <nl> } <nl> } <nl> <nl> TEST_F ( DISABLED_RingHashLoadBalancerTest , DetermineSpread ) { <nl> config_ . value ( envoy : : api : : v2 : : Cluster : : RingHashLbConfig ( ) ) ; <nl> config_ . value ( ) . mutable_minimum_ring_size ( ) - > set_value ( min_ring_size ) ; <nl> config_ . value ( ) . mutable_deprecated_v1 ( ) - > mutable_use_std_hash ( ) - > set_value ( false ) ; <nl> - RingHashLoadBalancer lb { priority_set_ , stats_ , runtime_ , random_ , config_ } ; <nl> + RingHashLoadBalancer thread_aware_lb { priority_set_ , stats_ , runtime_ , random_ , config_ } ; <nl> + thread_aware_lb . initialize ( ) ; <nl> <nl> + LoadBalancerPtr lb = thread_aware_lb . factory ( ) - > create ( ) ; <nl> for ( uint64_t i = 0 ; i < keys_to_simulate ; i + + ) { <nl> TestLoadBalancerContext context ( std : : hash < std : : string > ( ) ( fmt : : format ( " { } " , i ) ) ) ; <nl> - hit_counter [ lb_ - > chooseHost ( & context ) - > address ( ) - > asString ( ) ] + = 1 ; <nl> + hit_counter [ lb - > chooseHost ( & context ) - > address ( ) - > asString ( ) ] + = 1 ; <nl> } <nl> <nl> std : : cout < < fmt : : format ( " { : < 9 } { : < 4 } { : < 20 } " , " hits " , " % hit " , " server " ) < < std : : endl ; <nl> mmm a / test / common / upstream / subset_lb_test . cc <nl> ppp b / test / common / upstream / subset_lb_test . cc <nl> class SubsetLoadBalancerTest : public testing : : TestWithParam < UpdateOrder > { <nl> } <nl> } <nl> <nl> + void doLbTypeTest ( LoadBalancerType type ) { <nl> + EXPECT_CALL ( subset_info_ , fallbackPolicy ( ) ) <nl> + . WillRepeatedly ( Return ( envoy : : api : : v2 : : Cluster : : LbSubsetConfig : : ANY_ENDPOINT ) ) ; <nl> + <nl> + lb_type_ = type ; <nl> + init ( { { " tcp : / / 127 . 0 . 0 . 1 : 80 " , { { " version " , " 1 . 0 " } } } } ) ; <nl> + <nl> + EXPECT_EQ ( host_set_ . hosts_ [ 0 ] , lb_ - > chooseHost ( nullptr ) ) ; <nl> + <nl> + HostSharedPtr added_host = makeHost ( " tcp : / / 127 . 0 . 0 . 1 : 8000 " , { { " version " , " 1 . 0 " } } ) ; <nl> + modifyHosts ( { added_host } , { host_set_ . hosts_ . back ( ) } ) ; <nl> + <nl> + EXPECT_EQ ( added_host , lb_ - > chooseHost ( nullptr ) ) ; <nl> + } <nl> + <nl> LoadBalancerType lb_type_ { LoadBalancerType : : RoundRobin } ; <nl> NiceMock < MockPrioritySet > priority_set_ ; <nl> MockHostSet & host_set_ = * priority_set_ . getMockHostSet ( 0 ) ; <nl> TEST_F ( SubsetLoadBalancerTest , IgnoresHostsWithoutMetadata ) { <nl> EXPECT_EQ ( host_set_ . hosts_ [ 1 ] , lb_ - > chooseHost ( & context_version ) ) ; <nl> } <nl> <nl> - TEST_F ( SubsetLoadBalancerTest , LoadBalancerTypes ) { <nl> - EXPECT_CALL ( subset_info_ , fallbackPolicy ( ) ) <nl> - . WillRepeatedly ( Return ( envoy : : api : : v2 : : Cluster : : LbSubsetConfig : : ANY_ENDPOINT ) ) ; <nl> + / / TODO ( mattklein123 ) : The following 4 tests verify basic functionality with all sub - LB tests . <nl> + / / Optimally these would also be some type of TEST_P , but that is a little bit complicated as <nl> + / / modifyHosts ( ) also needs params . Clean this up . <nl> + TEST_P ( SubsetLoadBalancerTest , LoadBalancerTypesRoundRobin ) { <nl> + doLbTypeTest ( LoadBalancerType : : RoundRobin ) ; <nl> + } <nl> <nl> - auto types = <nl> - std : : vector < LoadBalancerType > ( { LoadBalancerType : : RoundRobin , LoadBalancerType : : LeastRequest , <nl> - LoadBalancerType : : Random , LoadBalancerType : : RingHash } ) ; <nl> + TEST_P ( SubsetLoadBalancerTest , LoadBalancerTypesLeastRequest ) { <nl> + doLbTypeTest ( LoadBalancerType : : LeastRequest ) ; <nl> + } <nl> <nl> - for ( const auto & it : types ) { <nl> - lb_type_ = it ; <nl> - init ( ) ; <nl> + TEST_P ( SubsetLoadBalancerTest , LoadBalancerTypesRandom ) { doLbTypeTest ( LoadBalancerType : : Random ) ; } <nl> <nl> - EXPECT_NE ( nullptr , lb_ - > chooseHost ( nullptr ) ) ; <nl> - } <nl> + TEST_P ( SubsetLoadBalancerTest , LoadBalancerTypesRingHash ) { <nl> + doLbTypeTest ( LoadBalancerType : : RingHash ) ; <nl> } <nl> <nl> TEST_F ( SubsetLoadBalancerTest , ZoneAwareFallback ) { <nl> mmm a / test / integration / header_integration_test . cc <nl> ppp b / test / integration / header_integration_test . cc <nl> class HeaderIntegrationTest : public HttpIntegrationTest , <nl> initialize ( ) ; <nl> } <nl> <nl> - virtual void createUpstreams ( ) override { <nl> + void createUpstreams ( ) override { <nl> HttpIntegrationTest : : createUpstreams ( ) ; <nl> <nl> if ( use_eds_ ) { <nl> class HeaderIntegrationTest : public HttpIntegrationTest , <nl> } <nl> } <nl> <nl> - virtual void initialize ( ) override { <nl> - HttpIntegrationTest : : initialize ( ) ; <nl> - <nl> + void initialize ( ) override { <nl> if ( use_eds_ ) { <nl> - eds_connection_ = fake_upstreams_ [ 1 ] - > waitForHttpConnection ( * dispatcher_ ) ; <nl> - eds_stream_ = eds_connection_ - > waitForNewStream ( * dispatcher_ ) ; <nl> - eds_stream_ - > startGrpcStream ( ) ; <nl> + pre_worker_start_test_steps_ = [ this ] ( ) { <nl> + eds_connection_ = fake_upstreams_ [ 1 ] - > waitForHttpConnection ( * dispatcher_ ) ; <nl> + eds_stream_ = eds_connection_ - > waitForNewStream ( * dispatcher_ ) ; <nl> + eds_stream_ - > startGrpcStream ( ) ; <nl> <nl> - envoy : : api : : v2 : : DiscoveryRequest discovery_request ; <nl> - eds_stream_ - > waitForGrpcMessage ( * dispatcher_ , discovery_request ) ; <nl> + envoy : : api : : v2 : : DiscoveryRequest discovery_request ; <nl> + eds_stream_ - > waitForGrpcMessage ( * dispatcher_ , discovery_request ) ; <nl> <nl> - envoy : : api : : v2 : : DiscoveryResponse discovery_response ; <nl> - discovery_response . set_version_info ( " 1 " ) ; <nl> - discovery_response . set_type_url ( Config : : TypeUrl : : get ( ) . ClusterLoadAssignment ) ; <nl> + envoy : : api : : v2 : : DiscoveryResponse discovery_response ; <nl> + discovery_response . set_version_info ( " 1 " ) ; <nl> + discovery_response . set_type_url ( Config : : TypeUrl : : get ( ) . ClusterLoadAssignment ) ; <nl> <nl> - envoy : : api : : v2 : : ClusterLoadAssignment cluster_load_assignment = <nl> - TestUtility : : parseYaml < envoy : : api : : v2 : : ClusterLoadAssignment > ( fmt : : format ( <nl> - R " EOF ( <nl> + envoy : : api : : v2 : : ClusterLoadAssignment cluster_load_assignment = <nl> + TestUtility : : parseYaml < envoy : : api : : v2 : : ClusterLoadAssignment > ( fmt : : format ( <nl> + R " EOF ( <nl> cluster_name : cluster_0 <nl> endpoints : <nl> - lb_endpoints : <nl> class HeaderIntegrationTest : public HttpIntegrationTest , <nl> test . namespace : <nl> key : metadata - value <nl> ) EOF " , <nl> - Network : : Test : : getLoopbackAddressString ( GetParam ( ) ) , <nl> - fake_upstreams_ [ 0 ] - > localAddress ( ) - > ip ( ) - > port ( ) ) ) ; <nl> + Network : : Test : : getLoopbackAddressString ( GetParam ( ) ) , <nl> + fake_upstreams_ [ 0 ] - > localAddress ( ) - > ip ( ) - > port ( ) ) ) ; <nl> <nl> - discovery_response . add_resources ( ) - > PackFrom ( cluster_load_assignment ) ; <nl> - eds_stream_ - > sendGrpcMessage ( discovery_response ) ; <nl> + discovery_response . add_resources ( ) - > PackFrom ( cluster_load_assignment ) ; <nl> + eds_stream_ - > sendGrpcMessage ( discovery_response ) ; <nl> <nl> - / / Wait for the next request to make sure the first response was consumed . <nl> - eds_stream_ - > waitForGrpcMessage ( * dispatcher_ , discovery_request ) ; <nl> + / / Wait for the next request to make sure the first response was consumed . <nl> + eds_stream_ - > waitForGrpcMessage ( * dispatcher_ , discovery_request ) ; <nl> + } ; <nl> } <nl> + <nl> + HttpIntegrationTest : : initialize ( ) ; <nl> } <nl> <nl> protected : <nl> mmm a / test / integration / integration . cc <nl> ppp b / test / integration / integration . cc <nl> void BaseIntegrationTest : : registerTestServerPorts ( const std : : vector < std : : string > <nl> <nl> void BaseIntegrationTest : : createGeneratedApiTestServer ( const std : : string & bootstrap_path , <nl> const std : : vector < std : : string > & port_names ) { <nl> - test_server_ = IntegrationTestServer : : create ( bootstrap_path , version_ ) ; <nl> + test_server_ = <nl> + IntegrationTestServer : : create ( bootstrap_path , version_ , pre_worker_start_test_steps_ ) ; <nl> if ( config_helper_ . bootstrap ( ) . static_resources ( ) . listeners_size ( ) > 0 ) { <nl> / / Wait for listeners to be created before invoking registerTestServerPorts ( ) below , as that <nl> / / needs to know about the bound listener ports . <nl> void BaseIntegrationTest : : createApiTestServer ( const ApiFilesystemConfig & api_fil <nl> void BaseIntegrationTest : : createTestServer ( const std : : string & json_path , <nl> const std : : vector < std : : string > & port_names ) { <nl> test_server_ = IntegrationTestServer : : create ( <nl> - TestEnvironment : : temporaryFileSubstitute ( json_path , port_map_ , version_ ) , version_ ) ; <nl> + TestEnvironment : : temporaryFileSubstitute ( json_path , port_map_ , version_ ) , version_ , nullptr ) ; <nl> registerTestServerPorts ( port_names ) ; <nl> } <nl> <nl> mmm a / test / integration / integration . h <nl> ppp b / test / integration / integration . h <nl> class BaseIntegrationTest : Logger : : Loggable < Logger : : Id : : testing > { <nl> void sendRawHttpAndWaitForResponse ( const char * http , std : : string * response ) ; <nl> <nl> protected : <nl> + bool initialized ( ) const { return initialized_ ; } <nl> + <nl> / / The IpVersion ( IPv4 , IPv6 ) to use . <nl> Network : : Address : : IpVersion version_ ; <nl> / / The config for envoy start - up . <nl> ConfigHelper config_helper_ ; <nl> + / / Steps that should be done prior to the workers starting . E . g . , xDS pre - init . <nl> + std : : function < void ( ) > pre_worker_start_test_steps_ ; <nl> <nl> std : : vector < std : : unique_ptr < FakeUpstream > > fake_upstreams_ ; <nl> spdlog : : level : : level_enum default_log_level_ ; <nl> class BaseIntegrationTest : Logger : : Loggable < Logger : : Id : : testing > { <nl> std : : vector < std : : string > named_ports_ { { " default_port " } } ; <nl> / / If true , use AutonomousUpstream for fake upstreams . <nl> bool autonomous_upstream_ { false } ; <nl> - bool initialized ( ) const { return initialized_ ; } <nl> <nl> private : <nl> / / The codec type for the client - to - Envoy connection <nl> mmm a / test / integration / legacy_json_integration_test . cc <nl> ppp b / test / integration / legacy_json_integration_test . cc <nl> TEST_P ( LegacyJsonIntegrationTest , TestServerXfc ) { <nl> param_map [ " set_current_client_cert_details " ] = " " ; <nl> std : : string config = TestEnvironment : : temporaryFileSubstitute ( <nl> " test / config / integration / server_xfcc . json " , param_map , port_map_ , version_ ) ; <nl> - IntegrationTestServer : : create ( config , version_ ) ; <nl> + IntegrationTestServer : : create ( config , version_ , nullptr ) ; <nl> } <nl> <nl> TEST_P ( LegacyJsonIntegrationTest , TestEchoServer ) { <nl> mmm a / test / integration / server . cc <nl> ppp b / test / integration / server . cc <nl> <nl> <nl> namespace Envoy { <nl> <nl> - IntegrationTestServerPtr IntegrationTestServer : : create ( const std : : string & config_path , <nl> - const Network : : Address : : IpVersion version ) { <nl> + IntegrationTestServerPtr <nl> + IntegrationTestServer : : create ( const std : : string & config_path , <nl> + const Network : : Address : : IpVersion version , <nl> + std : : function < void ( ) > pre_worker_start_test_steps ) { <nl> IntegrationTestServerPtr server { new IntegrationTestServer ( config_path ) } ; <nl> - server - > start ( version ) ; <nl> + server - > start ( version , pre_worker_start_test_steps ) ; <nl> return server ; <nl> } <nl> <nl> - void IntegrationTestServer : : start ( const Network : : Address : : IpVersion version ) { <nl> + void IntegrationTestServer : : start ( const Network : : Address : : IpVersion version , <nl> + std : : function < void ( ) > pre_worker_start_test_steps ) { <nl> ENVOY_LOG ( info , " starting integration test server " ) ; <nl> ASSERT ( ! thread_ ) ; <nl> thread_ . reset ( new Thread : : Thread ( [ version , this ] ( ) - > void { threadRoutine ( version ) ; } ) ) ; <nl> <nl> + / / If any steps need to be done prior to workers starting , do them now . E . g . , xDS pre - init . <nl> + if ( pre_worker_start_test_steps ! = nullptr ) { <nl> + pre_worker_start_test_steps ( ) ; <nl> + } <nl> + <nl> / / Wait for the server to be created and the number of initial listeners to wait for to be set . <nl> server_set_ . waitReady ( ) ; <nl> <nl> mmm a / test / integration / server . h <nl> ppp b / test / integration / server . h <nl> class IntegrationTestServer : Logger : : Loggable < Logger : : Id : : testing > , <nl> public Server : : ComponentFactory { <nl> public : <nl> static IntegrationTestServerPtr create ( const std : : string & config_path , <nl> - const Network : : Address : : IpVersion version ) ; <nl> + const Network : : Address : : IpVersion version , <nl> + std : : function < void ( ) > pre_worker_start_test_steps ) ; <nl> ~ IntegrationTestServer ( ) ; <nl> <nl> Server : : TestDrainManager & drainManager ( ) { return * drain_manager_ ; } <nl> class IntegrationTestServer : Logger : : Loggable < Logger : : Id : : testing > , <nl> void setOnWorkerListenerRemovedCb ( std : : function < void ( ) > on_worker_listener_removed ) { <nl> on_worker_listener_removed_cb_ = on_worker_listener_removed ; <nl> } <nl> - void start ( const Network : : Address : : IpVersion version ) ; <nl> + void start ( const Network : : Address : : IpVersion version , <nl> + std : : function < void ( ) > pre_worker_start_test_steps ) ; <nl> void start ( ) ; <nl> <nl> void waitForCounterGe ( const std : : string & name , uint64_t value ) { <nl>
|
ring hash lb : convert to main thread only ring computations ( )
|
envoyproxy/envoy
|
918be08f4200ec21588ba8177fe47cf675f776cf
|
2017-12-27T04:45:40Z
|
mmm a / tensorflow / python / debug / BUILD <nl> ppp b / tensorflow / python / debug / BUILD <nl> cuda_py_test ( <nl> " : debug_data " , <nl> " : debug_utils " , <nl> " : debugger_cli_common " , <nl> + " : source_utils " , <nl> " / / third_party / py / numpy " , <nl> " @ six_archive / / : six " , <nl> " / / tensorflow : tensorflow_py " , <nl> mmm a / tensorflow / python / debug / cli / analyzer_cli . py <nl> ppp b / tensorflow / python / debug / cli / analyzer_cli . py <nl> def _make_source_table ( self , source_list , is_tf_py_library ) : <nl> <nl> lines . append ( head ) <nl> <nl> - for item in source_list : <nl> - path_attributes = [ debugger_cli_common . MenuItem ( <nl> - None , " ps % s - b % d " % ( item [ 0 ] , item [ 5 ] ) ) , color ] <nl> - <nl> - line = RL ( item [ 0 ] , path_attributes ) <nl> + for ( file_path , _ , num_nodes , num_tensors , num_dumps , <nl> + first_line_num ) in source_list : <nl> + path_attributes = [ color ] <nl> + if source_utils . is_extension_uncompiled_python_source ( file_path ) : <nl> + path_attributes . append ( <nl> + debugger_cli_common . MenuItem ( None , " ps % s - b % d " % <nl> + ( file_path , first_line_num ) ) ) <nl> + <nl> + line = RL ( file_path , path_attributes ) <nl> line + = " " * ( path_column_width - len ( line ) ) <nl> line + = RL ( <nl> - str ( item [ 2 ] ) + " " * ( num_nodes_column_width - len ( str ( item [ 2 ] ) ) ) , <nl> + str ( num_nodes ) + " " * ( num_nodes_column_width - len ( str ( num_nodes ) ) ) , <nl> color ) <nl> line + = RL ( <nl> - str ( item [ 3 ] ) + " " * ( num_tensors_column_width - len ( str ( item [ 3 ] ) ) ) , <nl> - color ) <nl> - line + = RL ( str ( item [ 4 ] ) , color ) <nl> + str ( num_tensors ) + " " * <nl> + ( num_tensors_column_width - len ( str ( num_tensors ) ) ) , color ) <nl> + line + = RL ( str ( num_dumps ) , color ) <nl> lines . append ( line ) <nl> lines . append ( RL ( ) ) <nl> <nl> mmm a / tensorflow / python / debug / cli / analyzer_cli_test . py <nl> ppp b / tensorflow / python / debug / cli / analyzer_cli_test . py <nl> <nl> from tensorflow . python . debug . cli import debugger_cli_common <nl> from tensorflow . python . debug . lib import debug_data <nl> from tensorflow . python . debug . lib import debug_utils <nl> + from tensorflow . python . debug . lib import source_utils <nl> from tensorflow . python . framework import constant_op <nl> from tensorflow . python . framework import test_util <nl> from tensorflow . python . ops import control_flow_ops <nl> def testListSourceWithPathAndNodeNameFiltersWorks ( self ) : <nl> " File path regex filter : \ " % s \ " " % self . _curr_file_path , <nl> " Node name regex filter : \ " . * read \ " " , " " ] , out . lines [ : 4 ] ) <nl> <nl> + def testListSourceWithCompiledPythonSourceWorks ( self ) : <nl> + def fake_list_source_files_against_dump ( dump , <nl> + path_regex_whitelist = None , <nl> + node_name_regex_whitelist = None ) : <nl> + del dump , path_regex_whitelist , node_name_regex_whitelist <nl> + return [ ( " compiled_1 . pyc " , False , 10 , 20 , 30 , 4 ) , <nl> + ( " compiled_2 . pyo " , False , 10 , 20 , 30 , 5 ) , <nl> + ( " uncompiled . py " , False , 10 , 20 , 30 , 6 ) ] <nl> + <nl> + with test . mock . patch . object ( <nl> + source_utils , " list_source_files_against_dump " , <nl> + side_effect = fake_list_source_files_against_dump ) : <nl> + out = self . _registry . dispatch_command ( " list_source " , [ ] ) <nl> + <nl> + self . assertStartsWith ( out . lines [ 4 ] , " compiled_1 . pyc " ) <nl> + self . assertEqual ( ( 0 , 14 , [ cli_shared . COLOR_WHITE ] ) , <nl> + out . font_attr_segs [ 4 ] [ 0 ] ) <nl> + self . assertStartsWith ( out . lines [ 5 ] , " compiled_2 . pyo " ) <nl> + self . assertEqual ( ( 0 , 14 , [ cli_shared . COLOR_WHITE ] ) , <nl> + out . font_attr_segs [ 5 ] [ 0 ] ) <nl> + self . assertStartsWith ( out . lines [ 6 ] , " uncompiled . py " ) <nl> + self . assertEqual ( 0 , out . font_attr_segs [ 6 ] [ 0 ] [ 0 ] ) <nl> + self . assertEqual ( 13 , out . font_attr_segs [ 6 ] [ 0 ] [ 1 ] ) <nl> + self . assertEqual ( cli_shared . COLOR_WHITE , out . font_attr_segs [ 6 ] [ 0 ] [ 2 ] [ 0 ] ) <nl> + self . assertEqual ( " ps uncompiled . py - b 6 " , <nl> + out . font_attr_segs [ 6 ] [ 0 ] [ 2 ] [ 1 ] . content ) <nl> + <nl> <nl> class AnalyzerCLIPrintLargeTensorTest ( test_util . TensorFlowTestCase ) : <nl> <nl> mmm a / tensorflow / python / debug / lib / source_utils . py <nl> ppp b / tensorflow / python / debug / lib / source_utils . py <nl> <nl> os . path . dirname ( os . path . dirname ( os . path . dirname ( <nl> os . path . normpath ( os . path . abspath ( __file__ ) ) ) ) ) ) <nl> <nl> + UNCOMPILED_SOURCE_SUFFIXES = ( " . py " ) <nl> + COMPILED_SOURCE_SUFFIXES = ( " . pyc " , " . pyo " ) <nl> + <nl> + <nl> + def is_extension_uncompiled_python_source ( file_path ) : <nl> + _ , extension = os . path . splitext ( file_path ) <nl> + return extension . lower ( ) in UNCOMPILED_SOURCE_SUFFIXES <nl> + <nl> + <nl> + def is_extension_compiled_python_source ( file_path ) : <nl> + _ , extension = os . path . splitext ( file_path ) <nl> + return extension . lower ( ) in COMPILED_SOURCE_SUFFIXES <nl> + <nl> <nl> def _convert_watch_key_to_tensor_name ( watch_key ) : <nl> return watch_key [ : watch_key . rfind ( " : " ) ] <nl> def _guess_is_tensorflow_py_library ( py_file_path ) : <nl> ( ` bool ` ) Whether the file is a part of the tensorflow library . <nl> <nl> Raises : <nl> - ValueError : if py_file_path does not end with " . py " . <nl> + ValueError : if the extension name of py_file_path does not indicate a Python <nl> + source file ( compiled or uncomplied ) . <nl> " " " <nl> - <nl> - if not py_file_path . endswith ( " . py " ) : <nl> + if ( not is_extension_uncompiled_python_source ( py_file_path ) and <nl> + not is_extension_compiled_python_source ( py_file_path ) ) : <nl> raise ValueError ( <nl> " Input file path ( % s ) is not a Python source file . " % py_file_path ) <nl> py_file_path = os . path . normpath ( os . path . abspath ( py_file_path ) ) <nl> mmm a / tensorflow / python / debug / lib / source_utils_test . py <nl> ppp b / tensorflow / python / debug / lib / source_utils_test . py <nl> def testUnitTestFileReturnsFalse ( self ) : <nl> self . assertFalse ( source_utils . _guess_is_tensorflow_py_library ( <nl> self . curr_file_path ) ) <nl> <nl> - def _disabledtestSourceUtilModuleReturnsTrue ( self ) : <nl> + def testSourceUtilModuleReturnsTrue ( self ) : <nl> self . assertTrue ( source_utils . _guess_is_tensorflow_py_library ( <nl> source_utils . __file__ ) ) <nl> <nl>
|
tfdbg : fix bug related to compiled Python files
|
tensorflow/tensorflow
|
a2019a128c0731b35f1cb4231c996b1af142a0be
|
2017-04-11T23:19:52Z
|
mmm a / CMakeLists . txt <nl> ppp b / CMakeLists . txt <nl> if ( CMAKE_SYSTEM_NAME STREQUAL " Darwin " ) <nl> if ( NOT HAVE_CLOCK_GETTIME ) <nl> set ( DEFINE_CLOCK_GETTIME " - DNO_CLOCK_GETTIME_IN_MAC " ) <nl> endif ( ) <nl> + set ( CMAKE_CPP_FLAGS " $ { CMAKE_CPP_FLAGS } - Wno - deprecated - declarations - Wno - inconsistent - missing - override " ) <nl> endif ( ) <nl> <nl> - set ( CMAKE_CPP_FLAGS " $ { DEFINE_CLOCK_GETTIME } - DBRPC_WITH_GLOG = $ { WITH_GLOG_VAL } - DGFLAGS_NS = $ { GFLAGS_NS } " ) <nl> + set ( CMAKE_CPP_FLAGS " $ { CMAKE_CPP_FLAGS } $ { DEFINE_CLOCK_GETTIME } - DBRPC_WITH_GLOG = $ { WITH_GLOG_VAL } - DGFLAGS_NS = $ { GFLAGS_NS } " ) <nl> if ( WITH_MESALINK ) <nl> set ( CMAKE_CPP_FLAGS " $ { CMAKE_CPP_FLAGS } - DUSE_MESALINK " ) <nl> endif ( ) <nl> mmm a / config_brpc . sh <nl> ppp b / config_brpc . sh <nl> if [ ! - z " $ DEBUGSYMBOLS " ] ; then <nl> CPPFLAGS = " $ { CPPFLAGS } $ DEBUGSYMBOLS " <nl> fi <nl> if [ " $ SYSTEM " = " Darwin " ] ; then <nl> - CPPFLAGS = " $ { CPPFLAGS } - Wno - deprecated - declarations " <nl> + CPPFLAGS = " $ { CPPFLAGS } - Wno - deprecated - declarations - Wno - inconsistent - missing - override " <nl> version = ` sw_vers - productVersion | awk - F ' . ' ' { print $ 1 " . " $ 2 } ' ` <nl> if [ [ ` echo " $ version < 10 . 12 " | bc - l ` = = 1 ] ] ; then <nl> CPPFLAGS = " $ { CPPFLAGS } - DNO_CLOCK_GETTIME_IN_MAC " <nl> mmm a / src / brpc / builtin / hotspots_service . cpp <nl> ppp b / src / brpc / builtin / hotspots_service . cpp <nl> static std : : string GeneratePerlScriptPath ( const std : : string & filename ) { <nl> path + = FLAGS_rpc_profiling_dir ; <nl> path . push_back ( ' / ' ) ; <nl> path + = filename ; <nl> - return std : : move ( path ) ; <nl> + return path ; <nl> } <nl> <nl> extern bool cpu_profiler_enabled ; <nl> mmm a / src / brpc / policy / http_rpc_protocol . cpp <nl> ppp b / src / brpc / policy / http_rpc_protocol . cpp <nl> void SerializeHttpRequest ( butil : : IOBuf * / * not used * / , <nl> hreq . SetHeader ( common - > TE , common - > TRAILERS ) ; <nl> if ( cntl - > timeout_ms ( ) > = 0 ) { <nl> hreq . SetHeader ( common - > GRPC_TIMEOUT , <nl> - butil : : string_printf ( " % ldm " , cntl - > timeout_ms ( ) ) ) ; <nl> + butil : : string_printf ( " % " PRId64 , cntl - > timeout_ms ( ) ) ) ; <nl> } <nl> / / Append compressed and length before body <nl> AddGrpcPrefix ( & cntl - > request_attachment ( ) , grpc_compressed ) ; <nl> mmm a / src / brpc / redis . h <nl> ppp b / src / brpc / redis . h <nl> enum RedisCommandHandlerResult { <nl> / / The Command handler for a redis request . User should impletement Run ( ) . <nl> class RedisCommandHandler { <nl> public : <nl> - ~ RedisCommandHandler ( ) { } <nl> + virtual ~ RedisCommandHandler ( ) { } <nl> <nl> / / Once Server receives commands , it will first find the corresponding handlers and <nl> / / call them sequentially ( one by one ) according to the order that requests arrive , <nl> mmm a / src / brpc / rpc_dump . h <nl> ppp b / src / brpc / rpc_dump . h <nl> DECLARE_bool ( rpc_dump ) ; <nl> / / In practice , sampled requests are just small fraction of all requests . <nl> / / The overhead of sampling should be negligible for overall performance . <nl> <nl> - struct SampledRequest : public bvar : : Collected { <nl> + class SampledRequest : public bvar : : Collected { <nl> + public : <nl> butil : : IOBuf request ; <nl> RpcDumpMeta meta ; <nl> <nl> mmm a / src / bthread / fd . cpp <nl> ppp b / src / bthread / fd . cpp <nl> short epoll_to_poll_events ( uint32_t epoll_events ) { <nl> return poll_events ; <nl> } <nl> # elif defined ( OS_MACOSX ) <nl> - short kqueue_to_poll_events ( uint32_t kqueue_events ) { <nl> + static short kqueue_to_poll_events ( int kqueue_events ) { <nl> / / TODO : add more values ? <nl> short poll_events = 0 ; <nl> if ( kqueue_events = = EVFILT_READ ) { <nl> mmm a / src / butil / binary_printer . cpp <nl> ppp b / src / butil / binary_printer . cpp <nl> static void PrintIOBuf ( Appender * appender , const IOBuf & b , size_t max_length ) { <nl> printer . Flush ( ) ; <nl> char buf [ 48 ] ; <nl> int len = snprintf ( buf , sizeof ( buf ) , " . . . < skipping % " PRIu64 " bytes > " , <nl> - b . size ( ) - nw ) ; <nl> + ( uint64_t ) ( b . size ( ) - nw ) ) ; <nl> appender - > Append ( buf , len ) ; <nl> return ; <nl> } <nl> static void PrintString ( Appender * appender , const StringPiece & s , size_t max_len <nl> printer . Flush ( ) ; <nl> char buf [ 48 ] ; <nl> int len = snprintf ( buf , sizeof ( buf ) , " . . . < skipping % " PRIu64 " bytes > " , <nl> - s . size ( ) - i ) ; <nl> + ( uint64_t ) ( s . size ( ) - i ) ) ; <nl> appender - > Append ( buf , len ) ; <nl> return ; <nl> } <nl> mmm a / src / bvar / detail / sampler . cpp <nl> ppp b / src / bvar / detail / sampler . cpp <nl> class SamplerCollector : public bvar : : Reducer < Sampler * , CombineSampler > { <nl> private : <nl> bool _created ; <nl> bool _stop ; <nl> - pid_t _created_pid ; <nl> int64_t _cumulated_time_us ; <nl> pthread_t _tid ; <nl> } ; <nl> mmm a / tools / CMakeLists . txt <nl> ppp b / tools / CMakeLists . txt <nl> <nl> # specific language governing permissions and limitations <nl> # under the License . <nl> <nl> - set ( CMAKE_CPP_FLAGS " $ { DEFINE_CLOCK_GETTIME } - DBRPC_WITH_GLOG = $ { WITH_GLOG_VAL } - DGFLAGS_NS = $ { GFLAGS_NS } " ) <nl> - set ( CMAKE_CXX_FLAGS " $ { CMAKE_CPP_FLAGS } - DNDEBUG - O2 - D__const__ = - D__STRICT_ANSI__ - pipe - W - Wall - Wno - unused - parameter - fPIC - fno - omit - frame - pointer " ) <nl> - use_cxx11 ( ) <nl> set ( EXECUTABLE_OUTPUT_PATH $ { PROJECT_BINARY_DIR } / output / bin ) <nl> <nl> add_subdirectory ( parallel_http ) <nl>
|
fix warnings on MACOS
|
apache/incubator-brpc
|
9f510165bcefc9fd40e6342b8793f7762dddbcb8
|
2020-01-21T08:25:30Z
|
mmm a / xbmc / cores / AudioEngine / Engines / SoftAE / SoftAE . cpp <nl> ppp b / xbmc / cores / AudioEngine / Engines / SoftAE / SoftAE . cpp <nl> int CSoftAE : : RunOutputStage ( bool hasAudio ) <nl> data = m_converted ; <nl> } <nl> <nl> - wroteFrames = m_sink - > AddPackets ( ( uint8_t * ) data , m_sinkFormat . m_frames ) ; <nl> + wroteFrames = m_sink - > AddPackets ( ( uint8_t * ) data , m_sinkFormat . m_frames , hasAudio ) ; <nl> <nl> / * Return value of INT_MAX signals error in sink - restart * / <nl> if ( wroteFrames = = INT_MAX ) <nl> int CSoftAE : : RunRawOutputStage ( bool hasAudio ) <nl> data = m_converted ; <nl> } <nl> <nl> - int wroteFrames = m_sink - > AddPackets ( ( uint8_t * ) data , m_sinkFormat . m_frames ) ; <nl> + int wroteFrames = m_sink - > AddPackets ( ( uint8_t * ) data , m_sinkFormat . m_frames , hasAudio ) ; <nl> <nl> / * Return value of INT_MAX signals error in sink - restart * / <nl> if ( wroteFrames = = INT_MAX ) <nl> int CSoftAE : : RunTranscodeStage ( bool hasAudio ) <nl> / * if we have enough data to write * / <nl> if ( m_encodedBuffer . Used ( ) > = sinkBlock ) <nl> { <nl> - int wroteFrames = m_sink - > AddPackets ( ( uint8_t * ) m_encodedBuffer . Raw ( sinkBlock ) , m_sinkFormat . m_frames ) ; <nl> + int wroteFrames = m_sink - > AddPackets ( ( uint8_t * ) m_encodedBuffer . Raw ( sinkBlock ) , m_sinkFormat . m_frames , hasAudio ) ; <nl> <nl> / * Return value of INT_MAX signals error in sink - restart * / <nl> if ( wroteFrames = = INT_MAX ) <nl> mmm a / xbmc / cores / AudioEngine / Interfaces / AESink . h <nl> ppp b / xbmc / cores / AudioEngine / Interfaces / AESink . h <nl> class IAESink <nl> / * <nl> Adds packets to be sent out , this routine MUST block or sleep . <nl> * / <nl> - virtual unsigned int AddPackets ( uint8_t * data , unsigned int frames ) = 0 ; <nl> + virtual unsigned int AddPackets ( uint8_t * data , unsigned int frames , bool hasAudio ) = 0 ; <nl> <nl> / * <nl> Drain the sink <nl> mmm a / xbmc / cores / AudioEngine / Sinks / AESinkALSA . cpp <nl> ppp b / xbmc / cores / AudioEngine / Sinks / AESinkALSA . cpp <nl> double CAESinkALSA : : GetCacheTotal ( ) <nl> return ( double ) m_bufferSize * m_formatSampleRateMul ; <nl> } <nl> <nl> - unsigned int CAESinkALSA : : AddPackets ( uint8_t * data , unsigned int frames ) <nl> + unsigned int CAESinkALSA : : AddPackets ( uint8_t * data , unsigned int frames , bool hasAudio ) <nl> { <nl> if ( ! m_pcm ) <nl> return 0 ; <nl> mmm a / xbmc / cores / AudioEngine / Sinks / AESinkALSA . h <nl> ppp b / xbmc / cores / AudioEngine / Sinks / AESinkALSA . h <nl> class CAESinkALSA : public IAESink <nl> virtual double GetDelay ( ) ; <nl> virtual double GetCacheTime ( ) ; <nl> virtual double GetCacheTotal ( ) ; <nl> - virtual unsigned int AddPackets ( uint8_t * data , unsigned int frames ) ; <nl> + virtual unsigned int AddPackets ( uint8_t * data , unsigned int frames , bool hasAudio ) ; <nl> virtual void Drain ( ) ; <nl> <nl> static void EnumerateDevicesEx ( AEDeviceInfoList & list ) ; <nl> mmm a / xbmc / cores / AudioEngine / Sinks / AESinkDirectSound . h <nl> ppp b / xbmc / cores / AudioEngine / Sinks / AESinkDirectSound . h <nl> class CAESinkDirectSound : public IAESink <nl> virtual double GetDelay ( ) ; <nl> virtual double GetCacheTime ( ) ; <nl> virtual double GetCacheTotal ( ) ; <nl> - virtual unsigned int AddPackets ( uint8_t * data , unsigned int frames ) ; <nl> + virtual unsigned int AddPackets ( uint8_t * data , unsigned int frames , bool hasAudio ) ; <nl> static void EnumerateDevicesEx ( AEDeviceInfoList & deviceInfoList ) ; <nl> private : <nl> void AEChannelsFromSpeakerMask ( DWORD speakers ) ; <nl> mmm a / xbmc / cores / AudioEngine / Sinks / AESinkNULL . cpp <nl> ppp b / xbmc / cores / AudioEngine / Sinks / AESinkNULL . cpp <nl> double CAESinkNULL : : GetDelay ( ) <nl> return std : : max ( 0 . 0 , ( double ) ( m_ts - CurrentHostCounter ( ) ) / 1000000 . 0f ) ; <nl> } <nl> <nl> - unsigned int CAESinkNULL : : AddPackets ( uint8_t * data , unsigned int frames ) <nl> + unsigned int CAESinkNULL : : AddPackets ( uint8_t * data , unsigned int frames , bool hasAudio ) <nl> { <nl> float timeout = m_msPerFrame * frames ; <nl> m_ts = CurrentHostCounter ( ) + MathUtils : : round_int ( timeout * 1000000 . 0f ) ; <nl> mmm a / xbmc / cores / AudioEngine / Sinks / AESinkNULL . h <nl> ppp b / xbmc / cores / AudioEngine / Sinks / AESinkNULL . h <nl> class CAESinkNULL : public IAESink <nl> virtual double GetDelay ( ) ; <nl> virtual double GetCacheTime ( ) { return 0 . 0 ; } <nl> virtual double GetCacheTotal ( ) { return 0 . 0 ; } <nl> - virtual unsigned int AddPackets ( uint8_t * data , unsigned int frames ) ; <nl> + virtual unsigned int AddPackets ( uint8_t * data , unsigned int frames , bool hasAudio ) ; <nl> virtual void Drain ( ) ; <nl> static void EnumerateDevices ( AEDeviceList & devices , bool passthrough ) ; <nl> private : <nl> mmm a / xbmc / cores / AudioEngine / Sinks / AESinkOSS . cpp <nl> ppp b / xbmc / cores / AudioEngine / Sinks / AESinkOSS . cpp <nl> double CAESinkOSS : : GetDelay ( ) <nl> return ( double ) delay / ( m_format . m_frameSize * m_format . m_sampleRate ) ; <nl> } <nl> <nl> - unsigned int CAESinkOSS : : AddPackets ( uint8_t * data , unsigned int frames ) <nl> + unsigned int CAESinkOSS : : AddPackets ( uint8_t * data , unsigned int frames , bool hasAudio ) <nl> { <nl> int size = frames * m_format . m_frameSize ; <nl> int wrote = write ( m_fd , data , size ) ; <nl> mmm a / xbmc / cores / AudioEngine / Sinks / AESinkOSS . h <nl> ppp b / xbmc / cores / AudioEngine / Sinks / AESinkOSS . h <nl> class CAESinkOSS : public IAESink <nl> virtual double GetDelay ( ) ; <nl> virtual double GetCacheTime ( ) { return 0 . 0 ; } / * FIXME * / <nl> virtual double GetCacheTotal ( ) { return 0 . 0 ; } / * FIXME * / <nl> - virtual unsigned int AddPackets ( uint8_t * data , unsigned int frames ) ; <nl> + virtual unsigned int AddPackets ( uint8_t * data , unsigned int frames , bool hasAudio ) ; <nl> virtual void Drain ( ) ; <nl> static void EnumerateDevicesEx ( AEDeviceInfoList & list ) ; <nl> private : <nl> mmm a / xbmc / cores / AudioEngine / Sinks / AESinkProfiler . cpp <nl> ppp b / xbmc / cores / AudioEngine / Sinks / AESinkProfiler . cpp <nl> double CAESinkProfiler : : GetDelay ( ) <nl> return 0 . 0f ; <nl> } <nl> <nl> - unsigned int CAESinkProfiler : : AddPackets ( uint8_t * data , unsigned int frames ) <nl> + unsigned int CAESinkProfiler : : AddPackets ( uint8_t * data , unsigned int frames , bool hasAudio ) <nl> { <nl> int64_t ts = CurrentHostCounter ( ) ; <nl> CLog : : Log ( LOGDEBUG , " CAESinkProfiler : : AddPackets - latency % f ms " , ( float ) ( ts - m_ts ) / 1000000 . 0f ) ; <nl> mmm a / xbmc / cores / AudioEngine / Sinks / AESinkProfiler . h <nl> ppp b / xbmc / cores / AudioEngine / Sinks / AESinkProfiler . h <nl> class CAESinkProfiler : public IAESink <nl> virtual double GetDelay ( ) ; <nl> virtual double GetCacheTime ( ) { return 0 . 0 ; } <nl> virtual double GetCacheTotal ( ) { return 0 . 0 ; } <nl> - virtual unsigned int AddPackets ( uint8_t * data , unsigned int frames ) ; <nl> + virtual unsigned int AddPackets ( uint8_t * data , unsigned int frames , bool hasAudio ) ; <nl> virtual void Drain ( ) ; <nl> static void EnumerateDevices ( AEDeviceList & devices , bool passthrough ) ; <nl> private : <nl> mmm a / xbmc / cores / AudioEngine / Sinks / AESinkWASAPI . cpp <nl> ppp b / xbmc / cores / AudioEngine / Sinks / AESinkWASAPI . cpp <nl> double CAESinkWASAPI : : GetCacheTotal ( ) <nl> return hnsLatency / 10 . 0 ; <nl> } <nl> <nl> - unsigned int CAESinkWASAPI : : AddPackets ( uint8_t * data , unsigned int frames ) <nl> + unsigned int CAESinkWASAPI : : AddPackets ( uint8_t * data , unsigned int frames , bool hasAudio ) <nl> { <nl> if ( ! m_initialized ) <nl> return 0 ; <nl> mmm a / xbmc / cores / AudioEngine / Sinks / AESinkWASAPI . h <nl> ppp b / xbmc / cores / AudioEngine / Sinks / AESinkWASAPI . h <nl> class CAESinkWASAPI : public IAESink <nl> virtual double GetDelay ( ) ; <nl> virtual double GetCacheTime ( ) ; <nl> virtual double GetCacheTotal ( ) ; <nl> - virtual unsigned int AddPackets ( uint8_t * data , unsigned int frames ) ; <nl> + virtual unsigned int AddPackets ( uint8_t * data , unsigned int frames , bool hasAudio ) ; <nl> static void EnumerateDevicesEx ( AEDeviceInfoList & deviceInfoList ) ; <nl> private : <nl> bool InitializeExclusive ( AEAudioFormat & format ) ; <nl>
|
[ SoftAE ] pass audio / silence down to the sink so it can decide if it wants to output
|
xbmc/xbmc
|
74ba6a57b49221153150399dbed37b0031da4ec0
|
2012-07-11T03:37:52Z
|
mmm a / lib / Immediate / Immediate . cpp <nl> ppp b / lib / Immediate / Immediate . cpp <nl> static bool IRGenImportedModules ( CompilerInstance & CI , <nl> } ; <nl> std : : for_each ( Options . LinkLibraries . begin ( ) , Options . LinkLibraries . end ( ) , <nl> addLinkLibrary ) ; <nl> - M - > forAllVisibleModules ( Module : : AccessPathTy ( ) , <nl> + M - > forAllVisibleModules ( { } , / * includePrivateTopLevel = * / true , <nl> [ & ] ( Module : : ImportedModule import ) { <nl> import . second - > collectLinkLibraries ( addLinkLibrary ) ; <nl> } ) ; <nl> new file mode 100644 <nl> index 000000000000 . . d92dbb23cbec <nl> mmm / dev / null <nl> ppp b / test / Interpreter / SDK / Cocoa_repl . swift <nl> <nl> + / / RUN : rm - rf % t / clang - module - cache <nl> + / / RUN : % swift - module - cache - path = % t / clang - module - cache - sdk = % sdk - repl < % s | FileCheck % s <nl> + / / REQUIRES : sdk <nl> + / / REQUIRES : swift_repl <nl> + <nl> + import Cocoa <nl> + <nl> + / / CHECK : 0 { { $ } } <nl> + println ( NSNumber ( withInteger : 0 ) . description ( ) ) <nl>
|
When autolinking in immediate mode , make sure we ' re checking private imports . . .
|
apple/swift
|
81e13fb60d6a6d650492a08a0a35edd745d4f28a
|
2014-01-20T23:25:05Z
|
mmm a / selfdrive / modeld / modeld . cc <nl> ppp b / selfdrive / modeld / modeld . cc <nl> int main ( int argc , char * * argv ) { <nl> <nl> / / messaging <nl> PubMaster pm ( { " model " , " cameraOdometry " } ) ; <nl> - SubMaster sm ( { " pathPlan " } ) ; <nl> + SubMaster sm ( { " pathPlan " , " frame " } ) ; <nl> <nl> # ifdef QCOM <nl> cl_device_type device_type = CL_DEVICE_TYPE_DEFAULT ; <nl> int main ( int argc , char * * argv ) { <nl> } <nl> <nl> mat3 model_transform = matmul3 ( yuv_transform , transform ) ; <nl> + uint32_t frame_id = sm [ " frame " ] . getFrame ( ) . getFrameId ( ) ; <nl> <nl> mt1 = millis_since_boot ( ) ; <nl> <nl> int main ( int argc , char * * argv ) { <nl> model_transform , NULL , vec_desire ) ; <nl> mt2 = millis_since_boot ( ) ; <nl> <nl> - model_publish ( pm , extra . frame_id , model_buf , extra . timestamp_eof ) ; <nl> - posenet_publish ( pm , extra . frame_id , model_buf , extra . timestamp_eof ) ; <nl> + model_publish ( pm , extra . frame_id , frame_id , model_buf , extra . timestamp_eof ) ; <nl> + posenet_publish ( pm , extra . frame_id , frame_id , model_buf , extra . timestamp_eof ) ; <nl> <nl> - LOGD ( " model process : % . 2fms , from last % . 2fms " , mt2 - mt1 , mt1 - last ) ; <nl> + LOGD ( " model process : % . 2fms , from last % . 2fms , vipc_frame_id % zu , frame_id , % zu " , mt2 - mt1 , mt1 - last , extra . frame_id , frame_id ) ; <nl> last = mt1 ; <nl> } <nl> <nl> mmm a / selfdrive / modeld / models / driving . cc <nl> ppp b / selfdrive / modeld / models / driving . cc <nl> void fill_longi ( cereal : : ModelData : : LongitudinalData : : Builder longi , const float <nl> longi . setAccelerations ( accel ) ; <nl> } <nl> <nl> - void model_publish ( PubMaster & pm , uint32_t frame_id , <nl> + void model_publish ( PubMaster & pm , uint32_t vipc_frame_id , uint32_t frame_id , <nl> const ModelDataRaw & net_outputs , uint64_t timestamp_eof ) { <nl> / / make msg <nl> capnp : : MallocMessageBuilder msg ; <nl> void model_publish ( PubMaster & pm , uint32_t frame_id , <nl> event . setLogMonoTime ( nanos_since_boot ( ) ) ; <nl> <nl> auto framed = event . initModel ( ) ; <nl> - framed . setFrameId ( frame_id ) ; <nl> + framed . setFrameId ( vipc_frame_id ) ; <nl> framed . setTimestampEof ( timestamp_eof ) ; <nl> <nl> auto lpath = framed . initPath ( ) ; <nl> void model_publish ( PubMaster & pm , uint32_t frame_id , <nl> <nl> auto meta = framed . initMeta ( ) ; <nl> fill_meta ( meta , net_outputs . meta ) ; <nl> + event . setValid ( frame_id - vipc_frame_id < MAX_FRAME_AGE ) ; <nl> <nl> pm . send ( " model " , msg ) ; <nl> } <nl> <nl> - void posenet_publish ( PubMaster & pm , uint32_t frame_id , <nl> + void posenet_publish ( PubMaster & pm , uint32_t vipc_frame_id , uint32_t frame_id , <nl> const ModelDataRaw & net_outputs , uint64_t timestamp_eof ) { <nl> capnp : : MallocMessageBuilder msg ; <nl> cereal : : Event : : Builder event = msg . initRoot < cereal : : Event > ( ) ; <nl> void posenet_publish ( PubMaster & pm , uint32_t frame_id , <nl> posenetd . setRotStd ( rot_std_vs ) ; <nl> <nl> posenetd . setTimestampEof ( timestamp_eof ) ; <nl> - posenetd . setFrameId ( frame_id ) ; <nl> + posenetd . setFrameId ( vipc_frame_id ) ; <nl> + event . setValid ( frame_id - vipc_frame_id < MAX_FRAME_AGE ) ; <nl> <nl> pm . send ( " cameraOdometry " , msg ) ; <nl> } <nl> mmm a / selfdrive / modeld / models / driving . h <nl> ppp b / selfdrive / modeld / models / driving . h <nl> <nl> # define TIME_DISTANCE 100 <nl> # define POSE_SIZE 12 <nl> <nl> + # define MAX_FRAME_AGE 5 <nl> + <nl> struct ModelDataRaw { <nl> float * path ; <nl> float * left_lane ; <nl> ModelDataRaw model_eval_frame ( ModelState * s , cl_command_queue q , <nl> void model_free ( ModelState * s ) ; <nl> void poly_fit ( float * in_pts , float * in_stds , float * out ) ; <nl> <nl> - void model_publish ( PubMaster & pm , uint32_t frame_id , <nl> + void model_publish ( PubMaster & pm , uint32_t vipc_frame_id , uint32_t frame_id , <nl> const ModelDataRaw & data , uint64_t timestamp_eof ) ; <nl> - void posenet_publish ( PubMaster & pm , uint32_t frame_id , <nl> + void posenet_publish ( PubMaster & pm , uint32_t vipc_frame_id , uint32_t frame_id , <nl> const ModelDataRaw & data , uint64_t timestamp_eof ) ; <nl> # endif <nl>
|
Make model packets invalid when frames are too old ( )
|
commaai/openpilot
|
88f92663780665b27fafdb5ab86ad501cad4cbcf
|
2020-06-22T21:27:58Z
|
mmm a / core - tests / include / httplib_client . h <nl> ppp b / core - tests / include / httplib_client . h <nl> <nl> * Copyright ( c ) 2020 Yuji Hirose . All rights reserved . <nl> * MIT License <nl> * GitHub : https : / / github . com / yhirose / cpp - httplib <nl> - * / <nl> + * / <nl> <nl> # pragma once <nl> <nl> + # include " websocket . h " <nl> + <nl> / * <nl> * Configuration <nl> * / <nl> <nl> # endif <nl> <nl> # ifndef CPPHTTPLIB_TCP_NODELAY <nl> - # define CPPHTTPLIB_TCP_NODELAY false <nl> + # define CPPHTTPLIB_TCP_NODELAY true <nl> # endif <nl> <nl> # ifndef CPPHTTPLIB_RECV_BUFSIZ <nl> <nl> # endif <nl> <nl> # ifndef CPPHTTPLIB_THREAD_POOL_COUNT <nl> - # define CPPHTTPLIB_THREAD_POOL_COUNT \ <nl> - ( ( std : : max ) ( 8u , std : : thread : : hardware_concurrency ( ) > 0 \ <nl> - ? std : : thread : : hardware_concurrency ( ) - 1 \ <nl> - : 0 ) ) <nl> + # define CPPHTTPLIB_THREAD_POOL_COUNT \ <nl> + ( ( std : : max ) ( 8u , std : : thread : : hardware_concurrency ( ) > 0 ? std : : thread : : hardware_concurrency ( ) - 1 : 0 ) ) <nl> # endif <nl> <nl> / / Prefer gnu : : deprecated , otherwise gcc complains if we use <nl> <nl> # ifdef _WIN32 <nl> # ifndef _CRT_SECURE_NO_WARNINGS <nl> # define _CRT_SECURE_NO_WARNINGS <nl> - # endif / / _CRT_SECURE_NO_WARNINGS <nl> + # endif / / _CRT_SECURE_NO_WARNINGS <nl> <nl> # ifndef _CRT_NONSTDC_NO_DEPRECATE <nl> # define _CRT_NONSTDC_NO_DEPRECATE <nl> - # endif / / _CRT_NONSTDC_NO_DEPRECATE <nl> + # endif / / _CRT_NONSTDC_NO_DEPRECATE <nl> <nl> # if defined ( _MSC_VER ) <nl> # ifdef _WIN64 <nl> using ssize_t = int ; <nl> # if _MSC_VER < 1900 <nl> # define snprintf _snprintf_s <nl> # endif <nl> - # endif / / _MSC_VER <nl> + # endif / / _MSC_VER <nl> <nl> # ifndef S_ISREG <nl> - # define S_ISREG ( m ) ( ( ( m ) & S_IFREG ) = = S_IFREG ) <nl> - # endif / / S_ISREG <nl> + # define S_ISREG ( m ) ( ( ( m ) & S_IFREG ) = = S_IFREG ) <nl> + # endif / / S_ISREG <nl> <nl> # ifndef S_ISDIR <nl> - # define S_ISDIR ( m ) ( ( ( m ) & S_IFDIR ) = = S_IFDIR ) <nl> - # endif / / S_ISDIR <nl> + # define S_ISDIR ( m ) ( ( ( m ) & S_IFDIR ) = = S_IFDIR ) <nl> + # endif / / S_ISDIR <nl> <nl> # ifndef NOMINMAX <nl> # define NOMINMAX <nl> - # endif / / NOMINMAX <nl> + # endif / / NOMINMAX <nl> <nl> # include < io . h > <nl> # include < winsock2 . h > <nl> using ssize_t = int ; <nl> <nl> # ifndef strcasecmp <nl> # define strcasecmp _stricmp <nl> - # endif / / strcasecmp <nl> + # endif / / strcasecmp <nl> <nl> using socket_t = SOCKET ; <nl> # ifdef CPPHTTPLIB_USE_POLL <nl> # define poll ( fds , nfds , timeout ) WSAPoll ( fds , nfds , timeout ) <nl> # endif <nl> <nl> - # else / / not _WIN32 <nl> + # else / / not _WIN32 <nl> <nl> # include < arpa / inet . h > <nl> # include < cstring > <nl> using socket_t = SOCKET ; <nl> <nl> using socket_t = int ; <nl> # define INVALID_SOCKET ( - 1 ) <nl> - # endif / / _WIN32 <nl> + # endif / / _WIN32 <nl> <nl> # include < array > <nl> # include < atomic > <nl> using socket_t = int ; <nl> # if OPENSSL_VERSION_NUMBER < 0x10100000L <nl> # include < openssl / crypto . h > <nl> inline const unsigned char * ASN1_STRING_get0_data ( const ASN1_STRING * asn1 ) { <nl> - return M_ASN1_STRING_data ( asn1 ) ; <nl> + return M_ASN1_STRING_data ( asn1 ) ; <nl> } <nl> # endif <nl> # endif <nl> const std : : string USER_AGENT = " cpp - httplib / 0 . 7 " ; <nl> namespace detail { <nl> <nl> struct ci { <nl> - bool operator ( ) ( const std : : string & s1 , const std : : string & s2 ) const { <nl> - return std : : lexicographical_compare ( <nl> - s1 . begin ( ) , s1 . end ( ) , s2 . begin ( ) , s2 . end ( ) , <nl> - [ ] ( char c1 , char c2 ) { return : : tolower ( c1 ) < : : tolower ( c2 ) ; } ) ; <nl> - } <nl> + bool operator ( ) ( const std : : string & s1 , const std : : string & s2 ) const { <nl> + return std : : lexicographical_compare ( <nl> + s1 . begin ( ) , s1 . end ( ) , s2 . begin ( ) , s2 . end ( ) , [ ] ( char c1 , char c2 ) { return : : tolower ( c1 ) < : : tolower ( c2 ) ; } ) ; <nl> + } <nl> } ; <nl> <nl> - } / / namespace detail <nl> + } / / namespace detail <nl> <nl> using Headers = std : : multimap < std : : string , std : : string , detail : : ci > ; <nl> <nl> using Match = std : : smatch ; <nl> using Progress = std : : function < bool ( uint64_t current , uint64_t total ) > ; <nl> <nl> struct Response ; <nl> + struct WebSocketFrame ; <nl> + <nl> using ResponseHandler = std : : function < bool ( const Response & response ) > ; <nl> <nl> struct MultipartFormData { <nl> - std : : string name ; <nl> - std : : string content ; <nl> - std : : string filename ; <nl> - std : : string content_type ; <nl> + std : : string name ; <nl> + std : : string content ; <nl> + std : : string filename ; <nl> + std : : string content_type ; <nl> } ; <nl> using MultipartFormDataItems = std : : vector < MultipartFormData > ; <nl> using MultipartFormDataMap = std : : multimap < std : : string , MultipartFormData > ; <nl> <nl> class DataSink { <nl> - public : <nl> - DataSink ( ) : os ( & sb_ ) , sb_ ( * this ) { } <nl> - <nl> - DataSink ( const DataSink & ) = delete ; <nl> - DataSink & operator = ( const DataSink & ) = delete ; <nl> - DataSink ( DataSink & & ) = delete ; <nl> - DataSink & operator = ( DataSink & & ) = delete ; <nl> - <nl> - std : : function < void ( const char * data , size_t data_len ) > write ; <nl> - std : : function < void ( ) > done ; <nl> - std : : function < bool ( ) > is_writable ; <nl> - std : : ostream os ; <nl> - <nl> - private : <nl> - class data_sink_streambuf : public std : : streambuf { <nl> public : <nl> - data_sink_streambuf ( DataSink & sink ) : sink_ ( sink ) { } <nl> + DataSink ( ) : os ( & sb_ ) , sb_ ( * this ) { } <nl> <nl> - protected : <nl> - std : : streamsize xsputn ( const char * s , std : : streamsize n ) { <nl> - sink_ . write ( s , static_cast < size_t > ( n ) ) ; <nl> - return n ; <nl> - } <nl> + DataSink ( const DataSink & ) = delete ; <nl> + DataSink & operator = ( const DataSink & ) = delete ; <nl> + DataSink ( DataSink & & ) = delete ; <nl> + DataSink & operator = ( DataSink & & ) = delete ; <nl> + <nl> + std : : function < void ( const char * data , size_t data_len ) > write ; <nl> + std : : function < void ( ) > done ; <nl> + std : : function < bool ( ) > is_writable ; <nl> + std : : ostream os ; <nl> <nl> private : <nl> - DataSink & sink_ ; <nl> - } ; <nl> + class data_sink_streambuf : public std : : streambuf { <nl> + public : <nl> + data_sink_streambuf ( DataSink & sink ) : sink_ ( sink ) { } <nl> + <nl> + protected : <nl> + std : : streamsize xsputn ( const char * s , std : : streamsize n ) { <nl> + sink_ . write ( s , static_cast < size_t > ( n ) ) ; <nl> + return n ; <nl> + } <nl> + <nl> + private : <nl> + DataSink & sink_ ; <nl> + } ; <nl> <nl> - data_sink_streambuf sb_ ; <nl> + data_sink_streambuf sb_ ; <nl> } ; <nl> <nl> - using ContentProvider = <nl> - std : : function < bool ( size_t offset , size_t length , DataSink & sink ) > ; <nl> + using ContentProvider = std : : function < bool ( size_t offset , size_t length , DataSink & sink ) > ; <nl> <nl> - using ChunkedContentProvider = <nl> - std : : function < bool ( size_t offset , DataSink & sink ) > ; <nl> + using ChunkedContentProvider = std : : function < bool ( size_t offset , DataSink & sink ) > ; <nl> <nl> - using ContentReceiver = <nl> - std : : function < bool ( const char * data , size_t data_length ) > ; <nl> + using ContentReceiver = std : : function < bool ( const char * data , size_t data_length ) > ; <nl> <nl> - using MultipartContentHeader = <nl> - std : : function < bool ( const MultipartFormData & file ) > ; <nl> + using MultipartContentHeader = std : : function < bool ( const MultipartFormData & file ) > ; <nl> <nl> using Range = std : : pair < ssize_t , ssize_t > ; <nl> using Ranges = std : : vector < Range > ; <nl> <nl> struct Request { <nl> - std : : string method ; <nl> - std : : string path ; <nl> - Headers headers ; <nl> - std : : string body ; <nl> - <nl> - std : : string remote_addr ; <nl> - int remote_port = - 1 ; <nl> - <nl> - / / for server <nl> - std : : string version ; <nl> - std : : string target ; <nl> - Params params ; <nl> - MultipartFormDataMap files ; <nl> - Ranges ranges ; <nl> - Match matches ; <nl> - <nl> - / / for client <nl> - size_t redirect_count = CPPHTTPLIB_REDIRECT_MAX_COUNT ; <nl> - ResponseHandler response_handler ; <nl> - ContentReceiver content_receiver ; <nl> - size_t content_length = 0 ; <nl> - ContentProvider content_provider ; <nl> - Progress progress ; <nl> + std : : string method ; <nl> + std : : string path ; <nl> + Headers headers ; <nl> + std : : string body ; <nl> + <nl> + std : : string remote_addr ; <nl> + int remote_port = - 1 ; <nl> + <nl> + / / for server <nl> + std : : string version ; <nl> + std : : string target ; <nl> + Params params ; <nl> + MultipartFormDataMap files ; <nl> + Ranges ranges ; <nl> + Match matches ; <nl> + <nl> + / / for client <nl> + size_t redirect_count = CPPHTTPLIB_REDIRECT_MAX_COUNT ; <nl> + ResponseHandler response_handler ; <nl> + ContentReceiver content_receiver ; <nl> + size_t content_length = 0 ; <nl> + ContentProvider content_provider ; <nl> + Progress progress ; <nl> <nl> # ifdef CPPHTTPLIB_OPENSSL_SUPPORT <nl> - const SSL * ssl ; <nl> + const SSL * ssl ; <nl> # endif <nl> <nl> - bool has_header ( const char * key ) const ; <nl> - std : : string get_header_value ( const char * key , size_t id = 0 ) const ; <nl> - size_t get_header_value_count ( const char * key ) const ; <nl> - void set_header ( const char * key , const char * val ) ; <nl> - void set_header ( const char * key , const std : : string & val ) ; <nl> + bool has_header ( const char * key ) const ; <nl> + std : : string get_header_value ( const char * key , size_t id = 0 ) const ; <nl> + size_t get_header_value_count ( const char * key ) const ; <nl> + void set_header ( const char * key , const char * val ) ; <nl> + void set_header ( const char * key , const std : : string & val ) ; <nl> <nl> - bool has_param ( const char * key ) const ; <nl> - std : : string get_param_value ( const char * key , size_t id = 0 ) const ; <nl> - size_t get_param_value_count ( const char * key ) const ; <nl> + bool has_param ( const char * key ) const ; <nl> + std : : string get_param_value ( const char * key , size_t id = 0 ) const ; <nl> + size_t get_param_value_count ( const char * key ) const ; <nl> <nl> - bool is_multipart_form_data ( ) const ; <nl> + bool is_multipart_form_data ( ) const ; <nl> <nl> - bool has_file ( const char * key ) const ; <nl> - MultipartFormData get_file_value ( const char * key ) const ; <nl> + bool has_file ( const char * key ) const ; <nl> + MultipartFormData get_file_value ( const char * key ) const ; <nl> <nl> - / / private members . . . <nl> - size_t authorization_count_ = 0 ; <nl> + / / private members . . . <nl> + size_t authorization_count_ = 0 ; <nl> } ; <nl> <nl> struct Response { <nl> - std : : string version ; <nl> - int status = - 1 ; <nl> - Headers headers ; <nl> - std : : string body ; <nl> - <nl> - bool has_header ( const char * key ) const ; <nl> - std : : string get_header_value ( const char * key , size_t id = 0 ) const ; <nl> - size_t get_header_value_count ( const char * key ) const ; <nl> - void set_header ( const char * key , const char * val ) ; <nl> - void set_header ( const char * key , const std : : string & val ) ; <nl> - <nl> - void set_redirect ( const char * url , int status = 302 ) ; <nl> - void set_content ( const char * s , size_t n , const char * content_type ) ; <nl> - void set_content ( std : : string s , const char * content_type ) ; <nl> - <nl> - void set_content_provider ( <nl> - size_t length , ContentProvider provider , <nl> - std : : function < void ( ) > resource_releaser = [ ] { } ) ; <nl> - <nl> - void set_chunked_content_provider ( <nl> - ChunkedContentProvider provider , <nl> - std : : function < void ( ) > resource_releaser = [ ] { } ) ; <nl> - <nl> - Response ( ) = default ; <nl> - Response ( const Response & ) = default ; <nl> - Response & operator = ( const Response & ) = default ; <nl> - Response ( Response & & ) = default ; <nl> - Response & operator = ( Response & & ) = default ; <nl> - ~ Response ( ) { <nl> - if ( content_provider_resource_releaser_ ) { <nl> - content_provider_resource_releaser_ ( ) ; <nl> - } <nl> - } <nl> - <nl> - / / private members . . . <nl> - size_t content_length_ = 0 ; <nl> - ContentProvider content_provider_ ; <nl> - std : : function < void ( ) > content_provider_resource_releaser_ ; <nl> + std : : string version ; <nl> + int status = - 1 ; <nl> + Headers headers ; <nl> + std : : string body ; <nl> + <nl> + bool has_header ( const char * key ) const ; <nl> + std : : string get_header_value ( const char * key , size_t id = 0 ) const ; <nl> + size_t get_header_value_count ( const char * key ) const ; <nl> + void set_header ( const char * key , const char * val ) ; <nl> + void set_header ( const char * key , const std : : string & val ) ; <nl> + <nl> + void set_redirect ( const char * url , int status = 302 ) ; <nl> + void set_content ( const char * s , size_t n , const char * content_type ) ; <nl> + void set_content ( std : : string s , const char * content_type ) ; <nl> + <nl> + void set_content_provider ( size_t length , ContentProvider provider , std : : function < void ( ) > resource_releaser = [ ] { } ) ; <nl> + <nl> + void set_chunked_content_provider ( ChunkedContentProvider provider , std : : function < void ( ) > resource_releaser = [ ] { } ) ; <nl> + <nl> + Response ( ) = default ; <nl> + Response ( const Response & ) = default ; <nl> + Response & operator = ( const Response & ) = default ; <nl> + Response ( Response & & ) = default ; <nl> + Response & operator = ( Response & & ) = default ; <nl> + ~ Response ( ) { <nl> + if ( content_provider_resource_releaser_ ) { <nl> + content_provider_resource_releaser_ ( ) ; <nl> + } <nl> + } <nl> + <nl> + / / private members . . . <nl> + size_t content_length_ = 0 ; <nl> + ContentProvider content_provider_ ; <nl> + std : : function < void ( ) > content_provider_resource_releaser_ ; <nl> + } ; <nl> + <nl> + struct WebSocketFrame : public swWebSocket_frame { <nl> + WebSocketFrame ( ) = default ; <nl> + ~ WebSocketFrame ( ) { <nl> + if ( payload ) { <nl> + sw_free ( payload - header_length ) ; <nl> + } <nl> + } <nl> } ; <nl> <nl> class Stream { <nl> - public : <nl> - virtual ~ Stream ( ) = default ; <nl> + public : <nl> + virtual ~ Stream ( ) = default ; <nl> <nl> - virtual bool is_readable ( ) const = 0 ; <nl> - virtual bool is_writable ( ) const = 0 ; <nl> + virtual bool is_readable ( ) const = 0 ; <nl> + virtual bool is_writable ( ) const = 0 ; <nl> <nl> - virtual ssize_t read ( char * ptr , size_t size ) = 0 ; <nl> - virtual ssize_t write ( const char * ptr , size_t size ) = 0 ; <nl> - virtual void get_remote_ip_and_port ( std : : string & ip , int & port ) const = 0 ; <nl> + virtual ssize_t read ( char * ptr , size_t size ) = 0 ; <nl> + virtual ssize_t write ( const char * ptr , size_t size ) = 0 ; <nl> + virtual void get_remote_ip_and_port ( std : : string & ip , int & port ) const = 0 ; <nl> <nl> - template < typename . . . Args > <nl> - ssize_t write_format ( const char * fmt , const Args & . . . args ) ; <nl> - ssize_t write ( const char * ptr ) ; <nl> - ssize_t write ( const std : : string & s ) ; <nl> + template < typename . . . Args > <nl> + ssize_t write_format ( const char * fmt , const Args & . . . args ) ; <nl> + ssize_t write ( const char * ptr ) ; <nl> + ssize_t write ( const std : : string & s ) ; <nl> } ; <nl> <nl> using Logger = std : : function < void ( const Request & , const Response & ) > ; <nl> using Logger = std : : function < void ( const Request & , const Response & ) > ; <nl> using SocketOptions = std : : function < void ( socket_t sock ) > ; <nl> <nl> inline void default_socket_options ( socket_t sock ) { <nl> - int yes = 1 ; <nl> + int yes = 1 ; <nl> # ifdef _WIN32 <nl> - setsockopt ( sock , SOL_SOCKET , SO_REUSEADDR , reinterpret_cast < char * > ( & yes ) , <nl> - sizeof ( yes ) ) ; <nl> - setsockopt ( sock , SOL_SOCKET , SO_EXCLUSIVEADDRUSE , <nl> - reinterpret_cast < char * > ( & yes ) , sizeof ( yes ) ) ; <nl> + setsockopt ( sock , SOL_SOCKET , SO_REUSEADDR , reinterpret_cast < char * > ( & yes ) , sizeof ( yes ) ) ; <nl> + setsockopt ( sock , SOL_SOCKET , SO_EXCLUSIVEADDRUSE , reinterpret_cast < char * > ( & yes ) , sizeof ( yes ) ) ; <nl> # else <nl> # ifdef SO_REUSEPORT <nl> - setsockopt ( sock , SOL_SOCKET , SO_REUSEPORT , reinterpret_cast < void * > ( & yes ) , <nl> - sizeof ( yes ) ) ; <nl> + setsockopt ( sock , SOL_SOCKET , SO_REUSEPORT , reinterpret_cast < void * > ( & yes ) , sizeof ( yes ) ) ; <nl> # else <nl> - setsockopt ( sock , SOL_SOCKET , SO_REUSEADDR , reinterpret_cast < void * > ( & yes ) , <nl> - sizeof ( yes ) ) ; <nl> + setsockopt ( sock , SOL_SOCKET , SO_REUSEADDR , reinterpret_cast < void * > ( & yes ) , sizeof ( yes ) ) ; <nl> # endif <nl> # endif <nl> } <nl> <nl> class Client { <nl> - public : <nl> - explicit Client ( const std : : string & host ) ; <nl> - <nl> - explicit Client ( const std : : string & host , int port ) ; <nl> - <nl> - explicit Client ( const std : : string & host , int port , <nl> - const std : : string & client_cert_path , <nl> - const std : : string & client_key_path ) ; <nl> - <nl> - virtual ~ Client ( ) ; <nl> - <nl> - virtual bool is_valid ( ) const ; <nl> - <nl> - std : : shared_ptr < Response > Get ( const char * path ) ; <nl> + public : <nl> + explicit Client ( const std : : string & host ) ; <nl> <nl> - std : : shared_ptr < Response > Get ( const char * path , const Headers & headers ) ; <nl> + explicit Client ( const std : : string & host , int port ) ; <nl> <nl> - std : : shared_ptr < Response > Get ( const char * path , Progress progress ) ; <nl> + explicit Client ( const std : : string & host , <nl> + int port , <nl> + const std : : string & client_cert_path , <nl> + const std : : string & client_key_path ) ; <nl> <nl> - std : : shared_ptr < Response > Get ( const char * path , const Headers & headers , <nl> - Progress progress ) ; <nl> + virtual ~ Client ( ) ; <nl> <nl> - std : : shared_ptr < Response > Get ( const char * path , <nl> - ContentReceiver content_receiver ) ; <nl> + virtual bool is_valid ( ) const ; <nl> <nl> - std : : shared_ptr < Response > Get ( const char * path , const Headers & headers , <nl> - ContentReceiver content_receiver ) ; <nl> + std : : shared_ptr < Response > Get ( const char * path ) ; <nl> <nl> - std : : shared_ptr < Response > <nl> - Get ( const char * path , ContentReceiver content_receiver , Progress progress ) ; <nl> + std : : shared_ptr < Response > Get ( const char * path , const Headers & headers ) ; <nl> <nl> - std : : shared_ptr < Response > Get ( const char * path , const Headers & headers , <nl> - ContentReceiver content_receiver , <nl> - Progress progress ) ; <nl> + std : : shared_ptr < Response > Get ( const char * path , Progress progress ) ; <nl> <nl> - std : : shared_ptr < Response > Get ( const char * path , const Headers & headers , <nl> - ResponseHandler response_handler , <nl> - ContentReceiver content_receiver ) ; <nl> + std : : shared_ptr < Response > Get ( const char * path , const Headers & headers , Progress progress ) ; <nl> <nl> - std : : shared_ptr < Response > Get ( const char * path , const Headers & headers , <nl> - ResponseHandler response_handler , <nl> - ContentReceiver content_receiver , <nl> - Progress progress ) ; <nl> + std : : shared_ptr < Response > Get ( const char * path , ContentReceiver content_receiver ) ; <nl> <nl> - std : : shared_ptr < Response > Head ( const char * path ) ; <nl> + std : : shared_ptr < Response > Get ( const char * path , const Headers & headers , ContentReceiver content_receiver ) ; <nl> <nl> - std : : shared_ptr < Response > Head ( const char * path , const Headers & headers ) ; <nl> + std : : shared_ptr < Response > Get ( const char * path , ContentReceiver content_receiver , Progress progress ) ; <nl> <nl> - std : : shared_ptr < Response > Post ( const char * path ) ; <nl> + std : : shared_ptr < Response > Get ( const char * path , <nl> + const Headers & headers , <nl> + ContentReceiver content_receiver , <nl> + Progress progress ) ; <nl> <nl> - std : : shared_ptr < Response > Post ( const char * path , const std : : string & body , <nl> - const char * content_type ) ; <nl> + std : : shared_ptr < Response > Get ( const char * path , <nl> + const Headers & headers , <nl> + ResponseHandler response_handler , <nl> + ContentReceiver content_receiver ) ; <nl> <nl> - std : : shared_ptr < Response > Post ( const char * path , const Headers & headers , <nl> - const std : : string & body , <nl> - const char * content_type ) ; <nl> + std : : shared_ptr < Response > Get ( const char * path , <nl> + const Headers & headers , <nl> + ResponseHandler response_handler , <nl> + ContentReceiver content_receiver , <nl> + Progress progress ) ; <nl> <nl> - std : : shared_ptr < Response > Post ( const char * path , size_t content_length , <nl> - ContentProvider content_provider , <nl> - const char * content_type ) ; <nl> + bool Upgrade ( const char * path , Headers & headers ) ; <nl> <nl> - std : : shared_ptr < Response > Post ( const char * path , const Headers & headers , <nl> - size_t content_length , <nl> - ContentProvider content_provider , <nl> - const char * content_type ) ; <nl> + std : : shared_ptr < Response > Head ( const char * path ) ; <nl> <nl> - std : : shared_ptr < Response > Post ( const char * path , const Params & params ) ; <nl> + std : : shared_ptr < Response > Head ( const char * path , const Headers & headers ) ; <nl> <nl> - std : : shared_ptr < Response > Post ( const char * path , const Headers & headers , <nl> - const Params & params ) ; <nl> + std : : shared_ptr < Response > Post ( const char * path ) ; <nl> <nl> - std : : shared_ptr < Response > Post ( const char * path , <nl> - const MultipartFormDataItems & items ) ; <nl> + std : : shared_ptr < Response > Post ( const char * path , const std : : string & body , const char * content_type ) ; <nl> <nl> - std : : shared_ptr < Response > Post ( const char * path , const Headers & headers , <nl> - const MultipartFormDataItems & items ) ; <nl> + std : : shared_ptr < Response > Post ( const char * path , <nl> + const Headers & headers , <nl> + const std : : string & body , <nl> + const char * content_type ) ; <nl> <nl> - std : : shared_ptr < Response > Put ( const char * path ) ; <nl> + std : : shared_ptr < Response > Post ( const char * path , <nl> + size_t content_length , <nl> + ContentProvider content_provider , <nl> + const char * content_type ) ; <nl> <nl> - std : : shared_ptr < Response > Put ( const char * path , const std : : string & body , <nl> - const char * content_type ) ; <nl> + std : : shared_ptr < Response > Post ( const char * path , <nl> + const Headers & headers , <nl> + size_t content_length , <nl> + ContentProvider content_provider , <nl> + const char * content_type ) ; <nl> <nl> - std : : shared_ptr < Response > Put ( const char * path , const Headers & headers , <nl> - const std : : string & body , <nl> - const char * content_type ) ; <nl> + std : : shared_ptr < Response > Post ( const char * path , const Params & params ) ; <nl> <nl> - std : : shared_ptr < Response > Put ( const char * path , size_t content_length , <nl> - ContentProvider content_provider , <nl> - const char * content_type ) ; <nl> + std : : shared_ptr < Response > Post ( const char * path , const Headers & headers , const Params & params ) ; <nl> <nl> - std : : shared_ptr < Response > Put ( const char * path , const Headers & headers , <nl> - size_t content_length , <nl> - ContentProvider content_provider , <nl> - const char * content_type ) ; <nl> + std : : shared_ptr < Response > Post ( const char * path , const MultipartFormDataItems & items ) ; <nl> <nl> - std : : shared_ptr < Response > Put ( const char * path , const Params & params ) ; <nl> + std : : shared_ptr < Response > Post ( const char * path , const Headers & headers , const MultipartFormDataItems & items ) ; <nl> <nl> - std : : shared_ptr < Response > Put ( const char * path , const Headers & headers , <nl> - const Params & params ) ; <nl> + std : : shared_ptr < Response > Put ( const char * path ) ; <nl> <nl> - std : : shared_ptr < Response > Patch ( const char * path , const std : : string & body , <nl> - const char * content_type ) ; <nl> + std : : shared_ptr < Response > Put ( const char * path , const std : : string & body , const char * content_type ) ; <nl> <nl> - std : : shared_ptr < Response > Patch ( const char * path , const Headers & headers , <nl> + std : : shared_ptr < Response > Put ( const char * path , <nl> + const Headers & headers , <nl> const std : : string & body , <nl> const char * content_type ) ; <nl> <nl> - std : : shared_ptr < Response > Patch ( const char * path , size_t content_length , <nl> + std : : shared_ptr < Response > Put ( const char * path , <nl> + size_t content_length , <nl> ContentProvider content_provider , <nl> const char * content_type ) ; <nl> <nl> - std : : shared_ptr < Response > Patch ( const char * path , const Headers & headers , <nl> + std : : shared_ptr < Response > Put ( const char * path , <nl> + const Headers & headers , <nl> size_t content_length , <nl> ContentProvider content_provider , <nl> const char * content_type ) ; <nl> <nl> - std : : shared_ptr < Response > Delete ( const char * path ) ; <nl> + std : : shared_ptr < Response > Put ( const char * path , const Params & params ) ; <nl> <nl> - std : : shared_ptr < Response > Delete ( const char * path , const std : : string & body , <nl> - const char * content_type ) ; <nl> + std : : shared_ptr < Response > Put ( const char * path , const Headers & headers , const Params & params ) ; <nl> <nl> - std : : shared_ptr < Response > Delete ( const char * path , const Headers & headers ) ; <nl> + / / websocket <nl> + inline bool Push ( const std : : string & data , int opcode = WEBSOCKET_OPCODE_TEXT ) { <nl> + return Push ( data . c_str ( ) , data . length ( ) , WEBSOCKET_OPCODE_TEXT ) ; <nl> + } <nl> + bool Push ( const char * data , size_t length , int opcode = WEBSOCKET_OPCODE_TEXT ) ; <nl> + std : : shared_ptr < WebSocketFrame > Recv ( ) ; <nl> <nl> - std : : shared_ptr < Response > Delete ( const char * path , const Headers & headers , <nl> - const std : : string & body , <nl> - const char * content_type ) ; <nl> + std : : shared_ptr < Response > Patch ( const char * path , const std : : string & body , const char * content_type ) ; <nl> + <nl> + std : : shared_ptr < Response > Patch ( const char * path , <nl> + const Headers & headers , <nl> + const std : : string & body , <nl> + const char * content_type ) ; <nl> + <nl> + std : : shared_ptr < Response > Patch ( const char * path , <nl> + size_t content_length , <nl> + ContentProvider content_provider , <nl> + const char * content_type ) ; <nl> + <nl> + std : : shared_ptr < Response > Patch ( const char * path , <nl> + const Headers & headers , <nl> + size_t content_length , <nl> + ContentProvider content_provider , <nl> + const char * content_type ) ; <nl> + <nl> + std : : shared_ptr < Response > Delete ( const char * path ) ; <nl> <nl> - std : : shared_ptr < Response > Options ( const char * path ) ; <nl> + std : : shared_ptr < Response > Delete ( const char * path , const std : : string & body , const char * content_type ) ; <nl> <nl> - std : : shared_ptr < Response > Options ( const char * path , const Headers & headers ) ; <nl> + std : : shared_ptr < Response > Delete ( const char * path , const Headers & headers ) ; <nl> <nl> - bool send ( const Request & req , Response & res ) ; <nl> + std : : shared_ptr < Response > Delete ( const char * path , <nl> + const Headers & headers , <nl> + const std : : string & body , <nl> + const char * content_type ) ; <nl> <nl> - size_t is_socket_open ( ) const ; <nl> + std : : shared_ptr < Response > Options ( const char * path ) ; <nl> <nl> - void stop ( ) ; <nl> + std : : shared_ptr < Response > Options ( const char * path , const Headers & headers ) ; <nl> <nl> - void set_tcp_nodelay ( bool on ) ; <nl> - void set_socket_options ( SocketOptions socket_options ) ; <nl> + bool send ( const Request & req , Response & res ) ; <nl> <nl> - CPPHTTPLIB_DEPRECATED void set_timeout_sec ( time_t timeout_sec ) ; <nl> - void set_connection_timeout ( time_t sec , time_t usec = 0 ) ; <nl> - void set_read_timeout ( time_t sec , time_t usec = 0 ) ; <nl> - void set_write_timeout ( time_t sec , time_t usec = 0 ) ; <nl> + size_t is_socket_open ( ) const ; <nl> <nl> - void set_basic_auth ( const char * username , const char * password ) ; <nl> + void stop ( ) ; <nl> + <nl> + void set_tcp_nodelay ( bool on ) ; <nl> + void set_socket_options ( SocketOptions socket_options ) ; <nl> + <nl> + CPPHTTPLIB_DEPRECATED void set_timeout_sec ( time_t timeout_sec ) ; <nl> + void set_connection_timeout ( time_t sec , time_t usec = 0 ) ; <nl> + void set_read_timeout ( time_t sec , time_t usec = 0 ) ; <nl> + void set_write_timeout ( time_t sec , time_t usec = 0 ) ; <nl> + <nl> + void set_basic_auth ( const char * username , const char * password ) ; <nl> # ifdef CPPHTTPLIB_OPENSSL_SUPPORT <nl> - void set_digest_auth ( const char * username , const char * password ) ; <nl> + void set_digest_auth ( const char * username , const char * password ) ; <nl> # endif <nl> <nl> - void set_keep_alive ( bool on ) ; <nl> - void set_follow_location ( bool on ) ; <nl> + void set_keep_alive ( bool on ) ; <nl> + void set_follow_location ( bool on ) ; <nl> <nl> - void set_compress ( bool on ) ; <nl> + void set_compress ( bool on ) ; <nl> <nl> - void set_decompress ( bool on ) ; <nl> + void set_decompress ( bool on ) ; <nl> <nl> - void set_interface ( const char * intf ) ; <nl> + void set_interface ( const char * intf ) ; <nl> <nl> - void set_proxy ( const char * host , int port ) ; <nl> - void set_proxy_basic_auth ( const char * username , const char * password ) ; <nl> + void set_proxy ( const char * host , int port ) ; <nl> + void set_proxy_basic_auth ( const char * username , const char * password ) ; <nl> # ifdef CPPHTTPLIB_OPENSSL_SUPPORT <nl> - void set_proxy_digest_auth ( const char * username , const char * password ) ; <nl> + void set_proxy_digest_auth ( const char * username , const char * password ) ; <nl> # endif <nl> <nl> - void set_logger ( Logger logger ) ; <nl> + void set_logger ( Logger logger ) ; <nl> <nl> - protected : <nl> - struct Socket { <nl> - socket_t sock = INVALID_SOCKET ; <nl> + protected : <nl> + struct Socket { <nl> + socket_t sock = INVALID_SOCKET ; <nl> # ifdef CPPHTTPLIB_OPENSSL_SUPPORT <nl> - SSL * ssl = nullptr ; <nl> + SSL * ssl = nullptr ; <nl> # endif <nl> <nl> - bool is_open ( ) const { return sock ! = INVALID_SOCKET ; } <nl> - } ; <nl> + bool is_open ( ) const { <nl> + return sock ! = INVALID_SOCKET ; <nl> + } <nl> + } ; <nl> <nl> - virtual bool create_and_connect_socket ( Socket & socket ) ; <nl> - virtual void close_socket ( Socket & socket , bool process_socket_ret ) ; <nl> + virtual bool create_and_connect_socket ( Socket & socket ) ; <nl> + virtual void close_socket ( Socket & socket , bool process_socket_ret ) ; <nl> <nl> - bool process_request ( Stream & strm , const Request & req , Response & res , <nl> - bool close_connection ) ; <nl> + bool process_request ( Stream & strm , const Request & req , Response & res , bool close_connection ) ; <nl> <nl> - / / Socket endoint information <nl> - const std : : string host_ ; <nl> - const int port_ ; <nl> - const std : : string host_and_port_ ; <nl> + / / Socket endoint information <nl> + const std : : string host_ ; <nl> + const int port_ ; <nl> + const std : : string host_and_port_ ; <nl> <nl> - / / Current open socket <nl> - Socket socket_ ; <nl> - mutable std : : mutex socket_mutex_ ; <nl> - std : : recursive_mutex request_mutex_ ; <nl> + / / Current open socket <nl> + Socket socket_ ; <nl> + mutable std : : mutex socket_mutex_ ; <nl> + std : : recursive_mutex request_mutex_ ; <nl> <nl> - / / Settings <nl> - std : : string client_cert_path_ ; <nl> - std : : string client_key_path_ ; <nl> + / / Settings <nl> + std : : string client_cert_path_ ; <nl> + std : : string client_key_path_ ; <nl> <nl> - time_t connection_timeout_sec_ = CPPHTTPLIB_CONNECTION_TIMEOUT_SECOND ; <nl> - time_t connection_timeout_usec_ = CPPHTTPLIB_CONNECTION_TIMEOUT_USECOND ; <nl> - time_t read_timeout_sec_ = CPPHTTPLIB_READ_TIMEOUT_SECOND ; <nl> - time_t read_timeout_usec_ = CPPHTTPLIB_READ_TIMEOUT_USECOND ; <nl> - time_t write_timeout_sec_ = CPPHTTPLIB_WRITE_TIMEOUT_SECOND ; <nl> - time_t write_timeout_usec_ = CPPHTTPLIB_WRITE_TIMEOUT_USECOND ; <nl> + time_t connection_timeout_sec_ = CPPHTTPLIB_CONNECTION_TIMEOUT_SECOND ; <nl> + time_t connection_timeout_usec_ = CPPHTTPLIB_CONNECTION_TIMEOUT_USECOND ; <nl> + time_t read_timeout_sec_ = CPPHTTPLIB_READ_TIMEOUT_SECOND ; <nl> + time_t read_timeout_usec_ = CPPHTTPLIB_READ_TIMEOUT_USECOND ; <nl> + time_t write_timeout_sec_ = CPPHTTPLIB_WRITE_TIMEOUT_SECOND ; <nl> + time_t write_timeout_usec_ = CPPHTTPLIB_WRITE_TIMEOUT_USECOND ; <nl> <nl> - std : : string basic_auth_username_ ; <nl> - std : : string basic_auth_password_ ; <nl> + std : : string basic_auth_username_ ; <nl> + std : : string basic_auth_password_ ; <nl> # ifdef CPPHTTPLIB_OPENSSL_SUPPORT <nl> - std : : string digest_auth_username_ ; <nl> - std : : string digest_auth_password_ ; <nl> + std : : string digest_auth_username_ ; <nl> + std : : string digest_auth_password_ ; <nl> # endif <nl> <nl> - bool keep_alive_ = false ; <nl> - bool follow_location_ = false ; <nl> + bool keep_alive_ = false ; <nl> + bool follow_location_ = false ; <nl> <nl> - bool tcp_nodelay_ = CPPHTTPLIB_TCP_NODELAY ; <nl> - SocketOptions socket_options_ = nullptr ; <nl> + bool tcp_nodelay_ = CPPHTTPLIB_TCP_NODELAY ; <nl> + SocketOptions socket_options_ = nullptr ; <nl> <nl> - bool compress_ = false ; <nl> - bool decompress_ = true ; <nl> + bool compress_ = false ; <nl> + bool decompress_ = true ; <nl> <nl> - std : : string interface_ ; <nl> + std : : string interface_ ; <nl> <nl> - std : : string proxy_host_ ; <nl> - int proxy_port_ ; <nl> + std : : string proxy_host_ ; <nl> + int proxy_port_ = 80 ; <nl> <nl> - std : : string proxy_basic_auth_username_ ; <nl> - std : : string proxy_basic_auth_password_ ; <nl> + std : : string proxy_basic_auth_username_ ; <nl> + std : : string proxy_basic_auth_password_ ; <nl> # ifdef CPPHTTPLIB_OPENSSL_SUPPORT <nl> - std : : string proxy_digest_auth_username_ ; <nl> - std : : string proxy_digest_auth_password_ ; <nl> - # endif <nl> - <nl> - Logger logger_ ; <nl> - <nl> - void copy_settings ( const Client & rhs ) { <nl> - client_cert_path_ = rhs . client_cert_path_ ; <nl> - client_key_path_ = rhs . client_key_path_ ; <nl> - connection_timeout_sec_ = rhs . connection_timeout_sec_ ; <nl> - read_timeout_sec_ = rhs . read_timeout_sec_ ; <nl> - read_timeout_usec_ = rhs . read_timeout_usec_ ; <nl> - write_timeout_sec_ = rhs . write_timeout_sec_ ; <nl> - write_timeout_usec_ = rhs . write_timeout_usec_ ; <nl> - basic_auth_username_ = rhs . basic_auth_username_ ; <nl> - basic_auth_password_ = rhs . basic_auth_password_ ; <nl> + std : : string proxy_digest_auth_username_ ; <nl> + std : : string proxy_digest_auth_password_ ; <nl> + # endif <nl> + <nl> + Logger logger_ ; <nl> + <nl> + void copy_settings ( const Client & rhs ) { <nl> + client_cert_path_ = rhs . client_cert_path_ ; <nl> + client_key_path_ = rhs . client_key_path_ ; <nl> + connection_timeout_sec_ = rhs . connection_timeout_sec_ ; <nl> + read_timeout_sec_ = rhs . read_timeout_sec_ ; <nl> + read_timeout_usec_ = rhs . read_timeout_usec_ ; <nl> + write_timeout_sec_ = rhs . write_timeout_sec_ ; <nl> + write_timeout_usec_ = rhs . write_timeout_usec_ ; <nl> + basic_auth_username_ = rhs . basic_auth_username_ ; <nl> + basic_auth_password_ = rhs . basic_auth_password_ ; <nl> # ifdef CPPHTTPLIB_OPENSSL_SUPPORT <nl> - digest_auth_username_ = rhs . digest_auth_username_ ; <nl> - digest_auth_password_ = rhs . digest_auth_password_ ; <nl> - # endif <nl> - keep_alive_ = rhs . keep_alive_ ; <nl> - follow_location_ = rhs . follow_location_ ; <nl> - tcp_nodelay_ = rhs . tcp_nodelay_ ; <nl> - socket_options_ = rhs . socket_options_ ; <nl> - compress_ = rhs . compress_ ; <nl> - decompress_ = rhs . decompress_ ; <nl> - interface_ = rhs . interface_ ; <nl> - proxy_host_ = rhs . proxy_host_ ; <nl> - proxy_port_ = rhs . proxy_port_ ; <nl> - proxy_basic_auth_username_ = rhs . proxy_basic_auth_username_ ; <nl> - proxy_basic_auth_password_ = rhs . proxy_basic_auth_password_ ; <nl> + digest_auth_username_ = rhs . digest_auth_username_ ; <nl> + digest_auth_password_ = rhs . digest_auth_password_ ; <nl> + # endif <nl> + keep_alive_ = rhs . keep_alive_ ; <nl> + follow_location_ = rhs . follow_location_ ; <nl> + tcp_nodelay_ = rhs . tcp_nodelay_ ; <nl> + socket_options_ = rhs . socket_options_ ; <nl> + compress_ = rhs . compress_ ; <nl> + decompress_ = rhs . decompress_ ; <nl> + interface_ = rhs . interface_ ; <nl> + proxy_host_ = rhs . proxy_host_ ; <nl> + proxy_port_ = rhs . proxy_port_ ; <nl> + proxy_basic_auth_username_ = rhs . proxy_basic_auth_username_ ; <nl> + proxy_basic_auth_password_ = rhs . proxy_basic_auth_password_ ; <nl> # ifdef CPPHTTPLIB_OPENSSL_SUPPORT <nl> - proxy_digest_auth_username_ = rhs . proxy_digest_auth_username_ ; <nl> - proxy_digest_auth_password_ = rhs . proxy_digest_auth_password_ ; <nl> + proxy_digest_auth_username_ = rhs . proxy_digest_auth_username_ ; <nl> + proxy_digest_auth_password_ = rhs . proxy_digest_auth_password_ ; <nl> # endif <nl> - logger_ = rhs . logger_ ; <nl> - } <nl> - <nl> - private : <nl> - socket_t create_client_socket ( ) const ; <nl> - bool read_response_line ( Stream & strm , Response & res ) ; <nl> - bool write_request ( Stream & strm , const Request & req , bool close_connection ) ; <nl> - bool redirect ( const Request & req , Response & res ) ; <nl> - bool handle_request ( Stream & strm , const Request & req , Response & res , <nl> - bool close_connection ) ; <nl> - <nl> - std : : shared_ptr < Response > send_with_content_provider ( <nl> - const char * method , const char * path , const Headers & headers , <nl> - const std : : string & body , size_t content_length , <nl> - ContentProvider content_provider , const char * content_type ) ; <nl> - <nl> - virtual bool process_socket ( Socket & socket , <nl> - std : : function < bool ( Stream & strm ) > callback ) ; <nl> - virtual bool is_ssl ( ) const ; <nl> + logger_ = rhs . logger_ ; <nl> + } <nl> + <nl> + private : <nl> + socket_t create_client_socket ( ) const ; <nl> + bool read_response_line ( Stream & strm , Response & res ) ; <nl> + bool write_request ( Stream & strm , const Request & req , bool close_connection ) ; <nl> + bool redirect ( const Request & req , Response & res ) ; <nl> + bool handle_request ( Stream & strm , const Request & req , Response & res , bool close_connection ) ; <nl> + <nl> + std : : shared_ptr < Response > send_with_content_provider ( const char * method , <nl> + const char * path , <nl> + const Headers & headers , <nl> + const std : : string & body , <nl> + size_t content_length , <nl> + ContentProvider content_provider , <nl> + const char * content_type ) ; <nl> + <nl> + virtual bool process_socket ( Socket & socket , std : : function < bool ( Stream & strm ) > callback ) ; <nl> + virtual bool is_ssl ( ) const ; <nl> } ; <nl> <nl> - inline void Get ( std : : vector < Request > & requests , const char * path , <nl> - const Headers & headers ) { <nl> - Request req ; <nl> - req . method = " GET " ; <nl> - req . path = path ; <nl> - req . headers = headers ; <nl> - requests . emplace_back ( std : : move ( req ) ) ; <nl> + inline void Get ( std : : vector < Request > & requests , const char * path , const Headers & headers ) { <nl> + Request req ; <nl> + req . method = " GET " ; <nl> + req . path = path ; <nl> + req . headers = headers ; <nl> + requests . emplace_back ( std : : move ( req ) ) ; <nl> } <nl> <nl> inline void Get ( std : : vector < Request > & requests , const char * path ) { <nl> - Get ( requests , path , Headers ( ) ) ; <nl> + Get ( requests , path , Headers ( ) ) ; <nl> } <nl> <nl> - inline void Post ( std : : vector < Request > & requests , const char * path , <nl> - const Headers & headers , const std : : string & body , <nl> + inline void Post ( std : : vector < Request > & requests , <nl> + const char * path , <nl> + const Headers & headers , <nl> + const std : : string & body , <nl> const char * content_type ) { <nl> - Request req ; <nl> - req . method = " POST " ; <nl> - req . path = path ; <nl> - req . headers = headers ; <nl> - if ( content_type ) { req . headers . emplace ( " Content - Type " , content_type ) ; } <nl> - req . body = body ; <nl> - requests . emplace_back ( std : : move ( req ) ) ; <nl> + Request req ; <nl> + req . method = " POST " ; <nl> + req . path = path ; <nl> + req . headers = headers ; <nl> + if ( content_type ) { <nl> + req . headers . emplace ( " Content - Type " , content_type ) ; <nl> + } <nl> + req . body = body ; <nl> + requests . emplace_back ( std : : move ( req ) ) ; <nl> } <nl> <nl> - inline void Post ( std : : vector < Request > & requests , const char * path , <nl> - const std : : string & body , const char * content_type ) { <nl> - Post ( requests , path , Headers ( ) , body , content_type ) ; <nl> + inline void Post ( std : : vector < Request > & requests , const char * path , const std : : string & body , const char * content_type ) { <nl> + Post ( requests , path , Headers ( ) , body , content_type ) ; <nl> } <nl> <nl> - inline void Post ( std : : vector < Request > & requests , const char * path , <nl> - size_t content_length , ContentProvider content_provider , <nl> + inline void Post ( std : : vector < Request > & requests , <nl> + const char * path , <nl> + size_t content_length , <nl> + ContentProvider content_provider , <nl> const char * content_type ) { <nl> - Request req ; <nl> - req . method = " POST " ; <nl> - req . headers = Headers ( ) ; <nl> - req . path = path ; <nl> - req . content_length = content_length ; <nl> - req . content_provider = content_provider ; <nl> + Request req ; <nl> + req . method = " POST " ; <nl> + req . headers = Headers ( ) ; <nl> + req . path = path ; <nl> + req . content_length = content_length ; <nl> + req . content_provider = content_provider ; <nl> <nl> - if ( content_type ) { req . headers . emplace ( " Content - Type " , content_type ) ; } <nl> + if ( content_type ) { <nl> + req . headers . emplace ( " Content - Type " , content_type ) ; <nl> + } <nl> <nl> - requests . emplace_back ( std : : move ( req ) ) ; <nl> + requests . emplace_back ( std : : move ( req ) ) ; <nl> } <nl> <nl> class Client2 { <nl> - public : <nl> - explicit Client2 ( const char * scheme_host_port ) <nl> - : Client2 ( scheme_host_port , std : : string ( ) , std : : string ( ) ) { } <nl> + public : <nl> + explicit Client2 ( const char * scheme_host_port ) : Client2 ( scheme_host_port , std : : string ( ) , std : : string ( ) ) { } <nl> <nl> - explicit Client2 ( const char * scheme_host_port , <nl> - const std : : string & client_cert_path , <nl> - const std : : string & client_key_path ) { <nl> - const static std : : regex re ( R " ( ^ ( https ? ) : / / ( [ ^ : / ? # ] + ) ( ? : : ( \ d + ) ) ? ) " ) ; <nl> + explicit Client2 ( const char * scheme_host_port , <nl> + const std : : string & client_cert_path , <nl> + const std : : string & client_key_path ) { <nl> + const static std : : regex re ( R " ( ^ ( https ? ) : / / ( [ ^ : / ? # ] + ) ( ? : : ( \ d + ) ) ? ) " ) ; <nl> <nl> - std : : cmatch m ; <nl> - if ( std : : regex_match ( scheme_host_port , m , re ) ) { <nl> - auto scheme = m [ 1 ] . str ( ) ; <nl> - auto host = m [ 2 ] . str ( ) ; <nl> - auto port_str = m [ 3 ] . str ( ) ; <nl> + std : : cmatch m ; <nl> + if ( std : : regex_match ( scheme_host_port , m , re ) ) { <nl> + auto scheme = m [ 1 ] . str ( ) ; <nl> + auto host = m [ 2 ] . str ( ) ; <nl> + auto port_str = m [ 3 ] . str ( ) ; <nl> <nl> - auto port = ! port_str . empty ( ) ? std : : stoi ( port_str ) <nl> - : ( scheme = = " https " ? 443 : 80 ) ; <nl> + auto port = ! port_str . empty ( ) ? std : : stoi ( port_str ) : ( scheme = = " https " ? 443 : 80 ) ; <nl> <nl> - if ( scheme = = " https " ) { <nl> + if ( scheme = = " https " ) { <nl> # ifdef CPPHTTPLIB_OPENSSL_SUPPORT <nl> - is_ssl_ = true ; <nl> - cli_ = std : : make_shared < SSLClient > ( host . c_str ( ) , port , client_cert_path , <nl> - client_key_path ) ; <nl> + is_ssl_ = true ; <nl> + cli_ = std : : make_shared < SSLClient > ( host . c_str ( ) , port , client_cert_path , client_key_path ) ; <nl> # endif <nl> - } else { <nl> - cli_ = std : : make_shared < Client > ( host . c_str ( ) , port , client_cert_path , <nl> - client_key_path ) ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - ~ Client2 ( ) { } <nl> - <nl> - bool is_valid ( ) const { return cli_ ! = nullptr ; } <nl> - <nl> - std : : shared_ptr < Response > Get ( const char * path ) { return cli_ - > Get ( path ) ; } <nl> - <nl> - std : : shared_ptr < Response > Get ( const char * path , const Headers & headers ) { <nl> - return cli_ - > Get ( path , headers ) ; <nl> - } <nl> - <nl> - std : : shared_ptr < Response > Get ( const char * path , Progress progress ) { <nl> - return cli_ - > Get ( path , progress ) ; <nl> - } <nl> - <nl> - std : : shared_ptr < Response > Get ( const char * path , const Headers & headers , <nl> - Progress progress ) { <nl> - return cli_ - > Get ( path , headers , progress ) ; <nl> - } <nl> - <nl> - std : : shared_ptr < Response > Get ( const char * path , <nl> - ContentReceiver content_receiver ) { <nl> - return cli_ - > Get ( path , content_receiver ) ; <nl> - } <nl> - <nl> - std : : shared_ptr < Response > Get ( const char * path , const Headers & headers , <nl> - ContentReceiver content_receiver ) { <nl> - return cli_ - > Get ( path , headers , content_receiver ) ; <nl> - } <nl> - <nl> - std : : shared_ptr < Response > <nl> - Get ( const char * path , ContentReceiver content_receiver , Progress progress ) { <nl> - return cli_ - > Get ( path , content_receiver , progress ) ; <nl> - } <nl> - <nl> - std : : shared_ptr < Response > Get ( const char * path , const Headers & headers , <nl> - ContentReceiver content_receiver , <nl> - Progress progress ) { <nl> - return cli_ - > Get ( path , headers , content_receiver , progress ) ; <nl> - } <nl> - <nl> - std : : shared_ptr < Response > Get ( const char * path , const Headers & headers , <nl> - ResponseHandler response_handler , <nl> - ContentReceiver content_receiver ) { <nl> - return cli_ - > Get ( path , headers , response_handler , content_receiver ) ; <nl> - } <nl> - <nl> - std : : shared_ptr < Response > Get ( const char * path , const Headers & headers , <nl> - ResponseHandler response_handler , <nl> - ContentReceiver content_receiver , <nl> - Progress progress ) { <nl> - return cli_ - > Get ( path , headers , response_handler , content_receiver , <nl> - progress ) ; <nl> - } <nl> - <nl> - std : : shared_ptr < Response > Head ( const char * path ) { return cli_ - > Head ( path ) ; } <nl> - <nl> - std : : shared_ptr < Response > Head ( const char * path , const Headers & headers ) { <nl> - return cli_ - > Head ( path , headers ) ; <nl> - } <nl> - <nl> - std : : shared_ptr < Response > Post ( const char * path ) { return cli_ - > Post ( path ) ; } <nl> - <nl> - std : : shared_ptr < Response > Post ( const char * path , const std : : string & body , <nl> - const char * content_type ) { <nl> - return cli_ - > Post ( path , body , content_type ) ; <nl> - } <nl> - <nl> - std : : shared_ptr < Response > Post ( const char * path , const Headers & headers , <nl> - const std : : string & body , <nl> - const char * content_type ) { <nl> - return cli_ - > Post ( path , headers , body , content_type ) ; <nl> - } <nl> - <nl> - std : : shared_ptr < Response > Post ( const char * path , size_t content_length , <nl> - ContentProvider content_provider , <nl> - const char * content_type ) { <nl> - return cli_ - > Post ( path , content_length , content_provider , content_type ) ; <nl> - } <nl> - <nl> - std : : shared_ptr < Response > Post ( const char * path , const Headers & headers , <nl> - size_t content_length , <nl> - ContentProvider content_provider , <nl> - const char * content_type ) { <nl> - return cli_ - > Post ( path , headers , content_length , content_provider , <nl> - content_type ) ; <nl> - } <nl> - <nl> - std : : shared_ptr < Response > Post ( const char * path , const Params & params ) { <nl> - return cli_ - > Post ( path , params ) ; <nl> - } <nl> - <nl> - std : : shared_ptr < Response > Post ( const char * path , const Headers & headers , <nl> - const Params & params ) { <nl> - return cli_ - > Post ( path , headers , params ) ; <nl> - } <nl> - <nl> - std : : shared_ptr < Response > Post ( const char * path , <nl> - const MultipartFormDataItems & items ) { <nl> - return cli_ - > Post ( path , items ) ; <nl> - } <nl> - <nl> - std : : shared_ptr < Response > Post ( const char * path , const Headers & headers , <nl> - const MultipartFormDataItems & items ) { <nl> - return cli_ - > Post ( path , headers , items ) ; <nl> - } <nl> - <nl> - std : : shared_ptr < Response > Put ( const char * path ) { return cli_ - > Put ( path ) ; } <nl> - <nl> - std : : shared_ptr < Response > Put ( const char * path , const std : : string & body , <nl> - const char * content_type ) { <nl> - return cli_ - > Put ( path , body , content_type ) ; <nl> - } <nl> - <nl> - std : : shared_ptr < Response > Put ( const char * path , const Headers & headers , <nl> - const std : : string & body , <nl> - const char * content_type ) { <nl> - return cli_ - > Put ( path , headers , body , content_type ) ; <nl> - } <nl> - <nl> - std : : shared_ptr < Response > Put ( const char * path , size_t content_length , <nl> - ContentProvider content_provider , <nl> - const char * content_type ) { <nl> - return cli_ - > Put ( path , content_length , content_provider , content_type ) ; <nl> - } <nl> - <nl> - std : : shared_ptr < Response > Put ( const char * path , const Headers & headers , <nl> - size_t content_length , <nl> - ContentProvider content_provider , <nl> - const char * content_type ) { <nl> - return cli_ - > Put ( path , headers , content_length , content_provider , <nl> - content_type ) ; <nl> - } <nl> - <nl> - std : : shared_ptr < Response > Put ( const char * path , const Params & params ) { <nl> - return cli_ - > Put ( path , params ) ; <nl> - } <nl> - <nl> - std : : shared_ptr < Response > Put ( const char * path , const Headers & headers , <nl> - const Params & params ) { <nl> - return cli_ - > Put ( path , headers , params ) ; <nl> - } <nl> - <nl> - std : : shared_ptr < Response > Patch ( const char * path , const std : : string & body , <nl> - const char * content_type ) { <nl> - return cli_ - > Patch ( path , body , content_type ) ; <nl> - } <nl> + } else { <nl> + cli_ = std : : make_shared < Client > ( host . c_str ( ) , port , client_cert_path , client_key_path ) ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + ~ Client2 ( ) { } <nl> + <nl> + bool is_valid ( ) const { <nl> + return cli_ ! = nullptr ; <nl> + } <nl> + <nl> + std : : shared_ptr < Response > Get ( const char * path ) { <nl> + return cli_ - > Get ( path ) ; <nl> + } <nl> + <nl> + std : : shared_ptr < Response > Get ( const char * path , const Headers & headers ) { <nl> + return cli_ - > Get ( path , headers ) ; <nl> + } <nl> + <nl> + std : : shared_ptr < Response > Get ( const char * path , Progress progress ) { <nl> + return cli_ - > Get ( path , progress ) ; <nl> + } <nl> + <nl> + std : : shared_ptr < Response > Get ( const char * path , const Headers & headers , Progress progress ) { <nl> + return cli_ - > Get ( path , headers , progress ) ; <nl> + } <nl> + <nl> + std : : shared_ptr < Response > Get ( const char * path , ContentReceiver content_receiver ) { <nl> + return cli_ - > Get ( path , content_receiver ) ; <nl> + } <nl> + <nl> + std : : shared_ptr < Response > Get ( const char * path , const Headers & headers , ContentReceiver content_receiver ) { <nl> + return cli_ - > Get ( path , headers , content_receiver ) ; <nl> + } <nl> + <nl> + std : : shared_ptr < Response > Get ( const char * path , ContentReceiver content_receiver , Progress progress ) { <nl> + return cli_ - > Get ( path , content_receiver , progress ) ; <nl> + } <nl> + <nl> + std : : shared_ptr < Response > Get ( const char * path , <nl> + const Headers & headers , <nl> + ContentReceiver content_receiver , <nl> + Progress progress ) { <nl> + return cli_ - > Get ( path , headers , content_receiver , progress ) ; <nl> + } <nl> + <nl> + std : : shared_ptr < Response > Get ( const char * path , <nl> + const Headers & headers , <nl> + ResponseHandler response_handler , <nl> + ContentReceiver content_receiver ) { <nl> + return cli_ - > Get ( path , headers , response_handler , content_receiver ) ; <nl> + } <nl> + <nl> + std : : shared_ptr < Response > Get ( const char * path , <nl> + const Headers & headers , <nl> + ResponseHandler response_handler , <nl> + ContentReceiver content_receiver , <nl> + Progress progress ) { <nl> + return cli_ - > Get ( path , headers , response_handler , content_receiver , progress ) ; <nl> + } <nl> + <nl> + std : : shared_ptr < Response > Head ( const char * path ) { <nl> + return cli_ - > Head ( path ) ; <nl> + } <nl> + <nl> + std : : shared_ptr < Response > Head ( const char * path , const Headers & headers ) { <nl> + return cli_ - > Head ( path , headers ) ; <nl> + } <nl> + <nl> + std : : shared_ptr < Response > Post ( const char * path ) { <nl> + return cli_ - > Post ( path ) ; <nl> + } <nl> + <nl> + std : : shared_ptr < Response > Post ( const char * path , const std : : string & body , const char * content_type ) { <nl> + return cli_ - > Post ( path , body , content_type ) ; <nl> + } <nl> + <nl> + std : : shared_ptr < Response > Post ( const char * path , <nl> + const Headers & headers , <nl> + const std : : string & body , <nl> + const char * content_type ) { <nl> + return cli_ - > Post ( path , headers , body , content_type ) ; <nl> + } <nl> + <nl> + std : : shared_ptr < Response > Post ( const char * path , <nl> + size_t content_length , <nl> + ContentProvider content_provider , <nl> + const char * content_type ) { <nl> + return cli_ - > Post ( path , content_length , content_provider , content_type ) ; <nl> + } <nl> + <nl> + std : : shared_ptr < Response > Post ( const char * path , <nl> + const Headers & headers , <nl> + size_t content_length , <nl> + ContentProvider content_provider , <nl> + const char * content_type ) { <nl> + return cli_ - > Post ( path , headers , content_length , content_provider , content_type ) ; <nl> + } <nl> + <nl> + std : : shared_ptr < Response > Post ( const char * path , const Params & params ) { <nl> + return cli_ - > Post ( path , params ) ; <nl> + } <nl> + <nl> + std : : shared_ptr < Response > Post ( const char * path , const Headers & headers , const Params & params ) { <nl> + return cli_ - > Post ( path , headers , params ) ; <nl> + } <nl> + <nl> + std : : shared_ptr < Response > Post ( const char * path , const MultipartFormDataItems & items ) { <nl> + return cli_ - > Post ( path , items ) ; <nl> + } <nl> + <nl> + std : : shared_ptr < Response > Post ( const char * path , const Headers & headers , const MultipartFormDataItems & items ) { <nl> + return cli_ - > Post ( path , headers , items ) ; <nl> + } <nl> + <nl> + std : : shared_ptr < Response > Put ( const char * path ) { <nl> + return cli_ - > Put ( path ) ; <nl> + } <nl> + <nl> + std : : shared_ptr < Response > Put ( const char * path , const std : : string & body , const char * content_type ) { <nl> + return cli_ - > Put ( path , body , content_type ) ; <nl> + } <nl> <nl> - std : : shared_ptr < Response > Patch ( const char * path , const Headers & headers , <nl> + std : : shared_ptr < Response > Put ( const char * path , <nl> + const Headers & headers , <nl> const std : : string & body , <nl> const char * content_type ) { <nl> - return cli_ - > Patch ( path , headers , body , content_type ) ; <nl> - } <nl> + return cli_ - > Put ( path , headers , body , content_type ) ; <nl> + } <nl> <nl> - std : : shared_ptr < Response > Patch ( const char * path , size_t content_length , <nl> + std : : shared_ptr < Response > Put ( const char * path , <nl> + size_t content_length , <nl> ContentProvider content_provider , <nl> const char * content_type ) { <nl> - return cli_ - > Patch ( path , content_length , content_provider , content_type ) ; <nl> - } <nl> + return cli_ - > Put ( path , content_length , content_provider , content_type ) ; <nl> + } <nl> <nl> - std : : shared_ptr < Response > Patch ( const char * path , const Headers & headers , <nl> + std : : shared_ptr < Response > Put ( const char * path , <nl> + const Headers & headers , <nl> size_t content_length , <nl> ContentProvider content_provider , <nl> const char * content_type ) { <nl> - return cli_ - > Patch ( path , headers , content_length , content_provider , <nl> - content_type ) ; <nl> - } <nl> + return cli_ - > Put ( path , headers , content_length , content_provider , content_type ) ; <nl> + } <nl> <nl> - std : : shared_ptr < Response > Delete ( const char * path ) { <nl> - return cli_ - > Delete ( path ) ; <nl> - } <nl> + std : : shared_ptr < Response > Put ( const char * path , const Params & params ) { <nl> + return cli_ - > Put ( path , params ) ; <nl> + } <nl> <nl> - std : : shared_ptr < Response > Delete ( const char * path , const std : : string & body , <nl> - const char * content_type ) { <nl> - return cli_ - > Delete ( path , body , content_type ) ; <nl> - } <nl> + std : : shared_ptr < Response > Put ( const char * path , const Headers & headers , const Params & params ) { <nl> + return cli_ - > Put ( path , headers , params ) ; <nl> + } <nl> <nl> - std : : shared_ptr < Response > Delete ( const char * path , const Headers & headers ) { <nl> - return cli_ - > Delete ( path , headers ) ; <nl> - } <nl> + std : : shared_ptr < Response > Patch ( const char * path , const std : : string & body , const char * content_type ) { <nl> + return cli_ - > Patch ( path , body , content_type ) ; <nl> + } <nl> <nl> - std : : shared_ptr < Response > Delete ( const char * path , const Headers & headers , <nl> - const std : : string & body , <nl> - const char * content_type ) { <nl> - return cli_ - > Delete ( path , headers , body , content_type ) ; <nl> - } <nl> + std : : shared_ptr < Response > Patch ( const char * path , <nl> + const Headers & headers , <nl> + const std : : string & body , <nl> + const char * content_type ) { <nl> + return cli_ - > Patch ( path , headers , body , content_type ) ; <nl> + } <nl> + <nl> + std : : shared_ptr < Response > Patch ( const char * path , <nl> + size_t content_length , <nl> + ContentProvider content_provider , <nl> + const char * content_type ) { <nl> + return cli_ - > Patch ( path , content_length , content_provider , content_type ) ; <nl> + } <nl> + <nl> + std : : shared_ptr < Response > Patch ( const char * path , <nl> + const Headers & headers , <nl> + size_t content_length , <nl> + ContentProvider content_provider , <nl> + const char * content_type ) { <nl> + return cli_ - > Patch ( path , headers , content_length , content_provider , content_type ) ; <nl> + } <nl> <nl> - std : : shared_ptr < Response > Options ( const char * path ) { <nl> - return cli_ - > Options ( path ) ; <nl> - } <nl> + std : : shared_ptr < Response > Delete ( const char * path ) { <nl> + return cli_ - > Delete ( path ) ; <nl> + } <nl> + <nl> + std : : shared_ptr < Response > Delete ( const char * path , const std : : string & body , const char * content_type ) { <nl> + return cli_ - > Delete ( path , body , content_type ) ; <nl> + } <nl> + <nl> + std : : shared_ptr < Response > Delete ( const char * path , const Headers & headers ) { <nl> + return cli_ - > Delete ( path , headers ) ; <nl> + } <nl> + <nl> + std : : shared_ptr < Response > Delete ( const char * path , <nl> + const Headers & headers , <nl> + const std : : string & body , <nl> + const char * content_type ) { <nl> + return cli_ - > Delete ( path , headers , body , content_type ) ; <nl> + } <nl> + <nl> + std : : shared_ptr < Response > Options ( const char * path ) { <nl> + return cli_ - > Options ( path ) ; <nl> + } <nl> <nl> - std : : shared_ptr < Response > Options ( const char * path , const Headers & headers ) { <nl> - return cli_ - > Options ( path , headers ) ; <nl> - } <nl> + std : : shared_ptr < Response > Options ( const char * path , const Headers & headers ) { <nl> + return cli_ - > Options ( path , headers ) ; <nl> + } <nl> <nl> - bool send ( const Request & req , Response & res ) { return cli_ - > send ( req , res ) ; } <nl> + bool send ( const Request & req , Response & res ) { <nl> + return cli_ - > send ( req , res ) ; <nl> + } <nl> <nl> - bool is_socket_open ( ) { return cli_ - > is_socket_open ( ) ; } <nl> + bool is_socket_open ( ) { <nl> + return cli_ - > is_socket_open ( ) ; <nl> + } <nl> <nl> - void stop ( ) { cli_ - > stop ( ) ; } <nl> + void stop ( ) { <nl> + cli_ - > stop ( ) ; <nl> + } <nl> <nl> - void set_tcp_nodelay ( bool on ) { <nl> - cli_ - > set_tcp_nodelay ( on ) ; <nl> - } <nl> + void set_tcp_nodelay ( bool on ) { <nl> + cli_ - > set_tcp_nodelay ( on ) ; <nl> + } <nl> <nl> - void set_socket_options ( SocketOptions socket_options ) { <nl> - cli_ - > set_socket_options ( socket_options ) ; <nl> - } <nl> + void set_socket_options ( SocketOptions socket_options ) { <nl> + cli_ - > set_socket_options ( socket_options ) ; <nl> + } <nl> <nl> - Client2 & set_connection_timeout ( time_t sec , time_t usec ) { <nl> - cli_ - > set_connection_timeout ( sec , usec ) ; <nl> - return * this ; <nl> - } <nl> + Client2 & set_connection_timeout ( time_t sec , time_t usec ) { <nl> + cli_ - > set_connection_timeout ( sec , usec ) ; <nl> + return * this ; <nl> + } <nl> <nl> - Client2 & set_read_timeout ( time_t sec , time_t usec ) { <nl> - cli_ - > set_read_timeout ( sec , usec ) ; <nl> - return * this ; <nl> - } <nl> + Client2 & set_read_timeout ( time_t sec , time_t usec ) { <nl> + cli_ - > set_read_timeout ( sec , usec ) ; <nl> + return * this ; <nl> + } <nl> <nl> - Client2 & set_basic_auth ( const char * username , const char * password ) { <nl> - cli_ - > set_basic_auth ( username , password ) ; <nl> - return * this ; <nl> - } <nl> + Client2 & set_basic_auth ( const char * username , const char * password ) { <nl> + cli_ - > set_basic_auth ( username , password ) ; <nl> + return * this ; <nl> + } <nl> <nl> # ifdef CPPHTTPLIB_OPENSSL_SUPPORT <nl> - Client2 & set_digest_auth ( const char * username , const char * password ) { <nl> - cli_ - > set_digest_auth ( username , password ) ; <nl> - return * this ; <nl> - } <nl> + Client2 & set_digest_auth ( const char * username , const char * password ) { <nl> + cli_ - > set_digest_auth ( username , password ) ; <nl> + return * this ; <nl> + } <nl> # endif <nl> <nl> - Client2 & set_keep_alive ( bool on ) { <nl> - cli_ - > set_keep_alive ( on ) ; <nl> - return * this ; <nl> - } <nl> - <nl> - Client2 & set_follow_location ( bool on ) { <nl> - cli_ - > set_follow_location ( on ) ; <nl> - return * this ; <nl> - } <nl> - <nl> - Client2 & set_compress ( bool on ) { <nl> - cli_ - > set_compress ( on ) ; <nl> - return * this ; <nl> - } <nl> - <nl> - Client2 & set_decompress ( bool on ) { <nl> - cli_ - > set_decompress ( on ) ; <nl> - return * this ; <nl> - } <nl> - <nl> - Client2 & set_interface ( const char * intf ) { <nl> - cli_ - > set_interface ( intf ) ; <nl> - return * this ; <nl> - } <nl> - <nl> - Client2 & set_proxy ( const char * host , int port ) { <nl> - cli_ - > set_proxy ( host , port ) ; <nl> - return * this ; <nl> - } <nl> - <nl> - Client2 & set_proxy_basic_auth ( const char * username , const char * password ) { <nl> - cli_ - > set_proxy_basic_auth ( username , password ) ; <nl> - return * this ; <nl> - } <nl> + Client2 & set_keep_alive ( bool on ) { <nl> + cli_ - > set_keep_alive ( on ) ; <nl> + return * this ; <nl> + } <nl> + <nl> + Client2 & set_follow_location ( bool on ) { <nl> + cli_ - > set_follow_location ( on ) ; <nl> + return * this ; <nl> + } <nl> + <nl> + Client2 & set_compress ( bool on ) { <nl> + cli_ - > set_compress ( on ) ; <nl> + return * this ; <nl> + } <nl> + <nl> + Client2 & set_decompress ( bool on ) { <nl> + cli_ - > set_decompress ( on ) ; <nl> + return * this ; <nl> + } <nl> + <nl> + Client2 & set_interface ( const char * intf ) { <nl> + cli_ - > set_interface ( intf ) ; <nl> + return * this ; <nl> + } <nl> + <nl> + Client2 & set_proxy ( const char * host , int port ) { <nl> + cli_ - > set_proxy ( host , port ) ; <nl> + return * this ; <nl> + } <nl> + <nl> + Client2 & set_proxy_basic_auth ( const char * username , const char * password ) { <nl> + cli_ - > set_proxy_basic_auth ( username , password ) ; <nl> + return * this ; <nl> + } <nl> <nl> # ifdef CPPHTTPLIB_OPENSSL_SUPPORT <nl> - Client2 & set_proxy_digest_auth ( const char * username , const char * password ) { <nl> - cli_ - > set_proxy_digest_auth ( username , password ) ; <nl> - return * this ; <nl> - } <nl> + Client2 & set_proxy_digest_auth ( const char * username , const char * password ) { <nl> + cli_ - > set_proxy_digest_auth ( username , password ) ; <nl> + return * this ; <nl> + } <nl> # endif <nl> <nl> - Client2 & set_logger ( Logger logger ) { <nl> - cli_ - > set_logger ( logger ) ; <nl> - return * this ; <nl> - } <nl> + Client2 & set_logger ( Logger logger ) { <nl> + cli_ - > set_logger ( logger ) ; <nl> + return * this ; <nl> + } <nl> <nl> - / / SSL <nl> + / / SSL <nl> # ifdef CPPHTTPLIB_OPENSSL_SUPPORT <nl> - Client2 & set_ca_cert_path ( const char * ca_cert_file_path , <nl> - const char * ca_cert_dir_path = nullptr ) { <nl> - if ( is_ssl_ ) { <nl> - static_cast < SSLClient & > ( * cli_ ) . set_ca_cert_path ( ca_cert_file_path , <nl> - ca_cert_dir_path ) ; <nl> + Client2 & set_ca_cert_path ( const char * ca_cert_file_path , const char * ca_cert_dir_path = nullptr ) { <nl> + if ( is_ssl_ ) { <nl> + static_cast < SSLClient & > ( * cli_ ) . set_ca_cert_path ( ca_cert_file_path , ca_cert_dir_path ) ; <nl> + } <nl> + return * this ; <nl> } <nl> - return * this ; <nl> - } <nl> <nl> - Client2 & set_ca_cert_store ( X509_STORE * ca_cert_store ) { <nl> - if ( is_ssl_ ) { <nl> - static_cast < SSLClient & > ( * cli_ ) . set_ca_cert_store ( ca_cert_store ) ; <nl> + Client2 & set_ca_cert_store ( X509_STORE * ca_cert_store ) { <nl> + if ( is_ssl_ ) { <nl> + static_cast < SSLClient & > ( * cli_ ) . set_ca_cert_store ( ca_cert_store ) ; <nl> + } <nl> + return * this ; <nl> } <nl> - return * this ; <nl> - } <nl> <nl> - Client2 & enable_server_certificate_verification ( bool enabled ) { <nl> - if ( is_ssl_ ) { <nl> - static_cast < SSLClient & > ( * cli_ ) . enable_server_certificate_verification ( <nl> - enabled ) ; <nl> + Client2 & enable_server_certificate_verification ( bool enabled ) { <nl> + if ( is_ssl_ ) { <nl> + static_cast < SSLClient & > ( * cli_ ) . enable_server_certificate_verification ( enabled ) ; <nl> + } <nl> + return * this ; <nl> } <nl> - return * this ; <nl> - } <nl> <nl> - long get_openssl_verify_result ( ) const { <nl> - if ( is_ssl_ ) { <nl> - return static_cast < SSLClient & > ( * cli_ ) . get_openssl_verify_result ( ) ; <nl> + long get_openssl_verify_result ( ) const { <nl> + if ( is_ssl_ ) { <nl> + return static_cast < SSLClient & > ( * cli_ ) . get_openssl_verify_result ( ) ; <nl> + } <nl> + return - 1 ; / / NOTE : - 1 doesn ' t match any of X509_V_ERR_ ? ? ? <nl> } <nl> - return - 1 ; / / NOTE : - 1 doesn ' t match any of X509_V_ERR_ ? ? ? <nl> - } <nl> <nl> - SSL_CTX * ssl_context ( ) const { <nl> - if ( is_ssl_ ) { return static_cast < SSLClient & > ( * cli_ ) . ssl_context ( ) ; } <nl> - return nullptr ; <nl> - } <nl> + SSL_CTX * ssl_context ( ) const { <nl> + if ( is_ssl_ ) { <nl> + return static_cast < SSLClient & > ( * cli_ ) . ssl_context ( ) ; <nl> + } <nl> + return nullptr ; <nl> + } <nl> # endif <nl> <nl> - private : <nl> + private : <nl> # ifdef CPPHTTPLIB_OPENSSL_SUPPORT <nl> - bool is_ssl_ = false ; <nl> + bool is_ssl_ = false ; <nl> # endif <nl> - std : : shared_ptr < Client > cli_ ; <nl> + std : : shared_ptr < Client > cli_ ; <nl> } ; <nl> <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> class Client2 { <nl> namespace detail { <nl> <nl> inline bool is_hex ( char c , int & v ) { <nl> - if ( 0x20 < = c & & isdigit ( c ) ) { <nl> - v = c - ' 0 ' ; <nl> - return true ; <nl> - } else if ( ' A ' < = c & & c < = ' F ' ) { <nl> - v = c - ' A ' + 10 ; <nl> - return true ; <nl> - } else if ( ' a ' < = c & & c < = ' f ' ) { <nl> - v = c - ' a ' + 10 ; <nl> - return true ; <nl> - } <nl> - return false ; <nl> + if ( 0x20 < = c & & isdigit ( c ) ) { <nl> + v = c - ' 0 ' ; <nl> + return true ; <nl> + } else if ( ' A ' < = c & & c < = ' F ' ) { <nl> + v = c - ' A ' + 10 ; <nl> + return true ; <nl> + } else if ( ' a ' < = c & & c < = ' f ' ) { <nl> + v = c - ' a ' + 10 ; <nl> + return true ; <nl> + } <nl> + return false ; <nl> } <nl> <nl> - inline bool from_hex_to_i ( const std : : string & s , size_t i , size_t cnt , <nl> - int & val ) { <nl> - if ( i > = s . size ( ) ) { return false ; } <nl> + inline bool from_hex_to_i ( const std : : string & s , size_t i , size_t cnt , int & val ) { <nl> + if ( i > = s . size ( ) ) { <nl> + return false ; <nl> + } <nl> <nl> - val = 0 ; <nl> - for ( ; cnt ; i + + , cnt - - ) { <nl> - if ( ! s [ i ] ) { return false ; } <nl> - int v = 0 ; <nl> - if ( is_hex ( s [ i ] , v ) ) { <nl> - val = val * 16 + v ; <nl> - } else { <nl> - return false ; <nl> + val = 0 ; <nl> + for ( ; cnt ; i + + , cnt - - ) { <nl> + if ( ! s [ i ] ) { <nl> + return false ; <nl> + } <nl> + int v = 0 ; <nl> + if ( is_hex ( s [ i ] , v ) ) { <nl> + val = val * 16 + v ; <nl> + } else { <nl> + return false ; <nl> + } <nl> } <nl> - } <nl> - return true ; <nl> + return true ; <nl> } <nl> <nl> inline std : : string from_i_to_hex ( size_t n ) { <nl> - const char * charset = " 0123456789abcdef " ; <nl> - std : : string ret ; <nl> - do { <nl> - ret = charset [ n & 15 ] + ret ; <nl> - n > > = 4 ; <nl> - } while ( n > 0 ) ; <nl> - return ret ; <nl> + const char * charset = " 0123456789abcdef " ; <nl> + std : : string ret ; <nl> + do { <nl> + ret = charset [ n & 15 ] + ret ; <nl> + n > > = 4 ; <nl> + } while ( n > 0 ) ; <nl> + return ret ; <nl> } <nl> <nl> inline size_t to_utf8 ( int code , char * buff ) { <nl> - if ( code < 0x0080 ) { <nl> - buff [ 0 ] = ( code & 0x7F ) ; <nl> - return 1 ; <nl> - } else if ( code < 0x0800 ) { <nl> - buff [ 0 ] = static_cast < char > ( 0xC0 | ( ( code > > 6 ) & 0x1F ) ) ; <nl> - buff [ 1 ] = static_cast < char > ( 0x80 | ( code & 0x3F ) ) ; <nl> - return 2 ; <nl> - } else if ( code < 0xD800 ) { <nl> - buff [ 0 ] = static_cast < char > ( 0xE0 | ( ( code > > 12 ) & 0xF ) ) ; <nl> - buff [ 1 ] = static_cast < char > ( 0x80 | ( ( code > > 6 ) & 0x3F ) ) ; <nl> - buff [ 2 ] = static_cast < char > ( 0x80 | ( code & 0x3F ) ) ; <nl> - return 3 ; <nl> - } else if ( code < 0xE000 ) { / / D800 - DFFF is invalid . . . <nl> + if ( code < 0x0080 ) { <nl> + buff [ 0 ] = ( code & 0x7F ) ; <nl> + return 1 ; <nl> + } else if ( code < 0x0800 ) { <nl> + buff [ 0 ] = static_cast < char > ( 0xC0 | ( ( code > > 6 ) & 0x1F ) ) ; <nl> + buff [ 1 ] = static_cast < char > ( 0x80 | ( code & 0x3F ) ) ; <nl> + return 2 ; <nl> + } else if ( code < 0xD800 ) { <nl> + buff [ 0 ] = static_cast < char > ( 0xE0 | ( ( code > > 12 ) & 0xF ) ) ; <nl> + buff [ 1 ] = static_cast < char > ( 0x80 | ( ( code > > 6 ) & 0x3F ) ) ; <nl> + buff [ 2 ] = static_cast < char > ( 0x80 | ( code & 0x3F ) ) ; <nl> + return 3 ; <nl> + } else if ( code < 0xE000 ) { / / D800 - DFFF is invalid . . . <nl> + return 0 ; <nl> + } else if ( code < 0x10000 ) { <nl> + buff [ 0 ] = static_cast < char > ( 0xE0 | ( ( code > > 12 ) & 0xF ) ) ; <nl> + buff [ 1 ] = static_cast < char > ( 0x80 | ( ( code > > 6 ) & 0x3F ) ) ; <nl> + buff [ 2 ] = static_cast < char > ( 0x80 | ( code & 0x3F ) ) ; <nl> + return 3 ; <nl> + } else if ( code < 0x110000 ) { <nl> + buff [ 0 ] = static_cast < char > ( 0xF0 | ( ( code > > 18 ) & 0x7 ) ) ; <nl> + buff [ 1 ] = static_cast < char > ( 0x80 | ( ( code > > 12 ) & 0x3F ) ) ; <nl> + buff [ 2 ] = static_cast < char > ( 0x80 | ( ( code > > 6 ) & 0x3F ) ) ; <nl> + buff [ 3 ] = static_cast < char > ( 0x80 | ( code & 0x3F ) ) ; <nl> + return 4 ; <nl> + } <nl> + <nl> + / / NOTREACHED <nl> return 0 ; <nl> - } else if ( code < 0x10000 ) { <nl> - buff [ 0 ] = static_cast < char > ( 0xE0 | ( ( code > > 12 ) & 0xF ) ) ; <nl> - buff [ 1 ] = static_cast < char > ( 0x80 | ( ( code > > 6 ) & 0x3F ) ) ; <nl> - buff [ 2 ] = static_cast < char > ( 0x80 | ( code & 0x3F ) ) ; <nl> - return 3 ; <nl> - } else if ( code < 0x110000 ) { <nl> - buff [ 0 ] = static_cast < char > ( 0xF0 | ( ( code > > 18 ) & 0x7 ) ) ; <nl> - buff [ 1 ] = static_cast < char > ( 0x80 | ( ( code > > 12 ) & 0x3F ) ) ; <nl> - buff [ 2 ] = static_cast < char > ( 0x80 | ( ( code > > 6 ) & 0x3F ) ) ; <nl> - buff [ 3 ] = static_cast < char > ( 0x80 | ( code & 0x3F ) ) ; <nl> - return 4 ; <nl> - } <nl> - <nl> - / / NOTREACHED <nl> - return 0 ; <nl> } <nl> <nl> / / NOTE : This code came up with the following stackoverflow post : <nl> / / https : / / stackoverflow . com / questions / 180947 / base64 - decode - snippet - in - c <nl> inline std : : string base64_encode ( const std : : string & in ) { <nl> - static const auto lookup = <nl> - " ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 + / " ; <nl> + static const auto lookup = " ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 + / " ; <nl> <nl> - std : : string out ; <nl> - out . reserve ( in . size ( ) ) ; <nl> + std : : string out ; <nl> + out . reserve ( in . size ( ) ) ; <nl> <nl> - int val = 0 ; <nl> - int valb = - 6 ; <nl> + int val = 0 ; <nl> + int valb = - 6 ; <nl> <nl> - for ( auto c : in ) { <nl> - val = ( val < < 8 ) + static_cast < uint8_t > ( c ) ; <nl> - valb + = 8 ; <nl> - while ( valb > = 0 ) { <nl> - out . push_back ( lookup [ ( val > > valb ) & 0x3F ] ) ; <nl> - valb - = 6 ; <nl> + for ( auto c : in ) { <nl> + val = ( val < < 8 ) + static_cast < uint8_t > ( c ) ; <nl> + valb + = 8 ; <nl> + while ( valb > = 0 ) { <nl> + out . push_back ( lookup [ ( val > > valb ) & 0x3F ] ) ; <nl> + valb - = 6 ; <nl> + } <nl> } <nl> - } <nl> <nl> - if ( valb > - 6 ) { out . push_back ( lookup [ ( ( val < < 8 ) > > ( valb + 8 ) ) & 0x3F ] ) ; } <nl> + if ( valb > - 6 ) { <nl> + out . push_back ( lookup [ ( ( val < < 8 ) > > ( valb + 8 ) ) & 0x3F ] ) ; <nl> + } <nl> <nl> - while ( out . size ( ) % 4 ) { <nl> - out . push_back ( ' = ' ) ; <nl> - } <nl> + while ( out . size ( ) % 4 ) { <nl> + out . push_back ( ' = ' ) ; <nl> + } <nl> <nl> - return out ; <nl> + return out ; <nl> } <nl> <nl> inline bool is_file ( const std : : string & path ) { <nl> - struct stat st ; <nl> - return stat ( path . c_str ( ) , & st ) > = 0 & & S_ISREG ( st . st_mode ) ; <nl> + struct stat st ; <nl> + return stat ( path . c_str ( ) , & st ) > = 0 & & S_ISREG ( st . st_mode ) ; <nl> } <nl> <nl> inline bool is_dir ( const std : : string & path ) { <nl> - struct stat st ; <nl> - return stat ( path . c_str ( ) , & st ) > = 0 & & S_ISDIR ( st . st_mode ) ; <nl> + struct stat st ; <nl> + return stat ( path . c_str ( ) , & st ) > = 0 & & S_ISDIR ( st . st_mode ) ; <nl> } <nl> <nl> inline bool is_valid_path ( const std : : string & path ) { <nl> - size_t level = 0 ; <nl> - size_t i = 0 ; <nl> - <nl> - / / Skip slash <nl> - while ( i < path . size ( ) & & path [ i ] = = ' / ' ) { <nl> - i + + ; <nl> - } <nl> + size_t level = 0 ; <nl> + size_t i = 0 ; <nl> <nl> - while ( i < path . size ( ) ) { <nl> - / / Read component <nl> - auto beg = i ; <nl> - while ( i < path . size ( ) & & path [ i ] ! = ' / ' ) { <nl> - i + + ; <nl> + / / Skip slash <nl> + while ( i < path . size ( ) & & path [ i ] = = ' / ' ) { <nl> + i + + ; <nl> } <nl> <nl> - auto len = i - beg ; <nl> - assert ( len > 0 ) ; <nl> + while ( i < path . size ( ) ) { <nl> + / / Read component <nl> + auto beg = i ; <nl> + while ( i < path . size ( ) & & path [ i ] ! = ' / ' ) { <nl> + i + + ; <nl> + } <nl> <nl> - if ( ! path . compare ( beg , len , " . " ) ) { <nl> - ; <nl> - } else if ( ! path . compare ( beg , len , " . . " ) ) { <nl> - if ( level = = 0 ) { return false ; } <nl> - level - - ; <nl> - } else { <nl> - level + + ; <nl> - } <nl> + auto len = i - beg ; <nl> + assert ( len > 0 ) ; <nl> <nl> - / / Skip slash <nl> - while ( i < path . size ( ) & & path [ i ] = = ' / ' ) { <nl> - i + + ; <nl> + if ( ! path . compare ( beg , len , " . " ) ) { <nl> + ; <nl> + } else if ( ! path . compare ( beg , len , " . . " ) ) { <nl> + if ( level = = 0 ) { <nl> + return false ; <nl> + } <nl> + level - - ; <nl> + } else { <nl> + level + + ; <nl> + } <nl> + <nl> + / / Skip slash <nl> + while ( i < path . size ( ) & & path [ i ] = = ' / ' ) { <nl> + i + + ; <nl> + } <nl> } <nl> - } <nl> <nl> - return true ; <nl> + return true ; <nl> } <nl> <nl> inline void read_file ( const std : : string & path , std : : string & out ) { <nl> - std : : ifstream fs ( path , std : : ios_base : : binary ) ; <nl> - fs . seekg ( 0 , std : : ios_base : : end ) ; <nl> - auto size = fs . tellg ( ) ; <nl> - fs . seekg ( 0 ) ; <nl> - out . resize ( static_cast < size_t > ( size ) ) ; <nl> - fs . read ( & out [ 0 ] , static_cast < std : : streamsize > ( size ) ) ; <nl> + std : : ifstream fs ( path , std : : ios_base : : binary ) ; <nl> + fs . seekg ( 0 , std : : ios_base : : end ) ; <nl> + auto size = fs . tellg ( ) ; <nl> + fs . seekg ( 0 ) ; <nl> + out . resize ( static_cast < size_t > ( size ) ) ; <nl> + fs . read ( & out [ 0 ] , static_cast < std : : streamsize > ( size ) ) ; <nl> } <nl> <nl> inline std : : string file_extension ( const std : : string & path ) { <nl> - std : : smatch m ; <nl> - static auto re = std : : regex ( " \ \ . ( [ a - zA - Z0 - 9 ] + ) $ " ) ; <nl> - if ( std : : regex_search ( path , m , re ) ) { return m [ 1 ] . str ( ) ; } <nl> - return std : : string ( ) ; <nl> + std : : smatch m ; <nl> + static auto re = std : : regex ( " \ \ . ( [ a - zA - Z0 - 9 ] + ) $ " ) ; <nl> + if ( std : : regex_search ( path , m , re ) ) { <nl> + return m [ 1 ] . str ( ) ; <nl> + } <nl> + return std : : string ( ) ; <nl> } <nl> <nl> - template < class Fn > void split ( const char * b , const char * e , char d , Fn fn ) { <nl> - int i = 0 ; <nl> - int beg = 0 ; <nl> + template < class Fn > <nl> + void split ( const char * b , const char * e , char d , Fn fn ) { <nl> + int i = 0 ; <nl> + int beg = 0 ; <nl> <nl> - while ( e ? ( b + i ! = e ) : ( b [ i ] ! = ' \ 0 ' ) ) { <nl> - if ( b [ i ] = = d ) { <nl> - fn ( & b [ beg ] , & b [ i ] ) ; <nl> - beg = i + 1 ; <nl> + while ( e ? ( b + i ! = e ) : ( b [ i ] ! = ' \ 0 ' ) ) { <nl> + if ( b [ i ] = = d ) { <nl> + fn ( & b [ beg ] , & b [ i ] ) ; <nl> + beg = i + 1 ; <nl> + } <nl> + i + + ; <nl> } <nl> - i + + ; <nl> - } <nl> <nl> - if ( i ) { fn ( & b [ beg ] , & b [ i ] ) ; } <nl> + if ( i ) { <nl> + fn ( & b [ beg ] , & b [ i ] ) ; <nl> + } <nl> } <nl> <nl> / / NOTE : until the read size reaches ` fixed_buffer_size ` , use ` fixed_buffer ` <nl> / / to store data . The call can set memory on stack for performance . <nl> class stream_line_reader { <nl> - public : <nl> - stream_line_reader ( Stream & strm , char * fixed_buffer , size_t fixed_buffer_size ) <nl> - : strm_ ( strm ) , fixed_buffer_ ( fixed_buffer ) , <nl> - fixed_buffer_size_ ( fixed_buffer_size ) { } <nl> - <nl> - const char * ptr ( ) const { <nl> - if ( glowable_buffer_ . empty ( ) ) { <nl> - return fixed_buffer_ ; <nl> - } else { <nl> - return glowable_buffer_ . data ( ) ; <nl> + public : <nl> + stream_line_reader ( Stream & strm , char * fixed_buffer , size_t fixed_buffer_size ) <nl> + : strm_ ( strm ) , fixed_buffer_ ( fixed_buffer ) , fixed_buffer_size_ ( fixed_buffer_size ) { } <nl> + <nl> + const char * ptr ( ) const { <nl> + if ( glowable_buffer_ . empty ( ) ) { <nl> + return fixed_buffer_ ; <nl> + } else { <nl> + return glowable_buffer_ . data ( ) ; <nl> + } <nl> } <nl> - } <nl> <nl> - size_t size ( ) const { <nl> - if ( glowable_buffer_ . empty ( ) ) { <nl> - return fixed_buffer_used_size_ ; <nl> - } else { <nl> - return glowable_buffer_ . size ( ) ; <nl> + size_t size ( ) const { <nl> + if ( glowable_buffer_ . empty ( ) ) { <nl> + return fixed_buffer_used_size_ ; <nl> + } else { <nl> + return glowable_buffer_ . size ( ) ; <nl> + } <nl> } <nl> - } <nl> <nl> - bool end_with_crlf ( ) const { <nl> - auto end = ptr ( ) + size ( ) ; <nl> - return size ( ) > = 2 & & end [ - 2 ] = = ' \ r ' & & end [ - 1 ] = = ' \ n ' ; <nl> - } <nl> + bool end_with_crlf ( ) const { <nl> + auto end = ptr ( ) + size ( ) ; <nl> + return size ( ) > = 2 & & end [ - 2 ] = = ' \ r ' & & end [ - 1 ] = = ' \ n ' ; <nl> + } <nl> <nl> - bool getline ( ) { <nl> - fixed_buffer_used_size_ = 0 ; <nl> - glowable_buffer_ . clear ( ) ; <nl> + bool getline ( ) { <nl> + fixed_buffer_used_size_ = 0 ; <nl> + glowable_buffer_ . clear ( ) ; <nl> <nl> - for ( size_t i = 0 ; ; i + + ) { <nl> - char byte ; <nl> - auto n = strm_ . read ( & byte , 1 ) ; <nl> + for ( size_t i = 0 ; ; i + + ) { <nl> + char byte ; <nl> + auto n = strm_ . read ( & byte , 1 ) ; <nl> <nl> - if ( n < 0 ) { <nl> - return false ; <nl> - } else if ( n = = 0 ) { <nl> - if ( i = = 0 ) { <nl> - return false ; <nl> - } else { <nl> - break ; <nl> - } <nl> - } <nl> + if ( n < 0 ) { <nl> + return false ; <nl> + } else if ( n = = 0 ) { <nl> + if ( i = = 0 ) { <nl> + return false ; <nl> + } else { <nl> + break ; <nl> + } <nl> + } <nl> + <nl> + append ( byte ) ; <nl> <nl> - append ( byte ) ; <nl> + if ( byte = = ' \ n ' ) { <nl> + break ; <nl> + } <nl> + } <nl> <nl> - if ( byte = = ' \ n ' ) { break ; } <nl> + return true ; <nl> } <nl> <nl> - return true ; <nl> - } <nl> + private : <nl> + void append ( char c ) { <nl> + if ( fixed_buffer_used_size_ < fixed_buffer_size_ - 1 ) { <nl> + fixed_buffer_ [ fixed_buffer_used_size_ + + ] = c ; <nl> + fixed_buffer_ [ fixed_buffer_used_size_ ] = ' \ 0 ' ; <nl> + } else { <nl> + if ( glowable_buffer_ . empty ( ) ) { <nl> + assert ( fixed_buffer_ [ fixed_buffer_used_size_ ] = = ' \ 0 ' ) ; <nl> + glowable_buffer_ . assign ( fixed_buffer_ , fixed_buffer_used_size_ ) ; <nl> + } <nl> + glowable_buffer_ + = c ; <nl> + } <nl> + } <nl> <nl> - private : <nl> - void append ( char c ) { <nl> - if ( fixed_buffer_used_size_ < fixed_buffer_size_ - 1 ) { <nl> - fixed_buffer_ [ fixed_buffer_used_size_ + + ] = c ; <nl> - fixed_buffer_ [ fixed_buffer_used_size_ ] = ' \ 0 ' ; <nl> - } else { <nl> - if ( glowable_buffer_ . empty ( ) ) { <nl> - assert ( fixed_buffer_ [ fixed_buffer_used_size_ ] = = ' \ 0 ' ) ; <nl> - glowable_buffer_ . assign ( fixed_buffer_ , fixed_buffer_used_size_ ) ; <nl> - } <nl> - glowable_buffer_ + = c ; <nl> - } <nl> - } <nl> - <nl> - Stream & strm_ ; <nl> - char * fixed_buffer_ ; <nl> - const size_t fixed_buffer_size_ ; <nl> - size_t fixed_buffer_used_size_ = 0 ; <nl> - std : : string glowable_buffer_ ; <nl> + Stream & strm_ ; <nl> + char * fixed_buffer_ ; <nl> + const size_t fixed_buffer_size_ ; <nl> + size_t fixed_buffer_used_size_ = 0 ; <nl> + std : : string glowable_buffer_ ; <nl> } ; <nl> <nl> inline int close_socket ( socket_t sock ) { <nl> # ifdef _WIN32 <nl> - return closesocket ( sock ) ; <nl> + return closesocket ( sock ) ; <nl> # else <nl> - return close ( sock ) ; <nl> + return close ( sock ) ; <nl> # endif <nl> } <nl> <nl> - template < typename T > inline ssize_t handle_EINTR ( T fn ) { <nl> - ssize_t res = false ; <nl> - while ( true ) { <nl> - res = fn ( ) ; <nl> - if ( res < 0 & & errno = = EINTR ) { continue ; } <nl> - break ; <nl> - } <nl> - return res ; <nl> + template < typename T > <nl> + inline ssize_t handle_EINTR ( T fn ) { <nl> + ssize_t res = false ; <nl> + while ( true ) { <nl> + res = fn ( ) ; <nl> + if ( res < 0 & & errno = = EINTR ) { <nl> + continue ; <nl> + } <nl> + break ; <nl> + } <nl> + return res ; <nl> } <nl> <nl> inline ssize_t select_read ( socket_t sock , time_t sec , time_t usec ) { <nl> # ifdef CPPHTTPLIB_USE_POLL <nl> - struct pollfd pfd_read ; <nl> - pfd_read . fd = sock ; <nl> - pfd_read . events = POLLIN ; <nl> + struct pollfd pfd_read ; <nl> + pfd_read . fd = sock ; <nl> + pfd_read . events = POLLIN ; <nl> <nl> - auto timeout = static_cast < int > ( sec * 1000 + usec ) ; <nl> + auto timeout = static_cast < int > ( sec * 1000 + usec ) ; <nl> <nl> - return handle_EINTR ( [ & ] ( ) { return poll ( & pfd_read , 1 , timeout ) ; } ) ; <nl> + return handle_EINTR ( [ & ] ( ) { return poll ( & pfd_read , 1 , timeout ) ; } ) ; <nl> # else <nl> - fd_set fds ; <nl> - FD_ZERO ( & fds ) ; <nl> - FD_SET ( sock , & fds ) ; <nl> + fd_set fds ; <nl> + FD_ZERO ( & fds ) ; <nl> + FD_SET ( sock , & fds ) ; <nl> <nl> - timeval tv ; <nl> - tv . tv_sec = static_cast < long > ( sec ) ; <nl> - tv . tv_usec = static_cast < decltype ( tv . tv_usec ) > ( usec ) ; <nl> + timeval tv ; <nl> + tv . tv_sec = static_cast < long > ( sec ) ; <nl> + tv . tv_usec = static_cast < decltype ( tv . tv_usec ) > ( usec ) ; <nl> <nl> - return handle_EINTR ( [ & ] ( ) { <nl> - return select ( static_cast < int > ( sock + 1 ) , & fds , nullptr , nullptr , & tv ) ; <nl> - } ) ; <nl> + return handle_EINTR ( [ & ] ( ) { return select ( static_cast < int > ( sock + 1 ) , & fds , nullptr , nullptr , & tv ) ; } ) ; <nl> # endif <nl> } <nl> <nl> inline ssize_t select_write ( socket_t sock , time_t sec , time_t usec ) { <nl> # ifdef CPPHTTPLIB_USE_POLL <nl> - struct pollfd pfd_read ; <nl> - pfd_read . fd = sock ; <nl> - pfd_read . events = POLLOUT ; <nl> + struct pollfd pfd_read ; <nl> + pfd_read . fd = sock ; <nl> + pfd_read . events = POLLOUT ; <nl> <nl> - auto timeout = static_cast < int > ( sec * 1000 + usec / 1000 ) ; <nl> + auto timeout = static_cast < int > ( sec * 1000 + usec / 1000 ) ; <nl> <nl> - return handle_EINTR ( [ & ] ( ) { return poll ( & pfd_read , 1 , timeout ) ; } ) ; <nl> + return handle_EINTR ( [ & ] ( ) { return poll ( & pfd_read , 1 , timeout ) ; } ) ; <nl> # else <nl> - fd_set fds ; <nl> - FD_ZERO ( & fds ) ; <nl> - FD_SET ( sock , & fds ) ; <nl> + fd_set fds ; <nl> + FD_ZERO ( & fds ) ; <nl> + FD_SET ( sock , & fds ) ; <nl> <nl> - timeval tv ; <nl> - tv . tv_sec = static_cast < long > ( sec ) ; <nl> - tv . tv_usec = static_cast < decltype ( tv . tv_usec ) > ( usec ) ; <nl> + timeval tv ; <nl> + tv . tv_sec = static_cast < long > ( sec ) ; <nl> + tv . tv_usec = static_cast < decltype ( tv . tv_usec ) > ( usec ) ; <nl> <nl> - return handle_EINTR ( [ & ] ( ) { <nl> - return select ( static_cast < int > ( sock + 1 ) , nullptr , & fds , nullptr , & tv ) ; <nl> - } ) ; <nl> + return handle_EINTR ( [ & ] ( ) { return select ( static_cast < int > ( sock + 1 ) , nullptr , & fds , nullptr , & tv ) ; } ) ; <nl> # endif <nl> } <nl> <nl> inline bool wait_until_socket_is_ready ( socket_t sock , time_t sec , time_t usec ) { <nl> # ifdef CPPHTTPLIB_USE_POLL <nl> - struct pollfd pfd_read ; <nl> - pfd_read . fd = sock ; <nl> - pfd_read . events = POLLIN | POLLOUT ; <nl> - <nl> - auto timeout = static_cast < int > ( sec * 1000 + usec ) ; <nl> - <nl> - auto poll_res = handle_EINTR ( [ & ] ( ) { return poll ( & pfd_read , 1 , timeout ) ; } ) ; <nl> - <nl> - if ( poll_res > 0 & & pfd_read . revents & ( POLLIN | POLLOUT ) ) { <nl> - int error = 0 ; <nl> - socklen_t len = sizeof ( error ) ; <nl> - auto res = getsockopt ( sock , SOL_SOCKET , SO_ERROR , <nl> - reinterpret_cast < char * > ( & error ) , & len ) ; <nl> - return res > = 0 & & ! error ; <nl> - } <nl> - return false ; <nl> + struct pollfd pfd_read ; <nl> + pfd_read . fd = sock ; <nl> + pfd_read . events = POLLIN | POLLOUT ; <nl> + <nl> + auto timeout = static_cast < int > ( sec * 1000 + usec ) ; <nl> + <nl> + auto poll_res = handle_EINTR ( [ & ] ( ) { return poll ( & pfd_read , 1 , timeout ) ; } ) ; <nl> + <nl> + if ( poll_res > 0 & & pfd_read . revents & ( POLLIN | POLLOUT ) ) { <nl> + int error = 0 ; <nl> + socklen_t len = sizeof ( error ) ; <nl> + auto res = getsockopt ( sock , SOL_SOCKET , SO_ERROR , reinterpret_cast < char * > ( & error ) , & len ) ; <nl> + return res > = 0 & & ! error ; <nl> + } <nl> + return false ; <nl> # else <nl> - fd_set fdsr ; <nl> - FD_ZERO ( & fdsr ) ; <nl> - FD_SET ( sock , & fdsr ) ; <nl> - <nl> - auto fdsw = fdsr ; <nl> - auto fdse = fdsr ; <nl> - <nl> - timeval tv ; <nl> - tv . tv_sec = static_cast < long > ( sec ) ; <nl> - tv . tv_usec = static_cast < decltype ( tv . tv_usec ) > ( usec ) ; <nl> - <nl> - auto ret = handle_EINTR ( [ & ] ( ) { <nl> - return select ( static_cast < int > ( sock + 1 ) , & fdsr , & fdsw , & fdse , & tv ) ; <nl> - } ) ; <nl> - <nl> - if ( ret > 0 & & ( FD_ISSET ( sock , & fdsr ) | | FD_ISSET ( sock , & fdsw ) ) ) { <nl> - int error = 0 ; <nl> - socklen_t len = sizeof ( error ) ; <nl> - return getsockopt ( sock , SOL_SOCKET , SO_ERROR , <nl> - reinterpret_cast < char * > ( & error ) , & len ) > = 0 & & <nl> - ! error ; <nl> - } <nl> - return false ; <nl> + fd_set fdsr ; <nl> + FD_ZERO ( & fdsr ) ; <nl> + FD_SET ( sock , & fdsr ) ; <nl> + <nl> + auto fdsw = fdsr ; <nl> + auto fdse = fdsr ; <nl> + <nl> + timeval tv ; <nl> + tv . tv_sec = static_cast < long > ( sec ) ; <nl> + tv . tv_usec = static_cast < decltype ( tv . tv_usec ) > ( usec ) ; <nl> + <nl> + auto ret = handle_EINTR ( [ & ] ( ) { return select ( static_cast < int > ( sock + 1 ) , & fdsr , & fdsw , & fdse , & tv ) ; } ) ; <nl> + <nl> + if ( ret > 0 & & ( FD_ISSET ( sock , & fdsr ) | | FD_ISSET ( sock , & fdsw ) ) ) { <nl> + int error = 0 ; <nl> + socklen_t len = sizeof ( error ) ; <nl> + return getsockopt ( sock , SOL_SOCKET , SO_ERROR , reinterpret_cast < char * > ( & error ) , & len ) > = 0 & & ! error ; <nl> + } <nl> + return false ; <nl> # endif <nl> } <nl> <nl> class SocketStream : public Stream { <nl> - public : <nl> - SocketStream ( socket_t sock , time_t read_timeout_sec , time_t read_timeout_usec , <nl> - time_t write_timeout_sec , time_t write_timeout_usec ) ; <nl> - ~ SocketStream ( ) override ; <nl> - <nl> - bool is_readable ( ) const override ; <nl> - bool is_writable ( ) const override ; <nl> - ssize_t read ( char * ptr , size_t size ) override ; <nl> - ssize_t write ( const char * ptr , size_t size ) override ; <nl> - void get_remote_ip_and_port ( std : : string & ip , int & port ) const override ; <nl> - <nl> - private : <nl> - socket_t sock_ ; <nl> - time_t read_timeout_sec_ ; <nl> - time_t read_timeout_usec_ ; <nl> - time_t write_timeout_sec_ ; <nl> - time_t write_timeout_usec_ ; <nl> + public : <nl> + SocketStream ( socket_t sock , <nl> + time_t read_timeout_sec , <nl> + time_t read_timeout_usec , <nl> + time_t write_timeout_sec , <nl> + time_t write_timeout_usec ) ; <nl> + ~ SocketStream ( ) override ; <nl> + <nl> + bool is_readable ( ) const override ; <nl> + bool is_writable ( ) const override ; <nl> + ssize_t read ( char * ptr , size_t size ) override ; <nl> + ssize_t write ( const char * ptr , size_t size ) override ; <nl> + void get_remote_ip_and_port ( std : : string & ip , int & port ) const override ; <nl> + <nl> + private : <nl> + socket_t sock_ ; <nl> + time_t read_timeout_sec_ ; <nl> + time_t read_timeout_usec_ ; <nl> + time_t write_timeout_sec_ ; <nl> + time_t write_timeout_usec_ ; <nl> } ; <nl> <nl> # ifdef CPPHTTPLIB_OPENSSL_SUPPORT <nl> class SSLSocketStream : public Stream { <nl> - public : <nl> - SSLSocketStream ( socket_t sock , SSL * ssl , time_t read_timeout_sec , <nl> - time_t read_timeout_usec , time_t write_timeout_sec , <nl> - time_t write_timeout_usec ) ; <nl> - ~ SSLSocketStream ( ) override ; <nl> - <nl> - bool is_readable ( ) const override ; <nl> - bool is_writable ( ) const override ; <nl> - ssize_t read ( char * ptr , size_t size ) override ; <nl> - ssize_t write ( const char * ptr , size_t size ) override ; <nl> - void get_remote_ip_and_port ( std : : string & ip , int & port ) const override ; <nl> - <nl> - private : <nl> - socket_t sock_ ; <nl> - SSL * ssl_ ; <nl> - time_t read_timeout_sec_ ; <nl> - time_t read_timeout_usec_ ; <nl> - time_t write_timeout_sec_ ; <nl> - time_t write_timeout_usec_ ; <nl> + public : <nl> + SSLSocketStream ( socket_t sock , <nl> + SSL * ssl , <nl> + time_t read_timeout_sec , <nl> + time_t read_timeout_usec , <nl> + time_t write_timeout_sec , <nl> + time_t write_timeout_usec ) ; <nl> + ~ SSLSocketStream ( ) override ; <nl> + <nl> + bool is_readable ( ) const override ; <nl> + bool is_writable ( ) const override ; <nl> + ssize_t read ( char * ptr , size_t size ) override ; <nl> + ssize_t write ( const char * ptr , size_t size ) override ; <nl> + void get_remote_ip_and_port ( std : : string & ip , int & port ) const override ; <nl> + <nl> + private : <nl> + socket_t sock_ ; <nl> + SSL * ssl_ ; <nl> + time_t read_timeout_sec_ ; <nl> + time_t read_timeout_usec_ ; <nl> + time_t write_timeout_sec_ ; <nl> + time_t write_timeout_usec_ ; <nl> } ; <nl> # endif <nl> <nl> class BufferStream : public Stream { <nl> - public : <nl> - BufferStream ( ) = default ; <nl> - ~ BufferStream ( ) override = default ; <nl> + public : <nl> + BufferStream ( ) = default ; <nl> + ~ BufferStream ( ) override = default ; <nl> <nl> - bool is_readable ( ) const override ; <nl> - bool is_writable ( ) const override ; <nl> - ssize_t read ( char * ptr , size_t size ) override ; <nl> - ssize_t write ( const char * ptr , size_t size ) override ; <nl> - void get_remote_ip_and_port ( std : : string & ip , int & port ) const override ; <nl> + bool is_readable ( ) const override ; <nl> + bool is_writable ( ) const override ; <nl> + ssize_t read ( char * ptr , size_t size ) override ; <nl> + ssize_t write ( const char * ptr , size_t size ) override ; <nl> + void get_remote_ip_and_port ( std : : string & ip , int & port ) const override ; <nl> <nl> - const std : : string & get_buffer ( ) const ; <nl> + const std : : string & get_buffer ( ) const ; <nl> <nl> - private : <nl> - std : : string buffer ; <nl> - size_t position = 0 ; <nl> + private : <nl> + std : : string buffer ; <nl> + size_t position = 0 ; <nl> } ; <nl> <nl> inline bool keep_alive ( socket_t sock ) { <nl> - using namespace std : : chrono ; <nl> - auto start = steady_clock : : now ( ) ; <nl> - while ( true ) { <nl> - auto val = select_read ( sock , 0 , 10000 ) ; <nl> - if ( val < 0 ) { <nl> - return false ; <nl> - } else if ( val = = 0 ) { <nl> - auto current = steady_clock : : now ( ) ; <nl> - auto duration = duration_cast < milliseconds > ( current - start ) ; <nl> - auto timeout = CPPHTTPLIB_KEEPALIVE_TIMEOUT_SECOND * 100 + <nl> - CPPHTTPLIB_KEEPALIVE_TIMEOUT_SECOND ; <nl> - if ( duration . count ( ) > timeout ) { return false ; } <nl> - std : : this_thread : : sleep_for ( std : : chrono : : milliseconds ( 1 ) ) ; <nl> - } else { <nl> - return true ; <nl> + using namespace std : : chrono ; <nl> + auto start = steady_clock : : now ( ) ; <nl> + while ( true ) { <nl> + auto val = select_read ( sock , 0 , 10000 ) ; <nl> + if ( val < 0 ) { <nl> + return false ; <nl> + } else if ( val = = 0 ) { <nl> + auto current = steady_clock : : now ( ) ; <nl> + auto duration = duration_cast < milliseconds > ( current - start ) ; <nl> + auto timeout = CPPHTTPLIB_KEEPALIVE_TIMEOUT_SECOND * 100 + CPPHTTPLIB_KEEPALIVE_TIMEOUT_SECOND ; <nl> + if ( duration . count ( ) > timeout ) { <nl> + return false ; <nl> + } <nl> + std : : this_thread : : sleep_for ( std : : chrono : : milliseconds ( 1 ) ) ; <nl> + } else { <nl> + return true ; <nl> + } <nl> } <nl> - } <nl> } <nl> <nl> - <nl> template < typename T > <nl> - inline bool process_client_socket ( socket_t sock , time_t read_timeout_sec , <nl> + inline bool process_client_socket ( socket_t sock , <nl> + time_t read_timeout_sec , <nl> time_t read_timeout_usec , <nl> time_t write_timeout_sec , <nl> - time_t write_timeout_usec , T callback ) { <nl> - SocketStream strm ( sock , read_timeout_sec , read_timeout_usec , <nl> - write_timeout_sec , write_timeout_usec ) ; <nl> - return callback ( strm ) ; <nl> + time_t write_timeout_usec , <nl> + T callback ) { <nl> + SocketStream strm ( sock , read_timeout_sec , read_timeout_usec , write_timeout_sec , write_timeout_usec ) ; <nl> + return callback ( strm ) ; <nl> } <nl> <nl> inline int shutdown_socket ( socket_t sock ) { <nl> # ifdef _WIN32 <nl> - return shutdown ( sock , SD_BOTH ) ; <nl> + return shutdown ( sock , SD_BOTH ) ; <nl> # else <nl> - return shutdown ( sock , SHUT_RDWR ) ; <nl> + return shutdown ( sock , SHUT_RDWR ) ; <nl> # endif <nl> } <nl> <nl> template < typename BindOrConnect > <nl> - socket_t create_socket ( const char * host , int port , int socket_flags , <nl> - bool tcp_nodelay , SocketOptions socket_options , <nl> + socket_t create_socket ( const char * host , <nl> + int port , <nl> + int socket_flags , <nl> + bool tcp_nodelay , <nl> + SocketOptions socket_options , <nl> BindOrConnect bind_or_connect ) { <nl> - / / Get address info <nl> - struct addrinfo hints ; <nl> - struct addrinfo * result ; <nl> + / / Get address info <nl> + struct addrinfo hints ; <nl> + struct addrinfo * result ; <nl> <nl> - memset ( & hints , 0 , sizeof ( struct addrinfo ) ) ; <nl> - hints . ai_family = AF_UNSPEC ; <nl> - hints . ai_socktype = SOCK_STREAM ; <nl> - hints . ai_flags = socket_flags ; <nl> - hints . ai_protocol = 0 ; <nl> + memset ( & hints , 0 , sizeof ( struct addrinfo ) ) ; <nl> + hints . ai_family = AF_UNSPEC ; <nl> + hints . ai_socktype = SOCK_STREAM ; <nl> + hints . ai_flags = socket_flags ; <nl> + hints . ai_protocol = 0 ; <nl> <nl> - auto service = std : : to_string ( port ) ; <nl> + auto service = std : : to_string ( port ) ; <nl> <nl> - if ( getaddrinfo ( host , service . c_str ( ) , & hints , & result ) ) { <nl> - return INVALID_SOCKET ; <nl> - } <nl> + if ( getaddrinfo ( host , service . c_str ( ) , & hints , & result ) ) { <nl> + return INVALID_SOCKET ; <nl> + } <nl> <nl> - for ( auto rp = result ; rp ; rp = rp - > ai_next ) { <nl> - / / Create a socket <nl> + for ( auto rp = result ; rp ; rp = rp - > ai_next ) { <nl> + / / Create a socket <nl> # ifdef _WIN32 <nl> - auto sock = WSASocketW ( rp - > ai_family , rp - > ai_socktype , rp - > ai_protocol , <nl> - nullptr , 0 , WSA_FLAG_NO_HANDLE_INHERIT ) ; <nl> - / * * <nl> - * Since the WSA_FLAG_NO_HANDLE_INHERIT is only supported on Windows 7 SP1 <nl> - * and above the socket creation fails on older Windows Systems . <nl> - * <nl> - * Let ' s try to create a socket the old way in this case . <nl> - * <nl> - * Reference : <nl> - * https : / / docs . microsoft . com / en - us / windows / win32 / api / winsock2 / nf - winsock2 - wsasocketa <nl> - * <nl> - * WSA_FLAG_NO_HANDLE_INHERIT : <nl> - * This flag is supported on Windows 7 with SP1 , Windows Server 2008 R2 with <nl> - * SP1 , and later <nl> - * <nl> - * / <nl> - if ( sock = = INVALID_SOCKET ) { <nl> - sock = socket ( rp - > ai_family , rp - > ai_socktype , rp - > ai_protocol ) ; <nl> - } <nl> + auto sock = WSASocketW ( rp - > ai_family , rp - > ai_socktype , rp - > ai_protocol , nullptr , 0 , WSA_FLAG_NO_HANDLE_INHERIT ) ; <nl> + / * * <nl> + * Since the WSA_FLAG_NO_HANDLE_INHERIT is only supported on Windows 7 SP1 <nl> + * and above the socket creation fails on older Windows Systems . <nl> + * <nl> + * Let ' s try to create a socket the old way in this case . <nl> + * <nl> + * Reference : <nl> + * https : / / docs . microsoft . com / en - us / windows / win32 / api / winsock2 / nf - winsock2 - wsasocketa <nl> + * <nl> + * WSA_FLAG_NO_HANDLE_INHERIT : <nl> + * This flag is supported on Windows 7 with SP1 , Windows Server 2008 R2 with <nl> + * SP1 , and later <nl> + * <nl> + * / <nl> + if ( sock = = INVALID_SOCKET ) { <nl> + sock = socket ( rp - > ai_family , rp - > ai_socktype , rp - > ai_protocol ) ; <nl> + } <nl> # else <nl> - auto sock = socket ( rp - > ai_family , rp - > ai_socktype , rp - > ai_protocol ) ; <nl> + auto sock = socket ( rp - > ai_family , rp - > ai_socktype , rp - > ai_protocol ) ; <nl> # endif <nl> - if ( sock = = INVALID_SOCKET ) { continue ; } <nl> + if ( sock = = INVALID_SOCKET ) { <nl> + continue ; <nl> + } <nl> <nl> # ifndef _WIN32 <nl> - if ( fcntl ( sock , F_SETFD , FD_CLOEXEC ) = = - 1 ) { continue ; } <nl> + if ( fcntl ( sock , F_SETFD , FD_CLOEXEC ) = = - 1 ) { <nl> + continue ; <nl> + } <nl> # endif <nl> <nl> - if ( tcp_nodelay ) { <nl> - int yes = 1 ; <nl> - setsockopt ( sock , IPPROTO_TCP , TCP_NODELAY , reinterpret_cast < char * > ( & yes ) , <nl> - sizeof ( yes ) ) ; <nl> - } <nl> + if ( tcp_nodelay ) { <nl> + int yes = 1 ; <nl> + setsockopt ( sock , IPPROTO_TCP , TCP_NODELAY , reinterpret_cast < char * > ( & yes ) , sizeof ( yes ) ) ; <nl> + } <nl> <nl> - if ( socket_options ) { socket_options ( sock ) ; } <nl> + if ( socket_options ) { <nl> + socket_options ( sock ) ; <nl> + } <nl> <nl> - if ( rp - > ai_family = = AF_INET6 ) { <nl> - int no = 0 ; <nl> - setsockopt ( sock , IPPROTO_IPV6 , IPV6_V6ONLY , reinterpret_cast < char * > ( & no ) , <nl> - sizeof ( no ) ) ; <nl> - } <nl> + if ( rp - > ai_family = = AF_INET6 ) { <nl> + int no = 0 ; <nl> + setsockopt ( sock , IPPROTO_IPV6 , IPV6_V6ONLY , reinterpret_cast < char * > ( & no ) , sizeof ( no ) ) ; <nl> + } <nl> <nl> - / / bind or connect <nl> - if ( bind_or_connect ( sock , * rp ) ) { <nl> - freeaddrinfo ( result ) ; <nl> - return sock ; <nl> - } <nl> + / / bind or connect <nl> + if ( bind_or_connect ( sock , * rp ) ) { <nl> + freeaddrinfo ( result ) ; <nl> + return sock ; <nl> + } <nl> <nl> - close_socket ( sock ) ; <nl> - } <nl> + close_socket ( sock ) ; <nl> + } <nl> <nl> - freeaddrinfo ( result ) ; <nl> - return INVALID_SOCKET ; <nl> + freeaddrinfo ( result ) ; <nl> + return INVALID_SOCKET ; <nl> } <nl> <nl> inline void set_nonblocking ( socket_t sock , bool nonblocking ) { <nl> # ifdef _WIN32 <nl> - auto flags = nonblocking ? 1UL : 0UL ; <nl> - ioctlsocket ( sock , FIONBIO , & flags ) ; <nl> + auto flags = nonblocking ? 1UL : 0UL ; <nl> + ioctlsocket ( sock , FIONBIO , & flags ) ; <nl> # else <nl> - auto flags = fcntl ( sock , F_GETFL , 0 ) ; <nl> - fcntl ( sock , F_SETFL , <nl> - nonblocking ? ( flags | O_NONBLOCK ) : ( flags & ( ~ O_NONBLOCK ) ) ) ; <nl> + auto flags = fcntl ( sock , F_GETFL , 0 ) ; <nl> + fcntl ( sock , F_SETFL , nonblocking ? ( flags | O_NONBLOCK ) : ( flags & ( ~ O_NONBLOCK ) ) ) ; <nl> # endif <nl> } <nl> <nl> inline bool is_connection_error ( ) { <nl> # ifdef _WIN32 <nl> - return WSAGetLastError ( ) ! = WSAEWOULDBLOCK ; <nl> + return WSAGetLastError ( ) ! = WSAEWOULDBLOCK ; <nl> # else <nl> - return errno ! = EINPROGRESS ; <nl> + return errno ! = EINPROGRESS ; <nl> # endif <nl> } <nl> <nl> inline bool bind_ip_address ( socket_t sock , const char * host ) { <nl> - struct addrinfo hints ; <nl> - struct addrinfo * result ; <nl> + struct addrinfo hints ; <nl> + struct addrinfo * result ; <nl> <nl> - memset ( & hints , 0 , sizeof ( struct addrinfo ) ) ; <nl> - hints . ai_family = AF_UNSPEC ; <nl> - hints . ai_socktype = SOCK_STREAM ; <nl> - hints . ai_protocol = 0 ; <nl> + memset ( & hints , 0 , sizeof ( struct addrinfo ) ) ; <nl> + hints . ai_family = AF_UNSPEC ; <nl> + hints . ai_socktype = SOCK_STREAM ; <nl> + hints . ai_protocol = 0 ; <nl> <nl> - if ( getaddrinfo ( host , " 0 " , & hints , & result ) ) { return false ; } <nl> + if ( getaddrinfo ( host , " 0 " , & hints , & result ) ) { <nl> + return false ; <nl> + } <nl> <nl> - auto ret = false ; <nl> - for ( auto rp = result ; rp ; rp = rp - > ai_next ) { <nl> - const auto & ai = * rp ; <nl> - if ( ! : : bind ( sock , ai . ai_addr , static_cast < socklen_t > ( ai . ai_addrlen ) ) ) { <nl> - ret = true ; <nl> - break ; <nl> + auto ret = false ; <nl> + for ( auto rp = result ; rp ; rp = rp - > ai_next ) { <nl> + const auto & ai = * rp ; <nl> + if ( ! : : bind ( sock , ai . ai_addr , static_cast < socklen_t > ( ai . ai_addrlen ) ) ) { <nl> + ret = true ; <nl> + break ; <nl> + } <nl> } <nl> - } <nl> <nl> - freeaddrinfo ( result ) ; <nl> - return ret ; <nl> + freeaddrinfo ( result ) ; <nl> + return ret ; <nl> } <nl> <nl> # ifndef _WIN32 <nl> inline std : : string if2ip ( const std : : string & ifn ) { <nl> - struct ifaddrs * ifap ; <nl> - getifaddrs ( & ifap ) ; <nl> - for ( auto ifa = ifap ; ifa ; ifa = ifa - > ifa_next ) { <nl> - if ( ifa - > ifa_addr & & ifn = = ifa - > ifa_name ) { <nl> - if ( ifa - > ifa_addr - > sa_family = = AF_INET ) { <nl> - auto sa = reinterpret_cast < struct sockaddr_in * > ( ifa - > ifa_addr ) ; <nl> - char buf [ INET_ADDRSTRLEN ] ; <nl> - if ( inet_ntop ( AF_INET , & sa - > sin_addr , buf , INET_ADDRSTRLEN ) ) { <nl> - freeifaddrs ( ifap ) ; <nl> - return std : : string ( buf , INET_ADDRSTRLEN ) ; <nl> + struct ifaddrs * ifap ; <nl> + getifaddrs ( & ifap ) ; <nl> + for ( auto ifa = ifap ; ifa ; ifa = ifa - > ifa_next ) { <nl> + if ( ifa - > ifa_addr & & ifn = = ifa - > ifa_name ) { <nl> + if ( ifa - > ifa_addr - > sa_family = = AF_INET ) { <nl> + auto sa = reinterpret_cast < struct sockaddr_in * > ( ifa - > ifa_addr ) ; <nl> + char buf [ INET_ADDRSTRLEN ] ; <nl> + if ( inet_ntop ( AF_INET , & sa - > sin_addr , buf , INET_ADDRSTRLEN ) ) { <nl> + freeifaddrs ( ifap ) ; <nl> + return std : : string ( buf , INET_ADDRSTRLEN ) ; <nl> + } <nl> + } <nl> } <nl> - } <nl> } <nl> - } <nl> - freeifaddrs ( ifap ) ; <nl> - return std : : string ( ) ; <nl> + freeifaddrs ( ifap ) ; <nl> + return std : : string ( ) ; <nl> } <nl> # endif <nl> <nl> - inline socket_t create_client_socket ( const char * host , int port , <nl> + inline socket_t create_client_socket ( const char * host , <nl> + int port , <nl> bool tcp_nodelay , <nl> SocketOptions socket_options , <nl> - time_t timeout_sec , time_t timeout_usec , <nl> + time_t timeout_sec , <nl> + time_t timeout_usec , <nl> const std : : string & intf ) { <nl> - return create_socket ( <nl> - host , port , 0 , tcp_nodelay , socket_options , <nl> - [ & ] ( socket_t sock , struct addrinfo & ai ) - > bool { <nl> + return create_socket ( host , port , 0 , tcp_nodelay , socket_options , [ & ] ( socket_t sock , struct addrinfo & ai ) - > bool { <nl> if ( ! intf . empty ( ) ) { <nl> # ifndef _WIN32 <nl> - auto ip = if2ip ( intf ) ; <nl> - if ( ip . empty ( ) ) { ip = intf ; } <nl> - if ( ! bind_ip_address ( sock , ip . c_str ( ) ) ) { return false ; } <nl> + auto ip = if2ip ( intf ) ; <nl> + if ( ip . empty ( ) ) { <nl> + ip = intf ; <nl> + } <nl> + if ( ! bind_ip_address ( sock , ip . c_str ( ) ) ) { <nl> + return false ; <nl> + } <nl> # endif <nl> } <nl> <nl> set_nonblocking ( sock , true ) ; <nl> <nl> - auto ret = <nl> - : : connect ( sock , ai . ai_addr , static_cast < socklen_t > ( ai . ai_addrlen ) ) ; <nl> + auto ret = : : connect ( sock , ai . ai_addr , static_cast < socklen_t > ( ai . ai_addrlen ) ) ; <nl> if ( ret < 0 ) { <nl> - if ( is_connection_error ( ) | | <nl> - ! wait_until_socket_is_ready ( sock , timeout_sec , timeout_usec ) ) { <nl> - close_socket ( sock ) ; <nl> - return false ; <nl> - } <nl> + if ( is_connection_error ( ) | | ! wait_until_socket_is_ready ( sock , timeout_sec , timeout_usec ) ) { <nl> + close_socket ( sock ) ; <nl> + return false ; <nl> + } <nl> } <nl> <nl> set_nonblocking ( sock , false ) ; <nl> return true ; <nl> - } ) ; <nl> + } ) ; <nl> } <nl> <nl> inline void get_remote_ip_and_port ( const struct sockaddr_storage & addr , <nl> - socklen_t addr_len , std : : string & ip , <nl> + socklen_t addr_len , <nl> + std : : string & ip , <nl> int & port ) { <nl> - if ( addr . ss_family = = AF_INET ) { <nl> - port = ntohs ( reinterpret_cast < const struct sockaddr_in * > ( & addr ) - > sin_port ) ; <nl> - } else if ( addr . ss_family = = AF_INET6 ) { <nl> - port = <nl> - ntohs ( reinterpret_cast < const struct sockaddr_in6 * > ( & addr ) - > sin6_port ) ; <nl> - } <nl> + if ( addr . ss_family = = AF_INET ) { <nl> + port = ntohs ( reinterpret_cast < const struct sockaddr_in * > ( & addr ) - > sin_port ) ; <nl> + } else if ( addr . ss_family = = AF_INET6 ) { <nl> + port = ntohs ( reinterpret_cast < const struct sockaddr_in6 * > ( & addr ) - > sin6_port ) ; <nl> + } <nl> <nl> - std : : array < char , NI_MAXHOST > ipstr { } ; <nl> - if ( ! getnameinfo ( reinterpret_cast < const struct sockaddr * > ( & addr ) , addr_len , <nl> - ipstr . data ( ) , static_cast < socklen_t > ( ipstr . size ( ) ) , nullptr , <nl> - 0 , NI_NUMERICHOST ) ) { <nl> - ip = ipstr . data ( ) ; <nl> - } <nl> + std : : array < char , NI_MAXHOST > ipstr { } ; <nl> + if ( ! getnameinfo ( reinterpret_cast < const struct sockaddr * > ( & addr ) , <nl> + addr_len , <nl> + ipstr . data ( ) , <nl> + static_cast < socklen_t > ( ipstr . size ( ) ) , <nl> + nullptr , <nl> + 0 , <nl> + NI_NUMERICHOST ) ) { <nl> + ip = ipstr . data ( ) ; <nl> + } <nl> } <nl> <nl> inline void get_remote_ip_and_port ( socket_t sock , std : : string & ip , int & port ) { <nl> - struct sockaddr_storage addr ; <nl> - socklen_t addr_len = sizeof ( addr ) ; <nl> - <nl> - if ( ! getpeername ( sock , reinterpret_cast < struct sockaddr * > ( & addr ) , <nl> - & addr_len ) ) { <nl> - get_remote_ip_and_port ( addr , addr_len , ip , port ) ; <nl> - } <nl> - } <nl> - <nl> - inline const char * <nl> - find_content_type ( const std : : string & path , <nl> - const std : : map < std : : string , std : : string > & user_data ) { <nl> - auto ext = file_extension ( path ) ; <nl> - <nl> - auto it = user_data . find ( ext ) ; <nl> - if ( it ! = user_data . end ( ) ) { return it - > second . c_str ( ) ; } <nl> - <nl> - if ( ext = = " txt " ) { <nl> - return " text / plain " ; <nl> - } else if ( ext = = " html " | | ext = = " htm " ) { <nl> - return " text / html " ; <nl> - } else if ( ext = = " css " ) { <nl> - return " text / css " ; <nl> - } else if ( ext = = " jpeg " | | ext = = " jpg " ) { <nl> - return " image / jpg " ; <nl> - } else if ( ext = = " png " ) { <nl> - return " image / png " ; <nl> - } else if ( ext = = " gif " ) { <nl> - return " image / gif " ; <nl> - } else if ( ext = = " svg " ) { <nl> - return " image / svg + xml " ; <nl> - } else if ( ext = = " ico " ) { <nl> - return " image / x - icon " ; <nl> - } else if ( ext = = " json " ) { <nl> - return " application / json " ; <nl> - } else if ( ext = = " pdf " ) { <nl> - return " application / pdf " ; <nl> - } else if ( ext = = " js " ) { <nl> - return " application / javascript " ; <nl> - } else if ( ext = = " wasm " ) { <nl> - return " application / wasm " ; <nl> - } else if ( ext = = " xml " ) { <nl> - return " application / xml " ; <nl> - } else if ( ext = = " xhtml " ) { <nl> - return " application / xhtml + xml " ; <nl> - } <nl> - return nullptr ; <nl> + struct sockaddr_storage addr ; <nl> + socklen_t addr_len = sizeof ( addr ) ; <nl> + <nl> + if ( ! getpeername ( sock , reinterpret_cast < struct sockaddr * > ( & addr ) , & addr_len ) ) { <nl> + get_remote_ip_and_port ( addr , addr_len , ip , port ) ; <nl> + } <nl> + } <nl> + <nl> + inline const char * find_content_type ( const std : : string & path , const std : : map < std : : string , std : : string > & user_data ) { <nl> + auto ext = file_extension ( path ) ; <nl> + <nl> + auto it = user_data . find ( ext ) ; <nl> + if ( it ! = user_data . end ( ) ) { <nl> + return it - > second . c_str ( ) ; <nl> + } <nl> + <nl> + if ( ext = = " txt " ) { <nl> + return " text / plain " ; <nl> + } else if ( ext = = " html " | | ext = = " htm " ) { <nl> + return " text / html " ; <nl> + } else if ( ext = = " css " ) { <nl> + return " text / css " ; <nl> + } else if ( ext = = " jpeg " | | ext = = " jpg " ) { <nl> + return " image / jpg " ; <nl> + } else if ( ext = = " png " ) { <nl> + return " image / png " ; <nl> + } else if ( ext = = " gif " ) { <nl> + return " image / gif " ; <nl> + } else if ( ext = = " svg " ) { <nl> + return " image / svg + xml " ; <nl> + } else if ( ext = = " ico " ) { <nl> + return " image / x - icon " ; <nl> + } else if ( ext = = " json " ) { <nl> + return " application / json " ; <nl> + } else if ( ext = = " pdf " ) { <nl> + return " application / pdf " ; <nl> + } else if ( ext = = " js " ) { <nl> + return " application / javascript " ; <nl> + } else if ( ext = = " wasm " ) { <nl> + return " application / wasm " ; <nl> + } else if ( ext = = " xml " ) { <nl> + return " application / xml " ; <nl> + } else if ( ext = = " xhtml " ) { <nl> + return " application / xhtml + xml " ; <nl> + } <nl> + return nullptr ; <nl> } <nl> <nl> inline const char * status_message ( int status ) { <nl> - switch ( status ) { <nl> - case 100 : return " Continue " ; <nl> - case 101 : return " Switching Protocol " ; <nl> - case 102 : return " Processing " ; <nl> - case 103 : return " Early Hints " ; <nl> - case 200 : return " OK " ; <nl> - case 201 : return " Created " ; <nl> - case 202 : return " Accepted " ; <nl> - case 203 : return " Non - Authoritative Information " ; <nl> - case 204 : return " No Content " ; <nl> - case 205 : return " Reset Content " ; <nl> - case 206 : return " Partial Content " ; <nl> - case 207 : return " Multi - Status " ; <nl> - case 208 : return " Already Reported " ; <nl> - case 226 : return " IM Used " ; <nl> - case 300 : return " Multiple Choice " ; <nl> - case 301 : return " Moved Permanently " ; <nl> - case 302 : return " Found " ; <nl> - case 303 : return " See Other " ; <nl> - case 304 : return " Not Modified " ; <nl> - case 305 : return " Use Proxy " ; <nl> - case 306 : return " unused " ; <nl> - case 307 : return " Temporary Redirect " ; <nl> - case 308 : return " Permanent Redirect " ; <nl> - case 400 : return " Bad Request " ; <nl> - case 401 : return " Unauthorized " ; <nl> - case 402 : return " Payment Required " ; <nl> - case 403 : return " Forbidden " ; <nl> - case 404 : return " Not Found " ; <nl> - case 405 : return " Method Not Allowed " ; <nl> - case 406 : return " Not Acceptable " ; <nl> - case 407 : return " Proxy Authentication Required " ; <nl> - case 408 : return " Request Timeout " ; <nl> - case 409 : return " Conflict " ; <nl> - case 410 : return " Gone " ; <nl> - case 411 : return " Length Required " ; <nl> - case 412 : return " Precondition Failed " ; <nl> - case 413 : return " Payload Too Large " ; <nl> - case 414 : return " URI Too Long " ; <nl> - case 415 : return " Unsupported Media Type " ; <nl> - case 416 : return " Range Not Satisfiable " ; <nl> - case 417 : return " Expectation Failed " ; <nl> - case 418 : return " I ' m a teapot " ; <nl> - case 421 : return " Misdirected Request " ; <nl> - case 422 : return " Unprocessable Entity " ; <nl> - case 423 : return " Locked " ; <nl> - case 424 : return " Failed Dependency " ; <nl> - case 425 : return " Too Early " ; <nl> - case 426 : return " Upgrade Required " ; <nl> - case 428 : return " Precondition Required " ; <nl> - case 429 : return " Too Many Requests " ; <nl> - case 431 : return " Request Header Fields Too Large " ; <nl> - case 451 : return " Unavailable For Legal Reasons " ; <nl> - case 501 : return " Not Implemented " ; <nl> - case 502 : return " Bad Gateway " ; <nl> - case 503 : return " Service Unavailable " ; <nl> - case 504 : return " Gateway Timeout " ; <nl> - case 505 : return " HTTP Version Not Supported " ; <nl> - case 506 : return " Variant Also Negotiates " ; <nl> - case 507 : return " Insufficient Storage " ; <nl> - case 508 : return " Loop Detected " ; <nl> - case 510 : return " Not Extended " ; <nl> - case 511 : return " Network Authentication Required " ; <nl> - <nl> - default : <nl> - case 500 : return " Internal Server Error " ; <nl> - } <nl> + switch ( status ) { <nl> + case 100 : <nl> + return " Continue " ; <nl> + case 101 : <nl> + return " Switching Protocol " ; <nl> + case 102 : <nl> + return " Processing " ; <nl> + case 103 : <nl> + return " Early Hints " ; <nl> + case 200 : <nl> + return " OK " ; <nl> + case 201 : <nl> + return " Created " ; <nl> + case 202 : <nl> + return " Accepted " ; <nl> + case 203 : <nl> + return " Non - Authoritative Information " ; <nl> + case 204 : <nl> + return " No Content " ; <nl> + case 205 : <nl> + return " Reset Content " ; <nl> + case 206 : <nl> + return " Partial Content " ; <nl> + case 207 : <nl> + return " Multi - Status " ; <nl> + case 208 : <nl> + return " Already Reported " ; <nl> + case 226 : <nl> + return " IM Used " ; <nl> + case 300 : <nl> + return " Multiple Choice " ; <nl> + case 301 : <nl> + return " Moved Permanently " ; <nl> + case 302 : <nl> + return " Found " ; <nl> + case 303 : <nl> + return " See Other " ; <nl> + case 304 : <nl> + return " Not Modified " ; <nl> + case 305 : <nl> + return " Use Proxy " ; <nl> + case 306 : <nl> + return " unused " ; <nl> + case 307 : <nl> + return " Temporary Redirect " ; <nl> + case 308 : <nl> + return " Permanent Redirect " ; <nl> + case 400 : <nl> + return " Bad Request " ; <nl> + case 401 : <nl> + return " Unauthorized " ; <nl> + case 402 : <nl> + return " Payment Required " ; <nl> + case 403 : <nl> + return " Forbidden " ; <nl> + case 404 : <nl> + return " Not Found " ; <nl> + case 405 : <nl> + return " Method Not Allowed " ; <nl> + case 406 : <nl> + return " Not Acceptable " ; <nl> + case 407 : <nl> + return " Proxy Authentication Required " ; <nl> + case 408 : <nl> + return " Request Timeout " ; <nl> + case 409 : <nl> + return " Conflict " ; <nl> + case 410 : <nl> + return " Gone " ; <nl> + case 411 : <nl> + return " Length Required " ; <nl> + case 412 : <nl> + return " Precondition Failed " ; <nl> + case 413 : <nl> + return " Payload Too Large " ; <nl> + case 414 : <nl> + return " URI Too Long " ; <nl> + case 415 : <nl> + return " Unsupported Media Type " ; <nl> + case 416 : <nl> + return " Range Not Satisfiable " ; <nl> + case 417 : <nl> + return " Expectation Failed " ; <nl> + case 418 : <nl> + return " I ' m a teapot " ; <nl> + case 421 : <nl> + return " Misdirected Request " ; <nl> + case 422 : <nl> + return " Unprocessable Entity " ; <nl> + case 423 : <nl> + return " Locked " ; <nl> + case 424 : <nl> + return " Failed Dependency " ; <nl> + case 425 : <nl> + return " Too Early " ; <nl> + case 426 : <nl> + return " Upgrade Required " ; <nl> + case 428 : <nl> + return " Precondition Required " ; <nl> + case 429 : <nl> + return " Too Many Requests " ; <nl> + case 431 : <nl> + return " Request Header Fields Too Large " ; <nl> + case 451 : <nl> + return " Unavailable For Legal Reasons " ; <nl> + case 501 : <nl> + return " Not Implemented " ; <nl> + case 502 : <nl> + return " Bad Gateway " ; <nl> + case 503 : <nl> + return " Service Unavailable " ; <nl> + case 504 : <nl> + return " Gateway Timeout " ; <nl> + case 505 : <nl> + return " HTTP Version Not Supported " ; <nl> + case 506 : <nl> + return " Variant Also Negotiates " ; <nl> + case 507 : <nl> + return " Insufficient Storage " ; <nl> + case 508 : <nl> + return " Loop Detected " ; <nl> + case 510 : <nl> + return " Not Extended " ; <nl> + case 511 : <nl> + return " Network Authentication Required " ; <nl> + <nl> + default : <nl> + case 500 : <nl> + return " Internal Server Error " ; <nl> + } <nl> } <nl> <nl> # ifdef CPPHTTPLIB_ZLIB_SUPPORT <nl> inline bool can_compress ( const std : : string & content_type ) { <nl> - return ! content_type . find ( " text / " ) | | content_type = = " image / svg + xml " | | <nl> - content_type = = " application / javascript " | | <nl> - content_type = = " application / json " | | <nl> - content_type = = " application / xml " | | <nl> - content_type = = " application / xhtml + xml " ; <nl> + return ! content_type . find ( " text / " ) | | content_type = = " image / svg + xml " | | content_type = = " application / javascript " | | <nl> + content_type = = " application / json " | | content_type = = " application / xml " | | <nl> + content_type = = " application / xhtml + xml " ; <nl> } <nl> <nl> inline bool compress ( std : : string & content ) { <nl> - z_stream strm ; <nl> - strm . zalloc = Z_NULL ; <nl> - strm . zfree = Z_NULL ; <nl> - strm . opaque = Z_NULL ; <nl> + z_stream strm ; <nl> + strm . zalloc = Z_NULL ; <nl> + strm . zfree = Z_NULL ; <nl> + strm . opaque = Z_NULL ; <nl> <nl> - auto ret = deflateInit2 ( & strm , Z_DEFAULT_COMPRESSION , Z_DEFLATED , 31 , 8 , <nl> - Z_DEFAULT_STRATEGY ) ; <nl> - if ( ret ! = Z_OK ) { return false ; } <nl> + auto ret = deflateInit2 ( & strm , Z_DEFAULT_COMPRESSION , Z_DEFLATED , 31 , 8 , Z_DEFAULT_STRATEGY ) ; <nl> + if ( ret ! = Z_OK ) { <nl> + return false ; <nl> + } <nl> <nl> - strm . avail_in = static_cast < decltype ( strm . avail_in ) > ( content . size ( ) ) ; <nl> - strm . next_in = <nl> - const_cast < Bytef * > ( reinterpret_cast < const Bytef * > ( content . data ( ) ) ) ; <nl> + strm . avail_in = static_cast < decltype ( strm . avail_in ) > ( content . size ( ) ) ; <nl> + strm . next_in = const_cast < Bytef * > ( reinterpret_cast < const Bytef * > ( content . data ( ) ) ) ; <nl> <nl> - std : : string compressed ; <nl> + std : : string compressed ; <nl> <nl> - std : : array < char , 16384 > buff { } ; <nl> - do { <nl> - strm . avail_out = buff . size ( ) ; <nl> - strm . next_out = reinterpret_cast < Bytef * > ( buff . data ( ) ) ; <nl> - ret = deflate ( & strm , Z_FINISH ) ; <nl> - assert ( ret ! = Z_STREAM_ERROR ) ; <nl> - compressed . append ( buff . data ( ) , buff . size ( ) - strm . avail_out ) ; <nl> - } while ( strm . avail_out = = 0 ) ; <nl> + std : : array < char , 16384 > buff { } ; <nl> + do { <nl> + strm . avail_out = buff . size ( ) ; <nl> + strm . next_out = reinterpret_cast < Bytef * > ( buff . data ( ) ) ; <nl> + ret = deflate ( & strm , Z_FINISH ) ; <nl> + assert ( ret ! = Z_STREAM_ERROR ) ; <nl> + compressed . append ( buff . data ( ) , buff . size ( ) - strm . avail_out ) ; <nl> + } while ( strm . avail_out = = 0 ) ; <nl> <nl> - assert ( ret = = Z_STREAM_END ) ; <nl> - assert ( strm . avail_in = = 0 ) ; <nl> + assert ( ret = = Z_STREAM_END ) ; <nl> + assert ( strm . avail_in = = 0 ) ; <nl> <nl> - content . swap ( compressed ) ; <nl> + content . swap ( compressed ) ; <nl> <nl> - deflateEnd ( & strm ) ; <nl> - return true ; <nl> + deflateEnd ( & strm ) ; <nl> + return true ; <nl> } <nl> <nl> class decompressor { <nl> - public : <nl> - decompressor ( ) { <nl> - std : : memset ( & strm , 0 , sizeof ( strm ) ) ; <nl> - strm . zalloc = Z_NULL ; <nl> - strm . zfree = Z_NULL ; <nl> - strm . opaque = Z_NULL ; <nl> + public : <nl> + decompressor ( ) { <nl> + std : : memset ( & strm , 0 , sizeof ( strm ) ) ; <nl> + strm . zalloc = Z_NULL ; <nl> + strm . zfree = Z_NULL ; <nl> + strm . opaque = Z_NULL ; <nl> <nl> - / / 15 is the value of wbits , which should be at the maximum possible value <nl> - / / to ensure that any gzip stream can be decoded . The offset of 32 specifies <nl> - / / that the stream type should be automatically detected either gzip or <nl> - / / deflate . <nl> - is_valid_ = inflateInit2 ( & strm , 32 + 15 ) = = Z_OK ; <nl> - } <nl> + / / 15 is the value of wbits , which should be at the maximum possible value <nl> + / / to ensure that any gzip stream can be decoded . The offset of 32 specifies <nl> + / / that the stream type should be automatically detected either gzip or <nl> + / / deflate . <nl> + is_valid_ = inflateInit2 ( & strm , 32 + 15 ) = = Z_OK ; <nl> + } <nl> <nl> - ~ decompressor ( ) { inflateEnd ( & strm ) ; } <nl> + ~ decompressor ( ) { <nl> + inflateEnd ( & strm ) ; <nl> + } <nl> <nl> - bool is_valid ( ) const { return is_valid_ ; } <nl> + bool is_valid ( ) const { <nl> + return is_valid_ ; <nl> + } <nl> <nl> - template < typename T > <nl> - bool decompress ( const char * data , size_t data_length , T callback ) { <nl> - int ret = Z_OK ; <nl> + template < typename T > <nl> + bool decompress ( const char * data , size_t data_length , T callback ) { <nl> + int ret = Z_OK ; <nl> <nl> - strm . avail_in = static_cast < decltype ( strm . avail_in ) > ( data_length ) ; <nl> - strm . next_in = const_cast < Bytef * > ( reinterpret_cast < const Bytef * > ( data ) ) ; <nl> + strm . avail_in = static_cast < decltype ( strm . avail_in ) > ( data_length ) ; <nl> + strm . next_in = const_cast < Bytef * > ( reinterpret_cast < const Bytef * > ( data ) ) ; <nl> <nl> - std : : array < char , 16384 > buff { } ; <nl> - do { <nl> - strm . avail_out = buff . size ( ) ; <nl> - strm . next_out = reinterpret_cast < Bytef * > ( buff . data ( ) ) ; <nl> - <nl> - ret = inflate ( & strm , Z_NO_FLUSH ) ; <nl> - assert ( ret ! = Z_STREAM_ERROR ) ; <nl> - switch ( ret ) { <nl> - case Z_NEED_DICT : <nl> - case Z_DATA_ERROR : <nl> - case Z_MEM_ERROR : inflateEnd ( & strm ) ; return false ; <nl> - } <nl> - <nl> - if ( ! callback ( buff . data ( ) , buff . size ( ) - strm . avail_out ) ) { <nl> - return false ; <nl> - } <nl> - } while ( strm . avail_out = = 0 ) ; <nl> + std : : array < char , 16384 > buff { } ; <nl> + do { <nl> + strm . avail_out = buff . size ( ) ; <nl> + strm . next_out = reinterpret_cast < Bytef * > ( buff . data ( ) ) ; <nl> + <nl> + ret = inflate ( & strm , Z_NO_FLUSH ) ; <nl> + assert ( ret ! = Z_STREAM_ERROR ) ; <nl> + switch ( ret ) { <nl> + case Z_NEED_DICT : <nl> + case Z_DATA_ERROR : <nl> + case Z_MEM_ERROR : <nl> + inflateEnd ( & strm ) ; <nl> + return false ; <nl> + } <nl> <nl> - return ret = = Z_OK | | ret = = Z_STREAM_END ; <nl> - } <nl> + if ( ! callback ( buff . data ( ) , buff . size ( ) - strm . avail_out ) ) { <nl> + return false ; <nl> + } <nl> + } while ( strm . avail_out = = 0 ) ; <nl> + <nl> + return ret = = Z_OK | | ret = = Z_STREAM_END ; <nl> + } <nl> <nl> - private : <nl> - bool is_valid_ ; <nl> - z_stream strm ; <nl> + private : <nl> + bool is_valid_ ; <nl> + z_stream strm ; <nl> } ; <nl> # endif <nl> <nl> inline bool has_header ( const Headers & headers , const char * key ) { <nl> - return headers . find ( key ) ! = headers . end ( ) ; <nl> + return headers . find ( key ) ! = headers . end ( ) ; <nl> } <nl> <nl> - inline const char * get_header_value ( const Headers & headers , const char * key , <nl> - size_t id = 0 , const char * def = nullptr ) { <nl> - auto rng = headers . equal_range ( key ) ; <nl> - auto it = rng . first ; <nl> - std : : advance ( it , static_cast < ssize_t > ( id ) ) ; <nl> - if ( it ! = rng . second ) { return it - > second . c_str ( ) ; } <nl> - return def ; <nl> + inline const char * get_header_value ( const Headers & headers , const char * key , size_t id = 0 , const char * def = nullptr ) { <nl> + auto rng = headers . equal_range ( key ) ; <nl> + auto it = rng . first ; <nl> + std : : advance ( it , static_cast < ssize_t > ( id ) ) ; <nl> + if ( it ! = rng . second ) { <nl> + return it - > second . c_str ( ) ; <nl> + } <nl> + return def ; <nl> } <nl> <nl> - inline uint64_t get_header_value_uint64 ( const Headers & headers , const char * key , <nl> - uint64_t def = 0 ) { <nl> - auto it = headers . find ( key ) ; <nl> - if ( it ! = headers . end ( ) ) { <nl> - return std : : strtoull ( it - > second . data ( ) , nullptr , 10 ) ; <nl> - } <nl> - return def ; <nl> + inline uint64_t get_header_value_uint64 ( const Headers & headers , const char * key , uint64_t def = 0 ) { <nl> + auto it = headers . find ( key ) ; <nl> + if ( it ! = headers . end ( ) ) { <nl> + return std : : strtoull ( it - > second . data ( ) , nullptr , 10 ) ; <nl> + } <nl> + return def ; <nl> } <nl> <nl> inline void parse_header ( const char * beg , const char * end , Headers & headers ) { <nl> - auto p = beg ; <nl> - while ( p < end & & * p ! = ' : ' ) { <nl> - p + + ; <nl> - } <nl> - if ( p < end ) { <nl> - auto key_end = p ; <nl> - p + + ; / / skip ' : ' <nl> - while ( p < end & & ( * p = = ' ' | | * p = = ' \ t ' ) ) { <nl> - p + + ; <nl> + auto p = beg ; <nl> + while ( p < end & & * p ! = ' : ' ) { <nl> + p + + ; <nl> } <nl> if ( p < end ) { <nl> - auto val_begin = p ; <nl> - while ( p < end ) { <nl> - p + + ; <nl> - } <nl> - headers . emplace ( std : : string ( beg , key_end ) , std : : string ( val_begin , end ) ) ; <nl> + auto key_end = p ; <nl> + p + + ; / / skip ' : ' <nl> + while ( p < end & & ( * p = = ' ' | | * p = = ' \ t ' ) ) { <nl> + p + + ; <nl> + } <nl> + if ( p < end ) { <nl> + auto val_begin = p ; <nl> + while ( p < end ) { <nl> + p + + ; <nl> + } <nl> + headers . emplace ( std : : string ( beg , key_end ) , std : : string ( val_begin , end ) ) ; <nl> + } <nl> } <nl> - } <nl> } <nl> <nl> inline bool read_headers ( Stream & strm , Headers & headers ) { <nl> - const auto bufsiz = 2048 ; <nl> - char buf [ bufsiz ] ; <nl> - stream_line_reader line_reader ( strm , buf , bufsiz ) ; <nl> + const auto bufsiz = 2048 ; <nl> + char buf [ bufsiz ] ; <nl> + stream_line_reader line_reader ( strm , buf , bufsiz ) ; <nl> <nl> - for ( ; ; ) { <nl> - if ( ! line_reader . getline ( ) ) { return false ; } <nl> + for ( ; ; ) { <nl> + if ( ! line_reader . getline ( ) ) { <nl> + return false ; <nl> + } <nl> <nl> - / / Check if the line ends with CRLF . <nl> - if ( line_reader . end_with_crlf ( ) ) { <nl> - / / Blank line indicates end of headers . <nl> - if ( line_reader . size ( ) = = 2 ) { break ; } <nl> - } else { <nl> - continue ; / / Skip invalid line . <nl> - } <nl> + / / Check if the line ends with CRLF . <nl> + if ( line_reader . end_with_crlf ( ) ) { <nl> + / / Blank line indicates end of headers . <nl> + if ( line_reader . size ( ) = = 2 ) { <nl> + break ; <nl> + } <nl> + } else { <nl> + continue ; / / Skip invalid line . <nl> + } <nl> <nl> - / / Skip trailing spaces and tabs . <nl> - auto end = line_reader . ptr ( ) + line_reader . size ( ) - 2 ; <nl> - while ( line_reader . ptr ( ) < end & & ( end [ - 1 ] = = ' ' | | end [ - 1 ] = = ' \ t ' ) ) { <nl> - end - - ; <nl> - } <nl> + / / Skip trailing spaces and tabs . <nl> + auto end = line_reader . ptr ( ) + line_reader . size ( ) - 2 ; <nl> + while ( line_reader . ptr ( ) < end & & ( end [ - 1 ] = = ' ' | | end [ - 1 ] = = ' \ t ' ) ) { <nl> + end - - ; <nl> + } <nl> <nl> - parse_header ( line_reader . ptr ( ) , end , headers ) ; <nl> - } <nl> + parse_header ( line_reader . ptr ( ) , end , headers ) ; <nl> + } <nl> <nl> - return true ; <nl> + return true ; <nl> } <nl> <nl> - inline bool read_content_with_length ( Stream & strm , uint64_t len , <nl> - Progress progress , ContentReceiver out ) { <nl> - char buf [ CPPHTTPLIB_RECV_BUFSIZ ] ; <nl> + inline bool read_content_with_length ( Stream & strm , uint64_t len , Progress progress , ContentReceiver out ) { <nl> + char buf [ CPPHTTPLIB_RECV_BUFSIZ ] ; <nl> <nl> - uint64_t r = 0 ; <nl> - while ( r < len ) { <nl> - auto read_len = static_cast < size_t > ( len - r ) ; <nl> - auto n = strm . read ( buf , ( std : : min ) ( read_len , CPPHTTPLIB_RECV_BUFSIZ ) ) ; <nl> - if ( n < = 0 ) { return false ; } <nl> + uint64_t r = 0 ; <nl> + while ( r < len ) { <nl> + auto read_len = static_cast < size_t > ( len - r ) ; <nl> + auto n = strm . read ( buf , ( std : : min ) ( read_len , CPPHTTPLIB_RECV_BUFSIZ ) ) ; <nl> + if ( n < = 0 ) { <nl> + return false ; <nl> + } <nl> <nl> - if ( ! out ( buf , static_cast < size_t > ( n ) ) ) { return false ; } <nl> + if ( ! out ( buf , static_cast < size_t > ( n ) ) ) { <nl> + return false ; <nl> + } <nl> <nl> - r + = static_cast < uint64_t > ( n ) ; <nl> + r + = static_cast < uint64_t > ( n ) ; <nl> <nl> - if ( progress ) { <nl> - if ( ! progress ( r , len ) ) { return false ; } <nl> + if ( progress ) { <nl> + if ( ! progress ( r , len ) ) { <nl> + return false ; <nl> + } <nl> + } <nl> } <nl> - } <nl> <nl> - return true ; <nl> + return true ; <nl> } <nl> <nl> inline void skip_content_with_length ( Stream & strm , uint64_t len ) { <nl> - char buf [ CPPHTTPLIB_RECV_BUFSIZ ] ; <nl> - uint64_t r = 0 ; <nl> - while ( r < len ) { <nl> - auto read_len = static_cast < size_t > ( len - r ) ; <nl> - auto n = strm . read ( buf , ( std : : min ) ( read_len , CPPHTTPLIB_RECV_BUFSIZ ) ) ; <nl> - if ( n < = 0 ) { return ; } <nl> - r + = static_cast < uint64_t > ( n ) ; <nl> - } <nl> + char buf [ CPPHTTPLIB_RECV_BUFSIZ ] ; <nl> + uint64_t r = 0 ; <nl> + while ( r < len ) { <nl> + auto read_len = static_cast < size_t > ( len - r ) ; <nl> + auto n = strm . read ( buf , ( std : : min ) ( read_len , CPPHTTPLIB_RECV_BUFSIZ ) ) ; <nl> + if ( n < = 0 ) { <nl> + return ; <nl> + } <nl> + r + = static_cast < uint64_t > ( n ) ; <nl> + } <nl> } <nl> <nl> inline bool read_content_without_length ( Stream & strm , ContentReceiver out ) { <nl> - char buf [ CPPHTTPLIB_RECV_BUFSIZ ] ; <nl> - for ( ; ; ) { <nl> - auto n = strm . read ( buf , CPPHTTPLIB_RECV_BUFSIZ ) ; <nl> - if ( n < 0 ) { <nl> - return false ; <nl> - } else if ( n = = 0 ) { <nl> - return true ; <nl> + char buf [ CPPHTTPLIB_RECV_BUFSIZ ] ; <nl> + for ( ; ; ) { <nl> + auto n = strm . read ( buf , CPPHTTPLIB_RECV_BUFSIZ ) ; <nl> + if ( n < 0 ) { <nl> + return false ; <nl> + } else if ( n = = 0 ) { <nl> + return true ; <nl> + } <nl> + if ( ! out ( buf , static_cast < size_t > ( n ) ) ) { <nl> + return false ; <nl> + } <nl> } <nl> - if ( ! out ( buf , static_cast < size_t > ( n ) ) ) { return false ; } <nl> - } <nl> <nl> - return true ; <nl> + return true ; <nl> } <nl> <nl> inline bool read_content_chunked ( Stream & strm , ContentReceiver out ) { <nl> - const auto bufsiz = 16 ; <nl> - char buf [ bufsiz ] ; <nl> + const auto bufsiz = 16 ; <nl> + char buf [ bufsiz ] ; <nl> <nl> - stream_line_reader line_reader ( strm , buf , bufsiz ) ; <nl> + stream_line_reader line_reader ( strm , buf , bufsiz ) ; <nl> <nl> - if ( ! line_reader . getline ( ) ) { return false ; } <nl> + if ( ! line_reader . getline ( ) ) { <nl> + return false ; <nl> + } <nl> <nl> - unsigned long chunk_len ; <nl> - while ( true ) { <nl> - char * end_ptr ; <nl> + unsigned long chunk_len ; <nl> + while ( true ) { <nl> + char * end_ptr ; <nl> <nl> - chunk_len = std : : strtoul ( line_reader . ptr ( ) , & end_ptr , 16 ) ; <nl> + chunk_len = std : : strtoul ( line_reader . ptr ( ) , & end_ptr , 16 ) ; <nl> <nl> - if ( end_ptr = = line_reader . ptr ( ) ) { return false ; } <nl> - if ( chunk_len = = ULONG_MAX ) { return false ; } <nl> + if ( end_ptr = = line_reader . ptr ( ) ) { <nl> + return false ; <nl> + } <nl> + if ( chunk_len = = ULONG_MAX ) { <nl> + return false ; <nl> + } <nl> <nl> - if ( chunk_len = = 0 ) { break ; } <nl> + if ( chunk_len = = 0 ) { <nl> + break ; <nl> + } <nl> <nl> - if ( ! read_content_with_length ( strm , chunk_len , nullptr , out ) ) { <nl> - return false ; <nl> - } <nl> + if ( ! read_content_with_length ( strm , chunk_len , nullptr , out ) ) { <nl> + return false ; <nl> + } <nl> <nl> - if ( ! line_reader . getline ( ) ) { return false ; } <nl> + if ( ! line_reader . getline ( ) ) { <nl> + return false ; <nl> + } <nl> <nl> - if ( strcmp ( line_reader . ptr ( ) , " \ r \ n " ) ) { break ; } <nl> + if ( strcmp ( line_reader . ptr ( ) , " \ r \ n " ) ) { <nl> + break ; <nl> + } <nl> <nl> - if ( ! line_reader . getline ( ) ) { return false ; } <nl> - } <nl> + if ( ! line_reader . getline ( ) ) { <nl> + return false ; <nl> + } <nl> + } <nl> <nl> - if ( chunk_len = = 0 ) { <nl> - / / Reader terminator after chunks <nl> - if ( ! line_reader . getline ( ) | | strcmp ( line_reader . ptr ( ) , " \ r \ n " ) ) <nl> - return false ; <nl> - } <nl> + if ( chunk_len = = 0 ) { <nl> + / / Reader terminator after chunks <nl> + if ( ! line_reader . getline ( ) | | strcmp ( line_reader . ptr ( ) , " \ r \ n " ) ) return false ; <nl> + } <nl> <nl> - return true ; <nl> + return true ; <nl> } <nl> <nl> inline bool is_chunked_transfer_encoding ( const Headers & headers ) { <nl> - return ! strcasecmp ( get_header_value ( headers , " Transfer - Encoding " , 0 , " " ) , <nl> - " chunked " ) ; <nl> + return ! strcasecmp ( get_header_value ( headers , " Transfer - Encoding " , 0 , " " ) , " chunked " ) ; <nl> } <nl> <nl> template < typename T > <nl> - bool read_content ( Stream & strm , T & x , size_t payload_max_length , int & status , <nl> - Progress progress , ContentReceiver receiver , <nl> + bool read_content ( Stream & strm , <nl> + T & x , <nl> + size_t payload_max_length , <nl> + int & status , <nl> + Progress progress , <nl> + ContentReceiver receiver , <nl> bool decompress ) { <nl> - <nl> - ContentReceiver out = [ & ] ( const char * buf , size_t n ) { <nl> - return receiver ( buf , n ) ; <nl> - } ; <nl> + ContentReceiver out = [ & ] ( const char * buf , size_t n ) { return receiver ( buf , n ) ; } ; <nl> <nl> # ifdef CPPHTTPLIB_ZLIB_SUPPORT <nl> - decompressor decompressor ; <nl> + decompressor decompressor ; <nl> # endif <nl> <nl> - if ( decompress ) { <nl> + if ( decompress ) { <nl> # ifdef CPPHTTPLIB_ZLIB_SUPPORT <nl> - std : : string content_encoding = x . get_header_value ( " Content - Encoding " ) ; <nl> - if ( content_encoding . find ( " gzip " ) ! = std : : string : : npos | | <nl> - content_encoding . find ( " deflate " ) ! = std : : string : : npos ) { <nl> - if ( ! decompressor . is_valid ( ) ) { <nl> - status = 500 ; <nl> - return false ; <nl> - } <nl> + std : : string content_encoding = x . get_header_value ( " Content - Encoding " ) ; <nl> + if ( content_encoding . find ( " gzip " ) ! = std : : string : : npos | | <nl> + content_encoding . find ( " deflate " ) ! = std : : string : : npos ) { <nl> + if ( ! decompressor . is_valid ( ) ) { <nl> + status = 500 ; <nl> + return false ; <nl> + } <nl> <nl> - out = [ & ] ( const char * buf , size_t n ) { <nl> - return decompressor . decompress ( buf , n , [ & ] ( const char * buf , size_t n ) { <nl> - return receiver ( buf , n ) ; <nl> - } ) ; <nl> - } ; <nl> - } <nl> + out = [ & ] ( const char * buf , size_t n ) { <nl> + return decompressor . decompress ( buf , n , [ & ] ( const char * buf , size_t n ) { return receiver ( buf , n ) ; } ) ; <nl> + } ; <nl> + } <nl> # else <nl> - if ( x . get_header_value ( " Content - Encoding " ) = = " gzip " ) { <nl> - status = 415 ; <nl> - return false ; <nl> - } <nl> + if ( x . get_header_value ( " Content - Encoding " ) = = " gzip " ) { <nl> + status = 415 ; <nl> + return false ; <nl> + } <nl> # endif <nl> - } <nl> + } <nl> <nl> - auto ret = true ; <nl> - auto exceed_payload_max_length = false ; <nl> + auto ret = true ; <nl> + auto exceed_payload_max_length = false ; <nl> <nl> - if ( is_chunked_transfer_encoding ( x . headers ) ) { <nl> - ret = read_content_chunked ( strm , out ) ; <nl> - } else if ( ! has_header ( x . headers , " Content - Length " ) ) { <nl> - ret = read_content_without_length ( strm , out ) ; <nl> - } else { <nl> - auto len = get_header_value_uint64 ( x . headers , " Content - Length " , 0 ) ; <nl> - if ( len > payload_max_length ) { <nl> - exceed_payload_max_length = true ; <nl> - skip_content_with_length ( strm , len ) ; <nl> - ret = false ; <nl> - } else if ( len > 0 ) { <nl> - ret = read_content_with_length ( strm , len , progress , out ) ; <nl> + if ( is_chunked_transfer_encoding ( x . headers ) ) { <nl> + ret = read_content_chunked ( strm , out ) ; <nl> + } else if ( ! has_header ( x . headers , " Content - Length " ) ) { <nl> + ret = read_content_without_length ( strm , out ) ; <nl> + } else { <nl> + auto len = get_header_value_uint64 ( x . headers , " Content - Length " , 0 ) ; <nl> + if ( len > payload_max_length ) { <nl> + exceed_payload_max_length = true ; <nl> + skip_content_with_length ( strm , len ) ; <nl> + ret = false ; <nl> + } else if ( len > 0 ) { <nl> + ret = read_content_with_length ( strm , len , progress , out ) ; <nl> + } <nl> } <nl> - } <nl> <nl> - if ( ! ret ) { status = exceed_payload_max_length ? 413 : 400 ; } <nl> - return ret ; <nl> + if ( ! ret ) { <nl> + status = exceed_payload_max_length ? 413 : 400 ; <nl> + } <nl> + return ret ; <nl> } <nl> <nl> template < typename T > <nl> - inline ssize_t write_headers ( Stream & strm , const T & info , <nl> - const Headers & headers ) { <nl> - ssize_t write_len = 0 ; <nl> - for ( const auto & x : info . headers ) { <nl> - if ( x . first = = " EXCEPTION_WHAT " ) { continue ; } <nl> - auto len = <nl> - strm . write_format ( " % s : % s \ r \ n " , x . first . c_str ( ) , x . second . c_str ( ) ) ; <nl> - if ( len < 0 ) { return len ; } <nl> - write_len + = len ; <nl> - } <nl> - for ( const auto & x : headers ) { <nl> - auto len = <nl> - strm . write_format ( " % s : % s \ r \ n " , x . first . c_str ( ) , x . second . c_str ( ) ) ; <nl> - if ( len < 0 ) { return len ; } <nl> + inline ssize_t write_headers ( Stream & strm , const T & info , const Headers & headers ) { <nl> + ssize_t write_len = 0 ; <nl> + for ( const auto & x : info . headers ) { <nl> + if ( x . first = = " EXCEPTION_WHAT " ) { <nl> + continue ; <nl> + } <nl> + auto len = strm . write_format ( " % s : % s \ r \ n " , x . first . c_str ( ) , x . second . c_str ( ) ) ; <nl> + if ( len < 0 ) { <nl> + return len ; <nl> + } <nl> + write_len + = len ; <nl> + } <nl> + for ( const auto & x : headers ) { <nl> + auto len = strm . write_format ( " % s : % s \ r \ n " , x . first . c_str ( ) , x . second . c_str ( ) ) ; <nl> + if ( len < 0 ) { <nl> + return len ; <nl> + } <nl> + write_len + = len ; <nl> + } <nl> + auto len = strm . write ( " \ r \ n " ) ; <nl> + if ( len < 0 ) { <nl> + return len ; <nl> + } <nl> write_len + = len ; <nl> - } <nl> - auto len = strm . write ( " \ r \ n " ) ; <nl> - if ( len < 0 ) { return len ; } <nl> - write_len + = len ; <nl> - return write_len ; <nl> + return write_len ; <nl> } <nl> <nl> inline bool write_data ( Stream & strm , const char * d , size_t l ) { <nl> - size_t offset = 0 ; <nl> - while ( offset < l ) { <nl> - auto length = strm . write ( d + offset , l - offset ) ; <nl> - if ( length < 0 ) { return false ; } <nl> - offset + = static_cast < size_t > ( length ) ; <nl> - } <nl> - return true ; <nl> + size_t offset = 0 ; <nl> + while ( offset < l ) { <nl> + auto length = strm . write ( d + offset , l - offset ) ; <nl> + if ( length < 0 ) { <nl> + return false ; <nl> + } <nl> + offset + = static_cast < size_t > ( length ) ; <nl> + } <nl> + return true ; <nl> } <nl> <nl> template < typename T > <nl> - inline ssize_t write_content ( Stream & strm , ContentProvider content_provider , <nl> - size_t offset , size_t length , T is_shutting_down ) { <nl> - size_t begin_offset = offset ; <nl> - size_t end_offset = offset + length ; <nl> + inline ssize_t write_content ( <nl> + Stream & strm , ContentProvider content_provider , size_t offset , size_t length , T is_shutting_down ) { <nl> + size_t begin_offset = offset ; <nl> + size_t end_offset = offset + length ; <nl> <nl> - auto ok = true ; <nl> + auto ok = true ; <nl> <nl> - DataSink data_sink ; <nl> - data_sink . write = [ & ] ( const char * d , size_t l ) { <nl> - if ( ok ) { <nl> - offset + = l ; <nl> - if ( ! write_data ( strm , d , l ) ) { ok = false ; } <nl> - } <nl> - } ; <nl> - data_sink . is_writable = [ & ] ( void ) { return ok & & strm . is_writable ( ) ; } ; <nl> + DataSink data_sink ; <nl> + data_sink . write = [ & ] ( const char * d , size_t l ) { <nl> + if ( ok ) { <nl> + offset + = l ; <nl> + if ( ! write_data ( strm , d , l ) ) { <nl> + ok = false ; <nl> + } <nl> + } <nl> + } ; <nl> + data_sink . is_writable = [ & ] ( void ) { return ok & & strm . is_writable ( ) ; } ; <nl> <nl> - while ( ok & & offset < end_offset & & ! is_shutting_down ( ) ) { <nl> - if ( ! content_provider ( offset , end_offset - offset , data_sink ) ) { <nl> - return - 1 ; <nl> + while ( ok & & offset < end_offset & & ! is_shutting_down ( ) ) { <nl> + if ( ! content_provider ( offset , end_offset - offset , data_sink ) ) { <nl> + return - 1 ; <nl> + } <nl> + if ( ! ok ) { <nl> + return - 1 ; <nl> + } <nl> } <nl> - if ( ! ok ) { return - 1 ; } <nl> - } <nl> <nl> - return static_cast < ssize_t > ( offset - begin_offset ) ; <nl> + return static_cast < ssize_t > ( offset - begin_offset ) ; <nl> } <nl> <nl> template < typename T > <nl> - inline ssize_t write_content_chunked ( Stream & strm , <nl> - ContentProvider content_provider , <nl> - T is_shutting_down ) { <nl> - size_t offset = 0 ; <nl> - auto data_available = true ; <nl> - ssize_t total_written_length = 0 ; <nl> - <nl> - auto ok = true ; <nl> - <nl> - DataSink data_sink ; <nl> - data_sink . write = [ & ] ( const char * d , size_t l ) { <nl> - if ( ok ) { <nl> - data_available = l > 0 ; <nl> - offset + = l ; <nl> - <nl> - / / Emit chunked response header and footer for each chunk <nl> - auto chunk = from_i_to_hex ( l ) + " \ r \ n " + std : : string ( d , l ) + " \ r \ n " ; <nl> - if ( write_data ( strm , chunk . data ( ) , chunk . size ( ) ) ) { <nl> - total_written_length + = chunk . size ( ) ; <nl> - } else { <nl> - ok = false ; <nl> - } <nl> - } <nl> - } ; <nl> - data_sink . done = [ & ] ( void ) { <nl> - data_available = false ; <nl> - if ( ok ) { <nl> - static const std : : string done_marker ( " 0 \ r \ n \ r \ n " ) ; <nl> - if ( write_data ( strm , done_marker . data ( ) , done_marker . size ( ) ) ) { <nl> - total_written_length + = done_marker . size ( ) ; <nl> - } else { <nl> - ok = false ; <nl> - } <nl> - } <nl> - } ; <nl> - data_sink . is_writable = [ & ] ( void ) { return ok & & strm . is_writable ( ) ; } ; <nl> - <nl> - while ( data_available & & ! is_shutting_down ( ) ) { <nl> - if ( ! content_provider ( offset , 0 , data_sink ) ) { return - 1 ; } <nl> - if ( ! ok ) { return - 1 ; } <nl> - } <nl> - <nl> - return total_written_length ; <nl> + inline ssize_t write_content_chunked ( Stream & strm , ContentProvider content_provider , T is_shutting_down ) { <nl> + size_t offset = 0 ; <nl> + auto data_available = true ; <nl> + ssize_t total_written_length = 0 ; <nl> + <nl> + auto ok = true ; <nl> + <nl> + DataSink data_sink ; <nl> + data_sink . write = [ & ] ( const char * d , size_t l ) { <nl> + if ( ok ) { <nl> + data_available = l > 0 ; <nl> + offset + = l ; <nl> + <nl> + / / Emit chunked response header and footer for each chunk <nl> + auto chunk = from_i_to_hex ( l ) + " \ r \ n " + std : : string ( d , l ) + " \ r \ n " ; <nl> + if ( write_data ( strm , chunk . data ( ) , chunk . size ( ) ) ) { <nl> + total_written_length + = chunk . size ( ) ; <nl> + } else { <nl> + ok = false ; <nl> + } <nl> + } <nl> + } ; <nl> + data_sink . done = [ & ] ( void ) { <nl> + data_available = false ; <nl> + if ( ok ) { <nl> + static const std : : string done_marker ( " 0 \ r \ n \ r \ n " ) ; <nl> + if ( write_data ( strm , done_marker . data ( ) , done_marker . size ( ) ) ) { <nl> + total_written_length + = done_marker . size ( ) ; <nl> + } else { <nl> + ok = false ; <nl> + } <nl> + } <nl> + } ; <nl> + data_sink . is_writable = [ & ] ( void ) { return ok & & strm . is_writable ( ) ; } ; <nl> + <nl> + while ( data_available & & ! is_shutting_down ( ) ) { <nl> + if ( ! content_provider ( offset , 0 , data_sink ) ) { <nl> + return - 1 ; <nl> + } <nl> + if ( ! ok ) { <nl> + return - 1 ; <nl> + } <nl> + } <nl> + <nl> + return total_written_length ; <nl> } <nl> <nl> template < typename T > <nl> - inline bool redirect ( T & cli , const Request & req , Response & res , <nl> - const std : : string & path ) { <nl> - Request new_req = req ; <nl> - new_req . path = path ; <nl> - new_req . redirect_count - = 1 ; <nl> + inline bool redirect ( T & cli , const Request & req , Response & res , const std : : string & path ) { <nl> + Request new_req = req ; <nl> + new_req . path = path ; <nl> + new_req . redirect_count - = 1 ; <nl> <nl> - if ( res . status = = 303 & & ( req . method ! = " GET " & & req . method ! = " HEAD " ) ) { <nl> - new_req . method = " GET " ; <nl> - new_req . body . clear ( ) ; <nl> - new_req . headers . clear ( ) ; <nl> - } <nl> + if ( res . status = = 303 & & ( req . method ! = " GET " & & req . method ! = " HEAD " ) ) { <nl> + new_req . method = " GET " ; <nl> + new_req . body . clear ( ) ; <nl> + new_req . headers . clear ( ) ; <nl> + } <nl> <nl> - Response new_res ; <nl> + Response new_res ; <nl> <nl> - auto ret = cli . send ( new_req , new_res ) ; <nl> - if ( ret ) { res = new_res ; } <nl> - return ret ; <nl> + auto ret = cli . send ( new_req , new_res ) ; <nl> + if ( ret ) { <nl> + res = new_res ; <nl> + } <nl> + return ret ; <nl> } <nl> <nl> inline std : : string encode_url ( const std : : string & s ) { <nl> - std : : string result ; <nl> - <nl> - for ( size_t i = 0 ; s [ i ] ; i + + ) { <nl> - switch ( s [ i ] ) { <nl> - case ' ' : result + = " % 20 " ; break ; <nl> - case ' + ' : result + = " % 2B " ; break ; <nl> - case ' \ r ' : result + = " % 0D " ; break ; <nl> - case ' \ n ' : result + = " % 0A " ; break ; <nl> - case ' \ ' ' : result + = " % 27 " ; break ; <nl> - case ' , ' : result + = " % 2C " ; break ; <nl> - / / case ' : ' : result + = " % 3A " ; break ; / / ok ? probably . . . <nl> - case ' ; ' : result + = " % 3B " ; break ; <nl> - default : <nl> - auto c = static_cast < uint8_t > ( s [ i ] ) ; <nl> - if ( c > = 0x80 ) { <nl> - result + = ' % ' ; <nl> - char hex [ 4 ] ; <nl> - auto len = snprintf ( hex , sizeof ( hex ) - 1 , " % 02X " , c ) ; <nl> - assert ( len = = 2 ) ; <nl> - result . append ( hex , static_cast < size_t > ( len ) ) ; <nl> - } else { <nl> - result + = s [ i ] ; <nl> - } <nl> - break ; <nl> - } <nl> - } <nl> - <nl> - return result ; <nl> - } <nl> - <nl> - inline std : : string decode_url ( const std : : string & s , <nl> - bool convert_plus_to_space ) { <nl> - std : : string result ; <nl> - <nl> - for ( size_t i = 0 ; i < s . size ( ) ; i + + ) { <nl> - if ( s [ i ] = = ' % ' & & i + 1 < s . size ( ) ) { <nl> - if ( s [ i + 1 ] = = ' u ' ) { <nl> - int val = 0 ; <nl> - if ( from_hex_to_i ( s , i + 2 , 4 , val ) ) { <nl> - / / 4 digits Unicode codes <nl> - char buff [ 4 ] ; <nl> - size_t len = to_utf8 ( val , buff ) ; <nl> - if ( len > 0 ) { result . append ( buff , len ) ; } <nl> - i + = 5 ; / / ' u0000 ' <nl> - } else { <nl> - result + = s [ i ] ; <nl> + std : : string result ; <nl> + <nl> + for ( size_t i = 0 ; s [ i ] ; i + + ) { <nl> + switch ( s [ i ] ) { <nl> + case ' ' : <nl> + result + = " % 20 " ; <nl> + break ; <nl> + case ' + ' : <nl> + result + = " % 2B " ; <nl> + break ; <nl> + case ' \ r ' : <nl> + result + = " % 0D " ; <nl> + break ; <nl> + case ' \ n ' : <nl> + result + = " % 0A " ; <nl> + break ; <nl> + case ' \ ' ' : <nl> + result + = " % 27 " ; <nl> + break ; <nl> + case ' , ' : <nl> + result + = " % 2C " ; <nl> + break ; <nl> + / / case ' : ' : result + = " % 3A " ; break ; / / ok ? probably . . . <nl> + case ' ; ' : <nl> + result + = " % 3B " ; <nl> + break ; <nl> + default : <nl> + auto c = static_cast < uint8_t > ( s [ i ] ) ; <nl> + if ( c > = 0x80 ) { <nl> + result + = ' % ' ; <nl> + char hex [ 4 ] ; <nl> + auto len = snprintf ( hex , sizeof ( hex ) - 1 , " % 02X " , c ) ; <nl> + assert ( len = = 2 ) ; <nl> + result . append ( hex , static_cast < size_t > ( len ) ) ; <nl> + } else { <nl> + result + = s [ i ] ; <nl> + } <nl> + break ; <nl> } <nl> - } else { <nl> - int val = 0 ; <nl> - if ( from_hex_to_i ( s , i + 1 , 2 , val ) ) { <nl> - / / 2 digits hex codes <nl> - result + = static_cast < char > ( val ) ; <nl> - i + = 2 ; / / ' 00 ' <nl> + } <nl> + <nl> + return result ; <nl> + } <nl> + <nl> + inline std : : string decode_url ( const std : : string & s , bool convert_plus_to_space ) { <nl> + std : : string result ; <nl> + <nl> + for ( size_t i = 0 ; i < s . size ( ) ; i + + ) { <nl> + if ( s [ i ] = = ' % ' & & i + 1 < s . size ( ) ) { <nl> + if ( s [ i + 1 ] = = ' u ' ) { <nl> + int val = 0 ; <nl> + if ( from_hex_to_i ( s , i + 2 , 4 , val ) ) { <nl> + / / 4 digits Unicode codes <nl> + char buff [ 4 ] ; <nl> + size_t len = to_utf8 ( val , buff ) ; <nl> + if ( len > 0 ) { <nl> + result . append ( buff , len ) ; <nl> + } <nl> + i + = 5 ; / / ' u0000 ' <nl> + } else { <nl> + result + = s [ i ] ; <nl> + } <nl> + } else { <nl> + int val = 0 ; <nl> + if ( from_hex_to_i ( s , i + 1 , 2 , val ) ) { <nl> + / / 2 digits hex codes <nl> + result + = static_cast < char > ( val ) ; <nl> + i + = 2 ; / / ' 00 ' <nl> + } else { <nl> + result + = s [ i ] ; <nl> + } <nl> + } <nl> + } else if ( convert_plus_to_space & & s [ i ] = = ' + ' ) { <nl> + result + = ' ' ; <nl> } else { <nl> - result + = s [ i ] ; <nl> + result + = s [ i ] ; <nl> } <nl> - } <nl> - } else if ( convert_plus_to_space & & s [ i ] = = ' + ' ) { <nl> - result + = ' ' ; <nl> - } else { <nl> - result + = s [ i ] ; <nl> } <nl> - } <nl> <nl> - return result ; <nl> + return result ; <nl> } <nl> <nl> inline std : : string params_to_query_str ( const Params & params ) { <nl> - std : : string query ; <nl> + std : : string query ; <nl> <nl> - for ( auto it = params . begin ( ) ; it ! = params . end ( ) ; + + it ) { <nl> - if ( it ! = params . begin ( ) ) { query + = " & " ; } <nl> - query + = it - > first ; <nl> - query + = " = " ; <nl> - query + = detail : : encode_url ( it - > second ) ; <nl> - } <nl> + for ( auto it = params . begin ( ) ; it ! = params . end ( ) ; + + it ) { <nl> + if ( it ! = params . begin ( ) ) { <nl> + query + = " & " ; <nl> + } <nl> + query + = it - > first ; <nl> + query + = " = " ; <nl> + query + = detail : : encode_url ( it - > second ) ; <nl> + } <nl> <nl> - return query ; <nl> + return query ; <nl> } <nl> <nl> inline void parse_query_text ( const std : : string & s , Params & params ) { <nl> - split ( & s [ 0 ] , & s [ s . size ( ) ] , ' & ' , [ & ] ( const char * b , const char * e ) { <nl> - std : : string key ; <nl> - std : : string val ; <nl> - split ( b , e , ' = ' , [ & ] ( const char * b2 , const char * e2 ) { <nl> - if ( key . empty ( ) ) { <nl> - key . assign ( b2 , e2 ) ; <nl> - } else { <nl> - val . assign ( b2 , e2 ) ; <nl> - } <nl> + split ( & s [ 0 ] , & s [ s . size ( ) ] , ' & ' , [ & ] ( const char * b , const char * e ) { <nl> + std : : string key ; <nl> + std : : string val ; <nl> + split ( b , e , ' = ' , [ & ] ( const char * b2 , const char * e2 ) { <nl> + if ( key . empty ( ) ) { <nl> + key . assign ( b2 , e2 ) ; <nl> + } else { <nl> + val . assign ( b2 , e2 ) ; <nl> + } <nl> + } ) ; <nl> + params . emplace ( decode_url ( key , true ) , decode_url ( val , true ) ) ; <nl> } ) ; <nl> - params . emplace ( decode_url ( key , true ) , decode_url ( val , true ) ) ; <nl> - } ) ; <nl> } <nl> <nl> - inline bool parse_multipart_boundary ( const std : : string & content_type , <nl> - std : : string & boundary ) { <nl> - auto pos = content_type . find ( " boundary = " ) ; <nl> - if ( pos = = std : : string : : npos ) { return false ; } <nl> - boundary = content_type . substr ( pos + 9 ) ; <nl> - if ( boundary . length ( ) > = 2 & & boundary . front ( ) = = ' " ' & & <nl> - boundary . back ( ) = = ' " ' ) { <nl> - boundary = boundary . substr ( 1 , boundary . size ( ) - 2 ) ; <nl> - } <nl> - return ! boundary . empty ( ) ; <nl> + inline bool parse_multipart_boundary ( const std : : string & content_type , std : : string & boundary ) { <nl> + auto pos = content_type . find ( " boundary = " ) ; <nl> + if ( pos = = std : : string : : npos ) { <nl> + return false ; <nl> + } <nl> + boundary = content_type . substr ( pos + 9 ) ; <nl> + if ( boundary . length ( ) > = 2 & & boundary . front ( ) = = ' " ' & & boundary . back ( ) = = ' " ' ) { <nl> + boundary = boundary . substr ( 1 , boundary . size ( ) - 2 ) ; <nl> + } <nl> + return ! boundary . empty ( ) ; <nl> } <nl> <nl> inline bool parse_range_header ( const std : : string & s , Ranges & ranges ) { <nl> - static auto re_first_range = std : : regex ( R " ( bytes = ( \ d * - \ d * ( ? : , \ s * \ d * - \ d * ) * ) ) " ) ; <nl> - std : : smatch m ; <nl> - if ( std : : regex_match ( s , m , re_first_range ) ) { <nl> - auto pos = static_cast < size_t > ( m . position ( 1 ) ) ; <nl> - auto len = static_cast < size_t > ( m . length ( 1 ) ) ; <nl> - bool all_valid_ranges = true ; <nl> - split ( & s [ pos ] , & s [ pos + len ] , ' , ' , [ & ] ( const char * b , const char * e ) { <nl> - if ( ! all_valid_ranges ) return ; <nl> - static auto re_another_range = std : : regex ( R " ( \ s * ( \ d * ) - ( \ d * ) ) " ) ; <nl> - std : : cmatch cm ; <nl> - if ( std : : regex_match ( b , e , cm , re_another_range ) ) { <nl> - ssize_t first = - 1 ; <nl> - if ( ! cm . str ( 1 ) . empty ( ) ) { <nl> - first = static_cast < ssize_t > ( std : : stoll ( cm . str ( 1 ) ) ) ; <nl> - } <nl> - <nl> - ssize_t last = - 1 ; <nl> - if ( ! cm . str ( 2 ) . empty ( ) ) { <nl> - last = static_cast < ssize_t > ( std : : stoll ( cm . str ( 2 ) ) ) ; <nl> - } <nl> - <nl> - if ( first ! = - 1 & & last ! = - 1 & & first > last ) { <nl> - all_valid_ranges = false ; <nl> - return ; <nl> - } <nl> - ranges . emplace_back ( std : : make_pair ( first , last ) ) ; <nl> - } <nl> - } ) ; <nl> - return all_valid_ranges ; <nl> - } <nl> - return false ; <nl> + static auto re_first_range = std : : regex ( R " ( bytes = ( \ d * - \ d * ( ? : , \ s * \ d * - \ d * ) * ) ) " ) ; <nl> + std : : smatch m ; <nl> + if ( std : : regex_match ( s , m , re_first_range ) ) { <nl> + auto pos = static_cast < size_t > ( m . position ( 1 ) ) ; <nl> + auto len = static_cast < size_t > ( m . length ( 1 ) ) ; <nl> + bool all_valid_ranges = true ; <nl> + split ( & s [ pos ] , & s [ pos + len ] , ' , ' , [ & ] ( const char * b , const char * e ) { <nl> + if ( ! all_valid_ranges ) return ; <nl> + static auto re_another_range = std : : regex ( R " ( \ s * ( \ d * ) - ( \ d * ) ) " ) ; <nl> + std : : cmatch cm ; <nl> + if ( std : : regex_match ( b , e , cm , re_another_range ) ) { <nl> + ssize_t first = - 1 ; <nl> + if ( ! cm . str ( 1 ) . empty ( ) ) { <nl> + first = static_cast < ssize_t > ( std : : stoll ( cm . str ( 1 ) ) ) ; <nl> + } <nl> + <nl> + ssize_t last = - 1 ; <nl> + if ( ! cm . str ( 2 ) . empty ( ) ) { <nl> + last = static_cast < ssize_t > ( std : : stoll ( cm . str ( 2 ) ) ) ; <nl> + } <nl> + <nl> + if ( first ! = - 1 & & last ! = - 1 & & first > last ) { <nl> + all_valid_ranges = false ; <nl> + return ; <nl> + } <nl> + ranges . emplace_back ( std : : make_pair ( first , last ) ) ; <nl> + } <nl> + } ) ; <nl> + return all_valid_ranges ; <nl> + } <nl> + return false ; <nl> } <nl> <nl> class MultipartFormDataParser { <nl> - public : <nl> - MultipartFormDataParser ( ) = default ; <nl> - <nl> - void set_boundary ( std : : string & & boundary ) { boundary_ = boundary ; } <nl> - <nl> - bool is_valid ( ) const { return is_valid_ ; } <nl> - <nl> - template < typename T , typename U > <nl> - bool parse ( const char * buf , size_t n , T content_callback , U header_callback ) { <nl> - static const std : : regex re_content_type ( R " ( ^ Content - Type : \ s * ( . * ? ) \ s * $ ) " , <nl> - std : : regex_constants : : icase ) ; <nl> - <nl> - static const std : : regex re_content_disposition ( <nl> - " ^ Content - Disposition : \ \ s * form - data ; \ \ s * name = \ " ( . * ? ) \ " ( ? : ; \ \ s * filename = " <nl> - " \ " ( . * ? ) \ " ) ? \ \ s * $ " , <nl> - std : : regex_constants : : icase ) ; <nl> - static const std : : string dash_ = " - - " ; <nl> - static const std : : string crlf_ = " \ r \ n " ; <nl> - <nl> - buf_ . append ( buf , n ) ; / / TODO : performance improvement <nl> - <nl> - while ( ! buf_ . empty ( ) ) { <nl> - switch ( state_ ) { <nl> - case 0 : { / / Initial boundary <nl> - auto pattern = dash_ + boundary_ + crlf_ ; <nl> - if ( pattern . size ( ) > buf_ . size ( ) ) { return true ; } <nl> - auto pos = buf_ . find ( pattern ) ; <nl> - if ( pos ! = 0 ) { return false ; } <nl> - buf_ . erase ( 0 , pattern . size ( ) ) ; <nl> - off_ + = pattern . size ( ) ; <nl> - state_ = 1 ; <nl> - break ; <nl> - } <nl> - case 1 : { / / New entry <nl> - clear_file_info ( ) ; <nl> - state_ = 2 ; <nl> - break ; <nl> - } <nl> - case 2 : { / / Headers <nl> - auto pos = buf_ . find ( crlf_ ) ; <nl> - while ( pos ! = std : : string : : npos ) { <nl> - / / Empty line <nl> - if ( pos = = 0 ) { <nl> - if ( ! header_callback ( file_ ) ) { <nl> - is_valid_ = false ; <nl> - return false ; <nl> + public : <nl> + MultipartFormDataParser ( ) = default ; <nl> + <nl> + void set_boundary ( std : : string & & boundary ) { <nl> + boundary_ = boundary ; <nl> + } <nl> + <nl> + bool is_valid ( ) const { <nl> + return is_valid_ ; <nl> + } <nl> + <nl> + template < typename T , typename U > <nl> + bool parse ( const char * buf , size_t n , T content_callback , U header_callback ) { <nl> + static const std : : regex re_content_type ( R " ( ^ Content - Type : \ s * ( . * ? ) \ s * $ ) " , std : : regex_constants : : icase ) ; <nl> + <nl> + static const std : : regex re_content_disposition ( <nl> + " ^ Content - Disposition : \ \ s * form - data ; \ \ s * name = \ " ( . * ? ) \ " ( ? : ; \ \ s * filename = " <nl> + " \ " ( . * ? ) \ " ) ? \ \ s * $ " , <nl> + std : : regex_constants : : icase ) ; <nl> + static const std : : string dash_ = " - - " ; <nl> + static const std : : string crlf_ = " \ r \ n " ; <nl> + <nl> + buf_ . append ( buf , n ) ; / / TODO : performance improvement <nl> + <nl> + while ( ! buf_ . empty ( ) ) { <nl> + switch ( state_ ) { <nl> + case 0 : { / / Initial boundary <nl> + auto pattern = dash_ + boundary_ + crlf_ ; <nl> + if ( pattern . size ( ) > buf_ . size ( ) ) { <nl> + return true ; <nl> + } <nl> + auto pos = buf_ . find ( pattern ) ; <nl> + if ( pos ! = 0 ) { <nl> + return false ; <nl> + } <nl> + buf_ . erase ( 0 , pattern . size ( ) ) ; <nl> + off_ + = pattern . size ( ) ; <nl> + state_ = 1 ; <nl> + break ; <nl> } <nl> - buf_ . erase ( 0 , crlf_ . size ( ) ) ; <nl> - off_ + = crlf_ . size ( ) ; <nl> - state_ = 3 ; <nl> - break ; <nl> - } <nl> - <nl> - auto header = buf_ . substr ( 0 , pos ) ; <nl> - { <nl> - std : : smatch m ; <nl> - if ( std : : regex_match ( header , m , re_content_type ) ) { <nl> - file_ . content_type = m [ 1 ] ; <nl> - } else if ( std : : regex_match ( header , m , re_content_disposition ) ) { <nl> - file_ . name = m [ 1 ] ; <nl> - file_ . filename = m [ 2 ] ; <nl> + case 1 : { / / New entry <nl> + clear_file_info ( ) ; <nl> + state_ = 2 ; <nl> + break ; <nl> } <nl> - } <nl> - <nl> - buf_ . erase ( 0 , pos + crlf_ . size ( ) ) ; <nl> - off_ + = pos + crlf_ . size ( ) ; <nl> - pos = buf_ . find ( crlf_ ) ; <nl> - } <nl> - if ( state_ ! = 3 ) { return true ; } <nl> - break ; <nl> - } <nl> - case 3 : { / / Body <nl> - { <nl> - auto pattern = crlf_ + dash_ ; <nl> - if ( pattern . size ( ) > buf_ . size ( ) ) { return true ; } <nl> - <nl> - auto pos = buf_ . find ( pattern ) ; <nl> - if ( pos = = std : : string : : npos ) { <nl> - pos = buf_ . size ( ) ; <nl> - while ( pos > 0 ) { <nl> - auto c = buf_ [ pos - 1 ] ; <nl> - if ( c ! = ' \ r ' & & c ! = ' \ n ' & & c ! = ' - ' ) { break ; } <nl> - pos - - ; <nl> + case 2 : { / / Headers <nl> + auto pos = buf_ . find ( crlf_ ) ; <nl> + while ( pos ! = std : : string : : npos ) { <nl> + / / Empty line <nl> + if ( pos = = 0 ) { <nl> + if ( ! header_callback ( file_ ) ) { <nl> + is_valid_ = false ; <nl> + return false ; <nl> + } <nl> + buf_ . erase ( 0 , crlf_ . size ( ) ) ; <nl> + off_ + = crlf_ . size ( ) ; <nl> + state_ = 3 ; <nl> + break ; <nl> + } <nl> + <nl> + auto header = buf_ . substr ( 0 , pos ) ; <nl> + { <nl> + std : : smatch m ; <nl> + if ( std : : regex_match ( header , m , re_content_type ) ) { <nl> + file_ . content_type = m [ 1 ] ; <nl> + } else if ( std : : regex_match ( header , m , re_content_disposition ) ) { <nl> + file_ . name = m [ 1 ] ; <nl> + file_ . filename = m [ 2 ] ; <nl> + } <nl> + } <nl> + <nl> + buf_ . erase ( 0 , pos + crlf_ . size ( ) ) ; <nl> + off_ + = pos + crlf_ . size ( ) ; <nl> + pos = buf_ . find ( crlf_ ) ; <nl> + } <nl> + if ( state_ ! = 3 ) { <nl> + return true ; <nl> + } <nl> + break ; <nl> } <nl> - } <nl> - <nl> - if ( ! content_callback ( buf_ . data ( ) , pos ) ) { <nl> - is_valid_ = false ; <nl> - return false ; <nl> - } <nl> - <nl> - off_ + = pos ; <nl> - buf_ . erase ( 0 , pos ) ; <nl> - } <nl> - <nl> - { <nl> - auto pattern = crlf_ + dash_ + boundary_ ; <nl> - if ( pattern . size ( ) > buf_ . size ( ) ) { return true ; } <nl> - <nl> - auto pos = buf_ . find ( pattern ) ; <nl> - if ( pos ! = std : : string : : npos ) { <nl> - if ( ! content_callback ( buf_ . data ( ) , pos ) ) { <nl> - is_valid_ = false ; <nl> - return false ; <nl> + case 3 : { / / Body <nl> + { <nl> + auto pattern = crlf_ + dash_ ; <nl> + if ( pattern . size ( ) > buf_ . size ( ) ) { <nl> + return true ; <nl> + } <nl> + <nl> + auto pos = buf_ . find ( pattern ) ; <nl> + if ( pos = = std : : string : : npos ) { <nl> + pos = buf_ . size ( ) ; <nl> + while ( pos > 0 ) { <nl> + auto c = buf_ [ pos - 1 ] ; <nl> + if ( c ! = ' \ r ' & & c ! = ' \ n ' & & c ! = ' - ' ) { <nl> + break ; <nl> + } <nl> + pos - - ; <nl> + } <nl> + } <nl> + <nl> + if ( ! content_callback ( buf_ . data ( ) , pos ) ) { <nl> + is_valid_ = false ; <nl> + return false ; <nl> + } <nl> + <nl> + off_ + = pos ; <nl> + buf_ . erase ( 0 , pos ) ; <nl> + } <nl> + <nl> + { <nl> + auto pattern = crlf_ + dash_ + boundary_ ; <nl> + if ( pattern . size ( ) > buf_ . size ( ) ) { <nl> + return true ; <nl> + } <nl> + <nl> + auto pos = buf_ . find ( pattern ) ; <nl> + if ( pos ! = std : : string : : npos ) { <nl> + if ( ! content_callback ( buf_ . data ( ) , pos ) ) { <nl> + is_valid_ = false ; <nl> + return false ; <nl> + } <nl> + <nl> + off_ + = pos + pattern . size ( ) ; <nl> + buf_ . erase ( 0 , pos + pattern . size ( ) ) ; <nl> + state_ = 4 ; <nl> + } else { <nl> + if ( ! content_callback ( buf_ . data ( ) , pattern . size ( ) ) ) { <nl> + is_valid_ = false ; <nl> + return false ; <nl> + } <nl> + <nl> + off_ + = pattern . size ( ) ; <nl> + buf_ . erase ( 0 , pattern . size ( ) ) ; <nl> + } <nl> + } <nl> + break ; <nl> + } <nl> + case 4 : { / / Boundary <nl> + if ( crlf_ . size ( ) > buf_ . size ( ) ) { <nl> + return true ; <nl> + } <nl> + if ( buf_ . find ( crlf_ ) = = 0 ) { <nl> + buf_ . erase ( 0 , crlf_ . size ( ) ) ; <nl> + off_ + = crlf_ . size ( ) ; <nl> + state_ = 1 ; <nl> + } else { <nl> + auto pattern = dash_ + crlf_ ; <nl> + if ( pattern . size ( ) > buf_ . size ( ) ) { <nl> + return true ; <nl> + } <nl> + if ( buf_ . find ( pattern ) = = 0 ) { <nl> + buf_ . erase ( 0 , pattern . size ( ) ) ; <nl> + off_ + = pattern . size ( ) ; <nl> + is_valid_ = true ; <nl> + state_ = 5 ; <nl> + } else { <nl> + return true ; <nl> + } <nl> + } <nl> + break ; <nl> + } <nl> + case 5 : { / / Done <nl> + is_valid_ = false ; <nl> + return false ; <nl> } <nl> - <nl> - off_ + = pos + pattern . size ( ) ; <nl> - buf_ . erase ( 0 , pos + pattern . size ( ) ) ; <nl> - state_ = 4 ; <nl> - } else { <nl> - if ( ! content_callback ( buf_ . data ( ) , pattern . size ( ) ) ) { <nl> - is_valid_ = false ; <nl> - return false ; <nl> } <nl> - <nl> - off_ + = pattern . size ( ) ; <nl> - buf_ . erase ( 0 , pattern . size ( ) ) ; <nl> - } <nl> - } <nl> - break ; <nl> - } <nl> - case 4 : { / / Boundary <nl> - if ( crlf_ . size ( ) > buf_ . size ( ) ) { return true ; } <nl> - if ( buf_ . find ( crlf_ ) = = 0 ) { <nl> - buf_ . erase ( 0 , crlf_ . size ( ) ) ; <nl> - off_ + = crlf_ . size ( ) ; <nl> - state_ = 1 ; <nl> - } else { <nl> - auto pattern = dash_ + crlf_ ; <nl> - if ( pattern . size ( ) > buf_ . size ( ) ) { return true ; } <nl> - if ( buf_ . find ( pattern ) = = 0 ) { <nl> - buf_ . erase ( 0 , pattern . size ( ) ) ; <nl> - off_ + = pattern . size ( ) ; <nl> - is_valid_ = true ; <nl> - state_ = 5 ; <nl> - } else { <nl> - return true ; <nl> - } <nl> } <nl> - break ; <nl> - } <nl> - case 5 : { / / Done <nl> - is_valid_ = false ; <nl> - return false ; <nl> - } <nl> - } <nl> + <nl> + return true ; <nl> } <nl> <nl> - return true ; <nl> - } <nl> - <nl> - private : <nl> - void clear_file_info ( ) { <nl> - file_ . name . clear ( ) ; <nl> - file_ . filename . clear ( ) ; <nl> - file_ . content_type . clear ( ) ; <nl> - } <nl> - <nl> - std : : string boundary_ ; <nl> - <nl> - std : : string buf_ ; <nl> - size_t state_ = 0 ; <nl> - bool is_valid_ = false ; <nl> - size_t off_ = 0 ; <nl> - MultipartFormData file_ ; <nl> + private : <nl> + void clear_file_info ( ) { <nl> + file_ . name . clear ( ) ; <nl> + file_ . filename . clear ( ) ; <nl> + file_ . content_type . clear ( ) ; <nl> + } <nl> + <nl> + std : : string boundary_ ; <nl> + <nl> + std : : string buf_ ; <nl> + size_t state_ = 0 ; <nl> + bool is_valid_ = false ; <nl> + size_t off_ = 0 ; <nl> + MultipartFormData file_ ; <nl> } ; <nl> <nl> inline std : : string to_lower ( const char * beg , const char * end ) { <nl> - std : : string out ; <nl> - auto it = beg ; <nl> - while ( it ! = end ) { <nl> - out + = static_cast < char > ( : : tolower ( * it ) ) ; <nl> - it + + ; <nl> - } <nl> - return out ; <nl> + std : : string out ; <nl> + auto it = beg ; <nl> + while ( it ! = end ) { <nl> + out + = static_cast < char > ( : : tolower ( * it ) ) ; <nl> + it + + ; <nl> + } <nl> + return out ; <nl> } <nl> <nl> inline std : : string make_multipart_data_boundary ( ) { <nl> - static const char data [ ] = <nl> - " 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz " ; <nl> + static const char data [ ] = " 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz " ; <nl> <nl> - std : : random_device seed_gen ; <nl> - std : : mt19937 engine ( seed_gen ( ) ) ; <nl> + std : : random_device seed_gen ; <nl> + std : : mt19937 engine ( seed_gen ( ) ) ; <nl> <nl> - std : : string result = " - - cpp - httplib - multipart - data - " ; <nl> + std : : string result = " - - cpp - httplib - multipart - data - " ; <nl> <nl> - for ( auto i = 0 ; i < 16 ; i + + ) { <nl> - result + = data [ engine ( ) % ( sizeof ( data ) - 1 ) ] ; <nl> - } <nl> + for ( auto i = 0 ; i < 16 ; i + + ) { <nl> + result + = data [ engine ( ) % ( sizeof ( data ) - 1 ) ] ; <nl> + } <nl> <nl> - return result ; <nl> + return result ; <nl> } <nl> <nl> - inline std : : pair < size_t , size_t > <nl> - get_range_offset_and_length ( const Request & req , size_t content_length , <nl> - size_t index ) { <nl> - auto r = req . ranges [ index ] ; <nl> + inline std : : pair < size_t , size_t > get_range_offset_and_length ( const Request & req , size_t content_length , size_t index ) { <nl> + auto r = req . ranges [ index ] ; <nl> <nl> - if ( r . first = = - 1 & & r . second = = - 1 ) { <nl> - return std : : make_pair ( 0 , content_length ) ; <nl> - } <nl> + if ( r . first = = - 1 & & r . second = = - 1 ) { <nl> + return std : : make_pair ( 0 , content_length ) ; <nl> + } <nl> <nl> - auto slen = static_cast < ssize_t > ( content_length ) ; <nl> + auto slen = static_cast < ssize_t > ( content_length ) ; <nl> <nl> - if ( r . first = = - 1 ) { <nl> - r . first = slen - r . second ; <nl> - r . second = slen - 1 ; <nl> - } <nl> + if ( r . first = = - 1 ) { <nl> + r . first = slen - r . second ; <nl> + r . second = slen - 1 ; <nl> + } <nl> <nl> - if ( r . second = = - 1 ) { r . second = slen - 1 ; } <nl> + if ( r . second = = - 1 ) { <nl> + r . second = slen - 1 ; <nl> + } <nl> <nl> - return std : : make_pair ( r . first , r . second - r . first + 1 ) ; <nl> + return std : : make_pair ( r . first , r . second - r . first + 1 ) ; <nl> } <nl> <nl> - inline std : : string make_content_range_header_field ( size_t offset , size_t length , <nl> - size_t content_length ) { <nl> - std : : string field = " bytes " ; <nl> - field + = std : : to_string ( offset ) ; <nl> - field + = " - " ; <nl> - field + = std : : to_string ( offset + length - 1 ) ; <nl> - field + = " / " ; <nl> - field + = std : : to_string ( content_length ) ; <nl> - return field ; <nl> + inline std : : string make_content_range_header_field ( size_t offset , size_t length , size_t content_length ) { <nl> + std : : string field = " bytes " ; <nl> + field + = std : : to_string ( offset ) ; <nl> + field + = " - " ; <nl> + field + = std : : to_string ( offset + length - 1 ) ; <nl> + field + = " / " ; <nl> + field + = std : : to_string ( content_length ) ; <nl> + return field ; <nl> } <nl> <nl> template < typename SToken , typename CToken , typename Content > <nl> - bool process_multipart_ranges_data ( const Request & req , Response & res , <nl> + bool process_multipart_ranges_data ( const Request & req , <nl> + Response & res , <nl> const std : : string & boundary , <nl> const std : : string & content_type , <nl> - SToken stoken , CToken ctoken , <nl> + SToken stoken , <nl> + CToken ctoken , <nl> Content content ) { <nl> - for ( size_t i = 0 ; i < req . ranges . size ( ) ; i + + ) { <nl> - ctoken ( " - - " ) ; <nl> - stoken ( boundary ) ; <nl> - ctoken ( " \ r \ n " ) ; <nl> - if ( ! content_type . empty ( ) ) { <nl> - ctoken ( " Content - Type : " ) ; <nl> - stoken ( content_type ) ; <nl> - ctoken ( " \ r \ n " ) ; <nl> - } <nl> + for ( size_t i = 0 ; i < req . ranges . size ( ) ; i + + ) { <nl> + ctoken ( " - - " ) ; <nl> + stoken ( boundary ) ; <nl> + ctoken ( " \ r \ n " ) ; <nl> + if ( ! content_type . empty ( ) ) { <nl> + ctoken ( " Content - Type : " ) ; <nl> + stoken ( content_type ) ; <nl> + ctoken ( " \ r \ n " ) ; <nl> + } <nl> <nl> - auto offsets = get_range_offset_and_length ( req , res . body . size ( ) , i ) ; <nl> - auto offset = offsets . first ; <nl> - auto length = offsets . second ; <nl> + auto offsets = get_range_offset_and_length ( req , res . body . size ( ) , i ) ; <nl> + auto offset = offsets . first ; <nl> + auto length = offsets . second ; <nl> <nl> - ctoken ( " Content - Range : " ) ; <nl> - stoken ( make_content_range_header_field ( offset , length , res . body . size ( ) ) ) ; <nl> - ctoken ( " \ r \ n " ) ; <nl> - ctoken ( " \ r \ n " ) ; <nl> - if ( ! content ( offset , length ) ) { return false ; } <nl> - ctoken ( " \ r \ n " ) ; <nl> - } <nl> + ctoken ( " Content - Range : " ) ; <nl> + stoken ( make_content_range_header_field ( offset , length , res . body . size ( ) ) ) ; <nl> + ctoken ( " \ r \ n " ) ; <nl> + ctoken ( " \ r \ n " ) ; <nl> + if ( ! content ( offset , length ) ) { <nl> + return false ; <nl> + } <nl> + ctoken ( " \ r \ n " ) ; <nl> + } <nl> <nl> - ctoken ( " - - " ) ; <nl> - stoken ( boundary ) ; <nl> - ctoken ( " - - \ r \ n " ) ; <nl> + ctoken ( " - - " ) ; <nl> + stoken ( boundary ) ; <nl> + ctoken ( " - - \ r \ n " ) ; <nl> <nl> - return true ; <nl> + return true ; <nl> } <nl> <nl> - inline std : : string make_multipart_ranges_data ( const Request & req , Response & res , <nl> + inline std : : string make_multipart_ranges_data ( const Request & req , <nl> + Response & res , <nl> const std : : string & boundary , <nl> const std : : string & content_type ) { <nl> - std : : string data ; <nl> - <nl> - process_multipart_ranges_data ( <nl> - req , res , boundary , content_type , <nl> - [ & ] ( const std : : string & token ) { data + = token ; } , <nl> - [ & ] ( const char * token ) { data + = token ; } , <nl> - [ & ] ( size_t offset , size_t length ) { <nl> - data + = res . body . substr ( offset , length ) ; <nl> - return true ; <nl> - } ) ; <nl> - <nl> - return data ; <nl> - } <nl> - <nl> - inline size_t <nl> - get_multipart_ranges_data_length ( const Request & req , Response & res , <nl> - const std : : string & boundary , <nl> - const std : : string & content_type ) { <nl> - size_t data_length = 0 ; <nl> - <nl> - process_multipart_ranges_data ( <nl> - req , res , boundary , content_type , <nl> - [ & ] ( const std : : string & token ) { data_length + = token . size ( ) ; } , <nl> - [ & ] ( const char * token ) { data_length + = strlen ( token ) ; } , <nl> - [ & ] ( size_t / * offset * / , size_t length ) { <nl> - data_length + = length ; <nl> - return true ; <nl> - } ) ; <nl> - <nl> - return data_length ; <nl> + std : : string data ; <nl> + <nl> + process_multipart_ranges_data ( req , <nl> + res , <nl> + boundary , <nl> + content_type , <nl> + [ & ] ( const std : : string & token ) { data + = token ; } , <nl> + [ & ] ( const char * token ) { data + = token ; } , <nl> + [ & ] ( size_t offset , size_t length ) { <nl> + data + = res . body . substr ( offset , length ) ; <nl> + return true ; <nl> + } ) ; <nl> + <nl> + return data ; <nl> + } <nl> + <nl> + inline size_t get_multipart_ranges_data_length ( const Request & req , <nl> + Response & res , <nl> + const std : : string & boundary , <nl> + const std : : string & content_type ) { <nl> + size_t data_length = 0 ; <nl> + <nl> + process_multipart_ranges_data ( req , <nl> + res , <nl> + boundary , <nl> + content_type , <nl> + [ & ] ( const std : : string & token ) { data_length + = token . size ( ) ; } , <nl> + [ & ] ( const char * token ) { data_length + = strlen ( token ) ; } , <nl> + [ & ] ( size_t / * offset * / , size_t length ) { <nl> + data_length + = length ; <nl> + return true ; <nl> + } ) ; <nl> + <nl> + return data_length ; <nl> } <nl> <nl> template < typename T > <nl> - inline bool write_multipart_ranges_data ( Stream & strm , const Request & req , <nl> + inline bool write_multipart_ranges_data ( Stream & strm , <nl> + const Request & req , <nl> Response & res , <nl> const std : : string & boundary , <nl> const std : : string & content_type , <nl> T is_shutting_down ) { <nl> - return process_multipart_ranges_data ( <nl> - req , res , boundary , content_type , <nl> - [ & ] ( const std : : string & token ) { strm . write ( token ) ; } , <nl> - [ & ] ( const char * token ) { strm . write ( token ) ; } , <nl> - [ & ] ( size_t offset , size_t length ) { <nl> - return write_content ( strm , res . content_provider_ , offset , length , <nl> - is_shutting_down ) > = 0 ; <nl> - } ) ; <nl> + return process_multipart_ranges_data ( <nl> + req , <nl> + res , <nl> + boundary , <nl> + content_type , <nl> + [ & ] ( const std : : string & token ) { strm . write ( token ) ; } , <nl> + [ & ] ( const char * token ) { strm . write ( token ) ; } , <nl> + [ & ] ( size_t offset , size_t length ) { <nl> + return write_content ( strm , res . content_provider_ , offset , length , is_shutting_down ) > = 0 ; <nl> + } ) ; <nl> } <nl> <nl> - inline std : : pair < size_t , size_t > <nl> - get_range_offset_and_length ( const Request & req , const Response & res , <nl> - size_t index ) { <nl> - auto r = req . ranges [ index ] ; <nl> + inline std : : pair < size_t , size_t > get_range_offset_and_length ( const Request & req , const Response & res , size_t index ) { <nl> + auto r = req . ranges [ index ] ; <nl> <nl> - if ( r . second = = - 1 ) { <nl> - r . second = static_cast < ssize_t > ( res . content_length_ ) - 1 ; <nl> - } <nl> + if ( r . second = = - 1 ) { <nl> + r . second = static_cast < ssize_t > ( res . content_length_ ) - 1 ; <nl> + } <nl> <nl> - return std : : make_pair ( r . first , r . second - r . first + 1 ) ; <nl> + return std : : make_pair ( r . first , r . second - r . first + 1 ) ; <nl> } <nl> <nl> inline bool expect_content ( const Request & req ) { <nl> - if ( req . method = = " POST " | | req . method = = " PUT " | | req . method = = " PATCH " | | <nl> - req . method = = " PRI " | | <nl> - ( req . method = = " DELETE " & & req . has_header ( " Content - Length " ) ) ) { <nl> - return true ; <nl> - } <nl> - / / TODO : check if Content - Length is set <nl> - return false ; <nl> + if ( req . method = = " POST " | | req . method = = " PUT " | | req . method = = " PATCH " | | req . method = = " PRI " | | <nl> + ( req . method = = " DELETE " & & req . has_header ( " Content - Length " ) ) ) { <nl> + return true ; <nl> + } <nl> + / / TODO : check if Content - Length is set <nl> + return false ; <nl> } <nl> <nl> inline bool has_crlf ( const char * s ) { <nl> - auto p = s ; <nl> - while ( * p ) { <nl> - if ( * p = = ' \ r ' | | * p = = ' \ n ' ) { return true ; } <nl> - p + + ; <nl> - } <nl> - return false ; <nl> + auto p = s ; <nl> + while ( * p ) { <nl> + if ( * p = = ' \ r ' | | * p = = ' \ n ' ) { <nl> + return true ; <nl> + } <nl> + p + + ; <nl> + } <nl> + return false ; <nl> } <nl> <nl> # ifdef CPPHTTPLIB_OPENSSL_SUPPORT <nl> template < typename CTX , typename Init , typename Update , typename Final > <nl> - inline std : : string message_digest ( const std : : string & s , Init init , <nl> - Update update , Final final , <nl> - size_t digest_length ) { <nl> - using namespace std ; <nl> + inline std : : string message_digest ( const std : : string & s , Init init , Update update , Final final , size_t digest_length ) { <nl> + using namespace std ; <nl> <nl> - std : : vector < unsigned char > md ( digest_length , 0 ) ; <nl> - CTX ctx ; <nl> - init ( & ctx ) ; <nl> - update ( & ctx , s . data ( ) , s . size ( ) ) ; <nl> - final ( md . data ( ) , & ctx ) ; <nl> + std : : vector < unsigned char > md ( digest_length , 0 ) ; <nl> + CTX ctx ; <nl> + init ( & ctx ) ; <nl> + update ( & ctx , s . data ( ) , s . size ( ) ) ; <nl> + final ( md . data ( ) , & ctx ) ; <nl> <nl> - stringstream ss ; <nl> - for ( auto c : md ) { <nl> - ss < < setfill ( ' 0 ' ) < < setw ( 2 ) < < hex < < ( unsigned int ) c ; <nl> - } <nl> - return ss . str ( ) ; <nl> + stringstream ss ; <nl> + for ( auto c : md ) { <nl> + ss < < setfill ( ' 0 ' ) < < setw ( 2 ) < < hex < < ( unsigned int ) c ; <nl> + } <nl> + return ss . str ( ) ; <nl> } <nl> <nl> inline std : : string MD5 ( const std : : string & s ) { <nl> - return message_digest < MD5_CTX > ( s , MD5_Init , MD5_Update , MD5_Final , <nl> - MD5_DIGEST_LENGTH ) ; <nl> + return message_digest < MD5_CTX > ( s , MD5_Init , MD5_Update , MD5_Final , MD5_DIGEST_LENGTH ) ; <nl> } <nl> <nl> inline std : : string SHA_256 ( const std : : string & s ) { <nl> - return message_digest < SHA256_CTX > ( s , SHA256_Init , SHA256_Update , SHA256_Final , <nl> - SHA256_DIGEST_LENGTH ) ; <nl> + return message_digest < SHA256_CTX > ( s , SHA256_Init , SHA256_Update , SHA256_Final , SHA256_DIGEST_LENGTH ) ; <nl> } <nl> <nl> inline std : : string SHA_512 ( const std : : string & s ) { <nl> - return message_digest < SHA512_CTX > ( s , SHA512_Init , SHA512_Update , SHA512_Final , <nl> - SHA512_DIGEST_LENGTH ) ; <nl> + return message_digest < SHA512_CTX > ( s , SHA512_Init , SHA512_Update , SHA512_Final , SHA512_DIGEST_LENGTH ) ; <nl> } <nl> # endif <nl> <nl> # ifdef _WIN32 <nl> class WSInit { <nl> - public : <nl> - WSInit ( ) { <nl> - WSADATA wsaData ; <nl> - WSAStartup ( 0x0002 , & wsaData ) ; <nl> - } <nl> + public : <nl> + WSInit ( ) { <nl> + WSADATA wsaData ; <nl> + WSAStartup ( 0x0002 , & wsaData ) ; <nl> + } <nl> <nl> - ~ WSInit ( ) { WSACleanup ( ) ; } <nl> + ~ WSInit ( ) { <nl> + WSACleanup ( ) ; <nl> + } <nl> } ; <nl> <nl> static WSInit wsinit_ ; <nl> # endif <nl> <nl> - } / / namespace detail <nl> + } / / namespace detail <nl> <nl> / / Header utilities <nl> inline std : : pair < std : : string , std : : string > make_range_header ( Ranges ranges ) { <nl> - std : : string field = " bytes = " ; <nl> - auto i = 0 ; <nl> - for ( auto r : ranges ) { <nl> - if ( i ! = 0 ) { field + = " , " ; } <nl> - if ( r . first ! = - 1 ) { field + = std : : to_string ( r . first ) ; } <nl> - field + = ' - ' ; <nl> - if ( r . second ! = - 1 ) { field + = std : : to_string ( r . second ) ; } <nl> - i + + ; <nl> - } <nl> - return std : : make_pair ( " Range " , field ) ; <nl> - } <nl> - <nl> - inline std : : pair < std : : string , std : : string > <nl> - make_basic_authentication_header ( const std : : string & username , <nl> - const std : : string & password , <nl> - bool is_proxy = false ) { <nl> - auto field = " Basic " + detail : : base64_encode ( username + " : " + password ) ; <nl> - auto key = is_proxy ? " Proxy - Authorization " : " Authorization " ; <nl> - return std : : make_pair ( key , field ) ; <nl> + std : : string field = " bytes = " ; <nl> + auto i = 0 ; <nl> + for ( auto r : ranges ) { <nl> + if ( i ! = 0 ) { <nl> + field + = " , " ; <nl> + } <nl> + if ( r . first ! = - 1 ) { <nl> + field + = std : : to_string ( r . first ) ; <nl> + } <nl> + field + = ' - ' ; <nl> + if ( r . second ! = - 1 ) { <nl> + field + = std : : to_string ( r . second ) ; <nl> + } <nl> + i + + ; <nl> + } <nl> + return std : : make_pair ( " Range " , field ) ; <nl> + } <nl> + <nl> + inline std : : pair < std : : string , std : : string > make_basic_authentication_header ( const std : : string & username , <nl> + const std : : string & password , <nl> + bool is_proxy = false ) { <nl> + auto field = " Basic " + detail : : base64_encode ( username + " : " + password ) ; <nl> + auto key = is_proxy ? " Proxy - Authorization " : " Authorization " ; <nl> + return std : : make_pair ( key , field ) ; <nl> } <nl> <nl> # ifdef CPPHTTPLIB_OPENSSL_SUPPORT <nl> inline std : : pair < std : : string , std : : string > make_digest_authentication_header ( <nl> - const Request & req , const std : : map < std : : string , std : : string > & auth , <nl> - size_t cnonce_count , const std : : string & cnonce , const std : : string & username , <nl> - const std : : string & password , bool is_proxy = false ) { <nl> - using namespace std ; <nl> - <nl> - string nc ; <nl> - { <nl> - stringstream ss ; <nl> - ss < < setfill ( ' 0 ' ) < < setw ( 8 ) < < hex < < cnonce_count ; <nl> - nc = ss . str ( ) ; <nl> - } <nl> - <nl> - auto qop = auth . at ( " qop " ) ; <nl> - if ( qop . find ( " auth - int " ) ! = std : : string : : npos ) { <nl> - qop = " auth - int " ; <nl> - } else { <nl> - qop = " auth " ; <nl> - } <nl> - <nl> - std : : string algo = " MD5 " ; <nl> - if ( auth . find ( " algorithm " ) ! = auth . end ( ) ) { algo = auth . at ( " algorithm " ) ; } <nl> - <nl> - string response ; <nl> - { <nl> - auto H = algo = = " SHA - 256 " <nl> - ? detail : : SHA_256 <nl> - : algo = = " SHA - 512 " ? detail : : SHA_512 : detail : : MD5 ; <nl> - <nl> - auto A1 = username + " : " + auth . at ( " realm " ) + " : " + password ; <nl> + const Request & req , <nl> + const std : : map < std : : string , std : : string > & auth , <nl> + size_t cnonce_count , <nl> + const std : : string & cnonce , <nl> + const std : : string & username , <nl> + const std : : string & password , <nl> + bool is_proxy = false ) { <nl> + using namespace std ; <nl> + <nl> + string nc ; <nl> + { <nl> + stringstream ss ; <nl> + ss < < setfill ( ' 0 ' ) < < setw ( 8 ) < < hex < < cnonce_count ; <nl> + nc = ss . str ( ) ; <nl> + } <nl> + <nl> + auto qop = auth . at ( " qop " ) ; <nl> + if ( qop . find ( " auth - int " ) ! = std : : string : : npos ) { <nl> + qop = " auth - int " ; <nl> + } else { <nl> + qop = " auth " ; <nl> + } <nl> <nl> - auto A2 = req . method + " : " + req . path ; <nl> - if ( qop = = " auth - int " ) { A2 + = " : " + H ( req . body ) ; } <nl> + std : : string algo = " MD5 " ; <nl> + if ( auth . find ( " algorithm " ) ! = auth . end ( ) ) { <nl> + algo = auth . at ( " algorithm " ) ; <nl> + } <nl> <nl> - response = H ( H ( A1 ) + " : " + auth . at ( " nonce " ) + " : " + nc + " : " + cnonce + <nl> - " : " + qop + " : " + H ( A2 ) ) ; <nl> - } <nl> + string response ; <nl> + { <nl> + auto H = algo = = " SHA - 256 " ? detail : : SHA_256 : algo = = " SHA - 512 " ? detail : : SHA_512 : detail : : MD5 ; <nl> <nl> - auto field = " Digest username = \ " " + username + " \ " , realm = \ " " + <nl> - auth . at ( " realm " ) + " \ " , nonce = \ " " + auth . at ( " nonce " ) + <nl> - " \ " , uri = \ " " + req . path + " \ " , algorithm = " + algo + <nl> - " , qop = " + qop + " , nc = \ " " + nc + " \ " , cnonce = \ " " + cnonce + <nl> - " \ " , response = \ " " + response + " \ " " ; <nl> + auto A1 = username + " : " + auth . at ( " realm " ) + " : " + password ; <nl> <nl> - auto key = is_proxy ? " Proxy - Authorization " : " Authorization " ; <nl> - return std : : make_pair ( key , field ) ; <nl> - } <nl> - # endif <nl> + auto A2 = req . method + " : " + req . path ; <nl> + if ( qop = = " auth - int " ) { <nl> + A2 + = " : " + H ( req . body ) ; <nl> + } <nl> <nl> - inline bool parse_www_authenticate ( const Response & res , <nl> - std : : map < std : : string , std : : string > & auth , <nl> - bool is_proxy ) { <nl> - auto auth_key = is_proxy ? " Proxy - Authenticate " : " WWW - Authenticate " ; <nl> - if ( res . has_header ( auth_key ) ) { <nl> - static auto re = std : : regex ( R " ~ ( ( ? : ( ? : , \ s * ) ? ( . + ? ) = ( ? : " ( . * ? ) " | ( [ ^ , ] * ) ) ) ) ~ " ) ; <nl> - auto s = res . get_header_value ( auth_key ) ; <nl> - auto pos = s . find ( ' ' ) ; <nl> - if ( pos ! = std : : string : : npos ) { <nl> - auto type = s . substr ( 0 , pos ) ; <nl> - if ( type = = " Basic " ) { <nl> - return false ; <nl> - } else if ( type = = " Digest " ) { <nl> - s = s . substr ( pos + 1 ) ; <nl> - auto beg = std : : sregex_iterator ( s . begin ( ) , s . end ( ) , re ) ; <nl> - for ( auto i = beg ; i ! = std : : sregex_iterator ( ) ; + + i ) { <nl> - auto m = * i ; <nl> - auto key = s . substr ( static_cast < size_t > ( m . position ( 1 ) ) , <nl> - static_cast < size_t > ( m . length ( 1 ) ) ) ; <nl> - auto val = m . length ( 2 ) > 0 <nl> - ? s . substr ( static_cast < size_t > ( m . position ( 2 ) ) , <nl> - static_cast < size_t > ( m . length ( 2 ) ) ) <nl> - : s . substr ( static_cast < size_t > ( m . position ( 3 ) ) , <nl> - static_cast < size_t > ( m . length ( 3 ) ) ) ; <nl> - auth [ key ] = val ; <nl> + response = H ( H ( A1 ) + " : " + auth . at ( " nonce " ) + " : " + nc + " : " + cnonce + " : " + qop + " : " + H ( A2 ) ) ; <nl> + } <nl> + <nl> + auto field = " Digest username = \ " " + username + " \ " , realm = \ " " + auth . at ( " realm " ) + " \ " , nonce = \ " " + <nl> + auth . at ( " nonce " ) + " \ " , uri = \ " " + req . path + " \ " , algorithm = " + algo + " , qop = " + qop + " , nc = \ " " + <nl> + nc + " \ " , cnonce = \ " " + cnonce + " \ " , response = \ " " + response + " \ " " ; <nl> + <nl> + auto key = is_proxy ? " Proxy - Authorization " : " Authorization " ; <nl> + return std : : make_pair ( key , field ) ; <nl> + } <nl> + # endif <nl> + <nl> + inline bool parse_www_authenticate ( const Response & res , std : : map < std : : string , std : : string > & auth , bool is_proxy ) { <nl> + auto auth_key = is_proxy ? " Proxy - Authenticate " : " WWW - Authenticate " ; <nl> + if ( res . has_header ( auth_key ) ) { <nl> + static auto re = std : : regex ( R " ~ ( ( ? : ( ? : , \ s * ) ? ( . + ? ) = ( ? : " ( . * ? ) " | ( [ ^ , ] * ) ) ) ) ~ " ) ; <nl> + auto s = res . get_header_value ( auth_key ) ; <nl> + auto pos = s . find ( ' ' ) ; <nl> + if ( pos ! = std : : string : : npos ) { <nl> + auto type = s . substr ( 0 , pos ) ; <nl> + if ( type = = " Basic " ) { <nl> + return false ; <nl> + } else if ( type = = " Digest " ) { <nl> + s = s . substr ( pos + 1 ) ; <nl> + auto beg = std : : sregex_iterator ( s . begin ( ) , s . end ( ) , re ) ; <nl> + for ( auto i = beg ; i ! = std : : sregex_iterator ( ) ; + + i ) { <nl> + auto m = * i ; <nl> + auto key = s . substr ( static_cast < size_t > ( m . position ( 1 ) ) , static_cast < size_t > ( m . length ( 1 ) ) ) ; <nl> + auto val = m . length ( 2 ) > 0 <nl> + ? s . substr ( static_cast < size_t > ( m . position ( 2 ) ) , static_cast < size_t > ( m . length ( 2 ) ) ) <nl> + : s . substr ( static_cast < size_t > ( m . position ( 3 ) ) , static_cast < size_t > ( m . length ( 3 ) ) ) ; <nl> + auth [ key ] = val ; <nl> + } <nl> + return true ; <nl> + } <nl> } <nl> - return true ; <nl> - } <nl> } <nl> - } <nl> - return false ; <nl> + return false ; <nl> } <nl> <nl> / / https : / / stackoverflow . com / questions / 440133 / how - do - i - create - a - random - alpha - numeric - string - in - c / 440240 # answer - 440240 <nl> inline std : : string random_string ( size_t length ) { <nl> - auto randchar = [ ] ( ) - > char { <nl> - const char charset [ ] = " 0123456789 " <nl> - " ABCDEFGHIJKLMNOPQRSTUVWXYZ " <nl> - " abcdefghijklmnopqrstuvwxyz " ; <nl> - const size_t max_index = ( sizeof ( charset ) - 1 ) ; <nl> - return charset [ static_cast < size_t > ( rand ( ) ) % max_index ] ; <nl> - } ; <nl> - std : : string str ( length , 0 ) ; <nl> - std : : generate_n ( str . begin ( ) , length , randchar ) ; <nl> - return str ; <nl> + auto randchar = [ ] ( ) - > char { <nl> + const char charset [ ] = " 0123456789 " <nl> + " ABCDEFGHIJKLMNOPQRSTUVWXYZ " <nl> + " abcdefghijklmnopqrstuvwxyz " ; <nl> + const size_t max_index = ( sizeof ( charset ) - 1 ) ; <nl> + return charset [ static_cast < size_t > ( rand ( ) ) % max_index ] ; <nl> + } ; <nl> + std : : string str ( length , 0 ) ; <nl> + std : : generate_n ( str . begin ( ) , length , randchar ) ; <nl> + return str ; <nl> } <nl> <nl> / / Request implementation <nl> inline bool Request : : has_header ( const char * key ) const { <nl> - return detail : : has_header ( headers , key ) ; <nl> + return detail : : has_header ( headers , key ) ; <nl> } <nl> <nl> inline std : : string Request : : get_header_value ( const char * key , size_t id ) const { <nl> - return detail : : get_header_value ( headers , key , id , " " ) ; <nl> + return detail : : get_header_value ( headers , key , id , " " ) ; <nl> } <nl> <nl> inline size_t Request : : get_header_value_count ( const char * key ) const { <nl> - auto r = headers . equal_range ( key ) ; <nl> - return static_cast < size_t > ( std : : distance ( r . first , r . second ) ) ; <nl> + auto r = headers . equal_range ( key ) ; <nl> + return static_cast < size_t > ( std : : distance ( r . first , r . second ) ) ; <nl> } <nl> <nl> inline void Request : : set_header ( const char * key , const char * val ) { <nl> - if ( ! detail : : has_crlf ( key ) & & ! detail : : has_crlf ( val ) ) { <nl> - headers . emplace ( key , val ) ; <nl> - } <nl> + if ( ! detail : : has_crlf ( key ) & & ! detail : : has_crlf ( val ) ) { <nl> + headers . emplace ( key , val ) ; <nl> + } <nl> } <nl> <nl> inline void Request : : set_header ( const char * key , const std : : string & val ) { <nl> - if ( ! detail : : has_crlf ( key ) & & ! detail : : has_crlf ( val . c_str ( ) ) ) { <nl> - headers . emplace ( key , val ) ; <nl> - } <nl> + if ( ! detail : : has_crlf ( key ) & & ! detail : : has_crlf ( val . c_str ( ) ) ) { <nl> + headers . emplace ( key , val ) ; <nl> + } <nl> } <nl> <nl> inline bool Request : : has_param ( const char * key ) const { <nl> - return params . find ( key ) ! = params . end ( ) ; <nl> + return params . find ( key ) ! = params . end ( ) ; <nl> } <nl> <nl> inline std : : string Request : : get_param_value ( const char * key , size_t id ) const { <nl> - auto rng = params . equal_range ( key ) ; <nl> - auto it = rng . first ; <nl> - std : : advance ( it , static_cast < ssize_t > ( id ) ) ; <nl> - if ( it ! = rng . second ) { return it - > second ; } <nl> - return std : : string ( ) ; <nl> + auto rng = params . equal_range ( key ) ; <nl> + auto it = rng . first ; <nl> + std : : advance ( it , static_cast < ssize_t > ( id ) ) ; <nl> + if ( it ! = rng . second ) { <nl> + return it - > second ; <nl> + } <nl> + return std : : string ( ) ; <nl> } <nl> <nl> inline size_t Request : : get_param_value_count ( const char * key ) const { <nl> - auto r = params . equal_range ( key ) ; <nl> - return static_cast < size_t > ( std : : distance ( r . first , r . second ) ) ; <nl> + auto r = params . equal_range ( key ) ; <nl> + return static_cast < size_t > ( std : : distance ( r . first , r . second ) ) ; <nl> } <nl> <nl> inline bool Request : : is_multipart_form_data ( ) const { <nl> - const auto & content_type = get_header_value ( " Content - Type " ) ; <nl> - return ! content_type . find ( " multipart / form - data " ) ; <nl> + const auto & content_type = get_header_value ( " Content - Type " ) ; <nl> + return ! content_type . find ( " multipart / form - data " ) ; <nl> } <nl> <nl> inline bool Request : : has_file ( const char * key ) const { <nl> - return files . find ( key ) ! = files . end ( ) ; <nl> + return files . find ( key ) ! = files . end ( ) ; <nl> } <nl> <nl> inline MultipartFormData Request : : get_file_value ( const char * key ) const { <nl> - auto it = files . find ( key ) ; <nl> - if ( it ! = files . end ( ) ) { return it - > second ; } <nl> - return MultipartFormData ( ) ; <nl> + auto it = files . find ( key ) ; <nl> + if ( it ! = files . end ( ) ) { <nl> + return it - > second ; <nl> + } <nl> + return MultipartFormData ( ) ; <nl> } <nl> <nl> / / Response implementation <nl> inline bool Response : : has_header ( const char * key ) const { <nl> - return headers . find ( key ) ! = headers . end ( ) ; <nl> + return headers . find ( key ) ! = headers . end ( ) ; <nl> } <nl> <nl> - inline std : : string Response : : get_header_value ( const char * key , <nl> - size_t id ) const { <nl> - return detail : : get_header_value ( headers , key , id , " " ) ; <nl> + inline std : : string Response : : get_header_value ( const char * key , size_t id ) const { <nl> + return detail : : get_header_value ( headers , key , id , " " ) ; <nl> } <nl> <nl> inline size_t Response : : get_header_value_count ( const char * key ) const { <nl> - auto r = headers . equal_range ( key ) ; <nl> - return static_cast < size_t > ( std : : distance ( r . first , r . second ) ) ; <nl> + auto r = headers . equal_range ( key ) ; <nl> + return static_cast < size_t > ( std : : distance ( r . first , r . second ) ) ; <nl> } <nl> <nl> inline void Response : : set_header ( const char * key , const char * val ) { <nl> - if ( ! detail : : has_crlf ( key ) & & ! detail : : has_crlf ( val ) ) { <nl> - headers . emplace ( key , val ) ; <nl> - } <nl> + if ( ! detail : : has_crlf ( key ) & & ! detail : : has_crlf ( val ) ) { <nl> + headers . emplace ( key , val ) ; <nl> + } <nl> } <nl> <nl> inline void Response : : set_header ( const char * key , const std : : string & val ) { <nl> - if ( ! detail : : has_crlf ( key ) & & ! detail : : has_crlf ( val . c_str ( ) ) ) { <nl> - headers . emplace ( key , val ) ; <nl> - } <nl> + if ( ! detail : : has_crlf ( key ) & & ! detail : : has_crlf ( val . c_str ( ) ) ) { <nl> + headers . emplace ( key , val ) ; <nl> + } <nl> } <nl> <nl> inline void Response : : set_redirect ( const char * url , int stat ) { <nl> - if ( ! detail : : has_crlf ( url ) ) { <nl> - set_header ( " Location " , url ) ; <nl> - if ( 300 < = stat & & stat < 400 ) { <nl> - this - > status = stat ; <nl> - } else { <nl> - this - > status = 302 ; <nl> + if ( ! detail : : has_crlf ( url ) ) { <nl> + set_header ( " Location " , url ) ; <nl> + if ( 300 < = stat & & stat < 400 ) { <nl> + this - > status = stat ; <nl> + } else { <nl> + this - > status = 302 ; <nl> + } <nl> } <nl> - } <nl> } <nl> <nl> - inline void Response : : set_content ( const char * s , size_t n , <nl> - const char * content_type ) { <nl> - body . assign ( s , n ) ; <nl> - set_header ( " Content - Type " , content_type ) ; <nl> + inline void Response : : set_content ( const char * s , size_t n , const char * content_type ) { <nl> + body . assign ( s , n ) ; <nl> + set_header ( " Content - Type " , content_type ) ; <nl> } <nl> <nl> inline void Response : : set_content ( std : : string s , const char * content_type ) { <nl> - body = std : : move ( s ) ; <nl> - set_header ( " Content - Type " , content_type ) ; <nl> + body = std : : move ( s ) ; <nl> + set_header ( " Content - Type " , content_type ) ; <nl> } <nl> <nl> - inline void <nl> - Response : : set_content_provider ( size_t in_length , ContentProvider provider , <nl> - std : : function < void ( ) > resource_releaser ) { <nl> - assert ( in_length > 0 ) ; <nl> - content_length_ = in_length ; <nl> - content_provider_ = [ provider ] ( size_t offset , size_t length , DataSink & sink ) { <nl> - return provider ( offset , length , sink ) ; <nl> - } ; <nl> - content_provider_resource_releaser_ = resource_releaser ; <nl> + inline void Response : : set_content_provider ( size_t in_length , <nl> + ContentProvider provider , <nl> + std : : function < void ( ) > resource_releaser ) { <nl> + assert ( in_length > 0 ) ; <nl> + content_length_ = in_length ; <nl> + content_provider_ = [ provider ] ( size_t offset , size_t length , DataSink & sink ) { <nl> + return provider ( offset , length , sink ) ; <nl> + } ; <nl> + content_provider_resource_releaser_ = resource_releaser ; <nl> } <nl> <nl> - inline void Response : : set_chunked_content_provider ( <nl> - ChunkedContentProvider provider , std : : function < void ( ) > resource_releaser ) { <nl> - content_length_ = 0 ; <nl> - content_provider_ = [ provider ] ( size_t offset , size_t , DataSink & sink ) { <nl> - return provider ( offset , sink ) ; <nl> - } ; <nl> - content_provider_resource_releaser_ = resource_releaser ; <nl> + inline void Response : : set_chunked_content_provider ( ChunkedContentProvider provider , <nl> + std : : function < void ( ) > resource_releaser ) { <nl> + content_length_ = 0 ; <nl> + content_provider_ = [ provider ] ( size_t offset , size_t , DataSink & sink ) { return provider ( offset , sink ) ; } ; <nl> + content_provider_resource_releaser_ = resource_releaser ; <nl> } <nl> <nl> / / Rstream implementation <nl> inline ssize_t Stream : : write ( const char * ptr ) { <nl> - return write ( ptr , strlen ( ptr ) ) ; <nl> + return write ( ptr , strlen ( ptr ) ) ; <nl> } <nl> <nl> inline ssize_t Stream : : write ( const std : : string & s ) { <nl> - return write ( s . data ( ) , s . size ( ) ) ; <nl> + return write ( s . data ( ) , s . size ( ) ) ; <nl> } <nl> <nl> template < typename . . . Args > <nl> inline ssize_t Stream : : write_format ( const char * fmt , const Args & . . . args ) { <nl> - std : : array < char , 2048 > buf ; <nl> + std : : array < char , 2048 > buf ; <nl> <nl> # if defined ( _MSC_VER ) & & _MSC_VER < 1900 <nl> - auto sn = _snprintf_s ( buf , bufsiz , buf . size ( ) - 1 , fmt , args . . . ) ; <nl> + auto sn = _snprintf_s ( buf , bufsiz , buf . size ( ) - 1 , fmt , args . . . ) ; <nl> # else <nl> - auto sn = snprintf ( buf . data ( ) , buf . size ( ) - 1 , fmt , args . . . ) ; <nl> + auto sn = snprintf ( buf . data ( ) , buf . size ( ) - 1 , fmt , args . . . ) ; <nl> # endif <nl> - if ( sn < = 0 ) { return sn ; } <nl> + if ( sn < = 0 ) { <nl> + return sn ; <nl> + } <nl> <nl> - auto n = static_cast < size_t > ( sn ) ; <nl> + auto n = static_cast < size_t > ( sn ) ; <nl> <nl> - if ( n > = buf . size ( ) - 1 ) { <nl> - std : : vector < char > glowable_buf ( buf . size ( ) ) ; <nl> + if ( n > = buf . size ( ) - 1 ) { <nl> + std : : vector < char > glowable_buf ( buf . size ( ) ) ; <nl> <nl> - while ( n > = glowable_buf . size ( ) - 1 ) { <nl> - glowable_buf . resize ( glowable_buf . size ( ) * 2 ) ; <nl> + while ( n > = glowable_buf . size ( ) - 1 ) { <nl> + glowable_buf . resize ( glowable_buf . size ( ) * 2 ) ; <nl> # if defined ( _MSC_VER ) & & _MSC_VER < 1900 <nl> - n = static_cast < size_t > ( _snprintf_s ( & glowable_buf [ 0 ] , glowable_buf . size ( ) , <nl> - glowable_buf . size ( ) - 1 , fmt , <nl> - args . . . ) ) ; <nl> + n = static_cast < size_t > ( <nl> + _snprintf_s ( & glowable_buf [ 0 ] , glowable_buf . size ( ) , glowable_buf . size ( ) - 1 , fmt , args . . . ) ) ; <nl> # else <nl> - n = static_cast < size_t > ( <nl> - snprintf ( & glowable_buf [ 0 ] , glowable_buf . size ( ) - 1 , fmt , args . . . ) ) ; <nl> + n = static_cast < size_t > ( snprintf ( & glowable_buf [ 0 ] , glowable_buf . size ( ) - 1 , fmt , args . . . ) ) ; <nl> # endif <nl> + } <nl> + return write ( & glowable_buf [ 0 ] , n ) ; <nl> + } else { <nl> + return write ( buf . data ( ) , n ) ; <nl> } <nl> - return write ( & glowable_buf [ 0 ] , n ) ; <nl> - } else { <nl> - return write ( buf . data ( ) , n ) ; <nl> - } <nl> } <nl> <nl> namespace detail { <nl> <nl> / / Socket stream implementation <nl> - inline SocketStream : : SocketStream ( socket_t sock , time_t read_timeout_sec , <nl> + inline SocketStream : : SocketStream ( socket_t sock , <nl> + time_t read_timeout_sec , <nl> time_t read_timeout_usec , <nl> time_t write_timeout_sec , <nl> time_t write_timeout_usec ) <nl> - : sock_ ( sock ) , read_timeout_sec_ ( read_timeout_sec ) , <nl> + : sock_ ( sock ) , <nl> + read_timeout_sec_ ( read_timeout_sec ) , <nl> read_timeout_usec_ ( read_timeout_usec ) , <nl> write_timeout_sec_ ( write_timeout_sec ) , <nl> write_timeout_usec_ ( write_timeout_usec ) { } <nl> inline SocketStream : : SocketStream ( socket_t sock , time_t read_timeout_sec , <nl> inline SocketStream : : ~ SocketStream ( ) { } <nl> <nl> inline bool SocketStream : : is_readable ( ) const { <nl> - return select_read ( sock_ , read_timeout_sec_ , read_timeout_usec_ ) > 0 ; <nl> + return select_read ( sock_ , read_timeout_sec_ , read_timeout_usec_ ) > 0 ; <nl> } <nl> <nl> inline bool SocketStream : : is_writable ( ) const { <nl> - return select_write ( sock_ , write_timeout_sec_ , write_timeout_usec_ ) > 0 ; <nl> + return select_write ( sock_ , write_timeout_sec_ , write_timeout_usec_ ) > 0 ; <nl> } <nl> <nl> inline ssize_t SocketStream : : read ( char * ptr , size_t size ) { <nl> - if ( ! is_readable ( ) ) { return - 1 ; } <nl> + if ( ! is_readable ( ) ) { <nl> + return - 1 ; <nl> + } <nl> <nl> # ifdef _WIN32 <nl> - if ( size > static_cast < size_t > ( ( std : : numeric_limits < int > : : max ) ( ) ) ) { <nl> - return - 1 ; <nl> - } <nl> - return recv ( sock_ , ptr , static_cast < int > ( size ) , 0 ) ; <nl> + if ( size > static_cast < size_t > ( ( std : : numeric_limits < int > : : max ) ( ) ) ) { <nl> + return - 1 ; <nl> + } <nl> + return recv ( sock_ , ptr , static_cast < int > ( size ) , 0 ) ; <nl> # else <nl> - return handle_EINTR ( [ & ] ( ) { return recv ( sock_ , ptr , size , 0 ) ; } ) ; <nl> + return handle_EINTR ( [ & ] ( ) { return recv ( sock_ , ptr , size , 0 ) ; } ) ; <nl> # endif <nl> } <nl> <nl> inline ssize_t SocketStream : : write ( const char * ptr , size_t size ) { <nl> - if ( ! is_writable ( ) ) { return - 1 ; } <nl> + if ( ! is_writable ( ) ) { <nl> + return - 1 ; <nl> + } <nl> <nl> # ifdef _WIN32 <nl> - if ( size > static_cast < size_t > ( ( std : : numeric_limits < int > : : max ) ( ) ) ) { <nl> - return - 1 ; <nl> - } <nl> - return send ( sock_ , ptr , static_cast < int > ( size ) , 0 ) ; <nl> + if ( size > static_cast < size_t > ( ( std : : numeric_limits < int > : : max ) ( ) ) ) { <nl> + return - 1 ; <nl> + } <nl> + return send ( sock_ , ptr , static_cast < int > ( size ) , 0 ) ; <nl> # else <nl> - return handle_EINTR ( [ & ] ( ) { return send ( sock_ , ptr , size , 0 ) ; } ) ; <nl> + return handle_EINTR ( [ & ] ( ) { return send ( sock_ , ptr , size , 0 ) ; } ) ; <nl> # endif <nl> } <nl> <nl> - inline void SocketStream : : get_remote_ip_and_port ( std : : string & ip , <nl> - int & port ) const { <nl> - return detail : : get_remote_ip_and_port ( sock_ , ip , port ) ; <nl> + inline void SocketStream : : get_remote_ip_and_port ( std : : string & ip , int & port ) const { <nl> + return detail : : get_remote_ip_and_port ( sock_ , ip , port ) ; <nl> } <nl> <nl> / / Buffer stream implementation <nl> - inline bool BufferStream : : is_readable ( ) const { return true ; } <nl> + inline bool BufferStream : : is_readable ( ) const { <nl> + return true ; <nl> + } <nl> <nl> - inline bool BufferStream : : is_writable ( ) const { return true ; } <nl> + inline bool BufferStream : : is_writable ( ) const { <nl> + return true ; <nl> + } <nl> <nl> inline ssize_t BufferStream : : read ( char * ptr , size_t size ) { <nl> # if defined ( _MSC_VER ) & & _MSC_VER < 1900 <nl> - auto len_read = buffer . _Copy_s ( ptr , size , size , position ) ; <nl> + auto len_read = buffer . _Copy_s ( ptr , size , size , position ) ; <nl> # else <nl> - auto len_read = buffer . copy ( ptr , size , position ) ; <nl> + auto len_read = buffer . copy ( ptr , size , position ) ; <nl> # endif <nl> - position + = static_cast < size_t > ( len_read ) ; <nl> - return static_cast < ssize_t > ( len_read ) ; <nl> + position + = static_cast < size_t > ( len_read ) ; <nl> + return static_cast < ssize_t > ( len_read ) ; <nl> } <nl> <nl> inline ssize_t BufferStream : : write ( const char * ptr , size_t size ) { <nl> - buffer . append ( ptr , size ) ; <nl> - return static_cast < ssize_t > ( size ) ; <nl> - } <nl> - <nl> - inline void BufferStream : : get_remote_ip_and_port ( std : : string & / * ip * / , <nl> - int & / * port * / ) const { } <nl> - <nl> - inline const std : : string & BufferStream : : get_buffer ( ) const { return buffer ; } <nl> - <nl> - } / / namespace detail <nl> - <nl> - / / HTTP client implementation <nl> - inline Client : : Client ( const std : : string & host ) <nl> - : Client ( host , 80 , std : : string ( ) , std : : string ( ) ) { } <nl> - <nl> - inline Client : : Client ( const std : : string & host , int port ) <nl> - : Client ( host , port , std : : string ( ) , std : : string ( ) ) { } <nl> - <nl> - inline Client : : Client ( const std : : string & host , int port , <nl> - const std : : string & client_cert_path , <nl> - const std : : string & client_key_path ) <nl> - : host_ ( host ) , port_ ( port ) , <nl> - host_and_port_ ( host_ + " : " + std : : to_string ( port_ ) ) , <nl> - client_cert_path_ ( client_cert_path ) , client_key_path_ ( client_key_path ) { } <nl> - <nl> - inline Client : : ~ Client ( ) { stop ( ) ; } <nl> - <nl> - inline bool Client : : is_valid ( ) const { return true ; } <nl> - <nl> - inline socket_t Client : : create_client_socket ( ) const { <nl> - if ( ! proxy_host_ . empty ( ) ) { <nl> - return detail : : create_client_socket ( <nl> - proxy_host_ . c_str ( ) , proxy_port_ , tcp_nodelay_ , socket_options_ , <nl> - connection_timeout_sec_ , connection_timeout_usec_ , interface_ ) ; <nl> - } <nl> - return detail : : create_client_socket ( host_ . c_str ( ) , port_ , tcp_nodelay_ , <nl> - socket_options_ , connection_timeout_sec_ , <nl> - connection_timeout_usec_ , interface_ ) ; <nl> - } <nl> - <nl> - inline bool Client : : create_and_connect_socket ( Socket & socket ) { <nl> - auto sock = create_client_socket ( ) ; <nl> - if ( sock = = INVALID_SOCKET ) { return false ; } <nl> - socket . sock = sock ; <nl> - return true ; <nl> - } <nl> - <nl> - inline void Client : : close_socket ( Socket & socket , bool / * process_socket_ret * / ) { <nl> - detail : : close_socket ( socket . sock ) ; <nl> - socket_ . sock = INVALID_SOCKET ; <nl> - # ifdef CPPHTTPLIB_OPENSSL_SUPPORT <nl> - socket_ . ssl = nullptr ; <nl> - # endif <nl> - } <nl> - <nl> - inline bool Client : : read_response_line ( Stream & strm , Response & res ) { <nl> - std : : array < char , 2048 > buf ; <nl> - <nl> - detail : : stream_line_reader line_reader ( strm , buf . data ( ) , buf . size ( ) ) ; <nl> - <nl> - if ( ! line_reader . getline ( ) ) { return false ; } <nl> - <nl> - const static std : : regex re ( " ( HTTP / 1 \ \ . [ 01 ] ) ( \ \ d + ? ) . * \ r \ n " ) ; <nl> - <nl> - std : : cmatch m ; <nl> - if ( std : : regex_match ( line_reader . ptr ( ) , m , re ) ) { <nl> - res . version = std : : string ( m [ 1 ] ) ; <nl> - res . status = std : : stoi ( std : : string ( m [ 2 ] ) ) ; <nl> - } <nl> - <nl> - return true ; <nl> - } <nl> - <nl> - inline bool Client : : send ( const Request & req , Response & res ) { <nl> - std : : lock_guard < std : : recursive_mutex > request_mutex_guard ( request_mutex_ ) ; <nl> - <nl> - { <nl> - std : : lock_guard < std : : mutex > guard ( socket_mutex_ ) ; <nl> - <nl> - auto is_alive = false ; <nl> - if ( socket_ . is_open ( ) ) { <nl> - is_alive = detail : : select_write ( socket_ . sock , 0 , 0 ) > 0 ; <nl> - if ( ! is_alive ) { close_socket ( socket_ , false ) ; } <nl> - } <nl> - <nl> - if ( ! is_alive ) { <nl> - if ( ! create_and_connect_socket ( socket_ ) ) { return false ; } <nl> - <nl> - # ifdef CPPHTTPLIB_OPENSSL_SUPPORT <nl> - / / TODO : refactoring <nl> - if ( is_ssl ( ) ) { <nl> - auto & scli = static_cast < SSLClient & > ( * this ) ; <nl> - if ( ! proxy_host_ . empty ( ) ) { <nl> - bool success = false ; <nl> - if ( ! scli . connect_with_proxy ( socket_ , res , success ) ) { <nl> - return success ; <nl> - } <nl> - } <nl> - <nl> - if ( ! scli . initialize_ssl ( socket_ ) ) { return false ; } <nl> - } <nl> - # endif <nl> - } <nl> - } <nl> - <nl> - auto close_connection = ! keep_alive_ ; <nl> - <nl> - auto ret = process_socket ( socket_ , [ & ] ( Stream & strm ) { <nl> - return handle_request ( strm , req , res , close_connection ) ; <nl> - } ) ; <nl> - <nl> - if ( close_connection ) { stop ( ) ; } <nl> - <nl> - return ret ; <nl> - } <nl> - <nl> - inline bool Client : : handle_request ( Stream & strm , const Request & req , <nl> - Response & res , bool close_connection ) { <nl> - if ( req . path . empty ( ) ) { return false ; } <nl> - <nl> - bool ret ; <nl> - <nl> - if ( ! is_ssl ( ) & & ! proxy_host_ . empty ( ) ) { <nl> - auto req2 = req ; <nl> - req2 . path = " http : / / " + host_and_port_ + req . path ; <nl> - ret = process_request ( strm , req2 , res , close_connection ) ; <nl> - } else { <nl> - ret = process_request ( strm , req , res , close_connection ) ; <nl> - } <nl> - <nl> - if ( ! ret ) { return false ; } <nl> - <nl> - if ( 300 < res . status & & res . status < 400 & & follow_location_ ) { <nl> - ret = redirect ( req , res ) ; <nl> - } <nl> - <nl> - # ifdef CPPHTTPLIB_OPENSSL_SUPPORT <nl> - if ( ( res . status = = 401 | | res . status = = 407 ) & & <nl> - req . authorization_count_ < 5 ) { <nl> - auto is_proxy = res . status = = 407 ; <nl> - const auto & username = <nl> - is_proxy ? proxy_digest_auth_username_ : digest_auth_username_ ; <nl> - const auto & password = <nl> - is_proxy ? proxy_digest_auth_password_ : digest_auth_password_ ; <nl> - <nl> - if ( ! username . empty ( ) & & ! password . empty ( ) ) { <nl> - std : : map < std : : string , std : : string > auth ; <nl> - if ( parse_www_authenticate ( res , auth , is_proxy ) ) { <nl> - Request new_req = req ; <nl> - new_req . authorization_count_ + = 1 ; <nl> - auto key = is_proxy ? " Proxy - Authorization " : " Authorization " ; <nl> - new_req . headers . erase ( key ) ; <nl> - new_req . headers . insert ( make_digest_authentication_header ( <nl> - req , auth , new_req . authorization_count_ , random_string ( 10 ) , <nl> - username , password , is_proxy ) ) ; <nl> - <nl> - Response new_res ; <nl> - <nl> - ret = send ( new_req , new_res ) ; <nl> - if ( ret ) { res = new_res ; } <nl> - } <nl> - } <nl> - } <nl> - # endif <nl> - <nl> - return ret ; <nl> + buffer . append ( ptr , size ) ; <nl> + return static_cast < ssize_t > ( size ) ; <nl> } <nl> <nl> - inline bool Client : : redirect ( const Request & req , Response & res ) { <nl> - if ( req . redirect_count = = 0 ) { return false ; } <nl> - <nl> - auto location = res . get_header_value ( " location " ) ; <nl> - if ( location . empty ( ) ) { return false ; } <nl> - <nl> - const static std : : regex re ( <nl> - R " ( ^ ( ? : ( https ? ) : ) ? ( ? : / / ( [ ^ : / ? # ] * ) ( ? : : ( \ d + ) ) ? ) ? ( [ ^ ? # ] * ( ? : \ ? [ ^ # ] * ) ? ) ( ? : # . * ) ? ) " ) ; <nl> - <nl> - std : : smatch m ; <nl> - if ( ! std : : regex_match ( location , m , re ) ) { return false ; } <nl> - <nl> - auto scheme = is_ssl ( ) ? " https " : " http " ; <nl> - <nl> - auto next_scheme = m [ 1 ] . str ( ) ; <nl> - auto next_host = m [ 2 ] . str ( ) ; <nl> - auto port_str = m [ 3 ] . str ( ) ; <nl> - auto next_path = m [ 4 ] . str ( ) ; <nl> + inline void BufferStream : : get_remote_ip_and_port ( std : : string & / * ip * / , int & / * port * / ) const { } <nl> <nl> - auto next_port = port_ ; <nl> - if ( ! port_str . empty ( ) ) { <nl> - next_port = std : : stoi ( port_str ) ; <nl> - } else if ( ! next_scheme . empty ( ) ) { <nl> - next_port = next_scheme = = " https " ? 443 : 80 ; <nl> - } <nl> - <nl> - if ( next_scheme . empty ( ) ) { next_scheme = scheme ; } <nl> - if ( next_host . empty ( ) ) { next_host = host_ ; } <nl> - if ( next_path . empty ( ) ) { next_path = " / " ; } <nl> - <nl> - if ( next_scheme = = scheme & & next_host = = host_ & & next_port = = port_ ) { <nl> - return detail : : redirect ( * this , req , res , next_path ) ; <nl> - } else { <nl> - if ( next_scheme = = " https " ) { <nl> - # ifdef CPPHTTPLIB_OPENSSL_SUPPORT <nl> - SSLClient cli ( next_host . c_str ( ) , next_port ) ; <nl> - cli . copy_settings ( * this ) ; <nl> - return detail : : redirect ( cli , req , res , next_path ) ; <nl> - # else <nl> - return false ; <nl> - # endif <nl> - } else { <nl> - Client cli ( next_host . c_str ( ) , next_port ) ; <nl> - cli . copy_settings ( * this ) ; <nl> - return detail : : redirect ( cli , req , res , next_path ) ; <nl> - } <nl> - } <nl> + inline const std : : string & BufferStream : : get_buffer ( ) const { <nl> + return buffer ; <nl> } <nl> <nl> - inline bool Client : : write_request ( Stream & strm , const Request & req , <nl> - bool close_connection ) { <nl> - detail : : BufferStream bstrm ; <nl> - <nl> - / / Request line <nl> - const auto & path = detail : : encode_url ( req . path ) ; <nl> - <nl> - bstrm . write_format ( " % s % s HTTP / 1 . 1 \ r \ n " , req . method . c_str ( ) , path . c_str ( ) ) ; <nl> - <nl> - / / Additonal headers <nl> - Headers headers ; <nl> - if ( close_connection ) { headers . emplace ( " Connection " , " close " ) ; } <nl> - <nl> - if ( ! req . has_header ( " Host " ) ) { <nl> - if ( is_ssl ( ) ) { <nl> - if ( port_ = = 443 ) { <nl> - headers . emplace ( " Host " , host_ ) ; <nl> - } else { <nl> - headers . emplace ( " Host " , host_and_port_ ) ; <nl> - } <nl> - } else { <nl> - if ( port_ = = 80 ) { <nl> - headers . emplace ( " Host " , host_ ) ; <nl> - } else { <nl> - headers . emplace ( " Host " , host_and_port_ ) ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - if ( ! req . has_header ( " Accept " ) ) { headers . emplace ( " Accept " , " * / * " ) ; } <nl> - <nl> - if ( ! req . has_header ( " User - Agent " ) ) { <nl> - headers . emplace ( " User - Agent " , USER_AGENT ) ; <nl> - } <nl> - <nl> - if ( req . body . empty ( ) ) { <nl> - if ( req . content_provider ) { <nl> - auto length = std : : to_string ( req . content_length ) ; <nl> - headers . emplace ( " Content - Length " , length ) ; <nl> - } else { <nl> - headers . emplace ( " Content - Length " , " 0 " ) ; <nl> - } <nl> - } else { <nl> - if ( ! req . has_header ( " Content - Type " ) ) { <nl> - headers . emplace ( " Content - Type " , " text / plain " ) ; <nl> - } <nl> - <nl> - if ( ! req . has_header ( " Content - Length " ) ) { <nl> - auto length = std : : to_string ( req . body . size ( ) ) ; <nl> - headers . emplace ( " Content - Length " , length ) ; <nl> - } <nl> - } <nl> - <nl> - if ( ! basic_auth_username_ . empty ( ) & & ! basic_auth_password_ . empty ( ) ) { <nl> - headers . insert ( make_basic_authentication_header ( <nl> - basic_auth_username_ , basic_auth_password_ , false ) ) ; <nl> - } <nl> - <nl> - if ( ! proxy_basic_auth_username_ . empty ( ) & & <nl> - ! proxy_basic_auth_password_ . empty ( ) ) { <nl> - headers . insert ( make_basic_authentication_header ( <nl> - proxy_basic_auth_username_ , proxy_basic_auth_password_ , true ) ) ; <nl> - } <nl> - <nl> - detail : : write_headers ( bstrm , req , headers ) ; <nl> - <nl> - / / Flush buffer <nl> - auto & data = bstrm . get_buffer ( ) ; <nl> - if ( ! detail : : write_data ( strm , data . data ( ) , data . size ( ) ) ) { return false ; } <nl> - <nl> - / / Body <nl> - if ( req . body . empty ( ) ) { <nl> - if ( req . content_provider ) { <nl> - size_t offset = 0 ; <nl> - size_t end_offset = req . content_length ; <nl> - <nl> - bool ok = true ; <nl> - <nl> - DataSink data_sink ; <nl> - data_sink . write = [ & ] ( const char * d , size_t l ) { <nl> - if ( ok ) { <nl> - if ( detail : : write_data ( strm , d , l ) ) { <nl> - offset + = l ; <nl> - } else { <nl> - ok = false ; <nl> - } <nl> - } <nl> - } ; <nl> - data_sink . is_writable = [ & ] ( void ) { return ok & & strm . is_writable ( ) ; } ; <nl> - <nl> - while ( offset < end_offset ) { <nl> - if ( ! req . content_provider ( offset , end_offset - offset , data_sink ) ) { <nl> - return false ; <nl> - } <nl> - if ( ! ok ) { return false ; } <nl> - } <nl> - } <nl> - } else { <nl> - return detail : : write_data ( strm , req . body . data ( ) , req . body . size ( ) ) ; <nl> - } <nl> - <nl> - return true ; <nl> - } <nl> - <nl> - inline std : : shared_ptr < Response > Client : : send_with_content_provider ( <nl> - const char * method , const char * path , const Headers & headers , <nl> - const std : : string & body , size_t content_length , <nl> - ContentProvider content_provider , const char * content_type ) { <nl> - Request req ; <nl> - req . method = method ; <nl> - req . headers = headers ; <nl> - req . path = path ; <nl> - <nl> - if ( content_type ) { req . headers . emplace ( " Content - Type " , content_type ) ; } <nl> - <nl> - # ifdef CPPHTTPLIB_ZLIB_SUPPORT <nl> - if ( compress_ ) { <nl> - if ( content_provider ) { <nl> - size_t offset = 0 ; <nl> - <nl> - DataSink data_sink ; <nl> - data_sink . write = [ & ] ( const char * data , size_t data_len ) { <nl> - req . body . append ( data , data_len ) ; <nl> - offset + = data_len ; <nl> - } ; <nl> - data_sink . is_writable = [ & ] ( void ) { return true ; } ; <nl> - <nl> - while ( offset < content_length ) { <nl> - if ( ! content_provider ( offset , content_length - offset , data_sink ) ) { <nl> - return nullptr ; <nl> - } <nl> - } <nl> - } else { <nl> - req . body = body ; <nl> - } <nl> - <nl> - if ( ! detail : : compress ( req . body ) ) { return nullptr ; } <nl> - req . headers . emplace ( " Content - Encoding " , " gzip " ) ; <nl> - } else <nl> - # endif <nl> - { <nl> - if ( content_provider ) { <nl> - req . content_length = content_length ; <nl> - req . content_provider = content_provider ; <nl> - } else { <nl> - req . body = body ; <nl> - } <nl> - } <nl> - <nl> - auto res = std : : make_shared < Response > ( ) ; <nl> - <nl> - return send ( req , * res ) ? res : nullptr ; <nl> - } <nl> - <nl> - inline bool Client : : process_request ( Stream & strm , const Request & req , <nl> - Response & res , bool close_connection ) { <nl> - / / Send request <nl> - if ( ! write_request ( strm , req , close_connection ) ) { return false ; } <nl> - <nl> - / / Receive response and headers <nl> - if ( ! read_response_line ( strm , res ) | | <nl> - ! detail : : read_headers ( strm , res . headers ) ) { <nl> - return false ; <nl> - } <nl> - <nl> - if ( req . response_handler ) { <nl> - if ( ! req . response_handler ( res ) ) { return false ; } <nl> - } <nl> - <nl> - / / Body <nl> - if ( req . method ! = " HEAD " & & req . method ! = " CONNECT " ) { <nl> - auto out = <nl> - req . content_receiver <nl> - ? static_cast < ContentReceiver > ( [ & ] ( const char * buf , size_t n ) { <nl> - return req . content_receiver ( buf , n ) ; <nl> - } ) <nl> - : static_cast < ContentReceiver > ( [ & ] ( const char * buf , size_t n ) { <nl> - if ( res . body . size ( ) + n > res . body . max_size ( ) ) { return false ; } <nl> - res . body . append ( buf , n ) ; <nl> - return true ; <nl> - } ) ; <nl> - <nl> - int dummy_status ; <nl> - if ( ! detail : : read_content ( strm , res , ( std : : numeric_limits < size_t > : : max ) ( ) , <nl> - dummy_status , req . progress , out , decompress_ ) ) { <nl> - return false ; <nl> - } <nl> - } <nl> - <nl> - if ( res . get_header_value ( " Connection " ) = = " close " | | <nl> - res . version = = " HTTP / 1 . 0 " ) { <nl> - stop ( ) ; <nl> - } <nl> - <nl> - / / Log <nl> - if ( logger_ ) { logger_ ( req , res ) ; } <nl> - <nl> - return true ; <nl> - } <nl> - <nl> - inline bool Client : : process_socket ( Socket & socket , <nl> - std : : function < bool ( Stream & strm ) > callback ) { <nl> - return detail : : process_client_socket ( socket . sock , read_timeout_sec_ , <nl> - read_timeout_usec_ , write_timeout_sec_ , <nl> - write_timeout_usec_ , callback ) ; <nl> - } <nl> - <nl> - inline bool Client : : is_ssl ( ) const { return false ; } <nl> - <nl> - inline std : : shared_ptr < Response > Client : : Get ( const char * path ) { <nl> - return Get ( path , Headers ( ) , Progress ( ) ) ; <nl> - } <nl> - <nl> - inline std : : shared_ptr < Response > Client : : Get ( const char * path , <nl> - Progress progress ) { <nl> - return Get ( path , Headers ( ) , std : : move ( progress ) ) ; <nl> - } <nl> - <nl> - inline std : : shared_ptr < Response > Client : : Get ( const char * path , <nl> - const Headers & headers ) { <nl> - return Get ( path , headers , Progress ( ) ) ; <nl> - } <nl> - <nl> - inline std : : shared_ptr < Response > <nl> - Client : : Get ( const char * path , const Headers & headers , Progress progress ) { <nl> - Request req ; <nl> - req . method = " GET " ; <nl> - req . path = path ; <nl> - req . headers = headers ; <nl> - req . progress = std : : move ( progress ) ; <nl> - <nl> - auto res = std : : make_shared < Response > ( ) ; <nl> - return send ( req , * res ) ? res : nullptr ; <nl> - } <nl> - <nl> - inline std : : shared_ptr < Response > Client : : Get ( const char * path , <nl> - ContentReceiver content_receiver ) { <nl> - return Get ( path , Headers ( ) , nullptr , std : : move ( content_receiver ) , Progress ( ) ) ; <nl> - } <nl> - <nl> - inline std : : shared_ptr < Response > Client : : Get ( const char * path , <nl> - ContentReceiver content_receiver , <nl> - Progress progress ) { <nl> - return Get ( path , Headers ( ) , nullptr , std : : move ( content_receiver ) , <nl> - std : : move ( progress ) ) ; <nl> - } <nl> - <nl> - inline std : : shared_ptr < Response > Client : : Get ( const char * path , <nl> - const Headers & headers , <nl> - ContentReceiver content_receiver ) { <nl> - return Get ( path , headers , nullptr , std : : move ( content_receiver ) , Progress ( ) ) ; <nl> - } <nl> - <nl> - inline std : : shared_ptr < Response > Client : : Get ( const char * path , <nl> - const Headers & headers , <nl> - ContentReceiver content_receiver , <nl> - Progress progress ) { <nl> - return Get ( path , headers , nullptr , std : : move ( content_receiver ) , <nl> - std : : move ( progress ) ) ; <nl> - } <nl> - <nl> - inline std : : shared_ptr < Response > Client : : Get ( const char * path , <nl> - const Headers & headers , <nl> - ResponseHandler response_handler , <nl> - ContentReceiver content_receiver ) { <nl> - return Get ( path , headers , std : : move ( response_handler ) , content_receiver , <nl> - Progress ( ) ) ; <nl> - } <nl> - <nl> - inline std : : shared_ptr < Response > Client : : Get ( const char * path , <nl> - const Headers & headers , <nl> - ResponseHandler response_handler , <nl> - ContentReceiver content_receiver , <nl> - Progress progress ) { <nl> - Request req ; <nl> - req . method = " GET " ; <nl> - req . path = path ; <nl> - req . headers = headers ; <nl> - req . response_handler = std : : move ( response_handler ) ; <nl> - req . content_receiver = std : : move ( content_receiver ) ; <nl> - req . progress = std : : move ( progress ) ; <nl> - <nl> - auto res = std : : make_shared < Response > ( ) ; <nl> - return send ( req , * res ) ? res : nullptr ; <nl> - } <nl> - <nl> - inline std : : shared_ptr < Response > Client : : Head ( const char * path ) { <nl> - return Head ( path , Headers ( ) ) ; <nl> - } <nl> - <nl> - inline std : : shared_ptr < Response > Client : : Head ( const char * path , <nl> - const Headers & headers ) { <nl> - Request req ; <nl> - req . method = " HEAD " ; <nl> - req . headers = headers ; <nl> - req . path = path ; <nl> - <nl> - auto res = std : : make_shared < Response > ( ) ; <nl> - <nl> - return send ( req , * res ) ? res : nullptr ; <nl> - } <nl> - <nl> - inline std : : shared_ptr < Response > Client : : Post ( const char * path ) { <nl> - return Post ( path , std : : string ( ) , nullptr ) ; <nl> - } <nl> - <nl> - inline std : : shared_ptr < Response > Client : : Post ( const char * path , <nl> - const std : : string & body , <nl> - const char * content_type ) { <nl> - return Post ( path , Headers ( ) , body , content_type ) ; <nl> - } <nl> - <nl> - inline std : : shared_ptr < Response > Client : : Post ( const char * path , <nl> - const Headers & headers , <nl> - const std : : string & body , <nl> - const char * content_type ) { <nl> - return send_with_content_provider ( " POST " , path , headers , body , 0 , nullptr , <nl> - content_type ) ; <nl> - } <nl> - <nl> - inline std : : shared_ptr < Response > Client : : Post ( const char * path , <nl> - const Params & params ) { <nl> - return Post ( path , Headers ( ) , params ) ; <nl> - } <nl> - <nl> - inline std : : shared_ptr < Response > Client : : Post ( const char * path , <nl> - size_t content_length , <nl> - ContentProvider content_provider , <nl> - const char * content_type ) { <nl> - return Post ( path , Headers ( ) , content_length , content_provider , content_type ) ; <nl> - } <nl> - <nl> - inline std : : shared_ptr < Response > <nl> - Client : : Post ( const char * path , const Headers & headers , size_t content_length , <nl> - ContentProvider content_provider , const char * content_type ) { <nl> - return send_with_content_provider ( " POST " , path , headers , std : : string ( ) , <nl> - content_length , content_provider , <nl> - content_type ) ; <nl> - } <nl> - <nl> - inline std : : shared_ptr < Response > <nl> - Client : : Post ( const char * path , const Headers & headers , const Params & params ) { <nl> - auto query = detail : : params_to_query_str ( params ) ; <nl> - return Post ( path , headers , query , " application / x - www - form - urlencoded " ) ; <nl> - } <nl> - <nl> - inline std : : shared_ptr < Response > <nl> - Client : : Post ( const char * path , const MultipartFormDataItems & items ) { <nl> - return Post ( path , Headers ( ) , items ) ; <nl> - } <nl> - <nl> - inline std : : shared_ptr < Response > <nl> - Client : : Post ( const char * path , const Headers & headers , <nl> - const MultipartFormDataItems & items ) { <nl> - auto boundary = detail : : make_multipart_data_boundary ( ) ; <nl> - <nl> - std : : string body ; <nl> - <nl> - for ( const auto & item : items ) { <nl> - body + = " - - " + boundary + " \ r \ n " ; <nl> - body + = " Content - Disposition : form - data ; name = \ " " + item . name + " \ " " ; <nl> - if ( ! item . filename . empty ( ) ) { <nl> - body + = " ; filename = \ " " + item . filename + " \ " " ; <nl> - } <nl> - body + = " \ r \ n " ; <nl> - if ( ! item . content_type . empty ( ) ) { <nl> - body + = " Content - Type : " + item . content_type + " \ r \ n " ; <nl> - } <nl> - body + = " \ r \ n " ; <nl> - body + = item . content + " \ r \ n " ; <nl> - } <nl> - <nl> - body + = " - - " + boundary + " - - \ r \ n " ; <nl> - <nl> - std : : string content_type = " multipart / form - data ; boundary = " + boundary ; <nl> - return Post ( path , headers , body , content_type . c_str ( ) ) ; <nl> - } <nl> - <nl> - inline std : : shared_ptr < Response > Client : : Put ( const char * path ) { <nl> - return Put ( path , std : : string ( ) , nullptr ) ; <nl> - } <nl> - <nl> - inline std : : shared_ptr < Response > Client : : Put ( const char * path , <nl> - const std : : string & body , <nl> - const char * content_type ) { <nl> - return Put ( path , Headers ( ) , body , content_type ) ; <nl> - } <nl> - <nl> - inline std : : shared_ptr < Response > Client : : Put ( const char * path , <nl> - const Headers & headers , <nl> - const std : : string & body , <nl> - const char * content_type ) { <nl> - return send_with_content_provider ( " PUT " , path , headers , body , 0 , nullptr , <nl> - content_type ) ; <nl> - } <nl> - <nl> - inline std : : shared_ptr < Response > Client : : Put ( const char * path , <nl> - size_t content_length , <nl> - ContentProvider content_provider , <nl> - const char * content_type ) { <nl> - return Put ( path , Headers ( ) , content_length , content_provider , content_type ) ; <nl> - } <nl> - <nl> - inline std : : shared_ptr < Response > <nl> - Client : : Put ( const char * path , const Headers & headers , size_t content_length , <nl> - ContentProvider content_provider , const char * content_type ) { <nl> - return send_with_content_provider ( " PUT " , path , headers , std : : string ( ) , <nl> - content_length , content_provider , <nl> - content_type ) ; <nl> - } <nl> - <nl> - inline std : : shared_ptr < Response > Client : : Put ( const char * path , <nl> - const Params & params ) { <nl> - return Put ( path , Headers ( ) , params ) ; <nl> - } <nl> - <nl> - inline std : : shared_ptr < Response > <nl> - Client : : Put ( const char * path , const Headers & headers , const Params & params ) { <nl> - auto query = detail : : params_to_query_str ( params ) ; <nl> - return Put ( path , headers , query , " application / x - www - form - urlencoded " ) ; <nl> - } <nl> - <nl> - inline std : : shared_ptr < Response > Client : : Patch ( const char * path , <nl> - const std : : string & body , <nl> - const char * content_type ) { <nl> - return Patch ( path , Headers ( ) , body , content_type ) ; <nl> - } <nl> - <nl> - inline std : : shared_ptr < Response > Client : : Patch ( const char * path , <nl> - const Headers & headers , <nl> - const std : : string & body , <nl> - const char * content_type ) { <nl> - return send_with_content_provider ( " PATCH " , path , headers , body , 0 , nullptr , <nl> - content_type ) ; <nl> - } <nl> - <nl> - inline std : : shared_ptr < Response > Client : : Patch ( const char * path , <nl> - size_t content_length , <nl> - ContentProvider content_provider , <nl> - const char * content_type ) { <nl> - return Patch ( path , Headers ( ) , content_length , content_provider , content_type ) ; <nl> - } <nl> - <nl> - inline std : : shared_ptr < Response > <nl> - Client : : Patch ( const char * path , const Headers & headers , size_t content_length , <nl> - ContentProvider content_provider , const char * content_type ) { <nl> - return send_with_content_provider ( " PATCH " , path , headers , std : : string ( ) , <nl> - content_length , content_provider , <nl> - content_type ) ; <nl> - } <nl> - <nl> - inline std : : shared_ptr < Response > Client : : Delete ( const char * path ) { <nl> - return Delete ( path , Headers ( ) , std : : string ( ) , nullptr ) ; <nl> - } <nl> - <nl> - inline std : : shared_ptr < Response > Client : : Delete ( const char * path , <nl> - const std : : string & body , <nl> - const char * content_type ) { <nl> - return Delete ( path , Headers ( ) , body , content_type ) ; <nl> - } <nl> - <nl> - inline std : : shared_ptr < Response > Client : : Delete ( const char * path , <nl> - const Headers & headers ) { <nl> - return Delete ( path , headers , std : : string ( ) , nullptr ) ; <nl> - } <nl> - <nl> - inline std : : shared_ptr < Response > Client : : Delete ( const char * path , <nl> - const Headers & headers , <nl> - const std : : string & body , <nl> - const char * content_type ) { <nl> - Request req ; <nl> - req . method = " DELETE " ; <nl> - req . headers = headers ; <nl> - req . path = path ; <nl> - <nl> - if ( content_type ) { req . headers . emplace ( " Content - Type " , content_type ) ; } <nl> - req . body = body ; <nl> - <nl> - auto res = std : : make_shared < Response > ( ) ; <nl> - <nl> - return send ( req , * res ) ? res : nullptr ; <nl> - } <nl> - <nl> - inline std : : shared_ptr < Response > Client : : Options ( const char * path ) { <nl> - return Options ( path , Headers ( ) ) ; <nl> - } <nl> - <nl> - inline std : : shared_ptr < Response > Client : : Options ( const char * path , <nl> - const Headers & headers ) { <nl> - Request req ; <nl> - req . method = " OPTIONS " ; <nl> - req . path = path ; <nl> - req . headers = headers ; <nl> - <nl> - auto res = std : : make_shared < Response > ( ) ; <nl> - <nl> - return send ( req , * res ) ? res : nullptr ; <nl> - } <nl> - <nl> - inline size_t Client : : is_socket_open ( ) const { <nl> - std : : lock_guard < std : : mutex > guard ( socket_mutex_ ) ; <nl> - return socket_ . is_open ( ) ; <nl> - } <nl> - <nl> - inline void Client : : stop ( ) { <nl> - std : : lock_guard < std : : mutex > guard ( socket_mutex_ ) ; <nl> - if ( socket_ . is_open ( ) ) { <nl> - detail : : shutdown_socket ( socket_ . sock ) ; <nl> - std : : this_thread : : sleep_for ( std : : chrono : : milliseconds ( 1 ) ) ; <nl> - close_socket ( socket_ , true ) ; <nl> - std : : this_thread : : sleep_for ( std : : chrono : : milliseconds ( 1 ) ) ; <nl> - } <nl> - } <nl> - <nl> - inline void Client : : set_timeout_sec ( time_t timeout_sec ) { <nl> - set_connection_timeout ( timeout_sec , 0 ) ; <nl> - } <nl> - <nl> - inline void Client : : set_connection_timeout ( time_t sec , time_t usec ) { <nl> - connection_timeout_sec_ = sec ; <nl> - connection_timeout_usec_ = usec ; <nl> - } <nl> - <nl> - inline void Client : : set_read_timeout ( time_t sec , time_t usec ) { <nl> - read_timeout_sec_ = sec ; <nl> - read_timeout_usec_ = usec ; <nl> - } <nl> - <nl> - inline void Client : : set_write_timeout ( time_t sec , time_t usec ) { <nl> - write_timeout_sec_ = sec ; <nl> - write_timeout_usec_ = usec ; <nl> - } <nl> - <nl> - inline void Client : : set_basic_auth ( const char * username , const char * password ) { <nl> - basic_auth_username_ = username ; <nl> - basic_auth_password_ = password ; <nl> - } <nl> - <nl> - # ifdef CPPHTTPLIB_OPENSSL_SUPPORT <nl> - inline void Client : : set_digest_auth ( const char * username , <nl> - const char * password ) { <nl> - digest_auth_username_ = username ; <nl> - digest_auth_password_ = password ; <nl> - } <nl> - # endif <nl> - <nl> - inline void Client : : set_keep_alive ( bool on ) { keep_alive_ = on ; } <nl> - <nl> - inline void Client : : set_follow_location ( bool on ) { follow_location_ = on ; } <nl> - <nl> - inline void Client : : set_tcp_nodelay ( bool on ) { tcp_nodelay_ = on ; } <nl> - <nl> - inline void Client : : set_socket_options ( SocketOptions socket_options ) { <nl> - socket_options_ = socket_options ; <nl> - } <nl> - <nl> - inline void Client : : set_compress ( bool on ) { compress_ = on ; } <nl> - <nl> - inline void Client : : set_decompress ( bool on ) { decompress_ = on ; } <nl> - <nl> - inline void Client : : set_interface ( const char * intf ) { interface_ = intf ; } <nl> - <nl> - inline void Client : : set_proxy ( const char * host , int port ) { <nl> - proxy_host_ = host ; <nl> - proxy_port_ = port ; <nl> - } <nl> - <nl> - inline void Client : : set_proxy_basic_auth ( const char * username , <nl> - const char * password ) { <nl> - proxy_basic_auth_username_ = username ; <nl> - proxy_basic_auth_password_ = password ; <nl> - } <nl> - <nl> - # ifdef CPPHTTPLIB_OPENSSL_SUPPORT <nl> - inline void Client : : set_proxy_digest_auth ( const char * username , <nl> - const char * password ) { <nl> - proxy_digest_auth_username_ = username ; <nl> - proxy_digest_auth_password_ = password ; <nl> - } <nl> - # endif <nl> - <nl> - inline void Client : : set_logger ( Logger logger ) { logger_ = std : : move ( logger ) ; } <nl> + } / / namespace detail <nl> <nl> / * <nl> * SSL Implementation <nl> inline void Client : : set_logger ( Logger logger ) { logger_ = std : : move ( logger ) ; } <nl> namespace detail { <nl> <nl> template < typename U , typename V > <nl> - inline SSL * ssl_new ( socket_t sock , SSL_CTX * ctx , std : : mutex & ctx_mutex , <nl> - U SSL_connect_or_accept , V setup ) { <nl> - SSL * ssl = nullptr ; <nl> - { <nl> - std : : lock_guard < std : : mutex > guard ( ctx_mutex ) ; <nl> - ssl = SSL_new ( ctx ) ; <nl> - } <nl> + inline SSL * ssl_new ( socket_t sock , SSL_CTX * ctx , std : : mutex & ctx_mutex , U SSL_connect_or_accept , V setup ) { <nl> + SSL * ssl = nullptr ; <nl> + { <nl> + std : : lock_guard < std : : mutex > guard ( ctx_mutex ) ; <nl> + ssl = SSL_new ( ctx ) ; <nl> + } <nl> <nl> - if ( ssl ) { <nl> - auto bio = BIO_new_socket ( static_cast < int > ( sock ) , BIO_NOCLOSE ) ; <nl> - SSL_set_bio ( ssl , bio , bio ) ; <nl> + if ( ssl ) { <nl> + auto bio = BIO_new_socket ( static_cast < int > ( sock ) , BIO_NOCLOSE ) ; <nl> + SSL_set_bio ( ssl , bio , bio ) ; <nl> <nl> - if ( ! setup ( ssl ) | | SSL_connect_or_accept ( ssl ) ! = 1 ) { <nl> - SSL_shutdown ( ssl ) ; <nl> - { <nl> - std : : lock_guard < std : : mutex > guard ( ctx_mutex ) ; <nl> - SSL_free ( ssl ) ; <nl> - } <nl> - return nullptr ; <nl> + if ( ! setup ( ssl ) | | SSL_connect_or_accept ( ssl ) ! = 1 ) { <nl> + SSL_shutdown ( ssl ) ; <nl> + { <nl> + std : : lock_guard < std : : mutex > guard ( ctx_mutex ) ; <nl> + SSL_free ( ssl ) ; <nl> + } <nl> + return nullptr ; <nl> + } <nl> } <nl> - } <nl> <nl> - return ssl ; <nl> + return ssl ; <nl> } <nl> <nl> - inline void ssl_delete ( std : : mutex & ctx_mutex , SSL * ssl , <nl> - bool process_socket_ret ) { <nl> - if ( process_socket_ret ) { <nl> - SSL_shutdown ( ssl ) ; / / shutdown only if not already closed by remote <nl> - } <nl> + inline void ssl_delete ( std : : mutex & ctx_mutex , SSL * ssl , bool process_socket_ret ) { <nl> + if ( process_socket_ret ) { <nl> + SSL_shutdown ( ssl ) ; / / shutdown only if not already closed by remote <nl> + } <nl> <nl> - std : : lock_guard < std : : mutex > guard ( ctx_mutex ) ; <nl> - SSL_free ( ssl ) ; <nl> + std : : lock_guard < std : : mutex > guard ( ctx_mutex ) ; <nl> + SSL_free ( ssl ) ; <nl> } <nl> <nl> template < typename T > <nl> - inline bool <nl> - process_client_socket_ssl ( SSL * ssl , socket_t sock , time_t read_timeout_sec , <nl> - time_t read_timeout_usec , time_t write_timeout_sec , <nl> - time_t write_timeout_usec , T callback ) { <nl> - SSLSocketStream strm ( sock , ssl , read_timeout_sec , read_timeout_usec , <nl> - write_timeout_sec , write_timeout_usec ) ; <nl> - return callback ( strm ) ; <nl> + inline bool process_client_socket_ssl ( SSL * ssl , <nl> + socket_t sock , <nl> + time_t read_timeout_sec , <nl> + time_t read_timeout_usec , <nl> + time_t write_timeout_sec , <nl> + time_t write_timeout_usec , <nl> + T callback ) { <nl> + SSLSocketStream strm ( sock , ssl , read_timeout_sec , read_timeout_usec , write_timeout_sec , write_timeout_usec ) ; <nl> + return callback ( strm ) ; <nl> } <nl> <nl> # if OPENSSL_VERSION_NUMBER < 0x10100000L <nl> static std : : shared_ptr < std : : vector < std : : mutex > > openSSL_locks_ ; <nl> <nl> class SSLThreadLocks { <nl> - public : <nl> - SSLThreadLocks ( ) { <nl> - openSSL_locks_ = <nl> - std : : make_shared < std : : vector < std : : mutex > > ( CRYPTO_num_locks ( ) ) ; <nl> - CRYPTO_set_locking_callback ( locking_callback ) ; <nl> - } <nl> - <nl> - ~ SSLThreadLocks ( ) { CRYPTO_set_locking_callback ( nullptr ) ; } <nl> - <nl> - private : <nl> - static void locking_callback ( int mode , int type , const char * / * file * / , <nl> - int / * line * / ) { <nl> - auto & lk = ( * openSSL_locks_ ) [ static_cast < size_t > ( type ) ] ; <nl> - if ( mode & CRYPTO_LOCK ) { <nl> - lk . lock ( ) ; <nl> - } else { <nl> - lk . unlock ( ) ; <nl> + public : <nl> + SSLThreadLocks ( ) { <nl> + openSSL_locks_ = std : : make_shared < std : : vector < std : : mutex > > ( CRYPTO_num_locks ( ) ) ; <nl> + CRYPTO_set_locking_callback ( locking_callback ) ; <nl> + } <nl> + <nl> + ~ SSLThreadLocks ( ) { <nl> + CRYPTO_set_locking_callback ( nullptr ) ; <nl> + } <nl> + <nl> + private : <nl> + static void locking_callback ( int mode , int type , const char * / * file * / , int / * line * / ) { <nl> + auto & lk = ( * openSSL_locks_ ) [ static_cast < size_t > ( type ) ] ; <nl> + if ( mode & CRYPTO_LOCK ) { <nl> + lk . lock ( ) ; <nl> + } else { <nl> + lk . unlock ( ) ; <nl> + } <nl> } <nl> - } <nl> } ; <nl> <nl> # endif <nl> <nl> class SSLInit { <nl> - public : <nl> - SSLInit ( ) { <nl> + public : <nl> + SSLInit ( ) { <nl> # if OPENSSL_VERSION_NUMBER < 0x1010001fL <nl> - SSL_load_error_strings ( ) ; <nl> - SSL_library_init ( ) ; <nl> + SSL_load_error_strings ( ) ; <nl> + SSL_library_init ( ) ; <nl> # else <nl> - OPENSSL_init_ssl ( <nl> - OPENSSL_INIT_LOAD_SSL_STRINGS | OPENSSL_INIT_LOAD_CRYPTO_STRINGS , NULL ) ; <nl> + OPENSSL_init_ssl ( OPENSSL_INIT_LOAD_SSL_STRINGS | OPENSSL_INIT_LOAD_CRYPTO_STRINGS , NULL ) ; <nl> # endif <nl> - } <nl> + } <nl> <nl> - ~ SSLInit ( ) { <nl> + ~ SSLInit ( ) { <nl> # if OPENSSL_VERSION_NUMBER < 0x1010001fL <nl> - ERR_free_strings ( ) ; <nl> + ERR_free_strings ( ) ; <nl> # endif <nl> - } <nl> + } <nl> <nl> - private : <nl> + private : <nl> # if OPENSSL_VERSION_NUMBER < 0x10100000L <nl> - SSLThreadLocks thread_init_ ; <nl> + SSLThreadLocks thread_init_ ; <nl> # endif <nl> } ; <nl> <nl> / / SSL socket stream implementation <nl> - inline SSLSocketStream : : SSLSocketStream ( socket_t sock , SSL * ssl , <nl> + inline SSLSocketStream : : SSLSocketStream ( socket_t sock , <nl> + SSL * ssl , <nl> time_t read_timeout_sec , <nl> time_t read_timeout_usec , <nl> time_t write_timeout_sec , <nl> time_t write_timeout_usec ) <nl> - : sock_ ( sock ) , ssl_ ( ssl ) , read_timeout_sec_ ( read_timeout_sec ) , <nl> + : sock_ ( sock ) , <nl> + ssl_ ( ssl ) , <nl> + read_timeout_sec_ ( read_timeout_sec ) , <nl> read_timeout_usec_ ( read_timeout_usec ) , <nl> write_timeout_sec_ ( write_timeout_sec ) , <nl> write_timeout_usec_ ( write_timeout_usec ) { } <nl> inline SSLSocketStream : : SSLSocketStream ( socket_t sock , SSL * ssl , <nl> inline SSLSocketStream : : ~ SSLSocketStream ( ) { } <nl> <nl> inline bool SSLSocketStream : : is_readable ( ) const { <nl> - return detail : : select_read ( sock_ , read_timeout_sec_ , read_timeout_usec_ ) > 0 ; <nl> + return detail : : select_read ( sock_ , read_timeout_sec_ , read_timeout_usec_ ) > 0 ; <nl> } <nl> <nl> inline bool SSLSocketStream : : is_writable ( ) const { <nl> - return detail : : select_write ( sock_ , write_timeout_sec_ , write_timeout_usec_ ) > <nl> - 0 ; <nl> + return detail : : select_write ( sock_ , write_timeout_sec_ , write_timeout_usec_ ) > 0 ; <nl> } <nl> <nl> inline ssize_t SSLSocketStream : : read ( char * ptr , size_t size ) { <nl> - if ( SSL_pending ( ssl_ ) > 0 | | is_readable ( ) ) { <nl> - return SSL_read ( ssl_ , ptr , static_cast < int > ( size ) ) ; <nl> - } <nl> - return - 1 ; <nl> + if ( SSL_pending ( ssl_ ) > 0 | | is_readable ( ) ) { <nl> + return SSL_read ( ssl_ , ptr , static_cast < int > ( size ) ) ; <nl> + } <nl> + return - 1 ; <nl> } <nl> <nl> inline ssize_t SSLSocketStream : : write ( const char * ptr , size_t size ) { <nl> - if ( is_writable ( ) ) { return SSL_write ( ssl_ , ptr , static_cast < int > ( size ) ) ; } <nl> - return - 1 ; <nl> + if ( is_writable ( ) ) { <nl> + return SSL_write ( ssl_ , ptr , static_cast < int > ( size ) ) ; <nl> + } <nl> + return - 1 ; <nl> } <nl> <nl> - inline void SSLSocketStream : : get_remote_ip_and_port ( std : : string & ip , <nl> - int & port ) const { <nl> - detail : : get_remote_ip_and_port ( sock_ , ip , port ) ; <nl> + inline void SSLSocketStream : : get_remote_ip_and_port ( std : : string & ip , int & port ) const { <nl> + detail : : get_remote_ip_and_port ( sock_ , ip , port ) ; <nl> } <nl> <nl> static SSLInit sslinit_ ; <nl> <nl> - } / / namespace detail <nl> + } / / namespace detail <nl> <nl> class SSLClient : public Client { <nl> - public : <nl> - explicit SSLClient ( const std : : string & host ) ; <nl> + public : <nl> + explicit SSLClient ( const std : : string & host ) ; <nl> <nl> - explicit SSLClient ( const std : : string & host , int port ) ; <nl> + explicit SSLClient ( const std : : string & host , int port ) ; <nl> <nl> - explicit SSLClient ( const std : : string & host , int port , <nl> - const std : : string & client_cert_path , <nl> - const std : : string & client_key_path ) ; <nl> + explicit SSLClient ( const std : : string & host , <nl> + int port , <nl> + const std : : string & client_cert_path , <nl> + const std : : string & client_key_path ) ; <nl> <nl> - explicit SSLClient ( const std : : string & host , int port , X509 * client_cert , <nl> - EVP_PKEY * client_key ) ; <nl> + explicit SSLClient ( const std : : string & host , int port , X509 * client_cert , EVP_PKEY * client_key ) ; <nl> <nl> - ~ SSLClient ( ) override ; <nl> + ~ SSLClient ( ) override ; <nl> <nl> - bool is_valid ( ) const override ; <nl> + bool is_valid ( ) const override ; <nl> <nl> - void set_ca_cert_path ( const char * ca_cert_file_path , <nl> - const char * ca_cert_dir_path = nullptr ) ; <nl> + void set_ca_cert_path ( const char * ca_cert_file_path , const char * ca_cert_dir_path = nullptr ) ; <nl> <nl> - void set_ca_cert_store ( X509_STORE * ca_cert_store ) ; <nl> + void set_ca_cert_store ( X509_STORE * ca_cert_store ) ; <nl> <nl> - void enable_server_certificate_verification ( bool enabled ) ; <nl> + void enable_server_certificate_verification ( bool enabled ) ; <nl> <nl> - long get_openssl_verify_result ( ) const ; <nl> + long get_openssl_verify_result ( ) const ; <nl> <nl> - SSL_CTX * ssl_context ( ) const ; <nl> + SSL_CTX * ssl_context ( ) const ; <nl> <nl> - private : <nl> - bool create_and_connect_socket ( Socket & socket ) override ; <nl> - void close_socket ( Socket & socket , bool process_socket_ret ) override ; <nl> + private : <nl> + bool create_and_connect_socket ( Socket & socket ) override ; <nl> + void close_socket ( Socket & socket , bool process_socket_ret ) override ; <nl> <nl> - bool process_socket ( Socket & socket , <nl> - std : : function < bool ( Stream & strm ) > callback ) override ; <nl> - bool is_ssl ( ) const override ; <nl> + bool process_socket ( Socket & socket , std : : function < bool ( Stream & strm ) > callback ) override ; <nl> + bool is_ssl ( ) const override ; <nl> <nl> - bool connect_with_proxy ( Socket & sock , Response & res , bool & success ) ; <nl> - bool initialize_ssl ( Socket & socket ) ; <nl> + bool connect_with_proxy ( Socket & sock , Response & res , bool & success ) ; <nl> + bool initialize_ssl ( Socket & socket ) ; <nl> <nl> - bool verify_host ( X509 * server_cert ) const ; <nl> - bool verify_host_with_subject_alt_name ( X509 * server_cert ) const ; <nl> - bool verify_host_with_common_name ( X509 * server_cert ) const ; <nl> - bool check_host_name ( const char * pattern , size_t pattern_len ) const ; <nl> + bool verify_host ( X509 * server_cert ) const ; <nl> + bool verify_host_with_subject_alt_name ( X509 * server_cert ) const ; <nl> + bool verify_host_with_common_name ( X509 * server_cert ) const ; <nl> + bool check_host_name ( const char * pattern , size_t pattern_len ) const ; <nl> <nl> - SSL_CTX * ctx_ ; <nl> - std : : mutex ctx_mutex_ ; <nl> - std : : vector < std : : string > host_components_ ; <nl> + SSL_CTX * ctx_ ; <nl> + std : : mutex ctx_mutex_ ; <nl> + std : : vector < std : : string > host_components_ ; <nl> <nl> - std : : string ca_cert_file_path_ ; <nl> - std : : string ca_cert_dir_path_ ; <nl> - X509_STORE * ca_cert_store_ = nullptr ; <nl> - bool server_certificate_verification_ = false ; <nl> - long verify_result_ = 0 ; <nl> + std : : string ca_cert_file_path_ ; <nl> + std : : string ca_cert_dir_path_ ; <nl> + X509_STORE * ca_cert_store_ = nullptr ; <nl> + bool server_certificate_verification_ = false ; <nl> + long verify_result_ = 0 ; <nl> <nl> - friend class Client ; <nl> + friend class Client ; <nl> } ; <nl> <nl> / / SSL HTTP client implementation <nl> - inline SSLClient : : SSLClient ( const std : : string & host ) <nl> - : SSLClient ( host , 443 , std : : string ( ) , std : : string ( ) ) { } <nl> + inline SSLClient : : SSLClient ( const std : : string & host ) : SSLClient ( host , 443 , std : : string ( ) , std : : string ( ) ) { } <nl> <nl> - inline SSLClient : : SSLClient ( const std : : string & host , int port ) <nl> - : SSLClient ( host , port , std : : string ( ) , std : : string ( ) ) { } <nl> + inline SSLClient : : SSLClient ( const std : : string & host , int port ) : SSLClient ( host , port , std : : string ( ) , std : : string ( ) ) { } <nl> <nl> - inline SSLClient : : SSLClient ( const std : : string & host , int port , <nl> + inline SSLClient : : SSLClient ( const std : : string & host , <nl> + int port , <nl> const std : : string & client_cert_path , <nl> const std : : string & client_key_path ) <nl> : Client ( host , port , client_cert_path , client_key_path ) { <nl> - ctx_ = SSL_CTX_new ( SSLv23_client_method ( ) ) ; <nl> + ctx_ = SSL_CTX_new ( SSLv23_client_method ( ) ) ; <nl> <nl> - detail : : split ( & host_ [ 0 ] , & host_ [ host_ . size ( ) ] , ' . ' , <nl> - [ & ] ( const char * b , const char * e ) { <nl> - host_components_ . emplace_back ( std : : string ( b , e ) ) ; <nl> - } ) ; <nl> - if ( ! client_cert_path . empty ( ) & & ! client_key_path . empty ( ) ) { <nl> - if ( SSL_CTX_use_certificate_file ( ctx_ , client_cert_path . c_str ( ) , <nl> - SSL_FILETYPE_PEM ) ! = 1 | | <nl> - SSL_CTX_use_PrivateKey_file ( ctx_ , client_key_path . c_str ( ) , <nl> - SSL_FILETYPE_PEM ) ! = 1 ) { <nl> - SSL_CTX_free ( ctx_ ) ; <nl> - ctx_ = nullptr ; <nl> + detail : : split ( & host_ [ 0 ] , & host_ [ host_ . size ( ) ] , ' . ' , [ & ] ( const char * b , const char * e ) { <nl> + host_components_ . emplace_back ( std : : string ( b , e ) ) ; <nl> + } ) ; <nl> + if ( ! client_cert_path . empty ( ) & & ! client_key_path . empty ( ) ) { <nl> + if ( SSL_CTX_use_certificate_file ( ctx_ , client_cert_path . c_str ( ) , SSL_FILETYPE_PEM ) ! = 1 | | <nl> + SSL_CTX_use_PrivateKey_file ( ctx_ , client_key_path . c_str ( ) , SSL_FILETYPE_PEM ) ! = 1 ) { <nl> + SSL_CTX_free ( ctx_ ) ; <nl> + ctx_ = nullptr ; <nl> + } <nl> } <nl> - } <nl> } <nl> <nl> - inline SSLClient : : SSLClient ( const std : : string & host , int port , <nl> - X509 * client_cert , EVP_PKEY * client_key ) <nl> + inline SSLClient : : SSLClient ( const std : : string & host , int port , X509 * client_cert , EVP_PKEY * client_key ) <nl> : Client ( host , port ) { <nl> - ctx_ = SSL_CTX_new ( SSLv23_client_method ( ) ) ; <nl> + ctx_ = SSL_CTX_new ( SSLv23_client_method ( ) ) ; <nl> <nl> - detail : : split ( & host_ [ 0 ] , & host_ [ host_ . size ( ) ] , ' . ' , <nl> - [ & ] ( const char * b , const char * e ) { <nl> - host_components_ . emplace_back ( std : : string ( b , e ) ) ; <nl> - } ) ; <nl> - if ( client_cert ! = nullptr & & client_key ! = nullptr ) { <nl> - if ( SSL_CTX_use_certificate ( ctx_ , client_cert ) ! = 1 | | <nl> - SSL_CTX_use_PrivateKey ( ctx_ , client_key ) ! = 1 ) { <nl> - SSL_CTX_free ( ctx_ ) ; <nl> - ctx_ = nullptr ; <nl> + detail : : split ( & host_ [ 0 ] , & host_ [ host_ . size ( ) ] , ' . ' , [ & ] ( const char * b , const char * e ) { <nl> + host_components_ . emplace_back ( std : : string ( b , e ) ) ; <nl> + } ) ; <nl> + if ( client_cert ! = nullptr & & client_key ! = nullptr ) { <nl> + if ( SSL_CTX_use_certificate ( ctx_ , client_cert ) ! = 1 | | SSL_CTX_use_PrivateKey ( ctx_ , client_key ) ! = 1 ) { <nl> + SSL_CTX_free ( ctx_ ) ; <nl> + ctx_ = nullptr ; <nl> + } <nl> } <nl> - } <nl> } <nl> <nl> inline SSLClient : : ~ SSLClient ( ) { <nl> - if ( ctx_ ) { SSL_CTX_free ( ctx_ ) ; } <nl> + if ( ctx_ ) { <nl> + SSL_CTX_free ( ctx_ ) ; <nl> + } <nl> } <nl> <nl> - inline bool SSLClient : : is_valid ( ) const { return ctx_ ; } <nl> + inline bool SSLClient : : is_valid ( ) const { <nl> + return ctx_ ; <nl> + } <nl> <nl> - inline void SSLClient : : set_ca_cert_path ( const char * ca_cert_file_path , <nl> - const char * ca_cert_dir_path ) { <nl> - if ( ca_cert_file_path ) { ca_cert_file_path_ = ca_cert_file_path ; } <nl> - if ( ca_cert_dir_path ) { ca_cert_dir_path_ = ca_cert_dir_path ; } <nl> + inline void SSLClient : : set_ca_cert_path ( const char * ca_cert_file_path , const char * ca_cert_dir_path ) { <nl> + if ( ca_cert_file_path ) { <nl> + ca_cert_file_path_ = ca_cert_file_path ; <nl> + } <nl> + if ( ca_cert_dir_path ) { <nl> + ca_cert_dir_path_ = ca_cert_dir_path ; <nl> + } <nl> } <nl> <nl> inline void SSLClient : : set_ca_cert_store ( X509_STORE * ca_cert_store ) { <nl> - if ( ca_cert_store ) { ca_cert_store_ = ca_cert_store ; } <nl> + if ( ca_cert_store ) { <nl> + ca_cert_store_ = ca_cert_store ; <nl> + } <nl> } <nl> <nl> inline void SSLClient : : enable_server_certificate_verification ( bool enabled ) { <nl> - server_certificate_verification_ = enabled ; <nl> + server_certificate_verification_ = enabled ; <nl> } <nl> <nl> inline long SSLClient : : get_openssl_verify_result ( ) const { <nl> - return verify_result_ ; <nl> + return verify_result_ ; <nl> } <nl> <nl> - inline SSL_CTX * SSLClient : : ssl_context ( ) const { return ctx_ ; } <nl> + inline SSL_CTX * SSLClient : : ssl_context ( ) const { <nl> + return ctx_ ; <nl> + } <nl> <nl> inline bool SSLClient : : create_and_connect_socket ( Socket & socket ) { <nl> - return is_valid ( ) & & Client : : create_and_connect_socket ( socket ) ; <nl> - } <nl> - <nl> - inline bool SSLClient : : connect_with_proxy ( Socket & socket , Response & res , <nl> - bool & success ) { <nl> - success = true ; <nl> - Response res2 ; <nl> - <nl> - if ( ! detail : : process_client_socket ( <nl> - socket . sock , read_timeout_sec_ , read_timeout_usec_ , <nl> - write_timeout_sec_ , write_timeout_usec_ , [ & ] ( Stream & strm ) { <nl> - Request req2 ; <nl> - req2 . method = " CONNECT " ; <nl> - req2 . path = host_and_port_ ; <nl> - return process_request ( strm , req2 , res2 , false ) ; <nl> - } ) ) { <nl> - close_socket ( socket , true ) ; <nl> - success = false ; <nl> - return false ; <nl> - } <nl> - <nl> - if ( res2 . status = = 407 ) { <nl> - if ( ! proxy_digest_auth_username_ . empty ( ) & & <nl> - ! proxy_digest_auth_password_ . empty ( ) ) { <nl> - std : : map < std : : string , std : : string > auth ; <nl> - if ( parse_www_authenticate ( res2 , auth , true ) ) { <nl> - Response res3 ; <nl> - if ( ! detail : : process_client_socket ( <nl> - socket . sock , read_timeout_sec_ , read_timeout_usec_ , <nl> - write_timeout_sec_ , write_timeout_usec_ , [ & ] ( Stream & strm ) { <nl> - Request req3 ; <nl> - req3 . method = " CONNECT " ; <nl> - req3 . path = host_and_port_ ; <nl> - req3 . headers . insert ( make_digest_authentication_header ( <nl> - req3 , auth , 1 , random_string ( 10 ) , <nl> - proxy_digest_auth_username_ , proxy_digest_auth_password_ , <nl> - true ) ) ; <nl> - return process_request ( strm , req3 , res3 , false ) ; <nl> - } ) ) { <nl> - close_socket ( socket , true ) ; <nl> - success = false ; <nl> - return false ; <nl> - } <nl> - } <nl> - } else { <nl> - res = res2 ; <nl> - return false ; <nl> + return is_valid ( ) & & Client : : create_and_connect_socket ( socket ) ; <nl> + } <nl> + <nl> + inline bool SSLClient : : connect_with_proxy ( Socket & socket , Response & res , bool & success ) { <nl> + success = true ; <nl> + Response res2 ; <nl> + <nl> + if ( ! detail : : process_client_socket ( socket . sock , <nl> + read_timeout_sec_ , <nl> + read_timeout_usec_ , <nl> + write_timeout_sec_ , <nl> + write_timeout_usec_ , <nl> + [ & ] ( Stream & strm ) { <nl> + Request req2 ; <nl> + req2 . method = " CONNECT " ; <nl> + req2 . path = host_and_port_ ; <nl> + return process_request ( strm , req2 , res2 , false ) ; <nl> + } ) ) { <nl> + close_socket ( socket , true ) ; <nl> + success = false ; <nl> + return false ; <nl> } <nl> - } <nl> <nl> - return true ; <nl> - } <nl> - <nl> - inline bool SSLClient : : initialize_ssl ( Socket & socket ) { <nl> - auto ssl = detail : : ssl_new ( <nl> - socket . sock , ctx_ , ctx_mutex_ , <nl> - [ & ] ( SSL * ssl ) { <nl> - if ( ca_cert_file_path_ . empty ( ) & & ca_cert_store_ = = nullptr ) { <nl> - SSL_CTX_set_verify ( ctx_ , SSL_VERIFY_NONE , nullptr ) ; <nl> - } else if ( ! ca_cert_file_path_ . empty ( ) ) { <nl> - if ( ! SSL_CTX_load_verify_locations ( ctx_ , ca_cert_file_path_ . c_str ( ) , <nl> - nullptr ) ) { <nl> + if ( res2 . status = = 407 ) { <nl> + if ( ! proxy_digest_auth_username_ . empty ( ) & & ! proxy_digest_auth_password_ . empty ( ) ) { <nl> + std : : map < std : : string , std : : string > auth ; <nl> + if ( parse_www_authenticate ( res2 , auth , true ) ) { <nl> + Response res3 ; <nl> + if ( ! detail : : process_client_socket ( socket . sock , <nl> + read_timeout_sec_ , <nl> + read_timeout_usec_ , <nl> + write_timeout_sec_ , <nl> + write_timeout_usec_ , <nl> + [ & ] ( Stream & strm ) { <nl> + Request req3 ; <nl> + req3 . method = " CONNECT " ; <nl> + req3 . path = host_and_port_ ; <nl> + req3 . headers . insert ( make_digest_authentication_header ( <nl> + req3 , <nl> + auth , <nl> + 1 , <nl> + random_string ( 10 ) , <nl> + proxy_digest_auth_username_ , <nl> + proxy_digest_auth_password_ , <nl> + true ) ) ; <nl> + return process_request ( strm , req3 , res3 , false ) ; <nl> + } ) ) { <nl> + close_socket ( socket , true ) ; <nl> + success = false ; <nl> + return false ; <nl> + } <nl> + } <nl> + } else { <nl> + res = res2 ; <nl> return false ; <nl> - } <nl> - SSL_CTX_set_verify ( ctx_ , SSL_VERIFY_PEER , nullptr ) ; <nl> - } else if ( ca_cert_store_ ! = nullptr ) { <nl> - if ( SSL_CTX_get_cert_store ( ctx_ ) ! = ca_cert_store_ ) { <nl> - SSL_CTX_set_cert_store ( ctx_ , ca_cert_store_ ) ; <nl> - } <nl> - SSL_CTX_set_verify ( ctx_ , SSL_VERIFY_PEER , nullptr ) ; <nl> } <nl> + } <nl> <nl> - if ( SSL_connect ( ssl ) ! = 1 ) { return false ; } <nl> - <nl> - if ( server_certificate_verification_ ) { <nl> - verify_result_ = SSL_get_verify_result ( ssl ) ; <nl> - <nl> - if ( verify_result_ ! = X509_V_OK ) { return false ; } <nl> - <nl> - auto server_cert = SSL_get_peer_certificate ( ssl ) ; <nl> - <nl> - if ( server_cert = = nullptr ) { return false ; } <nl> - <nl> - if ( ! verify_host ( server_cert ) ) { <nl> - X509_free ( server_cert ) ; <nl> - return false ; <nl> - } <nl> - X509_free ( server_cert ) ; <nl> - } <nl> + return true ; <nl> + } <nl> <nl> + inline bool SSLClient : : initialize_ssl ( Socket & socket ) { <nl> + auto ssl = detail : : ssl_new ( socket . sock , <nl> + ctx_ , <nl> + ctx_mutex_ , <nl> + [ & ] ( SSL * ssl ) { <nl> + if ( ca_cert_file_path_ . empty ( ) & & ca_cert_store_ = = nullptr ) { <nl> + SSL_CTX_set_verify ( ctx_ , SSL_VERIFY_NONE , nullptr ) ; <nl> + } else if ( ! ca_cert_file_path_ . empty ( ) ) { <nl> + if ( ! SSL_CTX_load_verify_locations ( ctx_ , ca_cert_file_path_ . c_str ( ) , nullptr ) ) { <nl> + return false ; <nl> + } <nl> + SSL_CTX_set_verify ( ctx_ , SSL_VERIFY_PEER , nullptr ) ; <nl> + } else if ( ca_cert_store_ ! = nullptr ) { <nl> + if ( SSL_CTX_get_cert_store ( ctx_ ) ! = ca_cert_store_ ) { <nl> + SSL_CTX_set_cert_store ( ctx_ , ca_cert_store_ ) ; <nl> + } <nl> + SSL_CTX_set_verify ( ctx_ , SSL_VERIFY_PEER , nullptr ) ; <nl> + } <nl> + <nl> + if ( SSL_connect ( ssl ) ! = 1 ) { <nl> + return false ; <nl> + } <nl> + <nl> + if ( server_certificate_verification_ ) { <nl> + verify_result_ = SSL_get_verify_result ( ssl ) ; <nl> + <nl> + if ( verify_result_ ! = X509_V_OK ) { <nl> + return false ; <nl> + } <nl> + <nl> + auto server_cert = SSL_get_peer_certificate ( ssl ) ; <nl> + <nl> + if ( server_cert = = nullptr ) { <nl> + return false ; <nl> + } <nl> + <nl> + if ( ! verify_host ( server_cert ) ) { <nl> + X509_free ( server_cert ) ; <nl> + return false ; <nl> + } <nl> + X509_free ( server_cert ) ; <nl> + } <nl> + <nl> + return true ; <nl> + } , <nl> + [ & ] ( SSL * ssl ) { <nl> + SSL_set_tlsext_host_name ( ssl , host_ . c_str ( ) ) ; <nl> + return true ; <nl> + } ) ; <nl> + <nl> + if ( ssl ) { <nl> + socket . ssl = ssl ; <nl> return true ; <nl> - } , <nl> - [ & ] ( SSL * ssl ) { <nl> - SSL_set_tlsext_host_name ( ssl , host_ . c_str ( ) ) ; <nl> - return true ; <nl> - } ) ; <nl> - <nl> - if ( ssl ) { <nl> - socket . ssl = ssl ; <nl> - return true ; <nl> - } <nl> + } <nl> <nl> - close_socket ( socket , false ) ; <nl> - return false ; <nl> + close_socket ( socket , false ) ; <nl> + return false ; <nl> } <nl> <nl> inline void SSLClient : : close_socket ( Socket & socket , bool process_socket_ret ) { <nl> - detail : : close_socket ( socket . sock ) ; <nl> - socket_ . sock = INVALID_SOCKET ; <nl> - if ( socket . ssl ) { <nl> - detail : : ssl_delete ( ctx_mutex_ , socket . ssl , process_socket_ret ) ; <nl> - socket_ . ssl = nullptr ; <nl> - } <nl> + detail : : close_socket ( socket . sock ) ; <nl> + socket_ . sock = INVALID_SOCKET ; <nl> + if ( socket . ssl ) { <nl> + detail : : ssl_delete ( ctx_mutex_ , socket . ssl , process_socket_ret ) ; <nl> + socket_ . ssl = nullptr ; <nl> + } <nl> } <nl> <nl> - inline bool <nl> - SSLClient : : process_socket ( Socket & socket , <nl> - std : : function < bool ( Stream & strm ) > callback ) { <nl> - assert ( socket . ssl ) ; <nl> - return detail : : process_client_socket_ssl ( <nl> - socket . ssl , socket . sock , read_timeout_sec_ , read_timeout_usec_ , <nl> - write_timeout_sec_ , write_timeout_usec_ , callback ) ; <nl> + inline bool SSLClient : : process_socket ( Socket & socket , std : : function < bool ( Stream & strm ) > callback ) { <nl> + assert ( socket . ssl ) ; <nl> + return detail : : process_client_socket_ssl ( socket . ssl , <nl> + socket . sock , <nl> + read_timeout_sec_ , <nl> + read_timeout_usec_ , <nl> + write_timeout_sec_ , <nl> + write_timeout_usec_ , <nl> + callback ) ; <nl> } <nl> <nl> - inline bool SSLClient : : is_ssl ( ) const { return true ; } <nl> + inline bool SSLClient : : is_ssl ( ) const { <nl> + return true ; <nl> + } <nl> <nl> inline bool SSLClient : : verify_host ( X509 * server_cert ) const { <nl> - / * Quote from RFC2818 section 3 . 1 " Server Identity " <nl> + / * Quote from RFC2818 section 3 . 1 " Server Identity " <nl> <nl> - If a subjectAltName extension of type dNSName is present , that MUST <nl> - be used as the identity . Otherwise , the ( most specific ) Common Name <nl> - field in the Subject field of the certificate MUST be used . Although <nl> - the use of the Common Name is existing practice , it is deprecated and <nl> - Certification Authorities are encouraged to use the dNSName instead . <nl> + If a subjectAltName extension of type dNSName is present , that MUST <nl> + be used as the identity . Otherwise , the ( most specific ) Common Name <nl> + field in the Subject field of the certificate MUST be used . Although <nl> + the use of the Common Name is existing practice , it is deprecated and <nl> + Certification Authorities are encouraged to use the dNSName instead . <nl> <nl> - Matching is performed using the matching rules specified by <nl> - [ RFC2459 ] . If more than one identity of a given type is present in <nl> - the certificate ( e . g . , more than one dNSName name , a match in any one <nl> - of the set is considered acceptable . ) Names may contain the wildcard <nl> - character * which is considered to match any single domain name <nl> - component or component fragment . E . g . , * . a . com matches foo . a . com but <nl> - not bar . foo . a . com . f * . com matches foo . com but not bar . com . <nl> + Matching is performed using the matching rules specified by <nl> + [ RFC2459 ] . If more than one identity of a given type is present in <nl> + the certificate ( e . g . , more than one dNSName name , a match in any one <nl> + of the set is considered acceptable . ) Names may contain the wildcard <nl> + character * which is considered to match any single domain name <nl> + component or component fragment . E . g . , * . a . com matches foo . a . com but <nl> + not bar . foo . a . com . f * . com matches foo . com but not bar . com . <nl> <nl> - In some cases , the URI is specified as an IP address rather than a <nl> - hostname . In this case , the iPAddress subjectAltName must be present <nl> - in the certificate and must exactly match the IP in the URI . <nl> + In some cases , the URI is specified as an IP address rather than a <nl> + hostname . In this case , the iPAddress subjectAltName must be present <nl> + in the certificate and must exactly match the IP in the URI . <nl> <nl> - * / <nl> - return verify_host_with_subject_alt_name ( server_cert ) | | <nl> - verify_host_with_common_name ( server_cert ) ; <nl> + * / <nl> + return verify_host_with_subject_alt_name ( server_cert ) | | verify_host_with_common_name ( server_cert ) ; <nl> } <nl> <nl> - inline bool <nl> - SSLClient : : verify_host_with_subject_alt_name ( X509 * server_cert ) const { <nl> - auto ret = false ; <nl> + inline bool SSLClient : : verify_host_with_subject_alt_name ( X509 * server_cert ) const { <nl> + auto ret = false ; <nl> <nl> - auto type = GEN_DNS ; <nl> + auto type = GEN_DNS ; <nl> <nl> - struct in6_addr addr6 ; <nl> - struct in_addr addr ; <nl> - size_t addr_len = 0 ; <nl> + struct in6_addr addr6 ; <nl> + struct in_addr addr ; <nl> + size_t addr_len = 0 ; <nl> <nl> # ifndef __MINGW32__ <nl> - if ( inet_pton ( AF_INET6 , host_ . c_str ( ) , & addr6 ) ) { <nl> - type = GEN_IPADD ; <nl> - addr_len = sizeof ( struct in6_addr ) ; <nl> - } else if ( inet_pton ( AF_INET , host_ . c_str ( ) , & addr ) ) { <nl> - type = GEN_IPADD ; <nl> - addr_len = sizeof ( struct in_addr ) ; <nl> - } <nl> - # endif <nl> - <nl> - auto alt_names = static_cast < const struct stack_st_GENERAL_NAME * > ( <nl> - X509_get_ext_d2i ( server_cert , NID_subject_alt_name , nullptr , nullptr ) ) ; <nl> - <nl> - if ( alt_names ) { <nl> - auto dsn_matched = false ; <nl> - auto ip_mached = false ; <nl> - <nl> - auto count = sk_GENERAL_NAME_num ( alt_names ) ; <nl> - <nl> - for ( decltype ( count ) i = 0 ; i < count & & ! dsn_matched ; i + + ) { <nl> - auto val = sk_GENERAL_NAME_value ( alt_names , i ) ; <nl> - if ( val - > type = = type ) { <nl> - auto name = ( const char * ) ASN1_STRING_get0_data ( val - > d . ia5 ) ; <nl> - auto name_len = ( size_t ) ASN1_STRING_length ( val - > d . ia5 ) ; <nl> - <nl> - if ( strlen ( name ) = = name_len ) { <nl> - switch ( type ) { <nl> - case GEN_DNS : dsn_matched = check_host_name ( name , name_len ) ; break ; <nl> - <nl> - case GEN_IPADD : <nl> - if ( ! memcmp ( & addr6 , name , addr_len ) | | <nl> - ! memcmp ( & addr , name , addr_len ) ) { <nl> - ip_mached = true ; <nl> + if ( inet_pton ( AF_INET6 , host_ . c_str ( ) , & addr6 ) ) { <nl> + type = GEN_IPADD ; <nl> + addr_len = sizeof ( struct in6_addr ) ; <nl> + } else if ( inet_pton ( AF_INET , host_ . c_str ( ) , & addr ) ) { <nl> + type = GEN_IPADD ; <nl> + addr_len = sizeof ( struct in_addr ) ; <nl> + } <nl> + # endif <nl> + <nl> + auto alt_names = static_cast < const struct stack_st_GENERAL_NAME * > ( <nl> + X509_get_ext_d2i ( server_cert , NID_subject_alt_name , nullptr , nullptr ) ) ; <nl> + <nl> + if ( alt_names ) { <nl> + auto dsn_matched = false ; <nl> + auto ip_mached = false ; <nl> + <nl> + auto count = sk_GENERAL_NAME_num ( alt_names ) ; <nl> + <nl> + for ( decltype ( count ) i = 0 ; i < count & & ! dsn_matched ; i + + ) { <nl> + auto val = sk_GENERAL_NAME_value ( alt_names , i ) ; <nl> + if ( val - > type = = type ) { <nl> + auto name = ( const char * ) ASN1_STRING_get0_data ( val - > d . ia5 ) ; <nl> + auto name_len = ( size_t ) ASN1_STRING_length ( val - > d . ia5 ) ; <nl> + <nl> + if ( strlen ( name ) = = name_len ) { <nl> + switch ( type ) { <nl> + case GEN_DNS : <nl> + dsn_matched = check_host_name ( name , name_len ) ; <nl> + break ; <nl> + <nl> + case GEN_IPADD : <nl> + if ( ! memcmp ( & addr6 , name , addr_len ) | | ! memcmp ( & addr , name , addr_len ) ) { <nl> + ip_mached = true ; <nl> + } <nl> + break ; <nl> + } <nl> + } <nl> } <nl> - break ; <nl> - } <nl> } <nl> - } <nl> - } <nl> <nl> - if ( dsn_matched | | ip_mached ) { ret = true ; } <nl> - } <nl> + if ( dsn_matched | | ip_mached ) { <nl> + ret = true ; <nl> + } <nl> + } <nl> <nl> - GENERAL_NAMES_free ( ( STACK_OF ( GENERAL_NAME ) * ) alt_names ) ; <nl> - return ret ; <nl> + GENERAL_NAMES_free ( ( STACK_OF ( GENERAL_NAME ) * ) alt_names ) ; <nl> + return ret ; <nl> } <nl> <nl> inline bool SSLClient : : verify_host_with_common_name ( X509 * server_cert ) const { <nl> - const auto subject_name = X509_get_subject_name ( server_cert ) ; <nl> + const auto subject_name = X509_get_subject_name ( server_cert ) ; <nl> <nl> - if ( subject_name ! = nullptr ) { <nl> - char name [ BUFSIZ ] ; <nl> - auto name_len = X509_NAME_get_text_by_NID ( subject_name , NID_commonName , <nl> - name , sizeof ( name ) ) ; <nl> + if ( subject_name ! = nullptr ) { <nl> + char name [ BUFSIZ ] ; <nl> + auto name_len = X509_NAME_get_text_by_NID ( subject_name , NID_commonName , name , sizeof ( name ) ) ; <nl> <nl> - if ( name_len ! = - 1 ) { <nl> - return check_host_name ( name , static_cast < size_t > ( name_len ) ) ; <nl> + if ( name_len ! = - 1 ) { <nl> + return check_host_name ( name , static_cast < size_t > ( name_len ) ) ; <nl> + } <nl> } <nl> - } <nl> <nl> - return false ; <nl> + return false ; <nl> } <nl> <nl> - inline bool SSLClient : : check_host_name ( const char * pattern , <nl> - size_t pattern_len ) const { <nl> - if ( host_ . size ( ) = = pattern_len & & host_ = = pattern ) { return true ; } <nl> + inline bool SSLClient : : check_host_name ( const char * pattern , size_t pattern_len ) const { <nl> + if ( host_ . size ( ) = = pattern_len & & host_ = = pattern ) { <nl> + return true ; <nl> + } <nl> <nl> - / / Wildcard match <nl> - / / https : / / bugs . launchpad . net / ubuntu / + source / firefox - 3 . 0 / + bug / 376484 <nl> - std : : vector < std : : string > pattern_components ; <nl> - detail : : split ( & pattern [ 0 ] , & pattern [ pattern_len ] , ' . ' , <nl> - [ & ] ( const char * b , const char * e ) { <nl> - pattern_components . emplace_back ( std : : string ( b , e ) ) ; <nl> - } ) ; <nl> + / / Wildcard match <nl> + / / https : / / bugs . launchpad . net / ubuntu / + source / firefox - 3 . 0 / + bug / 376484 <nl> + std : : vector < std : : string > pattern_components ; <nl> + detail : : split ( & pattern [ 0 ] , & pattern [ pattern_len ] , ' . ' , [ & ] ( const char * b , const char * e ) { <nl> + pattern_components . emplace_back ( std : : string ( b , e ) ) ; <nl> + } ) ; <nl> <nl> - if ( host_components_ . size ( ) ! = pattern_components . size ( ) ) { return false ; } <nl> + if ( host_components_ . size ( ) ! = pattern_components . size ( ) ) { <nl> + return false ; <nl> + } <nl> <nl> - auto itr = pattern_components . begin ( ) ; <nl> - for ( const auto & h : host_components_ ) { <nl> - auto & p = * itr ; <nl> - if ( p ! = h & & p ! = " * " ) { <nl> - auto partial_match = ( p . size ( ) > 0 & & p [ p . size ( ) - 1 ] = = ' * ' & & <nl> - ! p . compare ( 0 , p . size ( ) - 1 , h ) ) ; <nl> - if ( ! partial_match ) { return false ; } <nl> + auto itr = pattern_components . begin ( ) ; <nl> + for ( const auto & h : host_components_ ) { <nl> + auto & p = * itr ; <nl> + if ( p ! = h & & p ! = " * " ) { <nl> + auto partial_match = ( p . size ( ) > 0 & & p [ p . size ( ) - 1 ] = = ' * ' & & ! p . compare ( 0 , p . size ( ) - 1 , h ) ) ; <nl> + if ( ! partial_match ) { <nl> + return false ; <nl> + } <nl> + } <nl> + + + itr ; <nl> } <nl> - + + itr ; <nl> - } <nl> <nl> - return true ; <nl> + return true ; <nl> } <nl> # endif <nl> <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> <nl> - } / / namespace httplib <nl> + } / / namespace httplib <nl> mmm a / core - tests / include / httplib_server . h <nl> ppp b / core - tests / include / httplib_server . h <nl> <nl> * Copyright ( c ) 2020 Yuji Hirose . All rights reserved . <nl> * MIT License <nl> * GitHub : https : / / github . com / yhirose / cpp - httplib <nl> - * / <nl> + * / <nl> <nl> # pragma once <nl> <nl> <nl> # include " coroutine_socket . h " <nl> # include " httplib_client . h " <nl> <nl> + using swoole : : Coroutine ; <nl> using swoole : : coroutine : : Socket ; <nl> using swoole : : coroutine : : System ; <nl> - using swoole : : Coroutine ; <nl> <nl> namespace httplib { <nl> <nl> class ContentReader { <nl> - public : <nl> - using Reader = std : : function < bool ( ContentReceiver receiver ) > ; <nl> - using MultipartReader = std : : function < bool ( MultipartContentHeader header , <nl> - ContentReceiver receiver ) > ; <nl> + public : <nl> + using Reader = std : : function < bool ( ContentReceiver receiver ) > ; <nl> + using MultipartReader = std : : function < bool ( MultipartContentHeader header , ContentReceiver receiver ) > ; <nl> <nl> - ContentReader ( Reader reader , MultipartReader multipart_reader ) <nl> - : reader_ ( reader ) , multipart_reader_ ( multipart_reader ) { } <nl> + ContentReader ( Reader reader , MultipartReader multipart_reader ) <nl> + : reader_ ( reader ) , multipart_reader_ ( multipart_reader ) { } <nl> <nl> - bool operator ( ) ( MultipartContentHeader header , <nl> - ContentReceiver receiver ) const { <nl> - return multipart_reader_ ( header , receiver ) ; <nl> - } <nl> + bool operator ( ) ( MultipartContentHeader header , ContentReceiver receiver ) const { <nl> + return multipart_reader_ ( header , receiver ) ; <nl> + } <nl> <nl> - bool operator ( ) ( ContentReceiver receiver ) const { return reader_ ( receiver ) ; } <nl> + bool operator ( ) ( ContentReceiver receiver ) const { <nl> + return reader_ ( receiver ) ; <nl> + } <nl> <nl> - Reader reader_ ; <nl> - MultipartReader multipart_reader_ ; <nl> + Reader reader_ ; <nl> + MultipartReader multipart_reader_ ; <nl> } ; <nl> <nl> class Server { <nl> - public : <nl> - using Handler = std : : function < void ( const Request & , Response & ) > ; <nl> - using HandlerWithContentReader = std : : function < void ( <nl> - const Request & , Response & , const ContentReader & content_reader ) > ; <nl> - using Expect100ContinueHandler = <nl> - std : : function < int ( const Request & , Response & ) > ; <nl> - <nl> - Server ( ) ; <nl> - <nl> - virtual ~ Server ( ) ; <nl> - <nl> - virtual bool is_valid ( ) const ; <nl> - <nl> - Server & Get ( const char * pattern , Handler handler ) ; <nl> - Server & Post ( const char * pattern , Handler handler ) ; <nl> - Server & Post ( const char * pattern , HandlerWithContentReader handler ) ; <nl> - Server & Put ( const char * pattern , Handler handler ) ; <nl> - Server & Put ( const char * pattern , HandlerWithContentReader handler ) ; <nl> - Server & Patch ( const char * pattern , Handler handler ) ; <nl> - Server & Patch ( const char * pattern , HandlerWithContentReader handler ) ; <nl> - Server & Delete ( const char * pattern , Handler handler ) ; <nl> - Server & Delete ( const char * pattern , HandlerWithContentReader handler ) ; <nl> - Server & Options ( const char * pattern , Handler handler ) ; <nl> - <nl> - CPPHTTPLIB_DEPRECATED bool set_base_dir ( const char * dir , <nl> - const char * mount_point = nullptr ) ; <nl> - bool set_mount_point ( const char * mount_point , const char * dir ) ; <nl> - bool remove_mount_point ( const char * mount_point ) ; <nl> - void set_file_extension_and_mimetype_mapping ( const char * ext , <nl> - const char * mime ) ; <nl> - void set_file_request_handler ( Handler handler ) ; <nl> - <nl> - void set_error_handler ( Handler handler ) ; <nl> - void set_expect_100_continue_handler ( Expect100ContinueHandler handler ) ; <nl> - void set_logger ( Logger logger ) ; <nl> - <nl> - void set_tcp_nodelay ( bool on ) ; <nl> - void set_socket_options ( SocketOptions socket_options ) ; <nl> - <nl> - void set_keep_alive_max_count ( size_t count ) ; <nl> - void set_read_timeout ( time_t sec , time_t usec = 0 ) ; <nl> - void set_write_timeout ( time_t sec , time_t usec = 0 ) ; <nl> - void set_idle_interval ( time_t sec , time_t usec = 0 ) ; <nl> - <nl> - void set_payload_max_length ( size_t length ) ; <nl> - <nl> - bool bind_to_port ( const char * host , int port , int socket_flags = 0 ) ; <nl> - int bind_to_any_port ( const char * host , int socket_flags = 0 ) ; <nl> - bool listen_after_bind ( ) ; <nl> - <nl> - bool listen ( const char * host , int port , int socket_flags = 0 ) ; <nl> - <nl> - bool is_running ( ) const ; <nl> - void stop ( ) ; <nl> - <nl> - protected : <nl> - bool process_request ( Stream & strm , bool close_connection , <nl> - bool & connection_closed , <nl> - const std : : function < void ( Request & ) > & setup_request ) ; <nl> - <nl> - Socket * svr_sock_ ; <nl> - size_t keep_alive_max_count_ = CPPHTTPLIB_KEEPALIVE_MAX_COUNT ; <nl> - time_t read_timeout_sec_ = CPPHTTPLIB_READ_TIMEOUT_SECOND ; <nl> - time_t read_timeout_usec_ = CPPHTTPLIB_READ_TIMEOUT_USECOND ; <nl> - time_t write_timeout_sec_ = CPPHTTPLIB_WRITE_TIMEOUT_SECOND ; <nl> - time_t write_timeout_usec_ = CPPHTTPLIB_WRITE_TIMEOUT_USECOND ; <nl> - time_t idle_interval_sec_ = CPPHTTPLIB_IDLE_INTERVAL_SECOND ; <nl> - time_t idle_interval_usec_ = CPPHTTPLIB_IDLE_INTERVAL_USECOND ; <nl> - size_t payload_max_length_ = CPPHTTPLIB_PAYLOAD_MAX_LENGTH ; <nl> - <nl> - private : <nl> - using Handlers = std : : vector < std : : pair < std : : regex , Handler > > ; <nl> - using HandlersForContentReader = <nl> - std : : vector < std : : pair < std : : regex , HandlerWithContentReader > > ; <nl> - <nl> - Socket * create_server_socket ( const char * host , int port , int socket_flags , <nl> - SocketOptions socket_options ) const ; <nl> - int bind_internal ( const char * host , int port , int socket_flags ) ; <nl> - bool listen_internal ( ) ; <nl> - <nl> - bool routing ( Request & req , Response & res , Stream & strm ) ; <nl> - bool handle_file_request ( Request & req , Response & res , bool head = false ) ; <nl> - bool dispatch_request ( Request & req , Response & res , Handlers & handlers ) ; <nl> - bool dispatch_request_for_content_reader ( Request & req , Response & res , <nl> - ContentReader content_reader , <nl> - HandlersForContentReader & handlers ) ; <nl> - <nl> - bool parse_request_line ( const char * s , Request & req ) ; <nl> - bool write_response ( Stream & strm , bool close_connection , const Request & req , <nl> - Response & res ) ; <nl> - bool write_content_with_provider ( Stream & strm , const Request & req , <nl> - Response & res , const std : : string & boundary , <nl> - const std : : string & content_type ) ; <nl> - bool read_content ( Stream & strm , Request & req , Response & res ) ; <nl> - bool <nl> - read_content_with_content_receiver ( Stream & strm , Request & req , Response & res , <nl> - ContentReceiver receiver , <nl> - MultipartContentHeader multipart_header , <nl> - ContentReceiver multipart_receiver ) ; <nl> - bool read_content_core ( Stream & strm , Request & req , Response & res , <nl> - ContentReceiver receiver , <nl> - MultipartContentHeader mulitpart_header , <nl> - ContentReceiver multipart_receiver ) ; <nl> - <nl> - virtual bool process_and_close_socket ( Socket * sock ) ; <nl> - <nl> - std : : atomic < bool > is_running_ ; <nl> - std : : vector < std : : pair < std : : string , std : : string > > base_dirs_ ; <nl> - std : : map < std : : string , std : : string > file_extension_and_mimetype_map_ ; <nl> - Handler file_request_handler_ ; <nl> - Handlers get_handlers_ ; <nl> - Handlers post_handlers_ ; <nl> - HandlersForContentReader post_handlers_for_content_reader_ ; <nl> - Handlers put_handlers_ ; <nl> - HandlersForContentReader put_handlers_for_content_reader_ ; <nl> - Handlers patch_handlers_ ; <nl> - HandlersForContentReader patch_handlers_for_content_reader_ ; <nl> - Handlers delete_handlers_ ; <nl> - HandlersForContentReader delete_handlers_for_content_reader_ ; <nl> - Handlers options_handlers_ ; <nl> - Handler error_handler_ ; <nl> - Logger logger_ ; <nl> - Expect100ContinueHandler expect_100_continue_handler_ ; <nl> - <nl> - bool tcp_nodelay_ = CPPHTTPLIB_TCP_NODELAY ; <nl> - SocketOptions socket_options_ = default_socket_options ; <nl> + public : <nl> + using Handler = std : : function < void ( const Request & , Response & ) > ; <nl> + using HandlerWithContentReader = <nl> + std : : function < void ( const Request & , Response & , const ContentReader & content_reader ) > ; <nl> + using Expect100ContinueHandler = std : : function < int ( const Request & , Response & ) > ; <nl> + <nl> + Server ( ) ; <nl> + <nl> + virtual ~ Server ( ) ; <nl> + <nl> + virtual bool is_valid ( ) const ; <nl> + <nl> + Server & Get ( const char * pattern , Handler handler ) ; <nl> + Server & Post ( const char * pattern , Handler handler ) ; <nl> + Server & Post ( const char * pattern , HandlerWithContentReader handler ) ; <nl> + Server & Put ( const char * pattern , Handler handler ) ; <nl> + Server & Put ( const char * pattern , HandlerWithContentReader handler ) ; <nl> + Server & Patch ( const char * pattern , Handler handler ) ; <nl> + Server & Patch ( const char * pattern , HandlerWithContentReader handler ) ; <nl> + Server & Delete ( const char * pattern , Handler handler ) ; <nl> + Server & Delete ( const char * pattern , HandlerWithContentReader handler ) ; <nl> + Server & Options ( const char * pattern , Handler handler ) ; <nl> + <nl> + CPPHTTPLIB_DEPRECATED bool set_base_dir ( const char * dir , const char * mount_point = nullptr ) ; <nl> + bool set_mount_point ( const char * mount_point , const char * dir ) ; <nl> + bool remove_mount_point ( const char * mount_point ) ; <nl> + void set_file_extension_and_mimetype_mapping ( const char * ext , const char * mime ) ; <nl> + void set_file_request_handler ( Handler handler ) ; <nl> + <nl> + void set_error_handler ( Handler handler ) ; <nl> + void set_expect_100_continue_handler ( Expect100ContinueHandler handler ) ; <nl> + void set_logger ( Logger logger ) ; <nl> + <nl> + void set_tcp_nodelay ( bool on ) ; <nl> + void set_socket_options ( SocketOptions socket_options ) ; <nl> + <nl> + void set_keep_alive_max_count ( size_t count ) ; <nl> + void set_read_timeout ( time_t sec , time_t usec = 0 ) ; <nl> + void set_write_timeout ( time_t sec , time_t usec = 0 ) ; <nl> + void set_idle_interval ( time_t sec , time_t usec = 0 ) ; <nl> + <nl> + void set_payload_max_length ( size_t length ) ; <nl> + <nl> + bool bind_to_port ( const char * host , int port , int socket_flags = 0 ) ; <nl> + int bind_to_any_port ( const char * host , int socket_flags = 0 ) ; <nl> + bool listen_after_bind ( ) ; <nl> + <nl> + bool listen ( const char * host , int port , int socket_flags = 0 ) ; <nl> + <nl> + bool is_running ( ) const ; <nl> + void stop ( ) ; <nl> + <nl> + protected : <nl> + bool process_request ( Stream & strm , <nl> + bool close_connection , <nl> + bool & connection_closed , <nl> + const std : : function < void ( Request & ) > & setup_request ) ; <nl> + <nl> + Socket * svr_sock_ ; <nl> + size_t keep_alive_max_count_ = CPPHTTPLIB_KEEPALIVE_MAX_COUNT ; <nl> + time_t read_timeout_sec_ = CPPHTTPLIB_READ_TIMEOUT_SECOND ; <nl> + time_t read_timeout_usec_ = CPPHTTPLIB_READ_TIMEOUT_USECOND ; <nl> + time_t write_timeout_sec_ = CPPHTTPLIB_WRITE_TIMEOUT_SECOND ; <nl> + time_t write_timeout_usec_ = CPPHTTPLIB_WRITE_TIMEOUT_USECOND ; <nl> + time_t idle_interval_sec_ = CPPHTTPLIB_IDLE_INTERVAL_SECOND ; <nl> + time_t idle_interval_usec_ = CPPHTTPLIB_IDLE_INTERVAL_USECOND ; <nl> + size_t payload_max_length_ = CPPHTTPLIB_PAYLOAD_MAX_LENGTH ; <nl> + <nl> + private : <nl> + using Handlers = std : : vector < std : : pair < std : : regex , Handler > > ; <nl> + using HandlersForContentReader = std : : vector < std : : pair < std : : regex , HandlerWithContentReader > > ; <nl> + <nl> + Socket * create_server_socket ( const char * host , int port , int socket_flags , SocketOptions socket_options ) const ; <nl> + int bind_internal ( const char * host , int port , int socket_flags ) ; <nl> + bool listen_internal ( ) ; <nl> + <nl> + bool routing ( Request & req , Response & res , Stream & strm ) ; <nl> + bool handle_file_request ( Request & req , Response & res , bool head = false ) ; <nl> + bool dispatch_request ( Request & req , Response & res , Handlers & handlers ) ; <nl> + bool dispatch_request_for_content_reader ( Request & req , <nl> + Response & res , <nl> + ContentReader content_reader , <nl> + HandlersForContentReader & handlers ) ; <nl> + <nl> + bool parse_request_line ( const char * s , Request & req ) ; <nl> + bool write_response ( Stream & strm , bool close_connection , const Request & req , Response & res ) ; <nl> + bool write_content_with_provider ( <nl> + Stream & strm , const Request & req , Response & res , const std : : string & boundary , const std : : string & content_type ) ; <nl> + bool read_content ( Stream & strm , Request & req , Response & res ) ; <nl> + bool read_content_with_content_receiver ( Stream & strm , <nl> + Request & req , <nl> + Response & res , <nl> + ContentReceiver receiver , <nl> + MultipartContentHeader multipart_header , <nl> + ContentReceiver multipart_receiver ) ; <nl> + bool read_content_core ( Stream & strm , <nl> + Request & req , <nl> + Response & res , <nl> + ContentReceiver receiver , <nl> + MultipartContentHeader mulitpart_header , <nl> + ContentReceiver multipart_receiver ) ; <nl> + <nl> + virtual bool process_and_close_socket ( Socket * sock ) ; <nl> + <nl> + std : : atomic < bool > is_running_ ; <nl> + std : : vector < std : : pair < std : : string , std : : string > > base_dirs_ ; <nl> + std : : map < std : : string , std : : string > file_extension_and_mimetype_map_ ; <nl> + Handler file_request_handler_ ; <nl> + Handlers get_handlers_ ; <nl> + Handlers post_handlers_ ; <nl> + HandlersForContentReader post_handlers_for_content_reader_ ; <nl> + Handlers put_handlers_ ; <nl> + HandlersForContentReader put_handlers_for_content_reader_ ; <nl> + Handlers patch_handlers_ ; <nl> + HandlersForContentReader patch_handlers_for_content_reader_ ; <nl> + Handlers delete_handlers_ ; <nl> + HandlersForContentReader delete_handlers_for_content_reader_ ; <nl> + Handlers options_handlers_ ; <nl> + Handler error_handler_ ; <nl> + Logger logger_ ; <nl> + Expect100ContinueHandler expect_100_continue_handler_ ; <nl> + <nl> + bool tcp_nodelay_ = CPPHTTPLIB_TCP_NODELAY ; <nl> + SocketOptions socket_options_ = default_socket_options ; <nl> } ; <nl> <nl> / / HTTP server implementation <nl> inline Server : : Server ( ) : svr_sock_ ( nullptr ) , is_running_ ( false ) { <nl> # ifndef _WIN32 <nl> - signal ( SIGPIPE , SIG_IGN ) ; <nl> + signal ( SIGPIPE , SIG_IGN ) ; <nl> # endif <nl> } <nl> <nl> inline Server : : ~ Server ( ) { <nl> } <nl> <nl> inline Server & Server : : Get ( const char * pattern , Handler handler ) { <nl> - get_handlers_ . push_back ( std : : make_pair ( std : : regex ( pattern ) , handler ) ) ; <nl> - return * this ; <nl> + get_handlers_ . push_back ( std : : make_pair ( std : : regex ( pattern ) , handler ) ) ; <nl> + return * this ; <nl> } <nl> <nl> inline Server & Server : : Post ( const char * pattern , Handler handler ) { <nl> - post_handlers_ . push_back ( std : : make_pair ( std : : regex ( pattern ) , handler ) ) ; <nl> - return * this ; <nl> + post_handlers_ . push_back ( std : : make_pair ( std : : regex ( pattern ) , handler ) ) ; <nl> + return * this ; <nl> } <nl> <nl> - inline Server & Server : : Post ( const char * pattern , <nl> - HandlerWithContentReader handler ) { <nl> - post_handlers_for_content_reader_ . push_back ( <nl> - std : : make_pair ( std : : regex ( pattern ) , handler ) ) ; <nl> - return * this ; <nl> + inline Server & Server : : Post ( const char * pattern , HandlerWithContentReader handler ) { <nl> + post_handlers_for_content_reader_ . push_back ( std : : make_pair ( std : : regex ( pattern ) , handler ) ) ; <nl> + return * this ; <nl> } <nl> <nl> inline Server & Server : : Put ( const char * pattern , Handler handler ) { <nl> - put_handlers_ . push_back ( std : : make_pair ( std : : regex ( pattern ) , handler ) ) ; <nl> - return * this ; <nl> + put_handlers_ . push_back ( std : : make_pair ( std : : regex ( pattern ) , handler ) ) ; <nl> + return * this ; <nl> } <nl> <nl> - inline Server & Server : : Put ( const char * pattern , <nl> - HandlerWithContentReader handler ) { <nl> - put_handlers_for_content_reader_ . push_back ( <nl> - std : : make_pair ( std : : regex ( pattern ) , handler ) ) ; <nl> - return * this ; <nl> + inline Server & Server : : Put ( const char * pattern , HandlerWithContentReader handler ) { <nl> + put_handlers_for_content_reader_ . push_back ( std : : make_pair ( std : : regex ( pattern ) , handler ) ) ; <nl> + return * this ; <nl> } <nl> <nl> inline Server & Server : : Patch ( const char * pattern , Handler handler ) { <nl> - patch_handlers_ . push_back ( std : : make_pair ( std : : regex ( pattern ) , handler ) ) ; <nl> - return * this ; <nl> + patch_handlers_ . push_back ( std : : make_pair ( std : : regex ( pattern ) , handler ) ) ; <nl> + return * this ; <nl> } <nl> <nl> - inline Server & Server : : Patch ( const char * pattern , <nl> - HandlerWithContentReader handler ) { <nl> - patch_handlers_for_content_reader_ . push_back ( <nl> - std : : make_pair ( std : : regex ( pattern ) , handler ) ) ; <nl> - return * this ; <nl> + inline Server & Server : : Patch ( const char * pattern , HandlerWithContentReader handler ) { <nl> + patch_handlers_for_content_reader_ . push_back ( std : : make_pair ( std : : regex ( pattern ) , handler ) ) ; <nl> + return * this ; <nl> } <nl> <nl> inline Server & Server : : Delete ( const char * pattern , Handler handler ) { <nl> - delete_handlers_ . push_back ( std : : make_pair ( std : : regex ( pattern ) , handler ) ) ; <nl> - return * this ; <nl> + delete_handlers_ . push_back ( std : : make_pair ( std : : regex ( pattern ) , handler ) ) ; <nl> + return * this ; <nl> } <nl> <nl> - inline Server & Server : : Delete ( const char * pattern , <nl> - HandlerWithContentReader handler ) { <nl> - delete_handlers_for_content_reader_ . push_back ( <nl> - std : : make_pair ( std : : regex ( pattern ) , handler ) ) ; <nl> - return * this ; <nl> + inline Server & Server : : Delete ( const char * pattern , HandlerWithContentReader handler ) { <nl> + delete_handlers_for_content_reader_ . push_back ( std : : make_pair ( std : : regex ( pattern ) , handler ) ) ; <nl> + return * this ; <nl> } <nl> <nl> inline Server & Server : : Options ( const char * pattern , Handler handler ) { <nl> - options_handlers_ . push_back ( std : : make_pair ( std : : regex ( pattern ) , handler ) ) ; <nl> - return * this ; <nl> + options_handlers_ . push_back ( std : : make_pair ( std : : regex ( pattern ) , handler ) ) ; <nl> + return * this ; <nl> } <nl> <nl> inline bool Server : : set_base_dir ( const char * dir , const char * mount_point ) { <nl> - return set_mount_point ( mount_point , dir ) ; <nl> + return set_mount_point ( mount_point , dir ) ; <nl> } <nl> <nl> inline bool Server : : set_mount_point ( const char * mount_point , const char * dir ) { <nl> - if ( detail : : is_dir ( dir ) ) { <nl> - std : : string mnt = mount_point ? mount_point : " / " ; <nl> - if ( ! mnt . empty ( ) & & mnt [ 0 ] = = ' / ' ) { <nl> - base_dirs_ . emplace_back ( mnt , dir ) ; <nl> - return true ; <nl> + if ( detail : : is_dir ( dir ) ) { <nl> + std : : string mnt = mount_point ? mount_point : " / " ; <nl> + if ( ! mnt . empty ( ) & & mnt [ 0 ] = = ' / ' ) { <nl> + base_dirs_ . emplace_back ( mnt , dir ) ; <nl> + return true ; <nl> + } <nl> } <nl> - } <nl> - return false ; <nl> + return false ; <nl> } <nl> <nl> inline bool Server : : remove_mount_point ( const char * mount_point ) { <nl> - for ( auto it = base_dirs_ . begin ( ) ; it ! = base_dirs_ . end ( ) ; + + it ) { <nl> - if ( it - > first = = mount_point ) { <nl> - base_dirs_ . erase ( it ) ; <nl> - return true ; <nl> + for ( auto it = base_dirs_ . begin ( ) ; it ! = base_dirs_ . end ( ) ; + + it ) { <nl> + if ( it - > first = = mount_point ) { <nl> + base_dirs_ . erase ( it ) ; <nl> + return true ; <nl> + } <nl> } <nl> - } <nl> - return false ; <nl> + return false ; <nl> } <nl> <nl> - inline void Server : : set_file_extension_and_mimetype_mapping ( const char * ext , <nl> - const char * mime ) { <nl> - file_extension_and_mimetype_map_ [ ext ] = mime ; <nl> + inline void Server : : set_file_extension_and_mimetype_mapping ( const char * ext , const char * mime ) { <nl> + file_extension_and_mimetype_map_ [ ext ] = mime ; <nl> } <nl> <nl> inline void Server : : set_file_request_handler ( Handler handler ) { <nl> - file_request_handler_ = std : : move ( handler ) ; <nl> + file_request_handler_ = std : : move ( handler ) ; <nl> } <nl> <nl> inline void Server : : set_error_handler ( Handler handler ) { <nl> - error_handler_ = std : : move ( handler ) ; <nl> + error_handler_ = std : : move ( handler ) ; <nl> } <nl> <nl> - inline void Server : : set_tcp_nodelay ( bool on ) { tcp_nodelay_ = on ; } <nl> + inline void Server : : set_tcp_nodelay ( bool on ) { <nl> + tcp_nodelay_ = on ; <nl> + } <nl> <nl> inline void Server : : set_socket_options ( SocketOptions socket_options ) { <nl> - socket_options_ = socket_options ; <nl> + socket_options_ = socket_options ; <nl> } <nl> <nl> - inline void Server : : set_logger ( Logger logger ) { logger_ = std : : move ( logger ) ; } <nl> + inline void Server : : set_logger ( Logger logger ) { <nl> + logger_ = std : : move ( logger ) ; <nl> + } <nl> <nl> - inline void <nl> - Server : : set_expect_100_continue_handler ( Expect100ContinueHandler handler ) { <nl> - expect_100_continue_handler_ = std : : move ( handler ) ; <nl> + inline void Server : : set_expect_100_continue_handler ( Expect100ContinueHandler handler ) { <nl> + expect_100_continue_handler_ = std : : move ( handler ) ; <nl> } <nl> <nl> inline void Server : : set_keep_alive_max_count ( size_t count ) { <nl> - keep_alive_max_count_ = count ; <nl> + keep_alive_max_count_ = count ; <nl> } <nl> <nl> inline void Server : : set_read_timeout ( time_t sec , time_t usec ) { <nl> - read_timeout_sec_ = sec ; <nl> - read_timeout_usec_ = usec ; <nl> + read_timeout_sec_ = sec ; <nl> + read_timeout_usec_ = usec ; <nl> } <nl> <nl> inline void Server : : set_write_timeout ( time_t sec , time_t usec ) { <nl> - write_timeout_sec_ = sec ; <nl> - write_timeout_usec_ = usec ; <nl> + write_timeout_sec_ = sec ; <nl> + write_timeout_usec_ = usec ; <nl> } <nl> <nl> inline void Server : : set_idle_interval ( time_t sec , time_t usec ) { <nl> - idle_interval_sec_ = sec ; <nl> - idle_interval_usec_ = usec ; <nl> + idle_interval_sec_ = sec ; <nl> + idle_interval_usec_ = usec ; <nl> } <nl> <nl> inline void Server : : set_payload_max_length ( size_t length ) { <nl> - payload_max_length_ = length ; <nl> + payload_max_length_ = length ; <nl> } <nl> <nl> inline bool Server : : bind_to_port ( const char * host , int port , int socket_flags ) { <nl> - if ( bind_internal ( host , port , socket_flags ) < 0 ) return false ; <nl> - return true ; <nl> + if ( bind_internal ( host , port , socket_flags ) < 0 ) return false ; <nl> + return true ; <nl> } <nl> inline int Server : : bind_to_any_port ( const char * host , int socket_flags ) { <nl> - return bind_internal ( host , 0 , socket_flags ) ; <nl> + return bind_internal ( host , 0 , socket_flags ) ; <nl> } <nl> <nl> - inline bool Server : : listen_after_bind ( ) { return listen_internal ( ) ; } <nl> + inline bool Server : : listen_after_bind ( ) { <nl> + return listen_internal ( ) ; <nl> + } <nl> <nl> inline bool Server : : listen ( const char * host , int port , int socket_flags ) { <nl> - return bind_to_port ( host , port , socket_flags ) & & listen_internal ( ) ; <nl> + return bind_to_port ( host , port , socket_flags ) & & listen_internal ( ) ; <nl> } <nl> <nl> - inline bool Server : : is_running ( ) const { return is_running_ ; } <nl> + inline bool Server : : is_running ( ) const { <nl> + return is_running_ ; <nl> + } <nl> <nl> inline void Server : : stop ( ) { <nl> if ( is_running_ ) { <nl> inline void Server : : stop ( ) { <nl> } <nl> <nl> inline bool Server : : parse_request_line ( const char * s , Request & req ) { <nl> - const static std : : regex re ( <nl> - " ( GET | HEAD | POST | PUT | DELETE | CONNECT | OPTIONS | TRACE | PATCH | PRI ) " <nl> - " ( ( [ ^ ? ] + ) ( ? : \ \ ? ( . * ? ) ) ? ) ( HTTP / 1 \ \ . [ 01 ] ) \ r \ n " ) ; <nl> - <nl> - std : : cmatch m ; <nl> - if ( std : : regex_match ( s , m , re ) ) { <nl> - req . version = std : : string ( m [ 5 ] ) ; <nl> - req . method = std : : string ( m [ 1 ] ) ; <nl> - req . target = std : : string ( m [ 2 ] ) ; <nl> - req . path = detail : : decode_url ( m [ 3 ] , false ) ; <nl> - <nl> - / / Parse query text <nl> - auto len = std : : distance ( m [ 4 ] . first , m [ 4 ] . second ) ; <nl> - if ( len > 0 ) { detail : : parse_query_text ( m [ 4 ] , req . params ) ; } <nl> + const static std : : regex re ( " ( GET | HEAD | POST | PUT | DELETE | CONNECT | OPTIONS | TRACE | PATCH | PRI ) " <nl> + " ( ( [ ^ ? ] + ) ( ? : \ \ ? ( . * ? ) ) ? ) ( HTTP / 1 \ \ . [ 01 ] ) \ r \ n " ) ; <nl> + <nl> + std : : cmatch m ; <nl> + if ( std : : regex_match ( s , m , re ) ) { <nl> + req . version = std : : string ( m [ 5 ] ) ; <nl> + req . method = std : : string ( m [ 1 ] ) ; <nl> + req . target = std : : string ( m [ 2 ] ) ; <nl> + req . path = detail : : decode_url ( m [ 3 ] , false ) ; <nl> + <nl> + / / Parse query text <nl> + auto len = std : : distance ( m [ 4 ] . first , m [ 4 ] . second ) ; <nl> + if ( len > 0 ) { <nl> + detail : : parse_query_text ( m [ 4 ] , req . params ) ; <nl> + } <nl> <nl> - return true ; <nl> - } <nl> + return true ; <nl> + } <nl> <nl> - return false ; <nl> + return false ; <nl> } <nl> <nl> - inline bool Server : : write_response ( Stream & strm , bool close_connection , <nl> - const Request & req , Response & res ) { <nl> - assert ( res . status ! = - 1 ) ; <nl> + inline bool Server : : write_response ( Stream & strm , bool close_connection , const Request & req , Response & res ) { <nl> + assert ( res . status ! = - 1 ) ; <nl> <nl> - if ( 400 < = res . status & & error_handler_ ) { error_handler_ ( req , res ) ; } <nl> + if ( 400 < = res . status & & error_handler_ ) { <nl> + error_handler_ ( req , res ) ; <nl> + } <nl> <nl> - detail : : BufferStream bstrm ; <nl> + detail : : BufferStream bstrm ; <nl> <nl> - / / Response line <nl> - if ( ! bstrm . write_format ( " HTTP / 1 . 1 % d % s \ r \ n " , res . status , <nl> - detail : : status_message ( res . status ) ) ) { <nl> - return false ; <nl> - } <nl> + / / Response line <nl> + if ( ! bstrm . write_format ( " HTTP / 1 . 1 % d % s \ r \ n " , res . status , detail : : status_message ( res . status ) ) ) { <nl> + return false ; <nl> + } <nl> <nl> - / / Headers <nl> - if ( close_connection | | req . get_header_value ( " Connection " ) = = " close " ) { <nl> - res . set_header ( " Connection " , " close " ) ; <nl> - } <nl> + / / Headers <nl> + if ( close_connection | | req . get_header_value ( " Connection " ) = = " close " ) { <nl> + res . set_header ( " Connection " , " close " ) ; <nl> + } <nl> <nl> - if ( ! close_connection & & req . get_header_value ( " Connection " ) = = " Keep - Alive " ) { <nl> - res . set_header ( " Connection " , " Keep - Alive " ) ; <nl> - } <nl> + if ( ! close_connection & & req . get_header_value ( " Connection " ) = = " Keep - Alive " ) { <nl> + res . set_header ( " Connection " , " Keep - Alive " ) ; <nl> + } <nl> <nl> - if ( ! res . has_header ( " Content - Type " ) & & <nl> - ( ! res . body . empty ( ) | | res . content_length_ > 0 ) ) { <nl> - res . set_header ( " Content - Type " , " text / plain " ) ; <nl> - } <nl> + if ( ! res . has_header ( " Content - Type " ) & & ( ! res . body . empty ( ) | | res . content_length_ > 0 ) ) { <nl> + res . set_header ( " Content - Type " , " text / plain " ) ; <nl> + } <nl> <nl> - if ( ! res . has_header ( " Accept - Ranges " ) & & req . method = = " HEAD " ) { <nl> - res . set_header ( " Accept - Ranges " , " bytes " ) ; <nl> - } <nl> + if ( ! res . has_header ( " Accept - Ranges " ) & & req . method = = " HEAD " ) { <nl> + res . set_header ( " Accept - Ranges " , " bytes " ) ; <nl> + } <nl> <nl> - std : : string content_type ; <nl> - std : : string boundary ; <nl> + std : : string content_type ; <nl> + std : : string boundary ; <nl> <nl> - if ( req . ranges . size ( ) > 1 ) { <nl> - boundary = detail : : make_multipart_data_boundary ( ) ; <nl> + if ( req . ranges . size ( ) > 1 ) { <nl> + boundary = detail : : make_multipart_data_boundary ( ) ; <nl> <nl> - auto it = res . headers . find ( " Content - Type " ) ; <nl> - if ( it ! = res . headers . end ( ) ) { <nl> - content_type = it - > second ; <nl> - res . headers . erase ( it ) ; <nl> - } <nl> + auto it = res . headers . find ( " Content - Type " ) ; <nl> + if ( it ! = res . headers . end ( ) ) { <nl> + content_type = it - > second ; <nl> + res . headers . erase ( it ) ; <nl> + } <nl> <nl> - res . headers . emplace ( " Content - Type " , <nl> - " multipart / byteranges ; boundary = " + boundary ) ; <nl> - } <nl> - <nl> - if ( res . body . empty ( ) ) { <nl> - if ( res . content_length_ > 0 ) { <nl> - size_t length = 0 ; <nl> - if ( req . ranges . empty ( ) ) { <nl> - length = res . content_length_ ; <nl> - } else if ( req . ranges . size ( ) = = 1 ) { <nl> - auto offsets = <nl> - detail : : get_range_offset_and_length ( req , res . content_length_ , 0 ) ; <nl> - auto offset = offsets . first ; <nl> - length = offsets . second ; <nl> - auto content_range = detail : : make_content_range_header_field ( <nl> - offset , length , res . content_length_ ) ; <nl> - res . set_header ( " Content - Range " , content_range ) ; <nl> - } else { <nl> - length = detail : : get_multipart_ranges_data_length ( req , res , boundary , <nl> - content_type ) ; <nl> - } <nl> - res . set_header ( " Content - Length " , std : : to_string ( length ) ) ; <nl> - } else { <nl> - if ( res . content_provider_ ) { <nl> - res . set_header ( " Transfer - Encoding " , " chunked " ) ; <nl> - } else { <nl> - res . set_header ( " Content - Length " , " 0 " ) ; <nl> - } <nl> + res . headers . emplace ( " Content - Type " , " multipart / byteranges ; boundary = " + boundary ) ; <nl> } <nl> - } else { <nl> - if ( req . ranges . empty ( ) ) { <nl> - ; <nl> - } else if ( req . ranges . size ( ) = = 1 ) { <nl> - auto offsets = <nl> - detail : : get_range_offset_and_length ( req , res . body . size ( ) , 0 ) ; <nl> - auto offset = offsets . first ; <nl> - auto length = offsets . second ; <nl> - auto content_range = detail : : make_content_range_header_field ( <nl> - offset , length , res . body . size ( ) ) ; <nl> - res . set_header ( " Content - Range " , content_range ) ; <nl> - res . body = res . body . substr ( offset , length ) ; <nl> + <nl> + if ( res . body . empty ( ) ) { <nl> + if ( res . content_length_ > 0 ) { <nl> + size_t length = 0 ; <nl> + if ( req . ranges . empty ( ) ) { <nl> + length = res . content_length_ ; <nl> + } else if ( req . ranges . size ( ) = = 1 ) { <nl> + auto offsets = detail : : get_range_offset_and_length ( req , res . content_length_ , 0 ) ; <nl> + auto offset = offsets . first ; <nl> + length = offsets . second ; <nl> + auto content_range = detail : : make_content_range_header_field ( offset , length , res . content_length_ ) ; <nl> + res . set_header ( " Content - Range " , content_range ) ; <nl> + } else { <nl> + length = detail : : get_multipart_ranges_data_length ( req , res , boundary , content_type ) ; <nl> + } <nl> + res . set_header ( " Content - Length " , std : : to_string ( length ) ) ; <nl> + } else { <nl> + if ( res . content_provider_ ) { <nl> + res . set_header ( " Transfer - Encoding " , " chunked " ) ; <nl> + } else { <nl> + res . set_header ( " Content - Length " , " 0 " ) ; <nl> + } <nl> + } <nl> } else { <nl> - res . body = <nl> - detail : : make_multipart_ranges_data ( req , res , boundary , content_type ) ; <nl> - } <nl> + if ( req . ranges . empty ( ) ) { <nl> + ; <nl> + } else if ( req . ranges . size ( ) = = 1 ) { <nl> + auto offsets = detail : : get_range_offset_and_length ( req , res . body . size ( ) , 0 ) ; <nl> + auto offset = offsets . first ; <nl> + auto length = offsets . second ; <nl> + auto content_range = detail : : make_content_range_header_field ( offset , length , res . body . size ( ) ) ; <nl> + res . set_header ( " Content - Range " , content_range ) ; <nl> + res . body = res . body . substr ( offset , length ) ; <nl> + } else { <nl> + res . body = detail : : make_multipart_ranges_data ( req , res , boundary , content_type ) ; <nl> + } <nl> <nl> # ifdef CPPHTTPLIB_ZLIB_SUPPORT <nl> - / / TODO : ' Accept - Encoding ' has gzip , not gzip ; q = 0 <nl> - const auto & encodings = req . get_header_value ( " Accept - Encoding " ) ; <nl> - if ( encodings . find ( " gzip " ) ! = std : : string : : npos & & <nl> - detail : : can_compress ( res . get_header_value ( " Content - Type " ) ) ) { <nl> - if ( detail : : compress ( res . body ) ) { <nl> - res . set_header ( " Content - Encoding " , " gzip " ) ; <nl> - } <nl> - } <nl> + / / TODO : ' Accept - Encoding ' has gzip , not gzip ; q = 0 <nl> + const auto & encodings = req . get_header_value ( " Accept - Encoding " ) ; <nl> + if ( encodings . find ( " gzip " ) ! = std : : string : : npos & & detail : : can_compress ( res . get_header_value ( " Content - Type " ) ) ) { <nl> + if ( detail : : compress ( res . body ) ) { <nl> + res . set_header ( " Content - Encoding " , " gzip " ) ; <nl> + } <nl> + } <nl> # endif <nl> <nl> - auto length = std : : to_string ( res . body . size ( ) ) ; <nl> - res . set_header ( " Content - Length " , length ) ; <nl> - } <nl> - <nl> - if ( ! detail : : write_headers ( bstrm , res , Headers ( ) ) ) { return false ; } <nl> - <nl> - / / Flush buffer <nl> - auto & data = bstrm . get_buffer ( ) ; <nl> - strm . write ( data . data ( ) , data . size ( ) ) ; <nl> + auto length = std : : to_string ( res . body . size ( ) ) ; <nl> + res . set_header ( " Content - Length " , length ) ; <nl> + } <nl> <nl> - / / Body <nl> - if ( req . method ! = " HEAD " ) { <nl> - if ( ! res . body . empty ( ) ) { <nl> - if ( ! strm . write ( res . body ) ) { return false ; } <nl> - } else if ( res . content_provider_ ) { <nl> - if ( ! write_content_with_provider ( strm , req , res , boundary , <nl> - content_type ) ) { <nl> + if ( ! detail : : write_headers ( bstrm , res , Headers ( ) ) ) { <nl> return false ; <nl> - } <nl> } <nl> - } <nl> <nl> - / / Log <nl> - if ( logger_ ) { logger_ ( req , res ) ; } <nl> + / / Flush buffer <nl> + auto & data = bstrm . get_buffer ( ) ; <nl> + strm . write ( data . data ( ) , data . size ( ) ) ; <nl> + <nl> + / / Body <nl> + if ( req . method ! = " HEAD " ) { <nl> + if ( ! res . body . empty ( ) ) { <nl> + if ( ! strm . write ( res . body ) ) { <nl> + return false ; <nl> + } <nl> + } else if ( res . content_provider_ ) { <nl> + if ( ! write_content_with_provider ( strm , req , res , boundary , content_type ) ) { <nl> + return false ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + / / Log <nl> + if ( logger_ ) { <nl> + logger_ ( req , res ) ; <nl> + } <nl> <nl> - return true ; <nl> + return true ; <nl> } <nl> <nl> - inline bool <nl> - Server : : write_content_with_provider ( Stream & strm , const Request & req , <nl> - Response & res , const std : : string & boundary , <nl> - const std : : string & content_type ) { <nl> - auto is_shutting_down = [ this ] ( ) { <nl> - return this - > svr_sock_ = = nullptr ; <nl> - } ; <nl> - <nl> - if ( res . content_length_ ) { <nl> - if ( req . ranges . empty ( ) ) { <nl> - if ( detail : : write_content ( strm , res . content_provider_ , 0 , <nl> - res . content_length_ , is_shutting_down ) < 0 ) { <nl> - return false ; <nl> - } <nl> - } else if ( req . ranges . size ( ) = = 1 ) { <nl> - auto offsets = <nl> - detail : : get_range_offset_and_length ( req , res . content_length_ , 0 ) ; <nl> - auto offset = offsets . first ; <nl> - auto length = offsets . second ; <nl> - if ( detail : : write_content ( strm , res . content_provider_ , offset , length , <nl> - is_shutting_down ) < 0 ) { <nl> - return false ; <nl> - } <nl> + inline bool Server : : write_content_with_provider ( <nl> + Stream & strm , const Request & req , Response & res , const std : : string & boundary , const std : : string & content_type ) { <nl> + auto is_shutting_down = [ this ] ( ) { return this - > svr_sock_ = = nullptr ; } ; <nl> + <nl> + if ( res . content_length_ ) { <nl> + if ( req . ranges . empty ( ) ) { <nl> + if ( detail : : write_content ( strm , res . content_provider_ , 0 , res . content_length_ , is_shutting_down ) < 0 ) { <nl> + return false ; <nl> + } <nl> + } else if ( req . ranges . size ( ) = = 1 ) { <nl> + auto offsets = detail : : get_range_offset_and_length ( req , res . content_length_ , 0 ) ; <nl> + auto offset = offsets . first ; <nl> + auto length = offsets . second ; <nl> + if ( detail : : write_content ( strm , res . content_provider_ , offset , length , is_shutting_down ) < 0 ) { <nl> + return false ; <nl> + } <nl> + } else { <nl> + if ( ! detail : : write_multipart_ranges_data ( strm , req , res , boundary , content_type , is_shutting_down ) ) { <nl> + return false ; <nl> + } <nl> + } <nl> } else { <nl> - if ( ! detail : : write_multipart_ranges_data ( <nl> - strm , req , res , boundary , content_type , is_shutting_down ) ) { <nl> - return false ; <nl> - } <nl> - } <nl> - } else { <nl> - if ( detail : : write_content_chunked ( strm , res . content_provider_ , <nl> - is_shutting_down ) < 0 ) { <nl> - return false ; <nl> + if ( detail : : write_content_chunked ( strm , res . content_provider_ , is_shutting_down ) < 0 ) { <nl> + return false ; <nl> + } <nl> } <nl> - } <nl> - return true ; <nl> + return true ; <nl> } <nl> <nl> inline bool Server : : read_content ( Stream & strm , Request & req , Response & res ) { <nl> - MultipartFormDataMap : : iterator cur ; <nl> - if ( read_content_core ( <nl> - strm , req , res , <nl> - / / Regular <nl> - [ & ] ( const char * buf , size_t n ) { <nl> - if ( req . body . size ( ) + n > req . body . max_size ( ) ) { return false ; } <nl> - req . body . append ( buf , n ) ; <nl> - return true ; <nl> - } , <nl> - / / Multipart <nl> - [ & ] ( const MultipartFormData & file ) { <nl> - cur = req . files . emplace ( file . name , file ) ; <nl> - return true ; <nl> - } , <nl> - [ & ] ( const char * buf , size_t n ) { <nl> - auto & content = cur - > second . content ; <nl> - if ( content . size ( ) + n > content . max_size ( ) ) { return false ; } <nl> - content . append ( buf , n ) ; <nl> - return true ; <nl> - } ) ) { <nl> - const auto & content_type = req . get_header_value ( " Content - Type " ) ; <nl> - if ( ! content_type . find ( " application / x - www - form - urlencoded " ) ) { <nl> - detail : : parse_query_text ( req . body , req . params ) ; <nl> + MultipartFormDataMap : : iterator cur ; <nl> + if ( read_content_core ( strm , <nl> + req , <nl> + res , <nl> + / / Regular <nl> + [ & ] ( const char * buf , size_t n ) { <nl> + if ( req . body . size ( ) + n > req . body . max_size ( ) ) { <nl> + return false ; <nl> + } <nl> + req . body . append ( buf , n ) ; <nl> + return true ; <nl> + } , <nl> + / / Multipart <nl> + [ & ] ( const MultipartFormData & file ) { <nl> + cur = req . files . emplace ( file . name , file ) ; <nl> + return true ; <nl> + } , <nl> + [ & ] ( const char * buf , size_t n ) { <nl> + auto & content = cur - > second . content ; <nl> + if ( content . size ( ) + n > content . max_size ( ) ) { <nl> + return false ; <nl> + } <nl> + content . append ( buf , n ) ; <nl> + return true ; <nl> + } ) ) { <nl> + const auto & content_type = req . get_header_value ( " Content - Type " ) ; <nl> + if ( ! content_type . find ( " application / x - www - form - urlencoded " ) ) { <nl> + detail : : parse_query_text ( req . body , req . params ) ; <nl> + } <nl> + return true ; <nl> } <nl> - return true ; <nl> - } <nl> - return false ; <nl> + return false ; <nl> } <nl> <nl> - inline bool Server : : read_content_with_content_receiver ( <nl> - Stream & strm , Request & req , Response & res , ContentReceiver receiver , <nl> - MultipartContentHeader multipart_header , <nl> - ContentReceiver multipart_receiver ) { <nl> - return read_content_core ( strm , req , res , receiver , multipart_header , <nl> - multipart_receiver ) ; <nl> + inline bool Server : : read_content_with_content_receiver ( Stream & strm , <nl> + Request & req , <nl> + Response & res , <nl> + ContentReceiver receiver , <nl> + MultipartContentHeader multipart_header , <nl> + ContentReceiver multipart_receiver ) { <nl> + return read_content_core ( strm , req , res , receiver , multipart_header , multipart_receiver ) ; <nl> } <nl> <nl> - inline bool Server : : read_content_core ( Stream & strm , Request & req , Response & res , <nl> + inline bool Server : : read_content_core ( Stream & strm , <nl> + Request & req , <nl> + Response & res , <nl> ContentReceiver receiver , <nl> MultipartContentHeader mulitpart_header , <nl> ContentReceiver multipart_receiver ) { <nl> - detail : : MultipartFormDataParser multipart_form_data_parser ; <nl> - ContentReceiver out ; <nl> + detail : : MultipartFormDataParser multipart_form_data_parser ; <nl> + ContentReceiver out ; <nl> + <nl> + if ( req . is_multipart_form_data ( ) ) { <nl> + const auto & content_type = req . get_header_value ( " Content - Type " ) ; <nl> + std : : string boundary ; <nl> + if ( ! detail : : parse_multipart_boundary ( content_type , boundary ) ) { <nl> + res . status = 400 ; <nl> + return false ; <nl> + } <nl> <nl> - if ( req . is_multipart_form_data ( ) ) { <nl> - const auto & content_type = req . get_header_value ( " Content - Type " ) ; <nl> - std : : string boundary ; <nl> - if ( ! detail : : parse_multipart_boundary ( content_type , boundary ) ) { <nl> - res . status = 400 ; <nl> - return false ; <nl> + multipart_form_data_parser . set_boundary ( std : : move ( boundary ) ) ; <nl> + out = [ & ] ( const char * buf , size_t n ) { <nl> + / * For debug <nl> + size_t pos = 0 ; <nl> + while ( pos < n ) { <nl> + auto read_size = std : : min < size_t > ( 1 , n - pos ) ; <nl> + auto ret = multipart_form_data_parser . parse ( <nl> + buf + pos , read_size , multipart_receiver , mulitpart_header ) ; <nl> + if ( ! ret ) { return false ; } <nl> + pos + = read_size ; <nl> + } <nl> + return true ; <nl> + * / <nl> + return multipart_form_data_parser . parse ( buf , n , multipart_receiver , mulitpart_header ) ; <nl> + } ; <nl> + } else { <nl> + out = receiver ; <nl> } <nl> <nl> - multipart_form_data_parser . set_boundary ( std : : move ( boundary ) ) ; <nl> - out = [ & ] ( const char * buf , size_t n ) { <nl> - / * For debug <nl> - size_t pos = 0 ; <nl> - while ( pos < n ) { <nl> - auto read_size = std : : min < size_t > ( 1 , n - pos ) ; <nl> - auto ret = multipart_form_data_parser . parse ( <nl> - buf + pos , read_size , multipart_receiver , mulitpart_header ) ; <nl> - if ( ! ret ) { return false ; } <nl> - pos + = read_size ; <nl> - } <nl> - return true ; <nl> - * / <nl> - return multipart_form_data_parser . parse ( buf , n , multipart_receiver , <nl> - mulitpart_header ) ; <nl> - } ; <nl> - } else { <nl> - out = receiver ; <nl> - } <nl> - <nl> - if ( ! detail : : read_content ( strm , req , payload_max_length_ , res . status , <nl> - Progress ( ) , out , true ) ) { <nl> - return false ; <nl> - } <nl> + if ( ! detail : : read_content ( strm , req , payload_max_length_ , res . status , Progress ( ) , out , true ) ) { <nl> + return false ; <nl> + } <nl> <nl> - if ( req . is_multipart_form_data ( ) ) { <nl> - if ( ! multipart_form_data_parser . is_valid ( ) ) { <nl> - res . status = 400 ; <nl> - return false ; <nl> + if ( req . is_multipart_form_data ( ) ) { <nl> + if ( ! multipart_form_data_parser . is_valid ( ) ) { <nl> + res . status = 400 ; <nl> + return false ; <nl> + } <nl> } <nl> - } <nl> <nl> - return true ; <nl> + return true ; <nl> } <nl> <nl> - inline bool Server : : handle_file_request ( Request & req , Response & res , <nl> - bool head ) { <nl> - for ( const auto & kv : base_dirs_ ) { <nl> - const auto & mount_point = kv . first ; <nl> - const auto & base_dir = kv . second ; <nl> - <nl> - / / Prefix match <nl> - if ( ! req . path . find ( mount_point ) ) { <nl> - std : : string sub_path = " / " + req . path . substr ( mount_point . size ( ) ) ; <nl> - if ( detail : : is_valid_path ( sub_path ) ) { <nl> - auto path = base_dir + sub_path ; <nl> - if ( path . back ( ) = = ' / ' ) { path + = " index . html " ; } <nl> - <nl> - if ( detail : : is_file ( path ) ) { <nl> - detail : : read_file ( path , res . body ) ; <nl> - auto type = <nl> - detail : : find_content_type ( path , file_extension_and_mimetype_map_ ) ; <nl> - if ( type ) { res . set_header ( " Content - Type " , type ) ; } <nl> - res . status = 200 ; <nl> - if ( ! head & & file_request_handler_ ) { <nl> - file_request_handler_ ( req , res ) ; <nl> - } <nl> - return true ; <nl> + inline bool Server : : handle_file_request ( Request & req , Response & res , bool head ) { <nl> + for ( const auto & kv : base_dirs_ ) { <nl> + const auto & mount_point = kv . first ; <nl> + const auto & base_dir = kv . second ; <nl> + <nl> + / / Prefix match <nl> + if ( ! req . path . find ( mount_point ) ) { <nl> + std : : string sub_path = " / " + req . path . substr ( mount_point . size ( ) ) ; <nl> + if ( detail : : is_valid_path ( sub_path ) ) { <nl> + auto path = base_dir + sub_path ; <nl> + if ( path . back ( ) = = ' / ' ) { <nl> + path + = " index . html " ; <nl> + } <nl> + <nl> + if ( detail : : is_file ( path ) ) { <nl> + detail : : read_file ( path , res . body ) ; <nl> + auto type = detail : : find_content_type ( path , file_extension_and_mimetype_map_ ) ; <nl> + if ( type ) { <nl> + res . set_header ( " Content - Type " , type ) ; <nl> + } <nl> + res . status = 200 ; <nl> + if ( ! head & & file_request_handler_ ) { <nl> + file_request_handler_ ( req , res ) ; <nl> + } <nl> + return true ; <nl> + } <nl> + } <nl> } <nl> - } <nl> } <nl> - } <nl> - return false ; <nl> + return false ; <nl> } <nl> <nl> - inline Socket * Server : : create_server_socket ( const char * host , int port , int socket_flags , <nl> + inline Socket * Server : : create_server_socket ( const char * host , <nl> + int port , <nl> + int socket_flags , <nl> SocketOptions socket_options ) const { <nl> - <nl> struct addrinfo hints ; <nl> struct addrinfo * result ; <nl> <nl> struct CoroutineArg { <nl> } ; <nl> <nl> inline bool Server : : listen_internal ( ) { <nl> - <nl> if ( ! svr_sock_ ) { <nl> return false ; <nl> } <nl> inline bool Server : : listen_internal ( ) { <nl> auto arg = new CoroutineArg ; <nl> arg - > client_socket = client_sock ; <nl> arg - > this_ = this ; <nl> - Coroutine : : create ( [ ] ( void * arg ) { <nl> - CoroutineArg * _arg = ( CoroutineArg * ) arg ; <nl> - _arg - > this_ - > process_and_close_socket ( _arg - > client_socket ) ; <nl> - delete _arg ; <nl> - } , arg ) ; <nl> + Coroutine : : create ( <nl> + [ ] ( void * arg ) { <nl> + CoroutineArg * _arg = ( CoroutineArg * ) arg ; <nl> + _arg - > this_ - > process_and_close_socket ( _arg - > client_socket ) ; <nl> + delete _arg ; <nl> + } , <nl> + arg ) ; <nl> continue ; <nl> } <nl> if ( svr_sock_ - > errCode = = EMFILE | | svr_sock_ - > errCode = = ENFILE ) { <nl> inline bool Server : : listen_internal ( ) { <nl> } <nl> <nl> inline bool Server : : routing ( Request & req , Response & res , Stream & strm ) { <nl> - / / File handler <nl> - bool is_head_request = req . method = = " HEAD " ; <nl> - if ( ( req . method = = " GET " | | is_head_request ) & & <nl> - handle_file_request ( req , res , is_head_request ) ) { <nl> - return true ; <nl> - } <nl> - <nl> - if ( detail : : expect_content ( req ) ) { <nl> - / / Content reader handler <nl> - { <nl> - ContentReader reader ( <nl> - [ & ] ( ContentReceiver receiver ) { <nl> - return read_content_with_content_receiver ( strm , req , res , receiver , <nl> - nullptr , nullptr ) ; <nl> - } , <nl> - [ & ] ( MultipartContentHeader header , ContentReceiver receiver ) { <nl> - return read_content_with_content_receiver ( strm , req , res , nullptr , <nl> - header , receiver ) ; <nl> - } ) ; <nl> - <nl> - if ( req . method = = " POST " ) { <nl> - if ( dispatch_request_for_content_reader ( <nl> - req , res , reader , post_handlers_for_content_reader_ ) ) { <nl> - return true ; <nl> - } <nl> - } else if ( req . method = = " PUT " ) { <nl> - if ( dispatch_request_for_content_reader ( <nl> - req , res , reader , put_handlers_for_content_reader_ ) ) { <nl> - return true ; <nl> - } <nl> - } else if ( req . method = = " PATCH " ) { <nl> - if ( dispatch_request_for_content_reader ( <nl> - req , res , reader , patch_handlers_for_content_reader_ ) ) { <nl> - return true ; <nl> + / / File handler <nl> + bool is_head_request = req . method = = " HEAD " ; <nl> + if ( ( req . method = = " GET " | | is_head_request ) & & handle_file_request ( req , res , is_head_request ) ) { <nl> + return true ; <nl> + } <nl> + <nl> + if ( detail : : expect_content ( req ) ) { <nl> + / / Content reader handler <nl> + { <nl> + ContentReader reader ( <nl> + [ & ] ( ContentReceiver receiver ) { <nl> + return read_content_with_content_receiver ( strm , req , res , receiver , nullptr , nullptr ) ; <nl> + } , <nl> + [ & ] ( MultipartContentHeader header , ContentReceiver receiver ) { <nl> + return read_content_with_content_receiver ( strm , req , res , nullptr , header , receiver ) ; <nl> + } ) ; <nl> + <nl> + if ( req . method = = " POST " ) { <nl> + if ( dispatch_request_for_content_reader ( req , res , reader , post_handlers_for_content_reader_ ) ) { <nl> + return true ; <nl> + } <nl> + } else if ( req . method = = " PUT " ) { <nl> + if ( dispatch_request_for_content_reader ( req , res , reader , put_handlers_for_content_reader_ ) ) { <nl> + return true ; <nl> + } <nl> + } else if ( req . method = = " PATCH " ) { <nl> + if ( dispatch_request_for_content_reader ( req , res , reader , patch_handlers_for_content_reader_ ) ) { <nl> + return true ; <nl> + } <nl> + } else if ( req . method = = " DELETE " ) { <nl> + if ( dispatch_request_for_content_reader ( req , res , reader , delete_handlers_for_content_reader_ ) ) { <nl> + return true ; <nl> + } <nl> + } <nl> } <nl> - } else if ( req . method = = " DELETE " ) { <nl> - if ( dispatch_request_for_content_reader ( <nl> - req , res , reader , delete_handlers_for_content_reader_ ) ) { <nl> - return true ; <nl> + <nl> + / / Read content into ` req . body ` <nl> + if ( ! read_content ( strm , req , res ) ) { <nl> + return false ; <nl> } <nl> - } <nl> } <nl> <nl> - / / Read content into ` req . body ` <nl> - if ( ! read_content ( strm , req , res ) ) { return false ; } <nl> - } <nl> - <nl> - / / Regular handler <nl> - if ( req . method = = " GET " | | req . method = = " HEAD " ) { <nl> - return dispatch_request ( req , res , get_handlers_ ) ; <nl> - } else if ( req . method = = " POST " ) { <nl> - return dispatch_request ( req , res , post_handlers_ ) ; <nl> - } else if ( req . method = = " PUT " ) { <nl> - return dispatch_request ( req , res , put_handlers_ ) ; <nl> - } else if ( req . method = = " DELETE " ) { <nl> - return dispatch_request ( req , res , delete_handlers_ ) ; <nl> - } else if ( req . method = = " OPTIONS " ) { <nl> - return dispatch_request ( req , res , options_handlers_ ) ; <nl> - } else if ( req . method = = " PATCH " ) { <nl> - return dispatch_request ( req , res , patch_handlers_ ) ; <nl> - } <nl> - <nl> - res . status = 400 ; <nl> - return false ; <nl> - } <nl> + / / Regular handler <nl> + if ( req . method = = " GET " | | req . method = = " HEAD " ) { <nl> + return dispatch_request ( req , res , get_handlers_ ) ; <nl> + } else if ( req . method = = " POST " ) { <nl> + return dispatch_request ( req , res , post_handlers_ ) ; <nl> + } else if ( req . method = = " PUT " ) { <nl> + return dispatch_request ( req , res , put_handlers_ ) ; <nl> + } else if ( req . method = = " DELETE " ) { <nl> + return dispatch_request ( req , res , delete_handlers_ ) ; <nl> + } else if ( req . method = = " OPTIONS " ) { <nl> + return dispatch_request ( req , res , options_handlers_ ) ; <nl> + } else if ( req . method = = " PATCH " ) { <nl> + return dispatch_request ( req , res , patch_handlers_ ) ; <nl> + } <nl> <nl> - inline bool Server : : dispatch_request ( Request & req , Response & res , <nl> - Handlers & handlers ) { <nl> + res . status = 400 ; <nl> + return false ; <nl> + } <nl> <nl> - try { <nl> - for ( const auto & x : handlers ) { <nl> - const auto & pattern = x . first ; <nl> - const auto & handler = x . second ; <nl> + inline bool Server : : dispatch_request ( Request & req , Response & res , Handlers & handlers ) { <nl> + try { <nl> + for ( const auto & x : handlers ) { <nl> + const auto & pattern = x . first ; <nl> + const auto & handler = x . second ; <nl> <nl> - if ( std : : regex_match ( req . path , req . matches , pattern ) ) { <nl> - handler ( req , res ) ; <nl> - return true ; <nl> - } <nl> + if ( std : : regex_match ( req . path , req . matches , pattern ) ) { <nl> + handler ( req , res ) ; <nl> + return true ; <nl> + } <nl> + } <nl> + } catch ( const std : : exception & ex ) { <nl> + res . status = 500 ; <nl> + res . set_header ( " EXCEPTION_WHAT " , ex . what ( ) ) ; <nl> + } catch ( . . . ) { <nl> + res . status = 500 ; <nl> + res . set_header ( " EXCEPTION_WHAT " , " UNKNOWN " ) ; <nl> } <nl> - } catch ( const std : : exception & ex ) { <nl> - res . status = 500 ; <nl> - res . set_header ( " EXCEPTION_WHAT " , ex . what ( ) ) ; <nl> - } catch ( . . . ) { <nl> - res . status = 500 ; <nl> - res . set_header ( " EXCEPTION_WHAT " , " UNKNOWN " ) ; <nl> - } <nl> - return false ; <nl> + return false ; <nl> } <nl> <nl> - inline bool Server : : dispatch_request_for_content_reader ( <nl> - Request & req , Response & res , ContentReader content_reader , <nl> - HandlersForContentReader & handlers ) { <nl> - for ( const auto & x : handlers ) { <nl> - const auto & pattern = x . first ; <nl> - const auto & handler = x . second ; <nl> + inline bool Server : : dispatch_request_for_content_reader ( Request & req , <nl> + Response & res , <nl> + ContentReader content_reader , <nl> + HandlersForContentReader & handlers ) { <nl> + for ( const auto & x : handlers ) { <nl> + const auto & pattern = x . first ; <nl> + const auto & handler = x . second ; <nl> <nl> - if ( std : : regex_match ( req . path , req . matches , pattern ) ) { <nl> - handler ( req , res , content_reader ) ; <nl> - return true ; <nl> + if ( std : : regex_match ( req . path , req . matches , pattern ) ) { <nl> + handler ( req , res , content_reader ) ; <nl> + return true ; <nl> + } <nl> } <nl> - } <nl> - return false ; <nl> + return false ; <nl> } <nl> <nl> - inline bool <nl> - Server : : process_request ( Stream & strm , bool close_connection , <nl> - bool & connection_closed , <nl> - const std : : function < void ( Request & ) > & setup_request ) { <nl> - std : : array < char , 2048 > buf { } ; <nl> + inline bool Server : : process_request ( Stream & strm , <nl> + bool close_connection , <nl> + bool & connection_closed , <nl> + const std : : function < void ( Request & ) > & setup_request ) { <nl> + std : : array < char , 2048 > buf { } ; <nl> <nl> - detail : : stream_line_reader line_reader ( strm , buf . data ( ) , buf . size ( ) ) ; <nl> + detail : : stream_line_reader line_reader ( strm , buf . data ( ) , buf . size ( ) ) ; <nl> <nl> - / / Connection has been closed on client <nl> - if ( ! line_reader . getline ( ) ) { return false ; } <nl> + / / Connection has been closed on client <nl> + if ( ! line_reader . getline ( ) ) { <nl> + return false ; <nl> + } <nl> <nl> - Request req ; <nl> - Response res ; <nl> + Request req ; <nl> + Response res ; <nl> <nl> - res . version = " HTTP / 1 . 1 " ; <nl> + res . version = " HTTP / 1 . 1 " ; <nl> <nl> - / / Check if the request URI doesn ' t exceed the limit <nl> - if ( line_reader . size ( ) > CPPHTTPLIB_REQUEST_URI_MAX_LENGTH ) { <nl> - Headers dummy ; <nl> - detail : : read_headers ( strm , dummy ) ; <nl> - res . status = 414 ; <nl> - return write_response ( strm , close_connection , req , res ) ; <nl> - } <nl> + / / Check if the request URI doesn ' t exceed the limit <nl> + if ( line_reader . size ( ) > CPPHTTPLIB_REQUEST_URI_MAX_LENGTH ) { <nl> + Headers dummy ; <nl> + detail : : read_headers ( strm , dummy ) ; <nl> + res . status = 414 ; <nl> + return write_response ( strm , close_connection , req , res ) ; <nl> + } <nl> <nl> - / / Request line and headers <nl> - if ( ! parse_request_line ( line_reader . ptr ( ) , req ) | | <nl> - ! detail : : read_headers ( strm , req . headers ) ) { <nl> - res . status = 400 ; <nl> - return write_response ( strm , close_connection , req , res ) ; <nl> - } <nl> + / / Request line and headers <nl> + if ( ! parse_request_line ( line_reader . ptr ( ) , req ) | | ! detail : : read_headers ( strm , req . headers ) ) { <nl> + res . status = 400 ; <nl> + return write_response ( strm , close_connection , req , res ) ; <nl> + } <nl> <nl> - if ( req . get_header_value ( " Connection " ) = = " close " ) { <nl> - connection_closed = true ; <nl> - } <nl> + if ( req . get_header_value ( " Connection " ) = = " close " ) { <nl> + connection_closed = true ; <nl> + } <nl> <nl> - if ( req . version = = " HTTP / 1 . 0 " & & <nl> - req . get_header_value ( " Connection " ) ! = " Keep - Alive " ) { <nl> - connection_closed = true ; <nl> - } <nl> + if ( req . version = = " HTTP / 1 . 0 " & & req . get_header_value ( " Connection " ) ! = " Keep - Alive " ) { <nl> + connection_closed = true ; <nl> + } <nl> <nl> - strm . get_remote_ip_and_port ( req . remote_addr , req . remote_port ) ; <nl> - req . set_header ( " REMOTE_ADDR " , req . remote_addr ) ; <nl> - req . set_header ( " REMOTE_PORT " , std : : to_string ( req . remote_port ) ) ; <nl> + strm . get_remote_ip_and_port ( req . remote_addr , req . remote_port ) ; <nl> + req . set_header ( " REMOTE_ADDR " , req . remote_addr ) ; <nl> + req . set_header ( " REMOTE_PORT " , std : : to_string ( req . remote_port ) ) ; <nl> <nl> - if ( req . has_header ( " Range " ) ) { <nl> - const auto & range_header_value = req . get_header_value ( " Range " ) ; <nl> - if ( ! detail : : parse_range_header ( range_header_value , req . ranges ) ) { <nl> - / / TODO : error <nl> + if ( req . has_header ( " Range " ) ) { <nl> + const auto & range_header_value = req . get_header_value ( " Range " ) ; <nl> + if ( ! detail : : parse_range_header ( range_header_value , req . ranges ) ) { <nl> + / / TODO : error <nl> + } <nl> } <nl> - } <nl> <nl> - if ( setup_request ) { setup_request ( req ) ; } <nl> - <nl> - if ( req . get_header_value ( " Expect " ) = = " 100 - continue " ) { <nl> - auto status = 100 ; <nl> - if ( expect_100_continue_handler_ ) { <nl> - status = expect_100_continue_handler_ ( req , res ) ; <nl> + if ( setup_request ) { <nl> + setup_request ( req ) ; <nl> } <nl> - switch ( status ) { <nl> - case 100 : <nl> - case 417 : <nl> - strm . write_format ( " HTTP / 1 . 1 % d % s \ r \ n \ r \ n " , status , <nl> - detail : : status_message ( status ) ) ; <nl> - break ; <nl> - default : return write_response ( strm , close_connection , req , res ) ; <nl> + <nl> + if ( req . get_header_value ( " Expect " ) = = " 100 - continue " ) { <nl> + auto status = 100 ; <nl> + if ( expect_100_continue_handler_ ) { <nl> + status = expect_100_continue_handler_ ( req , res ) ; <nl> + } <nl> + switch ( status ) { <nl> + case 100 : <nl> + case 417 : <nl> + strm . write_format ( " HTTP / 1 . 1 % d % s \ r \ n \ r \ n " , status , detail : : status_message ( status ) ) ; <nl> + break ; <nl> + default : <nl> + return write_response ( strm , close_connection , req , res ) ; <nl> + } <nl> } <nl> - } <nl> <nl> - / / Rounting <nl> - if ( routing ( req , res , strm ) ) { <nl> - if ( res . status = = - 1 ) { res . status = req . ranges . empty ( ) ? 200 : 206 ; } <nl> - } else { <nl> - if ( res . status = = - 1 ) { res . status = 404 ; } <nl> - } <nl> + / / Rounting <nl> + if ( routing ( req , res , strm ) ) { <nl> + if ( res . status = = - 1 ) { <nl> + res . status = req . ranges . empty ( ) ? 200 : 206 ; <nl> + } <nl> + } else { <nl> + if ( res . status = = - 1 ) { <nl> + res . status = 404 ; <nl> + } <nl> + } <nl> <nl> - return write_response ( strm , close_connection , req , res ) ; <nl> + return write_response ( strm , close_connection , req , res ) ; <nl> } <nl> <nl> - inline bool Server : : is_valid ( ) const { return true ; } <nl> + inline bool Server : : is_valid ( ) const { <nl> + return true ; <nl> + } <nl> <nl> namespace detail { <nl> <nl> template < typename T > <nl> - inline bool process_server_socket_core ( socket_t sock , <nl> - size_t keep_alive_max_count , <nl> - T callback ) { <nl> - assert ( keep_alive_max_count > 0 ) ; <nl> - auto ret = false ; <nl> - auto count = keep_alive_max_count ; <nl> - while ( count > 0 & & keep_alive ( sock ) ) { <nl> - auto close_connection = count = = 1 ; <nl> - auto connection_closed = false ; <nl> - ret = callback ( close_connection , connection_closed ) ; <nl> - if ( ! ret | | connection_closed ) { break ; } <nl> - count - - ; <nl> - } <nl> - return ret ; <nl> + inline bool process_server_socket_core ( socket_t sock , size_t keep_alive_max_count , T callback ) { <nl> + assert ( keep_alive_max_count > 0 ) ; <nl> + auto ret = false ; <nl> + auto count = keep_alive_max_count ; <nl> + while ( count > 0 & & keep_alive ( sock ) ) { <nl> + auto close_connection = count = = 1 ; <nl> + auto connection_closed = false ; <nl> + ret = callback ( close_connection , connection_closed ) ; <nl> + if ( ! ret | | connection_closed ) { <nl> + break ; <nl> + } <nl> + count - - ; <nl> + } <nl> + return ret ; <nl> } ; <nl> <nl> template < typename T > <nl> - inline bool process_server_socket ( socket_t sock , size_t keep_alive_max_count , <nl> + inline bool process_server_socket ( socket_t sock , <nl> + size_t keep_alive_max_count , <nl> time_t read_timeout_sec , <nl> time_t read_timeout_usec , <nl> time_t write_timeout_sec , <nl> - time_t write_timeout_usec , T callback ) { <nl> - return process_server_socket_core ( <nl> - sock , keep_alive_max_count , <nl> - [ & ] ( bool close_connection , bool connection_closed ) { <nl> - SocketStream strm ( sock , read_timeout_sec , read_timeout_usec , <nl> - write_timeout_sec , write_timeout_usec ) ; <nl> + time_t write_timeout_usec , <nl> + T callback ) { <nl> + return process_server_socket_core ( sock , keep_alive_max_count , [ & ] ( bool close_connection , bool connection_closed ) { <nl> + SocketStream strm ( sock , read_timeout_sec , read_timeout_usec , write_timeout_sec , write_timeout_usec ) ; <nl> return callback ( strm , close_connection , connection_closed ) ; <nl> - } ) ; <nl> + } ) ; <nl> } <nl> <nl> - } <nl> + } / / namespace detail <nl> <nl> class CoSocketStream : public detail : : SocketStream { <nl> - public : <nl> - CoSocketStream ( Socket * sock , time_t read_timeout_sec , time_t read_timeout_usec , time_t write_timeout_sec , <nl> + public : <nl> + CoSocketStream ( Socket * sock , <nl> + time_t read_timeout_sec , <nl> + time_t read_timeout_usec , <nl> + time_t write_timeout_sec , <nl> time_t write_timeout_usec ) <nl> - : detail : : SocketStream ( sock - > get_fd ( ) , read_timeout_sec , read_timeout_usec , write_timeout_sec , <nl> - write_timeout_usec ) { <nl> + : detail : : SocketStream ( <nl> + sock - > get_fd ( ) , read_timeout_sec , read_timeout_usec , write_timeout_sec , write_timeout_usec ) { <nl> sock_ = sock ; <nl> sock - > set_timeout ( ( double ) read_timeout_sec + ( ( double ) read_timeout_usec / 1000000 ) , swoole : : SW_TIMEOUT_READ ) ; <nl> sock - > set_timeout ( ( double ) write_timeout_sec + ( ( double ) write_timeout_usec / 1000000 ) , <nl> swoole : : SW_TIMEOUT_WRITE ) ; <nl> } <nl> - ~ CoSocketStream ( ) { <nl> - <nl> - } <nl> + ~ CoSocketStream ( ) { } <nl> bool is_readable ( ) const { <nl> return true ; <nl> } <nl> class CoSocketStream : public detail : : SocketStream { <nl> ip = std : : string ( swSocket_get_ip ( sock_ - > get_type ( ) , & sa ) ) ; <nl> port = swSocket_get_port ( sock_ - > get_type ( ) , & sa ) ; <nl> } <nl> - private : <nl> + <nl> + private : <nl> Socket * sock_ ; <nl> } ; <nl> <nl> inline bool Server : : process_and_close_socket ( Socket * sock ) { <nl> - <nl> size_t keep_alive_max_count = keep_alive_max_count_ ; <nl> time_t read_timeout_sec = read_timeout_sec_ ; <nl> time_t read_timeout_usec = read_timeout_usec_ ; <nl> inline bool Server : : process_and_close_socket ( Socket * sock ) { <nl> return ret ; <nl> } <nl> <nl> - } <nl> + } / / namespace httplib <nl> mmm a / core - tests / include / test_server . h <nl> ppp b / core - tests / include / test_server . h <nl> <nl> # define SERVER_THIS ( ( swoole : : test : : Server * ) serv - > ptr2 ) <nl> <nl> # define ON_WORKERSTART_PARAMS swServer * serv , int worker_id <nl> - # define ON_PACKET_PARAMS swServer * serv , swEventData * req <nl> - # define ON_RECEIVE_PARAMS swServer * serv , swEventData * req <nl> + # define ON_PACKET_PARAMS swServer * serv , swRecvData * req <nl> + # define ON_RECEIVE_PARAMS swServer * serv , swRecvData * req <nl> <nl> typedef void ( * _onStart ) ( swServer * serv ) ; <nl> typedef void ( * _onShutdown ) ( swServer * serv ) ; <nl> typedef void ( * _onPipeMessage ) ( swServer * , swEventData * data ) ; <nl> typedef void ( * _onWorkerStart ) ( swServer * serv , int worker_id ) ; <nl> typedef void ( * _onWorkerStop ) ( swServer * serv , int worker_id ) ; <nl> - typedef int ( * _onReceive ) ( swServer * , swEventData * ) ; <nl> - typedef int ( * _onPacket ) ( swServer * , swEventData * ) ; <nl> + typedef int ( * _onReceive ) ( swServer * , swRecvData * ) ; <nl> + typedef int ( * _onPacket ) ( swServer * , swRecvData * ) ; <nl> typedef void ( * _onClose ) ( swServer * serv , swDataHead * ) ; <nl> typedef void ( * _onConnect ) ( swServer * serv , swDataHead * ) ; <nl> <nl> class Server <nl> void on ( std : : string event , void * fn ) ; <nl> bool start ( ) ; <nl> bool listen ( std : : string host , int port , enum swSocket_type type ) ; <nl> - size_t get_packet ( swEventData * req , char * * data_ptr ) ; <nl> - int send ( int session_id , void * data , uint32_t length ) ; <nl> + int send ( int session_id , const void * data , uint32_t length ) ; <nl> ssize_t sendto ( swSocketAddress * address , const char * __buf , size_t __n , int server_socket = - 1 ) ; <nl> int close ( int session_id , int reset ) ; <nl> <nl> new file mode 100644 <nl> index 0000000000 . . dba69cc91e <nl> mmm / dev / null <nl> ppp b / core - tests / src / _lib / http . cpp <nl> <nl> + # include " tests . h " <nl> + # include " httplib_client . h " <nl> + # include " http . h " <nl> + <nl> + namespace httplib { <nl> + <nl> + bool Client : : Upgrade ( const char * _path , Headers & _headers ) { <nl> + set_keep_alive ( true ) ; <nl> + _headers . emplace ( " Connection " , " Upgrade " ) ; <nl> + _headers . emplace ( " Upgrade " , " websocket " ) ; <nl> + _headers . emplace ( " Sec - Websocket - Key " , " sN9cRrP / n9NdMgdcy2VJFQ = = " ) ; <nl> + _headers . emplace ( " Sec - WebSocket - Version " , " 13 " ) ; <nl> + <nl> + auto resp = Get ( _path , _headers ) ; <nl> + if ( resp = = nullptr or resp - > status ! = SW_HTTP_SWITCHING_PROTOCOLS ) { <nl> + return false ; <nl> + } <nl> + <nl> + return true ; <nl> + } <nl> + <nl> + bool Client : : Push ( const char * data , size_t length , int opcode ) { <nl> + if ( ! socket_ . is_open ( ) ) { <nl> + return false ; <nl> + } <nl> + return process_socket ( socket_ , [ & ] ( Stream & strm ) { <nl> + swString buffer = { } ; <nl> + char buf [ 32 ] ; <nl> + buffer . size = sizeof ( buf ) ; <nl> + buffer . str = buf ; <nl> + <nl> + swWebSocket_encode ( & buffer , data , length , opcode , SW_WEBSOCKET_FLAG_FIN | SW_WEBSOCKET_FLAG_ENCODE_HEADER_ONLY ) ; <nl> + strm . write ( buffer . str , buffer . length ) ; <nl> + strm . write ( data , length ) ; <nl> + return true ; <nl> + } ) ; <nl> + } <nl> + <nl> + std : : shared_ptr < WebSocketFrame > Client : : Recv ( ) { <nl> + auto msg = std : : make_shared < WebSocketFrame > ( ) ; <nl> + auto retval = process_socket ( socket_ , [ & ] ( Stream & strm ) { <nl> + swProtocol proto = { } ; <nl> + proto . package_length_size = SW_WEBSOCKET_HEADER_LEN ; <nl> + proto . get_package_length = swWebSocket_get_package_length ; <nl> + proto . package_max_length = SW_INPUT_BUFFER_SIZE ; <nl> + <nl> + char buf [ 1024 ] ; <nl> + ssize_t packet_len ; <nl> + <nl> + if ( strm . read ( buf , SW_WEBSOCKET_HEADER_LEN ) < = 0 ) { <nl> + return false ; <nl> + } <nl> + packet_len = proto . get_package_length ( & proto , nullptr , buf , 2 ) ; <nl> + if ( packet_len < 0 ) { <nl> + return false ; <nl> + } <nl> + if ( packet_len = = 0 ) { <nl> + if ( strm . read ( buf + SW_WEBSOCKET_HEADER_LEN , proto . real_header_length - SW_WEBSOCKET_HEADER_LEN ) < = 0 ) { <nl> + return false ; <nl> + } <nl> + packet_len = proto . get_package_length ( & proto , nullptr , buf , proto . real_header_length ) ; <nl> + if ( packet_len < = 0 ) { <nl> + return false ; <nl> + } <nl> + } <nl> + <nl> + char * data = ( char * ) malloc ( packet_len + 1 ) ; <nl> + if ( data = = nullptr ) { <nl> + return false ; <nl> + } <nl> + data [ packet_len ] = 0 ; <nl> + <nl> + uint32_t header_len = proto . real_header_length > 0 ? proto . real_header_length : SW_WEBSOCKET_HEADER_LEN ; <nl> + memcpy ( data , buf , header_len ) ; <nl> + <nl> + ssize_t read_bytes = header_len ; <nl> + while ( read_bytes < packet_len ) { <nl> + auto n_read = strm . read ( data + read_bytes , packet_len - read_bytes ) ; <nl> + if ( n_read < = 0 ) { <nl> + free ( data ) ; <nl> + return false ; <nl> + } <nl> + read_bytes + = n_read ; <nl> + } <nl> + <nl> + return swWebSocket_decode ( msg . get ( ) , data , packet_len ) ; <nl> + } ) ; <nl> + <nl> + return retval ? msg : nullptr ; <nl> + } <nl> + <nl> + / / HTTP client implementation <nl> + Client : : Client ( const std : : string & host ) : Client ( host , 80 , std : : string ( ) , std : : string ( ) ) { } <nl> + <nl> + Client : : Client ( const std : : string & host , int port ) : Client ( host , port , std : : string ( ) , std : : string ( ) ) { } <nl> + <nl> + Client : : Client ( const std : : string & host , <nl> + int port , <nl> + const std : : string & client_cert_path , <nl> + const std : : string & client_key_path ) <nl> + : host_ ( host ) , <nl> + port_ ( port ) , <nl> + host_and_port_ ( host_ + " : " + std : : to_string ( port_ ) ) , <nl> + client_cert_path_ ( client_cert_path ) , <nl> + client_key_path_ ( client_key_path ) { } <nl> + <nl> + Client : : ~ Client ( ) { <nl> + stop ( ) ; <nl> + } <nl> + <nl> + bool Client : : is_valid ( ) const { <nl> + return true ; <nl> + } <nl> + <nl> + socket_t Client : : create_client_socket ( ) const { <nl> + if ( ! proxy_host_ . empty ( ) ) { <nl> + return detail : : create_client_socket ( proxy_host_ . c_str ( ) , <nl> + proxy_port_ , <nl> + tcp_nodelay_ , <nl> + socket_options_ , <nl> + connection_timeout_sec_ , <nl> + connection_timeout_usec_ , <nl> + interface_ ) ; <nl> + } <nl> + return detail : : create_client_socket ( host_ . c_str ( ) , <nl> + port_ , <nl> + tcp_nodelay_ , <nl> + socket_options_ , <nl> + connection_timeout_sec_ , <nl> + connection_timeout_usec_ , <nl> + interface_ ) ; <nl> + } <nl> + <nl> + bool Client : : create_and_connect_socket ( Socket & socket ) { <nl> + auto sock = create_client_socket ( ) ; <nl> + if ( sock = = INVALID_SOCKET ) { <nl> + return false ; <nl> + } <nl> + socket . sock = sock ; <nl> + return true ; <nl> + } <nl> + <nl> + void Client : : close_socket ( Socket & socket , bool / * process_socket_ret * / ) { <nl> + detail : : close_socket ( socket . sock ) ; <nl> + socket_ . sock = INVALID_SOCKET ; <nl> + # ifdef CPPHTTPLIB_OPENSSL_SUPPORT <nl> + socket_ . ssl = nullptr ; <nl> + # endif <nl> + } <nl> + <nl> + bool Client : : read_response_line ( Stream & strm , Response & res ) { <nl> + std : : array < char , 2048 > buf ; <nl> + <nl> + detail : : stream_line_reader line_reader ( strm , buf . data ( ) , buf . size ( ) ) ; <nl> + <nl> + if ( ! line_reader . getline ( ) ) { <nl> + return false ; <nl> + } <nl> + <nl> + const static std : : regex re ( " ( HTTP / 1 \ \ . [ 01 ] ) ( \ \ d + ? ) . * \ r \ n " ) ; <nl> + <nl> + std : : cmatch m ; <nl> + if ( std : : regex_match ( line_reader . ptr ( ) , m , re ) ) { <nl> + res . version = std : : string ( m [ 1 ] ) ; <nl> + res . status = std : : stoi ( std : : string ( m [ 2 ] ) ) ; <nl> + } <nl> + <nl> + return true ; <nl> + } <nl> + <nl> + bool Client : : send ( const Request & req , Response & res ) { <nl> + std : : lock_guard < std : : recursive_mutex > request_mutex_guard ( request_mutex_ ) ; <nl> + <nl> + { <nl> + std : : lock_guard < std : : mutex > guard ( socket_mutex_ ) ; <nl> + <nl> + auto is_alive = false ; <nl> + if ( socket_ . is_open ( ) ) { <nl> + is_alive = detail : : select_write ( socket_ . sock , 0 , 0 ) > 0 ; <nl> + if ( ! is_alive ) { <nl> + close_socket ( socket_ , false ) ; <nl> + } <nl> + } <nl> + <nl> + if ( ! is_alive ) { <nl> + if ( ! create_and_connect_socket ( socket_ ) ) { <nl> + return false ; <nl> + } <nl> + <nl> + # ifdef CPPHTTPLIB_OPENSSL_SUPPORT <nl> + / / TODO : refactoring <nl> + if ( is_ssl ( ) ) { <nl> + auto & scli = static_cast < SSLClient & > ( * this ) ; <nl> + if ( ! proxy_host_ . empty ( ) ) { <nl> + bool success = false ; <nl> + if ( ! scli . connect_with_proxy ( socket_ , res , success ) ) { <nl> + return success ; <nl> + } <nl> + } <nl> + <nl> + if ( ! scli . initialize_ssl ( socket_ ) ) { <nl> + return false ; <nl> + } <nl> + } <nl> + # endif <nl> + } <nl> + } <nl> + <nl> + auto close_connection = ! keep_alive_ ; <nl> + <nl> + auto ret = process_socket ( socket_ , [ & ] ( Stream & strm ) { return handle_request ( strm , req , res , close_connection ) ; } ) ; <nl> + <nl> + if ( close_connection ) { <nl> + stop ( ) ; <nl> + } <nl> + <nl> + return ret ; <nl> + } <nl> + <nl> + bool Client : : handle_request ( Stream & strm , const Request & req , Response & res , bool close_connection ) { <nl> + if ( req . path . empty ( ) ) { <nl> + return false ; <nl> + } <nl> + <nl> + bool ret ; <nl> + <nl> + if ( ! is_ssl ( ) & & ! proxy_host_ . empty ( ) ) { <nl> + auto req2 = req ; <nl> + req2 . path = " http : / / " + host_and_port_ + req . path ; <nl> + ret = process_request ( strm , req2 , res , close_connection ) ; <nl> + } else { <nl> + ret = process_request ( strm , req , res , close_connection ) ; <nl> + } <nl> + <nl> + if ( ! ret ) { <nl> + return false ; <nl> + } <nl> + <nl> + if ( 300 < res . status & & res . status < 400 & & follow_location_ ) { <nl> + ret = redirect ( req , res ) ; <nl> + } <nl> + <nl> + # ifdef CPPHTTPLIB_OPENSSL_SUPPORT <nl> + if ( ( res . status = = 401 | | res . status = = 407 ) & & req . authorization_count_ < 5 ) { <nl> + auto is_proxy = res . status = = 407 ; <nl> + const auto & username = is_proxy ? proxy_digest_auth_username_ : digest_auth_username_ ; <nl> + const auto & password = is_proxy ? proxy_digest_auth_password_ : digest_auth_password_ ; <nl> + <nl> + if ( ! username . empty ( ) & & ! password . empty ( ) ) { <nl> + std : : map < std : : string , std : : string > auth ; <nl> + if ( parse_www_authenticate ( res , auth , is_proxy ) ) { <nl> + Request new_req = req ; <nl> + new_req . authorization_count_ + = 1 ; <nl> + auto key = is_proxy ? " Proxy - Authorization " : " Authorization " ; <nl> + new_req . headers . erase ( key ) ; <nl> + new_req . headers . insert ( make_digest_authentication_header ( <nl> + req , auth , new_req . authorization_count_ , random_string ( 10 ) , username , password , is_proxy ) ) ; <nl> + <nl> + Response new_res ; <nl> + <nl> + ret = send ( new_req , new_res ) ; <nl> + if ( ret ) { <nl> + res = new_res ; <nl> + } <nl> + } <nl> + } <nl> + } <nl> + # endif <nl> + <nl> + return ret ; <nl> + } <nl> + <nl> + bool Client : : redirect ( const Request & req , Response & res ) { <nl> + if ( req . redirect_count = = 0 ) { <nl> + return false ; <nl> + } <nl> + <nl> + auto location = res . get_header_value ( " location " ) ; <nl> + if ( location . empty ( ) ) { <nl> + return false ; <nl> + } <nl> + <nl> + const static std : : regex re ( R " ( ^ ( ? : ( https ? ) : ) ? ( ? : / / ( [ ^ : / ? # ] * ) ( ? : : ( \ d + ) ) ? ) ? ( [ ^ ? # ] * ( ? : \ ? [ ^ # ] * ) ? ) ( ? : # . * ) ? ) " ) ; <nl> + <nl> + std : : smatch m ; <nl> + if ( ! std : : regex_match ( location , m , re ) ) { <nl> + return false ; <nl> + } <nl> + <nl> + auto scheme = is_ssl ( ) ? " https " : " http " ; <nl> + <nl> + auto next_scheme = m [ 1 ] . str ( ) ; <nl> + auto next_host = m [ 2 ] . str ( ) ; <nl> + auto port_str = m [ 3 ] . str ( ) ; <nl> + auto next_path = m [ 4 ] . str ( ) ; <nl> + <nl> + auto next_port = port_ ; <nl> + if ( ! port_str . empty ( ) ) { <nl> + next_port = std : : stoi ( port_str ) ; <nl> + } else if ( ! next_scheme . empty ( ) ) { <nl> + next_port = next_scheme = = " https " ? 443 : 80 ; <nl> + } <nl> + <nl> + if ( next_scheme . empty ( ) ) { <nl> + next_scheme = scheme ; <nl> + } <nl> + if ( next_host . empty ( ) ) { <nl> + next_host = host_ ; <nl> + } <nl> + if ( next_path . empty ( ) ) { <nl> + next_path = " / " ; <nl> + } <nl> + <nl> + if ( next_scheme = = scheme & & next_host = = host_ & & next_port = = port_ ) { <nl> + return detail : : redirect ( * this , req , res , next_path ) ; <nl> + } else { <nl> + if ( next_scheme = = " https " ) { <nl> + # ifdef CPPHTTPLIB_OPENSSL_SUPPORT <nl> + SSLClient cli ( next_host . c_str ( ) , next_port ) ; <nl> + cli . copy_settings ( * this ) ; <nl> + return detail : : redirect ( cli , req , res , next_path ) ; <nl> + # else <nl> + return false ; <nl> + # endif <nl> + } else { <nl> + Client cli ( next_host . c_str ( ) , next_port ) ; <nl> + cli . copy_settings ( * this ) ; <nl> + return detail : : redirect ( cli , req , res , next_path ) ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + bool Client : : write_request ( Stream & strm , const Request & req , bool close_connection ) { <nl> + detail : : BufferStream bstrm ; <nl> + <nl> + / / Request line <nl> + const auto & path = detail : : encode_url ( req . path ) ; <nl> + <nl> + bstrm . write_format ( " % s % s HTTP / 1 . 1 \ r \ n " , req . method . c_str ( ) , path . c_str ( ) ) ; <nl> + <nl> + / / Additonal headers <nl> + Headers headers ; <nl> + if ( close_connection ) { <nl> + headers . emplace ( " Connection " , " close " ) ; <nl> + } <nl> + <nl> + if ( ! req . has_header ( " Host " ) ) { <nl> + if ( is_ssl ( ) ) { <nl> + if ( port_ = = 443 ) { <nl> + headers . emplace ( " Host " , host_ ) ; <nl> + } else { <nl> + headers . emplace ( " Host " , host_and_port_ ) ; <nl> + } <nl> + } else { <nl> + if ( port_ = = 80 ) { <nl> + headers . emplace ( " Host " , host_ ) ; <nl> + } else { <nl> + headers . emplace ( " Host " , host_and_port_ ) ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + if ( ! req . has_header ( " Accept " ) ) { <nl> + headers . emplace ( " Accept " , " * / * " ) ; <nl> + } <nl> + <nl> + if ( ! req . has_header ( " User - Agent " ) ) { <nl> + headers . emplace ( " User - Agent " , USER_AGENT ) ; <nl> + } <nl> + <nl> + if ( req . body . empty ( ) ) { <nl> + if ( req . content_provider ) { <nl> + auto length = std : : to_string ( req . content_length ) ; <nl> + headers . emplace ( " Content - Length " , length ) ; <nl> + } else { <nl> + headers . emplace ( " Content - Length " , " 0 " ) ; <nl> + } <nl> + } else { <nl> + if ( ! req . has_header ( " Content - Type " ) ) { <nl> + headers . emplace ( " Content - Type " , " text / plain " ) ; <nl> + } <nl> + <nl> + if ( ! req . has_header ( " Content - Length " ) ) { <nl> + auto length = std : : to_string ( req . body . size ( ) ) ; <nl> + headers . emplace ( " Content - Length " , length ) ; <nl> + } <nl> + } <nl> + <nl> + if ( ! basic_auth_username_ . empty ( ) & & ! basic_auth_password_ . empty ( ) ) { <nl> + headers . insert ( make_basic_authentication_header ( basic_auth_username_ , basic_auth_password_ , false ) ) ; <nl> + } <nl> + <nl> + if ( ! proxy_basic_auth_username_ . empty ( ) & & ! proxy_basic_auth_password_ . empty ( ) ) { <nl> + headers . insert ( make_basic_authentication_header ( proxy_basic_auth_username_ , proxy_basic_auth_password_ , true ) ) ; <nl> + } <nl> + <nl> + detail : : write_headers ( bstrm , req , headers ) ; <nl> + <nl> + / / Flush buffer <nl> + auto & data = bstrm . get_buffer ( ) ; <nl> + if ( ! detail : : write_data ( strm , data . data ( ) , data . size ( ) ) ) { <nl> + return false ; <nl> + } <nl> + <nl> + / / Body <nl> + if ( req . body . empty ( ) ) { <nl> + if ( req . content_provider ) { <nl> + size_t offset = 0 ; <nl> + size_t end_offset = req . content_length ; <nl> + <nl> + bool ok = true ; <nl> + <nl> + DataSink data_sink ; <nl> + data_sink . write = [ & ] ( const char * d , size_t l ) { <nl> + if ( ok ) { <nl> + if ( detail : : write_data ( strm , d , l ) ) { <nl> + offset + = l ; <nl> + } else { <nl> + ok = false ; <nl> + } <nl> + } <nl> + } ; <nl> + data_sink . is_writable = [ & ] ( void ) { return ok & & strm . is_writable ( ) ; } ; <nl> + <nl> + while ( offset < end_offset ) { <nl> + if ( ! req . content_provider ( offset , end_offset - offset , data_sink ) ) { <nl> + return false ; <nl> + } <nl> + if ( ! ok ) { <nl> + return false ; <nl> + } <nl> + } <nl> + } <nl> + } else { <nl> + return detail : : write_data ( strm , req . body . data ( ) , req . body . size ( ) ) ; <nl> + } <nl> + <nl> + return true ; <nl> + } <nl> + <nl> + std : : shared_ptr < Response > Client : : send_with_content_provider ( const char * method , <nl> + const char * path , <nl> + const Headers & headers , <nl> + const std : : string & body , <nl> + size_t content_length , <nl> + ContentProvider content_provider , <nl> + const char * content_type ) { <nl> + Request req ; <nl> + req . method = method ; <nl> + req . headers = headers ; <nl> + req . path = path ; <nl> + <nl> + if ( content_type ) { <nl> + req . headers . emplace ( " Content - Type " , content_type ) ; <nl> + } <nl> + <nl> + # ifdef CPPHTTPLIB_ZLIB_SUPPORT <nl> + if ( compress_ ) { <nl> + if ( content_provider ) { <nl> + size_t offset = 0 ; <nl> + <nl> + DataSink data_sink ; <nl> + data_sink . write = [ & ] ( const char * data , size_t data_len ) { <nl> + req . body . append ( data , data_len ) ; <nl> + offset + = data_len ; <nl> + } ; <nl> + data_sink . is_writable = [ & ] ( void ) { return true ; } ; <nl> + <nl> + while ( offset < content_length ) { <nl> + if ( ! content_provider ( offset , content_length - offset , data_sink ) ) { <nl> + return nullptr ; <nl> + } <nl> + } <nl> + } else { <nl> + req . body = body ; <nl> + } <nl> + <nl> + if ( ! detail : : compress ( req . body ) ) { <nl> + return nullptr ; <nl> + } <nl> + req . headers . emplace ( " Content - Encoding " , " gzip " ) ; <nl> + } else <nl> + # endif <nl> + { <nl> + if ( content_provider ) { <nl> + req . content_length = content_length ; <nl> + req . content_provider = content_provider ; <nl> + } else { <nl> + req . body = body ; <nl> + } <nl> + } <nl> + <nl> + auto res = std : : make_shared < Response > ( ) ; <nl> + <nl> + return send ( req , * res ) ? res : nullptr ; <nl> + } <nl> + <nl> + bool Client : : process_request ( Stream & strm , const Request & req , Response & res , bool close_connection ) { <nl> + / / Send request <nl> + if ( ! write_request ( strm , req , close_connection ) ) { <nl> + return false ; <nl> + } <nl> + <nl> + / / Receive response and headers <nl> + if ( ! read_response_line ( strm , res ) | | ! detail : : read_headers ( strm , res . headers ) ) { <nl> + return false ; <nl> + } <nl> + <nl> + if ( req . response_handler ) { <nl> + if ( ! req . response_handler ( res ) ) { <nl> + return false ; <nl> + } <nl> + } <nl> + <nl> + / / Body <nl> + if ( req . method ! = " HEAD " & & req . method ! = " CONNECT " ) { <nl> + auto out = <nl> + req . content_receiver <nl> + ? static_cast < ContentReceiver > ( [ & ] ( const char * buf , size_t n ) { return req . content_receiver ( buf , n ) ; } ) <nl> + : static_cast < ContentReceiver > ( [ & ] ( const char * buf , size_t n ) { <nl> + if ( res . body . size ( ) + n > res . body . max_size ( ) ) { <nl> + return false ; <nl> + } <nl> + res . body . append ( buf , n ) ; <nl> + return true ; <nl> + } ) ; <nl> + <nl> + int dummy_status ; <nl> + if ( ! detail : : read_content ( <nl> + strm , res , ( std : : numeric_limits < size_t > : : max ) ( ) , dummy_status , req . progress , out , decompress_ ) ) { <nl> + return false ; <nl> + } <nl> + } <nl> + <nl> + if ( res . get_header_value ( " Connection " ) = = " close " | | res . version = = " HTTP / 1 . 0 " ) { <nl> + stop ( ) ; <nl> + } <nl> + <nl> + / / Log <nl> + if ( logger_ ) { <nl> + logger_ ( req , res ) ; <nl> + } <nl> + <nl> + return true ; <nl> + } <nl> + <nl> + bool Client : : process_socket ( Socket & socket , std : : function < bool ( Stream & strm ) > callback ) { <nl> + return detail : : process_client_socket ( <nl> + socket . sock , read_timeout_sec_ , read_timeout_usec_ , write_timeout_sec_ , write_timeout_usec_ , callback ) ; <nl> + } <nl> + <nl> + bool Client : : is_ssl ( ) const { <nl> + return false ; <nl> + } <nl> + <nl> + std : : shared_ptr < Response > Client : : Get ( const char * path ) { <nl> + return Get ( path , Headers ( ) , Progress ( ) ) ; <nl> + } <nl> + <nl> + std : : shared_ptr < Response > Client : : Get ( const char * path , Progress progress ) { <nl> + return Get ( path , Headers ( ) , std : : move ( progress ) ) ; <nl> + } <nl> + <nl> + std : : shared_ptr < Response > Client : : Get ( const char * path , const Headers & headers ) { <nl> + return Get ( path , headers , Progress ( ) ) ; <nl> + } <nl> + <nl> + std : : shared_ptr < Response > Client : : Get ( const char * path , const Headers & headers , Progress progress ) { <nl> + Request req ; <nl> + req . method = " GET " ; <nl> + req . path = path ; <nl> + req . headers = headers ; <nl> + req . progress = std : : move ( progress ) ; <nl> + <nl> + auto res = std : : make_shared < Response > ( ) ; <nl> + return send ( req , * res ) ? res : nullptr ; <nl> + } <nl> + <nl> + std : : shared_ptr < Response > Client : : Get ( const char * path , ContentReceiver content_receiver ) { <nl> + return Get ( path , Headers ( ) , nullptr , std : : move ( content_receiver ) , Progress ( ) ) ; <nl> + } <nl> + <nl> + std : : shared_ptr < Response > Client : : Get ( const char * path , ContentReceiver content_receiver , Progress progress ) { <nl> + return Get ( path , Headers ( ) , nullptr , std : : move ( content_receiver ) , std : : move ( progress ) ) ; <nl> + } <nl> + <nl> + std : : shared_ptr < Response > Client : : Get ( const char * path , <nl> + const Headers & headers , <nl> + ContentReceiver content_receiver ) { <nl> + return Get ( path , headers , nullptr , std : : move ( content_receiver ) , Progress ( ) ) ; <nl> + } <nl> + <nl> + std : : shared_ptr < Response > Client : : Get ( const char * path , <nl> + const Headers & headers , <nl> + ContentReceiver content_receiver , <nl> + Progress progress ) { <nl> + return Get ( path , headers , nullptr , std : : move ( content_receiver ) , std : : move ( progress ) ) ; <nl> + } <nl> + <nl> + std : : shared_ptr < Response > Client : : Get ( const char * path , <nl> + const Headers & headers , <nl> + ResponseHandler response_handler , <nl> + ContentReceiver content_receiver ) { <nl> + return Get ( path , headers , std : : move ( response_handler ) , content_receiver , Progress ( ) ) ; <nl> + } <nl> + <nl> + std : : shared_ptr < Response > Client : : Get ( const char * path , <nl> + const Headers & headers , <nl> + ResponseHandler response_handler , <nl> + ContentReceiver content_receiver , <nl> + Progress progress ) { <nl> + Request req ; <nl> + req . method = " GET " ; <nl> + req . path = path ; <nl> + req . headers = headers ; <nl> + req . response_handler = std : : move ( response_handler ) ; <nl> + req . content_receiver = std : : move ( content_receiver ) ; <nl> + req . progress = std : : move ( progress ) ; <nl> + <nl> + auto res = std : : make_shared < Response > ( ) ; <nl> + return send ( req , * res ) ? res : nullptr ; <nl> + } <nl> + <nl> + std : : shared_ptr < Response > Client : : Head ( const char * path ) { <nl> + return Head ( path , Headers ( ) ) ; <nl> + } <nl> + <nl> + std : : shared_ptr < Response > Client : : Head ( const char * path , const Headers & headers ) { <nl> + Request req ; <nl> + req . method = " HEAD " ; <nl> + req . headers = headers ; <nl> + req . path = path ; <nl> + <nl> + auto res = std : : make_shared < Response > ( ) ; <nl> + <nl> + return send ( req , * res ) ? res : nullptr ; <nl> + } <nl> + <nl> + std : : shared_ptr < Response > Client : : Post ( const char * path ) { <nl> + return Post ( path , std : : string ( ) , nullptr ) ; <nl> + } <nl> + <nl> + std : : shared_ptr < Response > Client : : Post ( const char * path , const std : : string & body , const char * content_type ) { <nl> + return Post ( path , Headers ( ) , body , content_type ) ; <nl> + } <nl> + <nl> + std : : shared_ptr < Response > Client : : Post ( const char * path , <nl> + const Headers & headers , <nl> + const std : : string & body , <nl> + const char * content_type ) { <nl> + return send_with_content_provider ( " POST " , path , headers , body , 0 , nullptr , content_type ) ; <nl> + } <nl> + <nl> + std : : shared_ptr < Response > Client : : Post ( const char * path , const Params & params ) { <nl> + return Post ( path , Headers ( ) , params ) ; <nl> + } <nl> + <nl> + std : : shared_ptr < Response > Client : : Post ( const char * path , <nl> + size_t content_length , <nl> + ContentProvider content_provider , <nl> + const char * content_type ) { <nl> + return Post ( path , Headers ( ) , content_length , content_provider , content_type ) ; <nl> + } <nl> + <nl> + std : : shared_ptr < Response > Client : : Post ( const char * path , <nl> + const Headers & headers , <nl> + size_t content_length , <nl> + ContentProvider content_provider , <nl> + const char * content_type ) { <nl> + return send_with_content_provider ( <nl> + " POST " , path , headers , std : : string ( ) , content_length , content_provider , content_type ) ; <nl> + } <nl> + <nl> + std : : shared_ptr < Response > Client : : Post ( const char * path , const Headers & headers , const Params & params ) { <nl> + auto query = detail : : params_to_query_str ( params ) ; <nl> + return Post ( path , headers , query , " application / x - www - form - urlencoded " ) ; <nl> + } <nl> + <nl> + std : : shared_ptr < Response > Client : : Post ( const char * path , const MultipartFormDataItems & items ) { <nl> + return Post ( path , Headers ( ) , items ) ; <nl> + } <nl> + <nl> + std : : shared_ptr < Response > Client : : Post ( const char * path , <nl> + const Headers & headers , <nl> + const MultipartFormDataItems & items ) { <nl> + auto boundary = detail : : make_multipart_data_boundary ( ) ; <nl> + <nl> + std : : string body ; <nl> + <nl> + for ( const auto & item : items ) { <nl> + body + = " - - " + boundary + " \ r \ n " ; <nl> + body + = " Content - Disposition : form - data ; name = \ " " + item . name + " \ " " ; <nl> + if ( ! item . filename . empty ( ) ) { <nl> + body + = " ; filename = \ " " + item . filename + " \ " " ; <nl> + } <nl> + body + = " \ r \ n " ; <nl> + if ( ! item . content_type . empty ( ) ) { <nl> + body + = " Content - Type : " + item . content_type + " \ r \ n " ; <nl> + } <nl> + body + = " \ r \ n " ; <nl> + body + = item . content + " \ r \ n " ; <nl> + } <nl> + <nl> + body + = " - - " + boundary + " - - \ r \ n " ; <nl> + <nl> + std : : string content_type = " multipart / form - data ; boundary = " + boundary ; <nl> + return Post ( path , headers , body , content_type . c_str ( ) ) ; <nl> + } <nl> + <nl> + std : : shared_ptr < Response > Client : : Put ( const char * path ) { <nl> + return Put ( path , std : : string ( ) , nullptr ) ; <nl> + } <nl> + <nl> + std : : shared_ptr < Response > Client : : Put ( const char * path , const std : : string & body , const char * content_type ) { <nl> + return Put ( path , Headers ( ) , body , content_type ) ; <nl> + } <nl> + <nl> + std : : shared_ptr < Response > Client : : Put ( const char * path , <nl> + const Headers & headers , <nl> + const std : : string & body , <nl> + const char * content_type ) { <nl> + return send_with_content_provider ( " PUT " , path , headers , body , 0 , nullptr , content_type ) ; <nl> + } <nl> + <nl> + std : : shared_ptr < Response > Client : : Put ( const char * path , <nl> + size_t content_length , <nl> + ContentProvider content_provider , <nl> + const char * content_type ) { <nl> + return Put ( path , Headers ( ) , content_length , content_provider , content_type ) ; <nl> + } <nl> + <nl> + std : : shared_ptr < Response > Client : : Put ( const char * path , <nl> + const Headers & headers , <nl> + size_t content_length , <nl> + ContentProvider content_provider , <nl> + const char * content_type ) { <nl> + return send_with_content_provider ( <nl> + " PUT " , path , headers , std : : string ( ) , content_length , content_provider , content_type ) ; <nl> + } <nl> + <nl> + std : : shared_ptr < Response > Client : : Put ( const char * path , const Params & params ) { <nl> + return Put ( path , Headers ( ) , params ) ; <nl> + } <nl> + <nl> + std : : shared_ptr < Response > Client : : Put ( const char * path , const Headers & headers , const Params & params ) { <nl> + auto query = detail : : params_to_query_str ( params ) ; <nl> + return Put ( path , headers , query , " application / x - www - form - urlencoded " ) ; <nl> + } <nl> + <nl> + std : : shared_ptr < Response > Client : : Patch ( const char * path , const std : : string & body , const char * content_type ) { <nl> + return Patch ( path , Headers ( ) , body , content_type ) ; <nl> + } <nl> + <nl> + std : : shared_ptr < Response > Client : : Patch ( const char * path , <nl> + const Headers & headers , <nl> + const std : : string & body , <nl> + const char * content_type ) { <nl> + return send_with_content_provider ( " PATCH " , path , headers , body , 0 , nullptr , content_type ) ; <nl> + } <nl> + <nl> + std : : shared_ptr < Response > Client : : Patch ( const char * path , <nl> + size_t content_length , <nl> + ContentProvider content_provider , <nl> + const char * content_type ) { <nl> + return Patch ( path , Headers ( ) , content_length , content_provider , content_type ) ; <nl> + } <nl> + <nl> + std : : shared_ptr < Response > Client : : Patch ( const char * path , <nl> + const Headers & headers , <nl> + size_t content_length , <nl> + ContentProvider content_provider , <nl> + const char * content_type ) { <nl> + return send_with_content_provider ( <nl> + " PATCH " , path , headers , std : : string ( ) , content_length , content_provider , content_type ) ; <nl> + } <nl> + <nl> + std : : shared_ptr < Response > Client : : Delete ( const char * path ) { <nl> + return Delete ( path , Headers ( ) , std : : string ( ) , nullptr ) ; <nl> + } <nl> + <nl> + std : : shared_ptr < Response > Client : : Delete ( const char * path , const std : : string & body , const char * content_type ) { <nl> + return Delete ( path , Headers ( ) , body , content_type ) ; <nl> + } <nl> + <nl> + std : : shared_ptr < Response > Client : : Delete ( const char * path , const Headers & headers ) { <nl> + return Delete ( path , headers , std : : string ( ) , nullptr ) ; <nl> + } <nl> + <nl> + std : : shared_ptr < Response > Client : : Delete ( const char * path , <nl> + const Headers & headers , <nl> + const std : : string & body , <nl> + const char * content_type ) { <nl> + Request req ; <nl> + req . method = " DELETE " ; <nl> + req . headers = headers ; <nl> + req . path = path ; <nl> + <nl> + if ( content_type ) { <nl> + req . headers . emplace ( " Content - Type " , content_type ) ; <nl> + } <nl> + req . body = body ; <nl> + <nl> + auto res = std : : make_shared < Response > ( ) ; <nl> + <nl> + return send ( req , * res ) ? res : nullptr ; <nl> + } <nl> + <nl> + std : : shared_ptr < Response > Client : : Options ( const char * path ) { <nl> + return Options ( path , Headers ( ) ) ; <nl> + } <nl> + <nl> + std : : shared_ptr < Response > Client : : Options ( const char * path , const Headers & headers ) { <nl> + Request req ; <nl> + req . method = " OPTIONS " ; <nl> + req . path = path ; <nl> + req . headers = headers ; <nl> + <nl> + auto res = std : : make_shared < Response > ( ) ; <nl> + <nl> + return send ( req , * res ) ? res : nullptr ; <nl> + } <nl> + <nl> + size_t Client : : is_socket_open ( ) const { <nl> + std : : lock_guard < std : : mutex > guard ( socket_mutex_ ) ; <nl> + return socket_ . is_open ( ) ; <nl> + } <nl> + <nl> + void Client : : stop ( ) { <nl> + std : : lock_guard < std : : mutex > guard ( socket_mutex_ ) ; <nl> + if ( socket_ . is_open ( ) ) { <nl> + detail : : shutdown_socket ( socket_ . sock ) ; <nl> + std : : this_thread : : sleep_for ( std : : chrono : : milliseconds ( 1 ) ) ; <nl> + close_socket ( socket_ , true ) ; <nl> + std : : this_thread : : sleep_for ( std : : chrono : : milliseconds ( 1 ) ) ; <nl> + } <nl> + } <nl> + <nl> + void Client : : set_timeout_sec ( time_t timeout_sec ) { <nl> + set_connection_timeout ( timeout_sec , 0 ) ; <nl> + } <nl> + <nl> + void Client : : set_connection_timeout ( time_t sec , time_t usec ) { <nl> + connection_timeout_sec_ = sec ; <nl> + connection_timeout_usec_ = usec ; <nl> + } <nl> + <nl> + void Client : : set_read_timeout ( time_t sec , time_t usec ) { <nl> + read_timeout_sec_ = sec ; <nl> + read_timeout_usec_ = usec ; <nl> + } <nl> + <nl> + void Client : : set_write_timeout ( time_t sec , time_t usec ) { <nl> + write_timeout_sec_ = sec ; <nl> + write_timeout_usec_ = usec ; <nl> + } <nl> + <nl> + void Client : : set_basic_auth ( const char * username , const char * password ) { <nl> + basic_auth_username_ = username ; <nl> + basic_auth_password_ = password ; <nl> + } <nl> + <nl> + # ifdef CPPHTTPLIB_OPENSSL_SUPPORT <nl> + void Client : : set_digest_auth ( const char * username , const char * password ) { <nl> + digest_auth_username_ = username ; <nl> + digest_auth_password_ = password ; <nl> + } <nl> + # endif <nl> + <nl> + void Client : : set_keep_alive ( bool on ) { <nl> + keep_alive_ = on ; <nl> + } <nl> + <nl> + void Client : : set_follow_location ( bool on ) { <nl> + follow_location_ = on ; <nl> + } <nl> + <nl> + void Client : : set_tcp_nodelay ( bool on ) { <nl> + tcp_nodelay_ = on ; <nl> + } <nl> + <nl> + void Client : : set_socket_options ( SocketOptions socket_options ) { <nl> + socket_options_ = socket_options ; <nl> + } <nl> + <nl> + void Client : : set_compress ( bool on ) { <nl> + compress_ = on ; <nl> + } <nl> + <nl> + void Client : : set_decompress ( bool on ) { <nl> + decompress_ = on ; <nl> + } <nl> + <nl> + void Client : : set_interface ( const char * intf ) { <nl> + interface_ = intf ; <nl> + } <nl> + <nl> + void Client : : set_proxy ( const char * host , int port ) { <nl> + proxy_host_ = host ; <nl> + proxy_port_ = port ; <nl> + } <nl> + <nl> + void Client : : set_proxy_basic_auth ( const char * username , const char * password ) { <nl> + proxy_basic_auth_username_ = username ; <nl> + proxy_basic_auth_password_ = password ; <nl> + } <nl> + <nl> + # ifdef CPPHTTPLIB_OPENSSL_SUPPORT <nl> + void Client : : set_proxy_digest_auth ( const char * username , const char * password ) { <nl> + proxy_digest_auth_username_ = username ; <nl> + proxy_digest_auth_password_ = password ; <nl> + } <nl> + # endif <nl> + <nl> + void Client : : set_logger ( Logger logger ) { <nl> + logger_ = std : : move ( logger ) ; <nl> + } <nl> + <nl> + } / / namespace httplib <nl> similarity index 95 % <nl> rename from core - tests / src / server / base . cpp <nl> rename to core - tests / src / _lib / server . cpp <nl> mmm a / core - tests / src / server / base . cpp <nl> ppp b / core - tests / src / _lib / server . cpp <nl> bool Server : : listen ( std : : string host , int port , enum swSocket_type type ) { <nl> return true ; <nl> } <nl> <nl> - size_t Server : : get_packet ( swEventData * req , char * * data_ptr ) { <nl> - return serv . get_packet ( & serv , req , data_ptr ) ; <nl> - } <nl> - <nl> - int Server : : send ( int session_id , void * data , uint32_t length ) { <nl> + int Server : : send ( int session_id , const void * data , uint32_t length ) { <nl> return serv . send ( & serv , session_id , data , length ) ; <nl> } <nl> <nl> mmm a / core - tests / src / client / client . cpp <nl> ppp b / core - tests / src / client / client . cpp <nl> TEST ( client , tcp ) { <nl> <nl> Process proc ( [ ] ( Process * proc ) { <nl> on_receive_lambda_type receive_fn = [ ] ( ON_RECEIVE_PARAMS ) { <nl> - char * data_ptr = NULL ; <nl> - size_t data_len = SERVER_THIS - > get_packet ( req , ( char * * ) & data_ptr ) ; <nl> - <nl> - SERVER_THIS - > send ( req - > info . fd , data_ptr , data_len ) ; <nl> + SERVER_THIS - > send ( req - > info . fd , req - > data , req - > info . len ) ; <nl> } ; <nl> <nl> Server serv ( TEST_HOST , TEST_PORT , SW_MODE_BASE , SW_SOCK_TCP ) ; <nl> TEST ( client , tcp ) { <nl> ASSERT_EQ ( ret , GREETER_SIZE ) ; <nl> ASSERT_STREQ ( GREETER , buf ) ; <nl> cli . close ( & cli ) ; <nl> - kill ( pid , SIGKILL ) ; <nl> + <nl> + kill ( pid , SIGTERM ) ; <nl> + int status ; <nl> + wait ( & status ) ; <nl> } <nl> <nl> TEST ( client , udp ) { <nl> TEST ( client , udp ) { <nl> <nl> Process proc ( [ ] ( Process * proc ) { <nl> on_packet_lambda_type packet_fn = [ ] ( ON_PACKET_PARAMS ) { <nl> - swDgramPacket * packet = nullptr ; <nl> - SERVER_THIS - > get_packet ( req , ( char * * ) & packet ) ; <nl> - <nl> + swDgramPacket * packet = ( swDgramPacket * ) req - > data ; <nl> SERVER_THIS - > sendto ( & packet - > socket_addr , packet - > data , packet - > length , req - > info . server_fd ) ; <nl> } ; <nl> <nl> TEST ( client , udp ) { <nl> ASSERT_EQ ( ret , GREETER_SIZE ) ; <nl> ASSERT_STREQ ( GREETER , buf ) ; <nl> cli . close ( & cli ) ; <nl> - kill ( pid , SIGKILL ) ; <nl> + <nl> + kill ( pid , SIGTERM ) ; <nl> + int status ; <nl> + wait ( & status ) ; <nl> } <nl> <nl> TEST ( client , async_tcp ) { <nl> TEST ( client , async_tcp ) { <nl> <nl> Process proc ( [ & p ] ( Process * proc ) { <nl> on_receive_lambda_type receive_fn = [ ] ( ON_RECEIVE_PARAMS ) { <nl> - char * data_ptr = NULL ; <nl> - size_t data_len = SERVER_THIS - > get_packet ( req , ( char * * ) & data_ptr ) ; <nl> - <nl> - SERVER_THIS - > send ( req - > info . fd , data_ptr , data_len ) ; <nl> + SERVER_THIS - > send ( req - > info . fd , req - > data , req - > info . len ) ; <nl> } ; <nl> <nl> Server serv ( TEST_HOST , TEST_PORT , SW_MODE_BASE , SW_SOCK_TCP ) ; <nl> TEST ( client , async_tcp ) { <nl> <nl> swoole_event_wait ( ) ; <nl> <nl> - kill ( pid , SIGKILL ) ; <nl> + kill ( pid , SIGTERM ) ; <nl> + int status ; <nl> + wait ( & status ) ; <nl> } <nl> mmm a / core - tests / src / coroutine / socket . cpp <nl> ppp b / core - tests / src / coroutine / socket . cpp <nl> TEST ( coroutine_socket , recv_success ) { <nl> <nl> Process proc ( [ ] ( Process * proc ) { <nl> on_receive_lambda_type receive_fn = [ ] ( ON_RECEIVE_PARAMS ) { <nl> - char * data_ptr = NULL ; <nl> - size_t data_len = SERVER_THIS - > get_packet ( req , ( char * * ) & data_ptr ) ; <nl> - <nl> - SERVER_THIS - > send ( req - > info . fd , data_ptr , data_len ) ; <nl> + SERVER_THIS - > send ( req - > info . fd , req - > data , req - > info . len ) ; <nl> } ; <nl> <nl> Server serv ( TEST_HOST , TEST_PORT , SW_MODE_BASE , SW_SOCK_TCP ) ; <nl> TEST ( coroutine_socket , recv_fail ) { <nl> ASSERT_EQ ( n , 0 ) ; <nl> } ) ; <nl> <nl> - kill ( pid , SIGKILL ) ; <nl> + kill ( pid , SIGTERM ) ; <nl> + int status ; <nl> + wait ( & status ) ; <nl> } <nl> <nl> TEST ( coroutine_socket , bind_success ) { <nl> TEST ( coroutine_socket , listen ) { <nl> <nl> TEST ( coroutine_socket , accept ) { <nl> coroutine : : run ( { [ ] ( void * arg ) { <nl> - Socket sock ( SW_SOCK_TCP ) ; <nl> - bool retval = sock . bind ( " 127 . 0 . 0 . 1 " , 9909 ) ; <nl> - ASSERT_EQ ( retval , true ) ; <nl> - ASSERT_EQ ( sock . listen ( 128 ) , true ) ; <nl> + Socket sock ( SW_SOCK_TCP ) ; <nl> + bool retval = sock . bind ( " 127 . 0 . 0 . 1 " , 9909 ) ; <nl> + ASSERT_EQ ( retval , true ) ; <nl> + ASSERT_EQ ( sock . listen ( 128 ) , true ) ; <nl> <nl> - Socket * conn = sock . accept ( ) ; <nl> - ASSERT_NE ( conn , nullptr ) ; <nl> - } , <nl> + Socket * conn = sock . accept ( ) ; <nl> + ASSERT_NE ( conn , nullptr ) ; <nl> + } , <nl> <nl> - [ ] ( void * arg ) { <nl> - Socket sock ( SW_SOCK_TCP ) ; <nl> - bool retval = sock . connect ( " 127 . 0 . 0 . 1 " , 9909 , - 1 ) ; <nl> - ASSERT_EQ ( retval , true ) ; <nl> - ASSERT_EQ ( sock . errCode , 0 ) ; <nl> - sock . close ( ) ; <nl> - } } ) ; <nl> + [ ] ( void * arg ) { <nl> + Socket sock ( SW_SOCK_TCP ) ; <nl> + bool retval = sock . connect ( " 127 . 0 . 0 . 1 " , 9909 , - 1 ) ; <nl> + ASSERT_EQ ( retval , true ) ; <nl> + ASSERT_EQ ( sock . errCode , 0 ) ; <nl> + sock . close ( ) ; <nl> + } } ) ; <nl> } <nl> <nl> # define CRLF " \ r \ n " <nl> static void socket_set_eof_protocol ( Socket & sock ) { <nl> <nl> TEST ( coroutine_socket , eof_1 ) { <nl> coroutine : : run ( { [ ] ( void * arg ) { <nl> - Socket sock ( SW_SOCK_TCP ) ; <nl> - bool retval = sock . bind ( " 127 . 0 . 0 . 1 " , 9909 ) ; <nl> - ASSERT_EQ ( retval , true ) ; <nl> - ASSERT_EQ ( sock . listen ( 128 ) , true ) ; <nl> + Socket sock ( SW_SOCK_TCP ) ; <nl> + bool retval = sock . bind ( " 127 . 0 . 0 . 1 " , 9909 ) ; <nl> + ASSERT_EQ ( retval , true ) ; <nl> + ASSERT_EQ ( sock . listen ( 128 ) , true ) ; <nl> <nl> - Socket * conn = sock . accept ( ) ; <nl> - char buf [ 1024 ] ; <nl> - ssize_t l = conn - > recv ( buf , sizeof ( buf ) ) ; <nl> - EXPECT_EQ ( string ( buf , l ) , string ( " start \ r \ n " ) ) ; <nl> - conn - > send ( EOF_PACKET ) ; <nl> - } , <nl> + Socket * conn = sock . accept ( ) ; <nl> + char buf [ 1024 ] ; <nl> + ssize_t l = conn - > recv ( buf , sizeof ( buf ) ) ; <nl> + EXPECT_EQ ( string ( buf , l ) , string ( " start \ r \ n " ) ) ; <nl> + conn - > send ( EOF_PACKET ) ; <nl> + } , <nl> <nl> - [ ] ( void * arg ) { <nl> - Socket sock ( SW_SOCK_TCP ) ; <nl> - bool retval = sock . connect ( " 127 . 0 . 0 . 1 " , 9909 , - 1 ) ; <nl> - ASSERT_EQ ( retval , true ) ; <nl> - ASSERT_EQ ( sock . errCode , 0 ) ; <nl> - sock . send ( " start \ r \ n " ) ; <nl> + [ ] ( void * arg ) { <nl> + Socket sock ( SW_SOCK_TCP ) ; <nl> + bool retval = sock . connect ( " 127 . 0 . 0 . 1 " , 9909 , - 1 ) ; <nl> + ASSERT_EQ ( retval , true ) ; <nl> + ASSERT_EQ ( sock . errCode , 0 ) ; <nl> + sock . send ( " start \ r \ n " ) ; <nl> <nl> - socket_set_eof_protocol ( sock ) ; <nl> + socket_set_eof_protocol ( sock ) ; <nl> <nl> - ssize_t l = sock . recv_packet ( RECV_TIMEOUT ) ; <nl> - size_t eof_packet_len = strlen ( EOF_PACKET ) ; <nl> - auto buf = sock . get_read_buffer ( ) ; <nl> + ssize_t l = sock . recv_packet ( RECV_TIMEOUT ) ; <nl> + size_t eof_packet_len = strlen ( EOF_PACKET ) ; <nl> + auto buf = sock . get_read_buffer ( ) ; <nl> <nl> - ASSERT_EQ ( l , eof_packet_len ) ; <nl> - ASSERT_EQ ( string ( buf - > str , l ) , string ( EOF_PACKET ) ) ; <nl> - ASSERT_EQ ( buf - > length , eof_packet_len ) ; <nl> - ASSERT_EQ ( buf - > offset , eof_packet_len ) ; <nl> - } } ) ; <nl> + ASSERT_EQ ( l , eof_packet_len ) ; <nl> + ASSERT_EQ ( string ( buf - > str , l ) , string ( EOF_PACKET ) ) ; <nl> + ASSERT_EQ ( buf - > length , eof_packet_len ) ; <nl> + ASSERT_EQ ( buf - > offset , eof_packet_len ) ; <nl> + } } ) ; <nl> } <nl> <nl> TEST ( coroutine_socket , eof_2 ) { <nl> coroutine : : run ( { [ ] ( void * arg ) { <nl> - Socket sock ( SW_SOCK_TCP ) ; <nl> - bool retval = sock . bind ( " 127 . 0 . 0 . 1 " , 9909 ) ; <nl> - ASSERT_EQ ( retval , true ) ; <nl> - ASSERT_EQ ( sock . listen ( 128 ) , true ) ; <nl> - <nl> - Socket * conn = sock . accept ( ) ; <nl> - char buf [ 1024 ] ; <nl> - ssize_t l = conn - > recv ( buf , sizeof ( buf ) ) ; <nl> - EXPECT_EQ ( string ( buf , l ) , string ( " start \ r \ n " ) ) ; <nl> - conn - > send ( EOF_PACKET EOF_PACKET_2 ) ; <nl> - } , <nl> - <nl> - [ ] ( void * arg ) { <nl> - Socket sock ( SW_SOCK_TCP ) ; <nl> - bool retval = sock . connect ( " 127 . 0 . 0 . 1 " , 9909 , - 1 ) ; <nl> - ASSERT_EQ ( retval , true ) ; <nl> - ASSERT_EQ ( sock . errCode , 0 ) ; <nl> - sock . send ( " start \ r \ n " ) ; <nl> - <nl> - socket_set_eof_protocol ( sock ) ; <nl> - <nl> - / / packet 1 <nl> - { <nl> - ssize_t l = sock . recv_packet ( RECV_TIMEOUT ) ; <nl> - size_t eof_packet_len = strlen ( EOF_PACKET ) ; <nl> - auto buf = sock . get_read_buffer ( ) ; <nl> + Socket sock ( SW_SOCK_TCP ) ; <nl> + bool retval = sock . bind ( " 127 . 0 . 0 . 1 " , 9909 ) ; <nl> + ASSERT_EQ ( retval , true ) ; <nl> + ASSERT_EQ ( sock . listen ( 128 ) , true ) ; <nl> <nl> - ASSERT_EQ ( l , eof_packet_len ) ; <nl> - ASSERT_EQ ( string ( buf - > str , l ) , string ( EOF_PACKET ) ) ; <nl> - ASSERT_EQ ( buf - > length , strlen ( EOF_PACKET EOF_PACKET_2 ) ) ; <nl> - ASSERT_EQ ( buf - > offset , eof_packet_len ) ; <nl> - } <nl> - / / packet 2 <nl> - { <nl> - ssize_t l = sock . recv_packet ( RECV_TIMEOUT ) ; <nl> - size_t eof_packet_len = strlen ( EOF_PACKET_2 ) ; <nl> - auto buf = sock . get_read_buffer ( ) ; <nl> + Socket * conn = sock . accept ( ) ; <nl> + char buf [ 1024 ] ; <nl> + ssize_t l = conn - > recv ( buf , sizeof ( buf ) ) ; <nl> + EXPECT_EQ ( string ( buf , l ) , string ( " start \ r \ n " ) ) ; <nl> + conn - > send ( EOF_PACKET EOF_PACKET_2 ) ; <nl> + } , <nl> <nl> - ASSERT_EQ ( l , eof_packet_len ) ; <nl> - ASSERT_EQ ( string ( buf - > str , l ) , string ( EOF_PACKET_2 ) ) ; <nl> - ASSERT_EQ ( buf - > length , strlen ( EOF_PACKET_2 ) ) ; <nl> - ASSERT_EQ ( buf - > offset , eof_packet_len ) ; <nl> - } <nl> - } } ) ; <nl> + [ ] ( void * arg ) { <nl> + Socket sock ( SW_SOCK_TCP ) ; <nl> + bool retval = sock . connect ( " 127 . 0 . 0 . 1 " , 9909 , - 1 ) ; <nl> + ASSERT_EQ ( retval , true ) ; <nl> + ASSERT_EQ ( sock . errCode , 0 ) ; <nl> + sock . send ( " start \ r \ n " ) ; <nl> + <nl> + socket_set_eof_protocol ( sock ) ; <nl> + <nl> + / / packet 1 <nl> + { <nl> + ssize_t l = sock . recv_packet ( RECV_TIMEOUT ) ; <nl> + size_t eof_packet_len = strlen ( EOF_PACKET ) ; <nl> + auto buf = sock . get_read_buffer ( ) ; <nl> + <nl> + ASSERT_EQ ( l , eof_packet_len ) ; <nl> + ASSERT_EQ ( string ( buf - > str , l ) , string ( EOF_PACKET ) ) ; <nl> + ASSERT_EQ ( buf - > length , strlen ( EOF_PACKET EOF_PACKET_2 ) ) ; <nl> + ASSERT_EQ ( buf - > offset , eof_packet_len ) ; <nl> + } <nl> + / / packet 2 <nl> + { <nl> + ssize_t l = sock . recv_packet ( RECV_TIMEOUT ) ; <nl> + size_t eof_packet_len = strlen ( EOF_PACKET_2 ) ; <nl> + auto buf = sock . get_read_buffer ( ) ; <nl> + <nl> + ASSERT_EQ ( l , eof_packet_len ) ; <nl> + ASSERT_EQ ( string ( buf - > str , l ) , string ( EOF_PACKET_2 ) ) ; <nl> + ASSERT_EQ ( buf - > length , strlen ( EOF_PACKET_2 ) ) ; <nl> + ASSERT_EQ ( buf - > offset , eof_packet_len ) ; <nl> + } <nl> + } } ) ; <nl> } <nl> <nl> TEST ( coroutine_socket , eof_3 ) { <nl> coroutine : : run ( { [ ] ( void * arg ) { <nl> - Socket sock ( SW_SOCK_TCP ) ; <nl> - bool retval = sock . bind ( " 127 . 0 . 0 . 1 " , 9909 ) ; <nl> - ASSERT_EQ ( retval , true ) ; <nl> - ASSERT_EQ ( sock . listen ( 128 ) , true ) ; <nl> + Socket sock ( SW_SOCK_TCP ) ; <nl> + bool retval = sock . bind ( " 127 . 0 . 0 . 1 " , 9909 ) ; <nl> + ASSERT_EQ ( retval , true ) ; <nl> + ASSERT_EQ ( sock . listen ( 128 ) , true ) ; <nl> <nl> - Socket * conn = sock . accept ( ) ; <nl> - char buf [ 1024 ] ; <nl> - ssize_t l = conn - > recv ( buf , sizeof ( buf ) ) ; <nl> - EXPECT_EQ ( string ( buf , l ) , string ( " start \ r \ n " ) ) ; <nl> - conn - > shutdown ( ) ; <nl> - } , <nl> + Socket * conn = sock . accept ( ) ; <nl> + char buf [ 1024 ] ; <nl> + ssize_t l = conn - > recv ( buf , sizeof ( buf ) ) ; <nl> + EXPECT_EQ ( string ( buf , l ) , string ( " start \ r \ n " ) ) ; <nl> + conn - > shutdown ( ) ; <nl> + } , <nl> <nl> - [ ] ( void * arg ) { <nl> - Socket sock ( SW_SOCK_TCP ) ; <nl> - bool retval = sock . connect ( " 127 . 0 . 0 . 1 " , 9909 , - 1 ) ; <nl> - ASSERT_EQ ( retval , true ) ; <nl> - ASSERT_EQ ( sock . errCode , 0 ) ; <nl> - sock . send ( " start \ r \ n " ) ; <nl> + [ ] ( void * arg ) { <nl> + Socket sock ( SW_SOCK_TCP ) ; <nl> + bool retval = sock . connect ( " 127 . 0 . 0 . 1 " , 9909 , - 1 ) ; <nl> + ASSERT_EQ ( retval , true ) ; <nl> + ASSERT_EQ ( sock . errCode , 0 ) ; <nl> + sock . send ( " start \ r \ n " ) ; <nl> <nl> - socket_set_eof_protocol ( sock ) ; <nl> + socket_set_eof_protocol ( sock ) ; <nl> <nl> - ssize_t l = sock . recv_packet ( RECV_TIMEOUT ) ; <nl> - ASSERT_EQ ( l , 0 ) ; <nl> - } } ) ; <nl> + ssize_t l = sock . recv_packet ( RECV_TIMEOUT ) ; <nl> + ASSERT_EQ ( l , 0 ) ; <nl> + } } ) ; <nl> } <nl> <nl> TEST ( coroutine_socket , eof_4 ) { <nl> coroutine : : run ( { [ ] ( void * arg ) { <nl> - Socket sock ( SW_SOCK_TCP ) ; <nl> - bool retval = sock . bind ( " 127 . 0 . 0 . 1 " , 9909 ) ; <nl> - ASSERT_EQ ( retval , true ) ; <nl> - ASSERT_EQ ( sock . listen ( 128 ) , true ) ; <nl> + Socket sock ( SW_SOCK_TCP ) ; <nl> + bool retval = sock . bind ( " 127 . 0 . 0 . 1 " , 9909 ) ; <nl> + ASSERT_EQ ( retval , true ) ; <nl> + ASSERT_EQ ( sock . listen ( 128 ) , true ) ; <nl> <nl> - Socket * conn = sock . accept ( ) ; <nl> - char buf [ 1024 ] ; <nl> - ssize_t l = conn - > recv ( buf , sizeof ( buf ) ) ; <nl> - EXPECT_EQ ( string ( buf , l ) , string ( " start \ r \ n " ) ) ; <nl> - conn - > send ( EOF_PACKET , strlen ( EOF_PACKET ) - strlen ( CRLF ) ) ; / / no eof <nl> - conn - > shutdown ( ) ; <nl> - } , <nl> + Socket * conn = sock . accept ( ) ; <nl> + char buf [ 1024 ] ; <nl> + ssize_t l = conn - > recv ( buf , sizeof ( buf ) ) ; <nl> + EXPECT_EQ ( string ( buf , l ) , string ( " start \ r \ n " ) ) ; <nl> + conn - > send ( EOF_PACKET , strlen ( EOF_PACKET ) - strlen ( CRLF ) ) ; / / no eof <nl> + conn - > shutdown ( ) ; <nl> + } , <nl> <nl> - [ ] ( void * arg ) { <nl> - Socket sock ( SW_SOCK_TCP ) ; <nl> - bool retval = sock . connect ( " 127 . 0 . 0 . 1 " , 9909 , - 1 ) ; <nl> - ASSERT_EQ ( retval , true ) ; <nl> - ASSERT_EQ ( sock . errCode , 0 ) ; <nl> - sock . send ( " start \ r \ n " ) ; <nl> + [ ] ( void * arg ) { <nl> + Socket sock ( SW_SOCK_TCP ) ; <nl> + bool retval = sock . connect ( " 127 . 0 . 0 . 1 " , 9909 , - 1 ) ; <nl> + ASSERT_EQ ( retval , true ) ; <nl> + ASSERT_EQ ( sock . errCode , 0 ) ; <nl> + sock . send ( " start \ r \ n " ) ; <nl> <nl> - socket_set_eof_protocol ( sock ) ; <nl> + socket_set_eof_protocol ( sock ) ; <nl> <nl> - ssize_t l = sock . recv_packet ( RECV_TIMEOUT ) ; <nl> - ASSERT_EQ ( l , 0 ) ; <nl> + ssize_t l = sock . recv_packet ( RECV_TIMEOUT ) ; <nl> + ASSERT_EQ ( l , 0 ) ; <nl> <nl> - auto buf = sock . get_read_buffer ( ) ; <nl> - ASSERT_EQ ( string ( buf - > str , 10 ) , string ( EOF_PACKET , 10 ) ) ; <nl> - } } ) ; <nl> + auto buf = sock . get_read_buffer ( ) ; <nl> + ASSERT_EQ ( string ( buf - > str , 10 ) , string ( EOF_PACKET , 10 ) ) ; <nl> + } } ) ; <nl> } <nl> <nl> TEST ( coroutine_socket , eof_5 ) { <nl> coroutine : : run ( { [ ] ( void * arg ) { <nl> - Socket sock ( SW_SOCK_TCP ) ; <nl> - bool retval = sock . bind ( " 127 . 0 . 0 . 1 " , 9909 ) ; <nl> - ASSERT_EQ ( retval , true ) ; <nl> - ASSERT_EQ ( sock . listen ( 128 ) , true ) ; <nl> + Socket sock ( SW_SOCK_TCP ) ; <nl> + bool retval = sock . bind ( " 127 . 0 . 0 . 1 " , 9909 ) ; <nl> + ASSERT_EQ ( retval , true ) ; <nl> + ASSERT_EQ ( sock . listen ( 128 ) , true ) ; <nl> <nl> - Socket * conn = sock . accept ( ) ; <nl> - char buf [ 1024 ] ; <nl> - ssize_t l = conn - > recv ( buf , sizeof ( buf ) ) ; <nl> - EXPECT_EQ ( string ( buf , l ) , string ( " start \ r \ n " ) ) ; <nl> + Socket * conn = sock . accept ( ) ; <nl> + char buf [ 1024 ] ; <nl> + ssize_t l = conn - > recv ( buf , sizeof ( buf ) ) ; <nl> + EXPECT_EQ ( string ( buf , l ) , string ( " start \ r \ n " ) ) ; <nl> <nl> - swString * s = swoole : : make_string ( 128 * 1024 ) ; <nl> - swString_repeat ( s , " A " , 1 , 128 * 1024 - 16 ) ; <nl> - swString_append_ptr ( s , SW_STRL ( CRLF ) ) ; <nl> + swString * s = swoole : : make_string ( 128 * 1024 ) ; <nl> + swString_repeat ( s , " A " , 1 , 128 * 1024 - 16 ) ; <nl> + swString_append_ptr ( s , SW_STRL ( CRLF ) ) ; <nl> <nl> - conn - > send_all ( s - > str , s - > length ) ; <nl> - } , <nl> + conn - > send_all ( s - > str , s - > length ) ; <nl> + } , <nl> <nl> - [ ] ( void * arg ) { <nl> - Socket sock ( SW_SOCK_TCP ) ; <nl> - bool retval = sock . connect ( " 127 . 0 . 0 . 1 " , 9909 , - 1 ) ; <nl> - ASSERT_EQ ( retval , true ) ; <nl> - ASSERT_EQ ( sock . errCode , 0 ) ; <nl> - sock . send ( " start \ r \ n " ) ; <nl> + [ ] ( void * arg ) { <nl> + Socket sock ( SW_SOCK_TCP ) ; <nl> + bool retval = sock . connect ( " 127 . 0 . 0 . 1 " , 9909 , - 1 ) ; <nl> + ASSERT_EQ ( retval , true ) ; <nl> + ASSERT_EQ ( sock . errCode , 0 ) ; <nl> + sock . send ( " start \ r \ n " ) ; <nl> <nl> - socket_set_eof_protocol ( sock ) ; <nl> + socket_set_eof_protocol ( sock ) ; <nl> <nl> - ssize_t l = sock . recv_packet ( RECV_TIMEOUT ) ; <nl> - ASSERT_EQ ( l , 128 * 1024 - 14 ) ; <nl> - } } ) ; <nl> + ssize_t l = sock . recv_packet ( RECV_TIMEOUT ) ; <nl> + ASSERT_EQ ( l , 128 * 1024 - 14 ) ; <nl> + } } ) ; <nl> } <nl> <nl> TEST ( coroutine_socket , eof_6 ) { <nl> coroutine : : run ( { [ ] ( void * arg ) { <nl> - Socket sock ( SW_SOCK_TCP ) ; <nl> - bool retval = sock . bind ( " 127 . 0 . 0 . 1 " , 9909 ) ; <nl> - ASSERT_EQ ( retval , true ) ; <nl> - ASSERT_EQ ( sock . listen ( 128 ) , true ) ; <nl> + Socket sock ( SW_SOCK_TCP ) ; <nl> + bool retval = sock . bind ( " 127 . 0 . 0 . 1 " , 9909 ) ; <nl> + ASSERT_EQ ( retval , true ) ; <nl> + ASSERT_EQ ( sock . listen ( 128 ) , true ) ; <nl> <nl> - Socket * conn = sock . accept ( ) ; <nl> - char buf [ 1024 ] ; <nl> - ssize_t l = conn - > recv ( buf , sizeof ( buf ) ) ; <nl> - EXPECT_EQ ( string ( buf , l ) , string ( " start \ r \ n " ) ) ; <nl> + Socket * conn = sock . accept ( ) ; <nl> + char buf [ 1024 ] ; <nl> + ssize_t l = conn - > recv ( buf , sizeof ( buf ) ) ; <nl> + EXPECT_EQ ( string ( buf , l ) , string ( " start \ r \ n " ) ) ; <nl> <nl> - swString * s = swoole : : make_string ( 128 * 1024 ) ; <nl> - swString_repeat ( s , " A " , 1 , 128 * 1024 - 16 ) ; <nl> - swString_append_ptr ( s , SW_STRL ( CRLF ) ) ; <nl> + swString * s = swoole : : make_string ( 128 * 1024 ) ; <nl> + swString_repeat ( s , " A " , 1 , 128 * 1024 - 16 ) ; <nl> + swString_append_ptr ( s , SW_STRL ( CRLF ) ) ; <nl> <nl> - conn - > send_all ( s - > str , s - > length ) ; <nl> - } , <nl> + conn - > send_all ( s - > str , s - > length ) ; <nl> + } , <nl> <nl> - [ ] ( void * arg ) { <nl> - Socket sock ( SW_SOCK_TCP ) ; <nl> - bool retval = sock . connect ( " 127 . 0 . 0 . 1 " , 9909 , - 1 ) ; <nl> - ASSERT_EQ ( retval , true ) ; <nl> - ASSERT_EQ ( sock . errCode , 0 ) ; <nl> - sock . send ( " start \ r \ n " ) ; <nl> + [ ] ( void * arg ) { <nl> + Socket sock ( SW_SOCK_TCP ) ; <nl> + bool retval = sock . connect ( " 127 . 0 . 0 . 1 " , 9909 , - 1 ) ; <nl> + ASSERT_EQ ( retval , true ) ; <nl> + ASSERT_EQ ( sock . errCode , 0 ) ; <nl> + sock . send ( " start \ r \ n " ) ; <nl> <nl> - socket_set_eof_protocol ( sock ) ; <nl> - sock . protocol . package_max_length = 1024 * 64 ; <nl> + socket_set_eof_protocol ( sock ) ; <nl> + sock . protocol . package_max_length = 1024 * 64 ; <nl> <nl> - ssize_t l = sock . recv_packet ( RECV_TIMEOUT ) ; <nl> - ASSERT_EQ ( l , - 1 ) ; <nl> - ASSERT_EQ ( sock . errCode , SW_ERROR_PACKAGE_LENGTH_TOO_LARGE ) ; <nl> - } } ) ; <nl> + ssize_t l = sock . recv_packet ( RECV_TIMEOUT ) ; <nl> + ASSERT_EQ ( l , - 1 ) ; <nl> + ASSERT_EQ ( sock . errCode , SW_ERROR_PACKAGE_LENGTH_TOO_LARGE ) ; <nl> + } } ) ; <nl> } <nl> <nl> static void socket_set_length_protocol_1 ( Socket & sock ) { <nl> static void socket_set_length_protocol_2 ( Socket & sock ) { <nl> <nl> TEST ( coroutine_socket , length_1 ) { <nl> coroutine : : run ( { [ ] ( void * arg ) { <nl> - Socket sock ( SW_SOCK_TCP ) ; <nl> - bool retval = sock . bind ( " 127 . 0 . 0 . 1 " , 9502 ) ; <nl> - ASSERT_EQ ( retval , true ) ; <nl> - ASSERT_EQ ( sock . listen ( 128 ) , true ) ; <nl> + Socket sock ( SW_SOCK_TCP ) ; <nl> + bool retval = sock . bind ( " 127 . 0 . 0 . 1 " , 9502 ) ; <nl> + ASSERT_EQ ( retval , true ) ; <nl> + ASSERT_EQ ( sock . listen ( 128 ) , true ) ; <nl> <nl> - Socket * conn = sock . accept ( ) ; <nl> - char buf [ 1024 ] ; <nl> - ssize_t l = swoole_random_bytes ( buf + 2 , sizeof ( buf ) - 2 ) ; <nl> - * ( uint16_t * ) buf = htons ( l ) ; <nl> + Socket * conn = sock . accept ( ) ; <nl> + char buf [ 1024 ] ; <nl> + ssize_t l = swoole_random_bytes ( buf + 2 , sizeof ( buf ) - 2 ) ; <nl> + * ( uint16_t * ) buf = htons ( l ) ; <nl> <nl> - conn - > send ( buf , l + 2 ) ; <nl> - } , <nl> + conn - > send ( buf , l + 2 ) ; <nl> + } , <nl> <nl> - [ ] ( void * arg ) { <nl> - Socket sock ( SW_SOCK_TCP ) ; <nl> - bool retval = sock . connect ( " 127 . 0 . 0 . 1 " , 9502 , - 1 ) ; <nl> - ASSERT_EQ ( retval , true ) ; <nl> - ASSERT_EQ ( sock . errCode , 0 ) ; <nl> + [ ] ( void * arg ) { <nl> + Socket sock ( SW_SOCK_TCP ) ; <nl> + bool retval = sock . connect ( " 127 . 0 . 0 . 1 " , 9502 , - 1 ) ; <nl> + ASSERT_EQ ( retval , true ) ; <nl> + ASSERT_EQ ( sock . errCode , 0 ) ; <nl> <nl> - socket_set_length_protocol_1 ( sock ) ; <nl> + socket_set_length_protocol_1 ( sock ) ; <nl> <nl> - ssize_t l = sock . recv_packet ( RECV_TIMEOUT ) ; <nl> - auto buf = sock . get_read_buffer ( ) ; <nl> + ssize_t l = sock . recv_packet ( RECV_TIMEOUT ) ; <nl> + auto buf = sock . get_read_buffer ( ) ; <nl> <nl> - ASSERT_EQ ( l , 1024 ) ; <nl> - ASSERT_EQ ( buf - > length , l ) ; <nl> - ASSERT_EQ ( buf - > offset , l ) ; <nl> - } } ) ; <nl> + ASSERT_EQ ( l , 1024 ) ; <nl> + ASSERT_EQ ( buf - > length , l ) ; <nl> + ASSERT_EQ ( buf - > offset , l ) ; <nl> + } } ) ; <nl> } <nl> <nl> TEST ( coroutine_socket , length_2 ) { <nl> coroutine : : run ( { [ ] ( void * arg ) { <nl> - Socket sock ( SW_SOCK_TCP ) ; <nl> - bool retval = sock . bind ( " 127 . 0 . 0 . 1 " , 9502 ) ; <nl> - ASSERT_EQ ( retval , true ) ; <nl> - ASSERT_EQ ( sock . listen ( 128 ) , true ) ; <nl> + Socket sock ( SW_SOCK_TCP ) ; <nl> + bool retval = sock . bind ( " 127 . 0 . 0 . 1 " , 9502 ) ; <nl> + ASSERT_EQ ( retval , true ) ; <nl> + ASSERT_EQ ( sock . listen ( 128 ) , true ) ; <nl> <nl> - Socket * conn = sock . accept ( ) ; <nl> - char buf [ 1024 ] ; <nl> - * ( uint16_t * ) buf = htons ( 0 ) ; <nl> + Socket * conn = sock . accept ( ) ; <nl> + char buf [ 1024 ] ; <nl> + * ( uint16_t * ) buf = htons ( 0 ) ; <nl> <nl> - conn - > send ( buf , 2 ) ; <nl> - } , <nl> + conn - > send ( buf , 2 ) ; <nl> + } , <nl> <nl> - [ ] ( void * arg ) { <nl> - Socket sock ( SW_SOCK_TCP ) ; <nl> - bool retval = sock . connect ( " 127 . 0 . 0 . 1 " , 9502 , - 1 ) ; <nl> - ASSERT_EQ ( retval , true ) ; <nl> - ASSERT_EQ ( sock . errCode , 0 ) ; <nl> + [ ] ( void * arg ) { <nl> + Socket sock ( SW_SOCK_TCP ) ; <nl> + bool retval = sock . connect ( " 127 . 0 . 0 . 1 " , 9502 , - 1 ) ; <nl> + ASSERT_EQ ( retval , true ) ; <nl> + ASSERT_EQ ( sock . errCode , 0 ) ; <nl> <nl> - socket_set_length_protocol_1 ( sock ) ; <nl> + socket_set_length_protocol_1 ( sock ) ; <nl> <nl> - ssize_t l = sock . recv_packet ( RECV_TIMEOUT ) ; <nl> - auto buf = sock . get_read_buffer ( ) ; <nl> + ssize_t l = sock . recv_packet ( RECV_TIMEOUT ) ; <nl> + auto buf = sock . get_read_buffer ( ) ; <nl> <nl> - ASSERT_EQ ( l , 2 ) ; <nl> - ASSERT_EQ ( buf - > length , 2 ) ; <nl> - ASSERT_EQ ( buf - > offset , 2 ) ; <nl> - } } ) ; <nl> + ASSERT_EQ ( l , 2 ) ; <nl> + ASSERT_EQ ( buf - > length , 2 ) ; <nl> + ASSERT_EQ ( buf - > offset , 2 ) ; <nl> + } } ) ; <nl> } <nl> <nl> TEST ( coroutine_socket , length_3 ) { <nl> coroutine : : run ( { [ ] ( void * arg ) { <nl> - Socket sock ( SW_SOCK_TCP ) ; <nl> - bool retval = sock . bind ( " 127 . 0 . 0 . 1 " , 9502 ) ; <nl> - ASSERT_EQ ( retval , true ) ; <nl> - ASSERT_EQ ( sock . listen ( 128 ) , true ) ; <nl> + Socket sock ( SW_SOCK_TCP ) ; <nl> + bool retval = sock . bind ( " 127 . 0 . 0 . 1 " , 9502 ) ; <nl> + ASSERT_EQ ( retval , true ) ; <nl> + ASSERT_EQ ( sock . listen ( 128 ) , true ) ; <nl> <nl> - Socket * conn = sock . accept ( ) ; <nl> - char buf [ 1024 ] ; <nl> - memset ( buf , ' A ' , sizeof ( buf ) ) ; <nl> - * ( uint16_t * ) buf = htons ( 65530 ) ; <nl> + Socket * conn = sock . accept ( ) ; <nl> + char buf [ 1024 ] ; <nl> + memset ( buf , ' A ' , sizeof ( buf ) ) ; <nl> + * ( uint16_t * ) buf = htons ( 65530 ) ; <nl> <nl> - conn - > send ( buf , sizeof ( buf ) ) ; <nl> - } , <nl> + conn - > send ( buf , sizeof ( buf ) ) ; <nl> + } , <nl> <nl> - [ ] ( void * arg ) { <nl> - Socket sock ( SW_SOCK_TCP ) ; <nl> - bool retval = sock . connect ( " 127 . 0 . 0 . 1 " , 9502 , - 1 ) ; <nl> - ASSERT_EQ ( retval , true ) ; <nl> - ASSERT_EQ ( sock . errCode , 0 ) ; <nl> + [ ] ( void * arg ) { <nl> + Socket sock ( SW_SOCK_TCP ) ; <nl> + bool retval = sock . connect ( " 127 . 0 . 0 . 1 " , 9502 , - 1 ) ; <nl> + ASSERT_EQ ( retval , true ) ; <nl> + ASSERT_EQ ( sock . errCode , 0 ) ; <nl> <nl> - socket_set_length_protocol_1 ( sock ) ; <nl> - sock . protocol . package_max_length = 4096 ; <nl> + socket_set_length_protocol_1 ( sock ) ; <nl> + sock . protocol . package_max_length = 4096 ; <nl> <nl> - ssize_t l = sock . recv_packet ( RECV_TIMEOUT ) ; <nl> - ASSERT_EQ ( l , - 1 ) ; <nl> - ASSERT_EQ ( sock . errCode , SW_ERROR_PACKAGE_LENGTH_TOO_LARGE ) ; <nl> - } } ) ; <nl> + ssize_t l = sock . recv_packet ( RECV_TIMEOUT ) ; <nl> + ASSERT_EQ ( l , - 1 ) ; <nl> + ASSERT_EQ ( sock . errCode , SW_ERROR_PACKAGE_LENGTH_TOO_LARGE ) ; <nl> + } } ) ; <nl> } <nl> <nl> static string pkt_1 ; <nl> mmm a / core - tests / src / network / stream . cpp <nl> ppp b / core - tests / src / network / stream . cpp <nl> TEST ( stream , send ) { <nl> <nl> serv . onWorkerStart = [ & lock ] ( swServer * serv , int worker_id ) { lock . unlock ( ) ; } ; <nl> <nl> - serv . onReceive = [ & buf ] ( swServer * serv , swEventData * req ) - > int { <nl> - char * data = nullptr ; <nl> - size_t length = serv - > get_packet ( serv , req , & data ) ; <nl> + serv . onReceive = [ & buf ] ( swServer * serv , swRecvData * req ) - > int { <nl> <nl> - string req_body ( data + 4 , length - 4 ) ; <nl> + string req_body ( req - > data + 4 , req - > info . len - 4 ) ; <nl> <nl> EXPECT_EQ ( string ( buf , sizeof ( buf ) ) , req_body ) ; <nl> <nl> mmm a / core - tests / src / server / buffer . cpp <nl> ppp b / core - tests / src / server / buffer . cpp <nl> TEST ( server , send_buffer ) { <nl> <nl> serv . onWorkerStart = [ & lock ] ( swServer * serv , int worker_id ) { lock . unlock ( ) ; } ; <nl> <nl> - serv . onReceive = [ ] ( swServer * serv , swEventData * req ) - > int { <nl> - char * data = nullptr ; <nl> - size_t length = serv - > get_packet ( serv , req , & data ) ; <nl> - EXPECT_EQ ( string ( data , length ) , string ( packet ) ) ; <nl> + serv . onReceive = [ ] ( swServer * serv , swRecvData * req ) - > int { <nl> + EXPECT_EQ ( string ( req - > data , req - > info . len ) , string ( packet ) ) ; <nl> <nl> swoole : : String resp ( swoole : : make_string ( 1024 * 1024 * 16 ) ) ; <nl> auto str = resp . get ( ) ; <nl> mmm a / core - tests / src / server / http . cpp <nl> ppp b / core - tests / src / server / http . cpp <nl> struct http_context { <nl> response_headers [ key ] = value ; <nl> } <nl> <nl> - void response ( int code , string body ) { <nl> + void response ( enum swHttp_status_code code , string body ) { <nl> response_headers [ " Content - Length " ] = to_string ( body . length ( ) ) ; <nl> response ( code ) ; <nl> server - > send ( server , fd , body . c_str ( ) , body . length ( ) ) ; <nl> static void test_run_server ( function < void ( swServer * ) > fn ) { <nl> child_thread = thread ( fn , serv ) ; <nl> } ; <nl> <nl> - serv . onReceive = [ ] ( swServer * serv , swEventData * task ) - > int { <nl> - char * data = nullptr ; <nl> - size_t length = serv - > get_packet ( serv , task , & data ) ; <nl> + serv . onReceive = [ ] ( swServer * serv , swRecvData * req ) - > int { <nl> + <nl> + int session_id = req - > info . fd ; <nl> + auto conn = serv - > get_connection_by_session_id ( session_id ) ; <nl> + <nl> + if ( conn - > websocket_status = = WEBSOCKET_STATUS_ACTIVE ) { <nl> + swString_clear ( SwooleTG . buffer_stack ) ; <nl> + std : : string resp = " Swoole : " + string ( req - > data , req - > info . len ) ; <nl> + swWebSocket_encode ( SwooleTG . buffer_stack , resp . c_str ( ) , resp . length ( ) , WEBSOCKET_OPCODE_TEXT , SW_WEBSOCKET_FLAG_FIN ) ; <nl> + serv - > send ( serv , session_id , SwooleTG . buffer_stack - > str , SwooleTG . buffer_stack - > length ) ; <nl> + return SW_OK ; <nl> + } <nl> <nl> llhttp_t parser = { } ; <nl> llhttp_settings_t settings = { } ; <nl> static void test_run_server ( function < void ( swServer * ) > fn ) { <nl> <nl> http_context ctx = { } ; <nl> parser . data = & ctx ; <nl> + ctx . server = serv ; <nl> + ctx . fd = session_id ; <nl> <nl> settings . on_url = handle_on_url ; <nl> settings . on_header_field = handle_on_header_field ; <nl> settings . on_header_value = handle_on_header_value ; <nl> settings . on_message_complete = handle_on_message_complete ; <nl> <nl> - enum llhttp_errno err = llhttp_execute ( & parser , data , length ) ; <nl> + enum llhttp_errno err = llhttp_execute ( & parser , req - > data , req - > info . len ) ; <nl> <nl> if ( err = = HPE_PAUSED_UPGRADE ) { <nl> - ctx . server = serv ; <nl> - ctx . fd = task - > info . fd ; <nl> <nl> ctx . setHeader ( " Connection " , " Upgrade " ) ; <nl> ctx . setHeader ( " Sec - WebSocket - Accept " , " IIRiohCjop4iJrmvySrFcwcXpHo = " ) ; <nl> static void test_run_server ( function < void ( swServer * ) > fn ) { <nl> ctx . setHeader ( " Upgrade " , " websocket " ) ; <nl> ctx . setHeader ( " Content - Length " , " 0 " ) ; <nl> <nl> - ctx . response ( 101 ) ; <nl> + ctx . response ( SW_HTTP_SWITCHING_PROTOCOLS ) ; <nl> + <nl> + conn - > websocket_status = WEBSOCKET_STATUS_ACTIVE ; <nl> <nl> return SW_OK ; <nl> } <nl> static void test_run_server ( function < void ( swServer * ) > fn ) { <nl> } <nl> EXPECT_EQ ( err , HPE_OK ) ; <nl> <nl> - ctx . server = serv ; <nl> - ctx . fd = task - > info . fd ; <nl> - ctx . response ( 200 , " hello world " ) ; <nl> + ctx . response ( SW_HTTP_OK , " hello world " ) ; <nl> <nl> EXPECT_EQ ( ctx . headers [ " User - Agent " ] , httplib : : USER_AGENT ) ; <nl> <nl> TEST ( http_server , static_get ) { <nl> } ) ; <nl> } <nl> <nl> - TEST ( http_server , websocket ) { <nl> + static void websocket_test ( int server_port , const char * data , size_t length ) { <nl> + <nl> + httplib : : Client cli ( TEST_HOST , server_port ) ; <nl> + <nl> + httplib : : Headers headers ; <nl> + EXPECT_TRUE ( cli . Upgrade ( " / websocket " , headers ) ) ; <nl> + EXPECT_TRUE ( cli . Push ( data , length ) ) ; <nl> + <nl> + auto msg = cli . Recv ( ) ; <nl> + EXPECT_EQ ( string ( msg - > payload , msg - > payload_length ) , string ( " Swoole : " ) + string ( data , length ) ) ; <nl> + } <nl> + <nl> + TEST ( http_server , websocket_small ) { <nl> test_run_server ( [ ] ( swServer * serv ) { <nl> swSignal_none ( ) ; <nl> + websocket_test ( serv - > get_primary_port ( ) - > port , SW_STRL ( " hello world , swoole is best ! " ) ) ; <nl> + kill ( getpid ( ) , SIGTERM ) ; <nl> + } ) ; <nl> + } <nl> <nl> - auto port = serv - > get_primary_port ( ) ; <nl> + TEST ( http_server , websocket_medium ) { <nl> + test_run_server ( [ ] ( swServer * serv ) { <nl> + swSignal_none ( ) ; <nl> <nl> - httplib : : Headers headers ; <nl> + swString * str = make_string ( 8192 ) ; <nl> + swString_repeat ( str , " A " , 1 , 8192 ) ; <nl> + websocket_test ( serv - > get_primary_port ( ) - > port , str - > str , str - > length ) ; <nl> <nl> - headers . emplace ( " Connection " , " Upgrade " ) ; <nl> - headers . emplace ( " Upgrade " , " websocket " ) ; <nl> - headers . emplace ( " Sec - Websocket - Key " , " sN9cRrP / n9NdMgdcy2VJFQ = = " ) ; <nl> - headers . emplace ( " Sec - WebSocket - Version " , " 13 " ) ; <nl> + swString_free ( str ) ; <nl> <nl> - httplib : : Client cli ( TEST_HOST , port - > port ) ; <nl> - auto resp = cli . Get ( " / websocket " , headers ) ; <nl> - EXPECT_EQ ( resp - > status , 101 ) ; <nl> + kill ( getpid ( ) , SIGTERM ) ; <nl> + } ) ; <nl> + } <nl> + <nl> + TEST ( http_server , websocket_big ) { <nl> + test_run_server ( [ ] ( swServer * serv ) { <nl> + swSignal_none ( ) ; <nl> + <nl> + swString * str = make_string ( 128 * 1024 ) ; <nl> + swString_repeat ( str , " A " , 1 , str - > size - 1 ) ; <nl> + websocket_test ( serv - > get_primary_port ( ) - > port , str - > str , str - > length ) ; <nl> + <nl> + swString_free ( str ) ; <nl> <nl> kill ( getpid ( ) , SIGTERM ) ; <nl> } ) ; <nl> mmm a / core - tests / src / server / server . cpp <nl> ppp b / core - tests / src / server / server . cpp <nl> <nl> <nl> # include " tests . h " <nl> # include " swoole_memory . h " <nl> + # include " lock . h " <nl> # include " wrapper / client . hpp " <nl> # include " swoole_log . h " <nl> <nl> TEST ( server , base ) { <nl> <nl> serv . onWorkerStart = [ & lock ] ( swServer * serv , int worker_id ) { lock . unlock ( ) ; } ; <nl> <nl> - serv . onReceive = [ ] ( swServer * serv , swEventData * req ) - > int { <nl> - char * data = nullptr ; <nl> - size_t length = serv - > get_packet ( serv , req , & data ) ; <nl> - EXPECT_EQ ( string ( data , length ) , string ( packet ) ) ; <nl> + serv . onReceive = [ ] ( swServer * serv , swRecvData * req ) - > int { <nl> + EXPECT_EQ ( string ( req - > data , req - > info . len ) , string ( packet ) ) ; <nl> <nl> string resp = string ( " Server : " ) + string ( packet ) ; <nl> serv - > send ( serv , req - > info . fd , resp . c_str ( ) , resp . length ( ) ) ; <nl> TEST ( server , process ) { <nl> <nl> serv . onWorkerStart = [ & lock ] ( swServer * serv , int worker_id ) { lock - > unlock ( lock ) ; } ; <nl> <nl> - serv . onReceive = [ ] ( swServer * serv , swEventData * req ) - > int { <nl> - char * data = nullptr ; <nl> - size_t length = serv - > get_packet ( serv , req , & data ) ; <nl> - EXPECT_EQ ( string ( data , length ) , string ( packet ) ) ; <nl> + serv . onReceive = [ ] ( swServer * serv , swRecvData * req ) - > int { <nl> + EXPECT_EQ ( string ( req - > data , req - > info . len ) , string ( packet ) ) ; <nl> <nl> string resp = string ( " Server : " ) + string ( packet ) ; <nl> serv - > send ( serv , req - > info . fd , resp . c_str ( ) , resp . length ( ) ) ; <nl> mmm a / examples / cpp / test_server . cc <nl> ppp b / examples / cpp / test_server . cc <nl> <nl> <nl> using namespace swoole ; <nl> <nl> - int my_onPacket ( swServer * serv , swEventData * req ) ; <nl> - int my_onReceive ( swServer * serv , swEventData * req ) ; <nl> + int my_onPacket ( swServer * serv , swRecvData * req ) ; <nl> + int my_onReceive ( swServer * serv , swRecvData * req ) ; <nl> void my_onStart ( swServer * serv ) ; <nl> void my_onShutdown ( swServer * serv ) ; <nl> void my_onConnect ( swServer * serv , swDataHead * info ) ; <nl> void my_onWorkerStop ( swServer * serv , int worker_id ) { <nl> swNotice ( " WorkerStop [ % d ] PID = % d " , worker_id , getpid ( ) ) ; <nl> } <nl> <nl> - int my_onReceive ( swServer * serv , swEventData * req ) { <nl> + int my_onReceive ( swServer * serv , swRecvData * req ) { <nl> int ret ; <nl> + char req_data [ SW_IPC_BUFFER_SIZE ] ; <nl> char resp_data [ SW_IPC_BUFFER_SIZE ] ; <nl> <nl> g_receive_count + + ; <nl> <nl> - swPacket_ptr * req_pkg = ( swPacket_ptr * ) req ; <nl> - swConnection * conn = serv - > get_connection_by_session_id ( req_pkg - > info . fd ) ; <nl> + swConnection * conn = serv - > get_connection_by_session_id ( req - > info . fd ) ; <nl> <nl> - swoole_rtrim ( req_pkg - > data . str , req_pkg - > data . length ) ; <nl> + memcpy ( req_data , req - > data , req - > info . len ) ; <nl> + swoole_rtrim ( req_data , req - > info . len ) ; <nl> swNotice ( " onReceive [ % d ] : ip = % s | port = % d Data = % s | Len = % d " , <nl> g_receive_count , <nl> swSocket_get_ip ( conn - > socket_type , & conn - > info ) , <nl> swSocket_get_port ( conn - > socket_type , & conn - > info ) , <nl> - req_pkg - > data . str , <nl> - req_pkg - > data . length ) ; <nl> + req_data , <nl> + req - > info . len ) ; <nl> <nl> - int n = sw_snprintf ( resp_data , SW_IPC_BUFFER_SIZE , " Server : % . * s \ n " , req_pkg - > data . length , req_pkg - > data . str ) ; <nl> + int n = sw_snprintf ( resp_data , SW_IPC_BUFFER_SIZE , " Server : % . * s \ n " , req - > info . len , req_data ) ; <nl> <nl> ret = serv - > send ( serv , req - > info . fd , resp_data , n ) ; <nl> if ( ret < 0 ) { <nl> int my_onReceive ( swServer * serv , swEventData * req ) { <nl> return SW_OK ; <nl> } <nl> <nl> - int my_onPacket ( swServer * serv , swEventData * req ) { <nl> - char * data ; <nl> - int length ; <nl> + int my_onPacket ( swServer * serv , swRecvData * req ) { <nl> char address [ 256 ] ; <nl> int port = 0 ; <nl> int ret = 0 ; <nl> <nl> swDgramPacket * packet ; <nl> <nl> - serv - > get_packet ( serv , req , & data ) ; <nl> - packet = ( swDgramPacket * ) data ; <nl> + packet = ( swDgramPacket * ) req - > data ; <nl> <nl> int serv_sock = req - > info . server_fd ; <nl> <nl> int my_onPacket ( swServer * serv , swEventData * req ) { <nl> abort ( ) ; <nl> } <nl> <nl> - data = packet - > data ; <nl> - length = packet - > length ; <nl> + char * data = packet - > data ; <nl> + uint32_t length = packet - > length ; <nl> <nl> swNotice ( " Packet [ client = % s : % d , % d bytes ] : data = % . * s " , address , port , length , length , data ) ; <nl> <nl> mmm a / include / http . h <nl> ppp b / include / http . h <nl> <nl> * / <nl> # pragma once <nl> <nl> - # include " server . h " <nl> + # include " swoole . h " <nl> <nl> enum swHttp_version { <nl> SW_HTTP_VERSION_10 = 1 , <nl> const char * swHttp_get_method_string ( int method ) ; <nl> const char * swHttp_get_status_message ( int code ) ; <nl> size_t swHttp_url_decode ( char * str , size_t len ) ; <nl> char * swHttp_url_encode ( char const * str , size_t len ) ; <nl> - void swHttp_free_request ( swConnection * conn ) ; <nl> <nl> # ifdef SW_USE_HTTP2 <nl> ssize_t swHttpMix_get_package_length ( swProtocol * protocol , swSocket * conn , const char * data , uint32_t length ) ; <nl> mmm a / include / server . h <nl> ppp b / include / server . h <nl> <nl> # define SW_WORKER_NUM ( SW_CPU_NUM * 2 ) <nl> <nl> enum swServer_event_type { <nl> - / / data payload <nl> - SW_SERVER_EVENT_SEND_DATA , <nl> + / / recv data payload <nl> + SW_SERVER_EVENT_RECV_DATA , <nl> + SW_SERVER_EVENT_RECV_DGRAM , <nl> + / / send data <nl> SW_SERVER_EVENT_SEND_FILE , <nl> - SW_SERVER_EVENT_SNED_DGRAM , <nl> / / connection event <nl> SW_SERVER_EVENT_CLOSE , <nl> SW_SERVER_EVENT_CONNECT , <nl> struct swSendData { <nl> const char * data ; <nl> } ; <nl> <nl> + struct swRecvData { <nl> + swDataHead info ; <nl> + const char * data ; <nl> + } ; <nl> + <nl> struct swPipeBuffer { <nl> swDataHead info ; <nl> char data [ 0 ] ; <nl> class Server { <nl> / * * <nl> * Connection <nl> * / <nl> - std : : function < int ( Server * , swEventData * ) > onReceive ; <nl> - std : : function < int ( Server * , swEventData * ) > onPacket ; <nl> + std : : function < int ( Server * , swRecvData * ) > onReceive ; <nl> + std : : function < int ( Server * , swRecvData * ) > onPacket ; <nl> std : : function < void ( Server * , swDataHead * ) > onClose ; <nl> std : : function < void ( Server * , swDataHead * ) > onConnect ; <nl> std : : function < void ( Server * , swDataHead * ) > onBufferFull ; <nl> class Server { <nl> int create_worker ( swWorker * worker ) ; <nl> void disable_accept ( ) ; <nl> <nl> + void destroy_http_request ( Connection * conn ) ; <nl> + <nl> private : <nl> / * * <nl> * http static file directory <nl> swoole : : dtls : : Session * swServer_dtls_accept ( swServer * serv , swListenPort * ls , sw <nl> <nl> static sw_inline int swEventData_is_dgram ( uint8_t type ) { <nl> switch ( type ) { <nl> - case SW_SERVER_EVENT_SNED_DGRAM : <nl> + case SW_SERVER_EVENT_RECV_DGRAM : <nl> return SW_TRUE ; <nl> default : <nl> return SW_FALSE ; <nl> static sw_inline int swEventData_is_dgram ( uint8_t type ) { <nl> <nl> static sw_inline int swEventData_is_stream ( uint8_t type ) { <nl> switch ( type ) { <nl> - case SW_SERVER_EVENT_SEND_DATA : <nl> + case SW_SERVER_EVENT_RECV_DATA : <nl> case SW_SERVER_EVENT_CONNECT : <nl> case SW_SERVER_EVENT_CLOSE : <nl> case SW_SERVER_EVENT_PAUSE_RECV : <nl> mmm a / include / websocket . h <nl> ppp b / include / websocket . h <nl> enum swWebsocket_status { <nl> enum swWebSocket_frame_flag { <nl> SW_WEBSOCKET_FLAG_FIN = 1 < < 0 , / * BC : must be 1 * / <nl> SW_WEBSOCKET_FLAG_COMPRESS = 1 < < 1 , <nl> - / * readonly for user * / <nl> + / / readonly for user <nl> SW_WEBSOCKET_FLAG_RSV1 = 1 < < 2 , <nl> SW_WEBSOCKET_FLAG_RSV2 = 1 < < 3 , <nl> SW_WEBSOCKET_FLAG_RSV3 = 1 < < 4 , <nl> SW_WEBSOCKET_FLAG_MASK = 1 < < 5 , <nl> + / / for encoder / decoder <nl> + SW_WEBSOCKET_FLAG_ENCODE_HEADER_ONLY = 1 < < 6 , <nl> } ; <nl> <nl> enum swWebSocket_frame_union_flag { <nl> enum swWebSocket_frame_union_flag { <nl> SW_WEBSOCKET_FLAG_MASK | SW_WEBSOCKET_FLAG_COMPRESS <nl> } ; <nl> <nl> - typedef struct { <nl> + struct swWebSocket_frame_header { <nl> / * * <nl> * fin : 1 rsv1 : 1 rsv2 : 1 rsv3 : 1 opcode : 4 <nl> * / <nl> - uchar OPCODE : 4 ; <nl> - uchar RSV3 : 1 ; <nl> - uchar RSV2 : 1 ; <nl> - uchar RSV1 : 1 ; <nl> - uchar FIN : 1 ; <nl> - uchar LENGTH : 7 ; <nl> - uchar MASK : 1 ; <nl> - <nl> - } swWebSocket_frame_header ; <nl> + uchar OPCODE : 4 ; <nl> + uchar RSV3 : 1 ; <nl> + uchar RSV2 : 1 ; <nl> + uchar RSV1 : 1 ; <nl> + uchar FIN : 1 ; <nl> + uchar LENGTH : 7 ; <nl> + uchar MASK : 1 ; <nl> + } ; <nl> <nl> - typedef struct { <nl> + struct swWebSocket_frame { <nl> swWebSocket_frame_header header ; <nl> char mask_key [ SW_WEBSOCKET_MASK_LEN ] ; <nl> uint16_t header_length ; <nl> size_t payload_length ; <nl> char * payload ; <nl> - } swWebSocket_frame ; <nl> + } ; <nl> <nl> # define WEBSOCKET_VERSION 13 <nl> <nl> static inline uchar swWebSocket_set_flags ( uchar fin , uchar mask , uchar rsv1 , uch <nl> return flags ; <nl> } <nl> <nl> - void swWebSocket_encode ( swString * buffer , const char * data , size_t length , char opcode , uint8_t flags ) ; <nl> - void swWebSocket_decode ( swWebSocket_frame * frame , swString * data ) ; <nl> + bool swWebSocket_encode ( swString * buffer , const char * data , size_t length , char opcode , uint8_t flags ) ; <nl> + bool swWebSocket_decode ( swWebSocket_frame * frame , char * data , size_t length ) ; <nl> int swWebSocket_pack_close_frame ( swString * buffer , int code , char * reason , size_t length , uint8_t flags ) ; <nl> void swWebSocket_print_frame ( swWebSocket_frame * frame ) ; <nl> <nl> + inline bool swWebSocket_decode ( swWebSocket_frame * frame , swString * str ) { <nl> + return swWebSocket_decode ( frame , str - > str , str - > length ) ; <nl> + } <nl> + <nl> ssize_t swWebSocket_get_package_length ( swProtocol * protocol , swSocket * conn , const char * data , uint32_t length ) ; <nl> int swWebSocket_dispatch_frame ( swProtocol * protocol , swSocket * conn , const char * data , uint32_t length ) ; <nl> mmm a / include / wrapper / server . hpp <nl> ppp b / include / wrapper / server . hpp <nl> extern swString * _callback_buffer ; <nl> <nl> struct DataBuffer { <nl> size_t length ; <nl> - void * buffer ; <nl> + char * buffer ; <nl> <nl> DataBuffer ( ) { <nl> length = 0 ; <nl> buffer = nullptr ; <nl> } <nl> <nl> - DataBuffer ( const char * str ) { copy ( ( void * ) str , strlen ( str ) ) ; } <nl> + DataBuffer ( const char * str ) { <nl> + copy ( str , strlen ( str ) ) ; <nl> + } <nl> <nl> - DataBuffer ( string & str ) { copy ( ( void * ) str . c_str ( ) , str . length ( ) ) ; } <nl> + DataBuffer ( string & str ) { <nl> + copy ( str . c_str ( ) , str . length ( ) ) ; <nl> + } <nl> <nl> - DataBuffer ( const char * str , size_t length ) { copy ( ( void * ) str , length ) ; } <nl> + DataBuffer ( const char * str , size_t length ) { <nl> + copy ( str , length ) ; <nl> + } <nl> <nl> - void copy ( void * _data , size_t _length ) { <nl> + void copy ( const char * _data , size_t _length ) { <nl> alloc ( _length ) ; <nl> memcpy ( buffer , _data , _length ) ; <nl> } <nl> class Server { <nl> virtual void onFinish ( int , const DataBuffer & ) = 0 ; <nl> <nl> public : <nl> - static int _onReceive ( swServer * serv , swEventData * req ) ; <nl> + static int _onReceive ( swServer * serv , swRecvData * req ) ; <nl> + static int _onPacket ( swServer * serv , swRecvData * req ) ; <nl> static void _onConnect ( swServer * serv , swDataHead * info ) ; <nl> static void _onClose ( swServer * serv , swDataHead * info ) ; <nl> - static int _onPacket ( swServer * serv , swEventData * req ) ; <nl> static void _onPipeMessage ( swServer * serv , swEventData * req ) ; <nl> static void _onStart ( swServer * serv ) ; <nl> static void _onShutdown ( swServer * serv ) ; <nl> mmm a / src / protocol / http . cc <nl> ppp b / src / protocol / http . cc <nl> <nl> * / <nl> <nl> # include " http . h " <nl> + # include " server . h " <nl> <nl> # include < assert . h > <nl> # include < stddef . h > <nl> bool Server : : select_static_handler ( http : : Request * request , swConnection * conn ) { <nl> char header_buffer [ 1024 ] ; <nl> swSendData response ; <nl> response . info . fd = conn - > session_id ; <nl> - response . info . type = SW_SERVER_EVENT_SEND_DATA ; <nl> + response . info . type = SW_SERVER_EVENT_RECV_DATA ; <nl> <nl> if ( handler . status_code = = SW_HTTP_NOT_FOUND ) { <nl> response . info . len = sw_snprintf ( header_buffer , <nl> string Request : : get_date_if_modified_since ( ) { <nl> } / / namespace http <nl> } / / namespace swoole <nl> <nl> - void swHttp_free_request ( swConnection * conn ) { <nl> + void Server : : destroy_http_request ( Connection * conn ) { <nl> auto request = reinterpret_cast < swoole : : http : : Request * > ( conn - > object ) ; <nl> if ( ! request ) { <nl> return ; <nl> mmm a / src / protocol / websocket . cc <nl> ppp b / src / protocol / websocket . cc <nl> static sw_inline void swWebSocket_mask ( char * data , size_t len , const char * mask_ <nl> } <nl> } <nl> <nl> - void swWebSocket_encode ( swString * buffer , const char * data , size_t length , char opcode , uint8_t _flags ) { <nl> + bool swWebSocket_encode ( swString * buffer , const char * data , size_t length , char opcode , uint8_t _flags ) { <nl> int pos = 0 ; <nl> char frame_header [ 16 ] ; <nl> swWebSocket_frame_header * header = ( swWebSocket_frame_header * ) frame_header ; <nl> void swWebSocket_encode ( swString * buffer , const char * data , size_t length , char <nl> * / <nl> if ( header - > MASK ) { <nl> swString_append_ptr ( buffer , SW_WEBSOCKET_MASK_DATA , SW_WEBSOCKET_MASK_LEN ) ; <nl> + if ( _flags & SW_WEBSOCKET_FLAG_ENCODE_HEADER_ONLY ) { <nl> + return false ; <nl> + } <nl> if ( length > 0 ) { <nl> size_t offset = buffer - > length ; <nl> / / Warn : buffer may be extended , string pointer will change <nl> void swWebSocket_encode ( swString * buffer , const char * data , size_t length , char <nl> swWebSocket_mask ( buffer - > str + offset , length , SW_WEBSOCKET_MASK_DATA ) ; <nl> } <nl> } else { <nl> - if ( length > 0 ) { <nl> + if ( length > 0 and ! ( _flags & SW_WEBSOCKET_FLAG_ENCODE_HEADER_ONLY ) ) { <nl> swString_append_ptr ( buffer , data , length ) ; <nl> } <nl> } <nl> + <nl> + return true ; <nl> } <nl> <nl> - void swWebSocket_decode ( swWebSocket_frame * frame , swString * data ) { <nl> - memcpy ( frame , data - > str , SW_WEBSOCKET_HEADER_LEN ) ; <nl> + bool swWebSocket_decode ( swWebSocket_frame * frame , char * data , size_t length ) { <nl> + memcpy ( frame , data , SW_WEBSOCKET_HEADER_LEN ) ; <nl> <nl> / / 0 - 125 <nl> size_t payload_length = frame - > header . LENGTH ; <nl> uint8_t header_length = SW_WEBSOCKET_HEADER_LEN ; <nl> - char * buf = data - > str + SW_WEBSOCKET_HEADER_LEN ; <nl> + char * buf = data + SW_WEBSOCKET_HEADER_LEN ; <nl> <nl> / / uint16_t , 2byte <nl> if ( frame - > header . LENGTH = = 0x7e ) { <nl> void swWebSocket_decode ( swWebSocket_frame * frame , swString * data ) { <nl> header_length + = 8 ; <nl> } <nl> <nl> + if ( payload_length = = 0 ) { <nl> + frame - > header_length = header_length ; <nl> + frame - > payload_length = 0 ; <nl> + frame - > payload = nullptr ; <nl> + <nl> + return true ; <nl> + } <nl> + <nl> if ( frame - > header . MASK ) { <nl> - memcpy ( frame - > mask_key , data - > str + header_length , SW_WEBSOCKET_MASK_LEN ) ; <nl> + memcpy ( frame - > mask_key , data + header_length , SW_WEBSOCKET_MASK_LEN ) ; <nl> header_length + = SW_WEBSOCKET_MASK_LEN ; <nl> - if ( payload_length > 0 ) { <nl> - swWebSocket_mask ( data - > str + header_length , payload_length , frame - > mask_key ) ; <nl> - } <nl> + swWebSocket_mask ( data + header_length , payload_length , frame - > mask_key ) ; <nl> } <nl> <nl> + frame - > payload = data + header_length ; <nl> frame - > header_length = header_length ; <nl> - frame - > payload = data - > str + header_length ; <nl> frame - > payload_length = payload_length ; <nl> + <nl> + return true ; <nl> } <nl> <nl> int swWebSocket_pack_close_frame ( swString * buffer , int code , char * reason , size_t length , uint8_t flags ) { <nl> void swWebSocket_print_frame ( swWebSocket_frame * frame ) { <nl> int swWebSocket_dispatch_frame ( swProtocol * proto , swSocket * _socket , const char * data , uint32_t length ) { <nl> swServer * serv = ( swServer * ) proto - > private_data_2 ; <nl> swConnection * conn = ( swConnection * ) _socket - > object ; <nl> - swString frame ; <nl> - sw_memset_zero ( & frame , sizeof ( frame ) ) ; <nl> - frame . str = const_cast < char * > ( data ) ; <nl> - frame . length = length ; <nl> <nl> swString send_frame = { } ; <nl> char buf [ SW_WEBSOCKET_HEADER_LEN + SW_WEBSOCKET_CLOSE_CODE_LEN + SW_WEBSOCKET_CLOSE_REASON_MAX_LEN ] ; <nl> int swWebSocket_dispatch_frame ( swProtocol * proto , swSocket * _socket , const char <nl> send_frame . size = sizeof ( buf ) ; <nl> <nl> swWebSocket_frame ws ; <nl> - swWebSocket_decode ( & ws , & frame ) ; <nl> + swWebSocket_decode ( & ws , const_cast < char * > ( data ) , length ) ; <nl> <nl> swString * frame_buffer ; <nl> int frame_length ; <nl> int swWebSocket_dispatch_frame ( swProtocol * proto , swSocket * _socket , const char <nl> send_frame . str [ 0 ] = 0x88 ; / / FIN | OPCODE : WEBSOCKET_OPCODE_CLOSE <nl> send_frame . str [ 1 ] = ws . payload_length ; <nl> / / Get payload and return it as it is <nl> - memcpy ( send_frame . str + SW_WEBSOCKET_HEADER_LEN , <nl> - frame . str + frame . length - ws . payload_length , <nl> - ws . payload_length ) ; <nl> + memcpy ( send_frame . str + SW_WEBSOCKET_HEADER_LEN , data + length - ws . payload_length , ws . payload_length ) ; <nl> send_frame . length = SW_WEBSOCKET_HEADER_LEN + ws . payload_length ; <nl> swSocket_send ( _socket , send_frame . str , send_frame . length , 0 ) ; <nl> } else { <nl> mmm a / src / server / master . cc <nl> ppp b / src / server / master . cc <nl> static int swServer_tcp_send ( swServer * serv , int session_id , const void * data , u <nl> } <nl> <nl> _send . info . fd = session_id ; <nl> - _send . info . type = SW_SERVER_EVENT_SEND_DATA ; <nl> + _send . info . type = SW_SERVER_EVENT_RECV_DATA ; <nl> _send . data = ( char * ) data ; <nl> _send . info . len = length ; <nl> return factory - > finish ( factory , & _send ) ; <nl> int Server : : send_to_connection ( swSendData * _send ) { <nl> conn = get_connection_verify_no_ssl ( session_id ) ; <nl> } <nl> if ( ! conn ) { <nl> - if ( _send - > info . type = = SW_SERVER_EVENT_SEND_DATA ) { <nl> + if ( _send - > info . type = = SW_SERVER_EVENT_RECV_DATA ) { <nl> swoole_error_log ( SW_LOG_NOTICE , <nl> SW_ERROR_SESSION_NOT_EXIST , <nl> " send % d byte failed , session # % d does not exist " , <nl> static void swServer_signal_handler ( int sig ) { <nl> swTraceLog ( SW_TRACE_SERVER , " signal [ % d ] % s triggered in % d " , sig , swSignal_str ( sig ) , getpid ( ) ) ; <nl> <nl> swServer * serv = sw_server ( ) ; <nl> - if ( ! serv ) { <nl> + if ( ! SwooleG . running or ! serv ) { <nl> return ; <nl> } <nl> <nl> mmm a / src / server / port . cc <nl> ppp b / src / server / port . cc <nl> static int swPort_onRead_http ( swReactor * reactor , swListenPort * port , swEvent * e <nl> <nl> if ( conn - > websocket_status > = WEBSOCKET_STATUS_HANDSHAKE ) { <nl> if ( conn - > http_upgrade = = 0 ) { <nl> - swHttp_free_request ( conn ) ; <nl> + serv - > destroy_http_request ( conn ) ; <nl> conn - > websocket_status = WEBSOCKET_STATUS_ACTIVE ; <nl> conn - > http_upgrade = 1 ; <nl> } <nl> static int swPort_onRead_http ( swReactor * reactor , swListenPort * port , swEvent * e <nl> # endif <nl> } <nl> _close_fd : <nl> - swHttp_free_request ( conn ) ; <nl> + serv - > destroy_http_request ( conn ) ; <nl> swReactor_trigger_close_event ( reactor , event ) ; <nl> return SW_OK ; <nl> } <nl> static int swPort_onRead_http ( swReactor * reactor , swListenPort * port , swEvent * e <nl> conn - > http2_stream = 1 ; <nl> swHttp2_send_setting_frame ( protocol , _socket ) ; <nl> if ( buffer - > length = = sizeof ( SW_HTTP2_PRI_STRING ) - 1 ) { <nl> - swHttp_free_request ( conn ) ; <nl> + serv - > destroy_http_request ( conn ) ; <nl> swString_clear ( buffer ) ; <nl> return SW_OK ; <nl> } <nl> swString_reduce ( buffer , buffer - > offset ) ; <nl> - swHttp_free_request ( conn ) ; <nl> + serv - > destroy_http_request ( conn ) ; <nl> conn - > socket - > skip_recv = 1 ; <nl> return swPort_onRead_check_length ( reactor , port , event ) ; <nl> # endif <nl> static int swPort_onRead_http ( swReactor * reactor , swListenPort * port , swEvent * e <nl> request - > clean ( ) ; <nl> goto _parse ; <nl> } else { <nl> - swHttp_free_request ( conn ) ; <nl> + serv - > destroy_http_request ( conn ) ; <nl> swString_clear ( buffer ) ; <nl> return SW_OK ; <nl> } <nl> static int swPort_onRead_http ( swReactor * reactor , swListenPort * port , swEvent * e <nl> buffer - > offset = request_length ; <nl> Server : : dispatch_task ( protocol , _socket , buffer - > str , buffer - > length ) ; <nl> if ( conn - > active & & ! _socket - > removed ) { <nl> - swHttp_free_request ( conn ) ; <nl> + serv - > destroy_http_request ( conn ) ; <nl> swString_clear ( buffer ) ; <nl> } <nl> <nl> mmm a / src / server / process . cc <nl> ppp b / src / server / process . cc <nl> static int swFactoryProcess_dispatch ( swFactory * factory , swSendData * task ) { <nl> return serv - > send_to_worker_from_master ( worker , & task - > info , sizeof ( task - > info ) ) ; <nl> } <nl> <nl> - if ( task - > info . type = = SW_SERVER_EVENT_SEND_DATA ) { <nl> + if ( task - > info . type = = SW_SERVER_EVENT_RECV_DATA ) { <nl> worker - > dispatch_count + + ; <nl> } <nl> <nl> mmm a / src / server / reactor_process . cc <nl> ppp b / src / server / reactor_process . cc <nl> static int swReactorProcess_onPipeRead ( swReactor * reactor , swEvent * event ) { <nl> swString_append_ptr ( output_buffer , task . data , task . info . len ) ; <nl> if ( task . info . type = = SW_SERVER_EVENT_PROXY_END ) { <nl> memcpy ( & _send . info , & task . info , sizeof ( _send . info ) ) ; <nl> - _send . info . type = SW_SERVER_EVENT_SEND_DATA ; <nl> + _send . info . type = SW_SERVER_EVENT_RECV_DATA ; <nl> _send . data = output_buffer - > str ; <nl> _send . info . len = output_buffer - > length ; <nl> factory - > finish ( factory , & _send ) ; <nl> static int swReactorProcess_send2client ( swFactory * factory , swSendData * data ) { <nl> swEventData proxy_msg ; <nl> sw_memset_zero ( & proxy_msg . info , sizeof ( proxy_msg . info ) ) ; <nl> <nl> - if ( data - > info . type = = SW_SERVER_EVENT_SEND_DATA ) { <nl> + if ( data - > info . type = = SW_SERVER_EVENT_RECV_DATA ) { <nl> proxy_msg . info . fd = session_id ; <nl> proxy_msg . info . reactor_id = SwooleG . process_id ; <nl> proxy_msg . info . type = SW_SERVER_EVENT_PROXY_START ; <nl> mmm a / src / server / reactor_thread . cc <nl> ppp b / src / server / reactor_thread . cc <nl> static int swReactorThread_onPacketReceived ( swReactor * reactor , swEvent * event ) <nl> <nl> task . info . server_fd = fd ; <nl> task . info . reactor_id = SwooleTG . id ; <nl> - task . info . type = SW_SERVER_EVENT_SNED_DGRAM ; <nl> + task . info . type = SW_SERVER_EVENT_RECV_DGRAM ; <nl> # ifdef SW_BUFFER_RECV_TIME <nl> task . info . time = swoole_microtime ( ) ; <nl> # endif <nl> int Server : : close_connection ( swReactor * reactor , swSocket * socket ) { <nl> sw_atomic_fetch_sub ( port - > connection_num , 1 ) ; <nl> <nl> if ( port - > open_http_protocol & & conn - > object ) { <nl> - swHttp_free_request ( conn ) ; <nl> + serv - > destroy_http_request ( conn ) ; <nl> } <nl> if ( port - > open_redis_protocol & & conn - > object ) { <nl> sw_free ( conn - > object ) ; <nl> int Server : : dispatch_task ( swProtocol * proto , swSocket * _socket , const char * data <nl> task . info . reactor_id = conn - > reactor_id ; <nl> task . info . ext_flags = proto - > ext_flags ; <nl> proto - > ext_flags = 0 ; <nl> - task . info . type = SW_SERVER_EVENT_SEND_DATA ; <nl> + task . info . type = SW_SERVER_EVENT_RECV_DATA ; <nl> # ifdef SW_BUFFER_RECV_TIME <nl> task . info . info . time = conn - > last_time_usec ; <nl> # endif <nl> mmm a / src / server / worker . cc <nl> ppp b / src / server / worker . cc <nl> void swWorker_signal_init ( void ) { <nl> } <nl> <nl> void swWorker_signal_handler ( int signo ) { <nl> + if ( ! SwooleG . running ) { <nl> + return ; <nl> + } <nl> switch ( signo ) { <nl> case SIGTERM : <nl> / * * <nl> static int swWorker_onStreamPackage ( swProtocol * proto , swSocket * sock , const cha <nl> return SW_OK ; <nl> } <nl> <nl> - typedef std : : function < int ( swServer * , swEventData * ) > task_callback ; <nl> + typedef std : : function < int ( swServer * , swRecvData * ) > task_callback ; <nl> <nl> static sw_inline void swWorker_do_task ( swServer * serv , <nl> swWorker * worker , <nl> swEventData * task , <nl> const task_callback & callback ) { <nl> + swRecvData recv_data ; <nl> + recv_data . info = task - > info ; <nl> + recv_data . info . len = serv - > get_packet ( serv , task , const_cast < char * * > ( & recv_data . data ) ) ; <nl> # ifdef SW_BUFFER_RECV_TIME <nl> serv - > last_receive_usec = task - > info . time ; <nl> # endif <nl> - callback ( serv , task ) ; <nl> + callback ( serv , & recv_data ) ; <nl> # ifdef SW_BUFFER_RECV_TIME <nl> serv - > last_receive_usec = 0 ; <nl> # endif <nl> int Server : : accept_task ( swEventData * task ) { <nl> worker - > status = SW_WORKER_BUSY ; <nl> <nl> switch ( task - > info . type ) { <nl> - case SW_SERVER_EVENT_SEND_DATA : { <nl> + case SW_SERVER_EVENT_RECV_DATA : { <nl> swConnection * conn = get_connection_verify ( task - > info . fd ) ; <nl> if ( conn & & max_queued_bytes & & task - > info . len > 0 ) { <nl> sw_atomic_fetch_sub ( & conn - > queued_bytes , task - > info . len ) ; <nl> int Server : : accept_task ( swEventData * task ) { <nl> swWorker_do_task ( this , worker , task , onReceive ) ; <nl> break ; <nl> } <nl> - case SW_SERVER_EVENT_SNED_DGRAM : { <nl> + case SW_SERVER_EVENT_RECV_DGRAM : { <nl> swWorker_do_task ( this , worker , task , onPacket ) ; <nl> break ; <nl> } <nl> mmm a / src / wrapper / server . cc <nl> ppp b / src / wrapper / server . cc <nl> static DataBuffer task_unpack ( swEventData * task_result ) { <nl> return retval ; <nl> } <nl> <nl> - static DataBuffer get_recv_data ( swServer * serv , swEventData * req , char * header , uint32_t header_length ) { <nl> - char * data_ptr = nullptr ; <nl> + static DataBuffer get_recv_data ( swServer * serv , swRecvData * req , char * header , uint32_t header_length ) { <nl> + <nl> DataBuffer retval ; <nl> - size_t data_len = serv - > get_packet ( serv , req , & data_ptr ) ; <nl> + const char * data_ptr = req - > data ; <nl> + size_t data_len = req - > info . len ; <nl> <nl> if ( header_length > = ( uint32_t ) data_len ) { <nl> return retval ; <nl> bool Server : : start ( void ) { <nl> return true ; <nl> } <nl> <nl> - int Server : : _onReceive ( swServer * serv , swEventData * req ) { <nl> + int Server : : _onReceive ( swServer * serv , swRecvData * req ) { <nl> DataBuffer data = get_recv_data ( serv , req , nullptr , 0 ) ; <nl> Server * _this = ( Server * ) serv - > ptr2 ; <nl> _this - > onReceive ( req - > info . fd , data ) ; <nl> void Server : : _onWorkerStop ( swServer * serv , int worker_id ) { <nl> _this - > onWorkerStop ( worker_id ) ; <nl> } <nl> <nl> - int Server : : _onPacket ( swServer * serv , swEventData * req ) { <nl> + int Server : : _onPacket ( swServer * serv , swRecvData * req ) { <nl> swDgramPacket * packet ; <nl> <nl> - char * buffer ; <nl> - serv - > get_packet ( serv , req , & buffer ) ; <nl> + const char * buffer = req - > data ; <nl> packet = ( swDgramPacket * ) buffer ; <nl> <nl> char * data = nullptr ; <nl> - int length = 0 ; <nl> + uint32_t length = 0 ; <nl> ClientInfo clientInfo ; <nl> clientInfo . server_socket = req - > info . server_fd ; <nl> data = packet - > data ; <nl> mmm a / swoole_http2_server . cc <nl> ppp b / swoole_http2_server . cc <nl> int swoole_http2_server_parse ( http2_session * client , const char * buf ) { <nl> / * * <nl> * Http2 <nl> * / <nl> - int swoole_http2_server_onFrame ( swServer * serv , swConnection * conn , swEventData * req ) { <nl> + int swoole_http2_server_onFrame ( swServer * serv , swConnection * conn , swRecvData * req ) { <nl> int session_id = req - > info . fd ; <nl> http2_session * client = http2_sessions [ session_id ] ; <nl> if ( client = = nullptr ) { <nl> mmm a / swoole_http_server . cc <nl> ppp b / swoole_http_server . cc <nl> static bool http_context_send_data ( http_context * ctx , const char * data , size_t l <nl> static bool http_context_sendfile ( http_context * ctx , const char * file , uint32_t l_file , off_t offset , size_t length ) ; <nl> static bool http_context_disconnect ( http_context * ctx ) ; <nl> <nl> - int php_swoole_http_onReceive ( swServer * serv , swEventData * req ) { <nl> + int php_swoole_http_onReceive ( swServer * serv , swRecvData * req ) { <nl> int fd = req - > info . fd ; <nl> int server_fd = req - > info . server_fd ; <nl> <nl> mmm a / swoole_http_server . h <nl> ppp b / swoole_http_server . h <nl> <nl> # include " http . h " <nl> # include " websocket . h " <nl> <nl> - int swoole_websocket_onMessage ( swServer * serv , swEventData * req ) ; <nl> + int swoole_websocket_onMessage ( swServer * serv , swRecvData * req ) ; <nl> int swoole_websocket_onHandshake ( swServer * serv , swListenPort * port , http_context * ctx ) ; <nl> void swoole_websocket_onOpen ( http_context * ctx ) ; <nl> void swoole_websocket_onRequest ( http_context * ctx ) ; <nl> void swoole_http_server_init_context ( swServer * serv , http_context * ctx ) ; <nl> <nl> # ifdef SW_USE_HTTP2 <nl> <nl> - int swoole_http2_server_onFrame ( swServer * serv , swConnection * conn , swEventData * req ) ; <nl> + int swoole_http2_server_onFrame ( swServer * serv , swConnection * conn , swRecvData * req ) ; <nl> int swoole_http2_server_parse ( http2_session * client , const char * buf ) ; <nl> void swoole_http2_server_session_free ( swConnection * conn ) ; <nl> int swoole_http2_server_ping ( http_context * ctx ) ; <nl> mmm a / swoole_redis_server . cc <nl> ppp b / swoole_redis_server . cc <nl> void php_swoole_redis_server_rshutdown ( ) { <nl> redis_handlers . clear ( ) ; <nl> } <nl> <nl> - static int redis_onReceive ( swServer * serv , swEventData * req ) { <nl> + static int redis_onReceive ( swServer * serv , swRecvData * req ) { <nl> int fd = req - > info . fd ; <nl> swConnection * conn = serv - > get_connection_by_session_id ( fd ) ; <nl> if ( ! conn ) { <nl> mmm a / swoole_server . cc <nl> ppp b / swoole_server . cc <nl> int php_swoole_task_pack ( swEventData * task , zval * zdata ) { <nl> return task - > info . fd ; <nl> } <nl> <nl> - void php_swoole_get_recv_data ( swServer * serv , zval * zdata , swEventData * req ) { <nl> - char * data = nullptr ; <nl> - <nl> - size_t length = serv - > get_packet ( serv , req , & data ) ; <nl> + void php_swoole_get_recv_data ( swServer * serv , zval * zdata , swRecvData * req ) { <nl> + const char * data = req - > data ; <nl> + uint32_t length = req - > info . len ; <nl> if ( length = = 0 ) { <nl> ZVAL_EMPTY_STRING ( zdata ) ; <nl> } else { <nl> static void php_swoole_onPipeMessage ( swServer * serv , swEventData * req ) { <nl> sw_zval_free ( zdata ) ; <nl> } <nl> <nl> - int php_swoole_onReceive ( swServer * serv , swEventData * req ) { <nl> + int php_swoole_onReceive ( swServer * serv , swRecvData * req ) { <nl> zend_fcall_info_cache * fci_cache = <nl> php_swoole_server_get_fci_cache ( serv , req - > info . server_fd , SW_SERVER_CB_onReceive ) ; <nl> <nl> int php_swoole_onReceive ( swServer * serv , swEventData * req ) { <nl> return SW_OK ; <nl> } <nl> <nl> - int php_swoole_onPacket ( swServer * serv , swEventData * req ) { <nl> + int php_swoole_onPacket ( swServer * serv , swRecvData * req ) { <nl> zval * zserv = ( zval * ) serv - > ptr2 ; <nl> ServerObject * server_object = server_fetch_object ( Z_OBJ_P ( zserv ) ) ; <nl> zval zaddr ; <nl> <nl> - char * buffer ; <nl> - serv - > get_packet ( serv , req , & buffer ) ; <nl> - <nl> array_init ( & zaddr ) ; <nl> <nl> - swDgramPacket * packet = ( swDgramPacket * ) buffer ; <nl> + swDgramPacket * packet = ( swDgramPacket * ) req - > data ; <nl> <nl> add_assoc_long ( & zaddr , " server_socket " , req - > info . server_fd ) ; <nl> swConnection * from_sock = serv - > get_connection ( req - > info . server_fd ) ; <nl> mmm a / swoole_server . h <nl> ppp b / swoole_server . h <nl> int php_swoole_create_dir ( const char * path , size_t length ) ; <nl> void php_swoole_server_before_start ( swServer * serv , zval * zobject ) ; <nl> void php_swoole_http_server_init_global_variant ( ) ; <nl> void php_swoole_server_send_yield ( swServer * serv , int fd , zval * zdata , zval * return_value ) ; <nl> - void php_swoole_get_recv_data ( swServer * serv , zval * zdata , swEventData * req ) ; <nl> + void php_swoole_get_recv_data ( swServer * serv , zval * zdata , swRecvData * req ) ; <nl> void php_swoole_onConnect ( swServer * , swDataHead * ) ; <nl> - int php_swoole_onReceive ( swServer * , swEventData * ) ; <nl> - int php_swoole_http_onReceive ( swServer * , swEventData * ) ; <nl> + int php_swoole_onReceive ( swServer * , swRecvData * ) ; <nl> + int php_swoole_http_onReceive ( swServer * , swRecvData * ) ; <nl> void php_swoole_http_onClose ( swServer * , swDataHead * ) ; <nl> - int php_swoole_onPacket ( swServer * , swEventData * ) ; <nl> + int php_swoole_onPacket ( swServer * , swRecvData * ) ; <nl> void php_swoole_onClose ( swServer * , swDataHead * ) ; <nl> void php_swoole_onBufferFull ( swServer * , swDataHead * ) ; <nl> void php_swoole_onBufferEmpty ( swServer * , swDataHead * ) ; <nl> mmm a / swoole_websocket_server . cc <nl> ppp b / swoole_websocket_server . cc <nl> static bool websocket_message_compress ( swString * buffer , const char * data , size_ <nl> } <nl> # endif <nl> <nl> - int swoole_websocket_onMessage ( swServer * serv , swEventData * req ) { <nl> + int swoole_websocket_onMessage ( swServer * serv , swRecvData * req ) { <nl> int fd = req - > info . fd ; <nl> uchar flags = 0 ; <nl> zend_long opcode = 0 ; <nl>
|
Refactor receive callback ( )
|
swoole/swoole-src
|
b2629d117456c4328d1740bd69e0e461e0ae0006
|
2020-07-17T13:19:28Z
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.