Skip to content

Commit 4319512

Browse files
committed
libpressio version 0.62.0
Bug Fixes + Several Bug fixes to support MacOS -- tested on OSX 10.13.6 with XCode 10.0 + MacOS has a different value for size_t than Linux; replaced several references to fix this + Older MacOS did not have support for std::equals with four iterators, use a version from std_compat + A few cases of conversion failures in the JSON conversion code + marking a minor release because some of the changes _may_ change ABI
1 parent 17514fd commit 4319512

File tree

6 files changed

+31
-17
lines changed

6 files changed

+31
-17
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
cmake_minimum_required(VERSION 3.13 FATAL_ERROR)
2-
project(libpressio VERSION "0.61.0" LANGUAGES CXX C)
2+
project(libpressio VERSION "0.62.0" LANGUAGES CXX C)
33

44
#correct was to set a default build type
55
# https://blog.kitware.com/cmake-and-the-default-build-type/

COPYRIGHT.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Copyright © 2021 , UChicago Argonne, LLC
22
All Rights Reserved
3-
[libpressio, Version 0.59.0]
3+
[libpressio, Version 0.62.0]
44
Robert Underwood
55
Argonne National Laboratory
66

include/libpressio_ext/cpp/dtype.h

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,18 @@ namespace impl {
1616
};
1717
}
1818

19+
constexpr pressio_dtype pressio_size_type() {
20+
static_assert(sizeof(size_t) <= 8, "unexpected type");
21+
return (
22+
(sizeof(size_t) == 8 && std::is_unsigned<size_t>::value) ? pressio_uint64_dtype :
23+
(sizeof(size_t) == 8 && !std::is_unsigned<size_t>::value) ? pressio_int64_dtype :
24+
(sizeof(size_t) == 4 && std::is_unsigned<size_t>::value) ? pressio_uint32_dtype :
25+
(sizeof(size_t) == 4 && !std::is_unsigned<size_t>::value) ? pressio_int32_dtype :
26+
(sizeof(size_t) == 2 && std::is_unsigned<size_t>::value) ? pressio_uint16_dtype :
27+
(sizeof(size_t) == 2 && !std::is_unsigned<size_t>::value) ? pressio_int16_dtype :
28+
pressio_uint64_dtype
29+
);
30+
}
1931

