Welcome, Guest
Guest Settings
Help

Thread: Using TParallel.For from the Parallel Programming Library



Permlink Replies: 3 - Last Post: Apr 27, 2017 8:30 AM Last Post By: Remy Lebeau (Te... Threads: [ Previous | Next ]
boualem Ait Mes...

Posts: 2
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: 7,926
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: 2
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: 7,926
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)
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02