Skip to content

Instantly share code, notes, and snippets.

View psiha's full-sized avatar

Domagoj Šarić psiha

  • Zagreb, Croatia
  • 16:43 (UTC +01:00)
  • LinkedIn in/psiha
View GitHub Profile
@psiha
psiha / system.hpp
Last active October 7, 2019 13:57
System topology
struct gpu { /*todo*/ };
struct cpu // a type-of system_resource (intentionally not derving from it - avoid paying for RTTI if the user does not need it)
{
enum vendor { /*e.g. AMD, Intel, Samsung, Apple...*/ };
enum isa { /*e.g. x86, ARMv8, ...*/ };
enum microarchitecture { /*e.g. Haswell, Cortex A75, ...*/ };
struct register_bank
{
@psiha
psiha / gist:f92a7b8a93c5ce1736ae
Last active March 2, 2016 01:21
mmap.demo1 Clang codegen
btest`main:
0x100000c00 <+0>: pushq %rbp
0x100000c01 <+1>: movq %rsp, %rbp
0x100000c04 <+4>: pushq %r15
0x100000c06 <+6>: pushq %r14
0x100000c08 <+8>: pushq %r13
0x100000c0a <+10>: pushq %r12
0x100000c0c <+12>: pushq %rbx
0x100000c0d <+13>: subq $0x98, %rsp
0x100000c14 <+20>: leaq 0x28b(%rip), %rdi ; "foo"
@psiha
psiha / mmap.demo1.cpp
Created March 1, 2016 22:02
WannabeBoost.MMAP demo1
#define BOOST_MMAP_HEADER_ONLY
#include <boost/mmap/mapped_view/mapped_view.hpp>
#include <boost/mmap/mappable_objects/file/utility.hpp>
int main( int /*argc*/, char * /*argv*/[] ) noexcept
{
auto maybe_foo_view( boost::mmap::map_read_only_file( "foo" )() );
if ( !maybe_foo_view )
return static_cast<int>( maybe_foo_view.error() );
if ( maybe_foo_view->empty() )
@psiha
psiha / gist:4058473
Created November 12, 2012 10:08
kernel_atan
0001dce0 <nt2::details::internal::invtrig_base<boost::simd::native<float, boost::simd::tag::simd_emulation_<16u>, void>, nt2::radian_tag, mpl_::bool_<true>, float>::kernel_atan(float __vector(4))>:
1dce0: e92d 03f0 stmdb sp!, {r4, r5, r6, r7, r8, r9}
1dce4: ed2d 8b04 vpush {d8-d9}
1dce8: b090 sub sp, #64 ; 0x40
1dcea: af00 add r7, sp, #0
1dcec: b500 push {lr}
1dcee: f00a fd91 bl 28814 <__gnu_mcount_nc>
1dcf2: b0c4 sub sp, #272 ; 0x110
1dcf4: ffc0 6610 vmov.i32 d22, #-2147483648 ; 0x80000000
1dcf8: f10d 040f add.w r4, sp, #15
@psiha
psiha / gist:4038666
Created November 8, 2012 13:01
random gcc vectorizer output
boost\simd\operator\include/boost/simd/toolbox/operator/functions/simd/common/preprocessed/map.hpp:1: note: not vectorized: control flow in loop.
boost\simd\operator\include/boost/simd/toolbox/operator/functions/simd/common/preprocessed/map.hpp:1: note: not vectorized: data ref analysis failed D.596589_502 = MEM[(const type &)D.596576_495];
boost\simd\operator\include/boost/simd/toolbox/operator/functions/simd/common/preprocessed/map.hpp:1: note: not vectorized: data ref analysis failed D.596525_477 = MEM[(const type &)D.596504_466];
boost\simd\operator\include/boost/simd/toolbox/operator/functions/simd/common/preprocessed/map.hpp:1: note: not vectorized: control flow in loop.
boost\simd\operator\include/boost/simd/toolbox/operator/functions/simd/common/preprocessed/map.hpp:1: note: not vectorized: unexpected loop form.
boost\simd\operator\include/boost/simd/toolbox/operator/functions/simd/common/preprocessed/map.hpp:1: note: not vectorized: control flow in loop.
boost\simd\operator\include/boost/simd/toolbox
@psiha
psiha / gist:4038653
Created November 8, 2012 12:59
signnz#3
00019448 <boost::simd::ext::implement<boost::simd::tag::signnz_ (boost::dispatch::meta::simd_<boost::dispatch::meta::floating_<boost::simd::native<float, boost::simd::tag::simd_emulation_<16u>, void> >, boost::simd::tag::simd_emulation_<16u> >), boost::dispatch::tag::cpu_, void>::operator()(boost::simd::native<float, boost::simd::tag::simd_emulation_<16u>, void> const&) const>:
19448: e92d49f8 push {r3, r4, r5, r6, r7, r8, fp, lr}
1944c: e28db01c add fp, sp, #28
19450: e92d4000 push {lr}
19454: fa0010d6 blx 1d7b4 <__gnu_mcount_nc>
19458: e24dd060 sub sp, sp, #96 ; 0x60
1945c: e28d500f add r5, sp, #15
19460: e1a04000 mov r4, r0
19464: e3c5500f bic r5, r5, #15
19468: e1a06002 mov r6, r2
@psiha
psiha / gist:4038628
Created November 8, 2012 12:52
signnz#2
0001d348 <boost::simd::ext::implement<boost::simd::tag::signnz_ (boost::dispatch::meta::simd_<boost::dispatch::meta::floating_<boost::simd::native<float, boost::simd::tag::simd_emulation_<16u>, void> >, boost::simd::tag::simd_emulation_<16u> >), boost::dispatch::tag::cpu_, void>::operator()(boost::simd::native<float, boost::simd::tag::simd_emulation_<16u>, void> const&) const>:
1d348: e92d49f0 push {r4, r5, r6, r7, r8, fp, lr}
1d34c: e28db018 add fp, sp, #24
1d350: e24dd01c sub sp, sp, #28
1d354: e92d4000 push {lr}
1d358: fa000479 blx 1e544 <__gnu_mcount_nc>
1d35c: e24dd060 sub sp, sp, #96 ; 0x60
1d360: e1a05002 mov r5, r2
1d364: e28d4017 add r4, sp, #23
1d368: e1a08000 mov r8, r0
@psiha
psiha / gist:4001645
Created November 2, 2012 14:21
blunder
namespace ext
{
BOOST_SIMD_FUNCTOR_IMPLEMENTATION( boost::simd::tag::minus_, boost::simd::tag::simd_emulation_<16>
, (A0)
, ((simd_<arithmetic_<A0>,boost::simd::tag::cpu_>))
((simd_<arithmetic_<A0>,boost::simd::tag::cpu_>))
)
{
typedef A0 result_type;
@psiha
psiha / gist:3974720
Created October 29, 2012 16:38
signnz
000242d8 <boost::simd::ext::implement<boost::simd::tag::signnz_ (boost::dispatch::meta::simd_<boost::dispatch::meta::floating_<boost::simd::native<float, boost::simd::tag::simd_emulation_<16u>, void> >, boost::simd::tag::simd_emulation_<16u> >), boost::dispatch::tag::cpu_, void>::operator()(boost::simd::native<float, boost::simd::tag::simd_emulation_<16u>, void> const&) const>:
_ZNK5boost4simd3ext9implementIFNS0_3tag7signnz_ENS_8dispatch4meta5simd_INS6_9floating_INS0_6nativeIfNS3_15simd_emulation_ILj16EEEvEEEESB_EEENS5_3tag4cpu_EvEclERKSC_():
242d8: e92d41f0 push {r4, r5, r6, r7, r8, lr}
242dc: e24dd090 sub sp, sp, #144 ; 0x90
242e0: e92d4000 push {lr}
242e4: fa001e6c blx 2bc9c <__gnu_mcount_nc>
242e8: e1a05000 mov r5, r0
242ec: e1a01002 mov r1, r2
242f0: e28d0050 add r0, sp, #80 ; 0x50
242f4: e1a04002 mov r4, r2
@psiha
psiha / gist:3879115
Created October 12, 2012 13:08
error@crosscompiling
2>ClCompile:
2> gather_includes.cpp
2>xlocale(323): warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc
2>gather_includes.obj : error LNK2019: unresolved external symbol "void __cdecl boost::throw_exception(class std::exception const &)" (?throw_exception@boost@@YAXABVexception@std@@@Z) referenced in function "void __cdecl boost::exception_detail::throw_exception_<class std::runtime_error>(class std::runtime_error const &,char const *,char const *,int)" (??$throw_exception_@Vruntime_error@std@@@exception_detail@boost@@YAXABVruntime_error@std@@PBD1H@Z)
gather_includes.exe : fatal error LNK1120: 1 unresolved externals