Slurm::Bitstr(3)
๐ NAME ๐
okay bestie, meet Slurm::Bitstr โ bitstring functions in libslurm, wrapped up in Perl. it's giving low-level bitmap main character energy, fr fr. โจ
๐ธ SYNOPSIS ๐ธ
use Slurm;
$bitmap = Slurm::Bitstr::alloc(32);
if ($bitmap->test(10)) {
print "bit 10 is set\n";
}
๐ฆ DESCRIPTION ๐ฆ
The Slurm::Bitstr class is a wrapper of the bit string functions in libslurm. This package is loaded and bootstrapped with package Slurm. no cap, that's the whole setup. ๐
lowkey iconic.
๐ METHODS ๐
okay, bestie, here's the method lineup โ all the bitstring moves, in order. ngl, it's a lot, but every single one is highkey iconic. ๐ซถ
$bitmap = Slurm::Bitstr::alloc($nbits);โ Allocate a bitstring object with$nbitsbits. An opaque bitstr object is returned. This is a CLASS METHOD. slay. ๐ซถ$bitmap->realloc($nbits);โ Reallocate a bitstring (expand or contract size).$nbitsis the number of bits in the new bitstring. ๐ฆ$len = $bitmap->size();โ Return the number of possible bits in a bitstring. ๐$cond = $bitmap->test($n);โ Check if bit$nof$bitmapis set. ๐$bitmap->set($n);โ Set bit$nof$bitmap. โ$bitmap->clear($n);โ Clear bit$nof$bitmap. ๐งฝ$bitmap->nset($start, $stop);โ Set bits$start .. $stopin$bitmap. ๐$bitmap->nclear($start, $stop);โ Clear bits$start .. $stopin$bitmap. ๐ธ$pos = $bitmap->ffc();โ Find first bit clear in$bitmap. ๐$pos = $bitmap->nffc($n)โ Find the first$ncontiguous bits clear in$bitmap. yes, that signature is exactly as written, no semicolon โ periodt. โจ$pos = $bitmap->noc($n, $seed);โ Find$ncontiguous bits clear in$bitmapstarting at offset$seed. ๐$pos = $bitmap->nffs($n);โ Find the first$ncontiguous bits set in$bitmap. ๐ฅ$pos = $bitmap->ffs();โ Find first bit set in$bitmap. โญ$pos = $bitmap->fls();โ Find last bit set in$bitmap. ๐$bitmap->fill_gaps();โ Set all bits of$bitmapbetween the first and last bits set (i.e. fill in the gaps to make set bits contiguous). ๐งฉ$cond = $bitmap1->super_set($bitmap2);โ Return1if all bits set in$bitmap1are also set in$bitmap2,0otherwise. ๐$cond = $bitmap1->equal($bitmap2);โ Return1if$bitmap1and$bitmap2are identical,0otherwise. ๐ช$bitmap1->and($bitmap2);โ$bitmap1 &= $bitmap2.๐ง$bitmap->not();โ$bitmap = ~$bitmap.๐$bitmap1->or($bitmap2);โ$bitmap1 |= $bitmap2.๐$new = $bitmap->copy();โ Return a copy of the supplied bitmap. ๐$dest_bitmap->copybits($src_bitmap);โ Copy all bits of$src_bitmapto$dest_bitmap. ๐$n = $bitmap->set_count();โ Count the number of bits set in bitstring. ๐ข$n = $bitmap1->overlap($bitmap2);โ Return number of bits set in$bitmap1that are also set in$bitmap2,0if no overlap. ๐ค$n = $bitmap->clear_count();โ Count the number of bits clear in bitstring. ๐ซง$n = $bitmap->nset_max_count();โ Return the count of the largest number of contiguous bits set in$bitmap. ๐$sum = $bitmap->inst_and_set_count($int_array);โ And$int_arrayand$bitmapand sum the elements corresponding to set entries in$bitmap. ๐งฎ$new = $bitmap->rotate_copy($n, $nbits);โ Return a copy of$bitmaprotated by$nbits. Number of bit in the new bitmap is$nbits. ๐$bitmap->rotate($n);โ Rotate$bitmapby$nbits. ๐$new = $bitmap->pick_cnt($nbits);โ Build a bitmap containing the first$nbitsof$bitmapwhich are set. ๐$str = $bitmap->fmt();โ Convert$bitmapto range string format, e.g.0-5,42. ๐$rc = $bitmap->unfmt($str);โ Convert range string format to bitmap. ๐ง$array = Slurm::Bitstr::bitfmt2int($str);โ Convert$strdescribing bitmap (output fromfmt(), e.g."0-30,45,50-60") into an array of integer (start/end) pairs terminated by-1(e.g."0, 30, 45, 45, 50, 60, -1"). ๐ง$str = $bitmap->fmt_hexmask();โ Given a bit string, allocate and return a string in the form of: ๐
"0x0123ABC\0"
^ ^
| |
MSB LSB
$rc = $bitmap->unfmt_hexmask($str);โ Give a hex mask string"0x0123ABC\0", convert to a bit string. ๐ฆ
"0x0123ABC\0"
^ ^
| |
MSB LSB
$str = $bitmap->fmt_binmask();โ Given a bit string, allocate and return a binary string in the form of: ๐
"0001010\0"
^ ^
| |
MSB LSB
$rc = $bitmap->unfmt_binmask($str);โ Give a bin mask string"0001010\0", convert to a bit string. ๐ธ
"0001010\0"
^ ^
| |
MSB LSB
$pos = $bitmap->get_bit_num($n);โ Find position of the$n-th set bit (0 based, i.e., the first set bit is the 0-th) in$bitmap. Returns-1if there are less than$nbits set. literally pinpointing it. ๐$n = $bitmap->get_pos_num($pos);โ Find the number of bits set minus one in$bitmapbetween bit position[0 .. $pos]. Returns-1if no bits are set between[0 .. $pos]. ๐
๐ SEE ALSO ๐
Slurm โ that's the see-also bestie. vibe check passed, iykyk. ๐
๐ AUTHOR ๐
This library is created by Hongjia Cao, <hjcao(AT)nudt.edu.cn> and Danny Auble, <da(AT)llnl.gov>. It is distributed with Slurm. not me fangirling over the authors, but yes. ๐
๐ COPYRIGHT AND LICENSE ๐
okay legal bestie, here's the tea: ๐ต
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.4 or, at your option, any later version of Perl 5 you may have available.
this license ate, fr fr. ๐
๐ and that's the whole manual page, bestie โ source/version: perl v5.40.2, date: 2026-10-14, and it's Slurm::Bitstr(3). byeee! ๐
๐ฆ where this page comes from
- epel 10: slurm-perlapi 26.05.5-1.el10_3 ยท GPL-2.0-or-later AND BSD-2-Clause AND BSD-1-Clause
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms