Skip to content
This repository has been archived by the owner on Jan 26, 2022. It is now read-only.

Commit

Permalink
Merge pull request #24 from timocafe/inequality
Browse files Browse the repository at this point in the history
boundary range
  • Loading branch information
sharkovsky committed Feb 12, 2016
2 parents 456a7a5 + daa058d commit f8c3708
Show file tree
Hide file tree
Showing 18 changed files with 1,367 additions and 301 deletions.
49 changes: 18 additions & 31 deletions CMake/GitExternal.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@
# when only a specific branch of a repo is required and the full history
# is not required. Note that the SHALLOW option will only work for a branch
# or tag and cannot be used for an arbitrary SHA.
# OPTIONAL, when present, this option makes this operation optional.
# The function will output a warning and return if the repo could not be
# cloned.
#
# Targets:
# * <directory>-rebase: fetches latest updates and rebases the given external
Expand Down Expand Up @@ -77,7 +74,7 @@ function(JOIN VALUES GLUE OUTPUT)
endfunction()

function(GIT_EXTERNAL DIR REPO tag)
cmake_parse_arguments(GIT_EXTERNAL_LOCAL "VERBOSE;SHALLOW;OPTIONAL" "" "RESET" ${ARGN})
cmake_parse_arguments(GIT_EXTERNAL_LOCAL "VERBOSE;SHALLOW" "" "RESET" ${ARGN})
set(TAG ${tag})
if(GIT_EXTERNAL_TAG AND "${tag}" MATCHES "^[0-9a-f]+$")
set(TAG ${GIT_EXTERNAL_TAG})
Expand Down Expand Up @@ -118,12 +115,7 @@ function(GIT_EXTERNAL DIR REPO tag)
RESULT_VARIABLE nok ERROR_VARIABLE error
WORKING_DIRECTORY "${GIT_EXTERNAL_DIR}")
if(nok)
if(GIT_EXTERNAL_LOCAL_OPTIONAL)
message(STATUS "${DIR} clone failed: ${error}\n")
return()
else()
message(FATAL_ERROR "${DIR} clone failed: ${error}\n")
endif()
message(FATAL_ERROR "${DIR} clone failed: ${error}\n")
endif()

# checkout requested tag
Expand Down Expand Up @@ -273,29 +265,26 @@ if(EXISTS ${GIT_EXTERNALS} AND NOT GIT_EXTERNAL_SCRIPT_MODE)
# Create a unique, flat name
string(REPLACE "/" "-" GIT_EXTERNAL_NAME ${DIR}_${PROJECT_NAME})

if(NOT TARGET update-gitexternal-${GIT_EXTERNAL_NAME}) # not done
if(NOT TARGET update_git_external_${GIT_EXTERNAL_NAME}) # not done
# pull in identified external
git_external(${DIR} ${REPO} ${TAG})

# Create update script and target to bump external spec
if(NOT TARGET update)
add_custom_target(update)
endif()
if(NOT TARGET update-gitexternal)
add_custom_target(update-gitexternal)
add_custom_target(flatten-gitexternal)
add_dependencies(update update-gitexternal)
endif()
if(NOT TARGET ${PROJECT_NAME}-flatten-gitexternal)
add_custom_target(${PROJECT_NAME}-flatten-gitexternal)
if(NOT TARGET update_git_external)
add_custom_target(update_git_external)
add_custom_target(flatten_git_external)
add_dependencies(update update_git_external)
endif()

# Create a unique, flat name
file(RELATIVE_PATH GIT_EXTERNALS_BASE ${CMAKE_SOURCE_DIR}
${GIT_EXTERNALS})
string(REPLACE "/" "_" GIT_EXTERNAL_TARGET ${GIT_EXTERNALS_BASE})

