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

OpenColorIO: Add options for SIMD optimization support #26105

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
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
65 changes: 60 additions & 5 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": [None, True, False],
"use_sse2": [None, True, False],
"use_sse3": [None, True, False],
"use_ssse3": [None, True, False],
"use_sse4": [None, True, False],
"use_sse42": [None, True, False],
"use_avx": [None, True, False],
"use_avx2": [None, True, False],
"use_avx512": [None, True, False],
"use_f16c": [None, True, False],
}
default_options = {
"shared": False,
"fPIC": True,
"use_sse": True,
"use_sse": None,
"use_sse2": None,
"use_sse3": None,
"use_ssse3": None,
"use_sse4": None,
"use_sse42": None,
"use_avx": None,
"use_avx2": None,
"use_avx512": None,
"use_f16c": None,
}

def export_sources(self):
Expand All @@ -36,8 +60,9 @@ def export_sources(self):
def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC
if self.settings.arch not in ["x86", "x86_64"]:
del self.options.use_sse
# Reproduce the previous default which was injected instead of letting it be determined
if self.options.get_safe("use_sse", None) == None:
self.options.use_sse = self.settings.arch in ["x86", "x86_64"]

def configure(self):
if self.options.shared:
Expand Down Expand Up @@ -117,7 +142,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", None) == None:
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) == 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) == None:
print('Set OCIO_USE_SSE3 to ', self.options.use_sse3)
tc.variables["OCIO_USE_SSE3"] = self.options.use_sse3
if not self.options.get_safe("use_ssse3", None) == 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) == 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) == 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", None) == None:
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", None) == None:
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", None) == None:
print('Set OCIO_USE_AVX512 to ', self.options.use_avx512)
tc.variables["OCIO_USE_AVX512"] = self.options.use_avx512
if not self.options.get_safe("use_f16c", None) == None:
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