Skip to content

Instantly share code, notes, and snippets.

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDKalPVMjfwc6xyDXM9Pp5eync+Jv4VcQ/mSN/RLOPfl+wArIPJjhdJU7GecA6pv/09jt2bqTccgeFLm8ASibmIf5ZWoGMfUXquGuf5nUpadOyeIthfiuiFrWv7PY/MYT13Hh24nWrrvnJ7bDd+Jc7HQ5Y5oiV9fMZKBYLg6rwbLnBpHGGkIIRMhZfvD21/av+IZLnAzE3y0/ZTaY5zY9oQNODkWXEhso1+Jv9GEUj0JpUx4ocjhNTwtOydvFB6SamDE9MQ6l5ICXzlVzRxwT1nfXY3R0kkKGw/qSauzAMuBzB98s/zHXLrs1BEV+MNeGi9mE5MI7FBldjN5+sdbCWNJXc+Mjwl6cLZKMXNg1I8mwk2/2fC75GYDkVYse+zcrsfVc4xRTelAZ9rH6HIWy54SNgnY8BynfRKfF/3yn0oBvUcynov68mT2GRimnlXvhpXb12KM4/eDOPcyz/AZiZ2U4sOi+q/dFU4UjcjwbKWnUZvM6jNyP4RTlDUMIQRU1M= yazhou@yazhous-MBP
text = """
0.01908ms
0.02825ms
0.01729ms
0.03700ms
0.02542ms
0.02700ms
0.04529ms
0.00400ms
0.02742ms
import subprocess
import time
from statistics import mean
# Function to measure the execution time of a command
def measure_time(command):
start_time = time.time()
subprocess.run(command, shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
end_time = time.time()
return end_time - start_time
When performing matrix-vector multiplication on the GPU, you can optimize the operation using parallel reduction to efficiently sum up the elements. In a Vulkan compute shader, this could be done using shared memory (local memory in GLSL) to perform a partial sum for each workgroup before completing the sum for the entire vector.
Here's a GLSL compute shader example that demonstrates a reduction pattern for summing elements. The shader assumes that the size of the matrix row (which is the size of the vector) is a power of two for simplicity. This may not be the case in a real-world scenario, so you would need to modify the shader to handle arbitrary sizes.
```glsl
#version 450
// Define the size of the workgroup
layout(local_size_x = 128) in;
goroutine profile: total 60502
30061 @ 0x438cc0 0x448c43 0x835698 0x6c4c74 0x6c6ab5 0x6c8003 0x6c3a7c 0x4688d1
# 0x835697 main.sse+0x787 /data/tmp/portage/net-misc/gossipd-9999/work/src/github.intra.douban.com/push/gossipd/apps/ssed/sse.go:132
# 0x6c4c73 net/http.HandlerFunc.ServeHTTP+0x43 /usr/lib/go/src/net/http/server.go:2012
# 0x6c6ab4 net/http.(*ServeMux).ServeHTTP+0x1a4 /usr/lib/go/src/net/http/server.go:2387
# 0x6c8002 net/http.serverHandler.ServeHTTP+0xa2 /usr/lib/go/src/net/http/server.go:2807
# 0x6c3a7b net/http.(*conn).serve+0x86b /usr/lib/go/src/net/http/server.go:1895
30060 @ 0x438cc0 0x431b9a 0x431105 0x4d41d5 0x4d506b 0x4d504d 0x59c50f 0x5af0ae 0x608950 0x48a7b1 0x608b9c 0x607155 0x60b27b 0x60b286 0x833443 0x4688d1
# 0x431104 internal/poll.runtime_pollWait+0x54 /usr/lib/go/src/runtime/netpoll.go:203
#!/usr/bin/env python
from __future__ import absolute_import, print_function
import os
import sys
import subprocess
import tempfile
import platform
import functools
import codecs
@flaneur2020
flaneur2020 / python27_on_debian.sh
Created January 20, 2016 06:30 — forked from lukaslundgren/python27_on_debian.sh
How to install python 2.7 on debian
sudo apt-get install build-essential libsqlite3-dev zlib1g-dev libncurses5-dev libgdbm-dev libbz2-dev libreadline5-dev libssl-dev libdb-dev
wget http://www.python.org/ftp/python/2.7.9/Python-2.7.9.tgz
tar -xzf Python-2.7.9.tgz
cd Python-2.7.9
./configure --prefix=/usr --enable-shared
make
sudo make install
cd ..
var gulp = require('gulp');
var browserify = require('browserify');
var reactify = require('reactify');
var del = require('del');
var source = require('vinyl-source-stream');
var sass = require('gulp-sass');
var sourcemaps = require('gulp-sourcemaps')
var paths = {
SCSS: ['app/css/**/*.scss'],
def new
@form = flash[:new_fund_password_form] || NewFundPasswordForm.new
end
def create
@form = NewFundPasswordForm.new(new_fund_password_params)
if @form.save
flash[:notice] = I18n.t('fund_passwords.new.success')
redirect_to account_path
else
# 线程池最小为 1,最大为 8
threads 1, 8
# 进程池大小为 3,即应用服务器的 CPU 数 + 1
workers 3
# == 线程安全性:
#
# - ActiveRecord 会通过连接池保证线程安全,在没有 preload_app 时,不需要重新连接。
#