以前用的办法太老土啦
看到一个since C++11的方法,我觉得比较优雅
1 #include <iostream> 2 #include <chrono> 3 //#include <ratio> 4 #include <thread> 5 6 void f() 7 { 8 std::this_thread::sleep_for(std::chrono::seconds(1)); 9 } 10 11 int main() 12 { 13 auto t1 = std::chrono:: …
阅读更多迫于拙劣的cpp水平,这次来记录一些关于STL算法部分的内容。
参考内容是CS106L的course reader
Iterator Categories
Iterators分为以下五种:
* Output Iterators:可以使用"++";可以用*myItr = value,不能用value = *myItr * Input Iterators:可以使用"++";可以用value = *myItr,不能用*myItr = value * Forward Iterators: 可以使用"++",可以同时用value = *myItr和*myItr = …
阅读更多迫于拙劣的cpp水平,来补补以前忽略掉的cpp细节。
老规矩,先放资料。
参考资料:
A Gentle Introduction to C++ IO Streams
"Designing and implementing a general input/output facility for a programming language is notoriously difficult" - Bjarne Stroustrup
Stream的基本认识
说说我的理解。stream(流)可以看做输入输出的抽象。我们通过流可以忽略掉device的细节,采取同样的输入输出方式。
阅读更多可以了解成并行版的STL(?
过了一遍nvidia的官方网文档
发现如果熟悉STL的话,thrust没什么太多好说的,看起来很简单…
不过还是开一篇记录一下,一段时间内估计要和cuda c++ 打交道,就当记录使用过程中遇到的问题吧.
阅读更多由于发现cuda c++ 的 debug方式和c++ 差别很大,因此打算再开一篇,专门记录一些和error checking 以及debug有关的内容.
Error checks in CUDA code can help catch CUDA errors at their source. There are 2 sources of errors in CUDA source code:
阅读更多uodate:有毒吧。kernel中出问题原来是不会报错的。。。。
请教了组里的hust学长orz..、
学到了cuda-memcheck命令和cudaGetLastError来查看问题。。可以参考What is the canonical way to check for errors using the CUDA runtime API?
阅读更多分析levelDB源码的时候遇到的…发现是一个广泛应用的hash算法,而且是纯c写的,于是找来了源码看。
**MurmurHash** 是一种非[加密](https://zh.wikipedia.org/wiki/)型[哈希函数](https://zh.wikipedia.org/wiki/),适用于一般的哈希检索操 …
阅读更多参考:[wiki_FHS](http://Filesystem Hierarchy Standard)
其实这东西。。。虽然有一个统一的标准。。。但是不同发行版。。。或者同一个发行版的不同版本。。。差异貌似都蛮大的。。。所以只是理论上各个目录的作用。。。可能和具体的发行版不符。。。
阅读更多起因是百度实习二面的时候被问了一道类似这样的题:
给我下面的代码,问有没有什么问题。
1 /* *********************************************** 2 Author :111qqz 3 Created Time :2017年02月28日 星期二 14时49分37秒 4 File Name :vector.cpp 5 ************************************************ */ 6 #include <cstdio> 7 #include <vector> 8 …
阅读更多