Git Product home page Git Product logo

Comments (4)

JoshBlake avatar JoshBlake commented on May 18, 2024

Collaborating with @gordonmcshane, found an improvement to simdpp_multiarch() that avoids the need for a work-around. Will PR soon.

from libsimdpp.

p12tic avatar p12tic commented on May 18, 2024

@JoshBlake Does your fix involve add_custom_command and IMPLICIT_DEPENDS by chance?

from libsimdpp.

gordonmcshane avatar gordonmcshane commented on May 18, 2024

@p12tic our fix was a bit more brute force.

In SimdppMultiarch.cmake, we just add the current source path to the current directory's INCLUDE_DIRECTORIES property via include_directories(). This works because INCLUDE_DIRECTORIES is inherited by subdirectories, and the generated code is placed in a child directory of the current source directory.

    # add current path to include paths so generated simd variations are
    # able to reference the same includes found in base version
    include_directories("${CMAKE_CURRENT_SOURCE_DIR}/${SRC_PATH}")

    foreach(ARCH ${ARCHS})
        simdpp_get_arch_info(CXX_FLAGS DEFINES_LIST SUFFIX ${ARCH})

        if(NOT "${SUFFIX}" STREQUAL "")
            # Copy the source file and add the required flags
            set(DST_ABS_FILE "${CMAKE_CURRENT_BINARY_DIR}/${SRC_PATH}/${SRC_NAME}_simdpp_${SUFFIX}${SRC_EXT}")
            set(SRC_ABS_FILE "${CMAKE_CURRENT_SOURCE_DIR}/${SRC_FILE}")
            configure_file("${SRC_ABS_FILE}" "${DST_ABS_FILE}" COPYONLY)
            list(APPEND FILE_LIST "${DST_ABS_FILE}")

            # let CMake know that this file is created at build time
            set_source_files_properties("${DST_ABS_FILE}" PROPERTIES GENERATED TRUE)

            if (NOT "${CXX_FLAGS}" STREQUAL "")
              set_source_files_properties("${DST_ABS_FILE}" PROPERTIES COMPILE_FLAGS ${CXX_FLAGS})
            endif()

            # For the first file that is being processed, set it to emit
            # dispatcher code. The required flags will be added later
            if("${DISPATCHER_FILE}" STREQUAL "")
                set(DISPATCHER_FILE "${DST_ABS_FILE}")
            endif()

            # Add required dispatcher predefined macros for this architecture
            set(DISPATCHER_CXX_FLAGS "${DISPATCHER_CXX_FLAGS} -DSIMDPP_DISPATCH_ARCH${DISPATCH_ARCH_IDX}=${DEFINES_LIST}")
            math(EXPR DISPATCH_ARCH_IDX "${DISPATCH_ARCH_IDX}+1")
        endif()
    endforeach()

Beyond the include_directories() statement, the only other changes are the setting of GENERATED to TRUE on DST_ABS_FILE in the foreach() and the removal of the explicit -I arguments to CXX_FLAGS

from libsimdpp.

p12tic avatar p12tic commented on May 18, 2024

This could lead to issues, because include_directories() does not modify the include directories of source files. It sets the include directory for all targets defined in the current CMakeLists file and in CMakeLists files in children directories. These targets would end up with lots of extra include paths, which could cause problems if headers with same names are present.

I've committed the add_custom_command and IMPLICIT_DEPENDS fix at db8f68b. Thanks for all the help.

from libsimdpp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.