设为首页收藏本站
授权版本:2024_07
开启左侧

[HALCON文档] Halcon获取CPU指令集和GPU相关参数脚本

[复制链接]
绝地武士 发表于 2023-12-9 10:51:12 | 显示全部楼层 |阅读模式
1.SIMD单指令多数据流
  1. SIMDExtensions := ['mmx', 'sse2', 'sse3', 'ssse3', 'sse41', 'sse42', 'avx', 'avx2', 'avx512f', 'avx512dq', 'avx512bw', 'avx512cd', 'avx512vl', 'avx512vbmi', 'avx512ifma', 'avx512vbmi2', 'avx512vpopcntdq', 'avx512bitalg', 'avx512vnni']
  2. SystemKeys := []
  3. SystemValues := []
  4. for I := 0 to |SIMDExtensions| - 1 by 1
  5.     get_system (SIMDExtensions[I] + '_supported', Information)
  6.     SystemKeys := [SystemKeys,'    ' + SIMDExtensions[I] + ':']
  7.     SystemValues := [SystemValues,Information]
  8. endfor
复制代码


2.GPU相关(OPENGL)
  1. query_available_compute_devices (DeviceIdentifiers)
  2. SystemKeys := ['*** Compute Devices ***']
  3. SystemValues := ['']
  4. for I := 0 to |DeviceIdentifiers| - 1 by 1
  5.     get_compute_device_info (DeviceIdentifiers[I], 'name', DeviceName)
  6.     get_compute_device_info (DeviceIdentifiers[I], 'vendor', DeviceVendor)
  7.     get_compute_device_info (DeviceIdentifiers[I], 'platform_version', DevicePlatform)
  8.     get_compute_device_info (DeviceIdentifiers[I], 'driver_version', DeviceDriver)
  9.     SystemKeys := [SystemKeys,'    [' + I + '] Device:']
  10.     SystemValues := [SystemValues,DeviceVendor + ', ' + DeviceName]
  11.     SystemKeys := [SystemKeys,'       Platform:']
  12.     SystemValues := [SystemValues,DevicePlatform]
  13.     SystemKeys := [SystemKeys,'       Driver:']
  14.     SystemValues := [SystemValues,DeviceDriver]
  15.     get_compute_device_info (DeviceIdentifiers[I], 'image_support', DeviceImage)
  16.     SystemKeys := [SystemKeys,'       Image Support:']
  17.     if (DeviceImage == 'true')
  18.         get_compute_device_info (DeviceIdentifiers[I], 'image2d_max_width', DeviceImageWidth)
  19.         get_compute_device_info (DeviceIdentifiers[I], 'image2d_max_height', DeviceImageHeight)
  20.         SystemValues := [SystemValues,DeviceImageWidth + ' x ' + DeviceImageHeight]
  21.     else
  22.         SystemValues := [SystemValues,DeviceImage]
  23.     endif
  24.     get_compute_device_info (DeviceIdentifiers[I], 'extensions', DeviceExtensions)
  25.     SystemKeys := [SystemKeys,'       Extensions:']
  26.     SystemValues := [SystemValues,DeviceExtensions]
  27. endfor
  28. if (|DeviceIdentifiers| == 0)
  29.     SystemKeys := [SystemKeys,'    none']
  30.     SystemValues := [SystemValues,'']
  31. endif

  32. SystemKeys := [SystemKeys,'*** CUDA capable devices ***']
  33. SystemValues := [SystemValues,'']
  34. try
  35.     get_system ('cuda_version', CUDAVersion)
  36. catch (Exception)
  37.     if (Exception[0] == 7708)
  38.         CUDAVersion := 'No CUDA capable device'
  39.     else
  40.         throw (Exception)
  41.     endif
  42. endtry
  43. SystemKeys := [SystemKeys,'    CUDA Version:']
  44. SystemValues := [SystemValues,CUDAVersion]
  45. try
  46.     get_system ('cudnn_version', cuDNNVersion)
  47. catch (Exception)
  48.     if (Exception[0] == 7708)
  49.         cuDNNVersion := 'No CUDA capable device'
  50.     else
  51.         throw (Exception)
  52.     endif
  53. endtry
  54. SystemKeys := [SystemKeys,'    cuDNN Version:']
  55. SystemValues := [SystemValues,cuDNNVersion]
  56. try
  57.     get_system ('cublas_version', cuBLASVersion)
  58. catch (Exception)
  59.     if (Exception[0] == 7708)
  60.         cuBLASVersion := 'No CUDA capable device'
  61.     else
  62.         throw (Exception)
  63.     endif
  64. endtry
  65. SystemKeys := [SystemKeys,'    cuBLAS Version:']
  66. SystemValues := [SystemValues,cuBLASVersion]
  67. get_system ('cuda_devices', CUDADevices)
  68. if (CUDADevices == [])
  69.     CUDADevices := 'No CUDA capable device'
  70. endif
  71. CUDADevices := sum(CUDADevices + ', ')
  72. CUDADevices := CUDADevices{0:strlen(CUDADevices) - 3}
  73. SystemKeys := [SystemKeys,'    CUDA Devices:']
  74. SystemValues := [SystemValues,CUDADevices]

  75. get_system ('opengl_hidden_surface_removal_available', OpenGL_HSRA)
  76. get_system ('opengl_hidden_surface_removal_enable', OpenGL_HSRE)
  77. try
  78.     get_system ('opengl_info', OpenGL_Info)
  79. catch (Exception)
  80.     OpenGL_Info := 'No OpenGL information available'
  81. endtry
  82. tuple_regexp_replace (OpenGL_Info, '\\n$', '', OpenGL_Info)
  83. Substrings := split(OpenGL_Info,'\n')
  84. Substrings := split(Substrings,'=')
  85. EvenIdx := [0:2:|Substrings| - 1]
  86. OddIdx := [1:2:|Substrings| - 1]
  87. SystemKeys := [SystemKeys,'*** OpenGL Information ***']
  88. SystemValues := [SystemValues,'']
  89. SystemKeys := [SystemKeys,'    Hidden Surface Removal:']
  90. if (OpenGL_HSRA == 'true')
  91.     if (OpenGL_HSRE == 'true')
  92.         SystemValues := [SystemValues,'available, enabled']
  93.     else
  94.         SystemValues := [SystemValues,'available, disabled']
  95.     endif
  96. else
  97.     SystemValues := [SystemValues,OpenGL_HSRA]
  98. endif
  99. if (|OddIdx| > 0)
  100.     SystemKeys := [SystemKeys,'    ' + Substrings[EvenIdx] + ':']
  101.     SystemValues := [SystemValues,Substrings[OddIdx]]
  102. else
  103.     SystemKeys := [SystemKeys,'    ' + 'GL_VERSION:']
  104.     SystemValues := [SystemValues,Substrings]
  105. endif
复制代码


奖励计划已经开启,本站鼓励作者发布最擅长的技术内容和资源,流量变现就在现在,[点我]加入吧~~~Go
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表