Skip to content

Instantly share code, notes, and snippets.

View kaityo256's full-sized avatar
🤖
I, Robot

Hiroshi Watanabe kaityo256

🤖
I, Robot
  • Keio University
  • Japan
View GitHub Profile
@kaityo256
kaityo256 / force.cpp
Created March 17, 2017 05:00
Haswell vs. Skylake
/*
# Copyright H. Watanabe 2017
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
*/
//----------------------------------------------------------------------
#include <stdio.h>
#include <immintrin.h>
#include <iostream>
#include <stdio.h>
#include <immintrin.h>
#include <iostream>
#include <fstream>
#include <random>
#include <math.h>
#include <assert.h>
#include <sys/stat.h>
#include <sys/time.h>
const double density = 1.0;
@kaityo256
kaityo256 / test.cpp
Created March 31, 2017 15:22
sample code using both v4df and OpenMP
#include <stdio.h>
#include <immintrin.h>
#include <iostream>
#include <fstream>
#include <random>
#include <math.h>
#include <assert.h>
#include <sys/stat.h>
#include <sys/time.h>
const double density = 1.0;
@kaityo256
kaityo256 / test.cpp
Created April 5, 2017 03:27
Sample codes for schedule(dynamic)
/*
# Copyright H. Watanabe 2017
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
*/
#include <iostream>
#include <stdio.h>
#include <vector>
#include <chrono>
@kaityo256
kaityo256 / test.cpp
Created April 5, 2017 09:59
OpenMP sample with therad_local
/*
# Copyright H. Watanabe 2017
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
*/
#include <iostream>
#include <stdio.h>
#include <vector>
#include <chrono>
@kaityo256
kaityo256 / serializablemap.cpp
Created April 6, 2017 11:06
Serializable std::map
/*
# Copyright H. Watanabe 2017
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
*/
#include <iostream>
#include <vector>
#include <map>
@kaityo256
kaityo256 / test.cpp
Created April 10, 2017 00:43
MPI sample
#include <stdio.h>
#include <mpi.h>
int
main(int argc, char **argv) {
int rank = 0;
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if (0 == rank) {
int send_value = 12345;
@kaityo256
kaityo256 / test.cpp
Created May 16, 2017 10:30
AVX-512 sample
#include <immintrin.h>
extern __attribute__((aligned(64))) double z[1000000];
typedef double v8df __attribute__((vector_size(64)));
typedef double v4df __attribute__((vector_size(32)));
void
func(int i, v4df &zl, v4df &zh){
v8df zi = _mm512_load_pd((double*)(z + i));
zl = _mm512_extractf64x4_pd(zi,0);
zh = _mm512_extractf64x4_pd(zi,1);
}
@kaityo256
kaityo256 / before.cpp
Created May 24, 2017 04:22
Before SIMDization
void
force_sorted_z(void) {
const int pn = particle_number;
for (int i = 0; i < pn; i++) {
const double qx_key = z[i][X];
const double qy_key = z[i][Y];
const double qz_key = z[i][Z];
const int np = number_of_partners[i];
double pfx = 0;
double pfy = 0;
@kaityo256
kaityo256 / after.cpp
Created May 24, 2017 04:23
After SIMDization
void
force_sorted_z_intrin_swp(void) {
const int pn = particle_number;
const v8df vzero = _mm512_setzero_pd();
const v8df vcl2 = _mm512_set1_pd(CL2);
const v8df vc24 = _mm512_set1_pd(24.0*dt);
const v8df vc48 = _mm512_set1_pd(48.0*dt);
const __m512i idx = _mm512_set_epi64(3,2,1,0,7,6,5,4);
const __m512i idx_q = _mm512_set_epi64(11,10,9,8,3,2,1,0);
const __m512i idx_p = _mm512_set_epi64(15,14,13,12,7,6,5,4);