31 static std::string get_env(
const char *v) {
38 static int32_t get_env_i32(
const char *v) {
39 return std::atoi(get_env(v).c_str());
42 const size_t total_shards, shard_index;
50 std::string shard_status_file = get_env(
"TEST_SHARD_STATUS_FILE");
51 if (!shard_status_file.empty()) {
52 std::ofstream f(shard_status_file, std::ios::out | std::ios::binary);
60 : total_shards(get_env_i32(
"TEST_TOTAL_SHARDS")),
61 shard_index(get_env_i32(
"TEST_SHARD_INDEX")) {
64 if (total_shards != 0) {
65 if (total_shards < 0 || shard_index < 0 || shard_index >= total_shards) {
66 std::cerr <<
"Illegal values for sharding: total " << total_shards <<
" current " << shard_index <<
"\n";
73 if (total_shards > 0) {
74 return (task_index % total_shards) == shard_index;
81 return total_shards > 0;
static void accept_sharded_status()
bool should_run(size_t task_index) const
This file defines the class FunctionDAG, which is our representation of a Halide pipeline,...
@ Internal
Not visible externally, similar to 'static' linkage in C.
signed __INT32_TYPE__ int32_t
char * getenv(const char *)