I want to use a string matching in managedCuda. But how can I initialized it?
i've tried using C# version, here's the examples:
stringAr = new List<string>();
stringAr.Add("you");
stringAr.Add("your");
stringAr.Add("he");
stringAr.Add("she");
stringAr.Add("shes");
for the string matching, i've used this code:
bool found = false;
for (int i = 0; i < stringAr.Count; i++)
{
found = (stringAr[i]).IndexOf(textBox2.Text) > -1;
if (found) break;
}
if (found && textBox2.Text != "")
{
label1.Text = "Found!";
}
else
{
label1.Text = "Not Found!";
}
I also allocate input h_A in host memory
string[] h_B = new string[N];
When i want to allocate in device memory and copy vectors from host memory to device memory
CudaDeviceVariable<string[]> d_B = h_B;
It gave me this error
The type 'string[]' must be a non-nullable value type in order to use it as parameter 'T' in the generic type or method 'CudaDeviceVariable<T>'
any help?
Based on the documentation and your error message, only non-nullable value type can be used with CudaDeviceVariable
.
Change stringAr
list to a char[]
(or byte[]
) array, and then allocate it on device by using CudaDeviceVariable
with generic parameter char (or byte).
EDIT1
Here is the code that change stringAr
to byte[]
array:
byte[] stringArAsBytes = stringAr
.SelectMany(s => System.Text.Encoding.ASCII.GetBytes(s))
.ToArray();
then try something like this:
CudaDeviceVariable<byte> d_data = stringArAsBytes;