mirror of
https://github.com/NVIDIA/nvbench.git
synced 2026-03-14 20:27:24 +00:00
Add float64_axis.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
set(srcs
|
||||
axis_base.cu
|
||||
float64_axis.cu
|
||||
type_axis.cu
|
||||
int64_axis.cu
|
||||
)
|
||||
|
||||
17
nvbench/float64_axis.cu
Normal file
17
nvbench/float64_axis.cu
Normal file
@@ -0,0 +1,17 @@
|
||||
#include <nvbench/float64_axis.cuh>
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
||||
namespace nvbench
|
||||
{
|
||||
|
||||
float64_axis::~float64_axis() = default;
|
||||
|
||||
std::string float64_axis::do_get_input_string(std::size_t i) const
|
||||
{
|
||||
return fmt::to_string(m_values[i]);
|
||||
}
|
||||
|
||||
std::string float64_axis::do_get_description(std::size_t i) const { return {}; }
|
||||
|
||||
} // namespace nvbench
|
||||
38
nvbench/float64_axis.cuh
Normal file
38
nvbench/float64_axis.cuh
Normal file
@@ -0,0 +1,38 @@
|
||||
#pragma once
|
||||
|
||||
#include <nvbench/axis_base.cuh>
|
||||
|
||||
#include <nvbench/types.cuh>
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace nvbench
|
||||
{
|
||||
|
||||
struct float64_axis final : public axis_base
|
||||
{
|
||||
explicit float64_axis(std::string name)
|
||||
: axis_base{std::move(name), axis_type::float64}
|
||||
, m_values{}
|
||||
{}
|
||||
|
||||
~float64_axis() final;
|
||||
|
||||
void set_inputs(std::vector<nvbench::float64_t> inputs)
|
||||
{
|
||||
m_values = std::move(inputs);
|
||||
}
|
||||
[[nodiscard]] nvbench::float64_t get_value(std::size_t i) const
|
||||
{
|
||||
return m_values[i];
|
||||
}
|
||||
|
||||
private:
|
||||
std::size_t do_get_size() const final { return m_values.size(); }
|
||||
std::string do_get_input_string(std::size_t i) const final;
|
||||
std::string do_get_description(std::size_t i) const final;
|
||||
|
||||
std::vector<nvbench::float64_t> m_values;
|
||||
};
|
||||
|
||||
} // namespace nvbench
|
||||
@@ -1,9 +1,12 @@
|
||||
set(test_srcs
|
||||
int64_axis.cu
|
||||
float64_axis.cu
|
||||
type_axis.cu
|
||||
type_list.cu
|
||||
)
|
||||
|
||||
enable_testing()
|
||||
|
||||
foreach(test_src IN LISTS test_srcs)
|
||||
get_filename_component(test_name "${test_src}" NAME_WLE)
|
||||
string(PREPEND test_name "nvbench.test.")
|
||||
@@ -11,5 +14,5 @@ foreach(test_src IN LISTS test_srcs)
|
||||
target_include_directories(${test_name} PRIVATE "${CMAKE_CURRENT_LIST_DIR}")
|
||||
target_link_libraries(${test_name} PRIVATE nvbench fmt)
|
||||
set_target_properties(${test_name} PROPERTIES COMPILE_FEATURES cuda_std_17)
|
||||
add_test(NAME ${test_name} COMMAND "$<TARGET_FILE:${test_target}>")
|
||||
add_test(NAME ${test_name} COMMAND "$<TARGET_FILE:${test_name}>")
|
||||
endforeach()
|
||||
|
||||
@@ -1,4 +1,40 @@
|
||||
//
|
||||
// Created by allie on 12/22/2020.
|
||||
//
|
||||
#include <nvbench/float64_axis.cuh>
|
||||
|
||||
#include "test_asserts.cuh"
|
||||
|
||||
void test_empty()
|
||||
{
|
||||
nvbench::float64_axis axis("Empty");
|
||||
ASSERT(axis.get_name() == "Empty");
|
||||
ASSERT(axis.get_type() == nvbench::axis_type::float64);
|
||||
ASSERT(axis.get_size() == 0);
|
||||
|
||||
axis.set_inputs({});
|
||||
|
||||
ASSERT(axis.get_size() == 0);
|
||||
}
|
||||
|
||||
void test_basic()
|
||||
{
|
||||
nvbench::float64_axis axis("Basic");
|
||||
ASSERT(axis.get_name() == "Basic");
|
||||
|
||||
axis.set_inputs({-100.3, 0., 2064.15});
|
||||
|
||||
ASSERT(axis.get_size() == 3);
|
||||
ASSERT(axis.get_value(0) == -100.3);
|
||||
ASSERT(axis.get_input_string(0) == "-100.3");
|
||||
ASSERT(axis.get_description(0) == "");
|
||||
ASSERT(axis.get_value(1) == 0.);
|
||||
ASSERT(axis.get_input_string(1) == "0");
|
||||
ASSERT(axis.get_description(1) == "");
|
||||
ASSERT(axis.get_value(2) == 2064.15);
|
||||
ASSERT(axis.get_input_string(2) == "2064.15");
|
||||
ASSERT(axis.get_description(2) == "");
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test_empty();
|
||||
test_basic();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user