From: dbp Date: Fri, 1 Nov 2013 10:09:58 +0000 (+0400) Subject: 0024153: Adding OpenCL to OCCT prerequisites X-Git-Tag: V6_7_1~24 X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=04bcd478fca99a177e8331578b8ac0620a04913e;p=occt-wok.git 0024153: Adding OpenCL to OCCT prerequisites OpenCL checking in configuring process fixed -OpenCL is included into CSF_OPENCL_LIB taking into account word register --- diff --git a/src/WOKBuilderDef/CSF.edl b/src/WOKBuilderDef/CSF.edl index 53bc894..c1bef3c 100755 --- a/src/WOKBuilderDef/CSF.edl +++ b/src/WOKBuilderDef/CSF.edl @@ -107,6 +107,8 @@ @set %CSF_GL2PS = ""; @set %CSF_TBB_INCLUDES = ""; @set %CSF_TBB = ""; + @set %CSF_OPENCL_INCLUDES = ""; + @set %CSF_OPENCL = ""; @set %CSF_QT_INCLUDES = ""; @set %CSF_QT = ""; @@ -140,6 +142,7 @@ @set %ENV_HAVE_FREEIMAGE = "${HAVE_FREEIMAGE}"; @set %ENV_HAVE_GL2PS = "${HAVE_GL2PS}"; @set %ENV_HAVE_TBB = "${HAVE_TBB}"; + @set %ENV_HAVE_OPENCL = "${HAVE_OPENCL}"; @set %CSF_PRODUCTS_DEFINES = ""; @if (%ENV_HAVE_FREEIMAGE == "true") then @string %CSF_PRODUCTS_DEFINES = %CSF_PRODUCTS_DEFINES " -DHAVE_FREEIMAGE"; @@ -159,6 +162,16 @@ @set %CSF_TBB = "-ltbb -ltbbmalloc "; @endif; @endif; + @if (%ENV_HAVE_OPENCL == "true") then + @string %CSF_PRODUCTS_DEFINES = %CSF_PRODUCTS_DEFINES " -DHAVE_OPENCL"; + @if (%Station == "mac") then + @set %CSF_OPENCL = "-framework OpenCL "; + @else + @if (%Station != "wnt") then + @set %CSF_OPENCL = "-lOpenCL "; + @endif; + @endif; + @endif; -- On UNIX systems default configuration file 'config.h' -- placed in ${WOKHOME}/lib folder. diff --git a/src/WOKTclLib/osutils.tcl b/src/WOKTclLib/osutils.tcl index 2a63734..0ff9c37 100755 --- a/src/WOKTclLib/osutils.tcl +++ b/src/WOKTclLib/osutils.tcl @@ -1890,6 +1890,9 @@ proc osutils:csfList { theOS theCsfMap } { #-- GL2PS set aCsfMap(CSF_GL2PS) "gl2ps" + + #-- OpenCL + set aCsfMap(CSF_OPENCL) "OpenCL" } } diff --git a/src/WOKTclLib/templates/custom.sh.in b/src/WOKTclLib/templates/custom.sh.in index 01a87b8..91cd4a7 100644 --- a/src/WOKTclLib/templates/custom.sh.in +++ b/src/WOKTclLib/templates/custom.sh.in @@ -8,6 +8,7 @@ export HAVE_TCLTK=@HAVE_TCLTK@ export HAVE_FREEIMAGE=@HAVE_FREEIMAGE@ export HAVE_GL2PS=@HAVE_GL2PS@ export HAVE_TBB=@HAVE_TBB@ +export HAVE_OPENCL=@HAVE_OPENCL@ export HAVE_QT=@HAVE_QT@ # export CSF_OPT_INC="@CSF_OPT_INC@" diff --git a/src/WOKTclLib/templates/env.bat b/src/WOKTclLib/templates/env.bat index 77c4b1f..141dc91 100644 --- a/src/WOKTclLib/templates/env.bat +++ b/src/WOKTclLib/templates/env.bat @@ -19,8 +19,10 @@ set "VCVER=vc8" set "ARCH=32" set "VCVARS=" set "HAVE_TBB=false" +set "HAVE_OPENCL=false" set "HAVE_FREEIMAGE=false" set "HAVE_GL2PS=false" +set "HAVE_OPENCL=false" set "CSF_OPT_INC=" set "CSF_OPT_LIB32=" set "CSF_OPT_LIB64=" @@ -54,9 +56,11 @@ rem ----- Optional 3rd-parties should be enabled by HAVE macros ----- set "CSF_OPT_CMPL=" set "PRODUCTS_DEFINES=" if ["%HAVE_TBB%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_TBB" +if ["%HAVE_OPENCL%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_OPENCL" if ["%HAVE_GL2PS%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_GL2PS" if ["%HAVE_FREEIMAGE%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_FREEIMAGE" if ["%HAVE_TBB%"] == ["true"] set "CSF_DEFINES=HAVE_TBB;%CSF_DEFINES%" +if ["%HAVE_OPENCL%"] == ["true"] set "CSF_DEFINES=HAVE_OPENCL;%CSF_DEFINES%" if ["%HAVE_GL2PS%"] == ["true"] set "CSF_DEFINES=HAVE_GL2PS;%CSF_DEFINES%" if ["%HAVE_FREEIMAGE%"] == ["true"] set "CSF_DEFINES=HAVE_FREEIMAGE;%CSF_DEFINES%" diff --git a/src/WOKTclLib/templates/env.sh b/src/WOKTclLib/templates/env.sh index 3a28c45..7f6613c 100755 --- a/src/WOKTclLib/templates/env.sh +++ b/src/WOKTclLib/templates/env.sh @@ -15,6 +15,7 @@ fi # Reset values export CASDEB="" export HAVE_TBB="false"; +export HAVE_OPENCL="false"; export HAVE_FREEIMAGE="false"; export HAVE_GL2PS="false"; export MACOSX_USE_GLX="false"; @@ -83,6 +84,9 @@ export CSF_OPT_CMPL="" if [ "$HAVE_TBB" == "true" ]; then export CSF_OPT_CMPL="${CSF_OPT_CMPL} -DHAVE_TBB" fi +if [ "$HAVE_OPENCL" == "true" ]; then + export CSF_OPT_CMPL="${CSF_OPT_CMPL} -DHAVE_OPENCL" +fi if [ "$HAVE_FREEIMAGE" == "true" ]; then export CSF_OPT_CMPL="${CSF_OPT_CMPL} -DHAVE_FREEIMAGE" fi diff --git a/src/WOKTclLib/templates/template.ac b/src/WOKTclLib/templates/template.ac index c1501bd..9ede343 100644 --- a/src/WOKTclLib/templates/template.ac +++ b/src/WOKTclLib/templates/template.ac @@ -730,6 +730,41 @@ else fi fi +#--------------------------------------------------------------------- +# +# Check for OpenCL SDK Includes +# +# +#--------------------------------------------------------------------- +AC_ARG_WITH([opencl-include], + [AC_HELP_STRING([--with-opencl-include=DIR],[Location of OpenCL SDK includes])], + [opencl_inc="${withval}"],[opencl_inc=]) + +if test "xno" = "xno$opencl_inc"; then + # user specified --without-opencl-lib + HAVE_OPENCL=no + HAVE_OPENCL_INC=no + DISABLE_OPENCL_REASON_INC="(--with-opencl-include=DIR option was not defined)" +else + CSF_OPENCL_INCLUDES="" + AC_LANG([C++]) + HAVE_OPENCL_INC=yes + if test ! -d $opencl_inc; then + DISABLE_OPENCL_REASON_INC="($opencl_inc directory is not exists)" + AC_MSG_ERROR([$opencl_inc directory is not exists]) + elif test "x$opencl_inc" != "x"; then + CPPFLAGS="-I$opencl_inc $CPPFLAGS"; + else + AC_MSG_NOTICE("--with-opencl-include key is not defined") + fi + # TODO: Add MacOS X specific header check + AC_CHECK_HEADER( [CL/cl.h], [], [HAVE_OPENCL_INC=no] ) + if test "x$HAVE_OPENCL_INC" != "xyes"; then + AC_MSG_NOTICE("Specify --with-opencl-include to enable OpenCL support") + DISABLE_OPENCL_REASON_INC="(OpenCL includes were not found)" + fi +fi + #--------------------------------------------------------------------- # # Check for TBB Libraries @@ -789,6 +824,62 @@ fi AM_CONDITIONAL( HAVE_TBB, [test "xyes" = "x$HAVE_TBB"] ) +#--------------------------------------------------------------------- +# +# Check for OpenCL SDK Libraries +# +# +#--------------------------------------------------------------------- +AC_ARG_WITH([opencl-library], + [AC_HELP_STRING([--with-opencl-library=DIR],[Location of OpenCL SDK libraries])], + [opencl_lib="${withval}"],[opencl_lib=]) + +if test "xno" = "xno$opencl_lib"; then + # user specified --without-opencl + HAVE_OPENCL=no + DISABLE_OPENCL_REASON_LIB="(--with-opencl-library=DIR option was not defined)" +else + CSF_OPENCL_LIB="" + HAVE_OPENCL=yes + + if test "x$HAVE_OPENCL_INC" = "xyes"; then + if test ! -d $opencl_lib; then + DISABLE_OPENCL_REASON_LIB="($opencl_lib directory is not exists)" + AC_MSG_ERROR([$opencl_lib directory is not exists]) + elif test "x$opencl_lib" != "x"; then + LDFLAGS="-L$opencl_lib $LDFLAGS" + fi + AC_CHECK_LIB(OpenCL, [clGetPlatformInfo], [], [HAVE_OPENCL=no]) + else + HAVE_OPENCL=no + fi + + if test "x$HAVE_OPENCL" = "xyes"; then + if test "x$opencl_inc" != "x"; then + CSF_OPENCL_INCLUDES="-I$opencl_inc -DHAVE_OPENCL" + else + HAVE_OPENCL=no + fi + if test "x$opencl_lib" != "x"; then + CSF_OPENCL_LIB="-L$opencl_lib -lOpenCL" + else + HAVE_OPENCL=no + fi + + if test "x$HAVE_OPENCL" = "xyes"; then + CSF_OPT_INC="$opencl_inc:${CSF_OPT_INC}" + CSF_OPT_LIB="$opencl_lib:${CSF_OPT_LIB}" + else + DISABLE_OPENCL_REASON="(OpenCL was not found)"; + fi + else + AC_MSG_NOTICE("Specify --with-opencl-library to enable OpenCL support") + DISABLE_OPENCL_REASON_LIB="(OpenCL libraries were not found)" + fi +fi + +AM_CONDITIONAL( HAVE_OPENCL, [test "xyes" = "x$HAVE_OPENCL"] ) + #--------------------------------------------------------------------- # # Check for QT Libraries @@ -948,6 +1039,9 @@ AC_SUBST(CSF_XmuLibs_INCLUDES) AC_SUBST(HAVE_TBB) AC_SUBST(CSF_TBB_INCLUDES) AC_SUBST(CSF_TBB_LIB) +AC_SUBST(HAVE_OPENCL) +AC_SUBST(CSF_OPENCL_INCLUDES) +AC_SUBST(CSF_OPENCL_LIB) AC_SUBST(HAVE_QT) AC_SUBST(CSF_QT_INCLUDES) AC_SUBST(CSF_QT_LIB) @@ -975,6 +1069,7 @@ echo "gl2ps : $HAVE_GL2PS $DISABLE_GL2PS_REASON" echo "freeimage : $HAVE_FREEIMAGE $DISABLE_FREEIMAGE_REASON" echo "tbb includes : $HAVE_TBB_INC $DISABLE_TBB_REASON_INC" echo "tbb libraries : $HAVE_TBB $DISABLE_TBB_REASON_LIB" +echo "opencl : $HAVE_OPENCL $DISABLE_OPENCL_REASON" echo "qt : $HAVE_QT $DISABLE_QT_REASON" echo echo "Component Build" diff --git a/src/WOKsite/wok_deps.tcl b/src/WOKsite/wok_deps.tcl index 388f816..f9ff07e 100644 --- a/src/WOKsite/wok_deps.tcl +++ b/src/WOKsite/wok_deps.tcl @@ -26,6 +26,7 @@ if { "$tcl_platform(platform)" == "unix" } { set HAVE_FREEIMAGE "false" set HAVE_GL2PS "false" set HAVE_TBB "false" +set HAVE_OPENCL "false" set MACOSX_USE_GLX "false" set CHECK_QT4 "true" set CHECK_JDK "true" @@ -54,6 +55,9 @@ if { [info exists ::env(HAVE_GL2PS)] } { if { [info exists ::env(HAVE_TBB)] } { set HAVE_TBB "$::env(HAVE_TBB)" } +if { [info exists ::env(HAVE_OPENCL)] } { + set HAVE_OPENCL "$::env(HAVE_OPENCL)" +} if { [info exists ::env(MACOSX_USE_GLX)] } { set MACOSX_USE_GLX "$::env(MACOSX_USE_GLX)" } @@ -127,6 +131,20 @@ proc wokdep:SearchLib {theLib theBitness {theSearchPath ""}} { } } + if { "$::tcl_platform(platform)" == "linux" } { + if { "$theBitness" == "64" } { + set aPath "/usr/lib/x86_64-linux-gnu/lib${theLib}.so" + if { [file exists "$aPath"] } { + return "$aPath" + } + } else { + set aPath "/usr/lib/i386-linux-gnu/lib${theLib}.so" + if { [file exists "$aPath"] } { + return "$aPath" + } + } + } + return "" } @@ -540,6 +558,48 @@ proc wokdep:SearchTBB {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64 return "$isFound" } +# Search OpenCL library placement +proc wokdep:SearchOpenCL {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} { + upvar $theErrInc anErrInc + upvar $theErrLib32 anErrLib32 + upvar $theErrLib64 anErrLib64 + upvar $theErrBin32 anErrBin32 + upvar $theErrBin64 anErrBin64 + + set isFound "true" + if { "$::tcl_platform(os)" == "Darwin" } { + # OpenCL framework available since Mac OS X 16 + return "$isFound" + } + + set aCLHPath [wokdep:SearchHeader "CL/cl_gl.h"] + if { "$aCLHPath" == "" } { + set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{OpenCL}*] "$::VCVER" "$::ARCH" ] + if { "$aPath" != "" && [file exists "$aPath/include/CL/cl_gl.h"] } { + lappend ::CSF_OPT_INC "$aPath/include" + } else { + lappend anErrInc "Error: 'CL/cl_gl.h' not found (OpenCL)" + set isFound "false" + } + } + + foreach anArchIter {64 32} { + set aCLLibPath [wokdep:SearchLib "OpenCL" "$anArchIter"] + if { "$aCLLibPath" == "" } { + set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{OpenCL}*] "$::VCVER" "$anArchIter" ] + set aCLLibPath [wokdep:SearchLib "OpenCL" "$anArchIter" "$aPath/lib"] + if { "$aCLLibPath" != "" } { + lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib" + } else { + lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}OpenCL.${::SYS_LIB_SUFFIX}' not found (OpenCL)" + if { "$::ARCH" == "$anArchIter"} { set isFound "false" } + } + } + } + + return "$isFound" +} + # Search Qt4 libraries placement proc wokdep:SearchQt4 {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} { upvar $theErrInc anErrInc @@ -704,6 +764,7 @@ proc wokdep:SaveCustom {} { puts $aFile "set HAVE_FREEIMAGE=$::HAVE_FREEIMAGE" puts $aFile "set HAVE_GL2PS=$::HAVE_GL2PS" puts $aFile "set HAVE_TBB=$::HAVE_TBB" + puts $aFile "set HAVE_OPENCL=$::HAVE_OPENCL" puts $aFile "set CHECK_QT4=$::CHECK_QT4" puts $aFile "set CHECK_JDK=$::CHECK_JDK" @@ -750,6 +811,7 @@ proc wokdep:SaveCustom {} { puts $aFile "export HAVE_FREEIMAGE=$::HAVE_FREEIMAGE" puts $aFile "export HAVE_GL2PS=$::HAVE_GL2PS" puts $aFile "export HAVE_TBB=$::HAVE_TBB" + puts $aFile "export HAVE_OPENCL=$::HAVE_OPENCL" if { "$::tcl_platform(os)" == "Darwin" } { puts $aFile "export MACOSX_USE_GLX=$::MACOSX_USE_GLX" } diff --git a/src/WOKsite/wok_depsgui.tcl b/src/WOKsite/wok_depsgui.tcl index d0502e0..8338d3d 100644 --- a/src/WOKsite/wok_depsgui.tcl +++ b/src/WOKsite/wok_depsgui.tcl @@ -102,6 +102,9 @@ proc wokdep:gui:UpdateList {} { if { "$::HAVE_TBB" == "true" } { wokdep:SearchTBB anIncErrs anLib32Errs anLib64Errs anBin32Errs anBin64Errs } + if { "$::HAVE_OPENCL" == "true" } { + wokdep:SearchOpenCL anIncErrs anLib32Errs anLib64Errs anBin32Errs anBin64Errs + } if { "$::CHECK_QT4" == "true" } { wokdep:SearchQt4 anIncErrs anLib32Errs anLib64Errs anBin32Errs anBin64Errs } @@ -340,6 +343,8 @@ checkbutton .myFrame.myGl2psCheck -offvalue "false" -onvalue "true" -variab ttk::label .myFrame.myGl2psLbl -text "Use GL2PS" checkbutton .myFrame.myTbbCheck -offvalue "false" -onvalue "true" -variable HAVE_TBB -command wokdep:gui:UpdateList ttk::label .myFrame.myTbbLbl -text "Use Intel TBB" +checkbutton .myFrame.myOpenClCheck -offvalue "false" -onvalue "true" -variable HAVE_OPENCL -command wokdep:gui:UpdateList +ttk::label .myFrame.myOpenClLbl -text "Use OpenCL" checkbutton .myFrame.myMacGLXCheck -offvalue "false" -onvalue "true" -variable MACOSX_USE_GLX ttk::label .myFrame.myMacGLXLbl -text "Use X11 for windows drawing" checkbutton .myFrame.myQt4Check -offvalue "false" -onvalue "true" -variable CHECK_QT4 -command wokdep:gui:UpdateList @@ -434,6 +439,9 @@ incr aRowIter grid .myFrame.myTbbCheck -row $aRowIter -column 0 -sticky e grid .myFrame.myTbbLbl -row $aRowIter -column 1 -sticky w incr aRowIter +grid .myFrame.myOpenClCheck -row $aRowIter -column 0 -sticky e +grid .myFrame.myOpenClLbl -row $aRowIter -column 1 -sticky w +incr aRowIter if { "$::tcl_platform(os)" == "Darwin" } { grid .myFrame.myMacGLXCheck -row $aRowIter -column 0 -sticky e grid .myFrame.myMacGLXLbl -row $aRowIter -column 1 -sticky w diff --git a/src/WOKsite/wok_env.bat b/src/WOKsite/wok_env.bat index b14efd8..481669d 100644 --- a/src/WOKsite/wok_env.bat +++ b/src/WOKsite/wok_env.bat @@ -15,6 +15,7 @@ set "INCLUDE=" set "LIB=" set "DevEnvDir=" set "HAVE_TBB=false" +set "HAVE_OPENCL=false" set "HAVE_FREEIMAGE=false" set "HAVE_GL2PS=false" set "VCVARS=" @@ -26,6 +27,7 @@ if exist "%~dp0custom.bat" ( set "PRODUCTS_DEFINES=" if ["%HAVE_TBB%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_TBB" +if ["%HAVE_OPENCL%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_OPENCL" if ["%HAVE_GL2PS%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_GL2PS" if ["%HAVE_FREEIMAGE%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_FREEIMAGE" diff --git a/src/WOKsite/wok_env.sh b/src/WOKsite/wok_env.sh index dd87cf0..d5246a1 100644 --- a/src/WOKsite/wok_env.sh +++ b/src/WOKsite/wok_env.sh @@ -22,6 +22,7 @@ export DYLD_LIBRARY_PATH="$DYLD_LIBRARY_PATH"; export CPATH=""; export LIBRARY_PATH=""; export HAVE_TBB="false"; +export HAVE_OPENCL="false"; export HAVE_FREEIMAGE="false"; export HAVE_GL2PS="false"; export PRODUCTS_DEFINES=""; @@ -34,6 +35,9 @@ fi if [ "$HAVE_TBB" == "true" ]; then export PRODUCTS_DEFINES="$PRODUCTS_DEFINES -DHAVE_TBB"; fi +if [ "$HAVE_OPENCL" == "true" ]; then + export PRODUCTS_DEFINES="$PRODUCTS_DEFINES -DHAVE_OPENCL"; +fi if [ "$HAVE_GL2PS" == "true" ]; then export PRODUCTS_DEFINES="$PRODUCTS_DEFINES -DHAVE_GL2PS"; fi diff --git a/src/WOKsite/wok_tclshrc.tcl b/src/WOKsite/wok_tclshrc.tcl index e4e7a6c..f699383 100644 --- a/src/WOKsite/wok_tclshrc.tcl +++ b/src/WOKsite/wok_tclshrc.tcl @@ -169,6 +169,11 @@ if { "$::HAVE_TBB" == "true" } { puts " not found: Intel TBB (Optional, enabled)" } } +if { "$::HAVE_OPENCL" == "true" } { + if { [wokdep:SearchOpenCL anErrs anErrs anErrs anErrs anErrs] == "false" } { + puts " not found: OpenCL SDK (Optional, enabled)" + } +} if { "$::CHECK_QT4" == "true" } { if { [wokdep:SearchQt4 anErrs anErrs anErrs anErrs anErrs] == "false" } { puts " not found: Qt4 (Optional, set to check)"