strfind on gpu
Show older comments
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 Comments
Daniel Shub
on 24 May 2012
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
on 24 May 2012
Daniel Shub
on 24 May 2012
How do you "put" A on the GPU?
Mate 2u
on 24 May 2012
Jan
on 24 May 2012
@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
on 24 May 2012
@Jan the STRFIND function also "works" for numeric inputs, although with the obvious problems associated with floating point comparisons.
Mate 2u
on 24 May 2012
Accepted Answer
More Answers (5)
Jill Reese
on 21 May 2012
2 votes
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
on 21 May 2012
0 votes
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
on 24 May 2012
0 votes
4 Comments
Jan
on 24 May 2012
Without knowing you application, an advice requires too much guessing.
I assume a C-mex woduld be helpful.
Mate 2u
on 24 May 2012
Daniel Shub
on 24 May 2012
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
on 24 May 2012
Daniel Shub
on 24 May 2012
0 votes
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
on 3 Jun 2023
0 votes
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 Comment
Walter Roberson
on 3 Jun 2023
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.
Categories
Find more on Matrices and Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!