ermig1979 / Simd

C++ image processing and machine learning library with using of SIMD: SSE, AVX, AVX-512, AMX for x86/x64, VMX(Altivec) and VSX(Power7) for PowerPC, NEON for ARM.
http://ermig1979.github.io/Simd
MIT License
2.01k stars 407 forks source link

SimdBaseUyvyToBgr.cpp compile error VS 2022 #252

Closed jay3d closed 5 months ago

jay3d commented 1 year ago

Compiling this file getting those errors:

Simd/SimdYuvToBgr.h(383): error C3861: 'Load': identifier not found
Simd/SimdYuvToBgr.h(383): error C2065: 'Load': undeclared identifier
Simd/SimdYuvToBgr.h(392): error C3861: 'Load': identifier not found
Simd/SimdYuvToBgr.h(392): error C2065: 'Load': undeclared identifier
Simd/SimdYuvToBgr.h(550): error C3861: 'Load': identifier not found
Simd/SimdYuvToBgr.h(550): error C2065: 'Load': undeclared identifier
Simd/SimdYuvToBgr.h(557): error C3861: 'Load': identifier not found
Simd/SimdYuvToBgr.h(557): error C2065: 'Load': undeclared identifier
ermig1979 commented 1 year ago

Hi! I can't reproduce this error. Any way I hope that fixed it in place where it can happen.

jay3d commented 1 year ago

I'm doing a much simpler internal cmake compile instructions because the project cmake file doesn't support Ninja generator with VS

    add_compile_definitions(
            SIMD_VERSION="unknown"
            SIMD_AVX512BW_DISABLE
            SIMD_AVX512VNNI_DISABLE
            SIMD_AVX512BF16_DISABLE
            SIMD_AMXBF16_DISABLE
            SIMD_INT8_DEBUG_DISABLE
    )

    file(GLOB_RECURSE SIMD_BASE_SRC ${Simd_SOURCE_DIR}/src/Simd/SimdBase*.cpp)

    if (WIN32)
        file(GLOB_RECURSE SIMD_SSE41_SRC ${Simd_SOURCE_DIR}/src/Simd/SimdSse41*.cpp)
        file(GLOB_RECURSE SIMD_AVX1_SRC ${Simd_SOURCE_DIR}/src/Simd/SimdAvx1*.cpp)
        file(GLOB_RECURSE SIMD_AVX2_SRC ${Simd_SOURCE_DIR}/src/Simd/SimdAvx2*.cpp)
        set(SIMD_ALG_SRC ${SIMD_BASE_SRC} ${SIMD_SSE41_SRC} ${SIMD_AVX1_SRC} ${SIMD_AVX2_SRC})
    elseif (APPLE)
        file(GLOB_RECURSE SIMD_NEON_SRC ${Simd_SOURCE_DIR}/src/Simd/SimdNeon*.cpp)
        set(SIMD_ALG_SRC ${SIMD_BASE_SRC} ${SIMD_NEON_SRC})
    endif ()

    file(GLOB_RECURSE SIMD_LIB_SRC ${Simd_SOURCE_DIR}/src/Simd/SimdLib.cpp)

    add_library(Simd STATIC ${SIMD_LIB_SRC} ${SIMD_ALG_SRC})

    target_include_directories(Simd PRIVATE ${Simd_SOURCE_DIR}/src)

Anything I'm missing here?

Also I can't just use the solution file in my project.

ermig1979 commented 1 year ago

Do you add compiler specific CPU extensions options to corresponding sources?

jay3d commented 1 year ago

I have added those:

        add_compile_options(
                /arch:AVX
                /arch:AVX2
        )

But still same error

Strange everything compiles file except this

ermig1979 commented 1 year ago

Do you set /arch:AVX only for SIMD_AVX1_SRC and /arch:AVX2 only for SIMD_AVX2_SRC ?

jay3d commented 1 year ago
        file(GLOB_RECURSE SIMD_SSE41_SRC ${Simd_SOURCE_DIR}/src/Simd/SimdSse41*.cpp)
        file(GLOB_RECURSE SIMD_AVX1_SRC ${Simd_SOURCE_DIR}/src/Simd/SimdAvx1*.cpp)
        file(GLOB_RECURSE SIMD_AVX2_SRC ${Simd_SOURCE_DIR}/src/Simd/SimdAvx2*.cpp)
        set_source_files_properties(${SIMD_AVX1_SRC} PROPERTIES COMPILE_OPTIONS "/arch:AVX")
        set_source_files_properties(${SIMD_AVX2_SRC} PROPERTIES COMPILE_OPTIONS "/arch:AVX2")
        set(SIMD_ALG_SRC ${SIMD_BASE_SRC} ${SIMD_SSE41_SRC} ${SIMD_AVX1_SRC} ${SIMD_AVX2_SRC})

Same error

jay3d commented 1 year ago

Ok you have a missing include:

#include "Simd/SimdInit.h"
#include "Simd/SimdSet.h"
#include "Simd/SimdMath.h"
#include "Simd/SimdUnpack.h"
#include "Simd/SimdLog.h"
#include "Simd/SimdLoad.h" // <-- It was missing

Sometimes VS IDE is permissive where it should not be, this would make portability a problem, so using a different IDE will have issues like that. Adding the above include solves the problem.

Ah I see this is fixed in the master, or you just fixed it?! Thanks!!