Skip to content

Commit

Permalink
automate compiling with Intel's ispc during the build process
Browse files Browse the repository at this point in the history
  • Loading branch information
jvo203 committed Jan 1, 2019
1 parent 1d68dfd commit 0563f69
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 35 deletions.
6 changes: 4 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "fits_web_ql"
version = "4.0.8"
version = "4.0.9"
authors = ["jvo203 <[email protected]>"]
edition = "2018"

Expand All @@ -17,7 +17,8 @@ opencl = ["ocl", "rand"]
[build-dependencies]
bindgen = "*"
metadeps = "*"
clang = "*"
#clang = "*"
ispc = "*"

[package.metadata.pkg-config]
x265 = "2.8"
Expand Down Expand Up @@ -64,6 +65,7 @@ tar = "*"
flate2 = "*"
ocl = {version = "*", optional = true}
rand = {version = "*", optional = true}
ispc = "*"

#rulinalg = "*"
#linearkalman = "*"
Expand Down
9 changes: 1 addition & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,7 @@ https://ispc.github.io

in the "Downloads" section select the binary corresponding to your platform

then place the extracted executable "ispc" in your PATH (for example ~/bin/)

##
compile the native SIMD code with ispc

cd <your_projects_folder>/fits_web_ql

run "make" (from within the fits_web_ql directory where the Makefile is located)
then place the extracted executable "ispc" in your PATH (for example ~/bin/ or /usr/local/bin)

##
install clang
Expand Down
15 changes: 12 additions & 3 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
extern crate bindgen;
extern crate ispc;
extern crate metadeps;

use std::env;
use std::path::PathBuf;

