C++高性能并行编程与优化 - 课件 - 11 现代 CMake 进阶指南
cmake -B build 免去了先创建 build 目录再切换进去再指定源码目录的麻烦。 • cmake --build build 统一了不同平台( Linux 上会调用 make , Windows 上调用 devenv.exe ) • 结论:从现在开始,如果在命令行操作 cmake ,请使用更方便的 -B 和 --build 命令。 // 在源码目录用 -B 直接创建 build ) -G 选项:指定要用的生成器 • 众所周知, CMake 是一个跨平台的构建系统,可以从 CMakeLists.txt 生成不同类型的构建系 统(比如 Linux 的 make , Windows 的 MSBuild ),从而让构建规则可以只写一份,跨平 台使用。 • 过去的软件(例如 TBB )要跨平台,只好 Makefile 的构建规则写一份, MSBuild 也写一份 。 • Unix Makefiles 生成器; Windows 系统默认是 Visual Studio 2019 生成器; MacOS 系统默认是 Xcode 生成器。 • 可以用 -G 参数改用别的生成器,例如 cmake -GNinja 会生成 Ninja 这个构建系统的构 建规则。 Ninja 是一个高性能,跨平台的构建系统, Linux 、 Windows 、 MacOS 上都可 以用。 •0 码力 | 166 页 | 6.54 MB | 1 年前3C++高性能并行编程与优化 - 课件 - 16 现代 CMake 模块化项目管理指南
负责把包配置文件放到这里。如果第三方库的作者比较懒,没提供 CMake 支持(由安装 程序提供 XXXConfig.cmake ),那么得用另外的一套方法( FindXXX.cmake ),稍后细 谈。 Windows 系统下的搜索路径 •/ • /cmake/ • / */ • / */cmake/ • /
*/(lib/ |lib*|share)/ */cmake/ • 其中 是变量 ${CMAKE_PREFIX_PATH} , Windows 平台默认为 C:/Program Files 。 • 是你在 find_package( REQUIRED) 命令中指定的包名。 • 是系统的架构名。 Qt5/Qt5Config.cmake • /usr/Qt5/share/Qt5/Qt5Config.cmake 举例说明 find_package 搜索路径 • 例如你是 64 位的 Windows 系统, find_package(Qt5 REQUIRED) 会依次搜索: • C:/Program Files/Qt5Config.cmake • C:/Program Files/cmake/Qt5Config 0 码力 | 56 页 | 6.87 MB | 1 年前3C++20's
satellites’ atomic clocks. No file_clock Unspecified Typically: Jan 1, 1970 on POSIX; Jan 1, 1601 on Windows Used to create the time_point system used for file_time_type Unspecified * Coordinated Universal leap second story in MSVC… It’s complicated.32 The leap second story in MSVC… • Previously, the Windows operating system did not keep track of leap seconds. • Leap seconds were not tracked individually it was 1 second behind and make the adjustment then. • BUT as of Windows 10 October 2018 update and Windows Server 2019, Windows OS will now track leap seconds! • HOWEVER, they will not track leap0 码力 | 55 页 | 8.67 MB | 5 月前3C++高性能并行编程与优化 - 课件 - 15 C++ 系列课:字符与字符串
strlen(s) 现在总是会返回 3 了。 • 因此 C 语言为了适应这个变化,推出了专门针对 wchar_t 的 wcslen 、 wcscpy 、 wmemset 等函数。 • Windows 也赶紧推出 LoadLibraryA 和 LoadLibraryW 两个版本,分别伺候喜欢 char 和喜欢 wchar_t 的不同用 户群体。 UTF-32 的弊端 • 但是美国人和中国人又不高兴了。来听听他们说了啥: ( 27484 个汉字,在 65536 的范围内),凭什么为了你 Unicode 就要一下子变成 4 字节才能表示啊!就为了兼容那些几 乎不用的埃及文字? UTF-16 的流行 • 所以 Windows 采用了 UTF-16 编码格式,他的 wchar_t 是 2 字 节的(实际上就是 unsigned short 的类型别名),广为推行。 • 等等,不是说 Unicode 的范围是 0x000000~0x10FFFF !拆法很复杂,我就不解释了 。 • 美国人虽然有点不高兴,但毕竟 2 字节总比 4 字节好,而且也有 助于他的产品“ Windows” 畅销世界各地呀,所以最终 Windows 系 统内部就一致采用了 UTF-16 格式一直沿用至今。 • 当然, Windows 为了更好地伺候中国客户,还专门把中文 Windows 系统的默认编码格式改成了 GBK ,大大妨碍了程序员编 程和国际交流的便利性,可以说是“比尔盖茨,我卸卸你哦”了。0 码力 | 162 页 | 40.20 MB | 1 年前3C++高性能并行编程与优化 - 课件 - 12 从计算机组成原理看 C 语言指针
)。 • 64 位计算机:小丑竟是我自己 lscpu 命令查看处理器相关信息 C 语言中的整数类型 C 语言的基础整数类型 类型 Unix 32 位 Unix 64 位 Windows 32 位 Windows 64 位 char 8 位 8 位 8 位 8 位 short 16 位 16 位 16 位 16 位 int 32 位 32 位 32 位 32 位 long 32 位 long long 是超长整数类型,大小为 64 位或者说 8 字节。 long 比较特殊,在 Unix 上随系统位数变化, Windows 上始终是 32 位。 C 语言的基础整数类型 类型 Unix 32 位 Unix 64 位 Windows 32 位 Windows 64 位 char 8 位 8 位 8 位 8 位 short 16 位 16 位 16 位 16 位 int 32 位 Unix 64 位 Windows 32 位 Windows 64 位 char 8 位 8 位 8 位 8 位 short 16 位 16 位 16 位 16 位 int 32 位 32 位 32 位 32 位 long 32 位 64 位 32 位 32 位 long long 64 位 64 位 64 位 64 位 注意到 Unix 和 Windows 关于 long 的定义有分歧:0 码力 | 128 页 | 2.95 MB | 1 年前3Working with Asynchrony Generically: A Tour of C++ Executors
system for keyboard events and plays Model M clicky sounds.94 HACKING HOOKING WINDOWS95 HACKING HOOKING WINDOWS Raymond Chen, “Old New Thing”, https://devblogs.microsoft.com/oldnewthing/20060809-18/ ~ctrl_c_handler() { BOOL result = ::SetConsoleCtrlHandler(&consoleHandler,FALSE); ( l ) CTRL-C SENDER (WINDOWS-SPECIFIC) consoleHandler() checks if there is a pending completion. If so, it completes it. The return state{rec}; } ); } return unifex::create_simple<>( ); } CTRL-C SENDER (WINDOWS-SPECIFIC) ctrl_c_handler::event() returns a sender…105 [[nodiscard]] auto event() const; };0 码力 | 121 页 | 7.73 MB | 5 月前3C++高性能并行编程与优化 - 课件 - 01 学 C++ 从 CMake 学起
结业典礼:总结所学知识与优秀作业点评 I 硬件要求: 64 位( 32 位时代过去了) 至少 2 核 4 线程(并行课…) 英伟达家显卡( GPU 专题) 软件要求: Visual Studio 2019 ( Windows 用户) GCC 9 及以上( Linux 用户) CMake 3.12 及以上(跨平台作业) Git 2.x (作业上传到 GitHub ) CUDA Toolkit 10.0 以上( GPU 用通配符批量生成构建规则,避免针对每个 .cpp 和 .o 重复写 g++ 命令( %.o: %.cpp )。 • 但坏处也很明显: 1. make 在 Unix 类系统上是通用的,但在 Windows 则不然。 2. 需要准确地指明每个项目之间的依赖关系,有头文件时特别头疼。 3. make 的语法非常简单,不像 shell 或 python 可以做很多判断等。 4. 不同的编译器有不同的 准备的参数可能对 MSVC 不适用。 构建系统的构建系统( CMake ) • 为了解决 make 的以上问题,跨平台的 CMake 应运而生! • make 在 Unix 类系统上是通用的,但在 Windows 则不然。 • 只需要写一份 CMakeLists.txt ,他就能够在调用时生成当前系统所支持的构建系统。 • 需要准确地指明每个项目之间的依赖关系,有头文件时特别头疼。 • CMake0 码力 | 32 页 | 11.40 MB | 1 年前3whats new in visual studio
#1 most used code editor [StackOverflow Developer Surveys] Free, open-source code editor Runs on Windows, macOS, and Linux C++ IntelliSense, debug & code browsing CMake, vcpkg and git integrations SSH/container/WSL automatically linked for command-line builds Visual Studio integration • MSBuild & CMake support for Windows & Linux • Debugger integration for MSVC and Clang/LLVM Visit https://aka.ms/asan to learn more Announcing Simplify C++ dependency management with . vcpkg Open-source library manager for Windows, Linux, and macOS 1700+ popular open-source libraries available for installation • Built from source0 码力 | 42 页 | 19.02 MB | 5 月前3Making Libraries Consumable for Non-C++ Developers
The types char and wchar_t do not indicate encoding. The size of wchar_t: • Windows, sizeof(wchar_t) == 2 • Non-Windows, sizeof(wchar_t) == 4 std::basic_stringhas memory implications. More b); Switch .NET call from nint DoTheThing(BlubT b); to nint DoTheThing(in BlubT b); Result: Windows – everything passed. Linux – everything failed. Why?Making Libraries Consumable for Non-C++ 0 码力 | 29 页 | 1.21 MB | 5 月前3C++高性能并行编程与优化 - 课件 - 06 TBB 开启的并行编程之旅
结业典礼:总结所学知识与优秀作业点评 I 硬件要求: 64 位( 32 位时代过去了) 至少 2 核 4 线程(并行课…) 英伟达家显卡( GPU 专题) 软件要求: Visual Studio 2019 ( Windows 用户) GCC 9 及以上( Linux 用户) CMake 3.12 及以上(跨平台作业) Git 2.x (作业上传到 GitHub ) CUDA Toolkit 10.0 以上( GPU Ubuntu: • sudo apt-get install libtbb-dev • Arch Linux: • sudo pacman -S tbb • Windows: • .\vcpkg install tbb:x64-windows • Mac OS: • .\vcpkg install tbb:x64-macos • Other: • 从源码构建安装,参考: https://blog0 码力 | 116 页 | 15.85 MB | 1 年前3
共 18 条
- 1
- 2