User Defined Types

User Defined Types

jasno's picture

The documentation says that I can have user defined types as long as I follow a few basic rules
"

  • The type has a public default constructor, copy constructor,
    assignment operator and non-virtual destructor. All of these functions
    must be either implicitly declared or behave as if they were implicitly
    declared.
  • All non-static member variables of the types must be instances of
    Intel ArBB scalar types, container types, or other valid user-defined
    types.
  • If the type has any base classes, they must be valid user-defined types as well."

and then goes on to give an example that has no public default constructor, copy constructor,
assignment operator and non-virtual destructor and also uses just scalar types. Do you have any more complex examples ? None of the sample code uses UDTs.

Anyway, I plowed on and got this far creating a simple class of my own which compiles

class UDT1 {

public:

UDT1(){return;}

UDT1(long long v10, long long v11,long long v12, long long v20, long long v21,long long v22) {
v1[0] = v10; v1[1] = v11; v1[2] = v12;
v2[0] = v20; v2[1] = v21; v2[2] = v22;
return;
}
~UDT1() { return; }

const arbb::array getV1() {return v1;}
const arbb::array getV2() {return v2;}

private:
arbb::array v1;
arbb::array v2;

};

until I add the following

ARBB_ELTWISE_METHOD_0(const arbb::array,UDT1,getV1);

to try to list its methods. At this point I get the following error
test2.cpp:90:64: error: macro "ARBB_ELTWISE_METHOD_0" passed 4 arguments, but takes just 3
test2.cpp:90:1: error: ARBB_ELTWISE_METHOD_0 does not name a type

because obviously the macro is stealing the , I use in the return type and thinks its splitting two of
its arguments. Did I do something wrong? If I try to leave out the size of the return array it doesn't like
that eather . . .

--
jason

4 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.
Zhang Z (Intel)'s picture

Jason,

The problem is because you have a comma in the return type of the macro. I'd suggest you use the following technique to make it work:

typedef arbb::array Tuple3ul;
ARBB_ELTWISE_METHOD_0(const Tuple3ul, UDT1, getV1);

Actually, you can put the typedef before the definition of class UDT1 such that you can use the Tuple3ul type inside the class, saving you some typing. ;)

Thanks,
Zhang

jasno's picture

Ahhh, thanks, good idea. I'd realised the problem, if not the solution.

BTW, in
http://software.intel.com/sites/products/documentation/arbb/arbb_manual_...
section Modules->Control Flow->Defines you have the following code snippet

 // Initialize i to zero, and keep incrementing until it reaches a million.
 _for(i32 i = 0, i < 1000000; ++i) {
   // This code executes a million times.
   some_function(i);
 } _end_for;

I don't think you mean to have the ; after 100000 but rather a comma ?

--
jason

Zhang Z (Intel)'s picture

Jason,

Nice catch. It should have been a comma instead of a semicolon. We will have it fixed in the next revision of the online documentation.

Zhang

Login to leave a comment.