Skip to content

Commit

Permalink
revert blosc2 to v2.8.0 to remove new dependency libdl
Browse files Browse the repository at this point in the history
  • Loading branch information
fangq committed Oct 14, 2023
1 parent f2eadb5 commit d5b2c40
Show file tree
Hide file tree
Showing 58 changed files with 773 additions and 1,397 deletions.
6 changes: 1 addition & 5 deletions src/Makefile
Expand Up @@ -95,11 +95,7 @@ else
INCLUDEDIRS+=-Iblosc2/internal-complibs/zstd
LIBZLIB+=-Lblosc2/internal-complibs/zstd -lzstd
endif
ifeq ($(findstring _NT-,$(PLATFORM)), _NT-)
LIBZLIB+=-Lblosc2/lib -lblosc2 -pthread
else
LIBZLIB+=-Lblosc2/lib -lblosc2 -pthread -ldl
endif
LIBZLIB+=-Lblosc2/lib -lblosc2 -pthread
ifeq ($(HAVE_ZLIB),yes)
LIBZLIB+=-lz
endif
Expand Down
2 changes: 1 addition & 1 deletion src/blosc2/LICENSE.txt
Expand Up @@ -3,7 +3,7 @@ BSD License
For Blosc - A blocking, shuffling and lossless compression library

Copyright (C) 2009-2018 Francesc Alted <francesc@blosc.org>
Copyright (C) 2019- The Blosc Development Team <blosc@blosc.org>
Copyright (C) 2019-present Blosc Development team <blosc@blosc.org>

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Expand Down
113 changes: 50 additions & 63 deletions src/blosc2/README.rst

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/blosc2/blosc/Makefile
Expand Up @@ -37,7 +37,7 @@ PLATFORM = $(shell uname -s)

DLLFLAG=-fPIC

CPPOPT=-g -Wall -Wextra -O3 -msse2 -DNDEBUG $(DLLFLAG) -std=gnu99 #-g -Wall -std=c99 # -DUSE_OS_TIMER
CPPOPT=-g -Wall -Wextra -O3 -msse2 -DNDEBUG $(DLLFLAG) -std=gnu99 -Wno-unused-variable #-g -Wall -std=c99 # -DUSE_OS_TIMER

ifeq ($(HAVE_ZLIB),yes)
CPPOPT+=-DHAVE_ZLIB
Expand Down
44 changes: 11 additions & 33 deletions src/blosc2/blosc/b2nd.c
@@ -1,23 +1,19 @@
/*********************************************************************
Blosc - Blocked Shuffling and Compression Library
Copyright (c) 2021 The Blosc Development Team <blosc@blosc.org>
Copyright (C) 2021 The Blosc Developers <blosc@blosc.org>
https://blosc.org
License: BSD 3-Clause (see LICENSE.txt)
See LICENSE.txt for details about copyright and rights to use.
**********************************************************************/

#include "b2nd.h"
#include "b2nd_utils.h"
#include <b2nd.h>
#include "context.h"
#include "blosc2/blosc2-common.h"
#include "b2nd_utils.h"
#include "blosc2.h"

#include "blosc2/blosc2-common.h"
#include <inttypes.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>


