Can't access certain neighbor() using map()

Can't access certain neighbor() using map()

Hi,

In applying a map to a dense container I can succesfully access north, south, east and west neighbors.
However, when trying to access other neighbors like:

do_main() {
  dense v;
  call(doSomething)(v, 5, 5);
}

void doSomething(dense& v, usize vec_width, usize vec_height) {
   map(mapFunction)(v, vec_width, vec_height);
}

void mapFunction(f32& in, usize vec_width, usize vec_height) {

  array coord;
 position(coord);
 usize x = coord.at(0);
 usize y = coord.at(1);

   _if (x==0 || x == (vec_width -1) || y==0 || y == (vec_height-1)) {
      in = in;
   } _else {
     in = neighbor(in, -1, -1);
   } _end_if
}

I get Error: caught unexpected exception. COMP_ERROR: Dynamic Compiler Internal Error.

The code does work when setting ARBB_OPT_LEVEL=O0. But other values for ARBB_OPT_LEVEL give the same error. And it doesn't work for any of the directions: (northwest, southwest, northeast, southeast). Any idea on how this can be possible?

Writing things like this in mapFunction() does work:
f32 temp = neighbor(in, -1, -1) + neighbor(in, 1, 1);

The error occurs when trying to assign to 'in'. So in=temp; also gives the same error.

I tried not using 'in' and 'v' as both input and output but this didn't make a difference.

Thanks

4 帖子 / 0 全新
最新文章
如需更全面地了解编译器优化,请参阅优化注意事项
Zhang Z (Intel)的头像

I think the problem is because the 2D dense 'v' in your example was not initialized. When you declared it you did not give a size for each dimension. I changed the 'do_main' function slightly as below, and the whole thing worked out fine for me:

void do_main()
{
    dense v(5, 5);
    call(doSomething)(v, 5, 5);
}

Please let me know if this solves the problem for you. Thanks!

Hi,

In the real code it was initialized. Here is a complete simple example that crashes with me:

#include 
using namespace arbb;

void mapFunction(f32& in, usize vec_width, usize vec_height) { 

   array coord; 
   position(coord); 
   usize x = coord.at(0); 
   usize y = coord.at(1); 



    _if (x==0 || x == (vec_width -1) || y==0 || y == (vec_height-1)) { 
       in = in; 
    } _else { 
      in = neighbor(in,1,-1);
    } _end_if
 }

void doSomething(dense& v, usize vec_width, usize vec_height) { 
    map(mapFunction)(v, vec_width, vec_height); 
 } 

void do_main() {
  dense v(5,5);
  v=fill(1,5,5);
  call(doSomething)(v, 5, 5); 
  //print(v, 5, 5);
}


int main() {
   try {
     do_main();
   } catch (const std::exception& e) {
	std::cerr << "Error: caught unexpected exception." << std::endl;
 	std::cerr << "t" << e.what() << std::endl;
	return 1;
   } catch (...) {
	std::cerr << "Error: caught unexpected exception" << std::endl;
 	std::cerr << "t" << "" << std::endl;
 	return 1;
   }

}

I use Arbb 1.0.0.015 (latest?), in ubuntu 32-bit in VMWare on 64-bit windows 7. I haven't had any other issues.

Zhang Z (Intel)的头像

Hi, sorry for delayed response. After some investigation, this turned out to be a bug. There is an issue when branch statements are used within a map kernel function, along with position() and neighbor(). The Intel ArBB engineering team is now aware of the problem, and actively working on it.

Thanks,
Zhang

登陆并发表评论。