Quick Start#
The quick start sample below shows how to compute CRC on the data using Intel® Data Mover Library (Intel® DML). See CRC Generation operation for more information.
/*******************************************************************************
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
******************************************************************************/
#include <dml/dml.hpp>
#include <iostream>
#include <string>
#include <vector>
constexpr auto string = "Calculate CRC value for this string...\n";
template <typename path>
int execute_crc() {
std::cout << "Starting dml::crc example...\n";
std::cout << string;
// Prepare data
auto crc_seed = std::uint32_t(0u);
auto src = std::basic_string<std::uint8_t>(reinterpret_cast<const std::uint8_t *>(string));
// Run operation
auto result = dml::execute<path>(dml::crc, dml::make_view(src), crc_seed);
// Check result
if (result.status == dml::status_code::ok) {
std::cout << "Finished successfully. Calculated CRC is: 0x" << std::hex << result.crc_value << std::dec << std::endl;
}
else {
std::cout << "Failure occurred." << std::endl;
return -1;
}
return 0;
}
int main(int argc, char **argv)
{
if (argc < 2) {
std::cout << "Missing the execution path as the first parameter."
<< "Use hardware_path, software_path or automatic_path." << std::endl;
return 1;
}
std::string path = argv[1];
if (path == "hardware_path") {
std::cout << "Executing using dml::hardware path" << std::endl;
return execute_crc<dml::hardware>();
}
else if (path == "software_path") {
std::cout << "Executing using dml::software path" << std::endl;
return execute_crc<dml::software>();
}
else if (path == "auto_path") {
std::cout << "Executing using dml::automatic path" << std::endl;
return execute_crc<dml::automatic>();
}
else {
std::cout << "Unrecognized value for parameter."
<< "Use hardware_path, software_path or automatic_path." << std::endl;
return 1;
}
}
In order to build the library and all the examples, including the one above,
follow the steps at Building the Library.
The compiled examples will then be located in <dml_library>/build/examples/
.
To run the example on the Hardware Path, use:
sudo ./compression_example hardware_path
Attention
Hardware Path requires first configuring Intel® Data Streaming Accelerator (Intel® DSA). Please refer to the Accelerator Configuration section for detailed instructions.
Starting from Intel DML 1.2.0 release, the library will select any device from the socket of the calling thread for execution. Prior to this release, the library would only select devices from the NUMA node of the calling thread.
If more fine-grained control is needed, the Low-Level API of the library provides the ability to select devices
from a specific NUMA node using the numa_id
field in the job structure.
For more information, see the NUMA support for Low-Level API section.
It is the user’s responsibility to ensure that the devices are properly configured and available for the library to use.
Additionally, with the Hardware Path, the user must either place the libaccel-config
library in /usr/lib64/
or specify the location of libaccel-config
in the LD_LIBRARY_PATH
environment variable for the dynamic loader to find it.
Similarly you can specify software_path
for host execution or automatic_path
for automatic dispatching (choice would be made by library based on accelerator availability
and some other internal heuristics).