int b2nd_serialize_meta(int8_t ndim, const int64_t *shape, const int32_t *chunkshape,
Expand Down Expand Up @@ -176,8 +172,8 @@ int update_shape(b2nd_array_t *array, int8_t ndim, const int64_t *shape,
b2nd_serialize_meta(array->ndim, array->shape, array->chunkshape, array->blockshape,
array->dtype, array->dtype_format, &smeta);
if (smeta_len < 0) {
BLOSC_TRACE_ERROR("Error during serializing dims info for Blosc2 NDim");
BLOSC_ERROR(BLOSC2_ERROR_FAILURE);
fprintf(stderr, "error during serializing dims info for Blosc2 NDim");
return -1;
}
// ... and update it in its metalayer
if (blosc2_meta_exists(array->sc, "b2nd") < 0) {
Expand Down Expand Up @@ -269,10 +265,6 @@ int array_new(b2nd_context_t *ctx, int special_value, b2nd_array_t **array) {
}
}

if ((*array)->extchunknitems * sc->typesize > BLOSC2_MAX_BUFFERSIZE){
BLOSC_TRACE_ERROR("Chunksize exceeds maximum of %d", BLOSC2_MAX_BUFFERSIZE);
return BLOSC2_ERROR_MAX_BUFSIZE_EXCEEDED;
}
// Fill schunk with uninit values
if ((*array)->nitems != 0) {
int32_t chunksize = (int32_t) (*array)->extchunknitems * sc->typesize;
Expand Down Expand Up @@ -603,7 +595,7 @@ int get_set_slice(void *buffer, int64_t buffersize, const int64_t *start, const
int64_t nchunk;
blosc2_multidim_to_unidim(nchunk_ndim, ndim, chunks_in_array_strides, &nchunk);

// Check if the chunk needs to be updated
// check if the chunk needs to be updated
int64_t chunk_start[B2ND_MAX_DIM] = {0};
int64_t chunk_stop[B2ND_MAX_DIM] = {0};
for (int i = 0; i < ndim; ++i) {
Expand Down Expand Up @@ -648,7 +640,7 @@ int get_set_slice(void *buffer, int64_t buffersize, const int64_t *start, const
int64_t nblock_ndim[B2ND_MAX_DIM] = {0};
blosc2_unidim_to_multidim(ndim, blocks_in_chunk, nblock, nblock_ndim);

// Check if the block needs to be updated
// check if the block needs to be updated
int64_t block_start[B2ND_MAX_DIM] = {0};
int64_t block_stop[B2ND_MAX_DIM] = {0};
for (int i = 0; i < ndim; ++i) {
Expand Down Expand Up @@ -692,7 +684,7 @@ int get_set_slice(void *buffer, int64_t buffersize, const int64_t *start, const
int64_t nblock_ndim[B2ND_MAX_DIM] = {0};
blosc2_unidim_to_multidim(ndim, blocks_in_chunk, nblock, nblock_ndim);

// Check if the block needs to be updated
// check if the block needs to be updated
int64_t block_start[B2ND_MAX_DIM] = {0};
int64_t block_stop[B2ND_MAX_DIM] = {0};
for (int i = 0; i < ndim; ++i) {
Expand Down Expand Up @@ -891,7 +883,7 @@ int b2nd_get_slice(b2nd_context_t *ctx, b2nd_array_t **array, const b2nd_array_t
int64_t nchunk_ndim[B2ND_MAX_DIM] = {0};
blosc2_unidim_to_multidim(ndim, chunks_in_array, nchunk, nchunk_ndim);

// Check if the chunk needs to be updated
// check if the chunk needs to be updated
int64_t chunk_start[B2ND_MAX_DIM] = {0};
int64_t chunk_stop[B2ND_MAX_DIM] = {0};
int64_t chunk_shape[B2ND_MAX_DIM] = {0};
Expand Down Expand Up @@ -1100,7 +1092,7 @@ int b2nd_print_meta(const b2nd_array_t *array) {
&dtype, &dtype_format));
free(smeta);

printf("b2nd metalayer parameters:\n Ndim: %d", ndim);
printf("b2nd metalayer parameters: \n Ndim: %d", ndim);
printf("\n shape: %" PRId64 "", shape[0]);
for (int i = 1; i < ndim; ++i) {
printf(", %" PRId64 "", shape[i]);
Expand Down Expand Up @@ -1824,20 +1816,6 @@ b2nd_create_ctx(const blosc2_storage *b2_storage, int8_t ndim, const int64_t *sh
ctx->metalayers[i] = metalayers[i];
}

#if defined(HAVE_PLUGINS)
#include "blosc2/codecs-registry.h"
if ((ctx->b2_storage->cparams->compcode >= BLOSC_CODEC_ZFP_FIXED_ACCURACY) &&
(ctx->b2_storage->cparams->compcode <= BLOSC_CODEC_ZFP_FIXED_RATE)) {
for (int i = 0; i < BLOSC2_MAX_FILTERS; ++i) {
if ((ctx->b2_storage->cparams->filters[i] == BLOSC_SHUFFLE) ||
(ctx->b2_storage->cparams->filters[i] == BLOSC_BITSHUFFLE)) {
BLOSC_TRACE_ERROR("ZFP cannot be run in presence of SHUFFLE / BITSHUFFLE");
return NULL;
}
}
}
#endif /* HAVE_PLUGINS */

return ctx;
}

Expand Down
8 changes: 2 additions & 6 deletions src/blosc2/blosc/b2nd_utils.c
@@ -1,18 +1,14 @@
/*********************************************************************
Blosc - Blocked Shuffling and Compression Library
Copyright (c) 2021 The Blosc Development Team <blosc@blosc.org>
Copyright (C) 2021 The Blosc Developers <blosc@blosc.org>
https://blosc.org
License: BSD 3-Clause (see LICENSE.txt)
See LICENSE.txt for details about copyright and rights to use.
**********************************************************************/

#include "b2nd_utils.h"
#include "b2nd.h"

#include <stdint.h>
#include <string.h>
#include <b2nd_utils.h>

// copyNdim where N = {2-8} - specializations of copy loops to be used by b2nd_copy_buffer
// since we don't have c++ templates, substitute manual specializations for up to known B2ND_MAX_DIM (8)
Expand Down
20 changes: 15 additions & 5 deletions src/blosc2/blosc/b2nd_utils.h
@@ -1,17 +1,23 @@
/*********************************************************************
Blosc - Blocked Shuffling and Compression Library
Copyright (c) 2021 The Blosc Development Team <blosc@blosc.org>
Copyright (C) 2021 The Blosc Developers <blosc@blosc.org>
https://blosc.org
License: BSD 3-Clause (see LICENSE.txt)
See LICENSE.txt for details about copyright and rights to use.
**********************************************************************/

#ifndef BLOSC_B2ND_UTILS_H
#define BLOSC_B2ND_UTILS_H
#ifndef B2ND_B2ND_UTILS_H_
#define B2ND_B2ND_UTILS_H_

#include <b2nd.h>
#include <../plugins/plugin_utils.h>

#ifdef __cplusplus
extern "C" {
#endif

#include <stdint.h>

int b2nd_copy_buffer(int8_t ndim,
uint8_t itemsize,
Expand All @@ -20,4 +26,8 @@ int b2nd_copy_buffer(int8_t ndim,
void *dst, const int64_t *dst_pad_shape,
int64_t *dst_start);

#endif /* BLOSC_B2ND_UTILS_H */
#ifdef __cplusplus
}
#endif

#endif // B2ND_B2ND_UTILS_H_
9 changes: 3 additions & 6 deletions src/blosc2/blosc/bitshuffle-altivec.c
@@ -1,7 +1,7 @@
/*********************************************************************
Blosc - Blocked Shuffling and Compression Library
Copyright (c) 2021 The Blosc Development Team <blosc@blosc.org>
Copyright (C) 2021 The Blosc Developers <blosc@blosc.org>
https://blosc.org
License: BSD 3-Clause (see LICENSE.txt)
Expand All @@ -22,17 +22,14 @@
**********************************************************************/


#include "bitshuffle-altivec.h"
#include "bitshuffle-generic.h"
#include "bitshuffle-altivec.h"

/* Make sure ALTIVEC is available for the compilation target and compiler. */
#if defined(__ALTIVEC__)

#include "transpose-altivec.h"

#include <altivec.h>

#include <stdint.h>
#include "transpose-altivec.h"

/* The next is useful for debugging purposes */
#if 0
Expand Down
19 changes: 13 additions & 6 deletions src/blosc2/blosc/bitshuffle-altivec.h
@@ -1,7 +1,7 @@
/*********************************************************************
Blosc - Blocked Shuffling and Compression Library
Copyright (c) 2021 The Blosc Development Team <blosc@blosc.org>
Copyright (C) 2021 The Blosc Developers <blosc@blosc.org>
https://blosc.org
License: BSD 3-Clause (see LICENSE.txt)
Expand All @@ -10,13 +10,15 @@

/* ALTIVEC-accelerated shuffle/unshuffle routines. */

#ifndef BLOSC_BITSHUFFLE_ALTIVEC_H
#define BLOSC_BITSHUFFLE_ALTIVEC_H
#ifndef BITSHUFFLE_ALTIVEC_H
#define BITSHUFFLE_ALTIVEC_H

#include "blosc2/blosc2-common.h"

#include <stddef.h>
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif


BLOSC_NO_EXPORT int64_t
bshuf_trans_byte_elem_altivec(void* in, void* out, const size_t size,
Expand Down Expand Up @@ -44,4 +46,9 @@ BLOSC_NO_EXPORT int64_t
bshuf_untrans_bit_elem_altivec(void* in, void* out, const size_t size,
const size_t elem_size, void* tmp_buf);

#endif /* BLOSC_BITSHUFFLE_ALTIVEC_H */
#ifdef __cplusplus
}
#endif


#endif /* BITSHUFFLE_ALTIVEC_H */
10 changes: 5 additions & 5 deletions src/blosc2/blosc/bitshuffle-avx2.c
@@ -1,7 +1,7 @@
/*********************************************************************
Blosc - Blocked Shuffling and Compression Library
Copyright (c) 2021 The Blosc Development Team <blosc@blosc.org>
Copyright (C) 2021 The Blosc Developers <blosc@blosc.org>
https://blosc.org
License: BSD 3-Clause (see LICENSE.txt)
Expand All @@ -20,17 +20,17 @@
rights to use.
**********************************************************************/

#include "bitshuffle-avx2.h"
#include "bitshuffle-sse2.h"

#include "bitshuffle-generic.h"
#include "bitshuffle-sse2.h"
#include "bitshuffle-avx2.h"


/* Make sure AVX2 is available for the compilation target and compiler. */
#if defined(__AVX2__)

#include <immintrin.h>

#include <stdint.h>

/* The next is useful for debugging purposes */
#if 0
#include <stdio.h>
Expand Down
19 changes: 12 additions & 7 deletions src/blosc2/blosc/bitshuffle-avx2.h
@@ -1,7 +1,7 @@
/*********************************************************************
Blosc - Blocked Shuffling and Compression Library
Copyright (c) 2021 The Blosc Development Team <blosc@blosc.org>
Copyright (C) 2021 The Blosc Developers <blosc@blosc.org>
https://blosc.org
License: BSD 3-Clause (see LICENSE.txt)
Expand All @@ -10,13 +10,14 @@

/* AVX2-accelerated shuffle/unshuffle routines. */

#ifndef BLOSC_BITSHUFFLE_AVX2_H
#define BLOSC_BITSHUFFLE_AVX2_H
#ifndef BITSHUFFLE_AVX2_H
#define BITSHUFFLE_AVX2_H

#include "blosc2/blosc2-common.h"
#include <blosc2/blosc2-common.h>

#include <stddef.h>
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif

/**
AVX2-accelerated bitshuffle routine.
Expand All @@ -32,4 +33,8 @@ BLOSC_NO_EXPORT int64_t
bshuf_untrans_bit_elem_avx2(void* in, void* out, const size_t size,
const size_t elem_size, void* tmp_buf);

#endif /* BLOSC_BITSHUFFLE_AVX2_H */
#ifdef __cplusplus
}
#endif

#endif /* BITSHUFFLE_AVX2_H */
4 changes: 1 addition & 3 deletions src/blosc2/blosc/bitshuffle-generic.c
@@ -1,7 +1,7 @@
/*********************************************************************
Blosc - Blocked Shuffling and Compression Library
Copyright (c) 2021 The Blosc Development Team <blosc@blosc.org>
Copyright (C) 2021 The Blosc Developers <blosc@blosc.org>
https://blosc.org
License: BSD 3-Clause (see LICENSE.txt)
Expand All @@ -10,8 +10,6 @@

#include "bitshuffle-generic.h"

#include <stdint.h>

#ifdef _MSC_VER
#pragma warning (push)
#pragma warning (disable: 4146)
Expand Down

0 comments on commit d5b2c40

Please sign in to comment.