Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync externals and update Python bindings #229

Merged
merged 5 commits into from
May 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions externals/coda-oss/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ target/

modules/drivers/fftw/fftw-2.1.5/
modules/drivers/jpeg/jpeg-9/
modules/drivers/j2k/openjpeg/openjpeg-2.3.0_mod/
modules/drivers/pcre/pcre2-10.22/
modules/drivers/uuid/e2fsprogs-1.40-uuid/
modules/drivers/xml/xerces/xerces-c-3.1.1/
Expand Down
15 changes: 15 additions & 0 deletions externals/coda-oss/build/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -1171,6 +1171,21 @@ def writeConfig(conf, callback, guardTag, infile=None, outfile=None, path=None,

conf.setenv('')


def getDriverIncludes(bld, driver):
driverIncludeDirs = [x.split('=') for x in bld.env['header_builddir']
if x.startswith(driver)]
if not driverIncludeDirs:
bld.fatal('Could not find include dir for driver {}'.format(driver))
if len(driverIncludeDirs) != 1:
bld.fatal('Multiple options for include dir for driver {}'.format(
driver))

driverIncludeDir = driverIncludeDirs[0][1]
driverIncludePathname = os.path.join(bld.bldnode.abspath(),
driverIncludeDir)
return os.path.abspath(os.path.dirname(driverIncludePathname))

def configure(self):

if self.env['DETECTED_BUILD_PY']:
Expand Down
10 changes: 10 additions & 0 deletions externals/coda-oss/modules/c++/math/include/math/Round.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,16 @@ template<typename T> inline T round(T value, size_t fractionalDigits)
return (value > 0.0 ? std::floor(value * power10 + 0.5) / power10
: std::ceil(value * power10 - 0.5) / power10);
}

/*!
* Equivalent to ceil((float)numerator / denominator)
*
* \param numerator Number to divide
* \param denominator Non-zero number to divide by
* \return Result of division, rounded up
* \throw if denominator is 0
*/
size_t ceilingDivide(size_t numerator, size_t denominator);
}

#endif
37 changes: 37 additions & 0 deletions externals/coda-oss/modules/c++/math/source/Round.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/* =========================================================================
* This file is part of math-c++
* =========================================================================
*
* (C) Copyright 2004 - 2018, MDA Information Systems LLC
*
* math-c++ is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; If not,
* see <http://www.gnu.org/licenses/>.
*
*/

#include <except/Exception.h>
#include <math/Round.h>
#include <sys/Conf.h>

namespace math
{
size_t ceilingDivide(size_t numerator, size_t denominator)
{
if (denominator == 0)
{
throw except::Exception(Ctxt("Attempted division by 0"));
}
return (numerator / denominator) + (numerator % denominator != 0);
}
}
20 changes: 20 additions & 0 deletions externals/coda-oss/modules/c++/math/unittests/test_round.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,32 @@ TEST_CASE(testRoundDigits)
double actual8 = math::round(v8, 2);
TEST_ASSERT_ALMOST_EQ(actual8, expected8);
}

TEST_CASE(testCeilingDivide)
{
size_t n0 = 0;
size_t d0 = 1;
TEST_ASSERT_EQ(math::ceilingDivide(n0, d0), 0);

size_t n1 = 4;
size_t d1 = 2;
TEST_ASSERT_EQ(math::ceilingDivide(n1, d1), 2);

size_t n2 = 5;
size_t d2 = 2;
TEST_ASSERT_EQ(math::ceilingDivide(n2, d2), 3);

size_t n3 = 1;
size_t d3 = 0;
TEST_THROWS(math::ceilingDivide(n3, d3));
}
}

int main()
{
TEST_CHECK(testFix);
TEST_CHECK(testRound);
TEST_CHECK(testRoundDigits);
TEST_CHECK(testCeilingDivide);
return 0;
}
7 changes: 3 additions & 4 deletions externals/coda-oss/modules/c++/mt/source/ThreadPlanner.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <algorithm>

#include <math/Round.h>
#include <mt/ThreadPlanner.h>

namespace mt
Expand All @@ -13,8 +14,7 @@ ThreadPlanner::ThreadPlanner(size_t numElements, size_t numThreads) :
// If there are leftovers, add one more to the elements per thread value
// What this will amount to meaning is that early threads will end up with
// one more piece of work than later threads.
mNumElementsPerThread =
(mNumElements / mNumThreads) + (mNumElements % mNumThreads != 0);
mNumElementsPerThread = math::ceilingDivide(mNumElements, mNumThreads);
}

