strfind on gpu
古いコメントを表示
Hi there, When I try to use strfind on data which is on the gpu it gives me an error. It seems strfind cannot work on data which is on the gpu. Is there a work around?.
7 件のコメント
Daniel Shub
2012 年 5 月 24 日
Can you post a simple example of what you are trying to do. Specifically the code to create the arrays and how you are calling strfind on the GPU.
Mate 2u
2012 年 5 月 24 日
Daniel Shub
2012 年 5 月 24 日
How do you "put" A on the GPU?
Mate 2u
2012 年 5 月 24 日
Jan
2012 年 5 月 24 日
@Mate 2u, "string" means a [1 x N] CHAR vector. It is hard to give a meaningful advice, if the problem description is confusing.
I suggest to post the input, the wanted output, the current solution and an the required speedup.
Daniel Shub
2012 年 5 月 24 日
@Jan the STRFIND function also "works" for numeric inputs, although with the obvious problems associated with floating point comparisons.
Mate 2u
2012 年 5 月 24 日
採用された回答
その他の回答 (5 件)
Jill Reese
2012 年 5 月 21 日
2 投票
gpuArray currently only supports full, numeric types, so you cannot store a string on the GPU. How are you trying to call strfind?
Daniel Shub
2012 年 5 月 21 日
0 投票
I think I lead you to use STRFIND in my answer to this question where I pointed to Loren's blog. If you look at that blog post again, she states that strfind is not the fastest solution when the arrays get big. You might be better off using another one of her solutions because they are faster and at first glance seem to be GPU compatible.
Mate 2u
2012 年 5 月 24 日
0 投票
4 件のコメント
Jan
2012 年 5 月 24 日
Without knowing you application, an advice requires too much guessing.
I assume a C-mex woduld be helpful.
Mate 2u
2012 年 5 月 24 日
Daniel Shub
2012 年 5 月 24 日
From some of your other questions it is not clear to me if in the real application the "prices" are binary (or small integers) or if they are doubles.
Mate 2u
2012 年 5 月 24 日
Daniel Shub
2012 年 5 月 24 日
0 投票
Based on your comment "the string is Diff of prices....so are all in decimals...eg 0.0012 0.0001 -0.0002 etc" I would point out that using STRFIND on floating point number is a BAD IDEA. See FAQ:6.1 as to why comparing floating point numbers is in general a bad idea.
Jon Lareau
2023 年 6 月 3 日
0 投票
If you want to run on a GPU you can convert your strings to matrix of uint8 char values. You will need to build your GPU compiant processing function to work with the integer ASCII representation of the chars in the string.
A = uint8(char(my_string_array));
result = some_gpu_enabled_function(gpuArray(A));
1 件のコメント
Walter Roberson
2023 年 6 月 3 日
This is not wrong, but in context it is not relevant.
strfind() allows numeric inputs. For example
mask = A(:)>2; strfind([0;mask].', [0 1 1 1])
would search A looking for each place that a run of at least 3 values in a row are greater than 2.
The question was not about characters, it was about using a pattern matching function that happens to have "str" at the beginning of its name.
カテゴリ
ヘルプ センター および File Exchange で Matrices and Arrays についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!