2032
/**
2133
* Convert types to pressio_dtypes
@@ -25,14 +37,15 @@ namespace impl {
2537
*/
2638
template <class T>
2739
constexpr pressio_dtype pressio_dtype_from_type() {
28-
static_assert(impl::is_one_of<T,double, float, int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t, uint32_t, uint64_t>::value,
40+
static_assert(impl::is_one_of<T,double, float, int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t, uint32_t, uint64_t, size_t>::value,
2941
"unexpected type");
3042
return (std::is_same<T, double>::value ? pressio_double_dtype :
3143
std::is_same<T, float>::value ? pressio_float_dtype :
3244
std::is_same<T, int64_t>::value ? pressio_int64_dtype :
3345
std::is_same<T, int32_t>::value ? pressio_int32_dtype :
3446
std::is_same<T, int16_t>::value ? pressio_int16_dtype :
3547
std::is_same<T, int8_t>::value ? pressio_int8_dtype :
48+
std::is_same<T, size_t>::value ? pressio_size_type() :
3649
std::is_same<T, uint64_t>::value ? pressio_uint64_dtype :
3750
std::is_same<T, uint32_t>::value ? pressio_uint32_dtype :
3851
std::is_same<T, uint16_t>::value ? pressio_uint16_dtype :

src/plugins/io/csv.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "libpressio_ext/cpp/data.h"
1313
#include "libpressio_ext/cpp/io.h"
1414
#include "std_compat/memory.h"
15+
#include "std_compat/algorithm.h"
1516

1617
namespace {
1718
struct csv_printer {
@@ -63,7 +64,7 @@ struct csv_io : public libpressio_io_plugin
6364
sizes[1] = column;
6465
}
6566
sizes[0] -= skip_rows;
66-
if(data && data->has_data() && std::equal(sizes.begin(), sizes.end(), data->dimensions().begin(), data->dimensions().end()) && data->dtype() == pressio_double_dtype) {
67+
if(data && data->has_data() && compat::equal(sizes.begin(), sizes.end(), data->dimensions().begin(), data->dimensions().end()) && data->dtype() == pressio_double_dtype) {
6768
auto ret = pressio_data_new_empty(pressio_byte_dtype, 0, nullptr);
6869
*ret = std::move(*data);
6970
std::copy(builder.begin(), builder.end(), static_cast<double*>(ret->data()));

src/plugins/metrics/region_of_interest.cc

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ namespace region_of_interest {
2525
{
2626
region_of_interest_metrics m;
2727
if (start.empty()) {
28-
start = std::vector<uint64_t>(input_dims.size());
28+
start = std::vector<size_t>(input_dims.size());
2929
}
3030
if (end.empty()) {
3131
end = input_dims;
@@ -35,22 +35,22 @@ namespace region_of_interest {
3535
const size_t n = compat::transform_reduce(
3636
std::begin(start), std::end(start),
3737
std::begin(end),
38-
uint64_t{0},
39-
[](uint64_t start, uint64_t stop){ return stop-start; },
38+
size_t{0},
39+
[](size_t start, size_t stop){ return stop-start; },
4040
compat::plus<>{}
4141
);
4242
switch (input_dims.size()) {
4343
case 1:
44-
for (uint64_t i = start[0]; i < end[0]; ++i) {
44+
for (size_t i = start[0]; i < end[0]; ++i) {
4545
input_sum += input_begin[i];
4646
decomp_sum += decomp_begin[i];
4747
}
4848
break;
4949
case 2:
5050
{
5151
auto stride = input_dims[1];
52-
for (uint64_t i = start[0]; i < end[0]; ++i) {
53-
for (uint64_t j = start[1]; j < end[1]; ++j) {
52+
for (size_t i = start[0]; i < end[0]; ++i) {
53+
for (size_t j = start[1]; j < end[1]; ++j) {
5454
auto idx = j + stride * i;
5555
input_sum += input_begin[idx];
5656
decomp_sum += decomp_begin[idx];
@@ -62,9 +62,9 @@ namespace region_of_interest {
6262
{
6363
const auto stride = input_dims[2];
6464
const auto stride2 = input_dims[1] * input_dims[2];
65-
for (uint64_t i = start[0]; i < end[0]; ++i) {
66-
for (uint64_t j = start[1]; j < end[1]; ++j) {
67-
for (uint64_t k = start[2]; k < end[2]; ++k) {
65+
for (size_t i = start[0]; i < end[0]; ++i) {
66+
for (size_t j = start[1]; j < end[1]; ++j) {
67+
for (size_t k = start[2]; k < end[2]; ++k) {
6868
auto idx =k + j*stride + i*stride2;
6969
input_sum += input_begin[idx];
7070
decomp_sum += decomp_begin[idx];
@@ -84,7 +84,7 @@ namespace region_of_interest {
8484
}
8585

8686
std::vector<size_t> const input_dims, decomp_dims;
87-
std::vector<uint64_t> start,end;
87+
std::vector<size_t> start,end;
8888
};
8989
}
9090

@@ -101,7 +101,7 @@ class region_of_interest_plugin : public libpressio_metrics_plugin
101101
struct pressio_data const* output, int) override
102102
{
103103
err_metrics = pressio_data_for_each<region_of_interest::region_of_interest_metrics>( input_data, *output,
104-
region_of_interest::compute_metrics{input_data.dimensions(), output->dimensions(), start.to_vector<uint64_t>(), end.to_vector<uint64_t>()});
104+
region_of_interest::compute_metrics{input_data.dimensions(), output->dimensions(), start.to_vector<size_t>(), end.to_vector<size_t>()});
105105
}
106106

107107
struct pressio_options get_metrics_results() const override

src/pressio_options_json.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ static void from_json_array(nlohmann::json const& j, pressio_option& option) {
140140
switch(j_type) {
141141
case nlohmann::json::value_t::string:
142142
case nlohmann::json::value_t::binary:
143-
option = std::vector<std::string>(j.begin(), j.end());
143+
option = j.get<std::vector<std::string>>();
144144
break;
145145
case nlohmann::json::value_t::number_integer:
146146
case nlohmann::json::value_t::number_unsigned:
@@ -212,7 +212,7 @@ void from_json(nlohmann::json const& j, pressio_option& option) {
212212
option = double(j.at("value"));
213213
break;
214214
case pressio_option_charptr_type:
215-
option = std::string(j.at("value"));
215+
option = j.at("value").get<std::string>();
216216
break;
217217
case pressio_option_charptr_array_type:
218218
option = std::vector<std::string>{j.at("value")};

0 commit comments

Comments
 (0)