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
! Demo fortran program for some syntax candies | |
program fortran_candies | |
implicit none ! Disallow F77 naming conventions | |
integer, parameter :: M = 4, N = 3 ! parameter attribute declares constant | |
real :: A(M, N) | |
! Creates a random matrix | |
call random_number(A) | |
call print_matrix(A, 'A') | |
! Numpy-style slice and set value |
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
subroutine print_matrix(A, var_name) | |
real, intent(in) :: A(:,:) | |
character(len = *), intent(in) :: var_name | |
integer :: i, M, N | |
M = size(A, 1) | |
N = size(A, 2) | |
print *, var_name, '=' | |
do i = 1, M | |
print *, (A(i, j), j = 1,N) | |
end do |
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
# Install homebrew | |
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" | |
# Install python and nodejs | |
brew install python3 | |
brew install nodejs | |
# Install python packages | |
pip3 install numpy | |
pip3 install scipy |
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
heap->occupy_bmap[0] = 0x01; | |
/* becomes | |
598 .loc 2 134 3 is_stmt 1 ## lookup_helper_test.c:134:3 | |
599 leaq 72(%r13), %rsi | |
600 .loc 2 134 24 is_stmt 0 ## lookup_helper_test.c:134:24 | |
601 movq $1, -56(%rbp) | |
602 leaq -56(%rbp), %rdx | |
603 movl $8, %edi | |
604 movl $5, %ecx |
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
typedef enum GenericType GenericType; | |
typedef struct A A; | |
typedef struct B B; | |
enum GenericType | |
{ | |
TYPE_A = 0, | |
TYPE_B = 1, | |
}; |
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 <stdlib.h> | |
#include <stdio.h> | |
#include <pthread.h> | |
#include <stdatomic.h> | |
#include <stdbool.h> | |
static atomic_bool lock = false; | |
static volatile int counter = 0; | |
void* thread_start(void *arg) |
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
// gcc -O2 -Wall -pthread tls_bench.c -o tls_bench | |
// ./tls_bench <num_threads> <loop> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <stdint.h> | |
#include <pthread.h> | |
#include <assert.h> | |
#include <stdatomic.h> | |
__thread int tls = -1; |
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 <sys/mman.h> | |
#include <stdlib.h> | |
#include <stdio.h> | |
#include <stddef.h> | |
int main() | |
{ | |
ptrdiff_t offset = 1L << 36; | |
void* addr = NULL + offset; | |
void* map_addr; |
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
(require 'package) | |
(setq package-archives | |
'(("org" . "http://orgmode.org/elpa/") | |
("gnu" . "http://elpa.gnu.org/packages") | |
("marmalade"."http://marmalade-repo.org/packages/") | |
("melpa"."http://melpa.org/packages/"))) | |
(package-initialize) | |
(defun ensure-package-installed (&rest packages) | |
"Download the package if it were not installed" |
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
AC_DEFUN_ONCE([_AX_GCC_X86_CPU_INIT], | |
[AC_LANG_PUSH([C]) | |
AC_CACHE_CHECK([for gcc __builtin_cpu_init function], | |
[ax_cv_gcc_check_x86_cpu_init], | |
[AC_RUN_IFELSE( | |
[AC_LANG_PROGRAM([#include <stdlib.h>], | |
[__builtin_cpu_init ();]) | |
], | |
[ax_cv_gcc_check_x86_cpu_init=yes], | |
[ax_cv_gcc_check_x86_cpu_init=no])]) |
NewerOlder