Skip to content

Instantly share code, notes, and snippets.

View BillyONeal's full-sized avatar

Billy O'Neal BillyONeal

View GitHub Profile
@BillyONeal
BillyONeal / future.cpp
Created June 11, 2017 06:20
Visual C++ vMajorNext <future>
// STACK TRACE FUNCTIONS
_VCP_STATIC_ASSERT(_STD is_same<
decltype(__std_async_capture_stack_trace),
decltype(RtlCaptureStackBackTrace)
>::value);
// THREADPOOL FUNCTIONS
struct _Legacy_threadpool_thunk_data
{
@BillyONeal
BillyONeal / algorithm
Created June 9, 2017 21:24
Overhauled inplace_merge
// TEMPLATE FUNCTION inplace_merge WITH PRED
// The "usual invariants" for the inplace_merge helpers below are:
// [_First, _Mid) and [_Mid, _Last) are sorted
// _Pred(*_Mid, *_First) note: this means *_Mid is the "lowest" element
// _Pred(*prev(_Last), *prev(_Mid)) note: this means *prev(_Mid) is the "highest" element
// _Count1 == distance(_First, _Mid)
// _Count2 == distance(_Mid, _Last)
// _Count1 > 1
// _Count2 > 1
template<class _BidIt> inline
@BillyONeal
BillyONeal / hpx_for_each.cpp
Created June 9, 2017 03:41
HPX Comparative
#include <hpx/hpx.hpp>
#include <hpx/hpx_init.hpp>
#include <hpx/parallel/algorithms/for_each.hpp>
#include <stdio.h>
#include <chrono>
#include <cstddef>
#include <iterator>
#include <vector>
#include "stopwatch.hpp"
@BillyONeal
BillyONeal / Results
Last active June 9, 2017 03:34
Hello World Parallel Bench Derived From OpenMP Hello World Example
cl /Zi /std:c++latest /MD /EHsc /O2 /openmp .\openmp.cpp
cl /Zi /std:c++latest /MD /EHsc /O2 .\parallel_for_each_comparative.cpp
cl /D_HAS_AUTO_PTR_ETC=1 /std:c++latest /MD /EHsc /O2 /IC:\Users\bion\Desktop\vcpkg-export-20170608-100432\installed\x86-windows\include .\hpx_for_each.cpp /link /libpath:C:\Users\bion\Desktop\vcpkg-export-20170608-100432\installed\x86-windows\lib hpx.lib hpx_init.lib boost_program_options-vc140-mt-1_64.lib boost_system-vc140-mt-1_64.lib boost_timer-vc140-mt-1_64.lib boost_date_time-vc140-mt-1_64.lib boost_thread-vc140-mt-1_64.lib
PS TEST WCFB01 C:\Users\bion\Desktop>.\parallel_for_each_comparative.exe
Testing sequential
A[70] is 1
Sequential took 2874ms
@BillyONeal
BillyONeal / sorttest.cpp
Created June 8, 2017 07:59
Sort Determinisim
#include <assert.h>
#include <stdio.h>
#include <algorithm>
#include <random>
#include <vector>
using namespace std;
struct kv {
unsigned int significant;
@BillyONeal
BillyONeal / nextbench.cpp
Created June 3, 2017 02:25
std::next benchmark
#include <stdio.h>
#include <algorithm>
#include <chrono>
#include <functional>
#include <iterator>
#include <random>
#include <vector>
using namespace std;
using namespace std::chrono;
@BillyONeal
BillyONeal / mutex.hpp
Created May 31, 2017 23:56
Mutex Next
// CLASS mutex
class mutex
{ // class for mutual exclusion
public:
constexpr mutex() _NOEXCEPT
: _Data()
{ // construct std::mutex
}
mutex(const mutex&) = delete;
@BillyONeal
BillyONeal / algorithm.cpp
Last active May 30, 2017 23:57
inplace_merge overhaul
template<class _BidIt,
class _Diff,
class _Ty> inline
_BidIt _Buffered_rotate_unchecked(const _BidIt _First, const _BidIt _Mid, const _BidIt _Last,
const _Diff _Count1, const _Diff _Count2, _Temporary_buffer<_Ty>& _Temp_buf)
{ // rotate [_First, _Last) using temp buffer
// precondition: _Count1 == distance(_First, _Mid)
// precondition: _Count2 == distance(_Mid, _Last)
if (_Count1 == 0)
{ // do nothing
template <class T>
class StdAllocatorSysMem
{
public:
typedef T value_type;
StdAllocatorSysMem() = default;
StdAllocatorSysMem(const StdAllocatorSysMem&) = default;
template <class Other>
StdAllocatorSysMem(const StdAllocatorSysMem<Other>&)
@BillyONeal
BillyONeal / algorithm.cpp
Created April 3, 2017 22:21
MSVC++ std::clamp
#if _HAS_CXX17
// FUNCTION TEMPLATE clamp
template<class _Ty,
class _Pr>
constexpr const _Ty& clamp(const _Ty& _Val, const _Ty& _Min_val,
const _Ty& _Max_val, _Pr _Pred)
{ // returns _Val constrained to [_Min_val, _Max_val] ordered by _Pred
#if _ITERATOR_DEBUG_LEVEL == 2
return (_DEBUG_LT_PRED(_Pred, _Max_val, _Min_val)
? (_DEBUG_ERROR("invalid bounds arguments passed to std::clamp"), _Val)