strfind on gpu
Mostrar comentarios más antiguos
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 comentarios
Daniel Shub
el 24 de Mayo de 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
el 24 de Mayo de 2012
Daniel Shub
el 24 de Mayo de 2012
How do you "put" A on the GPU?
Mate 2u
el 24 de Mayo de 2012
Jan
el 24 de Mayo de 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
el 24 de Mayo de 2012
@Jan the STRFIND function also "works" for numeric inputs, although with the obvious problems associated with floating point comparisons.
Mate 2u
el 24 de Mayo de 2012
Respuesta aceptada
Más respuestas (5)
Jill Reese
el 21 de Mayo de 2012
2 votos
gpuArray currently only supports full, numeric types, so you cannot store a string on the GPU. How are you trying to call strfind?
1 comentario
Mate 2u
el 24 de Mayo de 2012
Daniel Shub
el 21 de Mayo de 2012
0 votos
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
el 24 de Mayo de 2012
0 votos
4 comentarios
Jan
el 24 de Mayo de 2012
Without knowing you application, an advice requires too much guessing.
I assume a C-mex woduld be helpful.
Mate 2u
el 24 de Mayo de 2012
Daniel Shub
el 24 de Mayo de 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
el 24 de Mayo de 2012
Daniel Shub
el 24 de Mayo de 2012
0 votos
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.
1 comentario
Mate 2u
el 24 de Mayo de 2012
Jon Lareau
el 3 de Jun. de 2023
0 votos
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 comentario
Walter Roberson
el 3 de Jun. de 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.
Categorías
Más información sobre Matrices and Arrays en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!