Giter VIP home page Giter VIP logo

asmmacro.jl's Introduction

AsmMacro.jl

Build Status codecov

AsmMacro.jl provides a relatively simple way to write assembly code in Julia.

Examples

using AsmMacro

# z[1:4] <- x[1:4]*n (with a loop)
@asm function add_loop_sse(x::Ptr{Float64},n::Int,z::Ptr{Float64})
    movq(n, rcx)
    movapd(x[0*16], xmm0)
    movapd(x[1*16], xmm1)
    xorpd(xmm2,xmm2)
    xorpd(xmm3,xmm3)
    @loop
    addpd(xmm0,xmm2)
    addpd(xmm1,xmm3)
    dec(rcx)
    jnz(@loop)
    movapd(xmm2, z[0*16])
    movapd(xmm3, z[1*16])
end

x = [1.0,2.0,4.0,5.0]
n = 10
z = similar(x)
add_loop_sse(pointer(x),n,pointer(z))

julia> z
4-element Array{Float64,1}:
 10.0
 20.0
 40.0
 50.0
using AsmMacro

# z[1:4] <- x[1:4] + y[1:4]
@asm function add_avx256(x::Ptr{Float64},y::Ptr{Float64},z::Ptr{Float64})
    vmovupd(x[0], ymm0)
    vmovupd(y[0], ymm1)
    vaddpd(ymm0, ymm1, ymm1)
    vmovupd(ymm1, z[0])
end

x = [1.0,2.0,3.0,4.0]
y = [4.0,3.0,2.0,1.0]
z = similar(x)
add_avx256(pointer(x),pointer(y),pointer(z))

julia> z
4-element Array{Float64,1}:
 5.0
 5.0
 5.0
 5.0

Acknowledgement

This package is based on the original code by Oscar Blumberg.

asmmacro.jl's People

Contributors

juliatagbot avatar thautwarm avatar yingboma avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.