Skip to content

Commit

Permalink
libpressio version 0.10.3
Browse files Browse the repository at this point in the history
- Clang-Tidy configuration was added
- Several Bug Fixes from Clang-Tidy
  - pass vectors by const& to reduce unnecessary copies
  - make move constructors noexcept to enable additional performance
    optimizations
  - explicitly call version functions in sz_plugin to prevent virtual
    call lookup
  - type mismatch in zfp_plugin has been corrected
  - removed unnessisary null character in tmpfile string in test_io
  • Loading branch information
robertu94 committed Aug 30, 2019
1 parent beb5a37 commit d4b2374
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 13 deletions.
34 changes: 34 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
Checks: 'clang-diagnostic-*,clang-analyzer-*,bugprone-*,-bugprone-macro-parentheses,performance-*,portability-*,security-*,moderize*'
WarningsAsErrors: ''
HeaderFilterRegex: '.*'
AnalyzeTemporaryDtors: false
FormatStyle: none
User: runderwood
CheckOptions:
- key: cert-dcl16-c.NewSuffixes
value: 'L;LL;LU;LLU'
- key: cppcoreguidelines-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic
value: '1'
- key: google-readability-braces-around-statements.ShortStatementLines
value: '1'
- key: google-readability-function-size.StatementThreshold
value: '800'
- key: google-readability-namespace-comments.ShortNamespaceLines
value: '10'
- key: google-readability-namespace-comments.SpacesBeforeComments
value: '2'
- key: modernize-loop-convert.MaxCopySize
value: '16'
- key: modernize-loop-convert.MinConfidence
value: reasonable
- key: modernize-loop-convert.NamingStyle
value: CamelCase
- key: modernize-pass-by-value.IncludeStyle
value: llvm
- key: modernize-replace-auto-ptr.IncludeStyle
value: llvm
- key: modernize-use-nullptr.NullMacros
value: 'NULL'
...

2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
project(libpressio VERSION "0.10.2" LANGUAGES CXX C)
project(libpressio VERSION "0.10.3" LANGUAGES CXX C)

enable_testing()
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
Expand Down
2 changes: 1 addition & 1 deletion COPYRIGHT.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Copyright © 2019 , UChicago Argonne, LLC
All Rights Reserved
[libpressio, Version 0.10.2]
[libpressio, Version 0.10.3]
Robert Underwood
Argonne National Laboratory

