HPP_UIUC_MP1: vector addition

本文介绍如何使用WebGPU进行本地开发,包括如何设置环境、运行示例程序以及使用特定命令行参数来处理输入输出文件。提供了详细的步骤说明,并附上了程序运行实例。

按照tutorial来在cmd里面输入:input output 文件名和type即可。

data set在webgpu的页面有的下载。


F:\1MOOC_SourceCode\HPP\libwb\build\Debug>.\MP1.exe -e -i input2.raw,input1.raw -o out.raw -t vector



作业地址:
http://webgpu.hwu.crhc.illinois.edu/mp/1

Local Development

While not required, the library used throughout the course can be downloaded from Github. The library does not depend on any external library (and should be cross platform), you can use make to generate the shared object file (further instructions are found on the Github page). Linking against the library would allow you to get similar behavior to the web interface (minus the imposed limitations). Once linked against the library, you can launch the your program as follows:

./program -e <expected_output_file> -i <input_file_1>,<input_file_2> -o <output_file> -t <type>

The <expected_output_file> and <input_file_n> are the input and output files provided in the dataset. The <output_file> is the location you’d like to place the output from your program. The <type> is the output file type: vectormatrix, or image. If an MP does not expect an input or output, then pass none as the parameter.

In case of issues or suggestions with the library, please report them through the issue tracker on Github.



`nlohmann::json_abi_v3_12_0::basic_json` 是 `nlohmann/json` 库中的一个核心类模板,用于处理 JSON 数据。该库是一个流行的现代 C++ JSON 库,以其简洁的 API 和高效的性能而受到广泛使用。 从给出的模板参数来看: - `std::map`:用于表示 JSON 对象,在 JSON 中对象是键值对的集合,`std::map` 提供了键值映射的功能。 - `std::vector`:用于表示 JSON 数组,JSON 数组是值的有序列表,`std::vector` 可以很好地存储和管理这些值。 - `std::string`:用于表示 JSON 字符串类型。 - `bool`:对应 JSON 的布尔值类型。 - `int64_t` 和 `uint64_t`:用于表示整数类型的 JSON 数字,分别处理有符号和无符号 64 位整数。 - `double`:用于表示浮点类型的 JSON 数字。 - `std::allocator`:是 C++ 标准库中的内存分配器,用于管理对象的内存分配和释放。 - `nlohmann::json_abi_v3_12_0::adl_serializer`:是该库自定义的序列化器,用于处理 JSON 对象的序列化和反序列化操作。 - `std::vector<uint8_t, std::allocator<_Ty>>`:可能用于处理二进制数据的 JSON 表示。 在内存效率方面,每个 JSON 对象都有一个指针(联合的最大大小)和一个枚举元素(1 字节)的开销。默认情况下,该类模板使用 `std::string` 对应字符串,`int64_t`、`uint64_t` 或者 `double` 对应数字,`std::map` 对应对象,`std::vector` 对应数组,以及 `bool` 对应布尔值。不过,可以通过模板化 `basic_json` 类来满足特定需求 [^1]。 以下是一个简单的使用 `nlohmann/json` 库的示例代码: ```cpp #include <iostream> #include <nlohmann/json.hpp> // 为了方便使用,使用命名空间 using json = nlohmann::json; int main() { // 创建一个 JSON 对象 json j; j["name"] = "John"; j["age"] = 30; j["hobbies"] = {"reading", "swimming", "running"}; // 输出 JSON 对象 std::cout << j.dump(4) << std::endl; return 0; } ``` ###
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值