Skip to content

Instantly share code, notes, and snippets.

// CacheSmth.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <chrono>
#include <iostream>
struct Timer
{
Timer()
@dubik
dubik / len.cu
Last active March 26, 2018 08:29
const int N_VECTORS = 1<<20;
const int VECTOR_COMPONENTS = 512;
const int KBlockSize = 256;
__global__
void calculateDistances(const float v[VECTOR_COMPONENTS], float *vectors, float *distances)
{
int vectorIndex = threadIdx.x + threadIdx.y * KBlockSize;
if (vectorIndex < N_VECTORS) {
float *vector = vectors + vectorIndex * VECTOR_COMPONENTS;
@dubik
dubik / aos.natvis
Created October 17, 2016 09:03
AOS natvis
<?xml version="1.0" encoding="utf-8"?>
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
<Type Name="Vectormath::Aos::Vector3">
<DisplayString>({mVec128.m128_f32[0]}, {mVec128.m128_f32[1]}, {mVec128.m128_f32[2]})</DisplayString>
<Expand>
<Item Name="[x]">mVec128.m128_f32[0]</Item>
<Item Name="[y]">mVec128.m128_f32[1]</Item>
<Item Name="[z]">mVec128.m128_f32[2]</Item>
</Expand>
// Start with 20 civ and 8 mil factories
val civ_fact_init = 20
val mil_fact_init = 8
// Simulate for 2 years
val time = 356 * 2
// Consts of factories in work-days, one civ produces 1 work per day
val mil_fact_cost = 720
// Civ is twice the mil
#define VERSION 1.0.0.0
#define XSTR(x) #x
#define STR(x) XSTR(x)
#define _VERSION _L(STR(VERSION))
_VERSION
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Text;
namespace PrecedenceClimbing
{
internal enum TokenType
@dubik
dubik / BBox.cpp
Last active April 8, 2023 18:04
// Vectormath https://github.com/erwincoumans/sce_vectormath
class Ray
{
public:
Ray();
public:
Vectormath::Aos::Vector3 m_pos;
Vectormath::Aos::Vector3 m_dir;
Vectormath::Aos::Vector3 m_invDir; // 1.0f / m_dir per elem
float m_min;
@dubik
dubik / main.cpp
Created March 24, 2012 20:14
Simple GA using OpenBeagle
#include <beagle/GA.hpp>
#include <vector>
#include <stdio.h>
using namespace std;
using namespace Beagle;
class MaxFctFloatEvalOp : public EvaluationOp {
public:
typedef Beagle::AllocatorT<MaxFctFloatEvalOp, EvaluationOp::Alloc> Alloc;
@dubik
dubik / perf-test.c
Created November 12, 2011 13:07
Performance counters using PAPI
#include <stdio.h>
#include <stdlib.h>
#include <papi.h>
#define NUM_EVENTS 4
void matmul(const double *A, const double *B,
double *C, int m, int n, int p)
{
int i, j, k;
@dubik
dubik / recentlyopenedmodel.cpp
Created July 29, 2011 08:37
QSortFilterProblem
#include <QDebug>
#include "recentlyopenedmodel.h"
RecentlyOpenedModel::RecentlyOpenedModel(QObject *parent) :
QSortFilterProxyModel(parent), maxItemsCount(INT_MAX)
{
setDynamicSortFilter(true);
}
int RecentlyOpenedModel::maxItems() const