Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions .github/workflows/container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,7 @@ jobs:
df -h
# 100 largest packages, in ascending order
dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -n | tail -n 100
sudo apt-get remove -y google-cloud-cli
sudo apt-get remove -y azure-cli
sudo apt-get remove -y microsoft-edge-stable
sudo apt-get remove -y '^dotnet-.*'
sudo apt-get remove -y '^temurin-.*-jdk'
sudo apt-get remove -y google-chrome-stable
sudo apt-get remove -y '^llvm-.*-dev'
sudo apt-get remove -y firefox
sudo apt-get remove -y powershell
sudo apt-get remove -y mono-devel
sudo apt-get remove -y microsoft-edge-stable azure-cli google-cloud-cli google-chrome-stable '^temurin-.*-jdk' '^llvm-.*-dev' firefox powershell
sudo apt-get autoremove -y
sudo apt-get clean
# disk space after removing packages
Expand All @@ -36,6 +27,7 @@ jobs:
uses: redhat-actions/buildah-build@v2
with:
image: pineappl-ci
tags: fastnlo-69d87cf4 latest
containerfiles: maintainer/pineappl-ci/Containerfile
context: maintainer/pineappl-ci/
oci: true
Expand Down
3 changes: 2 additions & 1 deletion maintainer/pineappl-ci/Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ FROM debian:11-slim

ARG APPLGRID_V=1.6.36
ARG CARGOC_V=0.10.3
ARG FASTNLO_V=2.5.0-2826
ARG FASTNLO_R=69d87cf4
ARG FASTNLO_V=2.6
ARG LHAPDF_V=6.5.4
ARG ZLIB_V=1.3.1

Expand Down
10 changes: 8 additions & 2 deletions maintainer/pineappl-ci/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
set -euo pipefail