set(GIT_EXTERNAL_TARGET update-gitexternal-${GIT_EXTERNAL_TARGET})
set(GIT_EXTERNAL_TARGET update_git_external_${GIT_EXTERNAL_TARGET})
if(NOT TARGET ${GIT_EXTERNAL_TARGET})
set(GIT_EXTERNAL_SCRIPT
"${CMAKE_CURRENT_BINARY_DIR}/${GIT_EXTERNAL_TARGET}.cmake")
Expand All @@ -312,46 +301,44 @@ if(EXISTS ${GIT_EXTERNALS} AND NOT GIT_EXTERNAL_SCRIPT_MODE)
file(WRITE "${GIT_EXTERNAL_SCRIPT}" "
include(\"${CMAKE_CURRENT_LIST_DIR}/GitExternal.cmake\")
execute_process(COMMAND \"${GIT_EXECUTABLE}\" fetch origin -q
WORKING_DIRECTORY \"${CMAKE_SOURCE_DIR}/${DIR}\")
WORKING_DIRECTORY \"${DIR}\")
execute_process(
COMMAND \"${GIT_EXECUTABLE}\" show-ref --hash=7 refs/remotes/origin/master
OUTPUT_VARIABLE newref OUTPUT_STRIP_TRAILING_WHITESPACE
WORKING_DIRECTORY \"${CMAKE_SOURCE_DIR}/${DIR}\")
WORKING_DIRECTORY \"${DIR}\")
if(newref)
file(APPEND ${GIT_EXTERNALS} \"# ${DIR} ${REPO} \${newref}\\n\")
git_external(${DIR} ${REPO} \${newref})
else()
file(APPEND ${GIT_EXTERNALS} \"# ${DIR} ${REPO} ${TAG}\n\")
endif()")
add_custom_target(update-gitexternal-${GIT_EXTERNAL_NAME}
add_custom_target(update_git_external_${GIT_EXTERNAL_NAME}
COMMAND "${CMAKE_COMMAND}" -DGIT_EXTERNAL_SCRIPT_MODE=1 -P ${GIT_EXTERNAL_SCRIPT}
COMMENT "Update ${REPO} in ${GIT_EXTERNALS_BASE}"
DEPENDS ${GIT_EXTERNAL_TARGET}
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")
add_dependencies(update-gitexternal
update-gitexternal-${GIT_EXTERNAL_NAME})
add_dependencies(update_git_external
update_git_external_${GIT_EXTERNAL_NAME})

# Flattens a git external repository into its parent repo:
# * Clean any changes from external
# * Unlink external from git: Remove external/.git and .gitexternals
# * Add external directory to parent
# * Commit with flattened repo and tag info
# - Depend on release branch checked out
add_custom_target(flatten-gitexternal-${GIT_EXTERNAL_NAME}
add_custom_target(flatten_git_external_${GIT_EXTERNAL_NAME}
COMMAND "${GIT_EXECUTABLE}" clean -dfx
COMMAND "${CMAKE_COMMAND}" -E remove_directory .git
COMMAND "${CMAKE_COMMAND}" -E remove -f "${CMAKE_CURRENT_SOURCE_DIR}/.gitexternals"
COMMAND "${GIT_EXECUTABLE}" add -f .
COMMAND "${GIT_EXECUTABLE}" commit -m "Flatten ${REPO} into ${DIR} at ${TAG}" . "${CMAKE_CURRENT_SOURCE_DIR}/.gitexternals"
COMMENT "Flatten ${REPO} into ${DIR}"
DEPENDS ${PROJECT_NAME}-make-branch
DEPENDS make_branch_${PROJECT_NAME}
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${DIR}")
add_dependencies(flatten-gitexternal
flatten-gitexternal-${GIT_EXTERNAL_NAME})
add_dependencies(${PROJECT_NAME}-flatten-gitexternal
flatten-gitexternal-${GIT_EXTERNAL_NAME})
add_dependencies(flatten_git_external
flatten_git_external_${GIT_EXTERNAL_NAME})

foreach(_target flatten-gitexternal-${GIT_EXTERNAL_NAME} ${PROJECT_NAME}-flatten-gitexternal flatten-gitexternal update-gitexternal-${GIT_EXTERNAL_NAME} ${GIT_EXTERNAL_TARGET} update-gitexternal update)
foreach(_target flatten_git_external_${GIT_EXTERNAL_NAME} flatten_git_external update_git_external_${GIT_EXTERNAL_NAME} ${GIT_EXTERNAL_TARGET} update_git_external update)
set_target_properties(${_target} PROPERTIES
EXCLUDE_FROM_DEFAULT_BUILD ON FOLDER git)
endforeach()
Expand Down
69 changes: 60 additions & 9 deletions cyme/core/expression/expr_vec.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,10 @@ namespace cyme{
}
};

/** and vertex in the DAG from a && b integer only, it look likes weird
/** and vertex in the DAG from a & b, it look likes weird
*
*/
template<class T, class T2, cyme::simd O, int N, class OP1, class OP2>
template<class T, cyme::simd O, int N, class OP1, class OP2>
class vec_and{
typename vec_traits<OP1,O,N>::value_type op1;
typename vec_traits<OP2,O,N>::value_type op2;
Expand All @@ -249,11 +249,31 @@ namespace cyme{
}

/* always return int */
forceinline vec_simd<int,O,N> operator()() const{
return op1() && op2();
forceinline vec_simd<T,O,N> operator()() const{
return op1() & op2();
}
};


/** and vertex in the DAG from a | b, it look likes weird
*
*/
template<class T, cyme::simd O, int N, class OP1, class OP2>
class vec_or{
typename vec_traits<OP1,O,N>::value_type op1;
typename vec_traits<OP2,O,N>::value_type op2;

public:
forceinline vec_or(OP1 const& a, OP2 const& b):op1(a), op2(b){
}

/* always return int */
forceinline vec_simd<T,O,N> operator()() const{
return op1() | op2();
}
};


/** less than vertex in the DAG from a < b
/note the inequality in SIMD are like usual operation it return a register 0 false -1 true
*/
Expand All @@ -266,11 +286,46 @@ namespace cyme{
forceinline vec_lt(OP1 const& a, OP2 const& b):op1(a), op2(b){
}
/* always return int */
forceinline vec_simd<int,O,N> operator()() const{
forceinline vec_simd<T,O,N> operator()() const{
return op1() < op2();
}
};

/** less than vertex in the DAG from a < b
/note the inequality in SIMD are like usual operation it return a register 0 false -1 true
*/
template<class T, cyme::simd O, int N, class OP1, class OP2>
class vec_gt{
typename vec_traits<OP1,O,N>::value_type op1;
typename vec_traits<OP2,O,N>::value_type op2;

public:
forceinline vec_gt(OP1 const& a, OP2 const& b):op1(a), op2(b){
}
/* always return int */
forceinline vec_simd<T,O,N> operator()() const{
return op1() > op2();
}
};

/** less than vertex in the DAG from a < b
/note the inequality in SIMD are like usual operation it return a register 0 false -1 true
*/
template<class T, cyme::simd O, int N, class OP1, class OP2>
class vec_eq{
typename vec_traits<OP1,O,N>::value_type op1;
typename vec_traits<OP2,O,N>::value_type op2;

public:
forceinline vec_eq(OP1 const& a, OP2 const& b):op1(a), op2(b){
}
/* always return int */
forceinline vec_simd<T,O,N> operator()() const{
return op1() == op2();
}
};


/** add vertex in the DAG from a+b */
template<class T, cyme::simd O, int N, class OP1, class OP2>
class vec_add{
Expand Down Expand Up @@ -305,10 +360,6 @@ namespace cyme{
Contrary to other class it is a structure, I did an optimization in case
I get multiple negate e.g. -(-(a)) the vertex is transformed to a.
<<<<<<< HEAD
=======
>>>>>>> cymepoly
For this I need to get the original operator (op1)
*/
template<class T, cyme::simd O, int N, class OP1>
Expand Down
61 changes: 48 additions & 13 deletions cyme/core/expression/expr_vec_ops.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -197,34 +197,69 @@ namespace cyme{
}

/**
* bitwise logic operator and, a && b
* the node a and b can not be necessarely of the same type (mandelbroat example)
* where we have: [ |z| < 4. && n < 255 ], z is a vec instantiated with double whereas
* n is instantiated with int
* bitwise logic operator and, a & b
*/
template<class T1, class T2, cyme::simd O, int N, class R1, class R2>
vec<int,O, N,vec_and<T1,T2,O,N,R1,R2> >
forceinline operator &&(vec<T1,O,N,R1> const& a, vec<T2,O,N,R2> const& b){
return vec<int,O,N,vec_and<T1,T2,O,N,R1,R2> >(vec_and<T1,T2,O,N,R1,R2>(a.rep(),b.rep()));
template<class T, cyme::simd O, int N, class R1, class R2>
forceinline vec<T,O,N,vec_and<T,O,N,R1,R2> >
operator &(vec<T,O,N,R1> const& a, vec<T,O,N,R2> const& b){
return vec<T,O,N,vec_and<T,O,N,R1,R2> >(vec_and<T,O,N,R1,R2>(a.rep(),b.rep()));
}

/**
* less than operator a < b
*/
template<class T, cyme::simd O, int N, class R1, class R2>
forceinline vec<int,O, N,vec_lt<T,O,N,R1,R2> >
forceinline vec<T,O, N,vec_lt<T,O,N,R1,R2> >
operator <(vec<T,O,N,R1> const& a, vec<T,O,N,R2> const& b){
return vec<int,O,N,vec_lt<T,O,N,R1,R2> >(vec_lt<T,O,N,R1,R2>(a.rep(),b.rep()));
return vec<T,O,N,vec_lt<T,O,N,R1,R2> >(vec_lt<T,O,N,R1,R2>(a.rep(),b.rep()));
}

/**
* less than operator a < s where b is a scalar
*/
template<class T, cyme::simd O, int N, class R1>
forceinline vec<int,O,N, vec_lt<T,O,N,R1,vec_scalar<T,O,N> > >
forceinline vec<T,O,N, vec_lt<T,O,N,R1,vec_scalar<T,O,N> > >
operator <(vec<T,O,N,R1> const& a, typename identity<T>::value_type const& s){
return vec<T,O,N,vec_lt<T,O,N,R1,vec_scalar<T,O,N> > >
(vec_lt<T,O,N,R1,vec_scalar<T,O,N> >(a.rep(),vec_scalar<T,O,N>(static_cast<T>(s))));
}

/**
* less than operator a > b
*/
template<class T, cyme::simd O, int N, class R1, class R2>
forceinline vec<T,O, N,vec_gt<T,O,N,R1,R2> >
operator >(vec<T,O,N,R1> const& a, vec<T,O,N,R2> const& b){
return vec<T,O,N,vec_gt<T,O,N,R1,R2> >(vec_gt<T,O,N,R1,R2>(a.rep(),b.rep()));
}

/**
* less than operator a > s where b is a scalar
*/
template<class T, cyme::simd O, int N, class R1>
forceinline vec<T,O,N, vec_gt<T,O,N,R1,vec_scalar<T,O,N> > >
operator >(vec<T,O,N,R1> const& a, typename identity<T>::value_type const& s){
return vec<T,O,N,vec_gt<T,O,N,R1,vec_scalar<T,O,N> > >
(vec_gt<T,O,N,R1,vec_scalar<T,O,N> >(a.rep(),vec_scalar<T,O,N>(static_cast<T>(s))));
}

/**
* less than operator a == b
*/
template<class T, cyme::simd O, int N, class R1, class R2>
forceinline vec<T,O, N,vec_eq<T,O,N,R1,R2> >
operator ==(vec<T,O,N,R1> const& a, vec<T,O,N,R2> const& b){
return vec<T,O,N,vec_eq<T,O,N,R1,R2> >(vec_eq<T,O,N,R1,R2>(a.rep(),b.rep()));
}

/**
* less than operator a == s where b is a scalar
*/
template<class T, cyme::simd O, int N, class R1>
forceinline vec<T,O,N, vec_eq<T,O,N,R1,vec_scalar<T,O,N> > >
operator <(vec<T,O,N,R1> const& a, typename identity<T>::value_type const& s){
return vec<int,O,N,vec_lt<T,O,N,R1,vec_scalar<T,O,N> > >
(vec_lt<int,O,N,R1,vec_scalar<T,O,N> >(a.rep(),vec_scalar<T,O,N>(static_cast<T>(s))));
return vec<T,O,N,vec_eq<T,O,N,R1,vec_scalar<T,O,N> > >
(vec_eq<T,O,N,R1,vec_scalar<T,O,N> >(a.rep(),vec_scalar<T,O,N>(static_cast<T>(s))));
}

/**
Expand Down
Loading

0 comments on commit f8c3708

Please sign in to comment.