Commit 5c3bb1b3 authored by cianciosa's avatar cianciosa
Browse files

The solver test wasn't syncing values. Check directly from the gpu buffers...

The solver test wasn't syncing values. Check directly from the gpu buffers instead. Account for arc when initalizing rays.
parent 4062d5fc
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -74,7 +74,8 @@ void trace_ray(const size_t num_times,

                for (size_t j = 0; j < local_num_rays; j++) {
                    omega->set(j, static_cast<T> (norm_dist1(engine)));
                    y->set(j, static_cast<T> (norm_dist2(engine)));
                    x->set(j, static_cast<T> (2.5*cos(norm_dist2(engine)/2.5)));
                    y->set(j, static_cast<T> (2.5*sin(norm_dist2(engine)/2.5)));
                    z->set(j, static_cast<T> (norm_dist2(engine)));
                    ky->set(j, static_cast<T> (norm_dist3(engine)));
                    kz->set(j, static_cast<T> (norm_dist4(engine)));
@@ -91,13 +92,13 @@ void trace_ray(const size_t num_times,

                for (size_t j = 0; j < local_num_rays; j++) {
                    omega->set(j, static_cast<T> (norm_dist1(engine)));
                    y->set(j, static_cast<T> (norm_dist2(engine)));
                    x->set(j, static_cast<T> (2.5*cos(norm_dist2(engine)/2.5)));
                    y->set(j, static_cast<T> (2.5*sin(norm_dist2(engine)/2.5)));
                    z->set(j, static_cast<T> (norm_dist2(engine)));
                    ky->set(j, static_cast<T> (norm_dist3(engine)));
                    kz->set(j, static_cast<T> (norm_dist4(engine)));
                }
            }
            x->set(static_cast<T> (2.5));
            kx->set(static_cast<T> (-700));

            auto eq = equilibrium::make_efit<T, SAFE_MATH> (NC_FILE);
@@ -249,7 +250,7 @@ void calculate_power(const size_t num_times,
                     stream.str(), local_num_rays, thread_number);
            root.compile();
            
            for (size_t j = 0; j < num_steps; j++) {
            for (size_t j = 0, je = num_steps + 1; j < je; j++) {
                root.run(j);
            }
        }, i, threads.size());
+1 −1
Original line number Diff line number Diff line
@@ -140,7 +140,7 @@ namespace absorption {
            inputs.push_back(graph::variable_cast(this->t));
            inputs.push_back(graph::variable_cast(this->w));

            solver::newton(work, {kamp}, inputs, {D.get_d()*D.get_d()});
            solver::newton(work, {kamp}, inputs, {D.get_d()});
        }

//------------------------------------------------------------------------------
+12 −0
Original line number Diff line number Diff line
@@ -246,6 +246,18 @@ namespace gpu {
            std::cout << std::endl;
        }

//------------------------------------------------------------------------------
///  @brief Check the value.
///
///  @params[in] index Ray index to check value for.
///  @params[in] node  Node to check the value for.
///  @returns The value at the index.
//------------------------------------------------------------------------------
        T check_value(const size_t index,
                      const graph::shared_leaf<T, SAFE_MATH> &node) {
            return kernel_arguments[node.get()][index];
        }

//------------------------------------------------------------------------------
///  @brief Copy buffer contents to the device.
///
+13 −0
Original line number Diff line number Diff line
@@ -390,6 +390,19 @@ namespace gpu {
            std::cout << std::endl;
        }

//------------------------------------------------------------------------------
///  @brief Check the value.
///
///  @params[in] index Ray index to check value for.
///  @params[in] node  Node to check the value for.
///  @returns The value at the index.
//------------------------------------------------------------------------------
        T check_value(const size_t index,
                      const graph::shared_leaf<T, SAFE_MATH> &node) {
            wait();
            return reinterpret_cast<T *> (kernel_arguments[node.get()])[index];
        }

//------------------------------------------------------------------------------
///  @brief Copy buffer contents to the device.
///
+2 −3
Original line number Diff line number Diff line
@@ -159,20 +159,19 @@ namespace dispersion {
              const size_t index=0,
              const typename DISPERSION_FUNCTION::base tolarance = 1.0E-30,
              const size_t max_iterations = 1000) {
            auto loss = D*D;
            auto x_var = graph::variable_cast(x);

            workflow::manager<typename DISPERSION_FUNCTION::base,
                              DISPERSION_FUNCTION::safe_math> work(index);

            solver::newton(work, {x}, inputs, loss, tolarance, max_iterations);
            solver::newton(work, {x}, inputs, this->D, tolarance, max_iterations);

            work.compile();
            work.run();

            work.copy_to_host(x, x_var->data());

            return loss;
            return this->D*this->D;
        }

//------------------------------------------------------------------------------
Loading