Skip to content

Commit

Permalink
scopehal: add CxxWrap code (#3553)
Browse files Browse the repository at this point in the history
* add CxxWrap code

* slow but actually working way to extract weirdo array

* install lib in the right place hopefully

* disable apple for now

* fix simd stuff on llvm on freebsd

* add function generator
  • Loading branch information
pepijndevos authored Aug 27, 2021
1 parent 1fb6f33 commit 5ed8675
Show file tree
Hide file tree
Showing 5 changed files with 676 additions and 2 deletions.
17 changes: 15 additions & 2 deletions S/scopehal/build_tarballs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# `julia build_tarballs.jl --help` to see a usage message.
using BinaryBuilder, Pkg

julia_version = v"1.6.0"

name = "scopehal"
version = v"0.1.0"

Expand All @@ -15,13 +17,16 @@ sources = [
script = raw"""
cd $WORKSPACE/srcdir/scopehal/
atomic_patch -p1 ${WORKSPACE}/srcdir/patches/0001-replace-color-with-string.patch
atomic_patch -p1 ${WORKSPACE}/srcdir/patches/0001-avx2-fma-on-llvm.patch
atomic_patch -p1 ${WORKSPACE}/srcdir/patches/0001-rigol-function-generator.patch
git submodule update --init
cd xptools
atomic_patch -p1 ${WORKSPACE}/srcdir/patches/0001-musl.patch
cd ../..
cmake -DCMAKE_INSTALL_PREFIX=${prefix} \
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TARGET_TOOLCHAIN%.*}_gcc.cmake \
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TARGET_TOOLCHAIN} \
-DCMAKE_BUILD_TYPE=Release \
-DJulia_PREFIX=${prefix} \
.
make -j${nproc}
make install
Expand All @@ -30,20 +35,28 @@ install_license scopehal/LICENSE

# These are the platforms we will build for by default, unless further
# platforms are passed in on the command line
platforms = filter!(p -> BinaryBuilder.proc_family(p) == "intel", supported_platforms())
include("../../L/libjulia/common.jl")
platforms = libjulia_platforms(julia_version)
# ARM targets are not supported
platforms = filter!(p -> BinaryBuilder.proc_family(p) == "intel", platforms)
# LLVM does not yet support OpenMP on BinaryBuilder
filter!(p -> !Sys.isapple(p), platforms)
platforms = expand_cxxstring_abis(platforms; skip=p->false)


# The products that we will ensure are always built
products = Product[
LibraryProduct("libscopehal", :scopehal)
LibraryProduct("libscopehalwrapper", :scopehalwrapper)
]

# Dependencies that must be installed before this package can be built
dependencies = [
Dependency(PackageSpec(name="yaml_cpp_jll", uuid="01fea8cc-7d33-533a-824e-56a766f4ffe8"))
Dependency(PackageSpec(name="ffts_jll", uuid="84ad2fbc-dacc-5b40-99f5-8db9d02a0a8a"))
Dependency(PackageSpec(name="CompilerSupportLibraries_jll", uuid="e66e0078-7015-5450-92f7-15fbd957f2ae"))
Dependency("libcxxwrap_julia_jll")
BuildDependency(PackageSpec(name="libjulia_jll", version=julia_version))
]

# Build the tarballs, and possibly a `build.jl` as well.
Expand Down
16 changes: 16 additions & 0 deletions S/scopehal/bundled/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,19 @@ add_subdirectory("${PROJECT_SOURCE_DIR}/scopehal/xptools")
set_property(TARGET scopehal PROPERTY POSITION_INDEPENDENT_CODE ON)
set_property(TARGET log PROPERTY POSITION_INDEPENDENT_CODE ON)
set_property(TARGET xptools PROPERTY POSITION_INDEPENDENT_CODE ON)

find_package(JlCxx)
get_target_property(JlCxx_location JlCxx::cxxwrap_julia LOCATION)
get_filename_component(JlCxx_location ${JlCxx_location} DIRECTORY)
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib;${JlCxx_location}")

message(STATUS "Found JlCxx at ${JlCxx_location}")

add_library(scopehalwrapper SHARED scopehalwrapper.cpp)

target_link_libraries(scopehalwrapper
JlCxx::cxxwrap_julia
scopehal
)

install(TARGETS scopehalwrapper LIBRARY)
25 changes: 25 additions & 0 deletions S/scopehal/bundled/patches/0001-avx2-fma-on-llvm.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
From d450b3fb02b6db81b922c42d26c11ec9b228b108 Mon Sep 17 00:00:00 2001
From: Pepijn de Vos <[email protected]>
Date: Fri, 27 Aug 2021 12:10:56 +0200
Subject: [PATCH] avx2+fma on llvm

---
scopehal/Oscilloscope.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scopehal/Oscilloscope.cpp b/scopehal/Oscilloscope.cpp
index a784a4d..4f93027 100644
--- a/scopehal/Oscilloscope.cpp
+++ b/scopehal/Oscilloscope.cpp
@@ -1111,7 +1111,7 @@ void Oscilloscope::Convert16BitSamplesAVX2(
}
}

-__attribute__((target("avx2","fma")))
+__attribute__((target("avx2,fma")))
void Oscilloscope::Convert16BitSamplesFMA(
int64_t* offs, int64_t* durs, float* pout, int16_t* pin, float gain, float offset, size_t count, int64_t ibase)
{
--
2.33.0

Loading

0 comments on commit 5ed8675

Please sign in to comment.