- Oct 28, 2005
- 9,840
- 6
- 71
I am playing around with using OpenMP to speed up the execution of some for loops in a main and I need to use firstprivate on a class object. firstprivate requires that:
A variable specified in a firstprivate clause must not have an incomplete type or a reference type.
A variable with a class type that is specified as firstprivate must have an accessible, unambiguous copy constructor.
Variables that are private within a parallel region or that appear in the reduction clause of a parallel directive cannot be specified in a firstprivate clause on a work-sharing directive that binds to the parallel construct.
http://msdn.microsoft.com/en-us/library/d179faxw.aspx
What I was wondering about is in regards to the first rule. The class object that I am specifying in firstprivate is a class object that contains functions that pass by reference. The variable itself is not a reference type but the class itself passes reference types, is this still valid or not? The program is wigging out when I run it in parallel and I think it maybe due to problems arising in the portions that are passing by reference.
A variable specified in a firstprivate clause must not have an incomplete type or a reference type.
A variable with a class type that is specified as firstprivate must have an accessible, unambiguous copy constructor.
Variables that are private within a parallel region or that appear in the reduction clause of a parallel directive cannot be specified in a firstprivate clause on a work-sharing directive that binds to the parallel construct.
http://msdn.microsoft.com/en-us/library/d179faxw.aspx
What I was wondering about is in regards to the first rule. The class object that I am specifying in firstprivate is a class object that contains functions that pass by reference. The variable itself is not a reference type but the class itself passes reference types, is this still valid or not? The program is wigging out when I run it in parallel and I think it maybe due to problems arising in the portions that are passing by reference.
