Watch, Follow, &
Connect with Us

Please visit our new home
community.embarcadero.com.


Welcome, Guest
Guest Settings
Help

Thread: Using TParallel.For from the Parallel Programming Library



Permlink Replies: 6 - Last Post: May 6, 2017 8:49 AM Last Post By: boualem Ait Mes... Threads: [ Previous | Next ]
boualem Ait Mes...

Posts: 12
Registered: 4/19/17
Using TParallel.For from the Parallel Programming Library
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 20, 2017 8:01 AM
My error:
[bcc32 Erreur] Unit66666.cpp(934): E2285 Impossible de trouver une correspondance pour 'TParallel::For(int,int,unsigned int,void)'

//----------------------------------------------------------------My source Code-------------------------------------------------------------------------------------------------------

void __fastcall TForm66666::Button6Click(TObject *Sender)
{
if (Edit11->Text=="" || Edit12->Text=="" || Edit13->Text=="" )

ShowMessage("Vous devez remplir tous les champs");

nb_x=Edit11->Text.ToInt();
nb_y=Edit12->Text.ToInt();
nb_z=Edit13->Text.ToInt();

pas_x= (brut_cellule.getxmax()-brut_cellule.getxmin())/nb_x ;
pas_y= (brut_cellule.getymax()-brut_cellule.getymin())/nb_y ;
pas_z= (brut_cellule.getzmax()-brut_cellule.getzmin())/nb_z ;

Edit16->Text=FormatFloat("0.000",pas_x);
Edit15->Text=FormatFloat("0.000",pas_y);
Edit14->Text=FormatFloat("0.000",pas_z);


//vector< vector<cellule_parallele_T> > tab_cel(x*y*z);
tab_cellules = new cellule_parallele_T **[nb_x];
for (int i = 0; i < nb_x; i++)
{
tab_cellules[i]= new cellule_parallele_T *[nb_y];
for(int j=0;j<nb_y;j++)
{
tab_cellules[i][j]= new cellule_parallele_T[nb_z];
}
}

Randomize();

for (int i = 0; i < nb_x; i++)

for (int j = 0; j < nb_y; j++)

for (int k = 0; k < nb_z; k++)

{
tab_cellules[i][j][k].setxmin(brut_cellule.getxmin()+pas_x*i);
tab_cellules[i][j][k].setxmax(tab_cellules[i][j][k].getxmin()+pas_x);

tab_cellules[i][j][k].setymin(brut_cellule.getymin()+pas_y*j);
tab_cellules[i][j][k].setymax(tab_cellules[i][j][k].getymin()+pas_y);

tab_cellules[i][j][k].setzmin(brut_cellule.getzmin()+pas_z*k);
tab_cellules[i][j][k].setzmax(tab_cellules[i][j][k].getzmin()+pas_z);

tab_cellules[i][j][k].choix_couleur();
}

TParallel::For(NULL,0,Tab_points.size()-1,MYiteratorEvent) ;

}
//---------------------------------------------------------------------------

void TForm66666::MYiteratorEvent(TObject *Sender,int AIndex)
{
int indice_I=(int) ((Tab_points[AIndex].getx() - brut_cellule.getxmin())/pas_x);
if(indice_I==nb_x) indice_I--;

int indice_J=(int) ((Tab_points[AIndex].gety() - brut_cellule.getymin())/pas_y);
if(indice_J==nb_y) indice_J--;

int indice_K=(int) ((Tab_points[AIndex].getz() - brut_cellule.getzmin())/pas_z);
if(indice_K==nb_z) indice_K--;

tab_cellules[indice_I][indice_J][indice_K].inserer_point(Tab_points[AIndex]);

}

Edited by: boualem Ait Messaoudene on Apr 20, 2017 8:01 AM

