/** * @brief Computes an array of the exponentials in the transport equation, * \f$ exp(-\frac{\Sigma_t * l}{sin(\theta)}) \f$, for each energy group * and polar angle for a given Track segment. * @param curr_segment pointer to the Track segment of interest * @param exponentials the array to store the exponential values */ void VectorizedSolver::computeExponentials(segment* curr_segment, FP_PRECISION* exponentials) { FP_PRECISION length = curr_segment->_length; FP_PRECISION* sigma_t = curr_segment->_material->getSigmaT(); /* Evaluate the exponentials using the linear interpolation table */ if (_interpolate_exponential) { FP_PRECISION tau; int index; for (int e=0; e < _num_groups; e++) { for (int p=0; p < _num_polar; p++) { tau = sigma_t[e] * length; index = round_to_int(tau * _inverse_exp_table_spacing); index *= _two_times_num_polar; exponentials(p,e) = (1. - (_exp_table[index+2 * p] * tau + _exp_table[index + 2 * p +1])); } } } /* Evalute the exponentials using the intrinsic exp(...) function */ else { int tid = omp_get_thread_num(); FP_PRECISION* sinthetas = _quad->getSinThetas(); FP_PRECISION* taus = &_thread_taus[tid*_polar_times_groups]; /* Initialize the tau argument for the exponentials */ for (int p=0; p < _num_polar; p++) { for (int v=0; v < _num_vector_lengths; v++) { #pragma simd vectorlength(VEC_LENGTH) for (int e=v*VEC_LENGTH; e < (v+1)*VEC_LENGTH; e++) taus(p,e) = -sigma_t[e] * length / sinthetas[p]; } } /* Evaluate the negative of the exponentials using Intel's MKL */ #ifdef SINGLE vsExp(_polar_times_groups, taus, exponentials); #else vdExp(_polar_times_groups, taus, exponentials); #endif /* Compute one minus the exponentials */ for (int p=0; p < _num_polar; p++) { for (int v=0; v < _num_vector_lengths; v++) { #pragma simd vectorlength(VEC_LENGTH) for (int e=v*VEC_LENGTH; e < (v+1)*VEC_LENGTH; e++) exponentials(p,e) = 1.0 - exponentials(p,e); } } } }
//vdExp Computation of the exponential of vector elements void klVSLExp(klVector<double>& v,klVector<double>& ans) { const __int64_t n = v.getColumns(); vdExp( n, v.getMemory(),ans.getMemory()); }
/** * @brief Computes an array of the exponentials in the transport equation, * \f$ exp(-\frac{\Sigma_t * l}{sin(\theta)}) \f$, for each energy group * and polar angle for a given Track segment. * @param curr_segment pointer to the Track segment of interest * @param exponentials the array to store the exponential values */ void VectorizedSolver::computeExponentials(segment* curr_segment, FP_PRECISION* exponentials) { FP_PRECISION length = curr_segment->_length; FP_PRECISION* sigma_t = curr_segment->_material->getSigmaT(); /* Evaluate the exponentials using the linear interpolation table */ if (_exp_evaluator->isUsingInterpolation()) { FP_PRECISION tau; for (int e=0; e < _num_groups; e++) { tau = length * sigma_t[e]; for (int p=0; p < _num_polar; p++) exponentials(p,e) = _exp_evaluator->computeExponential(tau, p); } } /* Evalute the exponentials using the intrinsic exp(...) function */ else { int tid = omp_get_thread_num(); FP_PRECISION* sin_thetas = _polar_quad->getSinThetas(); FP_PRECISION* taus = &_thread_taus[tid*_polar_times_groups]; /* Initialize the tau argument for the exponentials */ for (int p=0; p < _num_polar; p++) { for (int v=0; v < _num_vector_lengths; v++) { #pragma simd vectorlength(VEC_LENGTH) for (int e=v*VEC_LENGTH; e < (v+1)*VEC_LENGTH; e++) taus(p,e) = -sigma_t[e] * length; #pragma simd vectorlength(VEC_LENGTH) for (int e=v*VEC_LENGTH; e < (v+1)*VEC_LENGTH; e++) taus(p,e) /= sin_thetas[p]; } } /* Evaluate the negative of the exponentials using Intel's MKL */ #ifdef SINGLE vsExp(_polar_times_groups, taus, exponentials); #else vdExp(_polar_times_groups, taus, exponentials); #endif /* Compute one minus the exponentials */ for (int p=0; p < _num_polar; p++) { for (int v=0; v < _num_vector_lengths; v++) { #pragma simd vectorlength(VEC_LENGTH) for (int e=v*VEC_LENGTH; e < (v+1)*VEC_LENGTH; e++) exponentials(p,e) = 1.0 - exponentials(p,e); } } } }
/* * Class: com_intel_analytics_bigdl_mkl_MKL * Method: vdExp * Signature: (I[DI[DI)V */ JNIEXPORT void JNICALL Java_com_intel_analytics_bigdl_mkl_MKL_vdExp (JNIEnv * env, jclass cls, jint n, jdoubleArray a, jint aOffset, jdoubleArray y, jint yOffset) { jdouble * jni_a = (*env)->GetPrimitiveArrayCritical(env, a, JNI_FALSE); jdouble * jni_y = (*env)->GetPrimitiveArrayCritical(env, y, JNI_FALSE); vdExp( n, jni_a + aOffset, jni_y + yOffset); (*env)->ReleasePrimitiveArrayCritical(env, y, jni_y, 0); (*env)->ReleasePrimitiveArrayCritical(env, a, jni_a, 0); }
void PrecalcExponents(AppCtx* context, PetscScalar* coordinates) { int i; int nClusters = context->ci->mCurrentNumberOfClusters; int nTerminals = context->ci->terminalCells.size(); int nPrimaryPins = context->ci->primaryPins.size(); int count = (nClusters + nTerminals + nPrimaryPins) * 4; double* arguments = context->LSEdata.argsForPrecalcedExponents; PerformArgsAssignment(context, coordinates, arguments); #ifdef __MKL_VML_H__ int batchSize = context->LSEdata.batchSize; for (i = 0; i < count / batchSize; ++i) vdExp(batchSize, &arguments[i * batchSize], &context->LSEdata.precalcedExponents[i * batchSize]); vdExp(count % batchSize, &arguments[count - count % batchSize], &context->LSEdata.precalcedExponents[count - count % batchSize]); #else for (i = 0; i < count; ++i) context->LSEdata.precalcedExponents[i] = exp(arguments[i]); #endif }
void caffe_exp<double>(const int n, const double* a, double* y) { vdExp(n, a, y); }