Commit 6b052b35 authored by Leonardo Solis's avatar Leonardo Solis
Browse files

improved readability of gradient-norm calc

parent 478124ff
......@@ -66,10 +66,12 @@ bool is_gradDescent_enabled(
return *is_gradDescentEn;
}
float inner_product(__local float* vector1,
__local float* vector2,
void gradient_norm(
__local float* vector1,
uint inputSize,
__local float* init) {
__local float* init,
__local float* inner_product
) {
float temp = 0.0f;
......@@ -77,10 +79,11 @@ float inner_product(__local float* vector1,
for(uint i = get_local_id(0);
i < inputSize;
i+= NUM_OF_THREADS_PER_BLOCK) {
init[i] = vector1[i] * vector2[i];
init[i] = vector1[i] * vector1[i];
}
// Accumulating dot product
// Accumulating dot product,
// and then getting the norm
if(get_local_id(0) == 0) {
for(uint i = 0;
i < inputSize;
......@@ -88,11 +91,7 @@ float inner_product(__local float* vector1,
temp += init[i];
}
init [0] = temp;
*inner_product = native_sqrt(temp);
}
barrier(CLK_LOCAL_MEM_FENCE);
return init[0];
}
......@@ -168,7 +168,6 @@ gradient_minimizer(
__local float gradient_intra_z[MAX_NUM_OF_ATOMS];
__local float gradient_per_intracontributor[MAX_INTRAE_CONTRIBUTORS];
// -------------------------------------------------------------------
// Variables to store partial energies
......@@ -266,11 +265,7 @@ gradient_minimizer(
}
// Storing the norm of all gradients
local_gNorm = inner_product(local_gradient, local_gradient, dockpars_num_of_genes, dotProduct);
if (get_local_id(0) == 0) {
local_gNorm = native_sqrt(local_gNorm);
}
gradient_norm(local_gradient, dockpars_num_of_genes, dotProduct, &local_gNorm);
barrier(CLK_LOCAL_MEM_FENCE);
......@@ -353,10 +348,12 @@ gradient_minimizer(
async_work_group_copy(dockpars_conformations_next+(run_id*dockpars_pop_size+entity_id)*GENOTYPE_LENGTH_IN_GLOBMEM,
local_genotype,
dockpars_num_of_genes,0);
dockpars_num_of_genes, 0);
// FIXME: maybe not used outside?
// Copying final "local" results into "global" memory
/*
local_nIter = local_nIter - 1;
*/
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment