Skip to content

Instantly share code, notes, and snippets.

View chichunchen's full-sized avatar

Chi-Chun, Chen chichunchen

  • HPE/Cray
  • Minnesota
View GitHub Profile
@chichunchen
chichunchen / LearnNvprof.md
Created March 17, 2022 21:43 — forked from mrprajesh/LearnNvprof.md
Learn nvprof - Profiling CUDA Programs

nvprof - NVCC Profiler

It is Nvidia's Profiler, profiles any executable including CUDA programs.

How to use it?

nvprof ./executable

In case if you want the obsolute url /usr/local/cuda/bin/nvprof or /usr/local/cuda-<MAJOR.minor>/bin/nvprof where MAJOR.minor is your CUDA version installed.

@chichunchen
chichunchen / .bashrc
Created July 24, 2019 15:01 — forked from justintv/.bashrc
Display git branch in bash prompt
# If you work with git, you've probably had that nagging sensation of not knowing what branch you are on. Worry no longer!
export PS1="\\w:\$(git branch 2>/dev/null | grep '^*' | colrm 1 2)\$ "
# This will change your prompt to display not only your working directory but also your current git branch, if you have one. Pretty nifty!
# ~/code/web:beta_directory$ git checkout master
# Switched to branch "master"
# ~/code/web:master$ git checkout beta_directory
# Switched to branch "beta_directory"
@chichunchen
chichunchen / llvm-cmake.sh
Last active June 30, 2019 04:36
llvm cmake script for building the learning env.
# clone llvm-project -> mkdir build -> cd build
cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -DLLVM_TARGETS_TO_BUILD=X86 -DCMAKE_INSTALL_PREFIX=$HOME/llvm -DLLVM_ENABLE_PROJECTS="clang;libcxx;libcxxabi;lldb;lld;openmp;clang-tools-extra;compiler-rt" ../llvm/
ninja -j 7
@chichunchen
chichunchen / vimrc
Created June 26, 2019 02:25
my vimrc
set number
set shiftwidth=2
set tabstop=2
:syntax on
set autoindent
set smartindent
" highlight matching braces
set showmatch
set scrolloff=6
class Checker : public clang::ast_matchers::MatchFinder::MatchCallback {
public:
using MatchResult = clang::ast_matchers::MatchFinder::MatchResult;
Checker(bool RewriteOption, clang::Rewriter &Rewriter)
: RewriteOption(RewriteOption), Rewriter(Rewriter) {}
void run(const MatchResult &Result) {
const auto *Target = Result.Nodes.getNodeAs<clang::CXXMethodDecl>("target");
class Consumer : public clang::ASTConsumer {
public:
explicit Consumer(bool RewriteOption, clang::Rewriter &Rewriter)
: Checker(RewriteOption, Rewriter) {
using namespace clang::ast_matchers;
const auto CXXMethodMatcher =
cxxMethodDecl(unless(isExpansionInSystemHeader())).bind("target");
Finder.addMatcher(CXXMethodMatcher, &Checker);
}
// Clang includes
#include "clang/AST/AST.h"
#include "clang/AST/ASTConsumer.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/AttrIterator.h"
#include "clang/AST/Decl.h"
#include "clang/AST/DeclCXX.h"
#include "clang/AST/DeclarationName.h"
#include "clang/AST/RecursiveASTVisitor.h"
#include "clang/Basic/Diagnostic.h"
#include <iostream>
using namespace std;
class Base {
public:
// user wants to override this in
// the derived class
virtual void func()
{
cout << "I am in base" << endl;
#include <iostream>
using namespace std;
class Base {
public:
// user wants to override this in
// the derived class
virtual void func()
{
struct A
{
virtual void foo();
void bar();
};
struct B : A
{
void foo() const override; // Error: B::foo does not override A::foo
// (signature mismatch)