1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
|
How to build BitMagic library:
BM is small software package and you probably can just take the
sources and put it into your project directly. All library sources are in src
directory.
However if you want to use our makefiles you need to follow the next simple
instructions:
Unix:
-----
- Apply environment variables by runing bmenv.sh :
$ . bmenv.sh
- use GNU make (gmake) to build installation.
$gmake rebuild
or (DEBUG version)
$gmake DEBUG=YES rebuild
The default compiler on Unix and CygWin is g++.
If you want to change the default you can do that in makefile.in
(should be pretty easy to do)
Windows:
--------
If you use cygwin installation please follow general Unix recommendations.
If you use MSVC please use supplied bm.dsw and corresponding project files.
Fine tuning and optimizations:
------------------------------
All BM fine tuning parameters are controlled by the preprocessor defines.
=================================================================================
BM library includes some code optimized for 64-bit systems. To turn this
optimization on you need to #define BM64OPT in you makefile or in bm.h file.
To turn SSE2 optimization #define BMSSE2OPT
You will need compiler supporting Intel SSE2 intrinsics.
It could be MSVC .Net or Intel C++.
The limitation is that you cannot use BM64OPT and BMSSE2OPT together.
=================================================================================
BM library supports "restrict" keyword, some compilers
(for example Intel C++ for Itanium) generate better
code (out of order load-stores) when restrict keyword is helping. This option is
turned OFF by default since most of the C++ compilers does not support it.
To turn it ON please #define BM_HASRESTRICT in your project. Some compilers
use "__restrict" keyword for this purpose. You can correct if by
defineing BMRESTRICT macro to correct keyword.
=================================================================================
Bitcounting optimization can be turned ON by defining BMCOUNTOPT.
Please note this optimization is not completely thread safe.
bvector<> template keeps mutable variable inside it and update it
when it count() function is called. So it creates a certain chance that this
function will be called from multiple threads and crash on updating this
variable.
=================================================================================
If you want to use BM library in STL-free project you need to define
BM_NO_STL variable. It will disable inclusion of certain headers and also
will make bvector iterators incompatible with STL algorithms
(which you said you are not using anyway).
=================================================================================
Different compilers use different conventions about return by value
optimizations.
For instance operator or for bitvector can be implemented in two
different ways:
--------- With explicit temp variable
template<class A, class MS>
inline bvector<A, MS> operator| (const bvector<A, MS>& v1,
const bvector<A>& v2)
{
bvector<A, MS> ret(v1);
ret.bit_or(v2);
return ret;
}
--------- Temp variable is hidden
template<class A, class MS>
inline bvector<A, MS> operator| (const bvector<A, MS>& v1,
const bvector<A>& v2)
{
return bvector<A, MS>(v1).bit_or(v2);
}
----------
Some compilers can successfully optimize one or both of this cases.
BM implementation uses hidden temp variable unless you define
BM_USE_EXPLICIT_TEMP
=================================================================================
Thank you for using BitMagic library!
Anatoliy Kuznetsov (anatoliy_kuznetsov at yahoo.com)
|