Remy Lebeau (Te...


Posts: 8,921
Registered: 12/23/01
Re: Using TParallel.For from the Parallel Programming Library [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 20, 2017 9:25 AM   in response to: boualem Ait Mes... in response to: boualem Ait Mes...
boualem wrote:

My error:
[bcc32 Erreur] Unit66666.cpp(934): E2285 Impossible de trouver une
correspondance pour 'TParallel::For(int,int,unsigned int,void)'

Roughly translated:

E2285 Unable to find a match for 'TParallel::For(int,int,unsigned int,void)'

That means your call to TParallel::For() does not match any of the (many)
overloads available of For():

http://docwiki.embarcadero.com/Libraries/en/System.Threading.TParallel.For

If you look closely, you will see that the 3rd parameter is problematic.
Tab_points.size() is a size_t, which is an unsigned int, but For() expects
a signed int instead. So, you need to type-cast that value, eg:

TParallel::For(NULL, 0, (int)(Tab_points.size()-1), MYiteratorEvent);


Alternatively:

TParallel::For(NULL, 0, static_cast<int>(Tab_points.size()-1), MYiteratorEvent);


If that still does not compile, try also adding the '&' address operator
when passing MYiteratorEvent:

TParallel::For(..., &MYiteratorEvent);


--
Remy Lebeau (TeamB)
boualem Ait Mes...

Posts: 12
Registered: 4/19/17
Re: Using TParallel.For from the Parallel Programming Library [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 26, 2017 10:28 PM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Remy Lebeau (TeamB) wrote:
boualem wrote:

My error:
[bcc32 Erreur] Unit66666.cpp(934): E2285 Impossible de trouver une
correspondance pour 'TParallel::For(int,int,unsigned int,void)'

Roughly translated:

E2285 Unable to find a match for 'TParallel::For(int,int,unsigned int,void)'

That means your call to TParallel::For() does not match any of the (many)
overloads available of For():

http://docwiki.embarcadero.com/Libraries/en/System.Threading.TParallel.For

If you look closely, you will see that the 3rd parameter is problematic.
Tab_points.size() is a size_t, which is an unsigned int, but For() expects
a signed int instead. So, you need to type-cast that value, eg:

TParallel::For(NULL, 0, (int)(Tab_points.size()-1), MYiteratorEvent);


Alternatively:

TParallel::For(NULL, 0, static_cast<int>(Tab_points.size()-1), MYiteratorEvent);


If that still does not compile, try also adding the '&' address operator
when passing MYiteratorEvent:

TParallel::For(..., &MYiteratorEvent);


--
Remy Lebeau (TeamB)

thank you very much the solution was to add '&' address operator when passing MYiteratorEvent
sorry for asking too many questions but this is new for me
i want to make a nested parallel for like this :"
for(int I=1;I<=Max;I++){
for(int J=1;J<=Max;J++)
.
.
.
}
is that possible with the TParallel::For ??
thanks again !
Remy Lebeau (Te...


Posts: 8,921
Registered: 12/23/01
Re: Using TParallel.For from the Parallel Programming Library [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 27, 2017 8:30 AM   in response to: boualem Ait Mes... in response to: boualem Ait Mes...
boualem wrote:

i want to make a nested parallel for like this :"

for(int I=1;I<=Max;I++){
for(int J=1;J<=Max;J++)
.
.
.
}

is that possible with the TParallel::For ??

Hard to say without seeing the complete loop. You could try calling TParallel::For()
from inside of MYiteratorEvent(). Or you can try flattening the two loops
into a single loop using something like this:

for(int x = 1; x <= (Max*Max); x++)
{
    int I = x / Max;
    int J = x % Max;
    ...
}


--
Remy Lebeau (TeamB)
boualem Ait Mes...

Posts: 12
Registered: 4/19/17
Re: Using TParallel.For from the Parallel Programming Library [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 29, 2017 8:10 AM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Remy Lebeau (TeamB) wrote:
boualem wrote:

i want to make a nested parallel for like this :"

for(int I=1;I<=Max;I++){
for(int J=1;J<=Max;J++)
.
.
.
}

is that possible with the TParallel::For ??

Hard to say without seeing the complete loop. You could try calling TParallel::For()
from inside of MYiteratorEvent(). Or you can try flattening the two loops
into a single loop using something like this:

for(int x = 1; x <= (Max*Max); x++)
{
    int I = x / Max;
    int J = x % Max;
    ...
}


--
Remy Lebeau (TeamB)

i have tried the first solution of calling it inside of MYiteratorEvent() but it didn't work for me can you give me an example or more explication of how to do it ?
and the solution you proposed work for two loops but what if i have three loop ?

thanks again for answring me

Edited by: boualem Ait Messaoudene on May 3, 2017 2:22 AM

Edited by: boualem Ait Messaoudene on May 3, 2017 2:24 AM

Remy Lebeau (Te...


Posts: 8,921
Registered: 12/23/01
Re: Using TParallel.For from the Parallel Programming Library [Edit][Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 3, 2017 9:47 AM   in response to: boualem Ait Mes... in response to: boualem Ait Mes...
boualem wrote:

i have tried the first solution of calling it inside of
MYiteratorEvent() but it didn't work for me

In what way exactly? Please show your actual code, before and after introducing
TParallel.For() into it.

--
Remy Lebeau (TeamB)
boualem Ait Mes...

Posts: 12
Registered: 4/19/17
Re: Using TParallel.For from the Parallel Programming Library [Edit][Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 6, 2017 8:49 AM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Remy Lebeau (TeamB) wrote:
boualem wrote:

i have tried the first solution of calling it inside of
MYiteratorEvent() but it didn't work for me

In what way exactly? Please show your actual code, before and after introducing
TParallel.For() into it.

--
Remy Lebeau (TeamB)

befor :
for (int i = 0; i < nb_x; i++)
 
	   for (int j = 0; j < nb_y; j++)
 
	   for (int k = 0; k < nb_z; k++)
 
	   {
	   sous_nuages[i][j][k].setxmin(donnees_initiales.getxmin()+pas_x*i);
	   sous_nuages[i][j][k].setxmax(sous_nuages[i][j][k].getxmin()+pas_x);
 
	   sous_nuages[i][j][k].setymin(donnees_initiales.getymin()+pas_y*j);
	   sous_nuages[i][j][k].setymax(sous_nuages[i][j][k].getymin()+pas_y);
 
	   sous_nuages[i][j][k].setzmin(donnees_initiales.getzmin()+pas_z*k);
	   sous_nuages[i][j][k].setzmax(sous_nuages[i][j][k].getzmin()+pas_z);
 
	   sous_nuages[i][j][k].choix_couleur();
	   }
 


after:


TParallel::For(Sender,0,nb_x*nb_y*nb_z-1,creation_sous_nuages);
 
 
void  __fastcall TForm66666::creation_sous_nuages(TObject *Sender, int numero)
	   {
 
	   int i,j,k;
	   k = (int)(numero)/((nb_x*nb_y));
	   j=  (int) ((numero %(nb_x*nb_y))/nb_x);
	   i =  ((numero %(nb_x*nb_y))%nb_x);
 
 
 
	   sous_nuages[i][j][k].setxmin(donnees_initiales.getxmin()+pas_x*i);
	   sous_nuages[i][j][k].setxmax(sous_nuages[i][j][k].getxmin()+pas_x);
 
	   sous_nuages[i][j][k].setymin(donnees_initiales.getymin()+pas_y*j);
	   sous_nuages[i][j][k].setymax(sous_nuages[i][j][k].getymin()+pas_y);
 
	   sous_nuages[i][j][k].setzmin(donnees_initiales.getzmin()+pas_z*k);
	   sous_nuages[i][j][k].setzmax(sous_nuages[i][j][k].getzmin()+pas_z);
 
	   }


and in form i have :
class brut_parallele_T{
	private :
	double xmax;
	double xmin;
	double ymax;
	double ymin;
	double zmax;
	double zmin;
 
	vector<point_parallele_T> tab_points;
....
....
 
}
 
brut_parallele_T   donnees_initiales;
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02