/**
 * @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);
      }
    }
  }
}
/**
 * @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);
      }
    }
  }
}
Exemple #3
0
 /*
  * Class:     com_intel_analytics_bigdl_mkl_MKL
  * Method:    vsExp
  * Signature: (I[FI[FI)V
  */
 JNIEXPORT void JNICALL Java_com_intel_analytics_bigdl_mkl_MKL_vsExp
   (JNIEnv * env, jclass cls, jint n, jfloatArray a, jint aOffset, jfloatArray y,
   jint yOffset) {

  jfloat * jni_a = (*env)->GetPrimitiveArrayCritical(env, a, JNI_FALSE);
  jfloat * jni_y = (*env)->GetPrimitiveArrayCritical(env, y, JNI_FALSE);

  vsExp( n, jni_a + aOffset, jni_y + yOffset);

  (*env)->ReleasePrimitiveArrayCritical(env, y, jni_y, 0);
  (*env)->ReleasePrimitiveArrayCritical(env, a, jni_a, 0);
 }
Exemple #4
0
// To force linking in all needed Intel routines
// See compileCX for details (linking against .a)
void Dummy(void)
{
	vsAdd();
	vsSub();
	vsDiv();
	vsSqr();
	vsMul();
	vsAbs();
	vsInv();

	vsSin();   
	vsCos();   
	vsSinCos();
	vsTan();   
	vsAsin();  
	vsAcos();  
	vsAtan();  
	vsAtan2();

	vsSinh(); 
	vsCosh(); 
	vsTanh(); 
	vsAsinh();
	vsAcosh();
	vsAtanh();

	vsPow();    
	vsPowx();   
	vsSqrt();   
	vsCbrt();   
	vsInvSqrt();
	vsInvCbrt();
	vsHypot();

	vsFloor();   
	vsCeil();    
	vsRound();   
	vsTrunc();   
	vsRint();    
	vsNearbyInt();
	vsModf();

	vsExp();  	     
	vsLn();   
	vsLog10();

	vsErf();   
	vsErfc();  
	vsErfInv();
}
void caffe_exp<float>(const int n, const float* a, float* y) {
    vsExp(n, a, y);
}