fn main() {
let mut cfg = ispc::Config::new();
cfg.optimization_opt(ispc::opt::OptimizationOpt::FastMath);
cfg.addressing(ispc::opt::Addressing::A32);
let ispc_files = vec!["src/fits.ispc"];
for s in &ispc_files[..] {
cfg.file(*s);
}
cfg.compile("spmd");
//ispc::compile_library("ispc", &["src/fits.ispc"]);
// Tell cargo to tell rustc to link the ISPC object file turned into a static library
println!("cargo:rustc-link-search=native=native");
println!("cargo:rustc-link-lib=static=fits");
//println!("cargo:rustc-link-lib=static=thorenc");
//println!("cargo:rustc-link-search=native=native");
//println!("cargo:rustc-link-lib=static=fits");

println!("cargo:rustc-link-search=native=/usr/local/lib");
println!("cargo:rustc-link-lib=yuv");
Expand Down
4 changes: 0 additions & 4 deletions native/.gitignore

This file was deleted.

28 changes: 14 additions & 14 deletions src/fits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ impl FITS {
mem::forget(data_u8);

unsafe {
ispc_make_image_spectrumF16_minmax(
spmd::make_image_spectrumF16_minmax(
vec_raw.as_mut_ptr(),
self.bzero,
self.bscale,
Expand All @@ -527,7 +527,7 @@ impl FITS {
}
} else {
unsafe {
ispc_make_image_spectrumF32_minmax(
spmd::make_image_spectrumF32_minmax(
data_u8.as_ptr() as *mut i32,
vec_raw.as_mut_ptr(),
self.bzero,
Expand Down Expand Up @@ -621,7 +621,7 @@ impl FITS {
let mask_raw = slice::from_raw_parts_mut(mask_ptr, total_size);
let mask_tid_raw = slice::from_raw_parts_mut(mask_tid_ptr, total_size);

ispc_join_pixels_masks(
spmd::join_pixels_masks(
self.pixels.as_mut_ptr(),
pixels_tid.as_mut_ptr(),
mask_raw.as_mut_ptr(),
Expand Down Expand Up @@ -779,7 +779,7 @@ impl FITS {
let vec_raw = slice::from_raw_parts_mut(vec_ptr, vec_len);
let mask_raw = slice::from_raw_parts_mut(mask_ptr, mask_len);

ispc_make_image_spectrumF16_minmax(
spmd::make_image_spectrumF16_minmax(
vec_raw.as_mut_ptr(),
self.bzero,
self.bscale,
Expand Down Expand Up @@ -871,7 +871,7 @@ impl FITS {
let mask_raw = slice::from_raw_parts_mut(mask_ptr, total_size);
let mask_tid_raw = slice::from_raw_parts_mut(mask_tid_ptr, total_size);

ispc_join_pixels_masks(
spmd::join_pixels_masks(
self.pixels.as_mut_ptr(),
pixels_tid.as_mut_ptr(),
mask_raw.as_mut_ptr(),
Expand Down Expand Up @@ -2465,7 +2465,7 @@ impl FITS {
let vec_raw = slice::from_raw_parts_mut(vec_ptr, vec_len);
let mask_raw = slice::from_raw_parts_mut(mask_ptr, mask_len);

ispc_make_image_spectrumF16_minmax(
spmd::make_image_spectrumF16_minmax(
vec_raw.as_mut_ptr(),
self.bzero,
self.bscale,
Expand Down Expand Up @@ -2527,7 +2527,7 @@ impl FITS {
let mask_raw = slice::from_raw_parts_mut(mask_ptr, total_size);
let mask_tid_raw = slice::from_raw_parts_mut(mask_tid_ptr, total_size);

ispc_join_pixels_masks(
spmd::join_pixels_masks(
pixels.as_mut_ptr(),
pixels_tid.as_mut_ptr(),
mask_raw.as_mut_ptr(),
Expand Down Expand Up @@ -3643,7 +3643,7 @@ impl FITS {
let mask_raw = slice::from_raw_parts_mut(mask_ptr, mask_len);
let y_raw = slice::from_raw_parts_mut(y_ptr, len);

ispc_data_to_luminance_f16_linear(
spmd::data_to_luminance_f16_linear(
raw.as_mut_ptr(),
mask_raw.as_mut_ptr(),
self.bzero,
Expand All @@ -3660,7 +3660,7 @@ impl FITS {
let mask_raw = slice::from_raw_parts_mut(mask_ptr, mask_len);
let y_raw = slice::from_raw_parts_mut(y_ptr, len);

ispc_data_to_luminance_f16_logistic(
spmd::data_to_luminance_f16_logistic(
raw.as_mut_ptr(),
mask_raw.as_mut_ptr(),
self.bzero,
Expand All @@ -3676,7 +3676,7 @@ impl FITS {
let mask_raw = slice::from_raw_parts_mut(mask_ptr, mask_len);
let y_raw = slice::from_raw_parts_mut(y_ptr, len);

ispc_data_to_luminance_f16_ratio(
spmd::data_to_luminance_f16_ratio(
raw.as_mut_ptr(),
mask_raw.as_mut_ptr(),
self.bzero,
Expand All @@ -3692,7 +3692,7 @@ impl FITS {
let mask_raw = slice::from_raw_parts_mut(mask_ptr, mask_len);
let y_raw = slice::from_raw_parts_mut(y_ptr, len);

ispc_data_to_luminance_f16_square(
spmd::data_to_luminance_f16_square(
raw.as_mut_ptr(),
mask_raw.as_mut_ptr(),
self.bzero,
Expand All @@ -3709,7 +3709,7 @@ impl FITS {
let mask_raw = slice::from_raw_parts_mut(mask_ptr, mask_len);
let y_raw = slice::from_raw_parts_mut(y_ptr, len);

ispc_data_to_luminance_f16_legacy(
spmd::data_to_luminance_f16_legacy(
raw.as_mut_ptr(),
mask_raw.as_mut_ptr(),
self.bzero,
Expand Down Expand Up @@ -5041,7 +5041,7 @@ impl FITS {
unsafe {
let raw = slice::from_raw_parts_mut(ptr, len);

let spectrum = ispc_calculate_radial_spectrumF16(
let spectrum = spmd::calculate_radial_spectrumF16(
raw.as_mut_ptr(),
self.bzero,
self.bscale,
Expand Down Expand Up @@ -5229,7 +5229,7 @@ impl FITS {
unsafe {
let raw = slice::from_raw_parts_mut(ptr, len);

let spectrum = ispc_calculate_square_spectrumF16(
let spectrum = spmd::calculate_square_spectrumF16(
raw.as_mut_ptr(),
self.bzero,
self.bscale,
Expand Down
10 changes: 8 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@

include!(concat!(env!("OUT_DIR"), "/bindings.rs"));

#[macro_use]
extern crate ispc;

// Functions exported from ispc will be callable under spmd::*
ispc_module!(spmd);

#[macro_use]
extern crate scan_fmt;

Expand Down Expand Up @@ -2210,8 +2216,8 @@ lazy_static! {
#[cfg(feature = "server")]
static LOG_DIRECTORY: &'static str = "LOGS";

static SERVER_STRING: &'static str = "FITSWebQL v4.0.8";
static VERSION_STRING: &'static str = "SV2018-12-31.2";
static SERVER_STRING: &'static str = "FITSWebQL v4.0.9";
static VERSION_STRING: &'static str = "SV2019-01-01.0";
static WASM_STRING: &'static str = "WASM2018-12-17.0";

#[cfg(not(feature = "server"))]
Expand Down
2 changes: 0 additions & 2 deletions wrapper.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#include <stdbool.h>

#include "native/fits.h"

#include <libyuv/scale.h>

#include <x265.h>

0 comments on commit 0563f69

Please sign in to comment.