- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I'm having some troubles using VSL to compute a simple 2D convolution.
This snippet of code prints:
Thanks in andvance for your attention,
Corrado
I'm having some troubles using VSL to compute a simple 2D convolution.
[cpp]int err;
float *img, *krn, *ris;
VSLConvTaskPtr task;
int img_size[2], krn_size[2], ris_size[2];
int img_strd[2], krn_strd[2], ris_strd[2];
//Initializing dimensions and strides
//...
img = (float*) malloc(img_size[0]*img_size[1]*sizeof(float));
krn = (float*) malloc(krn_size[0]*krn_size[1]*sizeof(float));
ris_size[0] = img_size[0] + krn_size[0] - 1;
ris_size[1] = img_size[1] + krn_size[1] - 1;
ris = (float*) malloc(ris_size[0]*ris_size[1]*sizeof(float));
//Initializing images
//...
err = vslsConvNewTask(&task, VSL_CONV_MODE_AUTO, 2, img_size, krn_size, ris_size);
printf("CREATE ERROR = %dn", err);
err = vslsConvExec(task, img, img_strd, krn, krn_strd, ris, ris_strd);
printf("EXECUTION ERROR = %dn", err);
[/cpp]
This snippet of code prints:
[plain]CREATE ERROR = 0The last is the code of the VSL_CC_ERROR_DECIMATION but i didn't use any decimation! Even if I force decimation to be {1,1} I get the same error. What can I do?
EXECUTION ERROR = -2303[/plain]
Thanks in andvance for your attention,
Corrado
Link Copied
11 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Corrado,
It looks like you are not calling the vslConvSetStart routine to indicate which part of the result you are interested in.
I believe adding:
Best regards,
-Vladimir
It looks like you are not calling the vslConvSetStart routine to indicate which part of the result you are interested in.
I believe adding:
[cpp]int ris_start[2];will solve your issue.
//...
ris_start[0] = krn_size[0] - 1;
ris_start[1] = krn_size[1] - 1;
//...
err = vslConvSetStart( task, ris_start );
[/cpp]
Best regards,
-Vladimir
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - Vladimir Petrov (Intel)
Hello Corrado,
It looks like you are not calling the vslConvSetStart routine to indicate which part of the result you are interested in.
I believe adding:
Best regards,
-Vladimir
It looks like you are not calling the vslConvSetStart routine to indicate which part of the result you are interested in.
I believe adding:
[cpp]int ris_start[2];will solve your issue.
//...
ris_start[0] = krn_size[0] - 1;
ris_start[1] = krn_size[1] - 1;
//...
err = vslConvSetStart( task, ris_start );
[/cpp]
Best regards,
-Vladimir
Thank you for your reply, but even if vslConvSetStart doesn't return any error I actually get the same decimation related error when I execute the vslConvExec. Any other idea?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - iosonocorrado
Thank you for your reply, but even if vslConvSetStart doesn't return any error I actually get the same decimation related error when I execute the vslConvExec. Any other idea?
Best regards,
-Vladimir
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear Vladimir,
Thank you for your help, I solved my problem. The error arised from a bad setting of the dimension of the result array. I only would like that the error name would be a bit more meaningfull.
Just for you to know, if I set the the start as you suggested I get again the same error, than I think that in that case the size should be carefully altered.
Thank you again. Regards,
Corrado
Thank you for your help, I solved my problem. The error arised from a bad setting of the dimension of the result array. I only would like that the error name would be a bit more meaningfull.
Just for you to know, if I set the the start as you suggested I get again the same error, than I think that in that case the size should be carefully altered.
Thank you again. Regards,
Corrado
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Corrado,
It's great that you solved the problem. Jyst a few comments/questions to clarify the situation:
0. Your original code failed on my machine with -2323 if *_strd were not set
1. Your original code works fine on my machine if I replace *_strd with 0's (defaulting to unit strides). No problem with dimension of the result
2. My recomendation to set start was not correct since your original code computed all points of the convolution (img_size[0]+krn_size[0]-1)*(img_size[1]+krn_size[1]-1)
Best regards,
-Vladimir
It's great that you solved the problem. Jyst a few comments/questions to clarify the situation:
0. Your original code failed on my machine with -2323 if *_strd were not set
1. Your original code works fine on my machine if I replace *_strd with 0's (defaulting to unit strides). No problem with dimension of the result
2. My recomendation to set start was not correct since your original code computed all points of the convolution (img_size[0]+krn_size[0]-1)*(img_size[1]+krn_size[1]-1)
Best regards,
-Vladimir
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - Vladimir Petrov (Intel)
Corrado,
It's great that you solved the problem. Jyst a few comments/questions to clarify the situation:
0. Your original code failed on my machine with -2323 if *_strd were not set
1. Your original code works fine on my machine if I replace *_strd with 0's (defaulting to unit strides). No problem with dimension of the result
2. My recomendation to set start was not correct since your original code computed all points of the convolution (img_size[0]+krn_size[0]-1)*(img_size[1]+krn_size[1]-1)
Best regards,
-Vladimir
It's great that you solved the problem. Jyst a few comments/questions to clarify the situation:
0. Your original code failed on my machine with -2323 if *_strd were not set
1. Your original code works fine on my machine if I replace *_strd with 0's (defaulting to unit strides). No problem with dimension of the result
2. My recomendation to set start was not correct since your original code computed all points of the convolution (img_size[0]+krn_size[0]-1)*(img_size[1]+krn_size[1]-1)
Best regards,
-Vladimir
0. Does not setting *_strd mean passing to VSL uninitialized arrays of strides?
1. Does passing 0 as stride default to unitary stride in number of elements or in number of columns/rows?
2. Now that you I think about it I actually don't need to compute the whole convolution, so I could set the start and resize the output. Thank you ;-).
Thank you for all your attention.
Corrado
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear Corrado,
0. Does not setting *_strd mean passing to VSL uninitialized arrays of strides?
Exactly
1. Does passing 0 as stride default to unitary stride in number of elements or in number of columns/rows?
I'm not sure I understand the question. Passing NULL pointer should have the same effect as passing an array of 1's.
Best regards,
-Vladimir
0. Does not setting *_strd mean passing to VSL uninitialized arrays of strides?
Exactly
1. Does passing 0 as stride default to unitary stride in number of elements or in number of columns/rows?
I'm not sure I understand the question. Passing NULL pointer should have the same effect as passing an array of 1's.
Best regards,
-Vladimir
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear Vladimir,
I think it's simpler if I'll explain my doubt with an example. If I had an image NxM stored by rows I'd set the corrisponding stride to {1, N}. If the default (which at this point I no more know if is selected by a NULL pointer or an array of ones) is setting it to {1,1} I can only see bad things coming from it, am I wrong?
Moreover I read in the documentation that is an error passing 0 as stride, so I must think that the default is obtained by passing a NULL pointer, but I can't find documentation about it.
Thanks for attention. Regards
Corrado
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear Corrado,
I think I understand your concern now. Please note that strides in MKL's convolution do not correspond to the dimensions of the array. The strides set to {1,1} simply mean that all elements of the array are to be used in computation. Setting to {1,2} means that each second element along the second dimension is used in computation. Setting strides to {1,N} (as you suggest) would result in a 1D convolution along the first dimension. Please note that the size of the result has to be in synch with the strides.
Best regards,
-Vladimir
I think I understand your concern now. Please note that strides in MKL's convolution do not correspond to the dimensions of the array. The strides set to {1,1} simply mean that all elements of the array are to be used in computation. Setting to {1,2} means that each second element along the second dimension is used in computation. Setting strides to {1,N} (as you suggest) would result in a 1D convolution along the first dimension. Please note that the size of the result has to be in synch with the strides.
Best regards,
-Vladimir
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear Vladimir,
The Data Allocation subsection of the VSL section of the MKL Reference Manual I read speaks about strides. I confess that the examples at the end were quite hard to understand for me, but the theorical section seemed to me (perhaps wrongly) straightforward: What I understood is that if A is the linear index of x[i_1, i_2, ..., i_{k-1}, i_k, i_{k+1}, ..., i_n] and B is the same for x[i_1, i_2, ..., i_{k-1}, i_k + 1, i_{k+1}, ..., i_n] than A-B=stride. Am I wrong? Of course doubling the stride decimates the matrix by a factor 2 in the selected dimension, that is what I think you assert is obtained by setting the stride to 2. So my original question were: what is the "measure unit" of the stride? Linear indices, as I thought, or multiple of the corresponding dimension length, as it seems to me that you are affirming?
Thank you for your patience. Regards,
Corrado
The Data Allocation subsection of the VSL section of the MKL Reference Manual I read speaks about strides. I confess that the examples at the end were quite hard to understand for me, but the theorical section seemed to me (perhaps wrongly) straightforward: What I understood is that if A is the linear index of x[i_1, i_2, ..., i_{k-1}, i_k, i_{k+1}, ..., i_n] and B is the same for x[i_1, i_2, ..., i_{k-1}, i_k + 1, i_{k+1}, ..., i_n] than A-B=stride
Thank you for your patience. Regards,
Corrado
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear Corrado,
The stride in dimension k is measured in number of elements along this dimension k, which corresponds to linear affsets as follows:
linear_offsets[0] = 1*strides[0]
linear_offsets[1]= dims[0]*strides[1]
linear_offsets[2]= dims[0]*dims[1]*strides[2]
etc.
I hope that helps,
-Vladimir
The stride in dimension k is measured in number of elements along this dimension k, which corresponds to linear affsets as follows:
linear_offsets[0] = 1*strides[0]
linear_offsets[1]= dims[0]*strides[1]
linear_offsets[2]= dims[0]*dims[1]*strides[2]
etc.
I hope that helps,
-Vladimir

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page