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!