Skip to content

Instantly share code, notes, and snippets.

@Bulat-Ziganshin
Bulat-Ziganshin / Process.hs
Created May 1, 2022 12:29
CSP implemented in Haskell
---------------------------------------------------------------------------------------------------
---- "Взаимодействующие последовательные процессы", как описано в книге Хоара. ----
---------------------------------------------------------------------------------------------------
-- |
-- Module : Process
-- Copyright : (c) Bulat Ziganshin <[email protected]>
-- License : Public domain
--
-- Maintainer : [email protected]
-- Stability : experimental
@Bulat-Ziganshin
Bulat-Ziganshin / SmallestArchiver.hc
Created June 16, 2018 03:04
Example of C code produced by GHC 6
/* GHC_PACKAGES base rts
*/
#include "Stg.h"
#include "HsBase.h"
START_MOD_INIT(__stginit_Main,__stginit_Main_)
EF_(__stginit_SystemziEnvironment_);
EF_(__stginit_SystemziIOziUnsafe_);
EF_(__stginit_DataziChar_);
EF_(__stginit_Prelude_);
REGISTER_IMPORT(__stginit_SystemziEnvironment_);
@Bulat-Ziganshin
Bulat-Ziganshin / prime.cpp
Created December 31, 2017 11:36
Usage: "prime N" prints prime number higher or equal to N
#include <stdio.h>
#include <math.h>
#include <algorithm>
int main (int argc, char **argv)
{
if(argc!=2) {printf("Usage: prime N\n Prints prime number higher or equal to N\n"); return 0;}
unsigned long long N, N0;
sscanf (argv[1], "%llu", &N); N0=N;
unsigned m = std::min((unsigned long long)(sqrt(N))+10, N);
@Bulat-Ziganshin
Bulat-Ziganshin / xxh64-OldSpeedTest.txt
Created July 29, 2016 00:10
Example of measuring small time intervals by out-of-order RDTSC instruction. Just compare values produced by the 2 successive runs.
C:\!FreeArc\public\FARSH\SMHasher>a xxh64
-------------------------------------------------------------------------------
--- Testing XXH64 (xxHash, 64-bit result) --- Testing XXH64 (xxHash, 64-bit result)
[[[ Speed Tests ]]] [[[ Speed Tests ]]]
Bulk speed test - 262144-byte keys Bulk speed test - 262144-byte keys
Alignment 0 - 4.441 bytes/cycle - 12706.75 MiB/sec @ 3 ghz Alignment 0 - 3.516 bytes/cycle - 10058.15 MiB/sec @ 3 ghz
Alignment 1 - 4.408 bytes/cycle - 12610.07 MiB/sec @ 3 ghz Alignment 1 - 4.390 bytes/cycle - 12559.72 MiB/sec @ 3 ghz
@Bulat-Ziganshin
Bulat-Ziganshin / mtf_shelwien.cpp
Created June 3, 2016 18:04
MTF by Eugene Shelwien
template< int Mode=0 >
struct MTF {
enum{ CNUM=256 };
typedef short ranktypeF;
typedef byte ranktypeB;
ranktypeF RankF[CNUM];
ranktypeB RankB[CNUM];
@Bulat-Ziganshin
Bulat-Ziganshin / srcoder.c
Created June 3, 2016 13:29
SRC from OpenBWT 2.0
/*
* srcoder.c for the OpenBWT project
* Copyright (c) 2008-2010 Yuta Mori. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
@Bulat-Ziganshin
Bulat-Ziganshin / cuda+multi-gpu+openmp.cu
Created May 24, 2016 16:26
Example of using CUDA with Multi-GPU+OpenMP (compile with -Xcompiler /openmp)
#include<stdio.h>
#include<stdlib.h>
#include <cuda.h>
#include<omp.h>
#include <helper_functions.h>
#include <helper_cuda.h>
#include <cuda_runtime.h>
void fill_matrix(int *A, int fac, int m, int n)
{
@Bulat-Ziganshin
Bulat-Ziganshin / cuda+openmp.cu
Last active February 20, 2021 22:02
Example of using CUDA with OpenMP (compile with -Xcompiler /openmp)
#include<stdio.h>
#include<stdlib.h>
#include <cuda.h>
#include<omp.h>
#include <helper_functions.h>
#include <helper_cuda.h>
#include <cuda_runtime.h>
void fill_matrix(int *A, int fac, int m, int n)
{
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#define DATA_SIZE (1 << 29)
#define DATA_ACCESSES (1 << 8)
#define BLOCK_SIZE 128
#define BLOCKS_COUNT 1024
template<int COUNT, int PAGE_SIZE, typename T>