cvtceil¶
Converts the floating-point elements to integers of the same size, rounded toward plus infinity: 2.1 gives 3, -2.9 gives -2, as cvt(ceil(vd0)). The result is exactly the one of cvt applied to the rounded register, in one instruction on AVX-512 (AVX-512 DQ for float64), NEON from ARMv8 (float64 on AArch64) and RVV; elsewhere (SSE, AVX, SVE), the rounding then the conversion. The conversion of a NaN, or of a value whose rounding is out of the range of the destination, gives a result that depends on the target.
Mathematical semantics: \(\text{res}_i = (T_{\text{dst}}) \lceil vd0_i \rceil\)
Prototypes¶
// LMUL = 1 (also without the _m1 suffix)
vd_int64_m1_t mipp_cvtceil_float64_int64_m1(const vd_float64_m1_t vd0);
vd_int32_m1_t mipp_cvtceil_float32_int32_m1(const vd_float32_m1_t vd0);
vd_uint64_m1_t mipp_cvtceil_float64_uint64_m1(const vd_float64_m1_t vd0);
vd_uint32_m1_t mipp_cvtceil_float32_uint32_m1(const vd_float32_m1_t vd0);
// LMUL = 2
vd_int64_m2_t mipp_cvtceil_float64_int64_m2(const vd_float64_m2_t vd0);
vd_int32_m2_t mipp_cvtceil_float32_int32_m2(const vd_float32_m2_t vd0);
vd_uint64_m2_t mipp_cvtceil_float64_uint64_m2(const vd_float64_m2_t vd0);
vd_uint32_m2_t mipp_cvtceil_float32_uint32_m2(const vd_float32_m2_t vd0);
// LMUL = 4
vd_int64_m4_t mipp_cvtceil_float64_int64_m4(const vd_float64_m4_t vd0);
vd_int32_m4_t mipp_cvtceil_float32_int32_m4(const vd_float32_m4_t vd0);
vd_uint64_m4_t mipp_cvtceil_float64_uint64_m4(const vd_float64_m4_t vd0);
vd_uint32_m4_t mipp_cvtceil_float32_uint32_m4(const vd_float32_m4_t vd0);
// LMUL = 8
vd_int64_m8_t mipp_cvtceil_float64_int64_m8(const vd_float64_m8_t vd0);
vd_int32_m8_t mipp_cvtceil_float32_int32_m8(const vd_float32_m8_t vd0);
vd_uint64_m8_t mipp_cvtceil_float64_uint64_m8(const vd_float64_m8_t vd0);
vd_uint32_m8_t mipp_cvtceil_float32_uint32_m8(const vd_float32_m8_t vd0);
// d2 (half-vector)
vd_int64_d2_t mipp_cvtceil_float64_int64_d2(const vd_float64_d2_t vd0);
vd_int32_d2_t mipp_cvtceil_float32_int32_d2(const vd_float32_d2_t vd0);
vd_uint64_d2_t mipp_cvtceil_float64_uint64_d2(const vd_float64_d2_t vd0);
vd_uint32_d2_t mipp_cvtceil_float32_uint32_d2(const vd_float32_d2_t vd0);
// LMUL = 1
vd<int64_t> cvtceil_int64(const vd<float64_t> vd0);
vd<int32_t> cvtceil_int32(const vd<float32_t> vd0);
vd<uint64_t> cvtceil_uint64(const vd<float64_t> vd0);
vd<uint32_t> cvtceil_uint32(const vd<float32_t> vd0);
// LMUL = 2
vd<int64_t, 2> cvtceil_int64(const vd<float64_t, 2> vd0);
vd<int32_t, 2> cvtceil_int32(const vd<float32_t, 2> vd0);
vd<uint64_t, 2> cvtceil_uint64(const vd<float64_t, 2> vd0);
vd<uint32_t, 2> cvtceil_uint32(const vd<float32_t, 2> vd0);
// LMUL = 4
vd<int64_t, 4> cvtceil_int64(const vd<float64_t, 4> vd0);
vd<int32_t, 4> cvtceil_int32(const vd<float32_t, 4> vd0);
vd<uint64_t, 4> cvtceil_uint64(const vd<float64_t, 4> vd0);
vd<uint32_t, 4> cvtceil_uint32(const vd<float32_t, 4> vd0);
// LMUL = 8
vd<int64_t, 8> cvtceil_int64(const vd<float64_t, 8> vd0);
vd<int32_t, 8> cvtceil_int32(const vd<float32_t, 8> vd0);
vd<uint64_t, 8> cvtceil_uint64(const vd<float64_t, 8> vd0);
vd<uint32_t, 8> cvtceil_uint32(const vd<float32_t, 8> vd0);
// d2 (half-vector)
vd<int64_t, -2> cvtceil_int64(const vd<float64_t, -2> vd0);
vd<int32_t, -2> cvtceil_int32(const vd<float32_t, -2> vd0);
vd<uint64_t, -2> cvtceil_uint64(const vd<float64_t, -2> vd0);
vd<uint32_t, -2> cvtceil_uint32(const vd<float32_t, -2> vd0);
// LMUL = 1
template <typename T_DST, typename T_SRC> Vd<T_DST> cvtceil(const Vd<T_SRC>& vd0);
// LMUL = 2
template <typename T_DST, typename T_SRC> Vd<T_DST, 2> cvtceil(const Vd<T_SRC, 2>& vd0);
// LMUL = 4
template <typename T_DST, typename T_SRC> Vd<T_DST, 4> cvtceil(const Vd<T_SRC, 4>& vd0);
// LMUL = 8
template <typename T_DST, typename T_SRC> Vd<T_DST, 8> cvtceil(const Vd<T_SRC, 8>& vd0);
// d2 (half-vector)
template <typename T_DST, typename T_SRC> Vd<T_DST, -2> cvtceil(const Vd<T_SRC, -2>& vd0);
Headers¶
// Option 1: Monolithic (entire library)
#include <mipp.h>
// Option 2: Category level
#include <mipp/c/cat/convert.h> // all variants & LMULs
#include <mipp/c/cat/u/convert.h> // 1D: 'u' variant only (*)
#include <mipp/c/cat/m2/convert.h> // 1D: LMUL=2 only (*)
#include <mipp/c/cat/u/m2/convert.h> // 2D: 'u' + LMUL=2 (*)
// Option 3: Function level (recommended for minimal dependencies)
#include <mipp/c/fun/cvtceil.h> // all variants & LMULs
#include <mipp/c/fun/u/cvtceil.h> // 1D: 'u' variant only (*)
#include <mipp/c/fun/m2/cvtceil.h> // 1D: LMUL=2 only (*)
#include <mipp/c/fun/u/m2/cvtceil.h> // 2D atomic: 'u' + LMUL=2 (fastest compilation) (*)
// (*) Fine-grained headers require MIPP generated with '--granularity fine'
// Option 1: Monolithic (entire library)
#include <mipp.hpp>
// Option 2: Category level
#include <mipp/cpp/cat/convert.hpp> // all variants & LMULs
#include <mipp/cpp/cat/u/convert.hpp> // 1D: 'u' variant only (*)
#include <mipp/cpp/cat/m2/convert.hpp> // 1D: LMUL=2 only (*)
#include <mipp/cpp/cat/u/m2/convert.hpp> // 2D: 'u' + LMUL=2 (*)
// Option 3: Function level (recommended for minimal dependencies)
#include <mipp/cpp/fun/cvtceil.hpp> // all variants & LMULs
#include <mipp/cpp/fun/u/cvtceil.hpp> // 1D: 'u' variant only (*)
#include <mipp/cpp/fun/m2/cvtceil.hpp> // 1D: LMUL=2 only (*)
#include <mipp/cpp/fun/u/m2/cvtceil.hpp> // 2D atomic: 'u' + LMUL=2 (fastest compilation) (*)
// (*) Fine-grained headers require MIPP generated with '--granularity fine'
// Option 1: Monolithic (entire library)
#include <mipp_obj.hpp>
// Option 2: Category level
#include <mipp/obj/cat/convert.hpp> // all variants & LMULs
#include <mipp/obj/cat/u/convert.hpp> // 1D: 'u' variant only (*)
#include <mipp/obj/cat/m2/convert.hpp> // 1D: LMUL=2 only (*)
#include <mipp/obj/cat/u/m2/convert.hpp> // 2D: 'u' + LMUL=2 (*)
// Option 3: Function level (recommended for minimal dependencies)
#include <mipp/obj/fun/cvtceil.hpp> // all variants & LMULs
#include <mipp/obj/fun/u/cvtceil.hpp> // 1D: 'u' variant only (*)
#include <mipp/obj/fun/m2/cvtceil.hpp> // 1D: LMUL=2 only (*)
#include <mipp/obj/fun/u/m2/cvtceil.hpp> // 2D atomic: 'u' + LMUL=2 (fastest compilation) (*)
// (*) Fine-grained headers require MIPP generated with '--granularity fine'
Supported Datatypes¶
float64→int64float32→int32float64→uint64float32→uint32
Architecture & Implementation Matrix¶
Legend: L0 Native Hardware • L1 Dedicated Emulation • L2 Generic Emulation • L3 Scalar Fallback • − N/A — Full details. When the level depends on a compiler flag, the best level is shown.
| Architecture | f64→i64 | f32→i32 | f64→u64 | f32→u32 |
|---|---|---|---|---|
| SSE | L2 | L2 | L2 | L2 |
| AVX | L2 | L2 | L2 | L2 |
| AVX512 | L0 | L0 | L0 | L0 |
| NEON | L0 | L0 | L0 | L0 |
| RVV | L0 | L0 | L0 | L0 |
| SVE | L2 | L2 | L2 | L2 |
Reference Algorithm¶
The scalar reference of MIPP defines the expected result of the function, for each datatype and mask variant: the unit tests compare the SIMD implementations of every target with it.
vd_scalar_int64_m1_t mipp_scalar_cvtceil_float64_int64_m1(const vd_scalar_float64_m1_t vd0) {
vd_scalar_int64_m1_t res;
for (size_t i = 0; i < MIPP_SCALAR_N_FLOAT64; i++)
{
// requires #include <math.h>; rounded toward plus infinity, then converted
res.vd[i] = (int64_t)ceil(vd0.vd[i]);
}
return res;
}
vd_scalar_int32_m1_t mipp_scalar_cvtceil_float32_int32_m1(const vd_scalar_float32_m1_t vd0) {
vd_scalar_int32_m1_t res;
for (size_t i = 0; i < MIPP_SCALAR_N_FLOAT32; i++)
{
// requires #include <math.h>; rounded toward plus infinity, then converted
res.vd[i] = (int32_t)ceilf(vd0.vd[i]);
}
return res;
}
vd_scalar_uint64_m1_t mipp_scalar_cvtceil_float64_uint64_m1(const vd_scalar_float64_m1_t vd0) {
vd_scalar_uint64_m1_t res;
for (size_t i = 0; i < MIPP_SCALAR_N_FLOAT64; i++)
{
// requires #include <math.h>; rounded toward plus infinity, then converted
res.vd[i] = (uint64_t)ceil(vd0.vd[i]);
}
return res;
}
vd_scalar_uint32_m1_t mipp_scalar_cvtceil_float32_uint32_m1(const vd_scalar_float32_m1_t vd0) {
vd_scalar_uint32_m1_t res;
for (size_t i = 0; i < MIPP_SCALAR_N_FLOAT32; i++)
{
// requires #include <math.h>; rounded toward plus infinity, then converted
res.vd[i] = (uint32_t)ceilf(vd0.vd[i]);
}
return res;
}
Test & Verification Specifications¶
How the unit tests draw the inputs (random values) and compare each lane of the result with the scalar reference, as in the generated C API tests.
| Datatypes | Inputs | Comparison with the reference |
|---|---|---|
float64 → int64 |
[-9.223372036854775e+18, 9.223372036854775e+18] | Exact |
float32 → int32 |
[-2147483520, 2147483520] | Exact |
float64 → uint64 |
[0, 1.844674407370955e+19] | Exact |
float32 → uint32 |
[0, 4294967040] | Exact |
Special values
Every other iteration, the lanes of the inputs take these values (cycling, each further input one value later in the list), to cover the cases that random values never hit:
float32,int32:0.5,1.5,2.5,-0.5,-1.5,-2.5,0.25,-0.25,0.75,-0.75,2.999,-2.999,-0.0,8388607.5,16777215.0,2147483520.0,-2147483520.0float32,uint32:0.5,1.5,2.5,0.25,0.75,2.999,0.0,8388607.5,16777215.0,4294967040.0float64,int64:0.5,1.5,2.5,-0.5,-1.5,-2.5,0.25,-0.25,0.75,-0.75,2.999,-2.999,-0.0,4503599627370495.5,1000000000000000.5,9.223372036854775e+18,-9.223372036854775e+18float64,uint64:0.5,1.5,2.5,0.25,0.75,2.999,0.0,4503599627370495.5,1000000000000000.5,1.844674407370955e+19