約 2,552,638 件
https://w.atwiki.jp/yosilove/pages/81.html
OpenCLメモ OpenCL/API OpenCL/サンプル
https://w.atwiki.jp/macmini/pages/33.html
■OpenCLの実力 1. OpenCLとは OpenCLとは、今まで描画に使用されていたGPUの演算能力を、3D描画などの目的以外でも汎用的に使用する技術のことである。 FPS(First Person Shootin)などの3Dゲームはともかく、通常の使用においては、GPU(Graphics Processing Unit)は常に処理をしている訳でなく、アイドルの状態である。また、CPUとは異なり、複雑な条件分岐が発生しないストリームデータの処理においてはCPUよりも遥かに高速に処理することができる。そこで、CPUの用に汎用的にGPUを活用しようとGPGPU(General Purpose GPU)というアプローチが生まれ、特定のGPUに依存しないオープンな規格として纏めようとAppleが中心となって提唱したのがOpenCLである。 Snow LeopardはOpenCLを実装した初めてのOSであり、以下のGPUの組み合わせで使用することができる。 NVIDIA GeForce 8xxx GeForce 8600M GT、GeForce 8800 GT、GeForce 8800 GS GeForce 9xxx GeForce 9400M、GeForce 9600M GT GeForce GT1x GeForce GT 120、GeForce GT 130 GeForce GT2x GeForce GTX 285 Quadro FX Quadro FX 4800、Quadro FX5600 ATI Radeon 48x0 Radeon 4850、Radeon 4870 ■追記 (2009/10/25) Late 2009 iMacでATI Radeon 4670がサポートされた。Snow Leopardの技術情報では更新されていないが、Open CLをサポートしていると思われる。 スペックをみるとCore 680MHz/Memory 790MHz(GDR3)であり、デスクトップ版のCore 750MHz/Memory 1000MHz(GDR3)よりもクロックが下げられている。4650がCore 600Mhz/Memory 500MHz(DDR2)である為、実パフォーマンスは4650と4670の中間あたりと思われる。 現状、Radeon 4670のサポートは2009 Late iMacのプレインストール版10.6.1(カーネル10.1.2)のみであるが、10.6.2からRadeon 4670が標準でサポートされる。これにより、kextにデバイスIDを追記することで4350/4650も使用可能となり、現状の48x0のみから、46x0/45x0/43x0シリーズも使用できるようになる。 Mac miniとしてこの情報から考察すべき点は、内蔵GPUのパフォーマンスが振るわないArandaleではなく、独立GPUを必要とするMobile版Core i5/i7のClarksfiledと、消費電力の少ないRadeon 4550(*1)やそれ以下のMobility Radeon 4570/4530などを組み合わせた構成を取ることも想定できる。 (*1) デスクトップ版で消費電力は20Wであり、パフォマーンスにおいてもGeForce 9400GTより上である。 2. テストプログラムの実行 OpenCLを使用したアプリケーションはSnow Leopardリリース時点では無いが、Appleの開発者向けサイトでサンプルプログラムが公開されている。ただし、かなり不親切で公開されているのはソースのみであり、OpenCLの実力を体験するには自分でビルドする必要がある(説明ドキュメントも満足に整備されておらず、ソースを読まなければいけない状態とかなり雑)。 ■テストプログラム実行環境 MainMachine Apple Mac mini (MB463J/A) Memory 8GB(4GBx2) SanMax SMD-N4G68HP-10F DDR3-1066 S.O.DIMM 4GB CL7 hynix/JEDEC Storage SSD 256GB SAMSUNG PB-22J (MMDOE56G5MXP-0VB) ODD Blu-ray Read Super Drive Sony NEC Optiarc BC-5600S Slim Combo Drive OS OSX Snow Leopard 10.6.1(64bitカーネル) HFS+ (Journal Enabled) ■テストプログラムと実行結果 1. OpenCL NBody Simulation Example(ソース)/Galaxies(実行バイナリ) 主な操作キー1-6 Select an N-Body System Configurationg Select the next Graphics Devices Select the next Simulation Devicer Enable/Disable Auto Rotationd Show/Hide Dock UIh Show/Hide HUD UIu Show/Hide Simulation Updates Meterf Show/Hide FPS Meterspace Pause/Unpause Simulation0 Quit CPU演算の結果 (Core 2 Duo 2.0GHz 2Core/2Thread) GPU演算の結果 (GeForce 9400M Core 450MHz/Shader 1100MHz/SP16) CPU+GPU演算の結果 (Core 2 Duo 2.0GHz+GeForce 9400M) (追記:2010/1/20) 9800GT GEのパフォーマンス (GeForce 9800 GT Core 550MHz/Shader 1375MHz/SP112) 2. OpenCL Procedural Grass and Terrain Example(ソース)/Glass(実行バイナリ) 主な操作キー. NoisesBias up / NoisesBias down- FieldInstance(Glass) up= FieldInstance(Glass) down; FlowSpped(Wind) up' FlowSpped(Wind) downq quit FieldInstance Max 参考 OpenGLツール OepnGL Extension Viewer 戻る
https://w.atwiki.jp/asato/pages/312.html
Khronos OpenCL API Registry ニュース 「OpenCL 1.0」が公開--アップル提案のAPI仕様が業界標準に
https://w.atwiki.jp/yosilove/pages/82.html
OpenCLサンプルコード集 管理人作
https://w.atwiki.jp/gottaniwiki/pages/25.html
OpenCL ヘルパー C++ ラッパー サンプル これらのサンプルでは、上記のラッパーを利用しています。 ベクトルの加算 行列演算 セルオートマトン リンク トップページ 合計: - 今日: - 昨日: - トップページの合計: -
https://w.atwiki.jp/gottaniwiki/pages/21.html
OpenCL OpenCL C++ Binding のラッパー リンク トップページ 合計: - 今日: - 昨日: - トップページの合計: -
https://w.atwiki.jp/gottaniwiki/pages/27.html
OpenCL/セルオートマトン CA1.cl #define BLOCK_SIZE 128 __constant const int RULE[8] = { // 000 001 010 011 100 101 110 111 0, 1, 0, 1, 1, 0, 1, 0 }; __kernel void runCA90( __global const int * input1, __global int * output, __local int * work) { int index = get_global_id(0) + 1; //// int before = (input1[index - 1] * 4) + (input1[index +1]); //// output[index] = RULE[before]; //// return; //// output[index] = (input1[index - 1] ^ input1[index + 1]); //// return; int lx = get_local_id(0) + 1; work[lx] = input1[index]; if ( lx == 1 ) { work[0] = input1[index - 1]; work[BLOCK_SIZE +1] = input1[index + BLOCK_SIZE]; } barrier(CLK_LOCAL_MEM_FENCE); int before = (work[lx - 1] * 4) + (work[lx] * 2) + (work[lx +1]); output[index] = RULE[before]; //// output[index] = (work[lx - 1] ^ work[lx + 1]); } LifeGame.cpp #include "../Common/OclWrap.h" #include "../Common/SimpleTimer.h" #include fstream #include sstream #include iostream const int MAX_TIMES = 500; const int BLOCK_SIZE = 128; typedef int INPUT_TYPE; void runOnHost( const INPUT_TYPE * input1, INPUT_TYPE * output, const size_t NUM) { for ( size_t index = 1; index = NUM; ++ index ) { output[index] = (input1[index - 1] ^ input1[index + 1]); } return; } int main(int argc, char * argv[]) { cl_int err = CL_SUCCESS; const size_t NUM = (argc = 2 ? atol(argv[1]) BLOCK_SIZE * 100000); const size_t BUFFER_SIZE = (NUM + 2); std vector INPUT_TYPE vecInput1(BUFFER_SIZE); std vector INPUT_TYPE vecInput2(BUFFER_SIZE); std vector int vecOutputCPU(BUFFER_SIZE, 0); std vector INPUT_TYPE vecOutputGPU(BUFFER_SIZE, 0); INPUT_TYPE * const input1 = (vecInput1[0]); INPUT_TYPE * const input2 = (vecInput2[0]); INPUT_TYPE * const output1 = (vecOutputGPU[0]); CLWRAP OclWrap wrapper; // データの準備。 // for ( size_t i = 0; i BUFFER_SIZE; ++ i ) { input1[i] = 0; input2[i] = 0; } input1[BUFFER_SIZE / 2] = 1; // Running By GPU // CLWRAP SimpleTimer timer; CLWRAP SimpleTimer timeGPU; timer.startTimer(); try { wrapper.setupInstance(std cerr); wrapper.readSourceFile("CA1.cl"); wrapper.buildPrograms(std cerr); cl Kernel kernel(wrapper.getProgram(), "runCA90", err); cl Buffer memInput1 = wrapper.createBuffer( CL_MEM_READ_WRITE | CL_MEM_COPY_HOST_PTR, sizeof(INPUT_TYPE) * BUFFER_SIZE, input1, err); cl Buffer memInput2 = wrapper.createBuffer( CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR, sizeof(INPUT_TYPE) * BUFFER_SIZE, input2, err); cl CommandQueue queue = wrapper.createCommandQueue(0, err); kernel.setArg(2, sizeof(INPUT_TYPE) * (BLOCK_SIZE + 2) , NULL); timeGPU.startTimer(); for ( size_t t = 0; t MAX_TIMES; t += 2 ) { kernel.setArg(0, memInput1); kernel.setArg(1, memInput2); queue.enqueueNDRangeKernel(kernel, cl NullRange, cl NDRange(NUM), cl NDRange(BLOCK_SIZE), NULL, NULL); kernel.setArg(0, memInput2); kernel.setArg(1, memInput1); queue.enqueueNDRangeKernel(kernel, cl NullRange, cl NDRange(NUM), cl NDRange(BLOCK_SIZE), NULL, NULL); } timeGPU.stopTimer(); queue.enqueueReadBuffer(memInput1, CL_TRUE, 0, sizeof(INPUT_TYPE) * BUFFER_SIZE, output1, NULL, NULL); // } catch ( cl Error err ) { // std cerr "ERROR " err.what() "(" err.err() ")" std endl; } catch ( std exception err ) { std cerr "ERROR " err.what() std endl; exit( EXIT_FAILURE ); } catch ( ... ) { std cerr "Unknown Exception" std endl; exit( EXIT_FAILURE ); } timer.stopTimer(); std cerr "Run On GPU --- " "CLOCK " timer.getClockTime() ", REAL " timer.getRealTime() std endl; std cerr "In Kernel --- " "CLOCK " timeGPU.getClockTime() ", REAL " timeGPU.getRealTime() std endl; //// const size_t SHOW_OFFSET = (BUFFER_SIZE - 30) / 2; const size_t SHOW_OFFSET = 0; for ( int i = 0; i 30; ++ i ) { std cout output1[i + SHOW_OFFSET]; } std cout std endl; // Running By CPU // input2[BUFFER_SIZE / 2] = 1; timer.startTimer(); for ( size_t t = 0; t MAX_TIMES; t += 2 ) { runOnHost(input2, input1, NUM); runOnHost(input1, input2, NUM); } timer.stopTimer(); std cerr "Run On CPU --- " "CLOCK " timer.getClockTime() ", REAL " timer.getRealTime() std endl; for ( int i = 0; i 30; ++ i ) { std cout input1[i + SHOW_OFFSET]; } std cout std endl; return ( 0 ); } リンク トップページ 合計: - 今日: - 昨日: - トップページの合計: -
https://w.atwiki.jp/gottaniwiki/pages/26.html
OpenCL/Wrapper OclWrap.h #if !defined( OCLPROJ_COMMON_INCLUDED_OCL_WRAP_H ) # define OCLPROJ_COMMON_INCLUDED_OCL_WRAP_H #pragma once #include iosfwd #include string #include vector #include CL/cl.hpp // クラスの前方宣言。 // namespace CLWRAP { //======================================================================== // // ErrCode. // /** ** エラーコード型。 **/ typedef enum { ERR_SUCCESS = 0, /** 正常終了。 **/ ERR_FAILURE = 1, /** 異常終了。 **/ ERR_FILE_NOT_FOUND = 2, /** ファイルが見つからない。 **/ } ErrCode; //======================================================================== // // OclWrap class. // /** ** ラッパークラス。 **/ class OclWrap { //======================================================================== // // 初期化と終了。 // public //---------------------------------------------------------------- /** インスタンスを初期化する。 ** ** @param[out] os ログ出力用ストリーム。 ** @return エラーコードを返す。 ** - 異常終了時はエラーの種類を示す非ゼロ値を返す。 ** - 正常終了の場合はゼロを返す。 **/ const ErrCode setupInstance( std ostream os); //---------------------------------------------------------------- /** インスタンスの後始末をする。 ** ** @return エラーコードを返す。 ** - 異常終了時はエラーの種類を示す非ゼロ値を返す。 ** - 正常終了の場合はゼロを返す。 **/ const ErrCode clearInstance(); //======================================================================== // // プログラムの読み込みとカーネルの準備。 // public //---------------------------------------------------------------- /** ソースファイルを指定する。 ** ** @param [in] filename ファイル名。 ** @return エラーコードを返す。 ** - 異常終了時はエラーの種類を示す非ゼロ値を返す。 ** - 正常終了の場合はゼロを返す。 **/ const ErrCode readSourceFile( const std string filename); //---------------------------------------------------------------- /** 読み込んだソースコードからプログラムをビルドする。 ** ** @param[out] os ログ出力用ストリーム。 ** @return エラーコードを返す。 ** - 異常終了時はエラーの種類を示す非ゼロ値を返す。 ** - 正常終了の場合はゼロを返す。 **/ const ErrCode buildPrograms( std ostream os); //---------------------------------------------------------------- /** ビルドしたプログラムからカーネルを作成する。 ** ** @param [in] kname カーネル名。 ** @return エラーコードを返す。 ** - 異常終了時はエラーの種類を示す非ゼロ値を返す。 ** - 正常終了の場合はゼロを返す。 **/ const ErrCode createKernel( const std string kname); //======================================================================== // // メモリ管理。 // public //---------------------------------------------------------------- /** バッファを作成する。 ** **/ cl Buffer createBuffer( cl_mem_flags flags, size_t size, void * ptrHost = NULL, cl_int * ptrErr = NULL) { return ( cl Buffer(this- m_context, flags, size, ptrHost, ptrErr) ); } //======================================================================== // // カーネルの実行。 // public //---------------------------------------------------------------- /** コマンドキューを作成する。 ** **/ cl CommandQueue createCommandQueue( cl_command_queue_properties properties = 0, cl_int * ptrErr = NULL) { return ( cl CommandQueue(this- m_context, this- m_device, properties, ptrErr) ); } //======================================================================== // // Accessors. // public //---------------------------------------------------------------- /** コンテキストを取得する。 ** ** @return コンテキストの参照を返す。 **/ const cl Context getContext() const { return ( (this- m_context) ); } const cl Device getDevice() const { return ( this- m_device ); } //---------------------------------------------------------------- /** ビルドしたプログラムを取得する。 ** ** @return プログラムの参照を返す。 **/ const cl Program getProgram() const { return ( this- m_program ); } //======================================================================== // // Member Variables. // private cl Platform m_clPlatform; cl Context m_context; std vector cl Device m_devices; cl Device m_device; std vector std string m_srcFiles; cl Program m_program; }; } // End of namespace CLWRAP #endif OclWrap.cpp #include "OclWrap.h" #pragma comment (lib, "OpenCL.lib") #include fstream #include ostream namespace CLWRAP { //======================================================================== // // OclWrap class. // //======================================================================== // // 初期化と終了。 // //---------------------------------------------------------------- // インスタンスを初期化する。 // const ErrCode OclWrap setupInstance( std ostream os) { cl_int err = CL_SUCCESS; // プラットフォーム取得。 // std vector cl Platform platforms; cl Platform get( platforms); if ( (platforms.empty()) ) { throw std runtime_error("No Platforms!"); return ( ERR_FAILURE ); } os "# of Platforms = " (platforms.size()) std endl; this- m_clPlatform = platforms.at(0); cl_context_properties properties[] = { CL_CONTEXT_PLATFORM, reinterpret_cast cl_context_properties (this- m_clPlatform()), 0 }; // コンテキスト作成。 // this- m_context = cl Context( CL_DEVICE_TYPE_GPU, properties, NULL, NULL, err); if ( err != CL_SUCCESS ) { throw std runtime_error("Failed to Create Context"); return ( ERR_FAILURE ); } cl Context context = (this- m_context); // デバイス取得。 // std vector cl Device devices = (this- m_devices); devices = context.getInfo CL_CONTEXT_DEVICES (); os "# of Devices = " (devices.size()) std endl; if ( (devices.empty()) ) { throw std runtime_error("No Devices!"); return ( ERR_FAILURE ); } this- m_device = devices.at(0); os "Device Name " this- m_device.getInfo CL_DEVICE_NAME () std endl "Device Vendor " this- m_device.getInfo CL_DEVICE_VENDOR () std endl; return ( ERR_SUCCESS ); } //---------------------------------------------------------------- // インスタンスの後始末をする。 // const ErrCode OclWrap clearInstance() { return ( ERR_SUCCESS ); } //======================================================================== // // プログラムの読み込みとカーネルの準備。 // //---------------------------------------------------------------- // ソースファイルを指定する。 // const ErrCode OclWrap readSourceFile( const std string filename) { // この時点では未だ読み込まずに、ファイル名のリストだけ作成する。 // this- m_srcFiles.push_back(filename); return ( ERR_SUCCESS ); } //---------------------------------------------------------------- // 読み込んだソースコードからプログラムをビルドする。 // const ErrCode OclWrap buildPrograms( std ostream os) { cl_int err = CL_SUCCESS; typedef std vector std string const_iterator NameItr; std vector std string buffers; cl Program Sources srcs; ErrCode ret = ERR_SUCCESS; srcs.clear(); srcs.reserve(this- m_srcFiles.size()); const NameItr itrEnd = this- m_srcFiles.end(); for ( NameItr itr = (this- m_srcFiles.begin()); itr != itrEnd; ++ itr ) { // 存在しないファイルはまとめて通知した方が良いので、 // // 途中でファイル読み込みエラーが発生しても、 // // ファイルの存在チェックだけは最後まで継続して行う。 // std ifstream fsSource(itr- c_str()); if ( !fsSource ) { os "Source File [" (*itr) "] Not Found!" std endl; ret = ERR_FAILURE; } if ( ret != ERR_SUCCESS ) { // 途中でエラーを見つけている場合は、 // // ファイルの存在チェックのみ行う。 // continue; } // ファイルの内容を読み込む。 // buffers.push_back( std string( std istreambuf_iterator char (fsSource), (std istreambuf_iterator char ()) )); ////os strSrc std endl; const std string strSrc = buffers.back(); srcs.push_back( std make_pair(strSrc.c_str(), strSrc.length()) ); } if ( ret != ERR_SUCCESS ) { throw std runtime_error("Source File(s) Not Found!"); return ( ret ); } cl Context context = (this- m_context); cl Program program = cl Program(context, srcs, err); if ( err != CL_SUCCESS ) { throw std runtime_error("Failed to Read Sources!"); return ( ERR_FAILURE ); } err = program.build(this- m_devices); std string log = program.getBuildInfo CL_PROGRAM_BUILD_LOG (this- m_device); if ( err != CL_SUCCESS ) { os "Build Error ... \n" log std endl; throw std runtime_error("Build Error!"); return ( ERR_FAILURE ); } // ソーステキストはもう要らない。 // buffers.clear(); this- m_program = program; return ( ERR_SUCCESS ); } //---------------------------------------------------------------- // ビルドしたプログラムからカーネルを作成する。 // const ErrCode OclWrap createKernel( const std string kname) { return ( ERR_SUCCESS ); } } // End of namespace CLWRAP リンク トップページ 合計: - 今日: - 昨日: - トップページの合計: -
https://w.atwiki.jp/asterisk99/pages/564.html
original (2019/05/14 付) Google 翻訳 (2019/05/23 付) # Tesseract and OpenCL #TesseractとOpenCL OpenCL is an API which allows portable usage of GPU computing resources. OpenCLはGPUコンピューティングリソースの移植可能な使用を可能にするAPIです。 It is support for Linux, macOS and Windows. それはLinux、macOSそしてWindowsのサポートです。 Modern graphic cards can do some computations which are needed for Tesseract very fast. 最近のグラフィックカードはTesseractに必要ないくつかの計算を非常に速くすることができます。 By using that compute power, Tesseract ideally can be made faster. その計算能力を使うことによって、Tesseractは理想的にはより速くすることができます。 # How to build Tesseract with OpenCL #OpenCLでTesseractをビルドする方法 Important note OpenCL support in Tesseract is still considered experimental. There are some major bugs associated with it (see issue 837). Building Tesseract with OpenCL support is not recommended (for any version of Tesseract), unless you are a developer and want to improve the OpenCL code. 重要な注意事項:TesseractでのOpenCLサポートはまだ実験的なものと見なされています。それに関連するいくつかの主要なバグがあります(issue 837を参照してください)。あなたが開発者であり、OpenCLコードを改善したいのでなければ、OpenCLサポートでTesseractをビルドすることはお勧めできません(Tesseractのどのバージョンでも)。 ## Building Tesseract on VS 2010 with OpenCL ## OpenCLによるVS 2010でのTesseractの構築 1 Open the Tesseract Visual Studio 2010 solution file under \tesseract-ocr\vs2010\tesseract.sln 2 Select the required build configuration (LIB_DEBUG / LIB_RELEASE / DLL_DEBUG / DLL_RELEASE) 3 Set up the OpenCL paths in “tesseract” project * Right click on “tesseract” project and select Properties *「tesseract」プロジェクトを右クリックして「プロパティ」を選択します。 * Header file paths Go to Configuration Properties - C/C++ - General - Additional Include Directories. Add the directory path where OpenCL header files are located on the given machine. E.g On a machine with AMD APP SDK installed, this path will be $(AMDAPPSDKROOT)include. *ヘッダーファイルのパス:[構成プロパティ] - [C / C ++] - [一般] - [追加のインクルードディレクトリ]に移動します。指定されたマシン上のOpenCLヘッダーファイルが配置されているディレクトリパスを追加します。例:AMD APP SDKがインストールされているコンピュータにパスは$(AMDAPPSDKROOT)インクルードになります。 * Library file path Go to Configuration Properties - Linker - General - Additional Library Directories. Add the directory path where OpenCL library file, OpenCL.lib is located on the given machine. E.g On a machine with AMD APP SDK installed, this path will be $(AMDAPPSDKROOT)lib\x86. *ライブラリファイルのパス:[構成プロパティ] - [リンカ] - [一般] - [追加のライブラリディレクトリ]に移動します。 OpenCLライブラリファイルOpenCL.libが所定のマシン上にあるディレクトリパスを追加します。例:AMD APP SDKがインストールされているコンピュータにパスは$(AMDAPPSDKROOT)lib \ x86になります。 * Library reference Go to Configuration Properties - Linker - Input - Additional Dependencies. Add OpenCL.lib to the list of dependent libraries. *ライブラリ参照:[構成プロパティ] - [リンカ] - [入力] - [その他の依存関係]に移動します。依存ライブラリのリストにOpenCL.libを追加します。 * Preprocessor definition Go to Configuration Properties - C/C++ - Preprocessor - Preprocessor Definitions. Add USE_OPENCL to the list of preprocessor definitions list. *プリプロセッサー定義:「構成プロパティー」 - 「C / C ++」 - 「プリプロセッサー」 - 「プリプロセッサー定義」に進みます。プリプロセッサ定義リストのリストにUSE \ _OPENCLを追加します。 4 Repeat the same steps as point 3 above to set OpenCL paths for “libtesseract” project 5 Build and run the solution. ## Building Tesseract on Linux with OpenCL ## OpenCLを使ってLinuxでTesseractをビルドする 1. Make sure you have installed OpenCL sdk and libtiff-dev 1. OpenCL SDKとlibtiff-devがインストールされていることを確認してください。 1. The OpenCL header and library paths are currently defined by the variables OPENCL_HDR_PATH and OPENCL_LIB in configure.ac. These have to be set to the appropriate paths depending on the OpenCL installation. 1. OpenCLヘッダーとライブラリパスは現在configure.acの変数OPENCL \ _HDR \ _PATHとOPENCL \ _LIBによって定義されています。これらはOpenCLのインストールに応じて適切なパスに設定する必要があります。 1. To build on Linux use 1. Linux上でビルドする ` | ` ./configure --enable-opencl ./configure --enable-opencl ` | ` or if you want to specified opencl include (/opt/AMDAPP/include/) and library (/opt/AMDAPP/lib/x86_64/) paths またはopencl include( / opt / AMDAPP / include /)とライブラリ( / opt / AMDAPP / lib / x86_64 /)のパスを指定したい場合は、 ` | ` export LIBRARY_PATH=/opt/AMDAPP/lib/x86_64/ $LIBRARY_PATH export LIBRARY_PATH = / opt / AMDAPP / lib / x86_64 /:$ LIBRARY_PATH CPPFLAGS+=-I/opt/AMDAPP/include/ ./configure --enable-opencl CPPFLAGS + = - I / opt / AMDAPP / include / ./configure --enable-opencl ` | ` # Using Tesseract with OpenCL #OpenCLでTesseractを使う Normally Tesseract works with OpenCL Installable Client Drivers (ICD). 通常Tesseractは OpenCL Installable Client Drivers (ICD)で動作します。 It tests for available OpenCL drivers at runtime, so a Tesseract binary can work with different GPU hardware on different computers. All you have to do is installing the OpenCL driver for your GPU hardware. There also exists a generic OpenCL driver which uses the CPU instead of a GPU. More than one OpenCL driver can be enabled for a computer system. 実行時に利用可能なOpenCLドライバをテストするので、Tesseractバイナリは異なるコンピュータ上の異なるGPUハードウェアで動作することができます。 GPUハードウェア用のOpenCLドライバをインストールするだけです。 GPUの代わりにCPUを使用する一般的なOpenCLドライバもあります。コンピュータシステムに対して複数のOpenCLドライバを有効にすることができます。 When Tesseract with OpenCL support is started the first time, it looks for the available OpenCL drivers and runs benchmarks for each of them. In addition, the same benchmarks are run using the native CPU (without OpenCL). The benchmark results are saved in a file tesseract_opencl_profile_devices.dat in the current directory for future runs. Tesseract calculates a weighted performance index from all benchmark results and choses the fastest method for its calculations. Delete the file to force a rebuild. The generated GPU code for each OpenCL driver is also saved in individual files named kernel- plus the name of the driver plus .bin, for example kernel-Intel(R)_HD_Graphics_IvyBridge_M_GT2.bin. Delete those files after an update of your OpenCL software to force a rebuild. Tesseract with OpenCLサポートが最初に起動されるとき、それは利用可能なOpenCLドライバを探し、それぞれのベンチマークを実行します。さらに、同じベンチマークがネイティブCPU(OpenCLなし)を使用して実行されます。ベンチマーク結果は将来の実行のために現在のディレクトリのファイル tesseract_opencl_profile_devices.datに保存されます。 Tesseractは、すべてのベンチマーク結果から加重パフォーマンスインデックスを計算し、その計算に最速の方法を選択しました。ファイルを削除して再構築を強制します。各OpenCLドライバ用に生成されたGPUコードは、 kernel-という名前の個々のファイルにドライバの名前と .bin を加えたものにも保存されます。例えば、 kernel-Intel(R)_HD_Graphics_IvyBridge_M_GT2.bin`です。強制的に再構築するには、OpenCLソフトウェアの更新後にこれらのファイルを削除してください。 It is possible to override the automatic choice by setting the environment variable TESSERACT_OPENCL_DEVICE, for example TESSERACT_OPENCL_DEVICE=1 selects the first OpenCL device. As the native CPU has also a device number (always the highest number) in Tesseract, use of OpenCL can be disabled by setting that number. 環境変数TESSERACT_OPENCL_DEVICEを設定することで自動選択を無効にすることができます。例えば、TESSERACT OPENCL DEVICE = 1は最初のOpenCLデバイスを選択します。 TesseractではネイティブCPUにもデバイス番号(常に最大の番号)があるため、その番号を設定することでOpenCLの使用を無効にすることができます。 ## Installable Client Drivers for OpenCL (ICD) ## OpenCL用のインストール可能なクライアントドライバ(ICD) These Debian packages provide such drivers これらのDebianパッケージは、そのようなドライバを提供します。 * amd-opencl-icd – AMD Radeon GPU * amd-opencl-icd - AMD Radeon GPU * beignet-opencl-icd – Intel GPU * beignet-opencl-icd - インテルGPU * mesa-opencl-icd – AMD GPU * mesa-opencl-icd - AMD GPU * nvidia-egl-icd – NVIDIA GPU * nvidia-egl-icd - NVIDIA GPU * nvidia-legacy-304xx-opencl-icd – NVIDIA GPU * nvidia-legacy-304xx-opencl-icd - NVIDIA GPU * nvidia-legacy-340xx-opencl-icd – NVIDIA GPU * nvidia-legacy-340xx-opencl-icd - NVIDIA GPU * nvidia-opencl-icd – NVIDIA GPU * nvidia-opencl-icd - NVIDIA GPU * pocl-opencl-icd – native CPU * pocl-opencl-icd - ネイティブCPU It is possible to enable debug messages for some drivers by setting environment variables (example). 環境変数を設定することで、一部のドライバのデバッグメッセージを有効にすることができます(example)。 ## OpenCL devices (examples) ## OpenCLデバイス(例) ### Linux (x86) ### Linux(x86) * Intel(R) HD Graphics IvyBridge M GT2 *インテル(R)HDグラフィックスIvyBridge M GT2 * pthread-Intel(R) Core(TM) i7-3520M CPU @ 2.90GHz * pthread-インテル(R)コア(TM)i7-3520M CPU @ 2.90GHz * pthread-Intel(R) Xeon(R) CPU E5620 @ 2.40GHz * pthread-インテル(R)Xeon(R)CPU E5620 @ 2.40 GHz ### macOS ### マックOS ### Windows ###ウィンドウズ * pthread-Intel(R) Core(TM) i5 CPU 650 @ 3.20GHz * pthread-インテル(R)コア(TM)i5 CPU 650 @ 3.20 GHz ## Performance ##パフォーマンス Only some parts of the OCR process are handled by OpenCL, so using OpenCL does not necessarily result in much faster OCR. More precise measurements have to be done. OCRプロセスの一部のみがOpenCLによって処理されるため、OpenCLを使用しても必ずしもOCRが高速になるわけではありません。より正確な測定をする必要があります。 ## Known problems ##既知の問題 OpenCL is still experimental, so expect possible crashes, wrong OCR results or bad instead of improved performance. OpenCLはまだ実験的なものなので、パフォーマンスの向上ではなく、起こり得るクラッシュ、誤ったOCR結果、または悪い結果が予想されます。
https://w.atwiki.jp/sevenlives/pages/2256.html
GLUT OpenGL ES GLSL? WebGL OpenCL? シリコングラフィックス?