Files
project_6/cccl_upstream/libcudacxx/test/support/assert_checkpoint.h
EngineX CI 56fd68e7dd [INFRA] Import NVIDIA/CCCL upstream as optimization reference library
CCCL (CUDA C++ Core Libraries) provides:
- CUB: device/block/warp-level GPU primitives (reduce, scan, sort, topk)
- Thrust: high-level parallel algorithms (transform_reduce, sort, scan)
- libcudacxx: CUDA C++ standard library (atomics, barriers, memory)
- cudax: experimental features (memory resources, allocators)
- Tuning policies: per-SM hardware-specific algorithm parameters

Competition optimization vectors mapped to CCCL:
- Output TPS (83% weight): warp_reduce, block_reduce, device_topk
- Input TPS (14% weight): device_scan, block_load, prefetch
- Cache TPS (3% weight): prefix caching strategy patterns
- Memory (0.9 util): pooled/cached/buddy allocators

Source: https://github.com/NVIDIA/cccl (shallow clone, HEAD only)
License: Apache-2.0
2026-07-30 09:35:51 +00:00

98 lines
1.8 KiB
C++

#ifndef SUPPORT_ASSERT_CHECKPOINT_H
#define SUPPORT_ASSERT_CHECKPOINT_H
#include <csignal>
#include <cstdlib>
#include <iostream>
struct Checkpoint
{
const char* file;
const char* func;
int line;
const char* msg;
Checkpoint()
: file(nullptr)
, func(nullptr)
, line(-1)
, msg(nullptr)
{}
Checkpoint(const char* xfile, const char* xfunc, int xline, const char* xmsg)
: file(xfile)
, func(xfunc)
, line(xline)
, msg(xmsg)
{}
template <class Stream>
void print(Stream& s) const
{
if (!file)
{
s << "NO CHECKPOINT\n";
return;
}
s << file << ":" << line << " " << func << ": Checkpoint";
if (msg)
{
s << " '" << msg << "'";
}
s << '\n';
}
};
inline Checkpoint& globalCheckpoint()
{
static Checkpoint C;
return C;
}
inline void clearCheckpoint()
{
globalCheckpoint() = Checkpoint();
}
#if defined(__GNUC__)
# define CHECKPOINT_FUNCTION_NAME __PRETTY_FUNCTION__
#else
# define CHECKPOINT_FUNCTION_NAME __func__
#endif
#define CHECKPOINT(msg) globalCheckpoint() = Checkpoint(__FILE__, CHECKPOINT_FUNCTION_NAME, __LINE__, msg);
inline void checkpointSignalHandler(int signal)
{
if (signal == SIGABRT)
{
globalCheckpoint().print(std::cerr);
}
else
{
std::cerr << "Unexpected signal " << signal << " received\n";
}
std::_Exit(EXIT_FAILURE);
}
inline bool initCheckpointHandler()
{
using HandlerT = void (*)(int);
static bool isInit = false;
if (isInit)
{
return true;
}
HandlerT prev_h = std::signal(SIGABRT, checkpointSignalHandler);
if (prev_h == SIG_ERR)
{
std::cerr << "Setup failed.\n";
std::_Exit(EXIT_FAILURE);
}
isInit = true;
return false;
}
static bool initDummy = initCheckpointHandler();
#endif