clblas.jam 2.8 KB

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