Intel® oneAPI Threading Building Blocks
Ask questions and share information about adding parallelism to your applications when using this threading library.

creating a concurrent_vector

Joseph_S_Intel
Employee
207 Views
I'd like to create a concurrent_vector that is initialized with a set number of structures (100), however I am not sure of the syntax to use. Is the code below correct? If not what is the correct code?

static struct bodytype {
double pos[3];
double vel[3];
double acc[3];
double mass;
int ThreadID;
} body

concurrent_vector cvbody(100);
0 Kudos
2 Replies
smasherprog
Beginner
207 Views
struct bodytype {
double pos[3];
double vel[3];
double acc[3];
double mass;
int ThreadID;
};

concurrent_vector cvbody(100);
cvbody.shrink_to_fit(); // this might be needed, I cant see the code for the internal_resize, but maybe someone else can comment.
0 Kudos
RafSchietekat
Valued Contributor III
207 Views
"cvbody.shrink_to_fit(); // this might be needed, I cant see the code for the internal_resize, but maybe someone else can comment."
shrink_to_fit() is only relevant after several separate additions might have fragmented the concurrent_vector, or to remove underlying storage altogether after clear(), so it has no purpose right after initialisation.
0 Kudos
Reply