Skip to content

Commit

Permalink
FEATURE: Add automatic update script for tarballs
Browse files Browse the repository at this point in the history
  • Loading branch information
tmasthay committed May 22, 2024
1 parent 4549d9d commit 8e38cf7
Show file tree
Hide file tree
Showing 8 changed files with 2,582 additions and 216 deletions.
2,058 changes: 2,058 additions & 0 deletions api/julia/build_tarballs.jl

Large diffs are not rendered by default.

426 changes: 294 additions & 132 deletions api/julia/m8r.jl

Large diffs are not rendered by default.

50 changes: 50 additions & 0 deletions api/julia/tarball_base.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Note that this script can accept some limited command-line arguments, run
# `julia build_tarballs.jl --help` to see a usage message.
using BinaryBuilder, Pkg

name = "Madagascar"
version = v"1.0.0"

# Collection of sources required to complete build
sources = [
GitSource("https://github.com/ahay/src.git", "!?MADAGASCAR_HASH!?")
]

# Bash recipe for building across all platforms
script = raw"""
cd $WORKSPACE/srcdir/src
# install_license
install_license COPYING.txt
./configure --prefix=${prefix} CC=$(which gcc) CXX=$(which g++) CAIROPATH=${includedir}/cairo FFMPEGPATH=${includedir}/libavcodec/ AR=$(which ar) CPPPATH=${includedir} LIBPATH=${libdir} BLAS=openblas
make -j ${nproc}
make install
"""

# These are the platforms we will build for by default, unless further
# platforms are passed in on the command line
platforms = [
Platform("i686", "linux"; libc="glibc"),
Platform("x86_64", "linux"; libc="glibc")
]


# The products that we will ensure are always built
products = "!?DEPENDENT_EXECUTABLES!?"

# Dependencies that must be installed before this package can be built
dependencies = [
Dependency(PackageSpec(name="CompilerSupportLibraries_jll", uuid="e66e0078-7015-5450-92f7-15fbd957f2ae"))
Dependency(PackageSpec(name="SuiteSparse_jll", uuid="bea87d4a-7f5b-5778-9afe-8cc45184846c"))
Dependency(PackageSpec(name="FFMPEG_jll", uuid="b22a6f82-2f65-5046-a5b2-351ab43fb4e5"))
Dependency(PackageSpec(name="Cairo_jll", uuid="83423d85-b0ee-5818-9007-b63ccbeb887a"))
Dependency(PackageSpec(name="MPICH_jll", uuid="7cb0a576-ebde-5e09-9194-50597f1243b4"))
Dependency(PackageSpec(name="OpenBLAS32_jll", uuid="656ef2d0-ae68-5445-9ca0-591084a874a2"))
Dependency(PackageSpec(name="LAPACK32_jll", uuid="17f450c3-bd24-55df-bb84-8c51b4b939e3"))
Dependency(PackageSpec(name="FFTW_jll", uuid="f5851436-0d7a-5f13-b9de-f02708fd171a"))
]

# Build the tarballs, and possibly a `build.jl` as well.
build_tarballs(ARGS, name, version, sources, script, platforms, products, dependencies; julia_compat="1.6", preferred_gcc_version=v"10.2.0")
34 changes: 17 additions & 17 deletions api/julia/test/afdm.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/env julia
import m8r

c0 = -30.f0/12.f0
c1 = +16.f0/12.f0
c2 = - 1.f0/12.f0
c0 = -30.0f0 / 12.0f0
c1 = +16.0f0 / 12.0f0
c2 = -1.0f0 / 12.0f0

verb = m8r.getbool("verb", false) # verbosity
vel = m8r.getstring("vel")
Expand Down Expand Up @@ -32,17 +32,17 @@ oout = [oz ox ot]
lout = [lz lx lt]
uout = [uz ux ut]
Fo = m8r.output("out")
for i in 1:length(nout)
for i = 1:length(nout)
m8r.putint(Fo, "n$i", nout[i])
m8r.putfloat(Fo, "d$i", dout[i])
m8r.putfloat(Fo, "o$i", oout[i])
m8r.putstring(Fo, "label$i", lout[i])
m8r.putstring(Fo, "unit$i", uout[i])
end

dt2 = dt*dt
idz = 1.f0/(dz*dz)
idx = 1.f0/(dx*dx)
dt2 = dt * dt
idz = 1.0f0 / (dz * dz)
idx = 1.0f0 / (dx * dx)

# allocate temporary arrays
function run_afdm()
Expand All @@ -51,33 +51,33 @@ function run_afdm()
up = zero(vv)
ud = zero(vv)

for it in 1:nt
for it = 1:nt
if verb
print(stderr, "\b\b\b\b\b $it")
end
@views @. ud[3:end-2, 3:end-2] = c0 * uo[3:end-2, 3:end-2] * (idx+idz) +
c1*(uo[3:end-2, 2:end-3] + uo[3:end-2, 4:end-1])*idx +
c2*(uo[3:end-2, 1:end-4] + uo[3:end-2, 5:end ])*idx +
c1*(uo[2:end-3, 3:end-2] + uo[4:end-1, 3:end-2])*idz +
c2*(uo[1:end-4, 3:end-2] + uo[5:end, 3:end-2])*idz
@views @. ud[3:end-2, 3:end-2] =
c0 * uo[3:end-2, 3:end-2] * (idx + idz) +
c1 * (uo[3:end-2, 2:end-3] + uo[3:end-2, 4:end-1]) * idx +
c2 * (uo[3:end-2, 1:end-4] + uo[3:end-2, 5:end]) * idx +
c1 * (uo[2:end-3, 3:end-2] + uo[4:end-1, 3:end-2]) * idz +
c2 * (uo[1:end-4, 3:end-2] + uo[5:end, 3:end-2]) * idz

# inject wavelet
ud = @. ud - ww[it] * rr

# scale by velocity
ud = @. ud * vv * vv

# time step
up = @. 2f0uo - um + ud * dt2
# time step
up = @. 2.0f0uo - um + ud * dt2
um = uo
uo = up

m8r.floatwrite(vec(uo), nz*nx, Fo)
m8r.floatwrite(vec(uo), nz * nx, Fo)
end
end
@fastmath @inbounds run_afdm()

if verb
println(stderr, "\n")
end

3 changes: 1 addition & 2 deletions api/julia/test/clip.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ clip = m8r.getfloat("clip")

trace = Array{Float32}(undef, n1)

for i2 in 1:n2
for i2 = 1:n2
m8r.floatread(trace, n1, inp)
clamp!(trace, -clip, clip)
m8r.floatwrite(trace, n1, out)
end

Loading

0 comments on commit 8e38cf7

Please sign in to comment.