bool ThreadPlanner::getThreadInfo(size_t threadNum,
Expand Down Expand Up @@ -44,8 +44,7 @@ size_t ThreadPlanner::getNumThreadsThatWillBeUsed() const
else
{
const size_t numThreads =
(mNumElements / mNumElementsPerThread) +
(mNumElements % mNumElementsPerThread != 0);
math::ceilingDivide(mNumElements, mNumElementsPerThread);

return numThreads;
}
Expand Down
2 changes: 1 addition & 1 deletion externals/coda-oss/modules/c++/mt/wscript
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
NAME = 'mt'
MAINTAINER = '[email protected]'
VERSION = '1.1'
MODULE_DEPS = 'sys except mem types'
MODULE_DEPS = 'sys except math mem types'

options = configure = distclean = lambda p: None

Expand Down
7 changes: 3 additions & 4 deletions externals/coda-oss/modules/c++/serialize/wscript
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from os.path import join, dirname, abspath
from build import getDriverIncludes

NAME = 'serialize'
MAINTAINER = '[email protected]'
Expand All @@ -8,14 +8,13 @@ USELIB = 'BOOST_SERIALIZATION'

options = configure = distclean = lambda p: None


def build(bld):

# there is no target associated with the boost_config (only its install).
# we add the target directory here manually.
globs = globals()
b = [x.split('=') for x in bld.env['header_builddir'] if x.startswith('boost')][0]
boostInclude = dirname(abspath(join(bld.bldnode.abspath(), b[1])))
boostInclude = bld.root.find_dir(boostInclude).path_from(bld.path)
boostInclude = getDriverIncludes(bld, 'boost')
globs['includes'] = ['include', boostInclude]
globs['export_includes'] = ['include', boostInclude]
bld.module(**globs)
16 changes: 7 additions & 9 deletions externals/coda-oss/modules/drivers/boost/wscript
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import os, sys
import sys
from os.path import join
from waflib import Options
from waflib.TaskGen import feature, before, task_gen
from build import writeConfig, getConfigFilename
from build import writeConfig, getConfigFilename, getDriverIncludes

build = distclean = lambda x: None

Expand Down Expand Up @@ -36,7 +35,7 @@ def configure(conf):
linkType = 's' if staticLink else ''
libType = 'gd' if debug else ''
boostVer = Options.options.boost_version
libName = ['libboost_serialization', msvcVer[1], 'mt',
libName = ['libboost_serialization', msvcVer[1], 'mt',
linkType + libType, boostVer]
libName = '-'.join(filter(lambda x: x is not '', libName))
incPath = boostHome
Expand All @@ -49,7 +48,7 @@ def configure(conf):

# link the serialization library
libSer = conf.check(lib=libName,
uselib_store='BOOST_SERIALIZATION',
uselib_store='BOOST_SERIALIZATION',
header_name='boost/archive/tmpdir.hpp',
function_name='boost::archive::tmpdir',
libpath=libPath, includes=incPath,
Expand All @@ -66,11 +65,10 @@ def configure(conf):
conf.define('HAVE_BOOST', 1 if conf.env['HAVE_BOOST'] else 0)
writeConfig(conf, boost_callback, boost_guard)

def build (bld) :

def build(bld):
# install the boost_config.h file
b = [x.split('=') for x in bld.env['header_builddir'] if x.startswith(boost_guard)][0]
targetPath = bld.root.find_dir(join(bld.bldnode.abspath(), b[1])).path_from(bld.path)
bld(name='boost_config', features='install_tgt',
files=[getConfigFilename(boost_guard)],
dir=bld.path.make_node(targetPath),
dir=bld.path.make_node(getDriverIncludes(bld, boost_guard)),
install_path=join(bld.env['install_includedir'], boost_guard))
31 changes: 31 additions & 0 deletions externals/coda-oss/modules/drivers/j2k/openjpeg/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
The openjpeg-2.3.0_mod.tar file is a slight modification of a release of
OpenJPEG 2.3.0. These changes allow for compressing a single tile within an
image, in order to use multiple threads for compression.

diff -wr openjpeg-2.3.0_mod openjpeg-2.3.0
diff -wr openjpeg-2.3.0_mod/src/lib/openjp2/j2k.c openjpeg-2.3.0/src/lib/openjp2/j2k.c
11352c11352,11353
< p_j2k->m_current_tile_number = p_tile_index;
---
> opj_event_msg(p_manager, EVT_ERROR, "The given tile index does not
> match.");
> return OPJ_FALSE;
11534a11536,11537
> ++p_j2k->m_current_tile_number;
>
diff -wr openjpeg-2.3.0_mod/src/lib/openjp2/openjpeg.c openjpeg-2.3.0/src/lib/openjp2/openjpeg.c
791,798d790
< OPJ_BOOL OPJ_CALLCONV opj_flush(opj_codec_t *p_codec, opj_stream_t *p_stream)
< {
< opj_codec_private_t *l_codec = (opj_codec_private_t *) p_codec;
< opj_stream_private_t *l_stream = (opj_stream_private_t *) p_stream;
<
< return opj_stream_flush(l_stream, &l_codec->m_event_mgr);
< }
<
diff -wr openjpeg-2.3.0_mod/src/lib/openjp2/openjpeg.h openjpeg-2.3.0/src/lib/openjp2/openjpeg.h
1121,1122d1120
< OPJ_API OPJ_BOOL OPJ_CALLCONV opj_flush(opj_codec_t *p_codec, opj_stream_t
*p_stream);
<

Binary file not shown.
Loading