This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template<typename T> | |
struct get_optional_visit { | |
template<typename U> | |
std::optional<T> operator()(U) const { | |
return std::optional<T>(); | |
} | |
std::optional<T> operator()(const T& t) const { | |
return std::optional<T>(t); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <tuple> | |
/****************** | |
* Implementation * | |
******************/ | |
//If you're using C++14, just use std::integer_sequence | |
//instead of all this index_seq stuff | |
template<unsigned... Indices> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <iterator> | |
#include <algorithm> | |
#include <vector> | |
#include <cmath> | |
std::vector<float> make_log_linear(size_t n, | |
int linear, | |
int subbin) { | |
std::vector<float> result; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import re | |
import operator | |
if __name__ == '__main__': | |
filename = sys.argv[1] | |
f = open(filename, 'r') | |
sentences = {} | |
current_sentence = '' | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <prelude/sequences/uniform_sequence.h> | |
#include <prelude/runtime/tags.h> | |
#include <thrust/host_vector.h> | |
#include <thrust/copy.h> | |
#include <thrust/iterator/counting_iterator.h> | |
typedef copperhead::cpp_tag Tag; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Define the system to be OpenMP to remove all CUDA references | |
#define THRUST_DEVICE_SYSTEM THRUST_DEVICE_SYSTEM_OMP | |
#include <thrust/host_vector.h> | |
#include <thrust/fill.h> | |
#include <thrust/reduce.h> | |
#include <iostream> | |
template<typename T> | |
struct my_reduction { | |
typedef T result_type; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pycuda | |
import pycuda.autoinit | |
import pycuda.gpuarray as gpuarray | |
import numpy as np | |
from codepy.cgen import * | |
from codepy.bpl import BoostPythonModule | |
from codepy.cuda import CudaModule | |
#Make a host_module, compiled for CPU |