-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
31 lines (26 loc) · 844 Bytes
/
main.cpp
File metadata and controls
31 lines (26 loc) · 844 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <iostream>
#include "Dispatcher.h"
#include "avx/interface.h"
#include "cpu/interface.h"
// Helper Function to print the values
std::ostream &operator<<(std::ostream &cout, const array &a)
{
auto data_ptr = a.storage.get();
auto len = a.n;
for (size_t i = 0; i < len; i++)
{
std::cout << data_ptr[i] << ",";
}
return cout;
}
int main()
{
Dispatcher op_dispatcher = Dispatcher{};
Dispatcher cpu_dispatcher = Dispatcher{};
cpu_dispatcher.use_cpu = true;
array x_arr{/*numel=*/12, /*fill_value=*/5};
array y_arr{/*numel=*/12, /*fill_value=*/4};
auto out_arr_avx = op_dispatcher.binary_dispatch(avx2::mul, cpu::mul)(x_arr, y_arr);
auto out_arr_cpu = cpu_dispatcher.binary_dispatch(avx2::mul, cpu::mul)(x_arr, y_arr);
std::cout << (out_arr_cpu == out_arr_avx) << "\n";
}