Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
group-connectivity-pub
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Radek Hušek
group-connectivity-pub
Commits
0134460a
Commit
0134460a
authored
9 years ago
by
Radek Hušek
Committed by
Radek Hušek
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add optimized versions of Mapping class
Optimized versions are off by default
parent
a2da36b8
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
Makefile
+1
-1
1 addition, 1 deletion
Makefile
compileTimeOptions.h
+14
-0
14 additions, 0 deletions
compileTimeOptions.h
fast-array.h
+76
-6
76 additions, 6 deletions
fast-array.h
group-connectivity.h
+2
-2
2 additions, 2 deletions
group-connectivity.h
with
93 additions
and
9 deletions
Makefile
+
1
−
1
View file @
0134460a
default
:
groupConnectivity.so clean_obj
groupConnectivity.so
:
groupConnectivity.pyx group-connectivity.h setup.py compileTimeOptions.h rings.h parmap.py
groupConnectivity.so
:
groupConnectivity.pyx group-connectivity.h setup.py compileTimeOptions.h rings.h
fast-array.h
parmap.py
python setup.py build_ext
cp
build/lib
*
/groupConnectivity.so .
...
...
This diff is collapsed.
Click to expand it.
compileTimeOptions.h
+
14
−
0
View file @
0134460a
...
...
@@ -11,5 +11,19 @@
#pragma message "SAVE_MEMORY off"
#endif
#ifndef OPTIMIZED_MAPPINGS
#define OPTIMIZED_MAPPINGS 0
#endif
#if OPTIMIZED_MAPPINGS
#pragma message "OPTIMIZED_MAPPINGS ON"
#else
#pragma message "OPTIMIZED_MAPPINGS off"
#endif
#ifndef MAX_EDGES
#define MAX_EDGES 48
#endif
#endif
This diff is collapsed.
Click to expand it.
fast-array.h
+
76
−
6
View file @
0134460a
#ifndef __FAST_ARRAY_H__
#define __FAST_ARRAY_H__
template
<
typename
Ring
,
size_t
maxSize
=
0
>
#include
"rings.h"
template
<
typename
Ring
>
struct
Mapping
{
typedef
typename
Ring
::
T
T
;
std
::
vector
<
T
>
data
;
Mapping
()
{}
template
<
typename
X
>
Mapping
(
X
x
)
:
data
(
x
.
data
)
{}
Mapping
(
const
Mapping
&
x
)
:
data
(
x
.
data
)
{}
Mapping
(
size_t
size
=
0
,
T
val
=
0
)
:
data
(
size
,
val
)
{}
Mapping
(
size_t
size
=
0
)
:
data
(
size
,
0
)
{}
inline
size_t
size
()
const
{
return
data
.
size
();
}
inline
T
operator
[]
(
size_t
i
)
const
{
return
data
[
i
];
}
inline
void
assign
(
size_t
i
,
T
val
)
{
data
[
i
]
=
val
;
}
Mapping
&
combine
(
T
beta
,
const
Mapping
&
b
)
{
inline
void
combine
(
T
beta
,
const
Mapping
&
b
)
{
size_t
_size
=
size
();
for
(
size_t
i
=
0
;
i
<
_size
;
i
++
)
data
[
i
]
=
Ring
::
plus
(
data
[
i
],
Ring
::
multiply
(
beta
,
b
.
data
[
i
]));
return
*
this
;
}
};
template
<
size_t
i
,
size_t
shift
>
struct
Consts
{
static
const
uint64_t
clone
=
(
Consts
<
i
-
1
,
shift
>::
clone
<<
shift
)
|
1
;
static
const
uint64_t
mask
=
(
Consts
<
i
-
1
,
shift
>::
mask
<<
shift
)
|
3
;
};
template
<
size_t
shift
>
struct
Consts
<
0
,
shift
>
{
static
const
uint64_t
clone
=
0
;
static
const
uint64_t
mask
=
0
;
};
template
<
bool
isZ4
>
struct
FastArray
{
typedef
int
T
;
enum
{
valuesPerWord
=
16
};
enum
{
words
=
(
MAX_EDGES
+
valuesPerWord
-
1
)
/
valuesPerWord
};
enum
{
shift
=
4
};
static
const
uint64_t
clone
=
Consts
<
valuesPerWord
,
shift
>::
clone
;
static
const
uint64_t
mask
=
Consts
<
valuesPerWord
,
shift
>::
mask
;
size_t
size_
;
uint64_t
data
[
words
];
FastArray
()
{}
FastArray
(
const
FastArray
&
x
)
:
size_
(
x
.
size_
)
{
memcpy
(
data
,
x
.
data
,
sizeof
(
data
));
}
FastArray
(
size_t
size
=
0
)
:
size_
(
size
)
{
assert
(
size
<=
MAX_EDGES
);
memset
(
data
,
0
,
sizeof
(
data
));
}
inline
size_t
size
()
const
{
return
size_
;
}
inline
T
operator
[]
(
size_t
i
)
const
{
return
(
data
[
i
>>
4
]
>>
((
i
&
0xF
)
<<
2
))
&
3
;
}
inline
void
assign
(
size_t
i
,
T
val
)
{
size_t
w
=
i
>>
4
;
size_t
off
=
i
&
0xF
;
data
[
w
]
&=
~
(((
uint64_t
)
3
)
<<
(
off
<<
2
));
data
[
w
]
|=
(((
uint64_t
)
val
)
<<
(
off
<<
2
));
}
inline
void
combine
(
T
beta
,
const
FastArray
&
b
)
{
for
(
size_t
i
=
0
;
i
<
words
;
i
++
)
{
if
(
isZ4
)
data
[
i
]
=
(
data
[
i
]
+
((
beta
*
b
.
data
[
i
])
&
mask
))
&
mask
;
else
data
[
i
]
=
data
[
i
]
^
((
clone
*
beta
)
&
b
.
data
[
i
]);
}
}
};
#if OPTIMIZED_MAPPINGS
template
<
>
struct
Mapping
<
Ring
::
Z4
<
int
>
>
:
public
FastArray
<
true
>
{
Mapping
(
const
Mapping
&
x
)
:
FastArray
(
x
)
{}
Mapping
(
size_t
s
=
0
)
:
FastArray
(
s
)
{}
};
template
<
>
struct
Mapping
<
Ring
::
Z2_2
<
int
>
>
:
public
FastArray
<
false
>
{
Mapping
(
const
Mapping
&
x
)
:
FastArray
(
x
)
{}
Mapping
(
size_t
s
=
0
)
:
FastArray
(
s
)
{}
};
#endif
#endif
This diff is collapsed.
Click to expand it.
group-connectivity.h
+
2
−
2
View file @
0134460a
...
...
@@ -65,7 +65,7 @@ struct Tester : public AbstractTester {
classEdges
.
push_back
(
e
-
1
);
for
(
const
auto
&
elemCycle
:
elementaryCycles
)
{
nonClassEdges
.
push_back
(
std
::
make_pair
(
elemCycle
[
0
]
-
1
,
Mapping
(
edges
,
0
)));
nonClassEdges
.
push_back
(
std
::
make_pair
(
elemCycle
[
0
]
-
1
,
Mapping
(
edges
)));
Mapping
&
map
=
nonClassEdges
.
back
().
second
;
for
(
auto
edge
:
elemCycle
)
{
...
...
@@ -121,7 +121,7 @@ struct Tester : public AbstractTester {
virtual
bool
run
()
{
Mapping
forb
(
edges
,
0
);
Mapping
forb
(
edges
);
for
(
size_t
i
=
0
;
i
<
numForb
;
i
++
)
#if SAVE_MEMORY
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment