Skip to content

Commit

Permalink
Bump to croaring 4.1.1
Browse files Browse the repository at this point in the history
No API changes, just implementation
  • Loading branch information
Dr-Emann committed Jul 30, 2024
1 parent cb552f1 commit 006f76b
Show file tree
Hide file tree
Showing 11 changed files with 115 additions and 60 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ Current documentation is available at https://docs.rs/croaring/latest/croaring/

## CRoaring Version

This crate uses [CRoaring version `4.1.0`](https://github.com/RoaringBitmap/CRoaring/releases/tag/v4.1.0).
This crate uses [CRoaring version `4.1.1`](https://github.com/RoaringBitmap/CRoaring/releases/tag/v4.1.1).
The version of this crate does not necessarily match the version of CRoaring: the major version of the crate is only
incremented when there are breaking changes in the Rust API: It is possible (and has happened) that breaking changes
in the CRoaring C API do not necessitate a major version bump in this crate.
6 changes: 3 additions & 3 deletions croaring-sys/CRoaring/bindgen_bundled_version.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/* automatically generated by rust-bindgen 0.69.4 */

pub const ROARING_VERSION: &[u8; 6] = b"4.0.0\0";
pub const ROARING_VERSION: &[u8; 6] = b"4.1.1\0";
pub const ROARING_VERSION_MAJOR: _bindgen_ty_1 = 4;
pub const ROARING_VERSION_MINOR: _bindgen_ty_1 = 0;
pub const ROARING_VERSION_REVISION: _bindgen_ty_1 = 0;
pub const ROARING_VERSION_MINOR: _bindgen_ty_1 = 1;
pub const ROARING_VERSION_REVISION: _bindgen_ty_1 = 1;
pub type _bindgen_ty_1 = ::core::ffi::c_uint;
extern "C" {
#[doc = " result might be undefined when input_num is zero"]
Expand Down
145 changes: 100 additions & 45 deletions croaring-sys/CRoaring/roaring.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// !!! DO NOT EDIT - THIS IS AN AUTO-GENERATED FILE !!!
// Created by amalgamation.sh on 2024-07-03T21:30:32Z
// Created by amalgamation.sh on 2024-07-30T19:32:00Z

/*
* The CRoaring project is under a dual license (Apache/MIT).
Expand Down Expand Up @@ -12787,11 +12787,8 @@ int array_container_shrink_to_fit(array_container_t *src) {

/* Free memory. */
void array_container_free(array_container_t *arr) {
if (arr->array !=
NULL) { // Jon Strabala reports that some tools complain otherwise
roaring_free(arr->array);
arr->array = NULL; // pedantic
}
if (arr == NULL) return;
roaring_free(arr->array);
roaring_free(arr);
}

Expand Down Expand Up @@ -12819,10 +12816,7 @@ void array_container_grow(array_container_t *container, int32_t min,
(uint16_t *)roaring_realloc(array, new_capacity * sizeof(uint16_t));
if (container->array == NULL) roaring_free(array);
} else {
// Jon Strabala reports that some tools complain otherwise
if (array != NULL) {
roaring_free(array);
}
roaring_free(array);
container->array =
(uint16_t *)roaring_malloc(new_capacity * sizeof(uint16_t));
}
Expand Down Expand Up @@ -13343,11 +13337,8 @@ void bitset_container_add_from_range(bitset_container_t *bitset, uint32_t min,

/* Free memory. */
void bitset_container_free(bitset_container_t *bitset) {
if (bitset->words !=
NULL) { // Jon Strabala reports that some tools complain otherwise
roaring_aligned_free(bitset->words);
bitset->words = NULL; // pedantic
}
if (bitset == NULL) return;
roaring_aligned_free(bitset->words);
roaring_free(bitset);
}

Expand Down Expand Up @@ -17979,11 +17970,8 @@ void run_container_offset(const run_container_t *c, container_t **loc,

/* Free memory. */
void run_container_free(run_container_t *run) {
if (run->runs !=
NULL) { // Jon Strabala reports that some tools complain otherwise
roaring_free(run->runs);
run->runs = NULL; // pedantic
}
if (run == NULL) return;
roaring_free(run->runs);
roaring_free(run);
}

Expand All @@ -18001,10 +17989,7 @@ void run_container_grow(run_container_t *run, int32_t min, bool copy) {
run->capacity * sizeof(rle16_t));
if (run->runs == NULL) roaring_free(oldruns);
} else {
// Jon Strabala reports that some tools complain otherwise
if (run->runs != NULL) {
roaring_free(run->runs);
}
roaring_free(run->runs);
run->runs = (rle16_t *)roaring_malloc(run->capacity * sizeof(rle16_t));
}
// We may have run->runs == NULL.
Expand Down Expand Up @@ -18426,24 +18411,6 @@ void run_container_andnot(const run_container_t *src_1,
}
}

ALLOW_UNALIGNED
int run_container_to_uint32_array(void *vout, const run_container_t *cont,
uint32_t base) {
int outpos = 0;
uint32_t *out = (uint32_t *)vout;
for (int i = 0; i < cont->n_runs; ++i) {
uint32_t run_start = base + cont->runs[i].value;
uint16_t le = cont->runs[i].length;
for (int j = 0; j <= le; ++j) {
uint32_t val = run_start + j;
memcpy(out + outpos, &val,
sizeof(uint32_t)); // should be compiled as a MOV on x64
outpos++;
}
}
return outpos;
}

/*
* Print this container using printf (useful for debugging).
*/
Expand Down Expand Up @@ -18816,6 +18783,47 @@ static inline int _avx2_run_container_cardinality(const run_container_t *run) {
return sum;
}

ALLOW_UNALIGNED
int _avx2_run_container_to_uint32_array(void *vout, const run_container_t *cont,
uint32_t base) {
int outpos = 0;
uint32_t *out = (uint32_t *)vout;

for (int i = 0; i < cont->n_runs; ++i) {
uint32_t run_start = base + cont->runs[i].value;
uint16_t le = cont->runs[i].length;
if (le < 8) {
for (int j = 0; j <= le; ++j) {
uint32_t val = run_start + j;
memcpy(out + outpos, &val,
sizeof(uint32_t)); // should be compiled as a MOV on x64
outpos++;
}
} else {
int j = 0;
__m256i run_start_v = _mm256_set1_epi32(run_start);
// [8,8,8,8....]
__m256i inc = _mm256_set1_epi32(8);
// used for generate sequence:
// [0, 1, 2, 3...], [8, 9, 10,...]
__m256i delta = _mm256_setr_epi32(0, 1, 2, 3, 4, 5, 6, 7);
for (j = 0; j + 8 <= le; j += 8) {
__m256i val_v = _mm256_add_epi32(run_start_v, delta);
_mm256_storeu_si256((__m256i *)(out + outpos), val_v);
delta = _mm256_add_epi32(inc, delta);
outpos += 8;
}
for (; j <= le; ++j) {
uint32_t val = run_start + j;
memcpy(out + outpos, &val,
sizeof(uint32_t)); // should be compiled as a MOV on x64
outpos++;
}
}
}
return outpos;
}

CROARING_UNTARGET_AVX2

/* Get the cardinality of `run'. Requires an actual computation. */
Expand Down Expand Up @@ -18845,6 +18853,34 @@ int run_container_cardinality(const run_container_t *run) {
return _scalar_run_container_cardinality(run);
}
}

int _scalar_run_container_to_uint32_array(void *vout,
const run_container_t *cont,
uint32_t base) {
int outpos = 0;
uint32_t *out = (uint32_t *)vout;
for (int i = 0; i < cont->n_runs; ++i) {
uint32_t run_start = base + cont->runs[i].value;
uint16_t le = cont->runs[i].length;
for (int j = 0; j <= le; ++j) {
uint32_t val = run_start + j;
memcpy(out + outpos, &val,
sizeof(uint32_t)); // should be compiled as a MOV on x64
outpos++;
}
}
return outpos;
}

int run_container_to_uint32_array(void *vout, const run_container_t *cont,
uint32_t base) {
if (croaring_hardware_support() & ROARING_SUPPORTS_AVX2) {
return _avx2_run_container_to_uint32_array(vout, cont, base);
} else {
return _scalar_run_container_to_uint32_array(vout, cont, base);
}
}

#else

/* Get the cardinality of `run'. Requires an actual computation. */
Expand All @@ -18861,6 +18897,25 @@ int run_container_cardinality(const run_container_t *run) {

return sum;
}

ALLOW_UNALIGNED
int run_container_to_uint32_array(void *vout, const run_container_t *cont,
uint32_t base) {
int outpos = 0;
uint32_t *out = (uint32_t *)vout;
for (int i = 0; i < cont->n_runs; ++i) {
uint32_t run_start = base + cont->runs[i].value;
uint16_t le = cont->runs[i].length;
for (int j = 0; j <= le; ++j) {
uint32_t val = run_start + j;
memcpy(out + outpos, &val,
sizeof(uint32_t)); // should be compiled as a MOV on x64
outpos++;
}
}
return outpos;
}

#endif

#ifdef __cplusplus
Expand Down Expand Up @@ -18922,15 +18977,15 @@ POSSIBILITY OF SUCH DAMAGE.
#include <stdint.h>
#include <stdlib.h>

// Binaries produced by Visual Studio with solely AVX2 routines
// Binaries produced by Visual Studio 19.38 with solely AVX2 routines
// can compile to AVX-512 thus causing crashes on non-AVX-512 systems.
// This appears to affect VS 17.8 and 17.9. We disable AVX-512 and AVX2
// on these systems. It seems that ClangCL is not affected.
// https://github.com/RoaringBitmap/CRoaring/pull/603
#ifndef __clang__
#if _MSC_VER >= 1938
#if _MSC_VER == 1938
#define ROARING_DISABLE_AVX 1
#endif // _MSC_VER >= 1938
#endif // _MSC_VER == 1938
#endif // __clang__

// We need portability.h to be included first, see
Expand Down
8 changes: 4 additions & 4 deletions croaring-sys/CRoaring/roaring.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// !!! DO NOT EDIT - THIS IS AN AUTO-GENERATED FILE !!!
// Created by amalgamation.sh on 2024-07-03T21:30:32Z
// Created by amalgamation.sh on 2024-07-30T19:32:00Z

/*
* The CRoaring project is under a dual license (Apache/MIT).
Expand Down Expand Up @@ -59,11 +59,11 @@
// /include/roaring/roaring_version.h automatically generated by release.py, do not change by hand
#ifndef ROARING_INCLUDE_ROARING_VERSION
#define ROARING_INCLUDE_ROARING_VERSION
#define ROARING_VERSION "4.0.0"
#define ROARING_VERSION "4.1.1"
enum {
ROARING_VERSION_MAJOR = 4,
ROARING_VERSION_MINOR = 0,
ROARING_VERSION_REVISION = 0
ROARING_VERSION_MINOR = 1,
ROARING_VERSION_REVISION = 1
};
#endif // ROARING_INCLUDE_ROARING_VERSION
// clang-format on/* end file include/roaring/roaring_version.h */
Expand Down
2 changes: 1 addition & 1 deletion croaring-sys/CRoaring/roaring.hh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// !!! DO NOT EDIT - THIS IS AN AUTO-GENERATED FILE !!!
// Created by amalgamation.sh on 2024-07-03T21:30:32Z
// Created by amalgamation.sh on 2024-07-30T19:32:00Z

/*
* The CRoaring project is under a dual license (Apache/MIT).
Expand Down
2 changes: 1 addition & 1 deletion croaring-sys/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "croaring-sys"
version = "4.1.0"
version = "4.1.1"
edition = "2021"
authors = ["croaring-rs developers"]
license = "Apache-2.0"
Expand Down
2 changes: 1 addition & 1 deletion croaring-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ fn main() {
build.file("CRoaring/roaring.c");

if let Ok(target_arch) = env::var("ROARING_ARCH") {
build.flag_if_supported(&format!("-march={target_arch}"));
build.flag_if_supported(format!("-march={target_arch}"));
}

build.flag_if_supported("-Wno-unused-function");
Expand Down
2 changes: 1 addition & 1 deletion croaring/src/bitmap/imp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ impl Bitmap {
// (it can be moved safely), and can be freed with `free`, without freeing the underlying
// containers and auxiliary data. Ensure this is still valid every time we update
// the version of croaring.
const _: () = assert!(ffi::ROARING_VERSION_MAJOR == 4 && ffi::ROARING_VERSION_MINOR == 0);
const _: () = assert!(ffi::ROARING_VERSION_MAJOR == 4 && ffi::ROARING_VERSION_MINOR == 1);
ffi::roaring_free(p.cast::<c_void>());
result
}
Expand Down
2 changes: 1 addition & 1 deletion croaring/src/bitmap/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ impl Drop for Bitmap {
fn drop(&mut self) {
// This depends somewhat heavily on the implementation of croaring,
// Ensure this is still valid every time we update the version of croaring.
const _: () = assert!(ffi::ROARING_VERSION_MAJOR == 4 && ffi::ROARING_VERSION_MINOR == 0);
const _: () = assert!(ffi::ROARING_VERSION_MAJOR == 4 && ffi::ROARING_VERSION_MINOR == 1);

// Per https://github.com/RoaringBitmap/CRoaring/blob/4f8dbdb0cc884626b20ef0cc9e891f701fe157cf/cpp/roaring.hh#L182
// > By contract, calling roaring_bitmap_clear() is enough to
Expand Down
2 changes: 1 addition & 1 deletion croaring/src/bitmap/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ impl<'a> BitmapView<'a> {
// `containers` array is stored immediately after the roaring_bitmap_t data.
// Ensure this is still valid every time we update
// the version of croaring.
const _: () = assert!(ffi::ROARING_VERSION_MAJOR == 4 && ffi::ROARING_VERSION_MINOR == 0);
const _: () = assert!(ffi::ROARING_VERSION_MAJOR == 4 && ffi::ROARING_VERSION_MINOR == 1);

assert!(!p.is_null());

Expand Down

0 comments on commit 006f76b

Please sign in to comment.