pkgs=(
automake
build-essential
curl
gfortran
git
libssl-dev
libtool
openssl
pkg-config
)
Expand Down Expand Up @@ -85,8 +87,12 @@ cp src/*.h "${APPL_IGRID_DIR}"
cd ..

# install fastNLO
curl "https://fastnlo.hepforge.org/code/v25/fastnlo_toolkit-${FASTNLO_V}.tar.gz" | tar xzf -
cd "fastnlo_toolkit-${FASTNLO_V}"
# curl "https://fastnlo.hepforge.org/code/v25/fastnlo_toolkit-${FASTNLO_V}.tar.gz" | tar xzf -
git clone https://gitlab.etp.kit.edu/qcd-public/fastNLO.git
cd fastNLO
git checkout "${FASTNLO_R}"
cd "v${FASTNLO_V}/toolkit"
autoreconf -fi
./configure --prefix=/usr/local/
make -j V=1
make install
Expand Down
2 changes: 1 addition & 1 deletion pineappl_cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,6 @@ rustc-args = [ "--cfg feature=\"docs-only\"" ]
[features]
applgrid = ["dep:cxx", "dep:pineappl_applgrid"]
evolve = ["dep:base64", "dep:either", "dep:tar", "dep:lz4_flex", "dep:ndarray-npy", "dep:serde", "dep:serde_yaml"]
fastnlo = ["dep:pineappl_fastnlo"]
fastnlo = ["dep:cxx", "dep:pineappl_fastnlo"]
fktable = ["dep:flate2", "dep:tar"]
static = ["lhapdf/static", "pineappl/static", "pineappl_applgrid?/static", "pineappl_fastnlo?/static"]
49 changes: 48 additions & 1 deletion pineappl_cli/src/export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ use std::process::ExitCode;
#[cfg(feature = "applgrid")]
mod applgrid;

#[cfg(feature = "fastnlo")]
mod fastnlo;

#[cfg(feature = "applgrid")]
fn convert_into_applgrid(
output: &Path,
Expand Down Expand Up @@ -42,6 +45,36 @@ fn convert_into_applgrid(
))
}

#[cfg(feature = "fastnlo")]
fn convert_into_fastnlo(
output: &Path,
grid: &Grid,
conv_funs: &mut [Pdf],
_: usize,
discard_non_matching_scales: bool,
) -> Result<(&'static str, Vec<f64>, usize, Vec<bool>)> {
// TODO: check also scale-varied results

let (mut fastnlo, order_mask) =
fastnlo::convert_into_fastnlo(grid, output, discard_non_matching_scales)?;
let results = fastnlo::convolve_fastnlo(fastnlo.pin_mut(), conv_funs);

Ok(("fastNLO", results, 1, order_mask))
}

#[cfg(not(feature = "fastnlo"))]
fn convert_into_fastnlo(
_: &Path,
_: &Grid,
_: &mut [Pdf],
_: usize,
_: bool,
) -> Result<(&'static str, Vec<f64>, usize, Vec<bool>)> {
Err(anyhow!(
"you need to install `pineappl` with feature `fastnlo`"
))
}

fn convert_into_grid(
output: &Path,
grid: &mut Grid,
Expand All @@ -58,13 +91,27 @@ fn convert_into_grid(
scales,
discard_non_matching_scales,
);
} else if extension == "tab"
|| (extension == "gz"
&& output
.with_extension("")
.extension()
.map_or(false, |ext| ext == "tab"))
{
return convert_into_fastnlo(
output,
grid,
conv_funs,
scales,
discard_non_matching_scales,
);
}
}

Err(anyhow!("could not detect file format"))
}

/// Converts PineAPPL grids to APPLgrid files.
/// Converts PineAPPL grids to APPLgrid/fastNLO files.
#[derive(Parser)]
pub struct Opts {
/// Path to the input grid.
Expand Down
112 changes: 112 additions & 0 deletions pineappl_cli/src/export/fastnlo.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
use anyhow::{bail, Result};
use cxx::UniquePtr;
use float_cmp::assert_approx_eq;
use lhapdf::Pdf;
use pineappl::boc::Order;
use pineappl::grid::Grid;
use pineappl_fastnlo::ffi::{self, fastNLOLHAPDF};
use std::path::Path;
use std::pin::Pin;

pub fn convert_into_fastnlo(
grid: &Grid,
_output: &Path,
_discard_non_matching_scales: bool,
) -> Result<(UniquePtr<fastNLOLHAPDF>, Vec<bool>)> {
let bwfl = grid.bwfl();
let dim = bwfl.dimensions();

if dim > 3 {
bail!(
"grid has {} dimensions, but fastNLO only supports up to three-dimensional distributions",
dim
);
}

let bins = bwfl.bins();
let left_bin_limits: Vec<Vec<_>> = bins
.iter()
.map(|bin| bin.limits().iter().map(|&(l, _)| l).collect())
.collect();
let right_bin_limits: Vec<Vec<_>> = bins
.iter()
.map(|bin| bin.limits().iter().map(|&(_, r)| r).collect())
.collect();
let normalizations = bwfl.normalizations();

let order_mask = Order::create_mask(grid.orders(), 3, 0, false);
let orders_with_mask: Vec<_> = grid
.orders()
.iter()
.cloned()
.zip(order_mask.iter().copied())
.collect();
let lo_alphas = orders_with_mask
.iter()
.filter_map(|&(Order { alphas, .. }, keep)| keep.then_some(alphas))
.min()
// UNWRAP: this will fail for `Grid` with no orders, but this shouldn't happen
.unwrap();
//let loops = orders_with_mask
// .iter()
// .filter_map(|&(Order { alphas, .. }, keep)| keep.then_some(alphas))
// .max()
// .unwrap()
// - lo_alphas;

let convolutions: Vec<i32> = grid.convolutions().iter().map(|conv| conv.pid()).collect();

// TODO: lift this restriction
assert_eq!(grid.convolutions().len(), 2);

let channels: Vec<Vec<_>> = grid
.channels()
.iter()
.map(|channel| {
channel
.entry()
.iter()
.map(|&(ref pids, factor)| {
assert_approx_eq!(f64, factor, 1.0, ulps = 4);
ffi::pair_int_int {
first: pids[0],
second: pids[1],
}
})
.collect()
})
.collect();

//for (fnlo_order, order) in order_mask
// .iter()
// .enumerate()
// .filter_map(|(index, keep)| keep.then_some(index))
// .enumerate()
//{}

let _fastnlo = ffi::make_fastnlo_create(
// UNWRAP: negative numbers and overflow should not happen
lo_alphas.try_into().unwrap(),
&left_bin_limits,
&right_bin_limits,
&normalizations,
// TODO: calculate channels for each order separately
// UNWRAP: negative numbers and overflow should not happen
channels.len().try_into().unwrap(),
// UNWRAP: negative numbers and overflow should not happen
channels.len().try_into().unwrap(),
// UNWRAP: negative numbers and overflow should not happen
channels.len().try_into().unwrap(),
&convolutions,
&channels,
);

todo!()
}

pub fn convolve_fastnlo(_grid: Pin<&mut fastNLOLHAPDF>, conv_funs: &mut [Pdf]) -> Vec<f64> {
// TODO: add support for convolving an fastNLO table with two functions
assert_eq!(conv_funs.len(), 1);

todo!()
}
2 changes: 1 addition & 1 deletion pineappl_cli/tests/export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use assert_cmd::Command;
#[cfg(feature = "applgrid")]
use assert_fs::NamedTempFile;

const HELP_STR: &str = "Converts PineAPPL grids to APPLgrid files
const HELP_STR: &str = "Converts PineAPPL grids to APPLgrid/fastNLO files

Usage: pineappl export [OPTIONS] <INPUT> <OUTPUT> <CONV_FUNS>

Expand Down
2 changes: 1 addition & 1 deletion pineappl_cli/tests/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Commands:
convolve Convolutes a PineAPPL grid with a PDF set
diff Compares the numerical content of two grids with each other
evolve Evolve a grid with an evolution kernel operator to an FK table
export Converts PineAPPL grids to APPLgrid files
export Converts PineAPPL grids to APPLgrid/fastNLO files
help Display a manpage for selected subcommands
import Converts APPLgrid/fastNLO/FastKernel files to PineAPPL grids
merge Merges one or more PineAPPL grids together
Expand Down
2 changes: 1 addition & 1 deletion pineappl_fastnlo/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ fn main() {
.file("src/fastnlo.cpp")
.include(fnlo_include_path.trim())
.includes(lhapdf_include_paths)
.std("c++11") // apparently not supported by MSVC, but fastNLO probably can't be compiled on Windows
.std("c++17")
.compile("fnlo-bridge");

println!("cargo:rerun-if-changed=src/lib.rs");
Expand Down
Loading