Skip to content
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 setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ def build_extension(self, ext):
'ociocheck=PyOpenColorIO.command_line:main',
'ociochecklut=PyOpenColorIO.command_line:main',
'ocioconvert=PyOpenColorIO.command_line:main',
'ociocpuinfo=PyOpenColorIO.command_line:main',
'ociodisplay=PyOpenColorIO.command_line:main',
'ociolutimage=PyOpenColorIO.command_line:main',
'ociomakeclf=PyOpenColorIO.command_line:main',
Expand Down
26 changes: 20 additions & 6 deletions src/OpenColorIO/CPUInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,18 +183,20 @@ CPUInfo::CPUInfo()
}
}

CPUInfo& CPUInfo::instance()
{
static CPUInfo singleton = CPUInfo();
return singleton;
}
#elif defined(__aarch64__) // ARM Processor or Apple ARM.

CPUInfo::CPUInfo()
{
flags = 0;
memset(name, 0, sizeof(name));
memset(vendor, 0, sizeof(vendor));

snprintf(name, sizeof(name), "%s", "ARM");
#if __APPLE__
snprintf(vendor, sizeof(vendor), "%s", "Apple");
# else
snprintf(vendor, sizeof(vendor), "%s", "ARM");
#endif

// SSE2NEON library supports SSE, SSE2, SSE3, SSSE3, SSE4.1 and SSE4.2.
// It does not support any AVX instructions.
Expand All @@ -208,11 +210,23 @@ CPUInfo::CPUInfo()
}
}

#else

CPUInfo::CPUInfo() // Unknown Processor
{
flags = 0;
memset(name, 0, sizeof(name));
memset(vendor, 0, sizeof(vendor));
snprintf(name, sizeof(name), "%s", "Unknown");
snprintf(vendor, sizeof(vendor), "%s", "Unknown");
}

#endif

CPUInfo& CPUInfo::instance()
{
static CPUInfo singleton = CPUInfo();
return singleton;
}
#endif

} // namespace OCIO_NAMESPACE
43 changes: 0 additions & 43 deletions src/OpenColorIO/CPUInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ namespace OCIO_NAMESPACE
#define x86_check_flags(cpuext) \
(OCIO_USE_ ## cpuext && ((flags) & X86_CPU_FLAG_ ## cpuext))

#if !defined(__aarch64__) && OCIO_ARCH_X86 // Intel-based processor or Apple Rosetta x86_64.

struct CPUInfo
{
unsigned int flags;
Expand Down Expand Up @@ -79,47 +77,6 @@ struct CPUInfo

#undef x86_check_flags

#elif defined(__aarch64__) // ARM Processor or Apple ARM.

#define check_flags(cpuext) \
(OCIO_USE_ ## cpuext && ((flags) & X86_CPU_FLAG_ ## cpuext))

struct CPUInfo
{
unsigned int flags;
char name[65];

CPUInfo();

static CPUInfo& instance();

bool hasSSE2() const { return x86_check_flags(SSE2); }
bool SSE2Slow() const { return false; }

bool hasSSE3() const { return x86_check_flags(SSE3); }
bool SSE3Slow() const { return false; }

bool hasSSSE3() const { return x86_check_flags(SSSE3); }
bool SSSE3Slow() const { return false; }

bool hasSSE4() const { return x86_check_flags(SSE4); }
bool hasSSE42() const { return false; }

// Apple M1 does not support AVX SIMD instructions through Rosetta.
// SSE2NEON library does not supports AVX SIMD instructions.
bool hasAVX() const { return false; }
bool AVXSlow() const { return false; }
bool hasAVX2() const { return false; }
bool AVX2SlowGather() const { return false; }
bool hasAVX512() const { return false; }
bool hasF16C() const { return false; }

};

#undef x86_check_flags

#endif

} // namespace OCIO_NAMESPACE

#endif // CPUInfo_H
1 change: 1 addition & 0 deletions src/apps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ if(OCIO_BUILD_APPS)
add_subdirectory(ociobakelut)
add_subdirectory(ociocheck)
add_subdirectory(ociochecklut)
add_subdirectory(ociocpuinfo)
add_subdirectory(ociomakeclf)
add_subdirectory(ocioperf)
add_subdirectory(ociowrite)
Expand Down
27 changes: 27 additions & 0 deletions src/apps/ociocpuinfo/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright Contributors to the OpenColorIO Project.

set(SOURCES
main.cpp
${PROJECT_SOURCE_DIR}/src/OpenColorIO/CPUInfo.cpp
)

add_executable(ociocpuinfo ${SOURCES})

set_target_properties(ociocpuinfo PROPERTIES
COMPILE_OPTIONS "${PLATFORM_COMPILE_OPTIONS}"
LINK_OPTIONS "${PLATFORM_LINK_OPTIONS}"
)

target_include_directories(ociocpuinfo
PRIVATE
"$<TARGET_PROPERTY:OpenColorIO,INCLUDE_DIRECTORIES>"
"${PROJECT_BINARY_DIR}/generated_include"
)

include(StripUtils)
ocio_strip_binary(ociocpuinfo)

install(TARGETS ociocpuinfo
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
32 changes: 32 additions & 0 deletions src/apps/ociocpuinfo/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// SPDX-License-Identifier: BSD-3-Clause
// Copyright Contributors to the OpenColorIO Project.

#include <iostream>

#include "CPUInfo.h"

namespace OCIO = OCIO_NAMESPACE;

int main()
{
const OCIO::CPUInfo& cpu = OCIO::CPUInfo::instance();

std::cout << "name : " << cpu.getName() << std::endl;
std::cout << "vendor : " << cpu.getVendor() << std::endl;
std::cout << "hasSSE2 : " << cpu.hasSSE2() << std::endl;
std::cout << "SSE2Slow : " << cpu.SSE2Slow() << std::endl;
std::cout << "hasSSE3 : " << cpu.hasSSE3() << std::endl;
std::cout << "SSE3Slow : " << cpu.SSE3Slow() << std::endl;
std::cout << "hasSSSE3 : " << cpu.hasSSSE3() << std::endl;
std::cout << "SSSE3Slow : " << cpu.SSSE3Slow() << std::endl;
std::cout << "hasSSE4 : " << cpu.hasSSE4() << std::endl;
std::cout << "hasSSE42 : " << cpu.hasSSE42() << std::endl;
std::cout << "hasAVX : " << cpu.hasAVX() << std::endl;
std::cout << "AVXSlow : " << cpu.AVXSlow() << std::endl;
std::cout << "hasAVX2 : " << cpu.hasAVX2() << std::endl;
std::cout << "AVX2SlowGather : " << cpu.AVX2SlowGather() << std::endl;
std::cout << "hasAVX512 : " << cpu.hasAVX512() << std::endl;
std::cout << "hasF16C : " << cpu.hasF16C() << std::endl;

return 0;
}