Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions src/backend/common/ArrayFireTypesIO.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ struct fmt::formatter<af_seq> {
}

template<typename FormatContext>
auto format(const af_seq& p, FormatContext& ctx) -> decltype(ctx.out()) {
auto format(const af_seq& p, FormatContext& ctx) const
-> decltype(ctx.out()) {
// ctx.out() is an output iterator to write to.
if (p.begin == af_span.begin && p.end == af_span.end &&
p.step == af_span.step) {
Expand Down Expand Up @@ -72,19 +73,22 @@ struct fmt::formatter<arrayfire::common::Version> {
return it;
}

// fmt 10 and later require format() to be const, so the parsed flags
// are combined with the version's contents into locals rather than
// modified in place.
template<typename FormatContext>
auto format(const arrayfire::common::Version& ver, FormatContext& ctx)
auto format(const arrayfire::common::Version& ver, FormatContext& ctx) const
-> decltype(ctx.out()) {
if (ver.major() == -1) return format_to(ctx.out(), "N/A");
if (ver.minor() == -1) show_minor = false;
if (ver.patch() == -1) show_patch = false;
if (show_major && !show_minor && !show_patch) {
const bool minor = show_minor && ver.minor() != -1;
const bool patch = show_patch && ver.patch() != -1;
if (show_major && !minor && !patch) {
return format_to(ctx.out(), "{}", ver.major());
}
if (show_major && show_minor && !show_patch) {
if (show_major && minor && !patch) {
return format_to(ctx.out(), "{}.{}", ver.major(), ver.minor());
}
if (show_major && show_minor && show_patch) {
if (show_major && minor && patch) {
return format_to(ctx.out(), "{}.{}.{}", ver.major(), ver.minor(),
ver.patch());
}
Expand Down
8 changes: 7 additions & 1 deletion src/backend/common/debug.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@
#include <boost/stacktrace.hpp>
#include <common/ArrayFireTypesIO.hpp>
#include <common/jit/NodeIO.hpp>
#include <spdlog/fmt/bundled/format.h>
#include <spdlog/fmt/fmt.h>
// fmt 11 moved fmt::join from format.h to ranges.h
#if defined(SPDLOG_FMT_EXTERNAL)
#include <fmt/ranges.h>
#else
#include <spdlog/fmt/bundled/ranges.h>
#endif
#include <iostream>

#define DBGTRACE(msg) \
Expand Down
7 changes: 4 additions & 3 deletions src/backend/common/jit/NodeIO.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@

#pragma once
#include <common/jit/Node.hpp>
#include <spdlog/fmt/bundled/format.h>
#include <spdlog/fmt/fmt.h>

#include <common/util.hpp>

template<>
struct fmt::formatter<af::dtype> : fmt::formatter<char> {
template<typename FormatContext>
auto format(const af::dtype& p, FormatContext& ctx) -> decltype(ctx.out()) {
auto format(const af::dtype& p, FormatContext& ctx) const
-> decltype(ctx.out()) {
format_to(ctx.out(), "{}", arrayfire::common::getName(p));
return ctx.out();
}
Expand Down Expand Up @@ -58,7 +59,7 @@ struct fmt::formatter<arrayfire::common::Node> {
// Formats the point p using the parsed format specification (presentation)
// stored in this formatter.
template<typename FormatContext>
auto format(const arrayfire::common::Node& node, FormatContext& ctx)
auto format(const arrayfire::common::Node& node, FormatContext& ctx) const
-> decltype(ctx.out()) {
// ctx.out() is an output iterator to write to.

Expand Down
2 changes: 1 addition & 1 deletion src/backend/cuda/debug_cuda.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ template<>
struct fmt::formatter<dim3> : fmt::formatter<std::string> {
// parse is inherited from formatter<string_view>.
template<typename FormatContext>
auto format(dim3 c, FormatContext& ctx) {
auto format(const dim3& c, FormatContext& ctx) const {
std::string name = fmt::format("{} {} {}", c.x, c.y, c.z);
return formatter<std::string>::format(name, ctx);
}
Expand Down
7 changes: 7 additions & 0 deletions src/backend/opencl/compile_module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@
#include <platform.hpp>
#include <traits.hpp>

// fmt 11 moved fmt::join from format.h to ranges.h
#if defined(SPDLOG_FMT_EXTERNAL)
#include <fmt/ranges.h>
#else
#include <spdlog/fmt/bundled/ranges.h>
#endif

#include <algorithm>
#include <cctype>
#include <cstdio>
Expand Down
Loading