arrayfire / arrayfire/arrayfire-python

OpenCL interoperability does not work on 64-bit OS

オープン
#265 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
Python
スター
422
フォーク
63
PR マージ指標
30日以内にマージされた PR はありません

説明

Currently the OpenCL interoperability does not work on 64-bit Windows machine. The reason for this is the use of `c_int_t` which defaults to long on Windows (which on the other hand is 32-bit). This can be problematic with things like device IDs as they can easily go over 2^32/2-1. For example https://github.com/arrayfire/arrayfire-python/blob/master/arrayfire/opencl.py#L88 uses `c_int_t`, as well as a few other functions in the same file. This can be fixed by replacing the `c_int_t` with, for example, `c_void_ptr_t` as it is used with the context. Is there by the way some specific reason why context is treated differently?

There is also another issue. When the context is created by PyOpenCL, the input device, context and queue values are input as python ints in order to use the same context and queue, but on Windows you get `: int too long to convert` errors then. These can be avoided by casting them to, for example, `c_int64`-types. For example in https://github.com/arrayfire/arrayfire-python/blob/master/arrayfire/opencl.py#L156, replace `safe_call(backend.get().afcl_add_device_context(dev, ctx, que))` with `safe_call(backend.get().afcl_add_device_context(ct.c_int64(dev), ct.c_int64(ctx), ct.c_int64(que)))` (using `c_void_p` seems to work too).

I haven't tested these changes extensively, but they do seem to get things working on 64-bit Windows. I can provide a PR if needed.

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

調査の方向性

The affected entry points are arrayfire/opencl.py around lines 88 and 156, plus the other c_int_t uses in that file. Read those ctypes declarations first, then reproduce the 64-bit Windows OpenCL/PyOpenCL setup; done means device IDs and shared device, context, and queue values no longer overflow and interoperability works.

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python
領域
hpc
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
48/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。