[build] | |
rustflags = ["-C", "link-arg=-fuse-ld=lld"] | |
[target.x86_64-unknown-linux-gnu] | |
linker = "/usr/bin/clang-17" | |
ar = "/usr/bin/llvm-ar-17" | |
rustflags = ["-C", "link-arg=-fuse-ld=lld-17"] | |
[env] | |
CC = "/usr/bin/clang-17" |
function swap(a, b) | |
a = xor(a, b) | |
b = xor(a, b) | |
a = xor(a, b) | |
return a, b | |
end | |
a, b = 1, 2 | |
println(a, " ", b) | |
a, b = swap(a, b) |
import socketserver | |
import urllib.parse | |
import http.server | |
PORT = 4000 | |
data_base = {} | |
""" | |
Before your interview, write a program that runs a server that is accessible on | |
http://localhost:4000/. When your server receives a request on http://localhost:4000/set?somekey=somevalue |
As described in detail here, julia can take really excessive amounts of time to execute the first @everywhere
statement on many processes — around 1 hour for thousands of processes — even if the actual code being executed everywhere is trivial. Basically, the Distributed
functions need to be precompiled to make this happen quickly.
This gist provides a simple way to do so — at least on Slurm clusters (though the same principles should apply elsewhere). Just submit precompile.jl
as a batch job (adjusting the SBATCH
directives as needed), and it should create a sysimage that you can use to run future batch jobs. Check end of the log of the Slurm job to see exactly how to use the sysimage.
Note that both the original julia process and all processes created with addprocs
should use the --sysimage=/path/to/sys_everywhere.so
argument. Doing so reduces the time taken to execute the first @everywhere
sta
# high-low spread estimator (hlse) | |
def hlse(ohlc_df, frequency='daily'): | |
""" | |
Computes the high-low spread estimator, an estimate of bid-offer spreads, a measure of liquidity risk. | |
See Corwin & Schultz (2011) for details: https://papers.ssrn.com/sol3/papers.cfm?abstract_id=1106193 | |
Parameters | |
---------- | |
ohlc_df: DataFrame | |
DataFrame with DatetimeIndex and Open, High, Low and Close (OHLC) prices from which to compute the high-low spread estimates. |
# Use packages to ensure that we trigger Requires.jl. | |
using Zygote: Zygote | |
using ReverseDiff: ReverseDiff | |
using ForwardDiff: ForwardDiff | |
using Tracker: Tracker | |
using Memoization: Memoization # used for ReverseDiff.jl cache. | |
using Turing.Core: ForwardDiffAD, ReverseDiffAD, TrackerAD, ZygoteAD, CHUNKSIZE | |
const DEFAULT_ADBACKENDS = [ |
using ReverseDiff | |
f(x) = maximum(x;dims=1) | |
if abspath(PROGRAM_FILE) == @__FILE__ | |
x = rand(3, 3) | |
println(x) | |
println(ReverseDiff.gradient(sum∘f, x)) | |
end |