Skip to content

Commit

Permalink
Cherry-pick PRs and release notes for v3.0.2 (#143)
Browse files Browse the repository at this point in the history
* Lib version (#133)

* Expose IMATH_LIB_VERSION_STRING, for easier diagnostics

Expose the IMATH_LIB_VERSION as a cpp define, along with
IMATH_VERSION, to aid in confirming what SOCURRENT.SOAGE.SOVERSION the
library is built with.

Signed-off-by: Cary Phillips <[email protected]>

* Add comment explaining IMATH_LIB_VERSION

Signed-off-by: Cary Phillips <[email protected]>

* Add section on python bindings (#135)

Signed-off-by: Cary Phillips <[email protected]>

* Don't impose C++14 on downstream projects (#137)

We were setting

    target_compile_features(${objlib} PUBLIC cxx_std_${IMATH_CXX_STANDARD})

The PUBLIC forced downstream projects that consume the
ImathConfig*.cmake exports to use C++ standard at least as recent as
what Imath used to build (which defaults to 14).

But this is unnecessary. There's nothing in Imath's headers that
requires anything beyond C++11. So this patch uses a more fine-grained
setting of target properties to express this more correctly. Now it
will be fine for a C++11 project to consume Imath (via its exported
configs) even if that Imath happened to be built with C++14.

This change is exactly the same as
AcademySoftwareFoundation/openexr#995

Signed-off-by: Larry Gritz <[email protected]>

* Fix regression in succf()/predf() (#140)

And add more thorough test.

Signed-off-by: Cary Phillips <[email protected]>

* Clean up setting of Imath version (#139)

* Clean up setting of Imath version

* Set the version via the project() statement in top-level
  CMakeLists.txt, so all version-related settings are close together
  in an obvious place. Deprecate config/version.cmake and move logic
  to top level
* New option IMATH_VERSION_EXTRA to hold "dev" for the master branch
* Simplfy logic for SOVERSION.SOAGE.SOREVISION (no more SOCURRENT)

Signed-off-by: Cary Phillips <[email protected]>

* find_package uses CMAKE_PROJECT_VERSION instead of IMATH_VERSION

And removed EXACT since IMATH_VERSION includes IMATH_VERISON_EXTRA.

Signed-off-by: Cary Phillips <[email protected]>

* Bump SOVERSION to 28

Signed-off-by: Cary Phillips <[email protected]>

* Release notes for v3.0.2

Signed-off-by: Cary Phillips <[email protected]>

* Bump version for v3.0.2

Signed-off-by: Cary Phillips <[email protected]>

* Adjust SOVERSION/SOREVISION for v3.0.2

Signed-off-by: Cary Phillips <[email protected]>

* Change v3.0.2 release date to May 17

Signed-off-by: Cary Phillips <[email protected]>

* Fix order of ${IMATH_SOVERSION}.${IMATH_SOREVISION}.${IMATH_SOAGE} (#142)

Revision comes before age.

Signed-off-by: Cary Phillips <[email protected]>

* Changed release date of v3.0.2 to May 16

Signed-off-by: Cary Phillips <[email protected]>

Co-authored-by: Larry Gritz <[email protected]>
  • Loading branch information
cary-ilm and lgritz committed May 16, 2021
1 parent 73c2cdf commit f2bcae6
Show file tree
Hide file tree
Showing 9 changed files with 140 additions and 57 deletions.
12 changes: 12 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
# Imath Release Notes

* [Version 3.0.2](#version-302-may-16-2021) May 16, 2021
* [Version 3.0.1](#version-301-april-1-2021) April 1, 2021
* [Version 3.0.1-beta](#version-301-beta-march-28-2021) March 28, 2021
* [Version 3.0.0-beta](#version-300-beta-march-15-2021) March 15, 2021
* [Inherited History from OpenEXR](#inherited-history-from-openexr)

## Version 3.0.2 (May 16, 2021)

Patch release with miscellaneous bug/build fixes:

* \[[#142](https://github.com/AcademySoftwareFoundation/Imath/pull/142)\] Fix order of ${IMATH_SOVERSION}.${IMATH_SOREVISION}.${IMATH_SOAGE}
* \[[#140](https://github.com/AcademySoftwareFoundation/Imath/pull/140)\] Fix regression in succf()/predf()
* \[[#139](https://github.com/AcademySoftwareFoundation/Imath/pull/139)\] Clean up setting of Imath version
* \[[#137](https://github.com/AcademySoftwareFoundation/Imath/pull/137)\] Don't impose C++14 on downstream projects
* \[[#135](https://github.com/AcademySoftwareFoundation/Imath/pull/135)\] Add section on python bindings
* \[[#133](https://github.com/AcademySoftwareFoundation/Imath/pull/133)\] Lib version

## Version 3.0.1 (April 1, 2021)

First release of Imath independent of OpenEXR.
Expand Down
24 changes: 21 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,28 @@ if(POLICY CMP0077)
cmake_policy(SET CMP0077 NEW)
endif()

# Version numbers are maintained in config/version.cmake
include(config/version.cmake)
# Imath version

project(Imath VERSION ${IMATH_VERSION} LANGUAGES C CXX)
project(Imath VERSION 3.0.2 LANGUAGES C CXX)

set(IMATH_VERSION_EXTRA "" CACHE STRING "Extra version tag string for Imath build")

# See https://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
set(IMATH_SOVERSION 28)
set(IMATH_SOREVISION 0)
set(IMATH_SOAGE 0)
set(IMATH_LIB_VERSION "${IMATH_SOVERSION}.${IMATH_SOREVISION}.${IMATH_SOAGE}")

set(IMATH_VERSION_MAJOR ${CMAKE_PROJECT_VERSION_MAJOR})
set(IMATH_VERSION_MINOR ${CMAKE_PROJECT_VERSION_MINOR})
set(IMATH_VERSION_PATCH ${CMAKE_PROJECT_VERSION_PATCH})
set(IMATH_VERSION ${CMAKE_PROJECT_VERSION})
if (NOT IMATH_VERSION_EXTRA STREQUAL "")
set(IMATH_VERSION "${CMAKE_PROJECT_VERSION}-${IMATH_VERSION_EXTRA}")
endif()
set(IMATH_VERSION_API "${IMATH_VERSION_MAJOR}_${IMATH_VERSION_MINOR}")

message(STATUS "Configure Imath Version: ${IMATH_VERSION} Lib API: ${IMATH_LIB_VERSION}")

# ImathSetup.cmake declares all the configuration variables visible
# in cmake-gui or similar and the rest of the global
Expand Down
3 changes: 3 additions & 0 deletions config/ImathConfig.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@
(uint32_t(IMATH_VERSION_MINOR) << 16) | \
(uint32_t(IMATH_VERSION_PATCH) << 8))

// IMATH_LIB_VERSION is the library API version: SOCURRENT.SOAGE.SOREVISION
#define IMATH_LIB_VERSION_STRING "@IMATH_LIB_VERSION@"


//
// By default, opt into the interoparability constructors and assignments.
Expand Down
11 changes: 10 additions & 1 deletion config/LibraryDefine.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,16 @@ function(IMATH_DEFINE_LIBRARY libname)
${IMATH_CURLIB_HEADERS}
${IMATH_CURLIB_SOURCES})

target_compile_features(${objlib} PUBLIC cxx_std_${IMATH_CXX_STANDARD})
# Use ${IMATH_CXX_STANDARD} to determine the standard we use to compile
# Imath itself. But the headers only require C++11 features, so that's
# all we need to pass on as interface reqirements to downstream projects.
# For example, it's fine for an Imath built with C++14 to be called from
# an app that is compiled with C++11; Imath needn't force the app to
# also use C++14.
target_compile_features(${objlib}
PRIVATE cxx_std_${IMATH_CXX_STANDARD}
INTERFACE cxx_std_11 )

if(IMATH_CURLIB_PRIV_EXPORT AND BUILD_SHARED_LIBS)
target_compile_definitions(${objlib} PRIVATE ${IMATH_CURLIB_PRIV_EXPORT})
if(WIN32)
Expand Down
29 changes: 0 additions & 29 deletions config/version.cmake

This file was deleted.

26 changes: 26 additions & 0 deletions docs/PortingGuide2-3.md
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,10 @@ Other changes:
* When compiling for CUDA, the `complex` type comes from `thrust`
rather than `std`

### `Shear6` in ImathShear.h

* `baseTypeMin()` is replaced with `baseTypeLowest()`

### ImathVecAlgo.h

The following functions are no longer defined for integer-based
Expand Down Expand Up @@ -503,5 +507,27 @@ vectors, because such behavior is not clearly defined:
constructors that take as an argument any data object of similar
size and layout.

## Python Changes:

In general, the changes at the C++ level are reflected in the python
bindings. In particular:

* The following methods are removed for integer-based
vector and matrix objects and arrays:

- `length()`
- `normalize()`
- `normalizeExc()`
- `normalizeNonNull()`
- `normalized()`
- `normalizedExc()`
- `normalizedNonNull()`

* `baseTypeMin()` is replaced with `baseTypeLowest()` for:

- `Vec2`, `Vec3`, `Vec4`
- `Color3`, `Color4`
- `Matrix22`, `Matrix33`, `Matrix44`
- `Box`
- `Shear6`

4 changes: 2 additions & 2 deletions src/Imath/ImathFun.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ succf (float f) noexcept

u.i = 0x00000001;
}
else if (u.i > 0)
else if (u.f > 0)
{
// Positive float, normalized or denormalized.
// Incrementing the largest positive float
Expand Down Expand Up @@ -65,7 +65,7 @@ predf (float f) noexcept

u.i = 0x80000001;
}
else if (u.i > 0)
else if (u.f > 0)
{
// Positive float, normalized or denormalized.

Expand Down
86 changes: 65 additions & 21 deletions src/ImathTest/testFun.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
#endif

#include "ImathFun.h"
#if __cplusplus >= 202002L
# include <bit>
#endif
#include <iostream>
#include <assert.h>
#include <iostream>
#include <stdio.h>
Expand All @@ -18,16 +22,32 @@ using namespace std;
#if ULONG_MAX == 18446744073709551615LU
typedef long unsigned int Int64;
#else
typedef long long unsigned int Int64;
typedef long long unsigned int Int64;
#endif

#if __cplusplus < 202002L
template <typename To, typename From>
static inline To
bit_cast (From from)
{
static_assert (sizeof (From) == sizeof (To), "Type sizes do not match");
union
{
From f;
To t;
} u;
u.f = from;
return u.t;
}
#endif

void
testf (float f)
testf (float f, bool changeExpected = true)
{
printf ("\n");

float sf = IMATH_INTERNAL_NAMESPACE::succf (f);
float pf = IMATH_INTERNAL_NAMESPACE::predf (f);
float sf = IMATH_INTERNAL_NAMESPACE::succf (f);
float pf = IMATH_INTERNAL_NAMESPACE::predf (f);
float spf = IMATH_INTERNAL_NAMESPACE::succf (IMATH_INTERNAL_NAMESPACE::predf (f));
float psf = IMATH_INTERNAL_NAMESPACE::predf (IMATH_INTERNAL_NAMESPACE::succf (f));

Expand All @@ -36,15 +56,29 @@ testf (float f)
printf ("pf %.9g\n", pf);
printf ("spf %.9g\n", spf);
printf ("psf %.9g\n", psf);

fflush (stdout);

if (changeExpected)
{
assert (pf < f);
assert (f < sf);
}
else
{
// No bit change expected if input was inf or NaN
assert (bit_cast<unsigned> (pf) == bit_cast<unsigned> (f));
assert (bit_cast<unsigned> (sf) == bit_cast<unsigned> (f));
}
}

void
testd (double d)
testd (double d, bool changeExpected = true)
{
printf ("\n");

double sd = IMATH_INTERNAL_NAMESPACE::succd (d);
double pd = IMATH_INTERNAL_NAMESPACE::predd (d);
double sd = IMATH_INTERNAL_NAMESPACE::succd (d);
double pd = IMATH_INTERNAL_NAMESPACE::predd (d);
double spd = IMATH_INTERNAL_NAMESPACE::succd (IMATH_INTERNAL_NAMESPACE::predd (d));
double psd = IMATH_INTERNAL_NAMESPACE::predd (IMATH_INTERNAL_NAMESPACE::succd (d));

Expand All @@ -53,6 +87,20 @@ testd (double d)
printf ("pd %.18lg\n", pd);
printf ("spd %.18lg\n", spd);
printf ("psd %.18lg\n", psd);

fflush (stdout);

if (changeExpected)
{
assert (pd < d);
assert (d < sd);
}
else
{
// No bit change expected if input was inf or NaN
assert (bit_cast<Int64> (pd) == bit_cast<Int64> (d));
assert (bit_cast<Int64> (sd) == bit_cast<Int64> (d));
}
}

void
Expand Down Expand Up @@ -196,15 +244,13 @@ testFun()
testf (7);
testf (0.7);

union
{
float f;
int i;
} u;
union {float f; int i;} u;
u.i = 0x7f800000; // inf
testf (u.f);
testf (u.f, false);
u.i = 0xff800000; // -inf
testf (u.f, false);
u.i = 0x7f800001; // nan
testf (u.f);
testf (u.f, false);
u.i = 0x7f7fffff; // FLT_MAX
testf (u.f);
u.i = 0xff7fffff; // -FLT_MAX
Expand All @@ -218,15 +264,13 @@ testFun()
testd (7);
testd (0.7);

union
{
double d;
Int64 i;
} v;
union {double d; Int64 i;} v;
v.i = 0x7ff0000000000000ULL; // inf
testd (v.d);
testd (v.d, false);
v.i = 0xfff0000000000000ULL; // -inf
testd (v.d, false);
v.i = 0x7ff0000000000001ULL; // NAN
testd (v.d);
testd (v.d, false);
v.i = 0x7fefffffffffffffULL; // FLT_MAX
testd (v.d);
v.i = 0xffefffffffffffffULL; // -FLT_MAX
Expand Down
2 changes: 1 addition & 1 deletion src/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ endif()
include(config/PyImathSetup.cmake)

# we have a strong dependence on Imath being an exact match
find_package(Imath ${IMATH_VERSION} EXACT REQUIRED CONFIG)
find_package(Imath ${CMAKE_PROJECT_VERSION} REQUIRED CONFIG)

# we are building a python extension, so of course we depend on
# python as well. Except we don't know which version...
Expand Down

0 comments on commit f2bcae6

Please sign in to comment.