Skip to content

Instantly share code, notes, and snippets.

rolandschulz

Block or report user

Report or block rolandschulz

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@rolandschulz
rolandschulz / is_constexpr_memfn.cc
Last active Jan 28, 2019
Checking whether member function is constexpr
View is_constexpr_memfn.cc
//Checking whether member function is constexpr
#include <array>
#include <vector>
template<typename T, typename = void>
struct has_constexpr_size : std::false_type {};
template<typename T, typename Fn, typename ...Args>
constexpr auto invoke_memfn(Fn fn, Args...args) { return (T().*fn)(args...); }
View make_transform_iter_pair.cxx
#include <unordered_map>
#include <vector>
#include <iostream>
#include <type_traits>
#include <memory>
//iteator pair - very crude range
template <typename I1, typename I2=I1>
struct iter_pair : std::pair<I1, I2>
{
View int_cast.cc
//-checks=*,-modernize-use-auto,-hicpp-use-auto -extra-arg="-Weverything -Wno-missing-prototype -Wno-c++98-compat"
void f(double d, int a, int b) {
double r1 = a/b; //warning: result of integer division used in a floating point context; possible loss of precision [bugprone-integer-division]
double r2 = int{a/b};
double r3 = (int)(a/b); //redundant cast to the same type [google-readability-casting]
double r4 = int(a/b);
double r5 = static_cast<int>(a/b);
int i1 = d;
int i2 = int{d}; //error: type 'double' cannot be narrowed to 'int' in initializer list [clang-diagnostic-c++11-narrowing]
@rolandschulz
rolandschulz / dispatch_example.cc
Created Jan 17, 2018
Proof of concept of multi-versioned SIMD type and dispatch function
View dispatch_example.cc
#include <immintrin.h>
#ifdef __ICC //ICC>=16
#define USE_TARGET_ATTR 0
#else //Clang (>=3.8) or GCC
#define USE_TARGET_ATTR 1
#endif
#if USE_TARGET_ATTR
#define TARGET_AVX __attribute__ ((target ("avx")))
View gist:fe8ce3e642fbd3534591a7374142e1de
Update (s) Perf (ns/day)
flexible non-simd 0.494 2.196
flexible 0.253 2.236
non-freeze,acc, bNemd, NH 0.186 2.253
non-ctc 0.183 2.27
non-vsite/shell 0.115 2.278
diag M 0.11 2.258
intrinsic 0.077 2.268
intrinsic, collapse 0.048 2.262
View gist:f5e7b661984ccc3186d8
### Keybase proof
I hereby claim:
* I am rolandschulz on github.
* I am rschulz (https://keybase.io/rschulz) on keybase.
* I have a public key whose fingerprint is E0A8 00C1 496A 767D AA3F DDEE 8B21 18C9 DBF4 28AB
To claim this, I am signing this object:
View gromacs_eclipse_format.xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<profiles version="1">
<profile kind="CodeFormatterProfile" name="Gromacs" version="1">
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_method_declaration" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_for" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_new_line_in_empty_block" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.lineSplit" value="80"/>
<setting id="org.eclipse.cdt.core.formatter.alignment_for_member_access" value="0"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_comma_in_base_types" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.keep_else_statement_on_same_line" value="false"/>
View makeabspath.py
import sys,os,re
CMAKE_SOURCE_DIR="/home/rschulz/download/gromacs5.0"
sp=[CMAKE_SOURCE_DIR+"/src/", CMAKE_SOURCE_DIR+"/src/gromacs/legacyheaders/", os.path.abspath(os.path.dirname(sys.argv[1]))+"/"]
ll=file(sys.argv[1]).readlines()
of=file(sys.argv[1],"w")
inclp = re.compile('^# *include *"')
for l in ll:
You can’t perform that action at this time.