Skip to content

Instantly share code, notes, and snippets.

View mbianco's full-sized avatar

Mauro Bianco mbianco

View GitHub Profile
@mbianco
mbianco / gpu_clone.h
Created January 31, 2014 09:04
Class to update object on GPU and CPU.
#pragma once
#include <new>
#ifdef __CUDACC__
template <class derived_type>
struct mask_object {
char data[sizeof(derived_type)];
};
@mbianco
mbianco / hybrid_pointer.h
Created January 31, 2014 16:09
A pointer type that manages "heap" memory between CPU and GPU.
#include <cassert>
template <typename T>
struct hybrid_pointer {
T * cpu_p;
#ifdef __CUDACC__
T * gpu_p;
#endif
T * pointer_to_use;
int size;
@mbianco
mbianco / strange_int_list.cpp
Last active October 26, 2017 13:12
Trying to get some compiler errors to arise
#include <type_traits>
template <int... Ints>
struct basic_int_list {};
template <int... Values>
struct strange_int_list {};
template <template <int...> class Container, int... Values>
struct working_thing {
@mbianco
mbianco / double_pack.cu
Last active October 31, 2017 13:26
tuple_cat gives errors with nvcc
// This Compiles
#include <tuple>
template <typename ...T>
struct A {
template <typename ...U>
std::tuple<T..., U...>
make(T... x, U... y) {
return std::tuple<T..., U...>(x..., y...);
@mbianco
mbianco / c_interfaces.cpp
Created January 27, 2020 13:54
example of C to C++ interface
#include <memory>
#include "header.hpp"
std::unique_ptr<my_class<int>> obj;
extern "C"
void init_data(int x) {
obj = std::make_unique<my_class<int>>(x);
}