Expand Down
15 changes: 8 additions & 7 deletions include/libpressio_ext/cpp/data.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ struct pressio_data {
* \returns an empty data object (i.e. has no data)
* \see pressio_data_new_empty
* */
static pressio_data empty(const pressio_dtype dtype, std::vector<size_t> const dimensions) {
static pressio_data empty(const pressio_dtype dtype, std::vector<size_t> const& dimensions) {
return pressio_data(dtype, nullptr, nullptr, nullptr, dimensions.size(), dimensions.data());
}
/**
Expand All @@ -55,14 +55,15 @@ struct pressio_data {
* \returns an non-owning data object (i.e. calling pressio_data_free will not deallocate this memory)
* \see pressio_data_new_nonowning
* */
static pressio_data nonowning(const pressio_dtype dtype, void* data, std::vector<size_t> const dimensions) {
static pressio_data nonowning(const pressio_dtype dtype, void* data, std::vector<size_t> const& dimensions) {
return pressio_data::nonowning(dtype, data, dimensions.size(), dimensions.data());
}
/**
* creates a copy of a data buffer
*
* \param[in] dtype the type of the buffer
* \param[in] src the buffer to copy \param[in] dimensions the dimensions of the buffer \returns an owning copy of the data object \see pressio_data_new_copy */ static pressio_data copy(const enum pressio_dtype dtype, void* src, std::vector<size_t> const dimensions) {
* \param[in] src the buffer to copy \param[in] dimensions the dimensions of the buffer \returns an owning copy of the data object \see pressio_data_new_copy */
static pressio_data copy(const enum pressio_dtype dtype, void* src, std::vector<size_t> const& dimensions) {
return pressio_data::copy(dtype, src, dimensions.size(), dimensions.data());
}
/**
Expand All @@ -73,7 +74,7 @@ struct pressio_data {
* \returns an owning data object with uninitialized memory
* \see pressio_data_new_owning
* */
static pressio_data owning(const pressio_dtype dtype, std::vector<size_t> const dimensions) {
static pressio_data owning(const pressio_dtype dtype, std::vector<size_t> const& dimensions) {
return pressio_data::owning(dtype, dimensions.size(), dimensions.data());
}
/**
Expand All @@ -89,7 +90,7 @@ struct pressio_data {
* */
static pressio_data move(const pressio_dtype dtype,
void* data,
std::vector<size_t> const dimensions,
std::vector<size_t> const& dimensions,
pressio_data_delete_fn deleter,
void* metadata) {
return pressio_data::move(dtype, data, dimensions.size(), dimensions.data(), deleter, metadata);
Expand Down Expand Up @@ -194,7 +195,7 @@ struct pressio_data {
* \param[in] rhs the data buffer to move from
* \returns a reference to the object moved into
*/
pressio_data(pressio_data&& rhs):
pressio_data(pressio_data&& rhs) noexcept:
data_dtype(rhs.data_dtype),
data_ptr(std::exchange(rhs.data_ptr, nullptr)),
metadata_ptr(std::exchange(rhs.metadata_ptr, nullptr)),
Expand All @@ -207,7 +208,7 @@ struct pressio_data {
* \param[in] rhs the data buffer to move from
* \returns a l-value reference to the object moved into
*/
pressio_data& operator=(pressio_data && rhs) {
pressio_data& operator=(pressio_data && rhs) noexcept {
data_dtype = rhs.data_dtype,
data_ptr = std::exchange(rhs.data_ptr, nullptr),
metadata_ptr = std::exchange(rhs.metadata_ptr, nullptr),
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/compressors/sz_plugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class sz_plugin: public libpressio_compressor_plugin {
public:
sz_plugin() {
std::stringstream ss;
ss << major_version() << "." << minor_version() << "." << patch_version() << "." << revision_version();
ss << sz_plugin::major_version() << "." << sz_plugin::minor_version() << "." << sz_plugin::patch_version() << "." << revision_version();
sz_version = ss.str();
SZ_Init(NULL);
};
Expand Down
7 changes: 5 additions & 2 deletions src/plugins/compressors/zfp_plugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,12 @@ class zfp_plugin: public libpressio_compressor_plugin {
} else if (double tolerance; pressio_options_get_double(options, "zfp:accuracy", &tolerance) == pressio_options_key_set) {
zfp_stream_set_accuracy(zfp, tolerance);
} else if (double rate; pressio_options_get_double(options, "zfp:rate", &rate) == pressio_options_key_set) {
unsigned int type, dims, wra;
unsigned int type, dims;
int wra;
if(
pressio_options_get_uinteger(options, "zfp:type", &type) == pressio_options_key_set &&
pressio_options_get_uinteger(options, "zfp:dims", &dims) == pressio_options_key_set &&
pressio_options_get_uinteger(options, "zfp:wra", &wra) == pressio_options_key_set) {
pressio_options_get_integer(options, "zfp:wra", &wra) == pressio_options_key_set) {
zfp_stream_set_rate(zfp, rate, (zfp_type)type, dims, wra);
} else {
set_error(1, "if you set rate, you must set type, dims, and wra for the rate mode");
Expand Down Expand Up @@ -165,6 +166,7 @@ class zfp_plugin: public libpressio_compressor_plugin {
*type = zfp_type_float;
break;
default:
*type = zfp_type_none;
invalid_type();
}
return 0;
Expand Down Expand Up @@ -194,6 +196,7 @@ class zfp_plugin: public libpressio_compressor_plugin {
*field = zfp_field_4d(in_data, type, r0, r1, r2, r3);
break;
default:
*field = nullptr;
return invalid_dimensions();
}
return 0;
Expand Down
1 change: 1 addition & 0 deletions src/plugins/metrics/time.cc
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ class time_plugin : public libpressio_metrics_plugin {
return opt;
}

private:
timer check_options;
timer set_options;
timer get_options;
Expand Down
2 changes: 1 addition & 1 deletion test/test_io.cc
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ TEST_F(PressioDataIOTests, TestWrite) {
size_t buffer_size;
int* buffer = static_cast<int*>(pressio_data_ptr(data, &buffer_size));
std::iota(buffer, buffer + pressio_data_num_dimensions(data), 0);
auto tmpwrite_name = std::string("test_io_readXXXXXX\0");
auto tmpwrite_name = std::string("test_io_readXXXXXX");
auto tmpwrite_fd = mkstemp(const_cast<char*>(tmpwrite_name.data()));
EXPECT_EQ(pressio_io_data_write(data, tmpwrite_fd), sizeof(int)*6);
pressio_data_free(data);
Expand Down

0 comments on commit d4b2374

Please sign in to comment.