1# Copyright (c) 2018 Stefan Seefeld 2# 3# Use, modification and distribution is subject to the Boost Software 4# License Version 1.0. (See accompanying file LICENSE_1_0.txt or 5# http://www.boost.org/LICENSE_1_0.txt) 6 7# Supports the clblas library 8# 9# After 'using clblas', the following targets are available: 10# 11# /clblas//clblas -- The clblas library 12 13import project ; 14import ac ; 15import errors ; 16import feature ; 17import "class" : new ; 18import targets ; 19import modules ; 20import property-set ; 21import toolset : using ; 22 23using opencl ; 24 25header = clBLAS.h ; 26names = clBLAS ; 27 28library-id = 0 ; 29 30if --debug-configuration in [ modules.peek : ARGV ] 31{ 32 .debug = true ; 33} 34 35# Initializes the clblas library. 36# 37# Options for configuring clblas:: 38# 39# <search> 40# The directory containing the clblas library. 41# <name> 42# Overrides the default library name. 43# <include> 44# The directory containing the clblas headers. 45# 46# Examples:: 47# 48# # Find clblas in the default system location 49# using clblas ; 50# # Find clblas in /usr/local 51# using clblas : 1.2.7 52# : <include>/usr/local/include <search>/usr/local/lib ; 53# 54rule init ( version ? : # The clblas version (currently ignored) 55 options * : # A list of the options to use 56 requirements * ) # The requirements for the clblas target 57{ 58 local caller = [ project.current ] ; 59 60 if ! $(.initialized) 61 { 62 .initialized = true ; 63 64 project.initialize $(__name__) ; 65 .project = [ project.current ] ; 66 project clblas ; 67 } 68 69 local library-path = [ feature.get-values <search> : $(options) ] ; 70 local include-path = [ feature.get-values <include> : $(options) ] ; 71 local library-name = [ feature.get-values <name> : $(options) ] ; 72 73 if ! $(library-path) && ! $(include-path) && ! $(library-name) 74 { 75 is-default = true ; 76 } 77 78 condition = [ property-set.create $(requirements) ] ; 79 condition = [ property-set.create [ $(condition).base ] ] ; 80 81 if $(.configured.$(condition)) 82 { 83 if $(is-default) 84 { 85 if $(.debug) 86 { 87 ECHO "notice: [clblas] clblas is already configured" ; 88 } 89 } 90 else 91 { 92 errors.user-error "clblas is already configured" ; 93 } 94 return ; 95 } 96 else 97 { 98 if $(.debug) 99 { 100 ECHO "notice: [clblas] Using pre-installed library" ; 101 if $(condition) 102 { 103 ECHO "notice: [clblas] Condition" [ $(condition).raw ] ; 104 } 105 } 106 107 local mt = [ new ac-library clblas : $(.project) : $(condition) : 108 $(include-path) : $(library-path) : $(library-name) ] ; 109 $(mt).set-header $(header) ; 110 $(mt).set-default-names $(names) ; 111 targets.main-target-alternative $(mt) ; 112 } 113 .configured.$(condition) = true ; 114} 115