This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| std::vector<Object> dst_objs; | |
| // transform an iterator into a moveable one | |
| auto it = std::make_move_iterator(src_objs.begin()), | |
| end = std::make_move_iterator(src_objs.end()); | |
| std::copy_if(it, end, std::back_inserter(dst_objs), | |
| [](const Object& cur) { return cur.type() == Type::TYPE1; }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| std::vector<Object> dst_objs; | |
| for(auto&& cur : src_objs) { | |
| // filter all TYPE1 messages | |
| if (cur.type() == Type::TYPE1) | |
| dst_objs.push_back(std::move(cur)); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // comparator | |
| auto comp = [](const Object& lhs, const Object &rhs) { | |
| return lhs.type() < rhs.type() || | |
| (lhs.type() == rhs.type() && std::strcmp(lhs.msg(), rhs.msg()) < 0); | |
| }; | |
| std::sort(src_objs.begin(), src_objs.end(), comp); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| enum class Type { TYPE1, TYPE2, TYPE3 }; | |
| class Object { | |
| using LiteralPtr = std::unique_ptr<const char[]>; | |
| Type m_type; | |
| LiteralPtr m_msg; | |
| static LiteralPtr make_str_copy(const char* str) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Given any type, return unsigned int instead | |
| template <typename T> | |
| struct to_uint_traits { typedef unsigned int type; }; | |
| template <typename... Args> | |
| int enqueue_kernel( std::function<void (Args... )> block, | |
| typename to_uint_traits<Args>::type... sizes ) | |
| { | |
| // print sizes | |
| for (auto size : {sizes...}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int enqueue_kernel ( | |
| queue_t queue, | |
| kernel_enqueue_flags_t flags, | |
| const ndrange_t ndrange, | |
| void (^block)(local void *, ...), | |
| uint size0, ...) | |
| int enqueue_kernel ( | |
| queue_t queue, | |
| kernel_enqueue_flags_t flags, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int enqueue_kernel ( | |
| queue_t queue, | |
| kernel_enqueue_flags_t flags, | |
| const ndrange_t ndrange, | |
| void (^block)(void)) | |
| int enqueue_kernel ( | |
| queue_t queue, | |
| kernel_enqueue_flags_t flags, | |
| const ndrange_t ndrange, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| set(FlexTemplFile ${CMAKE_SOURCE_DIR}/lexer.ll.in) | |
| set(FlexSpecFile ${TMP_DIR}/lexer.ll) | |
| # Initialize the file opcodes.ll.cpp with the X-Macro code which extracts lexing rules | |
| # from the opcodes contained in the opcodes.def file (file is generated when cmake is executred) | |
| file(WRITE ${TMP_DIR}/opcodes.ll.cpp | |
| "\#define OPERATOR(NAME, ...) NAME { return OP_##NAME; }\n" | |
| "\#include \"opcodes.def\"\n") | |
| # A rule which runs the preprocessor of the opcodes.ll.cpp file and gives the content to a |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| cmake_minimum_required (VERSION 2.8) | |
| project (blog) | |
| # CHECKs if a C++11 compiler is available | |
| if(CMAKE_COMPILER_IS_GNUCXX) | |
| execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION) | |
| if (GCC_VERSION VERSION_GREATER 4.7 OR GCC_VERSION VERSION_EQUAL 4.7) | |
| message(STATUS "C++11 activated.") | |
| add_definitions("-std=c++11") | |
| else () |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| %code requires | |
| { | |
| #include <string> | |
| } | |
| %{ | |
| #include <iostream> | |
| void yyerror(const char *s) | |
| { |
NewerOlder