Skip to content

OpenColorIO: Add options for SIMD optimization support #26105

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

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
Changes from 2 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
58 changes: 56 additions & 2 deletions recipes/opencolorio/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,36 @@ class OpenColorIOConan(ConanFile):
options = {
"shared": [True, False],
"fPIC": [True, False],
"use_sse": [True, False],

# OCIO supports a number of optimized code paths using different SIMD instruction sets.
# By default it will determin the support of the current platform. A setting of none keeps
# those defaults, True or False will intentionally set the values.
# OCIO_USE_SSE was an option in older versions (< 2.3.2), newer versions support the following
# instruction sets OCIO_USE_SSE2 up to OCIO_USE_AVX512 (no pure SSE anymore).
"use_sse": ['default', True, False],
"use_sse2": ['default', True, False],
#"use_sse3": ['default', True, False],
"use_ssse3": ['default', True, False],
"use_sse4": ['default', True, False],
"use_sse42": ['default', True, False],
"use_avx": ['default', True, False],
"use_avx2": ['default', True, False],
#"use_avx512": ['default', True, False],
"use_f16c": ['default', True, False],
}
default_options = {
"shared": False,
"fPIC": True,
"use_sse": True,
"use_sse2": 'default',
#"use_sse3": 'default',
"use_ssse3": 'default',
"use_sse4": 'default',
"use_sse42": 'default',
"use_avx": 'default',
"use_avx2": 'default',
#"use_avx512": 'default',
"use_f16c": 'default',
}

def export_sources(self):
Expand Down Expand Up @@ -117,7 +141,37 @@ def generate(self):
tc.variables["TINYXML_OBJECT_LIB_EMBEDDED"] = False
tc.variables["USE_EXTERNAL_LCMS"] = True

tc.variables["OCIO_USE_SSE"] = self.options.get_safe("use_sse", False)
# Selection of SIMD Instruction sets
if not self.options.get_safe("use_sse", 'default') is 'default':
print('Set OCIO_USE_SSE to ', self.options.use_sse)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The print() must be removed before merging. The ways to display information in recipes is via self.output.info/verbose/warning/.., but it seems this wouldn't be necessary, I'd remove the prints.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It sounds like this logic could be done in a for-loop in a more compact way.

tc.variables["OCIO_USE_SSE"] = self.options.use_sse
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if not self.options.get_safe("use_sse2", None) is None:
print('Set OCIO_USE_SSE2 to ', self.options.use_sse2)
tc.variables["OCIO_USE_SSE2"] = self.options.use_sse2
if not self.options.get_safe("use_sse3", None) is None:
print('Set OCIO_USE_SSE3 to ', self.options.use_sse3)
tc.variables["OCIO_USE_SSE3"] = self.options.use_sse3
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get why if not self.options.get_safe("use_sse2", None) is None is executed, where None is set in the default_options, while if not self.options.get_safe("use_sse3", None) is None is skipped, where I don't set the option so it uses the default passed to get_safe. Are this different Nones (ok, here the default is 'default' but I changed it to see if an actual value compares, see tests below where I check for default?

if not self.options.get_safe("use_ssse3", None) is None:
print('Set OCIO_USE_SSSE3 to ', self.options.use_ssse3)
tc.variables["OCIO_USE_SSSE3"] = self.options.use_ssse3
if not self.options.get_safe("use_sse4", None) is None:
print('Set OCIO_USE_SSE4 to ', self.options.use_sse4)
tc.variables["OCIO_USE_SSE4"] = self.options.use_sse4
if not self.options.get_safe("use_sse42", None) is None:
print('Set OCIO_USE_SSE42 to ', self.options.use_sse42)
tc.variables["OCIO_USE_SSE42"] = self.options.use_sse42
if not self.options.get_safe("use_avx", 'default') is 'default':
print('Set OCIO_USE_AVX to ', self.options.use_avx)
tc.variables["OCIO_USE_AVX"] = self.options.use_avx
if not self.options.get_safe("use_avx2", 'default') is 'default':
print('Set OCIO_USE_AVX2 to ', self.options.use_avx2)
tc.variables["OCIO_USE_AVX2"] = self.options.use_avx2
if not self.options.get_safe("use_avx512", 'default') is 'default':
print('Set OCIO_USE_AVX512 to ', self.options.use_avx512)
tc.variables["OCIO_USE_AVX512"] = self.options.use_avx512
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use_avx2 is set to default and the if is still true, while I commented out use_avx512 so it falls back to the default-param of get_safe, which is the same anyway. Don't get an output printed for use_avx512 but for use_avx2, where I'd expect both to not output anything in the default case!

if not self.options.get_safe("use_f16c", 'default') is 'default':
print('Set OCIO_USE_F16C to ', self.options.use_f16c)
tc.variables["OCIO_USE_F16C"] = self.options.use_f16c

# openexr 2.x provides Half library
tc.variables["OCIO_USE_OPENEXR_HALF"] = True
Expand Down