Hi, I'm a beginner to the Brook+ development and I can't understand what is wrong with the code that follows:
kernel void calcular_integral(float input<>,float xo_g,float xf_g,float h,float num_processos,out float output<>
{
float tam;
float xo_l;
float xf_l;
float soma;
float nx;
float x;
float i;
tam = ((xf_g - xo_g)/num_processos);
xo_l = tam * input;
xf_l = (tam * input)+ tam;
nx = (xf_l - xo_l) / h;
soma = (xo_l * xo_l) + (xf_l * xf_l);
i = 1.0f;
for(; i < nx; i++)
{
x = (xo_l + (h * i));
soma += 2.0f *(x*x);
}
output = soma * (h/2.0f);
}
Please Help me. If you need more information than the code above, please tell me. The rest of my code executes perfectly, but when begins to execute the kernel code the following error occur :
Stream Write : Stream can't write to a NULL pointer.
I appreciate any help you can give me.
It seems the problem is not with your kernel code, but the host code. It is clear from the error that the pointer passed to streamWrite operator is NULL.
Could you post your host side code?
The host code is:
void Integral:reencherStream()
{
_input = (float*) malloc(sizeof(float));
for(int i = 0; i< _length; i++)
{
_input = (float)(i+1);
}
}
////////////////////////////////////////////////////////////////////////////////
//!
//! \brief backend implementation for the sample
//!
////////////////////////////////////////////////////////////////////////////////
bool Integral::run()
{
unsigned int retVal = 0;
const float h = 0.00000001f;
const float xo_g = 0.0f;
const float xo_f = 4.0f;
/////////////////////////////////////////////////////////////////////////
// Brook code block
/////////////////////////////////////////////////////////////////////////
{
unsigned int dim[] = {1};
::brook::Stream<float> inputStream(1, dim);
::brook::Stream<float> outputStream(1, dim);
unsigned int redDim[] = {1};
::brook::Stream<float> res(1, redDim);
PreencherStream();
inputStream.read(_input);
calcular_integral(inputStream,xo_g,xo_f,h (float)_length,outputStream);
outputStream.write(_output);
// Handle errors if any
if(outputStream.error())
{
std::cout << "Error occured" << std::endl;
std::cout << outputStream.errorLog() << std::endl;
retVal = -1;
}
streamWrite(res, &_result);
// Handle errors if any
if(res.error())
{
std::cout << "Error occured" << std::endl;
std::cout << res.errorLog() << std::endl;
retVal = -1;
}
}
/////////////////////////////////////////////////////////////////////////
// Print results
/////////////////////////////////////////////////////////////////////////
return true;
}
If you need any more information tell me. I'm appreciate the help you already gave to me.
Check the value of _output. It seems you have not allocated memory for it.
I did what you said, the new code is:
void Integral:reencherStream()
{
_input = (float*) malloc(sizeof(float));
_output = (float*) malloc(sizeof(float));
for(int i = 0; i< _length; i++)
{
_input = (float)(i+1);
}
}
But now the error is :
Stream Write : Unintialized stream.
I saw the examples that came with the Stream SDK and i think that my code is similar. What else could be missing ?
Where are you getting this error outputStream.errorLog() or res.errorLog()?
As you can see res is not an initialized stream (neither called streamRead nor its an output to kernel), hence you see this error.
I get the error in the res.errorLog, you are right that part i was not using it.
The new code is this :
bool Integral::run()
{
unsigned int retVal = 0;
const float h = 0.00000001f;
const float xo_g = 0.0f;
const float xo_f = 4.0f;
/////////////////////////////////////////////////////////////////////////
// Brook code block
/////////////////////////////////////////////////////////////////////////
{
unsigned int dim[] = {1};
::brook::Stream<float> inputStream(1, dim);
::brook::Stream<float> outputStream(1, dim);
PreencherStream();
inputStream.read(_input);
calcular_integral(inputStream,xo_g,xo_f,h,(float)_length,outputStream);
outputStream.write(_output);
// Handle errors if any
if(outputStream.error())
{
std::cout << "Error occured" << std::endl;
std::cout << outputStream.errorLog() << std::endl;
retVal = -1;
}
}
/////////////////////////////////////////////////////////////////////////
// Print results
/////////////////////////////////////////////////////////////////////////
return true;
}
The problem is that the error above was always present in the execution of my code:
"VPU Recover has reset your graphic accelerator as it was no longer responding to graphics driver commands"
My graphic card is the Ati HD 4830 with 512 Mb of Memory.
It has to be something wrong if my kernel code, right ? I don't know what to think.
Do you need more information ?
Thanks for your help so far.
Stream application require VPU recover to be disabled using Catalyst Control center on Windows system. Look at CAL FAQs point 1 under $(CALROOT)\CAL_Documentation
I read the document that you asked. But the ati2dvag still didn't respond. I think that my problem is simply a infinity loop in the Kernel Code. I will look in to that and if this do not work I will come back and tell you.
Thanks for your help so far.
Run with CPU backend to see if there is infinite loop in kernel. Set environment variable BRT_RUNTIME=cpu and run your application to use CPU runtime.
I'm using Visual Studio 2005, how can i do this ?
It has nothing to do with Visual Studio, you need to set the environment variable in your system. Also, make sure you close command prompt or visual studio application after setting env variable and then open it again.
Where can i find this environment variable ? In the documet from ATI it does not say.
Stream computing user guide : Section 2.1, 2.2.4