OverviewFilesCommitsIssuesDocsReleasesPeers

opencog-CompactHash commits / de4a0ec

Renaming oldHash to simplehash
de4a0ecd0ef3a61aa04c7f145035ab688685f1a5
by brobey <brobey@lanl.gov> · 2015-10-21T19:39:57.000Z

Changed files (23) +2648 -2648

Makefile.am +4 -4
……@@ -2,12 +2,12 @@ bin_PROGRAMS = neigh2d # neigh2d_memopts
22
33ACLOCAL_AMFLAGS = -I m4
44
5SUBDIRS = kdtree hash oldHash timer
5SUBDIRS = kdtree hash simplehash timer
66
77neigh2d_C_SRCS = neigh2d.c gpu.c
88neigh2d_H_SRCS = gpu.h
99neigh2d_SOURCES = ${neigh2d_C_SRCS} ${neigh2d_H_SRCS}
10neigh2d_LDADD = kdtree/libkdtree.la hash/libhash.la oldHash/libhashold.la timer/libtimer.la
10neigh2d_LDADD = kdtree/libkdtree.la hash/libhash.la simplehash/libsimplehash.la timer/libtimer.la
1111
1212LDADD = -lm
1313
……@@ -26,8 +26,8 @@ hash/libhash.la:
2626 cd hash
2727 make
2828
29oldHash/libhashold.la:
30 cd oldHash
29simplehash/libsimplehash.la:
30 cd simplehash
3131 make
3232
3333clean-local:
Makefile.in +5 -5
……@@ -110,7 +110,7 @@ am__objects_2 =
110110am_neigh2d_OBJECTS = $(am__objects_1) $(am__objects_2)
111111neigh2d_OBJECTS = $(am_neigh2d_OBJECTS)
112112neigh2d_DEPENDENCIES = kdtree/libkdtree.la hash/libhash.la \
113 oldHash/libhashold.la timer/libtimer.la
113 simplehash/libsimplehash.la timer/libtimer.la
114114AM_V_lt = $(am__v_lt_@AM_V@)
115115am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
116116am__v_lt_0 = --silent
……@@ -360,11 +360,11 @@ top_build_prefix = @top_build_prefix@
360360top_builddir = @top_builddir@
361361top_srcdir = @top_srcdir@
362362ACLOCAL_AMFLAGS = -I m4
363SUBDIRS = kdtree hash oldHash timer
363SUBDIRS = kdtree hash simplehash timer
364364neigh2d_C_SRCS = neigh2d.c gpu.c
365365neigh2d_H_SRCS = gpu.h
366366neigh2d_SOURCES = ${neigh2d_C_SRCS} ${neigh2d_H_SRCS}
367neigh2d_LDADD = kdtree/libkdtree.la hash/libhash.la oldHash/libhashold.la timer/libtimer.la
367neigh2d_LDADD = kdtree/libkdtree.la hash/libhash.la simplehash/libsimplehash.la timer/libtimer.la
368368LDADD = -lm
369369EXTRA_DIST = neigh2d_kern.cl APACHE_LICENSE-2_0 AUTHORS README LICENSE \
370370 Papers.bib NOTICE README.md ReleaseAuthorization.pdf Todo libtool
……@@ -933,8 +933,8 @@ hash/libhash.la:
933933 cd hash
934934 make
935935
936oldHash/libhashold.la:
937 cd oldHash
936simplehash/libsimplehash.la:
937 cd simplehash
938938 make
939939
940940clean-local:
configure +2 -2
……@@ -16311,7 +16311,7 @@ ac_config_files="$ac_config_files kdtree/Makefile"
1631116311
1631216312ac_config_files="$ac_config_files hash/Makefile"
1631316313
16314ac_config_files="$ac_config_files oldHash/Makefile"
16314ac_config_files="$ac_config_files simplehash/Makefile"
1631516315
1631616316ac_config_files="$ac_config_files timer/Makefile"
1631716317
……@@ -17357,7 +17357,7 @@ do
1735717357 "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
1735817358 "kdtree/Makefile") CONFIG_FILES="$CONFIG_FILES kdtree/Makefile" ;;
1735917359 "hash/Makefile") CONFIG_FILES="$CONFIG_FILES hash/Makefile" ;;
17360 "oldHash/Makefile") CONFIG_FILES="$CONFIG_FILES oldHash/Makefile" ;;
17360 "simplehash/Makefile") CONFIG_FILES="$CONFIG_FILES simplehash/Makefile" ;;
1736117361 "timer/Makefile") CONFIG_FILES="$CONFIG_FILES timer/Makefile" ;;
1736217362
1736317363 *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
configure.ac +1 -1
……@@ -376,7 +376,7 @@ AC_SUBST(CPREPROCESSOR)
376376AC_CONFIG_FILES([Makefile])
377377AC_CONFIG_FILES([kdtree/Makefile])
378378AC_CONFIG_FILES([hash/Makefile])
379AC_CONFIG_FILES([oldHash/Makefile])
379AC_CONFIG_FILES([simplehash/Makefile])
380380AC_CONFIG_FILES([timer/Makefile])
381381
382382AC_OUTPUT
neigh2d.c +2 -2
……@@ -50,8 +50,8 @@
5050#include "kdtree/KDTree2d.h"
5151#include "gpu.h"
5252#include "hash/hash.h"
53#include "oldHash/hashit.h"
54#include "oldHash/hasholdlib.h"
53#include "simplehash/simplehash.h"
54#include "simplehash/simplehashlib.h"
5555#include "timer/timer.h"
5656
5757#ifdef HAVE_OPENCL
oldHash/Makefile.am +0 -28
……@@ -1,28 +0,0 @@
1default: hashit.c hasholdlib.c libhashold.la
2all: hashit.c hasholdlib.c libhashold.la
3
4AM_MAKEFLAGS = -j 4
5
6DEFAULT_INCLUDES=-I. -I..
7
8lib_LTLIBRARIES = libhashold.la
9include_HEADERS = hashit.h hasholdlib.h
10
11H_SRCS = hashit.h hasholdlib.h
12
13C_SRCS = hashit.c hasholdlib.c
14
15libhashold_la_SOURCES = ${C_SRCS} ${H_SRCS}
16
17hasholdlib.c: hasholdlib_kern.inc hashold_kern.inc
18
19hasholdlib_kern.inc:
20 ./embed_source.pl hasholdlib_kern.cl > hasholdlib_kern.inc
21
22hashold_kern.inc:
23 ./embed_source.pl hashold_kern.cl > hashold_kern.inc
24
25EXTRA_DIST = hashold_kern.cl hasholdlib_kern.cl embed_source.pl
26
27clean-local:
28 rm -f *.inc
oldHash/Makefile.in +0 -680
……@@ -1,680 +0,0 @@
1# Makefile.in generated by automake 1.13.4 from Makefile.am.
2# @configure_input@
3
4# Copyright (C) 1994-2013 Free Software Foundation, Inc.
5
6# This Makefile.in is free software; the Free Software Foundation
7# gives unlimited permission to copy and/or distribute it,
8# with or without modifications, as long as this notice is preserved.
9
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
12# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13# PARTICULAR PURPOSE.
14
15@SET_MAKE@
16
17
18VPATH = @srcdir@
19am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
20am__make_running_with_option = \
21 case $${target_option-} in \
22 ?) ;; \
23 *) echo "am__make_running_with_option: internal error: invalid" \
24 "target option '$${target_option-}' specified" >&2; \
25 exit 1;; \
26 esac; \
27 has_opt=no; \
28 sane_makeflags=$$MAKEFLAGS; \
29 if $(am__is_gnu_make); then \
30 sane_makeflags=$$MFLAGS; \
31 else \
32 case $$MAKEFLAGS in \
33 *\\[\ \ ]*) \
34 bs=\\; \
35 sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
36 | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
37 esac; \
38 fi; \
39 skip_next=no; \
40 strip_trailopt () \
41 { \
42 flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
43 }; \
44 for flg in $$sane_makeflags; do \
45 test $$skip_next = yes && { skip_next=no; continue; }; \
46 case $$flg in \
47 *=*|--*) continue;; \
48 -*I) strip_trailopt 'I'; skip_next=yes;; \
49 -*I?*) strip_trailopt 'I';; \
50 -*O) strip_trailopt 'O'; skip_next=yes;; \
51 -*O?*) strip_trailopt 'O';; \
52 -*l) strip_trailopt 'l'; skip_next=yes;; \
53 -*l?*) strip_trailopt 'l';; \
54 -[dEDm]) skip_next=yes;; \
55 -[JT]) skip_next=yes;; \
56 esac; \
57 case $$flg in \
58 *$$target_option*) has_opt=yes; break;; \
59 esac; \
60 done; \
61 test $$has_opt = yes
62am__make_dryrun = (target_option=n; $(am__make_running_with_option))
63am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
64pkgdatadir = $(datadir)/@PACKAGE@
65pkgincludedir = $(includedir)/@PACKAGE@
66pkglibdir = $(libdir)/@PACKAGE@
67pkglibexecdir = $(libexecdir)/@PACKAGE@
68am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
69install_sh_DATA = $(install_sh) -c -m 644
70install_sh_PROGRAM = $(install_sh) -c
71install_sh_SCRIPT = $(install_sh) -c
72INSTALL_HEADER = $(INSTALL_DATA)
73transform = $(program_transform_name)
74NORMAL_INSTALL = :
75PRE_INSTALL = :
76POST_INSTALL = :
77NORMAL_UNINSTALL = :
78PRE_UNINSTALL = :
79POST_UNINSTALL = :
80build_triplet = @build@
81host_triplet = @host@
82subdir = oldHash
83DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
84 $(top_srcdir)/./config/depcomp $(include_HEADERS)
85ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
86am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
87 $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
88 $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
89 $(top_srcdir)/configure.ac
90am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
91 $(ACLOCAL_M4)
92mkinstalldirs = $(install_sh) -d
93CONFIG_CLEAN_FILES =
94CONFIG_CLEAN_VPATH_FILES =
95am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
96am__vpath_adj = case $$p in \
97 $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
98 *) f=$$p;; \
99 esac;
100am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
101am__install_max = 40
102am__nobase_strip_setup = \
103 srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
104am__nobase_strip = \
105 for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
106am__nobase_list = $(am__nobase_strip_setup); \
107 for p in $$list; do echo "$$p $$p"; done | \
108 sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
109 $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
110 if (++n[$$2] == $(am__install_max)) \
111 { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
112 END { for (dir in files) print dir, files[dir] }'
113am__base_list = \
114 sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
115 sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
116am__uninstall_files_from_dir = { \
117 test -z "$$files" \
118 || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
119 || { echo " ( cd '$$dir' && rm -f" $$files ")"; \
120 $(am__cd) "$$dir" && rm -f $$files; }; \
121 }
122am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(includedir)"
123LTLIBRARIES = $(lib_LTLIBRARIES)
124libhashold_la_LIBADD =
125am__objects_1 = hashit.lo hasholdlib.lo
126am__objects_2 =
127am_libhashold_la_OBJECTS = $(am__objects_1) $(am__objects_2)
128libhashold_la_OBJECTS = $(am_libhashold_la_OBJECTS)
129AM_V_lt = $(am__v_lt_@AM_V@)
130am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
131am__v_lt_0 = --silent
132am__v_lt_1 =
133AM_V_P = $(am__v_P_@AM_V@)
134am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
135am__v_P_0 = false
136am__v_P_1 = :
137AM_V_GEN = $(am__v_GEN_@AM_V@)
138am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
139am__v_GEN_0 = @echo " GEN " $@;
140am__v_GEN_1 =
141AM_V_at = $(am__v_at_@AM_V@)
142am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
143am__v_at_0 = @
144am__v_at_1 =
145depcomp = $(SHELL) $(top_srcdir)/./config/depcomp
146am__depfiles_maybe = depfiles
147am__mv = mv -f
148COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
149 $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
150LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
151 $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
152 $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
153 $(AM_CFLAGS) $(CFLAGS)
154AM_V_CC = $(am__v_CC_@AM_V@)
155am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
156am__v_CC_0 = @echo " CC " $@;
157am__v_CC_1 =
158CCLD = $(CC)
159LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
160 $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
161 $(AM_LDFLAGS) $(LDFLAGS) -o $@
162AM_V_CCLD = $(am__v_CCLD_@AM_V@)
163am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
164am__v_CCLD_0 = @echo " CCLD " $@;
165am__v_CCLD_1 =
166SOURCES = $(libhashold_la_SOURCES)
167DIST_SOURCES = $(libhashold_la_SOURCES)
168am__can_run_installinfo = \
169 case $$AM_UPDATE_INFO_DIR in \
170 n|no|NO) false;; \
171 *) (install-info --version) >/dev/null 2>&1;; \
172 esac
173HEADERS = $(include_HEADERS)
174am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
175# Read a list of newline-separated strings from the standard input,
176# and print each of them once, without duplicates. Input order is
177# *not* preserved.
178am__uniquify_input = $(AWK) '\
179 BEGIN { nonempty = 0; } \
180 { items[$$0] = 1; nonempty = 1; } \
181 END { if (nonempty) { for (i in items) print i; }; } \
182'
183# Make sure the list of sources is unique. This is necessary because,
184# e.g., the same source file might be shared among _SOURCES variables
185# for different programs/libraries.
186am__define_uniq_tagged_files = \
187 list='$(am__tagged_files)'; \
188 unique=`for i in $$list; do \
189 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
190 done | $(am__uniquify_input)`
191ETAGS = etags
192CTAGS = ctags
193DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
194ACLOCAL = @ACLOCAL@
195AMTAR = @AMTAR@
196AM_CPPFLAGS = @AM_CPPFLAGS@
197AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
198AR = @AR@
199AUTOCONF = @AUTOCONF@
200AUTOHEADER = @AUTOHEADER@
201AUTOMAKE = @AUTOMAKE@
202AWK = @AWK@
203CC = @CC@
204CCDEPMODE = @CCDEPMODE@
205CFLAGS = @CFLAGS@
206CPP = @CPP@
207CPPFLAGS = @CPPFLAGS@
208CPREPROCESSOR = @CPREPROCESSOR@
209CXX = @CXX@
210CXXCPP = @CXXCPP@
211CXXDEPMODE = @CXXDEPMODE@
212CXXFLAGS = @CXXFLAGS@
213CYGPATH_W = @CYGPATH_W@
214DEFS = @DEFS@
215DEPDIR = @DEPDIR@
216DLLTOOL = @DLLTOOL@
217DSYMUTIL = @DSYMUTIL@
218DUMPBIN = @DUMPBIN@
219ECHO_C = @ECHO_C@
220ECHO_N = @ECHO_N@
221ECHO_T = @ECHO_T@
222EGREP = @EGREP@
223EXEEXT = @EXEEXT@
224FGREP = @FGREP@
225GREP = @GREP@
226HAVE_ADDR2LINE = @HAVE_ADDR2LINE@
227INDENT = @INDENT@
228INSTALL = @INSTALL@
229INSTALL_DATA = @INSTALL_DATA@
230INSTALL_PROGRAM = @INSTALL_PROGRAM@
231INSTALL_SCRIPT = @INSTALL_SCRIPT@
232INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
233LD = @LD@
234LDFLAGS = @LDFLAGS@
235LIBOBJS = @LIBOBJS@
236LIBS = @LIBS@
237LIBTOOL = @LIBTOOL@
238LIPO = @LIPO@
239LN_S = @LN_S@
240LTLIBOBJS = @LTLIBOBJS@
241MAKEINFO = @MAKEINFO@
242MANIFEST_TOOL = @MANIFEST_TOOL@
243MKDIR_P = @MKDIR_P@
244NM = @NM@
245NMEDIT = @NMEDIT@
246OBJDUMP = @OBJDUMP@
247OBJEXT = @OBJEXT@
248OTOOL = @OTOOL@
249OTOOL64 = @OTOOL64@
250PACKAGE = @PACKAGE@
251PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
252PACKAGE_NAME = @PACKAGE_NAME@
253PACKAGE_STRING = @PACKAGE_STRING@
254PACKAGE_TARNAME = @PACKAGE_TARNAME@
255PACKAGE_URL = @PACKAGE_URL@
256PACKAGE_VERSION = @PACKAGE_VERSION@
257PATH_SEPARATOR = @PATH_SEPARATOR@
258RANLIB = @RANLIB@
259SED = @SED@
260SET_MAKE = @SET_MAKE@
261SHELL = @SHELL@
262STRIP = @STRIP@
263VERSION = @VERSION@
264abs_builddir = @abs_builddir@
265abs_srcdir = @abs_srcdir@
266abs_top_builddir = @abs_top_builddir@
267abs_top_srcdir = @abs_top_srcdir@
268ac_ct_AR = @ac_ct_AR@
269ac_ct_CC = @ac_ct_CC@
270ac_ct_CXX = @ac_ct_CXX@
271ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
272am__include = @am__include@
273am__leading_dot = @am__leading_dot@
274am__quote = @am__quote@
275am__tar = @am__tar@
276am__untar = @am__untar@
277bindir = @bindir@
278build = @build@
279build_alias = @build_alias@
280build_cpu = @build_cpu@
281build_os = @build_os@
282build_vendor = @build_vendor@
283builddir = @builddir@
284datadir = @datadir@
285datarootdir = @datarootdir@
286docdir = @docdir@
287dvidir = @dvidir@
288exec_prefix = @exec_prefix@
289host = @host@
290host_alias = @host_alias@
291host_cpu = @host_cpu@
292host_os = @host_os@
293host_vendor = @host_vendor@
294htmldir = @htmldir@
295includedir = @includedir@
296infodir = @infodir@
297install_sh = @install_sh@
298libdir = @libdir@
299libexecdir = @libexecdir@
300localedir = @localedir@
301localstatedir = @localstatedir@
302lspci_found = @lspci_found@
303mandir = @mandir@
304mkdir_p = @mkdir_p@
305oldincludedir = @oldincludedir@
306pdfdir = @pdfdir@
307prefix = @prefix@
308program_transform_name = @program_transform_name@
309psdir = @psdir@
310sbindir = @sbindir@
311sharedstatedir = @sharedstatedir@
312srcdir = @srcdir@
313sysconfdir = @sysconfdir@
314target_alias = @target_alias@
315top_build_prefix = @top_build_prefix@
316top_builddir = @top_builddir@
317top_srcdir = @top_srcdir@
318AM_MAKEFLAGS = -j 4
319DEFAULT_INCLUDES = -I. -I..
320lib_LTLIBRARIES = libhashold.la
321include_HEADERS = hashit.h hasholdlib.h
322H_SRCS = hashit.h hasholdlib.h
323C_SRCS = hashit.c hasholdlib.c
324libhashold_la_SOURCES = ${C_SRCS} ${H_SRCS}
325EXTRA_DIST = hashold_kern.cl hasholdlib_kern.cl embed_source.pl
326all: all-am
327
328.SUFFIXES:
329.SUFFIXES: .c .lo .o .obj
330$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
331 @for dep in $?; do \
332 case '$(am__configure_deps)' in \
333 *$$dep*) \
334 ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
335 && { if test -f $@; then exit 0; else break; fi; }; \
336 exit 1;; \
337 esac; \
338 done; \
339 echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign oldHash/Makefile'; \
340 $(am__cd) $(top_srcdir) && \
341 $(AUTOMAKE) --foreign oldHash/Makefile
342.PRECIOUS: Makefile
343Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
344 @case '$?' in \
345 *config.status*) \
346 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
347 *) \
348 echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
349 cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
350 esac;
351
352$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
353 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
354
355$(top_srcdir)/configure: $(am__configure_deps)
356 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
357$(ACLOCAL_M4): $(am__aclocal_m4_deps)
358 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
359$(am__aclocal_m4_deps):
360
361install-libLTLIBRARIES: $(lib_LTLIBRARIES)
362 @$(NORMAL_INSTALL)
363 @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
364 list2=; for p in $$list; do \
365 if test -f $$p; then \
366 list2="$$list2 $$p"; \
367 else :; fi; \
368 done; \
369 test -z "$$list2" || { \
370 echo " $(MKDIR_P) '$(DESTDIR)$(libdir)'"; \
371 $(MKDIR_P) "$(DESTDIR)$(libdir)" || exit 1; \
372 echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \
373 $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \
374 }
375
376uninstall-libLTLIBRARIES:
377 @$(NORMAL_UNINSTALL)
378 @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
379 for p in $$list; do \
380 $(am__strip_dir) \
381 echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \
382 $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \
383 done
384
385clean-libLTLIBRARIES:
386 -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
387 @list='$(lib_LTLIBRARIES)'; \
388 locs=`for p in $$list; do echo $$p; done | \
389 sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
390 sort -u`; \
391 test -z "$$locs" || { \
392 echo rm -f $${locs}; \
393 rm -f $${locs}; \
394 }
395
396libhashold.la: $(libhashold_la_OBJECTS) $(libhashold_la_DEPENDENCIES) $(EXTRA_libhashold_la_DEPENDENCIES)
397 $(AM_V_CCLD)$(LINK) -rpath $(libdir) $(libhashold_la_OBJECTS) $(libhashold_la_LIBADD) $(LIBS)
398
399mostlyclean-compile:
400 -rm -f *.$(OBJEXT)
401
402distclean-compile:
403 -rm -f *.tab.c
404
405@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hashit.Plo@am__quote@
406@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hasholdlib.Plo@am__quote@
407
408.c.o:
409@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
410@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
411@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
412@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
413@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c $<
414
415.c.obj:
416@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
417@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
418@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
419@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
420@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c `$(CYGPATH_W) '$<'`
421
422.c.lo:
423@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
424@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
425@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
426@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
427@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
428
429mostlyclean-libtool:
430 -rm -f *.lo
431
432clean-libtool:
433 -rm -rf .libs _libs
434install-includeHEADERS: $(include_HEADERS)
435 @$(NORMAL_INSTALL)
436 @list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \
437 if test -n "$$list"; then \
438 echo " $(MKDIR_P) '$(DESTDIR)$(includedir)'"; \
439 $(MKDIR_P) "$(DESTDIR)$(includedir)" || exit 1; \
440 fi; \
441 for p in $$list; do \
442 if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
443 echo "$$d$$p"; \
444 done | $(am__base_list) | \
445 while read files; do \
446 echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(includedir)'"; \
447 $(INSTALL_HEADER) $$files "$(DESTDIR)$(includedir)" || exit $$?; \
448 done
449
450uninstall-includeHEADERS:
451 @$(NORMAL_UNINSTALL)
452 @list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \
453 files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
454 dir='$(DESTDIR)$(includedir)'; $(am__uninstall_files_from_dir)
455
456ID: $(am__tagged_files)
457 $(am__define_uniq_tagged_files); mkid -fID $$unique
458tags: tags-am
459TAGS: tags
460
461tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
462 set x; \
463 here=`pwd`; \
464 $(am__define_uniq_tagged_files); \
465 shift; \
466 if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
467 test -n "$$unique" || unique=$$empty_fix; \
468 if test $$# -gt 0; then \
469 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
470 "$$@" $$unique; \
471 else \
472 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
473 $$unique; \
474 fi; \
475 fi
476ctags: ctags-am
477
478CTAGS: ctags
479ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
480 $(am__define_uniq_tagged_files); \
481 test -z "$(CTAGS_ARGS)$$unique" \
482 || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
483 $$unique
484
485GTAGS:
486 here=`$(am__cd) $(top_builddir) && pwd` \
487 && $(am__cd) $(top_srcdir) \
488 && gtags -i $(GTAGS_ARGS) "$$here"
489cscopelist: cscopelist-am
490
491cscopelist-am: $(am__tagged_files)
492 list='$(am__tagged_files)'; \
493 case "$(srcdir)" in \
494 [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
495 *) sdir=$(subdir)/$(srcdir) ;; \
496 esac; \
497 for i in $$list; do \
498 if test -f "$$i"; then \
499 echo "$(subdir)/$$i"; \
500 else \
501 echo "$$sdir/$$i"; \
502 fi; \
503 done >> $(top_builddir)/cscope.files
504
505distclean-tags:
506 -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
507
508distdir: $(DISTFILES)
509 @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
510 topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
511 list='$(DISTFILES)'; \
512 dist_files=`for file in $$list; do echo $$file; done | \
513 sed -e "s|^$$srcdirstrip/||;t" \
514 -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
515 case $$dist_files in \
516 */*) $(MKDIR_P) `echo "$$dist_files" | \
517 sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
518 sort -u` ;; \
519 esac; \
520 for file in $$dist_files; do \
521 if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
522 if test -d $$d/$$file; then \
523 dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
524 if test -d "$(distdir)/$$file"; then \
525 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
526 fi; \
527 if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
528 cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
529 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
530 fi; \
531 cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
532 else \
533 test -f "$(distdir)/$$file" \
534 || cp -p $$d/$$file "$(distdir)/$$file" \
535 || exit 1; \
536 fi; \
537 done
538check-am: all-am
539check: check-am
540all-am: Makefile $(LTLIBRARIES) $(HEADERS)
541installdirs:
542 for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(includedir)"; do \
543 test -z "$$dir" || $(MKDIR_P) "$$dir"; \
544 done
545install: install-am
546install-exec: install-exec-am
547install-data: install-data-am
548uninstall: uninstall-am
549
550install-am: all-am
551 @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
552
553installcheck: installcheck-am
554install-strip:
555 if test -z '$(STRIP)'; then \
556 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
557 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
558 install; \
559 else \
560 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
561 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
562 "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
563 fi
564mostlyclean-generic:
565
566clean-generic:
567
568distclean-generic:
569 -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
570 -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
571
572maintainer-clean-generic:
573 @echo "This command is intended for maintainers to use"
574 @echo "it deletes files that may require special tools to rebuild."
575clean: clean-am
576
577clean-am: clean-generic clean-libLTLIBRARIES clean-libtool clean-local \
578 mostlyclean-am
579
580distclean: distclean-am
581 -rm -rf ./$(DEPDIR)
582 -rm -f Makefile
583distclean-am: clean-am distclean-compile distclean-generic \
584 distclean-tags
585
586dvi: dvi-am
587
588dvi-am:
589
590html: html-am
591
592html-am:
593
594info: info-am
595
596info-am:
597
598install-data-am: install-includeHEADERS
599
600install-dvi: install-dvi-am
601
602install-dvi-am:
603
604install-exec-am: install-libLTLIBRARIES
605
606install-html: install-html-am
607
608install-html-am:
609
610install-info: install-info-am
611
612install-info-am:
613
614install-man:
615
616install-pdf: install-pdf-am
617
618install-pdf-am:
619
620install-ps: install-ps-am
621
622install-ps-am:
623
624installcheck-am:
625
626maintainer-clean: maintainer-clean-am
627 -rm -rf ./$(DEPDIR)
628 -rm -f Makefile
629maintainer-clean-am: distclean-am maintainer-clean-generic
630
631mostlyclean: mostlyclean-am
632
633mostlyclean-am: mostlyclean-compile mostlyclean-generic \
634 mostlyclean-libtool
635
636pdf: pdf-am
637
638pdf-am:
639
640ps: ps-am
641
642ps-am:
643
644uninstall-am: uninstall-includeHEADERS uninstall-libLTLIBRARIES
645
646.MAKE: install-am install-strip
647
648.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
649 clean-libLTLIBRARIES clean-libtool clean-local cscopelist-am \
650 ctags ctags-am distclean distclean-compile distclean-generic \
651 distclean-libtool distclean-tags distdir dvi dvi-am html \
652 html-am info info-am install install-am install-data \
653 install-data-am install-dvi install-dvi-am install-exec \
654 install-exec-am install-html install-html-am \
655 install-includeHEADERS install-info install-info-am \
656 install-libLTLIBRARIES install-man install-pdf install-pdf-am \
657 install-ps install-ps-am install-strip installcheck \
658 installcheck-am installdirs maintainer-clean \
659 maintainer-clean-generic mostlyclean mostlyclean-compile \
660 mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
661 tags tags-am uninstall uninstall-am uninstall-includeHEADERS \
662 uninstall-libLTLIBRARIES
663
664default: hashit.c hasholdlib.c libhashold.la
665all: hashit.c hasholdlib.c libhashold.la
666
667hasholdlib.c: hasholdlib_kern.inc hashold_kern.inc
668
669hasholdlib_kern.inc:
670 ./embed_source.pl hasholdlib_kern.cl > hasholdlib_kern.inc
671
672hashold_kern.inc:
673 ./embed_source.pl hashold_kern.cl > hashold_kern.inc
674
675clean-local:
676 rm -f *.inc
677
678# Tell versions [3.59,3.63) of GNU make to not export all variables.
679# Otherwise a system limit (for SysV at least) may be exceeded.
680.NOEXPORT:
oldHash/embed_source.pl +0 -68
……@@ -1,68 +0,0 @@
1eval 'exec perl -w $0 ${1+"$@"}'
2 if 0;
3
4# Copyright 2013-14. Los Alamos National Security, LLC. This material was produced
5# under U.S. Government contract DE-AC52-06NA25396 for Los Alamos National
6# Laboratory (LANL), which is operated by Los Alamos National Security, LLC
7# for the U.S. Department of Energy. The U.S. Government has rights to use,
8# reproduce, and distribute this software. NEITHER THE GOVERNMENT NOR LOS
9# ALAMOS NATIONAL SECURITY, LLC MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR
10# ASSUMES ANY LIABILITY FOR THE USE OF THIS SOFTWARE. If software is modified
11# to produce derivative works, such modified software should be clearly marked,
12# so as not to confuse it with the version available from LANL.
13#
14# Licensed under the Apache License, Version 2.0 (the "License"); you may not
15# use this file except in compliance with the License. You may obtain a copy
16# of the License at
17#
18# http://www.apache.org/licenses/LICENSE-2.0
19#
20# Unless required by applicable law or agreed to in writing, software distributed
21# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
22# CONDITIONS OF ANY KIND, either express or implied. See the License for the
23# specific language governing permissions and limitations under the License.
24#
25# Under this license, it is required to include a reference to this work. We
26# request that each derivative work contain a reference to LANL Copyright
27# Disclosure C14043/LA-CC-14-003 so that this work's impact can be roughly
28# measured. In addition, it is requested that a modifier is included as in
29# the following example:
30#
31# //<Uses | improves on | modified from> LANL Copyright Disclosure C14043/LA-CC-14-003
32#
33# This is LANL Copyright Disclosure C14043/LA-CC-14-003
34
35use File::Basename;
36
37$ARGV_LAST = "";
38
39($file,,) = fileparse($ARGV[0], qr/\..*/);
40print "const char *",$file,"_source =\n";
41
42while(<>) {
43 if ($ARGV ne $ARGV_LAST){
44# $comment = 0;
45 $ARGV_LAST=$ARGV;
46 }
47 chop $_;
48
49 s/"/""/g;
50
51# if (/^\/\*/){
52# #print "Setting comment to 1\n";
53# $comment = 1;
54# }
55# if (/\*\/$/){
56# #print "Setting comment to 0\n";
57# $comment = 0;
58# next;
59# }
60# if ($comment eq 1) {
61# #print "Skip line and goto next\n";
62## next;
63# }
64
65 print '"',$_,'\n','"',"\n";
66}
67
68print ";\n"
oldHash/hashit.c +0 -1266
……@@ -1,1266 +0,0 @@
1/* Copyright 2013-14. Los Alamos National Security, LLC. This material was produced
2 * under U.S. Government contract DE-AC52-06NA25396 for Los Alamos National
3 * Laboratory (LANL), which is operated by Los Alamos National Security, LLC
4 * for the U.S. Department of Energy. The U.S. Government has rights to use,
5 * reproduce, and distribute this software. NEITHER THE GOVERNMENT NOR LOS
6 * ALAMOS NATIONAL SECURITY, LLC MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR
7 * ASSUMES ANY LIABILITY FOR THE USE OF THIS SOFTWARE. If software is modified
8 * to produce derivative works, such modified software should be clearly marked,
9 * so as not to confuse it with the version available from LANL.
10 *
11 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
12 * use this file except in compliance with the License. You may obtain a copy
13 * of the License at
14 *
15 * http://www.apache.org/licenses/LICENSE-2.0
16 *
17 * Unless required by applicable law or agreed to in writing, software distributed
18 * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
19 * CONDITIONS OF ANY KIND, either express or implied. See the License for the
20 * specific language governing permissions and limitations under the License.
21 *
22 * Under this license, it is required to include a reference to this work. We
23 * request that each derivative work contain a reference to LANL Copyright
24 * Disclosure C14043/LA-CC-14-003 so that this work's impact can be roughly
25 * measured. In addition, it is requested that a modifier is included as in
26 * the following example:
27 *
28 * //<Uses | improves on | modified from> LANL Copyright Disclosure C14043/LA-CC-14-003
29 *
30 * This is LANL Copyright Disclosure C14043/LA-CC-14-003
31 */
32
33#include "hashit.h"
34//#include "timer/timer.h"
35
36static ulong AA;
37static ulong BB;
38static ulong prime=4294967291;
39static uint hashtablesize;
40static uint hash_stride;
41static uint hash_ncells;
42static uint write_hash_collisions;
43static uint read_hash_collisions;
44static double write_hash_collisions_runsum = 0.0;
45static double read_hash_collisions_runsum = 0.0;
46static uint write_hash_collisions_count = 0;
47static uint read_hash_collisions_count = 0;
48static uint hash_report_level = 0;
49static uint hash_queries;
50static uint hash_method = 1;
51static uint hash_jump_prime = 41;
52static double hash_mult = 3.0;
53static int do_compact_hash = 0;
54
55float mem_opt_factor;
56
57void compact_hash_delete(int *hash){
58 free(hash);
59}
60
61int (*read_hash)(ulong, int *);
62void (*write_hash)(uint, ulong, int *);
63
64#ifdef _OPENMP
65#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
66void (*write_hash_openmp)(uint, ulong, int *);
67#else
68void (*write_hash_openmp)(uint, ulong, int *, omp_lock_t * lock);
69#endif
70#endif
71
72int get_hash_method(void) {
73 return(hash_method);
74}
75
76long long get_hashtablesize(void) {
77 return(hashtablesize);
78}
79
80int *compact_hash_init(int ncells, uint isize, uint jsize, uint report_level){
81
82 hash_ncells = 0;
83 write_hash_collisions = 0;
84 read_hash_collisions = 0;
85 hash_queries = 0;
86 hash_report_level = report_level;
87 hash_stride = isize;
88 int *hash = NULL;
89
90 uint compact_hash_size = (uint)((double)ncells*hash_mult);
91 compact_hash_size = ncells;
92 uint perfect_hash_size = (uint)(isize*jsize);
93 float hash_mem_factor = 20.0;
94 float hash_mem_ratio = (double)perfect_hash_size/(double)compact_hash_size;
95 if (mem_opt_factor != 1.0) hash_mem_factor /= (mem_opt_factor*0.2);
96 do_compact_hash = (hash_mem_ratio < hash_mem_factor) ? 0 : 1;
97 do_compact_hash = 1;
98 if (hash_report_level >= 2) printf("DEBUG do_compact_hash %d hash_mem_ratio %f hash_mem_factor %f mem_opt_factor %f perfect_hash_size %u compact_hash_size %u\n",do_compact_hash,hash_mem_ratio,hash_mem_factor,mem_opt_factor,perfect_hash_size,compact_hash_size);
99
100 if (do_compact_hash) {
101 hashtablesize = compact_hash_size;
102 AA = (ulong)(1.0+(double)(prime-1)*drand48());
103 BB = (ulong)(0.0+(double)(prime-1)*drand48());
104 if (AA > prime-1 || BB > prime-1) exit(0);
105 if (hash_report_level > 1) printf("Factors AA %lu BB %lu\n",AA,BB);
106
107 hash = (int *)malloc(2*hashtablesize*sizeof(int));
108 for (uint ii = 0; ii<2*hashtablesize; ii+=2){
109 hash[ii] = -1;
110 }
111 } else {
112 hashtablesize = perfect_hash_size;
113
114 hash = (int *)malloc(hashtablesize*sizeof(int));
115 for (uint ii = 0; ii<hashtablesize; ii++){
116 hash[ii] = -1;
117 }
118 }
119
120 if (hash_report_level >= 2) {
121 printf("Hash table size %u perfect hash table size %u memory savings %u by percentage %lf\n",
122 hashtablesize,isize*jsize,isize*jsize-hashtablesize,
123 (double)hashtablesize/(double)(isize*jsize));
124 }
125
126 if (! do_compact_hash) {
127 read_hash = read_hash_perfect;
128 write_hash = write_hash_perfect;
129 } else if (hash_method == 0){
130 if (hash_report_level == 0){
131 read_hash = read_hash_linear;
132 write_hash = write_hash_linear;
133 } else if (hash_report_level == 1){
134 read_hash = read_hash_linear_report_level_1;
135 write_hash = write_hash_linear_report_level_1;
136 } else if (hash_report_level == 2){
137 read_hash = read_hash_linear_report_level_2;
138 write_hash = write_hash_linear_report_level_2;
139 } else if (hash_report_level == 3){
140 read_hash = read_hash_linear_report_level_3;
141 write_hash = write_hash_linear_report_level_3;
142 }
143 } else if (hash_method == 1){
144 if (hash_report_level == 0){
145 read_hash = read_hash_quadratic;
146 write_hash = write_hash_quadratic;
147 } else if (hash_report_level == 1){
148 read_hash = read_hash_quadratic_report_level_1;
149 write_hash = write_hash_quadratic_report_level_1;
150 } else if (hash_report_level == 2){
151 read_hash = read_hash_quadratic_report_level_2;
152 write_hash = write_hash_quadratic_report_level_2;
153 } else if (hash_report_level == 3){
154 read_hash = read_hash_quadratic_report_level_3;
155 write_hash = write_hash_quadratic_report_level_3;
156 }
157 } else if (hash_method == 2){
158 if (hash_report_level == 0){
159 read_hash = read_hash_primejump;
160 write_hash = write_hash_primejump;
161 } else if (hash_report_level == 1){
162 read_hash = read_hash_primejump_report_level_1;
163 write_hash = write_hash_primejump_report_level_1;
164 } else if (hash_report_level == 2){
165 read_hash = read_hash_primejump_report_level_2;
166 write_hash = write_hash_primejump_report_level_2;
167 } else if (hash_report_level == 3){
168 read_hash = read_hash_primejump_report_level_3;
169 write_hash = write_hash_primejump_report_level_3;
170 }
171 }
172
173 return(hash);
174}
175
176void write_hash_perfect(uint ic, ulong hashkey, int *hash){
177 hash[hashkey] = ic;
178}
179
180void write_hash_linear(uint ic, ulong hashkey, int *hash){
181 uint hashloc;
182
183 for (hashloc = (hashkey*AA+BB)%prime%hashtablesize; hash[2*hashloc] != -1 && hash[2*hashloc]!= (int)hashkey; hashloc++,hashloc = hashloc%hashtablesize);
184
185 hash[2*hashloc] = hashkey;
186 hash[2*hashloc+1] = ic;
187}
188
189void write_hash_linear_report_level_1(uint ic, ulong hashkey, int *hash){
190 int icount = 0;
191 uint hashloc;
192
193 hash_ncells++;
194 for (hashloc = (hashkey*AA+BB)%prime%hashtablesize; hash[2*hashloc] != -1 && hash[2*hashloc]!= (int)hashkey; hashloc++,hashloc = hashloc%hashtablesize){
195 write_hash_collisions++;
196 }
197
198 hash[2*hashloc] = hashkey;
199 hash[2*hashloc+1] = ic;
200}
201
202void write_hash_linear_report_level_2(uint ic, ulong hashkey, int *hash){
203 int icount = 0;
204 uint hashloc;
205
206 hash_ncells++;
207 for (hashloc = (hashkey*AA+BB)%prime%hashtablesize; hash[2*hashloc] != -1 && hash[2*hashloc]!= (int)hashkey; hashloc++,hashloc = hashloc%hashtablesize){
208 write_hash_collisions++;
209 }
210
211 hash[2*hashloc] = hashkey;
212 hash[2*hashloc+1] = ic;
213}
214
215void write_hash_linear_report_level_3(uint ic, ulong hashkey, int *hash){
216 int icount = 0;
217 uint hashloc;
218
219 hash_ncells++;
220 hashloc = (hashkey*AA+BB)%prime%hashtablesize;
221 printf("%d: cell %d hashloc is %d hash[2*hashloc] = %d hashkey %lu ii %lu jj %lu\n",icount,ic,hashloc,hash[2*hashloc],hashkey,hashkey%hash_stride,hashkey/hash_stride);
222 for (hashloc = (hashkey*AA+BB)%prime%hashtablesize; hash[2*hashloc] != -1 && hash[2*hashloc]!= (int)hashkey; hashloc++,hashloc = hashloc%hashtablesize){
223 int hashloctmp = hashloc+1;
224 hashloctmp = hashloctmp%hashtablesize;
225 printf("%d: cell %d hashloc is %d hash[2*hashloc] = %d hashkey %lu ii %lu jj %lu\n",icount,ic,hashloctmp,hash[2*hashloctmp],hashkey,hashkey%hash_stride,hashkey/hash_stride);
226 icount++;
227 }
228 write_hash_collisions += icount;
229
230 hash[2*hashloc] = hashkey;
231 hash[2*hashloc+1] = ic;
232}
233
234void write_hash_quadratic(uint ic, ulong hashkey, int *hash){
235 int icount = 0;
236 uint hashloc;
237
238 for (hashloc = (hashkey*AA+BB)%prime%hashtablesize; hash[2*hashloc] != -1 && hash[2*hashloc]!= (int)hashkey; hashloc+=(icount*icount),hashloc = hashloc%hashtablesize) {
239 icount++;
240 }
241
242 hash[2*hashloc] = hashkey;
243 hash[2*hashloc+1] = ic;
244}
245
246void write_hash_quadratic_report_level_1(uint ic, ulong hashkey, int *hash){
247 int icount = 0;
248 uint hashloc;
249
250 hash_ncells++;
251 for (hashloc = (hashkey*AA+BB)%prime%hashtablesize; hash[2*hashloc] != -1 && hash[2*hashloc]!= (int)hashkey; hashloc+=(icount*icount),hashloc = hashloc%hashtablesize){
252 icount++;
253 }
254 write_hash_collisions += icount;
255
256 hash[2*hashloc] = hashkey;
257 hash[2*hashloc+1] = ic;
258}
259
260void write_hash_quadratic_report_level_2(uint ic, ulong hashkey, int *hash){
261 int icount = 0;
262 uint hashloc;
263
264 hash_ncells++;
265 for (hashloc = (hashkey*AA+BB)%prime%hashtablesize; hash[2*hashloc] != -1 && hash[2*hashloc]!= (int)hashkey; hashloc+=(icount*icount),hashloc = hashloc%hashtablesize){
266 icount++;
267 }
268 write_hash_collisions += icount;
269
270 hash[2*hashloc] = hashkey;
271 hash[2*hashloc+1] = ic;
272}
273
274void write_hash_quadratic_report_level_3(uint ic, ulong hashkey, int *hash){
275 int icount = 0;
276 uint hashloc;
277
278 hash_ncells++;
279 hashloc = (hashkey*AA+BB)%prime%hashtablesize;
280 printf("%d: cell %d hashloc is %d hash[2*hashloc] = %d hashkey %lu ii %lu jj %lu\n",icount,ic,hashloc,hash[2*hashloc],hashkey,hashkey%hash_stride,hashkey/hash_stride);
281 for (hashloc = (hashkey*AA+BB)%prime%hashtablesize; hash[2*hashloc] != -1 && hash[2*hashloc]!= (int)hashkey; hashloc+=(icount*icount),hashloc = hashloc%hashtablesize){
282 icount++;
283 int hashloctmp = hashloc+icount*icount;
284 hashloctmp = hashloctmp%hashtablesize;
285 printf("%d: cell %d hashloc is %d hash[2*hashloc] = %d hashkey %lu ii %lu jj %lu\n",icount,ic,hashloctmp,hash[2*hashloctmp],hashkey,hashkey%hash_stride,hashkey/hash_stride);
286 }
287 write_hash_collisions += icount;
288
289 hash[2*hashloc] = hashkey;
290 hash[2*hashloc+1] = ic;
291}
292
293void write_hash_primejump(uint ic, ulong hashkey, int *hash){
294 int icount = 0;
295 uint hashloc;
296
297 uint jump = 1+hashkey%hash_jump_prime;
298
299 for (hashloc = (hashkey*AA+BB)%prime%hashtablesize; hash[2*hashloc] != -1 && hash[2*hashloc]!= (int)hashkey; hashloc+=(icount*jump),hashloc = hashloc%hashtablesize) {
300 icount++;
301 }
302
303 hash[2*hashloc] = hashkey;
304 hash[2*hashloc+1] = ic;
305}
306
307void write_hash_primejump_report_level_1(uint ic, ulong hashkey, int *hash){
308 int icount = 0;
309 uint hashloc;
310
311 uint jump = 1+hashkey%hash_jump_prime;
312
313 hash_ncells++;
314 for (hashloc = (hashkey*AA+BB)%prime%hashtablesize; hash[2*hashloc] != -1 && hash[2*hashloc]!= (int)hashkey; hashloc+=(icount*jump),hashloc = hashloc%hashtablesize){
315 icount++;
316 }
317 write_hash_collisions += icount;
318
319 hash[2*hashloc] = hashkey;
320 hash[2*hashloc+1] = ic;
321}
322
323void write_hash_primejump_report_level_2(uint ic, ulong hashkey, int *hash){
324 int icount = 0;
325 uint hashloc;
326
327 uint jump = 1+hashkey%hash_jump_prime;
328
329 hash_ncells++;
330 for (hashloc = (hashkey*AA+BB)%prime%hashtablesize; hash[2*hashloc] != -1 && hash[2*hashloc]!= (int)hashkey; hashloc+=(icount*jump),hashloc = hashloc%hashtablesize){
331 icount++;
332 }
333 write_hash_collisions += icount;
334
335 hash[2*hashloc] = hashkey;
336 hash[2*hashloc+1] = ic;
337}
338
339void write_hash_primejump_report_level_3(uint ic, ulong hashkey, int *hash){
340 int icount = 0;
341 uint hashloc;
342
343 uint jump = 1+hashkey%hash_jump_prime;
344
345 hash_ncells++;
346 hashloc = (hashkey*AA+BB)%prime%hashtablesize;
347 printf("%d: cell %d hashloc is %d hash[2*hashloc] = %d hashkey %lu ii %lu jj %lu\n",icount,ic,hashloc,hash[2*hashloc],hashkey,hashkey%hash_stride,hashkey/hash_stride);
348 for (hashloc = (hashkey*AA+BB)%prime%hashtablesize; hash[2*hashloc] != -1 && hash[2*hashloc]!= (int)hashkey; hashloc+=(icount*jump),hashloc = hashloc%hashtablesize){
349 icount++;
350 int hashloctmp = hashloc+1;
351 hashloctmp = hashloctmp%hashtablesize;
352 printf("%d: cell %d hashloc is %d hash[2*hashloc] = %d hashkey %lu ii %lu jj %lu\n",icount,ic,hashloctmp,hash[2*hashloctmp],hashkey,hashkey%hash_stride,hashkey/hash_stride);
353 }
354 write_hash_collisions += icount;
355
356 hash[2*hashloc] = hashkey;
357 hash[2*hashloc+1] = ic;
358}
359
360#ifdef _OPENMP
361
362#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
363void write_hash_perfect_openmp(uint ic, ulong hashkey, int *hash){
364#else
365void write_hash_perfect_openmp(uint ic, ulong hashkey, int *hash, omp_lock_t *lock){
366#endif
367 hash[hashkey] = ic;
368}
369
370#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
371void write_hash_linear_openmp(uint ic, ulong hashkey, int *hash){
372#else
373void write_hash_linear_openmp(uint ic, ulong hashkey, int *hash, omp_lock_t *lock){
374#endif
375 int icount;
376 uint hashloc = (hashkey*AA+BB)%prime%hashtablesize;;
377
378#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
379 int MaxTries = 1000;
380
381 int old_key = __sync_val_compare_and_swap(&hash[2*hashloc], -1, hashkey);
382 //printf("old_key is %d\n",old_key);
383
384 for (icount = 1; old_key != hashkey && old_key != -1 && icount < MaxTries; icount++){
385 hashloc++;
386 hashloc %= hashtablesize;
387
388 old_key = __sync_val_compare_and_swap(&hash[2*hashloc], -1, hashkey);
389 }
390
391 if (icount < MaxTries) hash[2*hashloc+1] = ic;
392#else
393 omp_set_lock(&(lock[hashloc]));
394 while (hash[2*hashloc] != -1 && hash[2*hashloc]!= (int)hashkey){
395 omp_unset_lock(&(lock[hashloc]));
396 hashloc++;
397 hashloc = hashloc%hashtablesize;
398 omp_set_lock(&(lock[hashloc]));
399 }
400
401 hash[2*hashloc] = hashkey;
402 hash[2*hashloc+1] = ic;
403 omp_unset_lock(&(lock[hashloc]));
404#endif
405}
406
407#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
408void write_hash_linear_openmp_report_level_1(uint ic, ulong hashkey, int *hash){
409#else
410void write_hash_linear_openmp_report_level_1(uint ic, ulong hashkey, int *hash, omp_lock_t *lock){
411#endif
412 int icount = 0;
413 uint hashloc = (hashkey*AA+BB)%prime%hashtablesize;;
414
415#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
416 int MaxTries = 1000;
417
418 int old_key = __sync_val_compare_and_swap(&hash[2*hashloc], -1, hashkey);
419 //printf("old_key is %d\n",old_key);
420
421 for (icount = 1; old_key != hashkey && old_key != -1 && icount < MaxTries; icount++){
422 hashloc++;
423 hashloc %= hashtablesize;
424
425 old_key = __sync_val_compare_and_swap(&hash[2*hashloc], -1, hashkey);
426 icount++;
427 }
428
429 if (icount < MaxTries) hash[2*hashloc+1] = ic;
430#else
431 omp_set_lock(&(lock[hashloc]));
432 while (hash[2*hashloc] != -1 && hash[2*hashloc]!= (int)hashkey){
433 omp_unset_lock(&(lock[hashloc]));
434 hashloc++;
435 hashloc = hashloc%hashtablesize;
436 omp_set_lock(&(lock[hashloc]));
437 icount++;
438 }
439
440 hash[2*hashloc] = hashkey;
441 hash[2*hashloc+1] = ic;
442 omp_unset_lock(&(lock[hashloc]));
443#endif
444
445#pragma omp atomic
446 write_hash_collisions += icount;;
447#pragma omp atomic
448 hash_ncells++;
449}
450
451#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
452void write_hash_linear_openmp_report_level_2(uint ic, ulong hashkey, int *hash){
453#else
454void write_hash_linear_openmp_report_level_2(uint ic, ulong hashkey, int *hash, omp_lock_t *lock){
455#endif
456 int icount = 0;
457 uint hashloc = (hashkey*AA+BB)%prime%hashtablesize;;
458
459#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
460 int MaxTries = 1000;
461
462 int old_key = __sync_val_compare_and_swap(&hash[2*hashloc], -1, hashkey);
463 //printf("old_key is %d\n",old_key);
464
465 for (icount = 1; old_key != hashkey && old_key != -1 && icount < MaxTries; icount++){
466 hashloc++;
467 hashloc %= hashtablesize;
468
469 old_key = __sync_val_compare_and_swap(&hash[2*hashloc], -1, hashkey);
470 icount++;
471 }
472
473 if (icount < MaxTries) hash[2*hashloc+1] = ic;
474#else
475 omp_set_lock(&(lock[hashloc]));
476 while (hash[2*hashloc] != -1 && hash[2*hashloc]!= (int)hashkey){
477 omp_unset_lock(&(lock[hashloc]));
478 hashloc++;
479 hashloc = hashloc%hashtablesize;
480 omp_set_lock(&(lock[hashloc]));
481 icount++;
482 }
483
484 hash[2*hashloc] = hashkey;
485 hash[2*hashloc+1] = ic;
486 omp_unset_lock(&(lock[hashloc]));
487#endif
488
489#pragma omp atomic
490 write_hash_collisions += icount;;
491#pragma omp atomic
492 hash_ncells++;
493}
494
495#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
496void write_hash_linear_openmp_report_level_3(uint ic, ulong hashkey, int *hash){
497#else
498void write_hash_linear_openmp_report_level_3(uint ic, ulong hashkey, int *hash, omp_lock_t *lock){
499#endif
500 int icount = 0;
501 uint hashloc = (hashkey*AA+BB)%prime%hashtablesize;;
502 printf("%d: cell %d hashloc is %d hash[2*hashloc] = %d hashkey %lu ii %lu jj %lu\n",icount,ic,hashloc,hash[2*hashloc],hashkey,hashkey%hash_stride,hashkey/hash_stride);
503
504#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
505 int MaxTries = 1000;
506
507 int old_key = __sync_val_compare_and_swap(&hash[2*hashloc], -1, hashkey);
508 //printf("old_key is %d\n",old_key);
509
510 for (icount = 1; old_key != hashkey && old_key != -1 && icount < MaxTries; icount++){
511 hashloc++;
512 hashloc %= hashtablesize;
513 printf("%d: cell %d hashloc is %d hash[2*hashloc] = %d hashkey %lu ii %lu jj %lu\n",icount,ic,hashloc,hash[2*hashloc],hashkey,hashkey%hash_stride,hashkey/hash_stride);
514
515 old_key = __sync_val_compare_and_swap(&hash[2*hashloc], -1, hashkey);
516 icount++;
517 }
518
519 if (icount < MaxTries) hash[2*hashloc+1] = ic;
520#else
521 omp_set_lock(&(lock[hashloc]));
522 while (hash[2*hashloc] != -1 && hash[2*hashloc]!= (int)hashkey){
523 omp_unset_lock(&(lock[hashloc]));
524 hashloc++;
525 hashloc = hashloc%hashtablesize;
526 printf("%d: cell %d hashloc is %d hash[2*hashloc] = %d hashkey %lu ii %lu jj %lu\n",icount,ic,hashloc,hash[2*hashloc],hashkey,hashkey%hash_stride,hashkey/hash_stride);
527 omp_set_lock(&(lock[hashloc]));
528 icount++;
529 }
530
531 hash[2*hashloc] = hashkey;
532 hash[2*hashloc+1] = ic;
533 omp_unset_lock(&(lock[hashloc]));
534#endif
535
536#pragma omp atomic
537 write_hash_collisions += icount;;
538#pragma omp atomic
539 hash_ncells++;
540}
541
542#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
543void write_hash_quadratic_openmp(uint ic, ulong hashkey, int *hash){
544#else
545void write_hash_quadratic_openmp(uint ic, ulong hashkey, int *hash, omp_lock_t *lock){
546#endif
547 int icount = 0;
548 uint hashloc = (hashkey*AA+BB)%prime%hashtablesize;
549
550#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
551 int MaxTries = 1000;
552
553 int old_key = __sync_val_compare_and_swap(&hash[2*hashloc], -1, hashkey);
554 //printf("old_key is %d\n",old_key);
555
556 for (icount = 1; old_key != hashkey && old_key != -1 && icount < MaxTries; icount++){
557 hashloc+=(icount*icount);
558 hashloc %= hashtablesize;
559
560 old_key = __sync_val_compare_and_swap(&hash[2*hashloc], -1, hashkey);
561 }
562
563 if (icount < MaxTries) hash[2*hashloc+1] = ic;
564#else
565 omp_set_lock(&(lock[hashloc]));
566 while (hash[2*hashloc] != -1 && hash[2*hashloc]!= (int)hashkey){
567 omp_unset_lock(&(lock[hashloc]));
568 icount++;
569 hashloc+=(icount*icount);
570 hashloc = hashloc%hashtablesize;
571 omp_set_lock(&(lock[hashloc]));
572 }
573
574 hash[2*hashloc] = hashkey;
575 hash[2*hashloc+1] = ic;
576 omp_unset_lock(&(lock[hashloc]));
577#endif
578}
579
580#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
581void write_hash_quadratic_openmp_report_level_1(uint ic, ulong hashkey, int *hash){
582#else
583void write_hash_quadratic_openmp_report_level_1(uint ic, ulong hashkey, int *hash, omp_lock_t *lock){
584#endif
585 int icount = 0;
586 uint hashloc = (hashkey*AA+BB)%prime%hashtablesize;
587
588#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
589 int MaxTries = 1000;
590
591 int old_key = __sync_val_compare_and_swap(&hash[2*hashloc], -1, hashkey);
592 //printf("old_key is %d\n",old_key);
593
594 for (icount = 1; old_key != hashkey && old_key != -1 && icount < MaxTries; icount++){
595 hashloc+=(icount*icount);
596 hashloc %= hashtablesize;
597
598 old_key = __sync_val_compare_and_swap(&hash[2*hashloc], -1, hashkey);
599 }
600
601 if (icount < MaxTries) hash[2*hashloc+1] = ic;
602#else
603 omp_set_lock(&(lock[hashloc]));
604 while (hash[2*hashloc] != -1 && hash[2*hashloc]!= (int)hashkey){
605 omp_unset_lock(&(lock[hashloc]));
606 icount++;
607 hashloc+=(icount*icount);
608 hashloc = hashloc%hashtablesize;
609 omp_set_lock(&(lock[hashloc]));
610 }
611
612 hash[2*hashloc] = hashkey;
613 hash[2*hashloc+1] = ic;
614 omp_unset_lock(&(lock[hashloc]));
615#endif
616
617#pragma omp atomic
618 write_hash_collisions += icount;;
619#pragma omp atomic
620 hash_ncells++;
621}
622
623#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
624void write_hash_quadratic_openmp_report_level_2(uint ic, ulong hashkey, int *hash){
625#else
626void write_hash_quadratic_openmp_report_level_2(uint ic, ulong hashkey, int *hash, omp_lock_t *lock){
627#endif
628 int icount = 0;
629 uint hashloc = (hashkey*AA+BB)%prime%hashtablesize;
630
631#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
632 int MaxTries = 1000;
633
634 int old_key = __sync_val_compare_and_swap(&hash[2*hashloc], -1, hashkey);
635 //printf("old_key is %d\n",old_key);
636
637 for (icount = 1; old_key != hashkey && old_key != -1 && icount < MaxTries; icount++){
638 hashloc+=(icount*icount);
639 hashloc %= hashtablesize;
640
641 old_key = __sync_val_compare_and_swap(&hash[2*hashloc], -1, hashkey);
642 }
643
644 if (icount < MaxTries) hash[2*hashloc+1] = ic;
645#else
646 omp_set_lock(&(lock[hashloc]));
647 while (hash[2*hashloc] != -1 && hash[2*hashloc]!= (int)hashkey){
648 omp_unset_lock(&(lock[hashloc]));
649 icount++;
650 hashloc+=(icount*icount);
651 hashloc = hashloc%hashtablesize;
652 omp_set_lock(&(lock[hashloc]));
653 }
654
655 hash[2*hashloc] = hashkey;
656 hash[2*hashloc+1] = ic;
657 omp_unset_lock(&(lock[hashloc]));
658#endif
659
660#pragma omp atomic
661 write_hash_collisions += icount;;
662#pragma omp atomic
663 hash_ncells++;
664}
665
666#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
667void write_hash_quadratic_openmp_report_level_3(uint ic, ulong hashkey, int *hash){
668#else
669void write_hash_quadratic_openmp_report_level_3(uint ic, ulong hashkey, int *hash, omp_lock_t *lock){
670#endif
671 int icount = 0;
672 uint hashloc = (hashkey*AA+BB)%prime%hashtablesize;
673 printf("%d: cell %d hashloc is %d hash[2*hashloc] = %d hashkey %lu ii %lu jj %lu\n",icount,ic,hashloc,hash[2*hashloc],hashkey,hashkey%hash_stride,hashkey/hash_stride);
674
675#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
676 int MaxTries = 1000;
677
678 int old_key = __sync_val_compare_and_swap(&hash[2*hashloc], -1, hashkey);
679 //printf("old_key is %d\n",old_key);
680
681 for (icount = 1; old_key != hashkey && old_key != -1 && icount < MaxTries; icount++){
682 hashloc+=(icount*icount);
683 hashloc %= hashtablesize;
684 printf("%d: cell %d hashloc is %d hash[2*hashloc] = %d hashkey %lu ii %lu jj %lu\n",icount,ic,hashloc,hash[2*hashloc],hashkey,hashkey%hash_stride,hashkey/hash_stride);
685
686 old_key = __sync_val_compare_and_swap(&hash[2*hashloc], -1, hashkey);
687 }
688
689 if (icount < MaxTries) hash[2*hashloc+1] = ic;
690#else
691 omp_set_lock(&(lock[hashloc]));
692 while (hash[2*hashloc] != -1 && hash[2*hashloc]!= (int)hashkey){
693 omp_unset_lock(&(lock[hashloc]));
694 icount++;
695 hashloc+=(icount*icount);
696 hashloc = hashloc%hashtablesize;
697 printf("%d: cell %d hashloc is %d hash[2*hashloc] = %d hashkey %lu ii %lu jj %lu\n",icount,ic,hashloc,hash[2*hashloc],hashkey,hashkey%hash_stride,hashkey/hash_stride);
698 omp_set_lock(&(lock[hashloc]));
699 }
700
701 hash[2*hashloc] = hashkey;
702 hash[2*hashloc+1] = ic;
703 omp_unset_lock(&(lock[hashloc]));
704#endif
705
706#pragma omp atomic
707 write_hash_collisions += icount;;
708#pragma omp atomic
709 hash_ncells++;
710}
711
712#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
713void write_hash_primejump_openmp(uint ic, ulong hashkey, int *hash){
714#else
715void write_hash_primejump_openmp(uint ic, ulong hashkey, int *hash, omp_lock_t *lock){
716#endif
717 int icount = 0;
718 uint jump = 1+hashkey%hash_jump_prime;
719 uint hashloc = (hashkey*AA+BB)%prime%hashtablesize;
720
721#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
722 int MaxTries = 1000;
723
724 int old_key = __sync_val_compare_and_swap(&hash[2*hashloc], -1, hashkey);
725 //printf("old_key is %d\n",old_key);
726
727 for (icount = 1; old_key != hashkey && old_key != -1 && icount < MaxTries; icount++){
728 hashloc+=(icount*jump);
729 hashloc %= hashtablesize;
730
731 old_key = __sync_val_compare_and_swap(&hash[2*hashloc], -1, hashkey);
732 }
733
734 if (icount < MaxTries) hash[2*hashloc+1] = ic;
735#else
736 omp_set_lock(&(lock[hashloc]));
737 while (hash[2*hashloc] != -1 && hash[2*hashloc]!= (int)hashkey){
738 omp_unset_lock(&(lock[hashloc]));
739 icount++;
740 hashloc+=(icount*jump);
741 hashloc = hashloc%hashtablesize;
742 omp_set_lock(&(lock[hashloc]));
743 }
744
745 hash[2*hashloc] = hashkey;
746 hash[2*hashloc+1] = ic;
747 omp_unset_lock(&(lock[hashloc]));
748#endif
749}
750
751#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
752void write_hash_primejump_openmp_report_level_1(uint ic, ulong hashkey, int *hash){
753#else
754void write_hash_primejump_openmp_report_level_1(uint ic, ulong hashkey, int *hash, omp_lock_t *lock){
755#endif
756 int icount = 0;
757 uint jump = 1+hashkey%hash_jump_prime;
758 uint hashloc = (hashkey*AA+BB)%prime%hashtablesize;
759
760#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
761 int MaxTries = 1000;
762
763 int old_key = __sync_val_compare_and_swap(&hash[2*hashloc], -1, hashkey);
764 //printf("old_key is %d\n",old_key);
765
766 for (icount = 1; old_key != hashkey && old_key != -1 && icount < MaxTries; icount++){
767 hashloc+=(icount*jump);
768 hashloc %= hashtablesize;
769
770 old_key = __sync_val_compare_and_swap(&hash[2*hashloc], -1, hashkey);
771 }
772
773 if (icount < MaxTries) hash[2*hashloc+1] = ic;
774#else
775 omp_set_lock(&(lock[hashloc]));
776 while (hash[2*hashloc] != -1 && hash[2*hashloc]!= (int)hashkey){
777 omp_unset_lock(&(lock[hashloc]));
778 icount++;
779 hashloc+=(icount*jump);
780 hashloc = hashloc%hashtablesize;
781 omp_set_lock(&(lock[hashloc]));
782 }
783
784 hash[2*hashloc] = hashkey;
785 hash[2*hashloc+1] = ic;
786 omp_unset_lock(&(lock[hashloc]));
787#endif
788
789#pragma omp atomic
790 write_hash_collisions += icount;;
791#pragma omp atomic
792 hash_ncells++;
793}
794
795#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
796void write_hash_primejump_openmp_report_level_2(uint ic, ulong hashkey, int *hash){
797#else
798void write_hash_primejump_openmp_report_level_2(uint ic, ulong hashkey, int *hash, omp_lock_t *lock){
799#endif
800 int icount = 0;
801 uint jump = 1+hashkey%hash_jump_prime;
802 uint hashloc = (hashkey*AA+BB)%prime%hashtablesize;
803
804#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
805 int MaxTries = 1000;
806
807 int old_key = __sync_val_compare_and_swap(&hash[2*hashloc], -1, hashkey);
808 //printf("old_key is %d\n",old_key);
809
810 for (icount = 1; old_key != hashkey && old_key != -1 && icount < MaxTries; icount++){
811 hashloc+=(icount*jump);
812 hashloc %= hashtablesize;
813
814 old_key = __sync_val_compare_and_swap(&hash[2*hashloc], -1, hashkey);
815 }
816
817 if (icount < MaxTries) hash[2*hashloc+1] = ic;
818#else
819 omp_set_lock(&(lock[hashloc]));
820 while (hash[2*hashloc] != -1 && hash[2*hashloc]!= (int)hashkey){
821 omp_unset_lock(&(lock[hashloc]));
822 icount++;
823 hashloc+=(icount*jump);
824 hashloc = hashloc%hashtablesize;
825 omp_set_lock(&(lock[hashloc]));
826 }
827
828 hash[2*hashloc] = hashkey;
829 hash[2*hashloc+1] = ic;
830 omp_unset_lock(&(lock[hashloc]));
831#endif
832
833#pragma omp atomic
834 write_hash_collisions += icount;;
835#pragma omp atomic
836 hash_ncells++;
837}
838
839#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
840void write_hash_primejump_openmp_report_level_3(uint ic, ulong hashkey, int *hash){
841#else
842void write_hash_primejump_openmp_report_level_3(uint ic, ulong hashkey, int *hash, omp_lock_t *lock){
843#endif
844 int icount = 0;
845 uint jump = 1+hashkey%hash_jump_prime;
846 uint hashloc = (hashkey*AA+BB)%prime%hashtablesize;
847 printf("%d: cell %d hashloc is %d hash[2*hashloc] = %d hashkey %lu ii %lu jj %lu\n",icount,ic,hashloc,hash[2*hashloc],hashkey,hashkey%hash_stride,hashkey/hash_stride);
848
849#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
850 int MaxTries = 1000;
851
852 int old_key = __sync_val_compare_and_swap(&hash[2*hashloc], -1, hashkey);
853 //printf("old_key is %d\n",old_key);
854
855 for (icount = 1; old_key != hashkey && old_key != -1 && icount < MaxTries; icount++){
856 hashloc+=(icount*jump);
857 hashloc %= hashtablesize;
858 printf("%d: cell %d hashloc is %d hash[2*hashloc] = %d hashkey %lu ii %lu jj %lu\n",icount,ic,hashloc,hash[2*hashloc],hashkey,hashkey%hash_stride,hashkey/hash_stride);
859
860 old_key = __sync_val_compare_and_swap(&hash[2*hashloc], -1, hashkey);
861 }
862
863 if (icount < MaxTries) hash[2*hashloc+1] = ic;
864#else
865 omp_set_lock(&(lock[hashloc]));
866 while (hash[2*hashloc] != -1 && hash[2*hashloc]!= (int)hashkey){
867 omp_unset_lock(&(lock[hashloc]));
868 icount++;
869 hashloc+=(icount*jump);
870 hashloc = hashloc%hashtablesize;
871 printf("%d: cell %d hashloc is %d hash[2*hashloc] = %d hashkey %lu ii %lu jj %lu\n",icount,ic,hashloc,hash[2*hashloc],hashkey,hashkey%hash_stride,hashkey/hash_stride);
872 omp_set_lock(&(lock[hashloc]));
873 }
874
875 hash[2*hashloc] = hashkey;
876 hash[2*hashloc+1] = ic;
877 omp_unset_lock(&(lock[hashloc]));
878#endif
879
880#pragma omp atomic
881 write_hash_collisions += icount;;
882#pragma omp atomic
883 hash_ncells++;
884}
885#endif
886
887int read_hash_perfect(ulong hashkey, int *hash){
888 return(hash[hashkey]);
889}
890
891int read_hash_linear(ulong hashkey, int *hash){
892 int hashval = -1;
893 uint hashloc;
894 for (hashloc = (hashkey*AA+BB)%prime%hashtablesize; hash[2*hashloc] != (int)hashkey && hash[2*hashloc] != -1; hashloc++,hashloc = hashloc%hashtablesize);
895
896 if (hash[2*hashloc] != -1) hashval = hash[2*hashloc+1];
897 return(hashval);
898}
899
900int read_hash_linear_report_level_1(ulong hashkey, int *hash){
901 int hashval = -1;
902 uint hashloc;
903 int icount=0;
904
905 hash_queries++;
906 for (hashloc = (hashkey*AA+BB)%prime%hashtablesize; hash[2*hashloc] != (int)hashkey && hash[2*hashloc] != -1; hashloc++,hashloc = hashloc%hashtablesize){
907 icount++;
908 }
909 read_hash_collisions += icount;
910
911 if (hash[2*hashloc] != -1) hashval = hash[2*hashloc+1];
912 return(hashval);
913}
914
915int read_hash_linear_report_level_2(ulong hashkey, int *hash){
916 int max_collisions_allowed = 1000;
917 int hashval = -1;
918 uint hashloc;
919 int icount=0;
920
921 hash_queries++;
922 for (hashloc = (hashkey*AA+BB)%prime%hashtablesize; hash[2*hashloc] != (int)hashkey && hash[2*hashloc] != -1; hashloc++,hashloc = hashloc%hashtablesize){
923 icount++;
924 if (icount > max_collisions_allowed) {
925 printf("Error -- too many read hash collisions\n");
926 exit(0);
927 }
928 }
929 read_hash_collisions += icount;
930
931 if (hash[2*hashloc] != -1) hashval = hash[2*hashloc+1];
932 return(hashval);
933}
934
935int read_hash_linear_report_level_3(ulong hashkey, int *hash){
936 int max_collisions_allowed = 1000;
937 int hashval = -1;
938 uint hashloc;
939 int icount=0;
940
941 hash_queries++;
942 hashloc = (hashkey*AA+BB)%prime%hashtablesize;
943 printf("%d: hashloc is %d hash[2*hashloc] = %d hashkey %lu ii %lu jj %lu\n",icount,hashloc,hash[2*hashloc],hashkey,hashkey%hash_stride,hashkey/hash_stride);
944 for (hashloc = (hashkey*AA+BB)%prime%hashtablesize; hash[2*hashloc] != (int)hashkey && hash[2*hashloc] != -1; hashloc++,hashloc = hashloc%hashtablesize){
945 icount++;
946 uint hashloctmp = hashloc+1;
947 hashloctmp = hashloctmp%hashtablesize;
948 printf("%d: hashloc is %d hash[2*hashloc] = %d hashkey %lu ii %lu jj %lu\n",icount,hashloctmp,hash[2*hashloctmp],hashkey,hashkey%hash_stride,hashkey/hash_stride);
949 if (icount > max_collisions_allowed) {
950 printf("Error -- too many read hash collisions\n");
951 exit(0);
952 }
953 }
954 read_hash_collisions += icount;
955
956 if (hash[2*hashloc] != -1) hashval = hash[2*hashloc+1];
957 return(hashval);
958}
959
960int read_hash_quadratic(ulong hashkey, int *hash){
961 int hashval = -1;
962 uint hashloc;
963 int icount=0;
964
965 for (hashloc = (hashkey*AA+BB)%prime%hashtablesize; hash[2*hashloc] != (int)hashkey && hash[2*hashloc] != -1; hashloc+=(icount*icount),hashloc = hashloc%hashtablesize){
966 icount++;
967 }
968
969 if (hash[2*hashloc] != -1) hashval = hash[2*hashloc+1];
970 return(hashval);
971}
972
973int read_hash_quadratic_report_level_1(ulong hashkey, int *hash){
974 int hashval = -1;
975 uint hashloc;
976 int icount=0;
977
978 hash_queries++;
979 for (hashloc = (hashkey*AA+BB)%prime%hashtablesize; hash[2*hashloc] != (int)hashkey && hash[2*hashloc] != -1; hashloc+=(icount*icount),hashloc = hashloc%hashtablesize){
980 icount++;
981 }
982 read_hash_collisions += icount;
983
984 if (hash[2*hashloc] != -1) hashval = hash[2*hashloc+1];
985 return(hashval);
986}
987
988int read_hash_quadratic_report_level_2(ulong hashkey, int *hash){
989 int max_collisions_allowed = 1000;
990 int hashval = -1;
991 uint hashloc;
992 int icount=0;
993
994 hash_queries++;
995 for (hashloc = (hashkey*AA+BB)%prime%hashtablesize; hash[2*hashloc] != (int)hashkey && hash[2*hashloc] != -1; hashloc+=(icount*icount),hashloc = hashloc%hashtablesize){
996 icount++;
997 if (icount > max_collisions_allowed) {
998 printf("Error -- too many read hash collisions\n");
999 exit(0);
1000 }
1001 }
1002 read_hash_collisions += icount;
1003
1004 if (hash[2*hashloc] != -1) hashval = hash[2*hashloc+1];
1005 return(hashval);
1006}
1007
1008int read_hash_quadratic_report_level_3(ulong hashkey, int *hash){
1009 int max_collisions_allowed = 1000;
1010 int hashval = -1;
1011 uint hashloc;
1012 int icount=0;
1013
1014 hash_queries++;
1015 hashloc = (hashkey*AA+BB)%prime%hashtablesize;
1016 printf("%d: hashloc is %d hash[2*hashloc] = %d hashkey %lu ii %lu jj %lu\n",icount,hashloc,hash[2*hashloc],hashkey,hashkey%hash_stride,hashkey/hash_stride);
1017 for (hashloc = (hashkey*AA+BB)%prime%hashtablesize; hash[2*hashloc] != (int)hashkey && hash[2*hashloc] != -1; hashloc+=(icount*icount),hashloc = hashloc%hashtablesize){
1018 icount++;
1019 uint hashloctmp = hashloc+1;
1020 hashloctmp = hashloctmp%hashtablesize;
1021 printf("%d: hashloc is %d hash[2*hashloc] = %d hashkey %lu ii %lu jj %lu\n",icount,hashloctmp,hash[2*hashloctmp],hashkey,hashkey%hash_stride,hashkey/hash_stride);
1022 if (icount > max_collisions_allowed) {
1023 printf("Error -- too many read hash collisions\n");
1024 exit(0);
1025 }
1026 }
1027 read_hash_collisions += icount;
1028
1029 if (hash[2*hashloc] != -1) hashval = hash[2*hashloc+1];
1030 return(hashval);
1031}
1032
1033int read_hash_primejump(ulong hashkey, int *hash){
1034 int hashval = -1;
1035 uint hashloc;
1036 int icount=0;
1037
1038 uint jump = 1+hashkey%hash_jump_prime;
1039 for (hashloc = (hashkey*AA+BB)%prime%hashtablesize; hash[2*hashloc] != (int)hashkey && hash[2*hashloc] != -1; hashloc+=(icount*jump),hashloc = hashloc%hashtablesize){
1040 icount++;
1041 }
1042
1043 if (hash[2*hashloc] != -1) hashval = hash[2*hashloc+1];
1044 return(hashval);
1045}
1046
1047int read_hash_primejump_report_level_1(ulong hashkey, int *hash){
1048 int hashval = -1;
1049 uint hashloc;
1050 int icount=0;
1051
1052 uint jump = 1+hashkey%hash_jump_prime;
1053 hash_queries++;
1054 for (hashloc = (hashkey*AA+BB)%prime%hashtablesize; hash[2*hashloc] != (int)hashkey && hash[2*hashloc] != -1; hashloc+=(icount*jump),hashloc = hashloc%hashtablesize){
1055 icount++;
1056 }
1057 read_hash_collisions += icount;
1058
1059 if (hash[2*hashloc] != -1) hashval = hash[2*hashloc+1];
1060 return(hashval);
1061}
1062
1063int read_hash_primejump_report_level_2(ulong hashkey, int *hash){
1064 int max_collisions_allowed = 1000;
1065 int hashval = -1;
1066 uint hashloc;
1067 int icount=0;
1068
1069 uint jump = 1+hashkey%hash_jump_prime;
1070
1071 hash_queries++;
1072 for (hashloc = (hashkey*AA+BB)%prime%hashtablesize; hash[2*hashloc] != (int)hashkey && hash[2*hashloc] != -1; hashloc+=(icount*jump),hashloc = hashloc%hashtablesize){
1073 icount++;
1074 if (icount > max_collisions_allowed) {
1075 printf("Error -- too many read hash collisions\n");
1076 exit(0);
1077 }
1078 }
1079 read_hash_collisions += icount;
1080
1081 if (hash[2*hashloc] != -1) hashval = hash[2*hashloc+1];
1082 return(hashval);
1083}
1084
1085int read_hash_primejump_report_level_3(ulong hashkey, int *hash){
1086 int max_collisions_allowed = 1000;
1087 int hashval = -1;
1088 uint hashloc;
1089 int icount=0;
1090
1091 uint jump = 1+hashkey%hash_jump_prime;
1092
1093 hash_queries++;
1094 hashloc = (hashkey*AA+BB)%prime%hashtablesize;
1095 printf("%d: hashloc is %d hash[2*hashloc] = %d hashkey %lu ii %lu jj %lu\n",icount,hashloc,hash[2*hashloc],hashkey,hashkey%hash_stride,hashkey/hash_stride);
1096 for (hashloc = (hashkey*AA+BB)%prime%hashtablesize; hash[2*hashloc] != (int)hashkey && hash[2*hashloc] != -1; hashloc+=(icount*jump),hashloc = hashloc%hashtablesize){
1097 icount++;
1098 uint hashloctmp = hashloc+1;
1099 hashloctmp = hashloctmp%hashtablesize;
1100 printf("%d: hashloc is %d hash[2*hashloc] = %d hashkey %lu ii %lu jj %lu\n",icount,hashloctmp,hash[2*hashloctmp],hashkey,hashkey%hash_stride,hashkey/hash_stride);
1101 if (icount > max_collisions_allowed) {
1102 printf("Error -- too many read hash collisions\n");
1103 exit(0);
1104 }
1105 }
1106 read_hash_collisions += icount;
1107
1108 if (hash[2*hashloc] != -1) hashval = hash[2*hashloc+1];
1109 return(hashval);
1110}
1111
1112int read_dev_hash(int hash_method, ulong hashtablesize, ulong AA, ulong BB, ulong hashkey, int *hash){
1113 //int hash_report_level = 3;
1114 int max_collisions_allowed = 1000;
1115 int hashval = -1;
1116 uint hashloc;
1117 int icount=0;
1118 if (hash_method == -1) {
1119 return(hash[hashkey]);
1120 }
1121 if (hash_method == 0) {
1122 if (hash_report_level == 0) {
1123 for (hashloc = (hashkey*AA+BB)%prime%hashtablesize; hash[2*hashloc] != (int)hashkey && hash[2*hashloc] != -1; hashloc++,hashloc = hashloc%hashtablesize){
1124 icount++;
1125 }
1126 } else if (hash_report_level == 1) {
1127 hash_queries++;
1128 for (hashloc = (hashkey*AA+BB)%prime%hashtablesize; hash[2*hashloc] != (int)hashkey && hash[2*hashloc] != -1; hashloc++,hashloc = hashloc%hashtablesize){
1129 icount++;
1130 }
1131 read_hash_collisions += icount;
1132 } else if (hash_report_level == 2) {
1133 hash_queries++;
1134 for (hashloc = (hashkey*AA+BB)%prime%hashtablesize; hash[2*hashloc] != (int)hashkey && hash[2*hashloc] != -1; hashloc++,hashloc = hashloc%hashtablesize){
1135 icount++;
1136 if (icount > max_collisions_allowed) {
1137 printf("Error -- too many read hash collisions\n");
1138 exit(0);
1139 }
1140 }
1141 read_hash_collisions += icount;
1142 } else if (hash_report_level == 3) {
1143 hash_queries++;
1144 hashloc = (hashkey*AA+BB)%prime%hashtablesize;
1145 printf("%d: hashloc is %d hash[2*hashloc] = %d hashkey %lu ii %lu jj %lu\n",icount,hashloc,hash[2*hashloc],hashkey,hashkey%hash_stride,hashkey/hash_stride);
1146 for (hashloc = (hashkey*AA+BB)%prime%hashtablesize; hash[2*hashloc] != (int)hashkey && hash[2*hashloc] != -1; hashloc++,hashloc = hashloc%hashtablesize){
1147 icount++;
1148 uint hashloctmp = hashloc+1;
1149 hashloctmp = hashloctmp%hashtablesize;
1150 printf("%d: hashloc is %d hash[2*hashloc] = %d hashkey %lu ii %lu jj %lu\n",icount,hashloctmp,hash[2*hashloctmp],hashkey,hashkey%hash_stride,hashkey/hash_stride);
1151 if (icount > max_collisions_allowed) {
1152 printf("Error -- too many read hash collisions\n");
1153 exit(0);
1154 }
1155 }
1156 read_hash_collisions += icount;
1157 }
1158 } else if (hash_method == 1) {
1159 if (hash_report_level == 0) {
1160 for (hashloc = (hashkey*AA+BB)%prime%hashtablesize; hash[2*hashloc] != (int)hashkey && hash[2*hashloc] != -1; hashloc+=(icount*icount),hashloc = hashloc%hashtablesize){
1161 icount++;
1162 }
1163 } else if (hash_report_level == 1) {
1164 hash_queries++;
1165 for (hashloc = (hashkey*AA+BB)%prime%hashtablesize; hash[2*hashloc] != (int)hashkey && hash[2*hashloc] != -1; hashloc+=(icount*icount),hashloc = hashloc%hashtablesize){
1166 icount++;
1167 }
1168 read_hash_collisions += icount;
1169 } else if (hash_report_level == 2) {
1170 hash_queries++;
1171 for (hashloc = (hashkey*AA+BB)%prime%hashtablesize; hash[2*hashloc] != (int)hashkey && hash[2*hashloc] != -1; hashloc+=(icount*icount),hashloc = hashloc%hashtablesize){
1172 icount++;
1173 if (icount > max_collisions_allowed) {
1174 printf("Error -- too many read hash collisions\n");
1175 exit(0);
1176 }
1177 }
1178 read_hash_collisions += icount;
1179 } else if (hash_report_level == 3) {
1180 hash_queries++;
1181 hashloc = (hashkey*AA+BB)%prime%hashtablesize;
1182 printf("%d: hashloc is %d hash[2*hashloc] = %d hashkey %lu ii %lu jj %lu\n",icount,hashloc,hash[2*hashloc],hashkey,hashkey%hash_stride,hashkey/hash_stride);
1183 for (hashloc = (hashkey*AA+BB)%prime%hashtablesize; hash[2*hashloc] != (int)hashkey && hash[2*hashloc] != -1; hashloc+=(icount*icount),hashloc = hashloc%hashtablesize){
1184 icount++;
1185 uint hashloctmp = hashloc+1;
1186 hashloctmp = hashloctmp%hashtablesize;
1187 printf("%d: hashloc is %d hash[2*hashloc] = %d hashkey %lu ii %lu jj %lu\n",icount,hashloctmp,hash[2*hashloctmp],hashkey,hashkey%hash_stride,hashkey/hash_stride);
1188 if (icount > max_collisions_allowed) {
1189 printf("Error -- too many read hash collisions\n");
1190 exit(0);
1191 }
1192 }
1193 read_hash_collisions += icount;
1194 }
1195 } else if (hash_method == 2) {
1196 uint jump = 1+hashkey%hash_jump_prime;
1197 if (hash_report_level == 0) {
1198 for (hashloc = (hashkey*AA+BB)%prime%hashtablesize; hash[2*hashloc] != (int)hashkey && hash[2*hashloc] != -1; hashloc+=(icount*jump),hashloc = hashloc%hashtablesize){
1199 icount++;
1200 }
1201 } else if (hash_report_level == 1) {
1202 hash_queries++;
1203 for (hashloc = (hashkey*AA+BB)%prime%hashtablesize; hash[2*hashloc] != (int)hashkey && hash[2*hashloc] != -1; hashloc+=(icount*jump),hashloc = hashloc%hashtablesize){
1204 icount++;
1205 }
1206 read_hash_collisions += icount;
1207 } else if (hash_report_level == 2) {
1208 hash_queries++;
1209 for (hashloc = (hashkey*AA+BB)%prime%hashtablesize; hash[2*hashloc] != (int)hashkey && hash[2*hashloc] != -1; hashloc+=(icount*jump),hashloc = hashloc%hashtablesize){
1210 icount++;
1211 if (icount > max_collisions_allowed) {
1212 printf("Error -- too many read hash collisions\n");
1213 exit(0);
1214 }
1215 }
1216 read_hash_collisions += icount;
1217 } else if (hash_report_level == 3) {
1218 hash_queries++;
1219 hashloc = (hashkey*AA+BB)%prime%hashtablesize;
1220 printf("%d: hashloc is %d hash[2*hashloc] = %d hashkey %lu ii %lu jj %lu\n",icount,hashloc,hash[2*hashloc],hashkey,hashkey%hash_stride,hashkey/hash_stride);
1221 for (hashloc = (hashkey*AA+BB)%prime%hashtablesize; hash[2*hashloc] != (int)hashkey && hash[2*hashloc] != -1; hashloc+=(icount*jump),hashloc = hashloc%hashtablesize){
1222 icount++;
1223 uint hashloctmp = hashloc+1;
1224 hashloctmp = hashloctmp%hashtablesize;
1225 printf("%d: hashloc is %d hash[2*hashloc] = %d hashkey %lu ii %lu jj %lu\n",icount,hashloctmp,hash[2*hashloctmp],hashkey,hashkey%hash_stride,hashkey/hash_stride);
1226 if (icount > max_collisions_allowed) {
1227 printf("Error -- too many read hash collisions\n");
1228 exit(0);
1229 }
1230 }
1231 read_hash_collisions += icount;
1232 }
1233 }
1234
1235 if (hash[2*hashloc] != -1) hashval = hash[2*hashloc+1];
1236 return(hashval);
1237}
1238
1239void write_hash_collision_report(void){
1240 if (! do_compact_hash) return;
1241 if (hash_report_level == 1) {
1242 write_hash_collisions_runsum += (double)write_hash_collisions/(double)hash_ncells;
1243 write_hash_collisions_count++;
1244 } else if (hash_report_level >= 2) {
1245 printf("Write hash collision report -- collisions per cell %lf, collisions %d cells %d\n",(double)write_hash_collisions/(double)hash_ncells,write_hash_collisions,hash_ncells);
1246 }
1247}
1248
1249void read_hash_collision_report(void){
1250 if (! do_compact_hash) return;
1251 if (hash_report_level == 1) {
1252 read_hash_collisions_runsum += (double)read_hash_collisions/(double)hash_queries;
1253 read_hash_collisions_count++;
1254 } else if (hash_report_level >= 2) {
1255 printf("Read hash collision report -- collisions per cell %lf, collisions %d cells %d\n",(double)read_hash_collisions/(double)hash_queries,read_hash_collisions,hash_queries);
1256 hash_queries = 0;
1257 read_hash_collisions = 0;
1258 }
1259}
1260
1261void final_hash_collision_report(void){
1262 if (hash_report_level >= 1 && read_hash_collisions_count > 0) {
1263 printf("Final hash collision report -- write/read collisions per cell %lf/%lf\n",write_hash_collisions_runsum/(double)write_hash_collisions_count,read_hash_collisions_runsum/(double)read_hash_collisions_count);
1264 }
1265}
1266
oldHash/hashit.h +0 -140
……@@ -1,140 +0,0 @@
1/* Copyright 2013-14. Los Alamos National Security, LLC. This material was produced
2 * under U.S. Government contract DE-AC52-06NA25396 for Los Alamos National
3 * Laboratory (LANL), which is operated by Los Alamos National Security, LLC
4 * for the U.S. Department of Energy. The U.S. Government has rights to use,
5 * reproduce, and distribute this software. NEITHER THE GOVERNMENT NOR LOS
6 * ALAMOS NATIONAL SECURITY, LLC MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR
7 * ASSUMES ANY LIABILITY FOR THE USE OF THIS SOFTWARE. If software is modified
8 * to produce derivative works, such modified software should be clearly marked,
9 * so as not to confuse it with the version available from LANL.
10 *
11 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
12 * use this file except in compliance with the License. You may obtain a copy
13 * of the License at
14 *
15 * http://www.apache.org/licenses/LICENSE-2.0
16 *
17 * Unless required by applicable law or agreed to in writing, software distributed
18 * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
19 * CONDITIONS OF ANY KIND, either express or implied. See the License for the
20 * specific language governing permissions and limitations under the License.
21 *
22 * Under this license, it is required to include a reference to this work. We
23 * request that each derivative work contain a reference to LANL Copyright
24 * Disclosure C14043/LA-CC-14-003 so that this work's impact can be roughly
25 * measured. In addition, it is requested that a modifier is included as in
26 * the following example:
27 *
28 * //<Uses | improves on | modified from> LANL Copyright Disclosure C14043/LA-CC-14-003
29 *
30 * This is LANL Copyright Disclosure C14043/LA-CC-14-003
31 */
32
33#ifndef _HASH_H
34#define _HASH_H
35
36#include <stdio.h>
37#include <stdlib.h>
38
39#ifdef __cplusplus
40extern "C"
41{
42#endif
43
44typedef unsigned int uint;
45typedef unsigned long ulong;
46
47int *compact_hash_init(int ncells, uint isize, uint jsize, uint report_level);
48
49#ifdef _OPENMP
50 #ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
51 int *compact_hash_init_openmp(int ncells, uint isize, uint jsize, uint report_level);
52 #else
53 int *compact_hash_init_openmp(int ncells, uint isize, uint jsize, uint report_level, omp_lock_t **lock);
54 #endif
55#endif
56
57int get_hash_method(void);
58long long get_hash_table_size(void);
59
60void write_hash_perfect(uint ic, ulong hashkey, int *hash);
61void write_hash_linear(uint ic, ulong hashkey, int *hash);
62void write_hash_linear_report_level_1(uint ic, ulong hashkey, int *hash);
63void write_hash_linear_report_level_2(uint ic, ulong hashkey, int *hash);
64void write_hash_linear_report_level_3(uint ic, ulong hashkey, int *hash);
65void write_hash_quadratic(uint ic, ulong hashkey, int *hash);
66void write_hash_quadratic_report_level_1(uint ic, ulong hashkey, int *hash);
67void write_hash_quadratic_report_level_2(uint ic, ulong hashkey, int *hash);
68void write_hash_quadratic_report_level_3(uint ic, ulong hashkey, int *hash);
69void write_hash_primejump(uint ic, ulong hashkey, int *hash);
70void write_hash_primejump_report_level_1(uint ic, ulong hashkey, int *hash);
71void write_hash_primejump_report_level_2(uint ic, ulong hashkey, int *hash);
72void write_hash_primejump_report_level_3(uint ic, ulong hashkey, int *hash);
73extern void (*write_hash)(uint ic, ulong hashkey, int *hash); // declared in hash.c
74
75#ifdef _OPENMP
76 #ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
77 void write_hash_perfect_openmp(uint ic, ulong hashkey, int *hash);
78 void write_hash_linear_openmp(uint ic, ulong hashkey, int *hash);
79 void write_hash_linear_openmp_report_level_1(uint ic, ulong hashkey, int *hash);
80 void write_hash_linear_openmp_report_level_2(uint ic, ulong hashkey, int *hash);
81 void write_hash_linear_openmp_report_level_3(uint ic, ulong hashkey, int *hash);
82 void write_hash_quadratic_openmp(uint ic, ulong hashkey, int *hash);
83 void write_hash_quadratic_openmp_report_level_1(uint ic, ulong hashkey, int *hash);
84 void write_hash_quadratic_openmp_report_level_2(uint ic, ulong hashkey, int *hash);
85 void write_hash_quadratic_openmp_report_level_3(uint ic, ulong hashkey, int *hash);
86 void write_hash_primejump_openmp(uint ic, ulong hashkey, int *hash);
87 void write_hash_primejump_openmp_report_level_1(uint ic, ulong hashkey, int *hash);
88 void write_hash_primejump_openmp_report_level_2(uint ic, ulong hashkey, int *hash);
89 void write_hash_primejump_openmp_report_level_3(uint ic, ulong hashkey, int *hash);
90 extern void (*write_hash_openmp)(uint ic, ulong hashkey, int *hash); // declared in hash.c
91 #else
92 void write_hash_perfect_openmp(uint ic, ulong hashkey, int *hash, omp_lock_t *lock);
93 void write_hash_linear_openmp(uint ic, ulong hashkey, int *hash, omp_lock_t *lock);
94 void write_hash_linear_openmp_report_level_1(uint ic, ulong hashkey, int *hash, omp_lock_t *lock);
95 void write_hash_linear_openmp_report_level_2(uint ic, ulong hashkey, int *hash, omp_lock_t *lock);
96 void write_hash_linear_openmp_report_level_3(uint ic, ulong hashkey, int *hash, omp_lock_t *lock);
97 void write_hash_quadratic_openmp(uint ic, ulong hashkey, int *hash, omp_lock_t *lock);
98 void write_hash_quadratic_openmp_report_level_1(uint ic, ulong hashkey, int *hash, omp_lock_t *lock);
99 void write_hash_quadratic_openmp_report_level_2(uint ic, ulong hashkey, int *hash, omp_lock_t *lock);
100 void write_hash_quadratic_openmp_report_level_3(uint ic, ulong hashkey, int *hash, omp_lock_t *lock);
101 void write_hash_primejump_openmp(uint ic, ulong hashkey, int *hash, omp_lock_t *lock);
102 void write_hash_primejump_openmp_report_level_1(uint ic, ulong hashkey, int *hash, omp_lock_t *lock);
103 void write_hash_primejump_openmp_report_level_2(uint ic, ulong hashkey, int *hash, omp_lock_t *lock);
104 void write_hash_primejump_openmp_report_level_3(uint ic, ulong hashkey, int *hash, omp_lock_t *lock);
105 extern void (*write_hash_openmp)(uint ic, ulong hashkey, int *hash, omp_lock_t *lock); // declared in hash.c
106 #endif
107#endif
108
109int read_hash_perfect(ulong hashkey, int *hash);
110int read_hash_linear(ulong hashkey, int *hash);
111int read_hash_linear_report_level_1(ulong hashkey, int *hash);
112int read_hash_linear_report_level_2(ulong hashkey, int *hash);
113int read_hash_linear_report_level_3(ulong hashkey, int *hash);
114int read_hash_quadratic(ulong hashkey, int *hash);
115int read_hash_quadratic_report_level_1(ulong hashkey, int *hash);
116int read_hash_quadratic_report_level_2(ulong hashkey, int *hash);
117int read_hash_quadratic_report_level_3(ulong hashkey, int *hash);
118int read_hash_primejump(ulong hashkey, int *hash);
119int read_hash_primejump_report_level_1(ulong hashkey, int *hash);
120int read_hash_primejump_report_level_2(ulong hashkey, int *hash);
121int read_hash_primejump_report_level_3(ulong hashkey, int *hash);
122extern int (*read_hash)(ulong hashkey, int *hash); // declared in hash.c
123
124void compact_hash_delete(int *hash);
125#ifdef _OPENMP
126 #ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
127 void compact_hash_delete_openmp(int *hash);
128 #else
129 void compact_hash_delete_openmp(int *hash, omp_lock_t *lock);
130 #endif
131#endif
132
133void read_hash_collision_report(void);
134void final_hash_collision_report(void);
135
136#ifdef __cplusplus
137}
138#endif
139
140#endif // _HASH_H
oldHash/hashold_kern.cl +0 -181
……@@ -1,181 +0,0 @@
1/* Copyright 2013-14. Los Alamos National Security, LLC. This material was produced
2 * under U.S. Government contract DE-AC52-06NA25396 for Los Alamos National
3 * Laboratory (LANL), which is operated by Los Alamos National Security, LLC
4 * for the U.S. Department of Energy. The U.S. Government has rights to use,
5 * reproduce, and distribute this software. NEITHER THE GOVERNMENT NOR LOS
6 * ALAMOS NATIONAL SECURITY, LLC MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR
7 * ASSUMES ANY LIABILITY FOR THE USE OF THIS SOFTWARE. If software is modified
8 * to produce derivative works, such modified software should be clearly marked,
9 * so as not to confuse it with the version available from LANL.
10 *
11 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
12 * use this file except in compliance with the License. You may obtain a copy
13 * of the License at
14 *
15 * http://www.apache.org/licenses/LICENSE-2.0
16 *
17 * Unless required by applicable law or agreed to in writing, software distributed
18 * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
19 * CONDITIONS OF ANY KIND, either express or implied. See the License for the
20 * specific language governing permissions and limitations under the License.
21 *
22 * Under this license, it is required to include a reference to this work. We
23 * request that each derivative work contain a reference to LANL Copyright
24 * Disclosure C14043/LA-CC-14-003 so that this work's impact can be roughly
25 * measured. In addition, it is requested that a modifier is included as in
26 * the following example:
27 *
28 * //<Uses | improves on | modified from> LANL Copyright Disclosure C14043/LA-CC-14-003
29 *
30 * This is LANL Copyright Disclosure C14043/LA-CC-14-003
31 */
32
33/*
34 * Authors: Bob Robey XCP-2 brobey@lanl.gov
35 * Peter Ahrens peter.ahrens@lanl.gov, ptrahrens@gmail.com
36 * Sara Hartse sara@lanl.gov, sara.hartse@gmail.com
37 * Rebecka Tumblin rtumblin@lanl.gov, rebeckatumblin@gmail.com
38 */
39
40/* neigh2d_kern.cl */
41
42void write_hash(
43 const int hash_method,
44 const ulong hash_table_size,
45 const ulong AA,
46 const ulong BB,
47 const uint giX,
48 const ulong hashkey,
49 __global int *hash);
50int read_hash(
51 const int hash_method,
52 const ulong hash_table_size,
53 const ulong AA,
54 const ulong BB,
55 const ulong hashkey,
56 __global const int *hash);
57
58#ifndef __HAVE_CL_DOUBLE_DEFINED__
59#define __HAVE_CL_DOUBLE_DEFINED__
60
61#ifdef HAVE_CL_DOUBLE
62#pragma OPENCL EXTENSION cl_khr_fp64 : enable
63typedef double real;
64#else
65typedef float real;
66#endif
67
68#endif
69
70__constant ulong prime = 4294967291;
71__constant uint hash_jump_prime = 41;
72
73void write_hash(
74 const int hash_method,
75 const ulong hash_table_size,
76 const ulong AA,
77 const ulong BB,
78 const uint giX,
79 const ulong hashkey,
80 __global int *hash)
81{
82 uint hashloc;
83 int icount = 0;
84 uint jump;
85 int old_key;
86 int MaxTries = 1000;
87#ifndef __APPLE_CC__
88 switch (hash_method) {
89 case -1:
90#endif
91 hash[hashkey] = giX;
92#ifndef __APPLE_CC__
93 break;
94 case 0:
95 hashloc = (hashkey*AA+BB)%prime%hash_table_size;
96 old_key = atomic_cmpxchg(&hash[2*hashloc],-1,hashkey);
97
98 for (int icount = 1; old_key != (int)hashkey && old_key != -1 && icount < MaxTries; icount++){
99 hashloc++;
100 hashloc %= hash_table_size;
101
102 old_key = atomic_cmpxchg(&hash[2*hashloc],-1,hashkey);
103 }
104
105 if (icount < MaxTries) hash[2*hashloc+1] = giX;
106 break;
107 case 1:
108 hashloc = (hashkey*AA+BB)%prime%hash_table_size;
109 old_key = atomic_cmpxchg(&hash[2*hashloc],-1,hashkey);
110
111 for (int icount = 1; old_key != (int)hashkey && old_key != -1 && icount < MaxTries; icount++){
112 hashloc+=(icount*icount);
113 hashloc %= hash_table_size;
114
115 old_key = atomic_cmpxchg(&hash[2*hashloc],-1,hashkey);
116 }
117
118 if (icount < MaxTries) hash[2*hashloc+1] = giX;
119 break;
120 case 2:
121 jump = 1+hashkey%hash_jump_prime;
122 hashloc = (hashkey*AA+BB)%prime%hash_table_size;
123 old_key = atomic_cmpxchg(&hash[2*hashloc],-1,hashkey);
124
125 for (int icount = 1; old_key != (int)hashkey && old_key != -1 && icount < MaxTries; icount++){
126 hashloc += (icount*jump);
127 hashloc %= hash_table_size;
128
129 old_key = atomic_cmpxchg(&hash[2*hashloc],-1,hashkey);
130 }
131
132 if (icount < MaxTries) hash[2*hashloc+1] = giX;
133 break;
134 }
135#endif
136}
137
138int read_hash(
139 const int hash_method,
140 const ulong hash_table_size,
141 const ulong AA,
142 const ulong BB,
143 const ulong hashkey,
144 __global const int *hash)
145{
146 int hashval = -1;
147 uint hashloc;
148 int icount = 0;
149 uint jump;
150
151#ifndef __APPLE_CC__
152 switch (hash_method) {
153 case -1:
154#endif
155 return(hash[hashkey]);
156#ifndef __APPLE_CC__
157 break;
158 case 0:
159 for (hashloc = (hashkey*AA+BB)%prime%hash_table_size; hash[2*hashloc] != (int)hashkey && hash[2*hashloc] != -1; hashloc++,hashloc %= hash_table_size);
160 if (hash[2*hashloc] != -1) hashval = hash[2*hashloc+1];
161 return(hashval);
162 break;
163 case 1:
164 for (hashloc = (hashkey*AA+BB)%prime%hash_table_size; hash[2*hashloc] != (int)hashkey && hash[2*hashloc] != -1; hashloc+=(icount*icount),hashloc %= hash_table_size){
165 icount++;
166 }
167 if (hash[2*hashloc] != -1) hashval = hash[2*hashloc+1];
168 return(hashval);
169 break;
170 case 2:
171 jump = 1+hashkey%hash_jump_prime;
172 for (hashloc = (hashkey*AA+BB)%prime%hash_table_size; hash[2*hashloc] != (int)hashkey && hash[2*hashloc] != -1; hashloc+=(icount*jump),hashloc %= hash_table_size){
173 icount++;
174 }
175 if (hash[2*hashloc] != -1) hashval = hash[2*hashloc+1];
176 return(hashval);
177 break;
178 }
179#endif
180 return(hashval);
181}
oldHash/hasholdlib.c +0 -156
……@@ -1,156 +0,0 @@
1/* Copyright 2013-14. Los Alamos National Security, LLC. This material was produced
2 * under U.S. Government contract DE-AC52-06NA25396 for Los Alamos National
3 * Laboratory (LANL), which is operated by Los Alamos National Security, LLC
4 * for the U.S. Department of Energy. The U.S. Government has rights to use,
5 * reproduce, and distribute this software. NEITHER THE GOVERNMENT NOR LOS
6 * ALAMOS NATIONAL SECURITY, LLC MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR
7 * ASSUMES ANY LIABILITY FOR THE USE OF THIS SOFTWARE. If software is modified
8 * to produce derivative works, such modified software should be clearly marked,
9 * so as not to confuse it with the version available from LANL.
10 *
11 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
12 * use this file except in compliance with the License. You may obtain a copy
13 * of the License at
14 *
15 * http://www.apache.org/licenses/LICENSE-2.0
16 *
17 * Unless required by applicable law or agreed to in writing, software distributed
18 * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
19 * CONDITIONS OF ANY KIND, either express or implied. See the License for the
20 * specific language governing permissions and limitations under the License.
21 *
22 * Under this license, it is required to include a reference to this work. We
23 * request that each derivative work contain a reference to LANL Copyright
24 * Disclosure C14043/LA-CC-14-003 so that this work's impact can be roughly
25 * measured. In addition, it is requested that a modifier is included as in
26 * the following example:
27 *
28 * //<Uses | improves on | modified from> LANL Copyright Disclosure C14043/LA-CC-14-003
29 *
30 * This is LANL Copyright Disclosure C14043/LA-CC-14-003
31 */
32
33#include <stdlib.h>
34//#ifdef HAVE_CONFIG_H
35//#include "config.h"
36//#endif
37#include "hasholdlib.h"
38#include "hasholdlib_kern.inc"
39#include "hashold_kern.inc"
40
41static int reportLevel = 0;
42
43char *get_hash_kernel_source_string(void){
44 return (char*) hashold_kern_source;
45}
46
47#ifdef HAVE_OPENCL
48cl_kernel init_kernel;
49void hash_lib_init(cl_context context){
50
51 cl_int error;
52
53 cl_program program = clCreateProgramWithSource(context, 1, (const char **)&hasholdlib_kern_source, NULL, &error);
54 if (error != CL_SUCCESS){
55 printf("clCreateProgramWithSource returned an error %d at line %d in file %s\n", error,__LINE__,__FILE__);
56 }
57
58 size_t nReportSize;
59 char* BuildReport;
60 #ifdef HAVE_CL_DOUBLE
61 error = clBuildProgram(program, 0, NULL, "-DHAVE_CL_DOUBLE", NULL, NULL);
62 #else
63 error = clBuildProgram(program, 0, NULL, "-DNO_CL_DOUBLE -cl-single-precision-constant", NULL, NULL);
64 #endif
65 if (error != CL_SUCCESS){
66 printf("clBuildProgram returned an error %d at line %d in file %s\n", error,__LINE__,__FILE__);
67
68 cl_device_id device;
69
70 clGetContextInfo(context, CL_CONTEXT_DEVICES, 1, &device, NULL);
71 if (context == NULL){
72 printf("EZCL_DEVTYPE_INIT: Failed to find device and setup context in file %s at line %d\n", __FILE__, __LINE__);
73 exit(-1); // No device is available, something is wrong
74 }
75
76 error = clGetProgramBuildInfo(program, device, CL_PROGRAM_BUILD_LOG, 0, NULL, &nReportSize);
77 if (error != CL_SUCCESS) {
78 switch (error){
79 case CL_INVALID_DEVICE:
80 printf("Invalid device in clProgramBuildInfo\n");
81 break;
82 case CL_INVALID_VALUE:
83 printf("Invalid value in clProgramBuildInfo\n");
84 break;
85 case CL_INVALID_PROGRAM:
86 printf("Invalid program in clProgramBuildInfo\n");
87 break;
88 }
89 }
90
91 BuildReport = (char *)malloc(nReportSize);
92
93 error = clGetProgramBuildInfo(program, device, CL_PROGRAM_BUILD_LOG, nReportSize, BuildReport, NULL);
94 if (error != CL_SUCCESS) {
95 switch (error){
96 case CL_INVALID_DEVICE:
97 printf("Invalid device in clProgramBuildInfo\n");
98 break;
99 case CL_INVALID_VALUE:
100 printf("Invalid value in clProgramBuildInfo\n");
101 break;
102 case CL_INVALID_PROGRAM:
103 printf("Invalid program in clProgramBuildInfo\n");
104 break;
105 }
106 }
107 printf("%s\n", BuildReport);
108 }
109
110
111 init_kernel = clCreateKernel(program, "init_kern", &error);
112 if (error != CL_SUCCESS) printf("Error is %d at line %d\n",error,__LINE__);
113}
114
115cl_mem hash_init (int hash_size, int TILE_SIZE, cl_context context, cl_command_queue queue, long *gpu_time)
116{
117 cl_int error;
118
119 long gpu_time_start, gpu_time_end;
120
121 cl_mem hash_buffer = clCreateBuffer(context, CL_MEM_READ_WRITE, hash_size*sizeof(int), NULL, &error);
122 if (error != CL_SUCCESS) printf("Error is %d at line %d\n",error,__LINE__);
123
124 //init to -1
125
126 error = clSetKernelArg(init_kernel, 0, sizeof(cl_uint), &hash_size);
127 if (error != CL_SUCCESS) printf("Error is %d at line %d\n",error,__LINE__);
128 error = clSetKernelArg(init_kernel, 1, sizeof(cl_mem), (void*)&hash_buffer);
129 if (error != CL_SUCCESS) printf("Error is %d at line %d\n",error,__LINE__);
130
131 size_t global_work_size;
132 size_t local_work_size;
133
134 local_work_size = TILE_SIZE;
135 global_work_size = ((hash_size+local_work_size-1)/local_work_size)*local_work_size;
136
137 cl_event hash_init_event;
138
139 error = clEnqueueNDRangeKernel(queue, init_kernel, 1, 0, &global_work_size, &local_work_size, 0, NULL, &hash_init_event);
140 if (error != CL_SUCCESS) printf("Error is %d at line %d\n",error,__LINE__);
141
142 clWaitForEvents(1,&hash_init_event);
143
144 clGetEventProfilingInfo(hash_init_event, CL_PROFILING_COMMAND_START, sizeof(gpu_time_start), &gpu_time_start, NULL);
145 clGetEventProfilingInfo(hash_init_event, CL_PROFILING_COMMAND_END, sizeof(gpu_time_end), &gpu_time_end, NULL);
146
147
148 *gpu_time = gpu_time_end - gpu_time_start;
149
150 clReleaseEvent(hash_init_event);
151
152 //if (DETAILED_TIMING) printf("\n\tinit %.6lf,", (double)(gpu_time_end - gpu_time_start)*1.0e-9);
153
154 return(hash_buffer);
155}
156#endif
oldHash/hasholdlib.h +0 -50
……@@ -1,50 +0,0 @@
1/* Copyright 2013-14. Los Alamos National Security, LLC. This material was produced
2 * under U.S. Government contract DE-AC52-06NA25396 for Los Alamos National
3 * Laboratory (LANL), which is operated by Los Alamos National Security, LLC
4 * for the U.S. Department of Energy. The U.S. Government has rights to use,
5 * reproduce, and distribute this software. NEITHER THE GOVERNMENT NOR LOS
6 * ALAMOS NATIONAL SECURITY, LLC MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR
7 * ASSUMES ANY LIABILITY FOR THE USE OF THIS SOFTWARE. If software is modified
8 * to produce derivative works, such modified software should be clearly marked,
9 * so as not to confuse it with the version available from LANL.
10 *
11 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
12 * use this file except in compliance with the License. You may obtain a copy
13 * of the License at
14 *
15 * http://www.apache.org/licenses/LICENSE-2.0
16 *
17 * Unless required by applicable law or agreed to in writing, software distributed
18 * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
19 * CONDITIONS OF ANY KIND, either express or implied. See the License for the
20 * specific language governing permissions and limitations under the License.
21 *
22 * Under this license, it is required to include a reference to this work. We
23 * request that each derivative work contain a reference to LANL Copyright
24 * Disclosure C14043/LA-CC-14-003 so that this work's impact can be roughly
25 * measured. In addition, it is requested that a modifier is included as in
26 * the following example:
27 *
28 * //<Uses | improves on | modified from> LANL Copyright Disclosure C14043/LA-CC-14-003
29 *
30 * This is LANL Copyright Disclosure C14043/LA-CC-14-003
31 */
32
33#include <stdio.h>
34//#ifdef HAVE_CONFIG_H
35//#include "config.h"
36//#endif
37
38#ifdef HAVE_OPENCL
39#ifdef __APPLE_CC__
40#include <OpenCL/OpenCL.h>
41#else
42#include <CL/cl.h>
43#endif
44#endif
45
46char *get_hash_kernel_source_string();
47#ifdef HAVE_OPENCL
48void hash_lib_init(cl_context context);
49cl_mem hash_init (int hash_size, int TILE_SIZE, cl_context context, cl_command_queue queue, long *gpu_time);
50#endif
oldHash/hasholdlib_kern.cl +0 -65
……@@ -1,65 +0,0 @@
1/* Copyright 2013-14. Los Alamos National Security, LLC. This material was produced
2 * under U.S. Government contract DE-AC52-06NA25396 for Los Alamos National
3 * Laboratory (LANL), which is operated by Los Alamos National Security, LLC
4 * for the U.S. Department of Energy. The U.S. Government has rights to use,
5 * reproduce, and distribute this software. NEITHER THE GOVERNMENT NOR LOS
6 * ALAMOS NATIONAL SECURITY, LLC MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR
7 * ASSUMES ANY LIABILITY FOR THE USE OF THIS SOFTWARE. If software is modified
8 * to produce derivative works, such modified software should be clearly marked,
9 * so as not to confuse it with the version available from LANL.
10 *
11 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
12 * use this file except in compliance with the License. You may obtain a copy
13 * of the License at
14 *
15 * http://www.apache.org/licenses/LICENSE-2.0
16 *
17 * Unless required by applicable law or agreed to in writing, software distributed
18 * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
19 * CONDITIONS OF ANY KIND, either express or implied. See the License for the
20 * specific language governing permissions and limitations under the License.
21 *
22 * Under this license, it is required to include a reference to this work. We
23 * request that each derivative work contain a reference to LANL Copyright
24 * Disclosure C14043/LA-CC-14-003 so that this work's impact can be roughly
25 * measured. In addition, it is requested that a modifier is included as in
26 * the following example:
27 *
28 * //<Uses | improves on | modified from> LANL Copyright Disclosure C14043/LA-CC-14-003
29 *
30 * This is LANL Copyright Disclosure C14043/LA-CC-14-003
31 */
32
33/*
34 * Authors: Bob Robey XCP-2 brobey@lanl.gov
35 * Peter Ahrens peter.ahrens@lanl.gov, ptrahrens@gmail.com
36 * Sara Hartse sara@lanl.gov, sara.hartse@gmail.com
37 * Rebecka Tumblin rtumblin@lanl.gov, rebeckatumblin@gmail.com
38 */
39
40/* neigh2d_kern.cl */
41
42#ifndef __HAVE_CL_DOUBLE_DEFINED__
43#define __HAVE_CL_DOUBLE_DEFINED__
44
45#ifdef HAVE_CL_DOUBLE
46#pragma OPENCL EXTENSION cl_khr_fp64 : enable
47typedef double real;
48#else
49typedef float real;
50#endif
51
52#endif
53
54
55__kernel void init_kern(
56 const uint size,
57 __global int *temp) {
58
59 const uint idx = get_global_id(0);
60
61 if (idx >= size) return;
62
63 temp[idx] = -1;
64}
65
simplehash/Makefile.am +28 -0
……@@ -0,0 +1,28 @@
1default: simplehash.c simplehashlib.c libsimplehash.la
2all: simplehash.c simplehashlib.c libsimplehash.la
3
4AM_MAKEFLAGS = -j 4
5
6DEFAULT_INCLUDES=-I. -I..
7
8lib_LTLIBRARIES = libsimplehash.la
9include_HEADERS = simplehash.h simplehashlib.h
10
11H_SRCS = simplehash.h simplehashlib.h
12
13C_SRCS = simplehash.c simplehashlib.c
14
15libsimplehash_la_SOURCES = ${C_SRCS} ${H_SRCS}
16
17simplehashlib.c: simplehashlib_kern.inc simplehash_kern.inc
18
19simplehashlib_kern.inc:
20 ./embed_source.pl simplehashlib_kern.cl > simplehashlib_kern.inc
21
22simplehash_kern.inc:
23 ./embed_source.pl simplehash_kern.cl > simplehash_kern.inc
24
25EXTRA_DIST = simplehash_kern.cl simplehashlib_kern.cl embed_source.pl
26
27clean-local:
28 rm -f *.inc
simplehash/Makefile.in +680 -0
……@@ -0,0 +1,680 @@
1# Makefile.in generated by automake 1.13.4 from Makefile.am.
2# @configure_input@
3
4# Copyright (C) 1994-2013 Free Software Foundation, Inc.
5
6# This Makefile.in is free software; the Free Software Foundation
7# gives unlimited permission to copy and/or distribute it,
8# with or without modifications, as long as this notice is preserved.
9
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
12# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13# PARTICULAR PURPOSE.
14
15@SET_MAKE@
16
17
18VPATH = @srcdir@
19am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
20am__make_running_with_option = \
21 case $${target_option-} in \
22 ?) ;; \
23 *) echo "am__make_running_with_option: internal error: invalid" \
24 "target option '$${target_option-}' specified" >&2; \
25 exit 1;; \
26 esac; \
27 has_opt=no; \
28 sane_makeflags=$$MAKEFLAGS; \
29 if $(am__is_gnu_make); then \
30 sane_makeflags=$$MFLAGS; \
31 else \
32 case $$MAKEFLAGS in \
33 *\\[\ \ ]*) \
34 bs=\\; \
35 sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
36 | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
37 esac; \
38 fi; \
39 skip_next=no; \
40 strip_trailopt () \
41 { \
42 flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
43 }; \
44 for flg in $$sane_makeflags; do \
45 test $$skip_next = yes && { skip_next=no; continue; }; \
46 case $$flg in \
47 *=*|--*) continue;; \
48 -*I) strip_trailopt 'I'; skip_next=yes;; \
49 -*I?*) strip_trailopt 'I';; \
50 -*O) strip_trailopt 'O'; skip_next=yes;; \
51 -*O?*) strip_trailopt 'O';; \
52 -*l) strip_trailopt 'l'; skip_next=yes;; \
53 -*l?*) strip_trailopt 'l';; \
54 -[dEDm]) skip_next=yes;; \
55 -[JT]) skip_next=yes;; \
56 esac; \
57 case $$flg in \
58 *$$target_option*) has_opt=yes; break;; \
59 esac; \
60 done; \
61 test $$has_opt = yes
62am__make_dryrun = (target_option=n; $(am__make_running_with_option))
63am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
64pkgdatadir = $(datadir)/@PACKAGE@
65pkgincludedir = $(includedir)/@PACKAGE@
66pkglibdir = $(libdir)/@PACKAGE@
67pkglibexecdir = $(libexecdir)/@PACKAGE@
68am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
69install_sh_DATA = $(install_sh) -c -m 644
70install_sh_PROGRAM = $(install_sh) -c
71install_sh_SCRIPT = $(install_sh) -c
72INSTALL_HEADER = $(INSTALL_DATA)
73transform = $(program_transform_name)
74NORMAL_INSTALL = :
75PRE_INSTALL = :
76POST_INSTALL = :
77NORMAL_UNINSTALL = :
78PRE_UNINSTALL = :
79POST_UNINSTALL = :
80build_triplet = @build@
81host_triplet = @host@
82subdir = simplehash
83DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
84 $(top_srcdir)/./config/depcomp $(include_HEADERS)
85ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
86am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
87 $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
88 $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
89 $(top_srcdir)/configure.ac
90am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
91 $(ACLOCAL_M4)
92mkinstalldirs = $(install_sh) -d
93CONFIG_CLEAN_FILES =
94CONFIG_CLEAN_VPATH_FILES =
95am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
96am__vpath_adj = case $$p in \
97 $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
98 *) f=$$p;; \
99 esac;
100am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
101am__install_max = 40
102am__nobase_strip_setup = \
103 srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
104am__nobase_strip = \
105 for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
106am__nobase_list = $(am__nobase_strip_setup); \
107 for p in $$list; do echo "$$p $$p"; done | \
108 sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
109 $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
110 if (++n[$$2] == $(am__install_max)) \
111 { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
112 END { for (dir in files) print dir, files[dir] }'
113am__base_list = \
114 sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
115 sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
116am__uninstall_files_from_dir = { \
117 test -z "$$files" \
118 || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
119 || { echo " ( cd '$$dir' && rm -f" $$files ")"; \
120 $(am__cd) "$$dir" && rm -f $$files; }; \
121 }
122am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(includedir)"
123LTLIBRARIES = $(lib_LTLIBRARIES)
124libsimplehash_la_LIBADD =
125am__objects_1 = simplehash.lo simplehashlib.lo
126am__objects_2 =
127am_libsimplehash_la_OBJECTS = $(am__objects_1) $(am__objects_2)
128libsimplehash_la_OBJECTS = $(am_libsimplehash_la_OBJECTS)
129AM_V_lt = $(am__v_lt_@AM_V@)
130am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
131am__v_lt_0 = --silent
132am__v_lt_1 =
133AM_V_P = $(am__v_P_@AM_V@)
134am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
135am__v_P_0 = false
136am__v_P_1 = :
137AM_V_GEN = $(am__v_GEN_@AM_V@)
138am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
139am__v_GEN_0 = @echo " GEN " $@;
140am__v_GEN_1 =
141AM_V_at = $(am__v_at_@AM_V@)
142am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
143am__v_at_0 = @
144am__v_at_1 =
145depcomp = $(SHELL) $(top_srcdir)/./config/depcomp
146am__depfiles_maybe = depfiles
147am__mv = mv -f
148COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
149 $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
150LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
151 $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
152 $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
153 $(AM_CFLAGS) $(CFLAGS)
154AM_V_CC = $(am__v_CC_@AM_V@)
155am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
156am__v_CC_0 = @echo " CC " $@;
157am__v_CC_1 =
158CCLD = $(CC)
159LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
160 $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
161 $(AM_LDFLAGS) $(LDFLAGS) -o $@
162AM_V_CCLD = $(am__v_CCLD_@AM_V@)
163am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
164am__v_CCLD_0 = @echo " CCLD " $@;
165am__v_CCLD_1 =
166SOURCES = $(libsimplehash_la_SOURCES)
167DIST_SOURCES = $(libsimplehash_la_SOURCES)
168am__can_run_installinfo = \
169 case $$AM_UPDATE_INFO_DIR in \
170 n|no|NO) false;; \
171 *) (install-info --version) >/dev/null 2>&1;; \
172 esac
173HEADERS = $(include_HEADERS)
174am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
175# Read a list of newline-separated strings from the standard input,
176# and print each of them once, without duplicates. Input order is
177# *not* preserved.
178am__uniquify_input = $(AWK) '\
179 BEGIN { nonempty = 0; } \
180 { items[$$0] = 1; nonempty = 1; } \
181 END { if (nonempty) { for (i in items) print i; }; } \
182'
183# Make sure the list of sources is unique. This is necessary because,
184# e.g., the same source file might be shared among _SOURCES variables
185# for different programs/libraries.
186am__define_uniq_tagged_files = \
187 list='$(am__tagged_files)'; \
188 unique=`for i in $$list; do \
189 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
190 done | $(am__uniquify_input)`
191ETAGS = etags
192CTAGS = ctags
193DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
194ACLOCAL = @ACLOCAL@
195AMTAR = @AMTAR@
196AM_CPPFLAGS = @AM_CPPFLAGS@
197AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
198AR = @AR@
199AUTOCONF = @AUTOCONF@
200AUTOHEADER = @AUTOHEADER@
201AUTOMAKE = @AUTOMAKE@
202AWK = @AWK@
203CC = @CC@
204CCDEPMODE = @CCDEPMODE@
205CFLAGS = @CFLAGS@
206CPP = @CPP@
207CPPFLAGS = @CPPFLAGS@
208CPREPROCESSOR = @CPREPROCESSOR@
209CXX = @CXX@
210CXXCPP = @CXXCPP@
211CXXDEPMODE = @CXXDEPMODE@
212CXXFLAGS = @CXXFLAGS@
213CYGPATH_W = @CYGPATH_W@
214DEFS = @DEFS@
215DEPDIR = @DEPDIR@
216DLLTOOL = @DLLTOOL@
217DSYMUTIL = @DSYMUTIL@
218DUMPBIN = @DUMPBIN@
219ECHO_C = @ECHO_C@
220ECHO_N = @ECHO_N@
221ECHO_T = @ECHO_T@
222EGREP = @EGREP@
223EXEEXT = @EXEEXT@
224FGREP = @FGREP@
225GREP = @GREP@
226HAVE_ADDR2LINE = @HAVE_ADDR2LINE@
227INDENT = @INDENT@
228INSTALL = @INSTALL@
229INSTALL_DATA = @INSTALL_DATA@
230INSTALL_PROGRAM = @INSTALL_PROGRAM@
231INSTALL_SCRIPT = @INSTALL_SCRIPT@
232INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
233LD = @LD@
234LDFLAGS = @LDFLAGS@
235LIBOBJS = @LIBOBJS@
236LIBS = @LIBS@
237LIBTOOL = @LIBTOOL@
238LIPO = @LIPO@
239LN_S = @LN_S@
240LTLIBOBJS = @LTLIBOBJS@
241MAKEINFO = @MAKEINFO@
242MANIFEST_TOOL = @MANIFEST_TOOL@
243MKDIR_P = @MKDIR_P@
244NM = @NM@
245NMEDIT = @NMEDIT@
246OBJDUMP = @OBJDUMP@
247OBJEXT = @OBJEXT@
248OTOOL = @OTOOL@
249OTOOL64 = @OTOOL64@
250PACKAGE = @PACKAGE@
251PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
252PACKAGE_NAME = @PACKAGE_NAME@
253PACKAGE_STRING = @PACKAGE_STRING@
254PACKAGE_TARNAME = @PACKAGE_TARNAME@
255PACKAGE_URL = @PACKAGE_URL@
256PACKAGE_VERSION = @PACKAGE_VERSION@
257PATH_SEPARATOR = @PATH_SEPARATOR@
258RANLIB = @RANLIB@
259SED = @SED@
260SET_MAKE = @SET_MAKE@
261SHELL = @SHELL@
262STRIP = @STRIP@
263VERSION = @VERSION@
264abs_builddir = @abs_builddir@
265abs_srcdir = @abs_srcdir@
266abs_top_builddir = @abs_top_builddir@
267abs_top_srcdir = @abs_top_srcdir@
268ac_ct_AR = @ac_ct_AR@
269ac_ct_CC = @ac_ct_CC@
270ac_ct_CXX = @ac_ct_CXX@
271ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
272am__include = @am__include@
273am__leading_dot = @am__leading_dot@
274am__quote = @am__quote@
275am__tar = @am__tar@
276am__untar = @am__untar@
277bindir = @bindir@
278build = @build@
279build_alias = @build_alias@
280build_cpu = @build_cpu@
281build_os = @build_os@
282build_vendor = @build_vendor@
283builddir = @builddir@
284datadir = @datadir@
285datarootdir = @datarootdir@
286docdir = @docdir@
287dvidir = @dvidir@
288exec_prefix = @exec_prefix@
289host = @host@
290host_alias = @host_alias@
291host_cpu = @host_cpu@
292host_os = @host_os@
293host_vendor = @host_vendor@
294htmldir = @htmldir@
295includedir = @includedir@
296infodir = @infodir@
297install_sh = @install_sh@
298libdir = @libdir@
299libexecdir = @libexecdir@
300localedir = @localedir@
301localstatedir = @localstatedir@
302lspci_found = @lspci_found@
303mandir = @mandir@
304mkdir_p = @mkdir_p@
305oldincludedir = @oldincludedir@
306pdfdir = @pdfdir@
307prefix = @prefix@
308program_transform_name = @program_transform_name@
309psdir = @psdir@
310sbindir = @sbindir@
311sharedstatedir = @sharedstatedir@
312srcdir = @srcdir@
313sysconfdir = @sysconfdir@
314target_alias = @target_alias@
315top_build_prefix = @top_build_prefix@
316top_builddir = @top_builddir@
317top_srcdir = @top_srcdir@
318AM_MAKEFLAGS = -j 4
319DEFAULT_INCLUDES = -I. -I..
320lib_LTLIBRARIES = libsimplehash.la
321include_HEADERS = simplehash.h simplehashlib.h
322H_SRCS = simplehash.h simplehashlib.h
323C_SRCS = simplehash.c simplehashlib.c
324libsimplehash_la_SOURCES = ${C_SRCS} ${H_SRCS}
325EXTRA_DIST = simplehash_kern.cl simplehashlib_kern.cl embed_source.pl
326all: all-am
327
328.SUFFIXES:
329.SUFFIXES: .c .lo .o .obj
330$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
331 @for dep in $?; do \
332 case '$(am__configure_deps)' in \
333 *$$dep*) \
334 ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
335 && { if test -f $@; then exit 0; else break; fi; }; \
336 exit 1;; \
337 esac; \
338 done; \
339 echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign simplehash/Makefile'; \
340 $(am__cd) $(top_srcdir) && \
341 $(AUTOMAKE) --foreign simplehash/Makefile
342.PRECIOUS: Makefile
343Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
344 @case '$?' in \
345 *config.status*) \
346 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
347 *) \
348 echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
349 cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
350 esac;
351
352$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
353 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
354
355$(top_srcdir)/configure: $(am__configure_deps)
356 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
357$(ACLOCAL_M4): $(am__aclocal_m4_deps)
358 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
359$(am__aclocal_m4_deps):
360
361install-libLTLIBRARIES: $(lib_LTLIBRARIES)
362 @$(NORMAL_INSTALL)
363 @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
364 list2=; for p in $$list; do \
365 if test -f $$p; then \
366 list2="$$list2 $$p"; \
367 else :; fi; \
368 done; \
369 test -z "$$list2" || { \
370 echo " $(MKDIR_P) '$(DESTDIR)$(libdir)'"; \
371 $(MKDIR_P) "$(DESTDIR)$(libdir)" || exit 1; \
372 echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \
373 $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \
374 }
375
376uninstall-libLTLIBRARIES:
377 @$(NORMAL_UNINSTALL)
378 @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
379 for p in $$list; do \
380 $(am__strip_dir) \
381 echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \
382 $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \
383 done
384
385clean-libLTLIBRARIES:
386 -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
387 @list='$(lib_LTLIBRARIES)'; \
388 locs=`for p in $$list; do echo $$p; done | \
389 sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
390 sort -u`; \
391 test -z "$$locs" || { \
392 echo rm -f $${locs}; \
393 rm -f $${locs}; \
394 }
395
396libsimplehash.la: $(libsimplehash_la_OBJECTS) $(libsimplehash_la_DEPENDENCIES) $(EXTRA_libsimplehash_la_DEPENDENCIES)
397 $(AM_V_CCLD)$(LINK) -rpath $(libdir) $(libsimplehash_la_OBJECTS) $(libsimplehash_la_LIBADD) $(LIBS)
398
399mostlyclean-compile:
400 -rm -f *.$(OBJEXT)
401
402distclean-compile:
403 -rm -f *.tab.c
404
405@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/simplehash.Plo@am__quote@
406@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/simplehashlib.Plo@am__quote@
407
408.c.o:
409@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
410@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
411@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
412@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
413@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c $<
414
415.c.obj:
416@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
417@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
418@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
419@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
420@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c `$(CYGPATH_W) '$<'`
421
422.c.lo:
423@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
424@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
425@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
426@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
427@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
428
429mostlyclean-libtool:
430 -rm -f *.lo
431
432clean-libtool:
433 -rm -rf .libs _libs
434install-includeHEADERS: $(include_HEADERS)
435 @$(NORMAL_INSTALL)
436 @list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \
437 if test -n "$$list"; then \
438 echo " $(MKDIR_P) '$(DESTDIR)$(includedir)'"; \
439 $(MKDIR_P) "$(DESTDIR)$(includedir)" || exit 1; \
440 fi; \
441 for p in $$list; do \
442 if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
443 echo "$$d$$p"; \
444 done | $(am__base_list) | \
445 while read files; do \
446 echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(includedir)'"; \
447 $(INSTALL_HEADER) $$files "$(DESTDIR)$(includedir)" || exit $$?; \
448 done
449
450uninstall-includeHEADERS:
451 @$(NORMAL_UNINSTALL)
452 @list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \
453 files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
454 dir='$(DESTDIR)$(includedir)'; $(am__uninstall_files_from_dir)
455
456ID: $(am__tagged_files)
457 $(am__define_uniq_tagged_files); mkid -fID $$unique
458tags: tags-am
459TAGS: tags
460
461tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
462 set x; \
463 here=`pwd`; \
464 $(am__define_uniq_tagged_files); \
465 shift; \
466 if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
467 test -n "$$unique" || unique=$$empty_fix; \
468 if test $$# -gt 0; then \
469 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
470 "$$@" $$unique; \
471 else \
472 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
473 $$unique; \
474 fi; \
475 fi
476ctags: ctags-am
477
478CTAGS: ctags
479ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
480 $(am__define_uniq_tagged_files); \
481 test -z "$(CTAGS_ARGS)$$unique" \
482 || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
483 $$unique
484
485GTAGS:
486 here=`$(am__cd) $(top_builddir) && pwd` \
487 && $(am__cd) $(top_srcdir) \
488 && gtags -i $(GTAGS_ARGS) "$$here"
489cscopelist: cscopelist-am
490
491cscopelist-am: $(am__tagged_files)
492 list='$(am__tagged_files)'; \
493 case "$(srcdir)" in \
494 [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
495 *) sdir=$(subdir)/$(srcdir) ;; \
496 esac; \
497 for i in $$list; do \
498 if test -f "$$i"; then \
499 echo "$(subdir)/$$i"; \
500 else \
501 echo "$$sdir/$$i"; \
502 fi; \
503 done >> $(top_builddir)/cscope.files
504
505distclean-tags:
506 -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
507
508distdir: $(DISTFILES)
509 @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
510 topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
511 list='$(DISTFILES)'; \
512 dist_files=`for file in $$list; do echo $$file; done | \
513 sed -e "s|^$$srcdirstrip/||;t" \
514 -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
515 case $$dist_files in \
516 */*) $(MKDIR_P) `echo "$$dist_files" | \
517 sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
518 sort -u` ;; \
519 esac; \
520 for file in $$dist_files; do \
521 if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
522 if test -d $$d/$$file; then \
523 dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
524 if test -d "$(distdir)/$$file"; then \
525 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
526 fi; \
527 if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
528 cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
529 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
530 fi; \
531 cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
532 else \
533 test -f "$(distdir)/$$file" \
534 || cp -p $$d/$$file "$(distdir)/$$file" \
535 || exit 1; \
536 fi; \
537 done
538check-am: all-am
539check: check-am
540all-am: Makefile $(LTLIBRARIES) $(HEADERS)
541installdirs:
542 for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(includedir)"; do \
543 test -z "$$dir" || $(MKDIR_P) "$$dir"; \
544 done
545install: install-am
546install-exec: install-exec-am
547install-data: install-data-am
548uninstall: uninstall-am
549
550install-am: all-am
551 @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
552
553installcheck: installcheck-am
554install-strip:
555 if test -z '$(STRIP)'; then \
556 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
557 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
558 install; \
559 else \
560 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
561 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
562 "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
563 fi
564mostlyclean-generic:
565
566clean-generic:
567
568distclean-generic:
569 -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
570 -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
571
572maintainer-clean-generic:
573 @echo "This command is intended for maintainers to use"
574 @echo "it deletes files that may require special tools to rebuild."
575clean: clean-am
576
577clean-am: clean-generic clean-libLTLIBRARIES clean-libtool clean-local \
578 mostlyclean-am
579
580distclean: distclean-am
581 -rm -rf ./$(DEPDIR)
582 -rm -f Makefile
583distclean-am: clean-am distclean-compile distclean-generic \
584 distclean-tags
585
586dvi: dvi-am
587
588dvi-am:
589
590html: html-am
591
592html-am:
593
594info: info-am
595
596info-am:
597
598install-data-am: install-includeHEADERS
599
600install-dvi: install-dvi-am
601
602install-dvi-am:
603
604install-exec-am: install-libLTLIBRARIES
605
606install-html: install-html-am
607
608install-html-am:
609
610install-info: install-info-am
611
612install-info-am:
613
614install-man:
615
616install-pdf: install-pdf-am
617
618install-pdf-am:
619
620install-ps: install-ps-am
621
622install-ps-am:
623
624installcheck-am:
625
626maintainer-clean: maintainer-clean-am
627 -rm -rf ./$(DEPDIR)
628 -rm -f Makefile
629maintainer-clean-am: distclean-am maintainer-clean-generic
630
631mostlyclean: mostlyclean-am
632
633mostlyclean-am: mostlyclean-compile mostlyclean-generic \
634 mostlyclean-libtool
635
636pdf: pdf-am
637
638pdf-am:
639
640ps: ps-am
641
642ps-am:
643
644uninstall-am: uninstall-includeHEADERS uninstall-libLTLIBRARIES
645
646.MAKE: install-am install-strip
647
648.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
649 clean-libLTLIBRARIES clean-libtool clean-local cscopelist-am \
650 ctags ctags-am distclean distclean-compile distclean-generic \
651 distclean-libtool distclean-tags distdir dvi dvi-am html \
652 html-am info info-am install install-am install-data \
653 install-data-am install-dvi install-dvi-am install-exec \
654 install-exec-am install-html install-html-am \
655 install-includeHEADERS install-info install-info-am \
656 install-libLTLIBRARIES install-man install-pdf install-pdf-am \
657 install-ps install-ps-am install-strip installcheck \
658 installcheck-am installdirs maintainer-clean \
659 maintainer-clean-generic mostlyclean mostlyclean-compile \
660 mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
661 tags tags-am uninstall uninstall-am uninstall-includeHEADERS \
662 uninstall-libLTLIBRARIES
663
664default: simplehash.c simplehashlib.c libsimplehash.la
665all: simplehash.c simplehashlib.c libsimplehash.la
666
667simplehashlib.c: simplehashlib_kern.inc simplehash_kern.inc
668
669simplehashlib_kern.inc:
670 ./embed_source.pl simplehashlib_kern.cl > simplehashlib_kern.inc
671
672simplehash_kern.inc:
673 ./embed_source.pl simplehash_kern.cl > simplehash_kern.inc
674
675clean-local:
676 rm -f *.inc
677
678# Tell versions [3.59,3.63) of GNU make to not export all variables.
679# Otherwise a system limit (for SysV at least) may be exceeded.
680.NOEXPORT:
simplehash/embed_source.pl +68 -0
……@@ -0,0 +1,68 @@
1eval 'exec perl -w $0 ${1+"$@"}'
2 if 0;
3
4# Copyright 2013-14. Los Alamos National Security, LLC. This material was produced
5# under U.S. Government contract DE-AC52-06NA25396 for Los Alamos National
6# Laboratory (LANL), which is operated by Los Alamos National Security, LLC
7# for the U.S. Department of Energy. The U.S. Government has rights to use,
8# reproduce, and distribute this software. NEITHER THE GOVERNMENT NOR LOS
9# ALAMOS NATIONAL SECURITY, LLC MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR
10# ASSUMES ANY LIABILITY FOR THE USE OF THIS SOFTWARE. If software is modified
11# to produce derivative works, such modified software should be clearly marked,
12# so as not to confuse it with the version available from LANL.
13#
14# Licensed under the Apache License, Version 2.0 (the "License"); you may not
15# use this file except in compliance with the License. You may obtain a copy
16# of the License at
17#
18# http://www.apache.org/licenses/LICENSE-2.0
19#
20# Unless required by applicable law or agreed to in writing, software distributed
21# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
22# CONDITIONS OF ANY KIND, either express or implied. See the License for the
23# specific language governing permissions and limitations under the License.
24#
25# Under this license, it is required to include a reference to this work. We
26# request that each derivative work contain a reference to LANL Copyright
27# Disclosure C14043/LA-CC-14-003 so that this work's impact can be roughly
28# measured. In addition, it is requested that a modifier is included as in
29# the following example:
30#
31# //<Uses | improves on | modified from> LANL Copyright Disclosure C14043/LA-CC-14-003
32#
33# This is LANL Copyright Disclosure C14043/LA-CC-14-003
34
35use File::Basename;
36
37$ARGV_LAST = "";
38
39($file,,) = fileparse($ARGV[0], qr/\..*/);
40print "const char *",$file,"_source =\n";
41
42while(<>) {
43 if ($ARGV ne $ARGV_LAST){
44# $comment = 0;
45 $ARGV_LAST=$ARGV;
46 }
47 chop $_;
48
49 s/"/""/g;
50
51# if (/^\/\*/){
52# #print "Setting comment to 1\n";
53# $comment = 1;
54# }
55# if (/\*\/$/){
56# #print "Setting comment to 0\n";
57# $comment = 0;
58# next;
59# }
60# if ($comment eq 1) {
61# #print "Skip line and goto next\n";
62## next;
63# }
64
65 print '"',$_,'\n','"',"\n";
66}
67
68print ";\n"
simplehash/simplehash.c +1266 -0
……@@ -0,0 +1,1266 @@
1/* Copyright 2013-14. Los Alamos National Security, LLC. This material was produced
2 * under U.S. Government contract DE-AC52-06NA25396 for Los Alamos National
3 * Laboratory (LANL), which is operated by Los Alamos National Security, LLC
4 * for the U.S. Department of Energy. The U.S. Government has rights to use,
5 * reproduce, and distribute this software. NEITHER THE GOVERNMENT NOR LOS
6 * ALAMOS NATIONAL SECURITY, LLC MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR
7 * ASSUMES ANY LIABILITY FOR THE USE OF THIS SOFTWARE. If software is modified
8 * to produce derivative works, such modified software should be clearly marked,
9 * so as not to confuse it with the version available from LANL.
10 *
11 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
12 * use this file except in compliance with the License. You may obtain a copy
13 * of the License at
14 *
15 * http://www.apache.org/licenses/LICENSE-2.0
16 *
17 * Unless required by applicable law or agreed to in writing, software distributed
18 * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
19 * CONDITIONS OF ANY KIND, either express or implied. See the License for the
20 * specific language governing permissions and limitations under the License.
21 *
22 * Under this license, it is required to include a reference to this work. We
23 * request that each derivative work contain a reference to LANL Copyright
24 * Disclosure C14043/LA-CC-14-003 so that this work's impact can be roughly
25 * measured. In addition, it is requested that a modifier is included as in
26 * the following example:
27 *
28 * //<Uses | improves on | modified from> LANL Copyright Disclosure C14043/LA-CC-14-003
29 *
30 * This is LANL Copyright Disclosure C14043/LA-CC-14-003
31 */
32
33#include "simplehash.h"
34//#include "timer/timer.h"
35
36static ulong AA;
37static ulong BB;
38static ulong prime=4294967291;
39static uint hashtablesize;
40static uint hash_stride;
41static uint hash_ncells;
42static uint write_hash_collisions;
43static uint read_hash_collisions;
44static double write_hash_collisions_runsum = 0.0;
45static double read_hash_collisions_runsum = 0.0;
46static uint write_hash_collisions_count = 0;
47static uint read_hash_collisions_count = 0;
48static uint hash_report_level = 0;
49static uint hash_queries;
50static uint hash_method = 1;
51static uint hash_jump_prime = 41;
52static double hash_mult = 3.0;
53static int do_compact_hash = 0;
54
55float mem_opt_factor;
56
57void compact_hash_delete(int *hash){
58 free(hash);
59}
60
61int (*read_hash)(ulong, int *);
62void (*write_hash)(uint, ulong, int *);
63
64#ifdef _OPENMP
65#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
66void (*write_hash_openmp)(uint, ulong, int *);
67#else
68void (*write_hash_openmp)(uint, ulong, int *, omp_lock_t * lock);
69#endif
70#endif
71
72int get_hash_method(void) {
73 return(hash_method);
74}
75
76long long get_hashtablesize(void) {
77 return(hashtablesize);
78}
79
80int *compact_hash_init(int ncells, uint isize, uint jsize, uint report_level){
81
82 hash_ncells = 0;
83 write_hash_collisions = 0;
84 read_hash_collisions = 0;
85 hash_queries = 0;
86 hash_report_level = report_level;
87 hash_stride = isize;
88 int *hash = NULL;
89
90 uint compact_hash_size = (uint)((double)ncells*hash_mult);
91 compact_hash_size = ncells;
92 uint perfect_hash_size = (uint)(isize*jsize);
93 float hash_mem_factor = 20.0;
94 float hash_mem_ratio = (double)perfect_hash_size/(double)compact_hash_size;
95 if (mem_opt_factor != 1.0) hash_mem_factor /= (mem_opt_factor*0.2);
96 do_compact_hash = (hash_mem_ratio < hash_mem_factor) ? 0 : 1;
97 do_compact_hash = 1;
98 if (hash_report_level >= 2) printf("DEBUG do_compact_hash %d hash_mem_ratio %f hash_mem_factor %f mem_opt_factor %f perfect_hash_size %u compact_hash_size %u\n",do_compact_hash,hash_mem_ratio,hash_mem_factor,mem_opt_factor,perfect_hash_size,compact_hash_size);
99
100 if (do_compact_hash) {
101 hashtablesize = compact_hash_size;
102 AA = (ulong)(1.0+(double)(prime-1)*drand48());
103 BB = (ulong)(0.0+(double)(prime-1)*drand48());
104 if (AA > prime-1 || BB > prime-1) exit(0);
105 if (hash_report_level > 1) printf("Factors AA %lu BB %lu\n",AA,BB);
106
107 hash = (int *)malloc(2*hashtablesize*sizeof(int));
108 for (uint ii = 0; ii<2*hashtablesize; ii+=2){
109 hash[ii] = -1;
110 }
111 } else {
112 hashtablesize = perfect_hash_size;
113
114 hash = (int *)malloc(hashtablesize*sizeof(int));
115 for (uint ii = 0; ii<hashtablesize; ii++){
116 hash[ii] = -1;
117 }
118 }
119
120 if (hash_report_level >= 2) {
121 printf("Hash table size %u perfect hash table size %u memory savings %u by percentage %lf\n",
122 hashtablesize,isize*jsize,isize*jsize-hashtablesize,
123 (double)hashtablesize/(double)(isize*jsize));
124 }
125
126 if (! do_compact_hash) {
127 read_hash = read_hash_perfect;
128 write_hash = write_hash_perfect;
129 } else if (hash_method == 0){
130 if (hash_report_level == 0){
131 read_hash = read_hash_linear;
132 write_hash = write_hash_linear;
133 } else if (hash_report_level == 1){
134 read_hash = read_hash_linear_report_level_1;
135 write_hash = write_hash_linear_report_level_1;
136 } else if (hash_report_level == 2){
137 read_hash = read_hash_linear_report_level_2;
138 write_hash = write_hash_linear_report_level_2;
139 } else if (hash_report_level == 3){
140 read_hash = read_hash_linear_report_level_3;
141 write_hash = write_hash_linear_report_level_3;
142 }
143 } else if (hash_method == 1){
144 if (hash_report_level == 0){
145 read_hash = read_hash_quadratic;
146 write_hash = write_hash_quadratic;
147 } else if (hash_report_level == 1){
148 read_hash = read_hash_quadratic_report_level_1;
149 write_hash = write_hash_quadratic_report_level_1;
150 } else if (hash_report_level == 2){
151 read_hash = read_hash_quadratic_report_level_2;
152 write_hash = write_hash_quadratic_report_level_2;
153 } else if (hash_report_level == 3){
154 read_hash = read_hash_quadratic_report_level_3;
155 write_hash = write_hash_quadratic_report_level_3;
156 }
157 } else if (hash_method == 2){
158 if (hash_report_level == 0){
159 read_hash = read_hash_primejump;
160 write_hash = write_hash_primejump;
161 } else if (hash_report_level == 1){
162 read_hash = read_hash_primejump_report_level_1;
163 write_hash = write_hash_primejump_report_level_1;
164 } else if (hash_report_level == 2){
165 read_hash = read_hash_primejump_report_level_2;
166 write_hash = write_hash_primejump_report_level_2;
167 } else if (hash_report_level == 3){
168 read_hash = read_hash_primejump_report_level_3;
169 write_hash = write_hash_primejump_report_level_3;
170 }
171 }
172
173 return(hash);
174}
175
176void write_hash_perfect(uint ic, ulong hashkey, int *hash){
177 hash[hashkey] = ic;
178}
179
180void write_hash_linear(uint ic, ulong hashkey, int *hash){
181 uint hashloc;
182
183 for (hashloc = (hashkey*AA+BB)%prime%hashtablesize; hash[2*hashloc] != -1 && hash[2*hashloc]!= (int)hashkey; hashloc++,hashloc = hashloc%hashtablesize);
184
185 hash[2*hashloc] = hashkey;
186 hash[2*hashloc+1] = ic;
187}
188
189void write_hash_linear_report_level_1(uint ic, ulong hashkey, int *hash){
190 int icount = 0;
191 uint hashloc;
192
193 hash_ncells++;
194 for (hashloc = (hashkey*AA+BB)%prime%hashtablesize; hash[2*hashloc] != -1 && hash[2*hashloc]!= (int)hashkey; hashloc++,hashloc = hashloc%hashtablesize){
195 write_hash_collisions++;
196 }
197
198 hash[2*hashloc] = hashkey;
199 hash[2*hashloc+1] = ic;
200}
201
202void write_hash_linear_report_level_2(uint ic, ulong hashkey, int *hash){
203 int icount = 0;
204 uint hashloc;
205
206 hash_ncells++;
207 for (hashloc = (hashkey*AA+BB)%prime%hashtablesize; hash[2*hashloc] != -1 && hash[2*hashloc]!= (int)hashkey; hashloc++,hashloc = hashloc%hashtablesize){
208 write_hash_collisions++;
209 }
210
211 hash[2*hashloc] = hashkey;
212 hash[2*hashloc+1] = ic;
213}
214
215void write_hash_linear_report_level_3(uint ic, ulong hashkey, int *hash){
216 int icount = 0;
217 uint hashloc;
218
219 hash_ncells++;
220 hashloc = (hashkey*AA+BB)%prime%hashtablesize;
221 printf("%d: cell %d hashloc is %d hash[2*hashloc] = %d hashkey %lu ii %lu jj %lu\n",icount,ic,hashloc,hash[2*hashloc],hashkey,hashkey%hash_stride,hashkey/hash_stride);
222 for (hashloc = (hashkey*AA+BB)%prime%hashtablesize; hash[2*hashloc] != -1 && hash[2*hashloc]!= (int)hashkey; hashloc++,hashloc = hashloc%hashtablesize){
223 int hashloctmp = hashloc+1;
224 hashloctmp = hashloctmp%hashtablesize;
225 printf("%d: cell %d hashloc is %d hash[2*hashloc] = %d hashkey %lu ii %lu jj %lu\n",icount,ic,hashloctmp,hash[2*hashloctmp],hashkey,hashkey%hash_stride,hashkey/hash_stride);
226 icount++;
227 }
228 write_hash_collisions += icount;
229
230 hash[2*hashloc] = hashkey;
231 hash[2*hashloc+1] = ic;
232}
233
234void write_hash_quadratic(uint ic, ulong hashkey, int *hash){
235 int icount = 0;
236 uint hashloc;
237
238 for (hashloc = (hashkey*AA+BB)%prime%hashtablesize; hash[2*hashloc] != -1 && hash[2*hashloc]!= (int)hashkey; hashloc+=(icount*icount),hashloc = hashloc%hashtablesize) {
239 icount++;
240 }
241
242 hash[2*hashloc] = hashkey;
243 hash[2*hashloc+1] = ic;
244}
245
246void write_hash_quadratic_report_level_1(uint ic, ulong hashkey, int *hash){
247 int icount = 0;
248 uint hashloc;
249
250 hash_ncells++;
251 for (hashloc = (hashkey*AA+BB)%prime%hashtablesize; hash[2*hashloc] != -1 && hash[2*hashloc]!= (int)hashkey; hashloc+=(icount*icount),hashloc = hashloc%hashtablesize){
252 icount++;
253 }
254 write_hash_collisions += icount;
255
256 hash[2*hashloc] = hashkey;
257 hash[2*hashloc+1] = ic;
258}
259
260void write_hash_quadratic_report_level_2(uint ic, ulong hashkey, int *hash){
261 int icount = 0;
262 uint hashloc;
263
264 hash_ncells++;
265 for (hashloc = (hashkey*AA+BB)%prime%hashtablesize; hash[2*hashloc] != -1 && hash[2*hashloc]!= (int)hashkey; hashloc+=(icount*icount),hashloc = hashloc%hashtablesize){
266 icount++;
267 }
268 write_hash_collisions += icount;
269
270 hash[2*hashloc] = hashkey;
271 hash[2*hashloc+1] = ic;
272}
273
274void write_hash_quadratic_report_level_3(uint ic, ulong hashkey, int *hash){
275 int icount = 0;
276 uint hashloc;
277
278 hash_ncells++;
279 hashloc = (hashkey*AA+BB)%prime%hashtablesize;
280 printf("%d: cell %d hashloc is %d hash[2*hashloc] = %d hashkey %lu ii %lu jj %lu\n",icount,ic,hashloc,hash[2*hashloc],hashkey,hashkey%hash_stride,hashkey/hash_stride);
281 for (hashloc = (hashkey*AA+BB)%prime%hashtablesize; hash[2*hashloc] != -1 && hash[2*hashloc]!= (int)hashkey; hashloc+=(icount*icount),hashloc = hashloc%hashtablesize){
282 icount++;
283 int hashloctmp = hashloc+icount*icount;
284 hashloctmp = hashloctmp%hashtablesize;
285 printf("%d: cell %d hashloc is %d hash[2*hashloc] = %d hashkey %lu ii %lu jj %lu\n",icount,ic,hashloctmp,hash[2*hashloctmp],hashkey,hashkey%hash_stride,hashkey/hash_stride);
286 }
287 write_hash_collisions += icount;
288
289 hash[2*hashloc] = hashkey;
290 hash[2*hashloc+1] = ic;
291}
292
293void write_hash_primejump(uint ic, ulong hashkey, int *hash){
294 int icount = 0;
295 uint hashloc;
296
297 uint jump = 1+hashkey%hash_jump_prime;
298
299 for (hashloc = (hashkey*AA+BB)%prime%hashtablesize; hash[2*hashloc] != -1 && hash[2*hashloc]!= (int)hashkey; hashloc+=(icount*jump),hashloc = hashloc%hashtablesize) {
300 icount++;
301 }
302
303 hash[2*hashloc] = hashkey;
304 hash[2*hashloc+1] = ic;
305}
306
307void write_hash_primejump_report_level_1(uint ic, ulong hashkey, int *hash){
308 int icount = 0;
309 uint hashloc;
310
311 uint jump = 1+hashkey%hash_jump_prime;
312
313 hash_ncells++;
314 for (hashloc = (hashkey*AA+BB)%prime%hashtablesize; hash[2*hashloc] != -1 && hash[2*hashloc]!= (int)hashkey; hashloc+=(icount*jump),hashloc = hashloc%hashtablesize){
315 icount++;
316 }
317 write_hash_collisions += icount;
318
319 hash[2*hashloc] = hashkey;
320 hash[2*hashloc+1] = ic;
321}
322
323void write_hash_primejump_report_level_2(uint ic, ulong hashkey, int *hash){
324 int icount = 0;
325 uint hashloc;
326
327 uint jump = 1+hashkey%hash_jump_prime;
328
329 hash_ncells++;
330 for (hashloc = (hashkey*AA+BB)%prime%hashtablesize; hash[2*hashloc] != -1 && hash[2*hashloc]!= (int)hashkey; hashloc+=(icount*jump),hashloc = hashloc%hashtablesize){
331 icount++;
332 }
333 write_hash_collisions += icount;
334
335 hash[2*hashloc] = hashkey;
336 hash[2*hashloc+1] = ic;
337}
338
339void write_hash_primejump_report_level_3(uint ic, ulong hashkey, int *hash){
340 int icount = 0;
341 uint hashloc;
342
343 uint jump = 1+hashkey%hash_jump_prime;
344
345 hash_ncells++;
346 hashloc = (hashkey*AA+BB)%prime%hashtablesize;
347 printf("%d: cell %d hashloc is %d hash[2*hashloc] = %d hashkey %lu ii %lu jj %lu\n",icount,ic,hashloc,hash[2*hashloc],hashkey,hashkey%hash_stride,hashkey/hash_stride);
348 for (hashloc = (hashkey*AA+BB)%prime%hashtablesize; hash[2*hashloc] != -1 && hash[2*hashloc]!= (int)hashkey; hashloc+=(icount*jump),hashloc = hashloc%hashtablesize){
349 icount++;
350 int hashloctmp = hashloc+1;
351 hashloctmp = hashloctmp%hashtablesize;
352 printf("%d: cell %d hashloc is %d hash[2*hashloc] = %d hashkey %lu ii %lu jj %lu\n",icount,ic,hashloctmp,hash[2*hashloctmp],hashkey,hashkey%hash_stride,hashkey/hash_stride);
353 }
354 write_hash_collisions += icount;
355
356 hash[2*hashloc] = hashkey;
357 hash[2*hashloc+1] = ic;
358}
359
360#ifdef _OPENMP
361
362#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
363void write_hash_perfect_openmp(uint ic, ulong hashkey, int *hash){
364#else
365void write_hash_perfect_openmp(uint ic, ulong hashkey, int *hash, omp_lock_t *lock){
366#endif
367 hash[hashkey] = ic;
368}
369
370#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
371void write_hash_linear_openmp(uint ic, ulong hashkey, int *hash){
372#else
373void write_hash_linear_openmp(uint ic, ulong hashkey, int *hash, omp_lock_t *lock){
374#endif
375 int icount;
376 uint hashloc = (hashkey*AA+BB)%prime%hashtablesize;;
377
378#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
379 int MaxTries = 1000;
380
381 int old_key = __sync_val_compare_and_swap(&hash[2*hashloc], -1, hashkey);
382 //printf("old_key is %d\n",old_key);
383
384 for (icount = 1; old_key != hashkey && old_key != -1 && icount < MaxTries; icount++){
385 hashloc++;
386 hashloc %= hashtablesize;
387
388 old_key = __sync_val_compare_and_swap(&hash[2*hashloc], -1, hashkey);
389 }
390
391 if (icount < MaxTries) hash[2*hashloc+1] = ic;
392#else
393 omp_set_lock(&(lock[hashloc]));
394 while (hash[2*hashloc] != -1 && hash[2*hashloc]!= (int)hashkey){
395 omp_unset_lock(&(lock[hashloc]));
396 hashloc++;
397 hashloc = hashloc%hashtablesize;
398 omp_set_lock(&(lock[hashloc]));
399 }
400
401 hash[2*hashloc] = hashkey;
402 hash[2*hashloc+1] = ic;
403 omp_unset_lock(&(lock[hashloc]));
404#endif
405}
406
407#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
408void write_hash_linear_openmp_report_level_1(uint ic, ulong hashkey, int *hash){
409#else
410void write_hash_linear_openmp_report_level_1(uint ic, ulong hashkey, int *hash, omp_lock_t *lock){
411#endif
412 int icount = 0;
413 uint hashloc = (hashkey*AA+BB)%prime%hashtablesize;;
414
415#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
416 int MaxTries = 1000;
417
418 int old_key = __sync_val_compare_and_swap(&hash[2*hashloc], -1, hashkey);
419 //printf("old_key is %d\n",old_key);
420
421 for (icount = 1; old_key != hashkey && old_key != -1 && icount < MaxTries; icount++){
422 hashloc++;
423 hashloc %= hashtablesize;
424
425 old_key = __sync_val_compare_and_swap(&hash[2*hashloc], -1, hashkey);
426 icount++;
427 }
428
429 if (icount < MaxTries) hash[2*hashloc+1] = ic;
430#else
431 omp_set_lock(&(lock[hashloc]));
432 while (hash[2*hashloc] != -1 && hash[2*hashloc]!= (int)hashkey){
433 omp_unset_lock(&(lock[hashloc]));
434 hashloc++;
435 hashloc = hashloc%hashtablesize;
436 omp_set_lock(&(lock[hashloc]));
437 icount++;
438 }
439
440 hash[2*hashloc] = hashkey;
441 hash[2*hashloc+1] = ic;
442 omp_unset_lock(&(lock[hashloc]));
443#endif
444
445#pragma omp atomic
446 write_hash_collisions += icount;;
447#pragma omp atomic
448 hash_ncells++;
449}
450
451#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
452void write_hash_linear_openmp_report_level_2(uint ic, ulong hashkey, int *hash){
453#else
454void write_hash_linear_openmp_report_level_2(uint ic, ulong hashkey, int *hash, omp_lock_t *lock){
455#endif
456 int icount = 0;
457 uint hashloc = (hashkey*AA+BB)%prime%hashtablesize;;
458
459#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
460 int MaxTries = 1000;
461
462 int old_key = __sync_val_compare_and_swap(&hash[2*hashloc], -1, hashkey);
463 //printf("old_key is %d\n",old_key);
464
465 for (icount = 1; old_key != hashkey && old_key != -1 && icount < MaxTries; icount++){
466 hashloc++;
467 hashloc %= hashtablesize;
468
469 old_key = __sync_val_compare_and_swap(&hash[2*hashloc], -1, hashkey);
470 icount++;
471 }
472
473 if (icount < MaxTries) hash[2*hashloc+1] = ic;
474#else
475 omp_set_lock(&(lock[hashloc]));
476 while (hash[2*hashloc] != -1 && hash[2*hashloc]!= (int)hashkey){
477 omp_unset_lock(&(lock[hashloc]));
478 hashloc++;
479 hashloc = hashloc%hashtablesize;
480 omp_set_lock(&(lock[hashloc]));
481 icount++;
482 }
483
484 hash[2*hashloc] = hashkey;
485 hash[2*hashloc+1] = ic;
486 omp_unset_lock(&(lock[hashloc]));
487#endif
488
489#pragma omp atomic
490 write_hash_collisions += icount;;
491#pragma omp atomic
492 hash_ncells++;
493}
494
495#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
496void write_hash_linear_openmp_report_level_3(uint ic, ulong hashkey, int *hash){
497#else
498void write_hash_linear_openmp_report_level_3(uint ic, ulong hashkey, int *hash, omp_lock_t *lock){
499#endif
500 int icount = 0;
501 uint hashloc = (hashkey*AA+BB)%prime%hashtablesize;;
502 printf("%d: cell %d hashloc is %d hash[2*hashloc] = %d hashkey %lu ii %lu jj %lu\n",icount,ic,hashloc,hash[2*hashloc],hashkey,hashkey%hash_stride,hashkey/hash_stride);
503
504#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
505 int MaxTries = 1000;
506
507 int old_key = __sync_val_compare_and_swap(&hash[2*hashloc], -1, hashkey);
508 //printf("old_key is %d\n",old_key);
509
510 for (icount = 1; old_key != hashkey && old_key != -1 && icount < MaxTries; icount++){
511 hashloc++;
512 hashloc %= hashtablesize;
513 printf("%d: cell %d hashloc is %d hash[2*hashloc] = %d hashkey %lu ii %lu jj %lu\n",icount,ic,hashloc,hash[2*hashloc],hashkey,hashkey%hash_stride,hashkey/hash_stride);
514
515 old_key = __sync_val_compare_and_swap(&hash[2*hashloc], -1, hashkey);
516 icount++;
517 }
518
519 if (icount < MaxTries) hash[2*hashloc+1] = ic;
520#else
521 omp_set_lock(&(lock[hashloc]));
522 while (hash[2*hashloc] != -1 && hash[2*hashloc]!= (int)hashkey){
523 omp_unset_lock(&(lock[hashloc]));
524 hashloc++;
525 hashloc = hashloc%hashtablesize;
526 printf("%d: cell %d hashloc is %d hash[2*hashloc] = %d hashkey %lu ii %lu jj %lu\n",icount,ic,hashloc,hash[2*hashloc],hashkey,hashkey%hash_stride,hashkey/hash_stride);
527 omp_set_lock(&(lock[hashloc]));
528 icount++;
529 }
530
531 hash[2*hashloc] = hashkey;
532 hash[2*hashloc+1] = ic;
533 omp_unset_lock(&(lock[hashloc]));
534#endif
535
536#pragma omp atomic
537 write_hash_collisions += icount;;
538#pragma omp atomic
539 hash_ncells++;
540}
541
542#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
543void write_hash_quadratic_openmp(uint ic, ulong hashkey, int *hash){
544#else
545void write_hash_quadratic_openmp(uint ic, ulong hashkey, int *hash, omp_lock_t *lock){
546#endif
547 int icount = 0;
548 uint hashloc = (hashkey*AA+BB)%prime%hashtablesize;
549
550#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
551 int MaxTries = 1000;
552
553 int old_key = __sync_val_compare_and_swap(&hash[2*hashloc], -1, hashkey);
554 //printf("old_key is %d\n",old_key);
555
556 for (icount = 1; old_key != hashkey && old_key != -1 && icount < MaxTries; icount++){
557 hashloc+=(icount*icount);
558 hashloc %= hashtablesize;
559
560 old_key = __sync_val_compare_and_swap(&hash[2*hashloc], -1, hashkey);
561 }
562
563 if (icount < MaxTries) hash[2*hashloc+1] = ic;
564#else
565 omp_set_lock(&(lock[hashloc]));
566 while (hash[2*hashloc] != -1 && hash[2*hashloc]!= (int)hashkey){
567 omp_unset_lock(&(lock[hashloc]));
568 icount++;
569 hashloc+=(icount*icount);
570 hashloc = hashloc%hashtablesize;
571 omp_set_lock(&(lock[hashloc]));
572 }
573
574 hash[2*hashloc] = hashkey;
575 hash[2*hashloc+1] = ic;
576 omp_unset_lock(&(lock[hashloc]));
577#endif
578}
579
580#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
581void write_hash_quadratic_openmp_report_level_1(uint ic, ulong hashkey, int *hash){
582#else
583void write_hash_quadratic_openmp_report_level_1(uint ic, ulong hashkey, int *hash, omp_lock_t *lock){
584#endif
585 int icount = 0;
586 uint hashloc = (hashkey*AA+BB)%prime%hashtablesize;
587
588#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
589 int MaxTries = 1000;
590
591 int old_key = __sync_val_compare_and_swap(&hash[2*hashloc], -1, hashkey);
592 //printf("old_key is %d\n",old_key);
593
594 for (icount = 1; old_key != hashkey && old_key != -1 && icount < MaxTries; icount++){
595 hashloc+=(icount*icount);
596 hashloc %= hashtablesize;
597
598 old_key = __sync_val_compare_and_swap(&hash[2*hashloc], -1, hashkey);
599 }
600
601 if (icount < MaxTries) hash[2*hashloc+1] = ic;
602#else
603 omp_set_lock(&(lock[hashloc]));
604 while (hash[2*hashloc] != -1 && hash[2*hashloc]!= (int)hashkey){
605 omp_unset_lock(&(lock[hashloc]));
606 icount++;
607 hashloc+=(icount*icount);
608 hashloc = hashloc%hashtablesize;
609 omp_set_lock(&(lock[hashloc]));
610 }
611
612 hash[2*hashloc] = hashkey;
613 hash[2*hashloc+1] = ic;
614 omp_unset_lock(&(lock[hashloc]));
615#endif
616
617#pragma omp atomic
618 write_hash_collisions += icount;;
619#pragma omp atomic
620 hash_ncells++;
621}
622
623#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
624void write_hash_quadratic_openmp_report_level_2(uint ic, ulong hashkey, int *hash){
625#else
626void write_hash_quadratic_openmp_report_level_2(uint ic, ulong hashkey, int *hash, omp_lock_t *lock){
627#endif
628 int icount = 0;
629 uint hashloc = (hashkey*AA+BB)%prime%hashtablesize;
630
631#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
632 int MaxTries = 1000;
633
634 int old_key = __sync_val_compare_and_swap(&hash[2*hashloc], -1, hashkey);
635 //printf("old_key is %d\n",old_key);
636
637 for (icount = 1; old_key != hashkey && old_key != -1 && icount < MaxTries; icount++){
638 hashloc+=(icount*icount);
639 hashloc %= hashtablesize;
640
641 old_key = __sync_val_compare_and_swap(&hash[2*hashloc], -1, hashkey);
642 }
643
644 if (icount < MaxTries) hash[2*hashloc+1] = ic;
645#else
646 omp_set_lock(&(lock[hashloc]));
647 while (hash[2*hashloc] != -1 && hash[2*hashloc]!= (int)hashkey){
648 omp_unset_lock(&(lock[hashloc]));
649 icount++;
650 hashloc+=(icount*icount);
651 hashloc = hashloc%hashtablesize;
652 omp_set_lock(&(lock[hashloc]));
653 }
654
655 hash[2*hashloc] = hashkey;
656 hash[2*hashloc+1] = ic;
657 omp_unset_lock(&(lock[hashloc]));
658#endif
659
660#pragma omp atomic
661 write_hash_collisions += icount;;
662#pragma omp atomic
663 hash_ncells++;
664}
665
666#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
667void write_hash_quadratic_openmp_report_level_3(uint ic, ulong hashkey, int *hash){
668#else
669void write_hash_quadratic_openmp_report_level_3(uint ic, ulong hashkey, int *hash, omp_lock_t *lock){
670#endif
671 int icount = 0;
672 uint hashloc = (hashkey*AA+BB)%prime%hashtablesize;
673 printf("%d: cell %d hashloc is %d hash[2*hashloc] = %d hashkey %lu ii %lu jj %lu\n",icount,ic,hashloc,hash[2*hashloc],hashkey,hashkey%hash_stride,hashkey/hash_stride);
674
675#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
676 int MaxTries = 1000;
677
678 int old_key = __sync_val_compare_and_swap(&hash[2*hashloc], -1, hashkey);
679 //printf("old_key is %d\n",old_key);
680
681 for (icount = 1; old_key != hashkey && old_key != -1 && icount < MaxTries; icount++){
682 hashloc+=(icount*icount);
683 hashloc %= hashtablesize;
684 printf("%d: cell %d hashloc is %d hash[2*hashloc] = %d hashkey %lu ii %lu jj %lu\n",icount,ic,hashloc,hash[2*hashloc],hashkey,hashkey%hash_stride,hashkey/hash_stride);
685
686 old_key = __sync_val_compare_and_swap(&hash[2*hashloc], -1, hashkey);
687 }
688
689 if (icount < MaxTries) hash[2*hashloc+1] = ic;
690#else
691 omp_set_lock(&(lock[hashloc]));
692 while (hash[2*hashloc] != -1 && hash[2*hashloc]!= (int)hashkey){
693 omp_unset_lock(&(lock[hashloc]));
694 icount++;
695 hashloc+=(icount*icount);
696 hashloc = hashloc%hashtablesize;
697 printf("%d: cell %d hashloc is %d hash[2*hashloc] = %d hashkey %lu ii %lu jj %lu\n",icount,ic,hashloc,hash[2*hashloc],hashkey,hashkey%hash_stride,hashkey/hash_stride);
698 omp_set_lock(&(lock[hashloc]));
699 }
700
701 hash[2*hashloc] = hashkey;
702 hash[2*hashloc+1] = ic;
703 omp_unset_lock(&(lock[hashloc]));
704#endif
705
706#pragma omp atomic
707 write_hash_collisions += icount;;
708#pragma omp atomic
709 hash_ncells++;
710}
711
712#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
713void write_hash_primejump_openmp(uint ic, ulong hashkey, int *hash){
714#else
715void write_hash_primejump_openmp(uint ic, ulong hashkey, int *hash, omp_lock_t *lock){
716#endif
717 int icount = 0;
718 uint jump = 1+hashkey%hash_jump_prime;
719 uint hashloc = (hashkey*AA+BB)%prime%hashtablesize;
720
721#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
722 int MaxTries = 1000;
723
724 int old_key = __sync_val_compare_and_swap(&hash[2*hashloc], -1, hashkey);
725 //printf("old_key is %d\n",old_key);
726
727 for (icount = 1; old_key != hashkey && old_key != -1 && icount < MaxTries; icount++){
728 hashloc+=(icount*jump);
729 hashloc %= hashtablesize;
730
731 old_key = __sync_val_compare_and_swap(&hash[2*hashloc], -1, hashkey);
732 }
733
734 if (icount < MaxTries) hash[2*hashloc+1] = ic;
735#else
736 omp_set_lock(&(lock[hashloc]));
737 while (hash[2*hashloc] != -1 && hash[2*hashloc]!= (int)hashkey){
738 omp_unset_lock(&(lock[hashloc]));
739 icount++;
740 hashloc+=(icount*jump);
741 hashloc = hashloc%hashtablesize;
742 omp_set_lock(&(lock[hashloc]));
743 }
744
745 hash[2*hashloc] = hashkey;
746 hash[2*hashloc+1] = ic;
747 omp_unset_lock(&(lock[hashloc]));
748#endif
749}
750
751#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
752void write_hash_primejump_openmp_report_level_1(uint ic, ulong hashkey, int *hash){
753#else
754void write_hash_primejump_openmp_report_level_1(uint ic, ulong hashkey, int *hash, omp_lock_t *lock){
755#endif
756 int icount = 0;
757 uint jump = 1+hashkey%hash_jump_prime;
758 uint hashloc = (hashkey*AA+BB)%prime%hashtablesize;
759
760#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
761 int MaxTries = 1000;
762
763 int old_key = __sync_val_compare_and_swap(&hash[2*hashloc], -1, hashkey);
764 //printf("old_key is %d\n",old_key);
765
766 for (icount = 1; old_key != hashkey && old_key != -1 && icount < MaxTries; icount++){
767 hashloc+=(icount*jump);
768 hashloc %= hashtablesize;
769
770 old_key = __sync_val_compare_and_swap(&hash[2*hashloc], -1, hashkey);
771 }
772
773 if (icount < MaxTries) hash[2*hashloc+1] = ic;
774#else
775 omp_set_lock(&(lock[hashloc]));
776 while (hash[2*hashloc] != -1 && hash[2*hashloc]!= (int)hashkey){
777 omp_unset_lock(&(lock[hashloc]));
778 icount++;
779 hashloc+=(icount*jump);
780 hashloc = hashloc%hashtablesize;
781 omp_set_lock(&(lock[hashloc]));
782 }
783
784 hash[2*hashloc] = hashkey;
785 hash[2*hashloc+1] = ic;
786 omp_unset_lock(&(lock[hashloc]));
787#endif
788
789#pragma omp atomic
790 write_hash_collisions += icount;;
791#pragma omp atomic
792 hash_ncells++;
793}
794
795#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
796void write_hash_primejump_openmp_report_level_2(uint ic, ulong hashkey, int *hash){
797#else
798void write_hash_primejump_openmp_report_level_2(uint ic, ulong hashkey, int *hash, omp_lock_t *lock){
799#endif
800 int icount = 0;
801 uint jump = 1+hashkey%hash_jump_prime;
802 uint hashloc = (hashkey*AA+BB)%prime%hashtablesize;
803
804#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
805 int MaxTries = 1000;
806
807 int old_key = __sync_val_compare_and_swap(&hash[2*hashloc], -1, hashkey);
808 //printf("old_key is %d\n",old_key);
809
810 for (icount = 1; old_key != hashkey && old_key != -1 && icount < MaxTries; icount++){
811 hashloc+=(icount*jump);
812 hashloc %= hashtablesize;
813
814 old_key = __sync_val_compare_and_swap(&hash[2*hashloc], -1, hashkey);
815 }
816
817 if (icount < MaxTries) hash[2*hashloc+1] = ic;
818#else
819 omp_set_lock(&(lock[hashloc]));
820 while (hash[2*hashloc] != -1 && hash[2*hashloc]!= (int)hashkey){
821 omp_unset_lock(&(lock[hashloc]));
822 icount++;
823 hashloc+=(icount*jump);
824 hashloc = hashloc%hashtablesize;
825 omp_set_lock(&(lock[hashloc]));
826 }
827
828 hash[2*hashloc] = hashkey;
829 hash[2*hashloc+1] = ic;
830 omp_unset_lock(&(lock[hashloc]));
831#endif
832
833#pragma omp atomic
834 write_hash_collisions += icount;;
835#pragma omp atomic
836 hash_ncells++;
837}
838
839#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
840void write_hash_primejump_openmp_report_level_3(uint ic, ulong hashkey, int *hash){
841#else
842void write_hash_primejump_openmp_report_level_3(uint ic, ulong hashkey, int *hash, omp_lock_t *lock){
843#endif
844 int icount = 0;
845 uint jump = 1+hashkey%hash_jump_prime;
846 uint hashloc = (hashkey*AA+BB)%prime%hashtablesize;
847 printf("%d: cell %d hashloc is %d hash[2*hashloc] = %d hashkey %lu ii %lu jj %lu\n",icount,ic,hashloc,hash[2*hashloc],hashkey,hashkey%hash_stride,hashkey/hash_stride);
848
849#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
850 int MaxTries = 1000;
851
852 int old_key = __sync_val_compare_and_swap(&hash[2*hashloc], -1, hashkey);
853 //printf("old_key is %d\n",old_key);
854
855 for (icount = 1; old_key != hashkey && old_key != -1 && icount < MaxTries; icount++){
856 hashloc+=(icount*jump);
857 hashloc %= hashtablesize;
858 printf("%d: cell %d hashloc is %d hash[2*hashloc] = %d hashkey %lu ii %lu jj %lu\n",icount,ic,hashloc,hash[2*hashloc],hashkey,hashkey%hash_stride,hashkey/hash_stride);
859
860 old_key = __sync_val_compare_and_swap(&hash[2*hashloc], -1, hashkey);
861 }
862
863 if (icount < MaxTries) hash[2*hashloc+1] = ic;
864#else
865 omp_set_lock(&(lock[hashloc]));
866 while (hash[2*hashloc] != -1 && hash[2*hashloc]!= (int)hashkey){
867 omp_unset_lock(&(lock[hashloc]));
868 icount++;
869 hashloc+=(icount*jump);
870 hashloc = hashloc%hashtablesize;
871 printf("%d: cell %d hashloc is %d hash[2*hashloc] = %d hashkey %lu ii %lu jj %lu\n",icount,ic,hashloc,hash[2*hashloc],hashkey,hashkey%hash_stride,hashkey/hash_stride);
872 omp_set_lock(&(lock[hashloc]));
873 }
874
875 hash[2*hashloc] = hashkey;
876 hash[2*hashloc+1] = ic;
877 omp_unset_lock(&(lock[hashloc]));
878#endif
879
880#pragma omp atomic
881 write_hash_collisions += icount;;
882#pragma omp atomic
883 hash_ncells++;
884}
885#endif
886
887int read_hash_perfect(ulong hashkey, int *hash){
888 return(hash[hashkey]);
889}
890
891int read_hash_linear(ulong hashkey, int *hash){
892 int hashval = -1;
893 uint hashloc;
894 for (hashloc = (hashkey*AA+BB)%prime%hashtablesize; hash[2*hashloc] != (int)hashkey && hash[2*hashloc] != -1; hashloc++,hashloc = hashloc%hashtablesize);
895
896 if (hash[2*hashloc] != -1) hashval = hash[2*hashloc+1];
897 return(hashval);
898}
899
900int read_hash_linear_report_level_1(ulong hashkey, int *hash){
901 int hashval = -1;
902 uint hashloc;
903 int icount=0;
904
905 hash_queries++;
906 for (hashloc = (hashkey*AA+BB)%prime%hashtablesize; hash[2*hashloc] != (int)hashkey && hash[2*hashloc] != -1; hashloc++,hashloc = hashloc%hashtablesize){
907 icount++;
908 }
909 read_hash_collisions += icount;
910
911 if (hash[2*hashloc] != -1) hashval = hash[2*hashloc+1];
912 return(hashval);
913}
914
915int read_hash_linear_report_level_2(ulong hashkey, int *hash){
916 int max_collisions_allowed = 1000;
917 int hashval = -1;
918 uint hashloc;
919 int icount=0;
920
921 hash_queries++;
922 for (hashloc = (hashkey*AA+BB)%prime%hashtablesize; hash[2*hashloc] != (int)hashkey && hash[2*hashloc] != -1; hashloc++,hashloc = hashloc%hashtablesize){
923 icount++;
924 if (icount > max_collisions_allowed) {
925 printf("Error -- too many read hash collisions\n");
926 exit(0);
927 }
928 }
929 read_hash_collisions += icount;
930
931 if (hash[2*hashloc] != -1) hashval = hash[2*hashloc+1];
932 return(hashval);
933}
934
935int read_hash_linear_report_level_3(ulong hashkey, int *hash){
936 int max_collisions_allowed = 1000;
937 int hashval = -1;
938 uint hashloc;
939 int icount=0;
940
941 hash_queries++;
942 hashloc = (hashkey*AA+BB)%prime%hashtablesize;
943 printf("%d: hashloc is %d hash[2*hashloc] = %d hashkey %lu ii %lu jj %lu\n",icount,hashloc,hash[2*hashloc],hashkey,hashkey%hash_stride,hashkey/hash_stride);
944 for (hashloc = (hashkey*AA+BB)%prime%hashtablesize; hash[2*hashloc] != (int)hashkey && hash[2*hashloc] != -1; hashloc++,hashloc = hashloc%hashtablesize){
945 icount++;
946 uint hashloctmp = hashloc+1;
947 hashloctmp = hashloctmp%hashtablesize;
948 printf("%d: hashloc is %d hash[2*hashloc] = %d hashkey %lu ii %lu jj %lu\n",icount,hashloctmp,hash[2*hashloctmp],hashkey,hashkey%hash_stride,hashkey/hash_stride);
949 if (icount > max_collisions_allowed) {
950 printf("Error -- too many read hash collisions\n");
951 exit(0);
952 }
953 }
954 read_hash_collisions += icount;
955
956 if (hash[2*hashloc] != -1) hashval = hash[2*hashloc+1];
957 return(hashval);
958}
959
960int read_hash_quadratic(ulong hashkey, int *hash){
961 int hashval = -1;
962 uint hashloc;
963 int icount=0;
964
965 for (hashloc = (hashkey*AA+BB)%prime%hashtablesize; hash[2*hashloc] != (int)hashkey && hash[2*hashloc] != -1; hashloc+=(icount*icount),hashloc = hashloc%hashtablesize){
966 icount++;
967 }
968
969 if (hash[2*hashloc] != -1) hashval = hash[2*hashloc+1];
970 return(hashval);
971}
972
973int read_hash_quadratic_report_level_1(ulong hashkey, int *hash){
974 int hashval = -1;
975 uint hashloc;
976 int icount=0;
977
978 hash_queries++;
979 for (hashloc = (hashkey*AA+BB)%prime%hashtablesize; hash[2*hashloc] != (int)hashkey && hash[2*hashloc] != -1; hashloc+=(icount*icount),hashloc = hashloc%hashtablesize){
980 icount++;
981 }
982 read_hash_collisions += icount;
983
984 if (hash[2*hashloc] != -1) hashval = hash[2*hashloc+1];
985 return(hashval);
986}
987
988int read_hash_quadratic_report_level_2(ulong hashkey, int *hash){
989 int max_collisions_allowed = 1000;
990 int hashval = -1;
991 uint hashloc;
992 int icount=0;
993
994 hash_queries++;
995 for (hashloc = (hashkey*AA+BB)%prime%hashtablesize; hash[2*hashloc] != (int)hashkey && hash[2*hashloc] != -1; hashloc+=(icount*icount),hashloc = hashloc%hashtablesize){
996 icount++;
997 if (icount > max_collisions_allowed) {
998 printf("Error -- too many read hash collisions\n");
999 exit(0);
1000 }
1001 }
1002 read_hash_collisions += icount;
1003
1004 if (hash[2*hashloc] != -1) hashval = hash[2*hashloc+1];
1005 return(hashval);
1006}
1007
1008int read_hash_quadratic_report_level_3(ulong hashkey, int *hash){
1009 int max_collisions_allowed = 1000;
1010 int hashval = -1;
1011 uint hashloc;
1012 int icount=0;
1013
1014 hash_queries++;
1015 hashloc = (hashkey*AA+BB)%prime%hashtablesize;
1016 printf("%d: hashloc is %d hash[2*hashloc] = %d hashkey %lu ii %lu jj %lu\n",icount,hashloc,hash[2*hashloc],hashkey,hashkey%hash_stride,hashkey/hash_stride);
1017 for (hashloc = (hashkey*AA+BB)%prime%hashtablesize; hash[2*hashloc] != (int)hashkey && hash[2*hashloc] != -1; hashloc+=(icount*icount),hashloc = hashloc%hashtablesize){
1018 icount++;
1019 uint hashloctmp = hashloc+1;
1020 hashloctmp = hashloctmp%hashtablesize;
1021 printf("%d: hashloc is %d hash[2*hashloc] = %d hashkey %lu ii %lu jj %lu\n",icount,hashloctmp,hash[2*hashloctmp],hashkey,hashkey%hash_stride,hashkey/hash_stride);
1022 if (icount > max_collisions_allowed) {
1023 printf("Error -- too many read hash collisions\n");
1024 exit(0);
1025 }
1026 }
1027 read_hash_collisions += icount;
1028
1029 if (hash[2*hashloc] != -1) hashval = hash[2*hashloc+1];
1030 return(hashval);
1031}
1032
1033int read_hash_primejump(ulong hashkey, int *hash){
1034 int hashval = -1;
1035 uint hashloc;
1036 int icount=0;
1037
1038 uint jump = 1+hashkey%hash_jump_prime;
1039 for (hashloc = (hashkey*AA+BB)%prime%hashtablesize; hash[2*hashloc] != (int)hashkey && hash[2*hashloc] != -1; hashloc+=(icount*jump),hashloc = hashloc%hashtablesize){
1040 icount++;
1041 }
1042
1043 if (hash[2*hashloc] != -1) hashval = hash[2*hashloc+1];
1044 return(hashval);
1045}
1046
1047int read_hash_primejump_report_level_1(ulong hashkey, int *hash){
1048 int hashval = -1;
1049 uint hashloc;
1050 int icount=0;
1051
1052 uint jump = 1+hashkey%hash_jump_prime;
1053 hash_queries++;
1054 for (hashloc = (hashkey*AA+BB)%prime%hashtablesize; hash[2*hashloc] != (int)hashkey && hash[2*hashloc] != -1; hashloc+=(icount*jump),hashloc = hashloc%hashtablesize){
1055 icount++;
1056 }
1057 read_hash_collisions += icount;
1058
1059 if (hash[2*hashloc] != -1) hashval = hash[2*hashloc+1];
1060 return(hashval);
1061}
1062
1063int read_hash_primejump_report_level_2(ulong hashkey, int *hash){
1064 int max_collisions_allowed = 1000;
1065 int hashval = -1;
1066 uint hashloc;
1067 int icount=0;
1068
1069 uint jump = 1+hashkey%hash_jump_prime;
1070
1071 hash_queries++;
1072 for (hashloc = (hashkey*AA+BB)%prime%hashtablesize; hash[2*hashloc] != (int)hashkey && hash[2*hashloc] != -1; hashloc+=(icount*jump),hashloc = hashloc%hashtablesize){
1073 icount++;
1074 if (icount > max_collisions_allowed) {
1075 printf("Error -- too many read hash collisions\n");
1076 exit(0);
1077 }
1078 }
1079 read_hash_collisions += icount;
1080
1081 if (hash[2*hashloc] != -1) hashval = hash[2*hashloc+1];
1082 return(hashval);
1083}
1084
1085int read_hash_primejump_report_level_3(ulong hashkey, int *hash){
1086 int max_collisions_allowed = 1000;
1087 int hashval = -1;
1088 uint hashloc;
1089 int icount=0;
1090
1091 uint jump = 1+hashkey%hash_jump_prime;
1092
1093 hash_queries++;
1094 hashloc = (hashkey*AA+BB)%prime%hashtablesize;
1095 printf("%d: hashloc is %d hash[2*hashloc] = %d hashkey %lu ii %lu jj %lu\n",icount,hashloc,hash[2*hashloc],hashkey,hashkey%hash_stride,hashkey/hash_stride);
1096 for (hashloc = (hashkey*AA+BB)%prime%hashtablesize; hash[2*hashloc] != (int)hashkey && hash[2*hashloc] != -1; hashloc+=(icount*jump),hashloc = hashloc%hashtablesize){
1097 icount++;
1098 uint hashloctmp = hashloc+1;
1099 hashloctmp = hashloctmp%hashtablesize;
1100 printf("%d: hashloc is %d hash[2*hashloc] = %d hashkey %lu ii %lu jj %lu\n",icount,hashloctmp,hash[2*hashloctmp],hashkey,hashkey%hash_stride,hashkey/hash_stride);
1101 if (icount > max_collisions_allowed) {
1102 printf("Error -- too many read hash collisions\n");
1103 exit(0);
1104 }
1105 }
1106 read_hash_collisions += icount;
1107
1108 if (hash[2*hashloc] != -1) hashval = hash[2*hashloc+1];
1109 return(hashval);
1110}
1111
1112int read_dev_hash(int hash_method, ulong hashtablesize, ulong AA, ulong BB, ulong hashkey, int *hash){
1113 //int hash_report_level = 3;
1114 int max_collisions_allowed = 1000;
1115 int hashval = -1;
1116 uint hashloc;
1117 int icount=0;
1118 if (hash_method == -1) {
1119 return(hash[hashkey]);
1120 }
1121 if (hash_method == 0) {
1122 if (hash_report_level == 0) {
1123 for (hashloc = (hashkey*AA+BB)%prime%hashtablesize; hash[2*hashloc] != (int)hashkey && hash[2*hashloc] != -1; hashloc++,hashloc = hashloc%hashtablesize){
1124 icount++;
1125 }
1126 } else if (hash_report_level == 1) {
1127 hash_queries++;
1128 for (hashloc = (hashkey*AA+BB)%prime%hashtablesize; hash[2*hashloc] != (int)hashkey && hash[2*hashloc] != -1; hashloc++,hashloc = hashloc%hashtablesize){
1129 icount++;
1130 }
1131 read_hash_collisions += icount;
1132 } else if (hash_report_level == 2) {
1133 hash_queries++;
1134 for (hashloc = (hashkey*AA+BB)%prime%hashtablesize; hash[2*hashloc] != (int)hashkey && hash[2*hashloc] != -1; hashloc++,hashloc = hashloc%hashtablesize){
1135 icount++;
1136 if (icount > max_collisions_allowed) {
1137 printf("Error -- too many read hash collisions\n");
1138 exit(0);
1139 }
1140 }
1141 read_hash_collisions += icount;
1142 } else if (hash_report_level == 3) {
1143 hash_queries++;
1144 hashloc = (hashkey*AA+BB)%prime%hashtablesize;
1145 printf("%d: hashloc is %d hash[2*hashloc] = %d hashkey %lu ii %lu jj %lu\n",icount,hashloc,hash[2*hashloc],hashkey,hashkey%hash_stride,hashkey/hash_stride);
1146 for (hashloc = (hashkey*AA+BB)%prime%hashtablesize; hash[2*hashloc] != (int)hashkey && hash[2*hashloc] != -1; hashloc++,hashloc = hashloc%hashtablesize){
1147 icount++;
1148 uint hashloctmp = hashloc+1;
1149 hashloctmp = hashloctmp%hashtablesize;
1150 printf("%d: hashloc is %d hash[2*hashloc] = %d hashkey %lu ii %lu jj %lu\n",icount,hashloctmp,hash[2*hashloctmp],hashkey,hashkey%hash_stride,hashkey/hash_stride);
1151 if (icount > max_collisions_allowed) {
1152 printf("Error -- too many read hash collisions\n");
1153 exit(0);
1154 }
1155 }
1156 read_hash_collisions += icount;
1157 }
1158 } else if (hash_method == 1) {
1159 if (hash_report_level == 0) {
1160 for (hashloc = (hashkey*AA+BB)%prime%hashtablesize; hash[2*hashloc] != (int)hashkey && hash[2*hashloc] != -1; hashloc+=(icount*icount),hashloc = hashloc%hashtablesize){
1161 icount++;
1162 }
1163 } else if (hash_report_level == 1) {
1164 hash_queries++;
1165 for (hashloc = (hashkey*AA+BB)%prime%hashtablesize; hash[2*hashloc] != (int)hashkey && hash[2*hashloc] != -1; hashloc+=(icount*icount),hashloc = hashloc%hashtablesize){
1166 icount++;
1167 }
1168 read_hash_collisions += icount;
1169 } else if (hash_report_level == 2) {
1170 hash_queries++;
1171 for (hashloc = (hashkey*AA+BB)%prime%hashtablesize; hash[2*hashloc] != (int)hashkey && hash[2*hashloc] != -1; hashloc+=(icount*icount),hashloc = hashloc%hashtablesize){
1172 icount++;
1173 if (icount > max_collisions_allowed) {
1174 printf("Error -- too many read hash collisions\n");
1175 exit(0);
1176 }
1177 }
1178 read_hash_collisions += icount;
1179 } else if (hash_report_level == 3) {
1180 hash_queries++;
1181 hashloc = (hashkey*AA+BB)%prime%hashtablesize;
1182 printf("%d: hashloc is %d hash[2*hashloc] = %d hashkey %lu ii %lu jj %lu\n",icount,hashloc,hash[2*hashloc],hashkey,hashkey%hash_stride,hashkey/hash_stride);
1183 for (hashloc = (hashkey*AA+BB)%prime%hashtablesize; hash[2*hashloc] != (int)hashkey && hash[2*hashloc] != -1; hashloc+=(icount*icount),hashloc = hashloc%hashtablesize){
1184 icount++;
1185 uint hashloctmp = hashloc+1;
1186 hashloctmp = hashloctmp%hashtablesize;
1187 printf("%d: hashloc is %d hash[2*hashloc] = %d hashkey %lu ii %lu jj %lu\n",icount,hashloctmp,hash[2*hashloctmp],hashkey,hashkey%hash_stride,hashkey/hash_stride);
1188 if (icount > max_collisions_allowed) {
1189 printf("Error -- too many read hash collisions\n");
1190 exit(0);
1191 }
1192 }
1193 read_hash_collisions += icount;
1194 }
1195 } else if (hash_method == 2) {
1196 uint jump = 1+hashkey%hash_jump_prime;
1197 if (hash_report_level == 0) {
1198 for (hashloc = (hashkey*AA+BB)%prime%hashtablesize; hash[2*hashloc] != (int)hashkey && hash[2*hashloc] != -1; hashloc+=(icount*jump),hashloc = hashloc%hashtablesize){
1199 icount++;
1200 }
1201 } else if (hash_report_level == 1) {
1202 hash_queries++;
1203 for (hashloc = (hashkey*AA+BB)%prime%hashtablesize; hash[2*hashloc] != (int)hashkey && hash[2*hashloc] != -1; hashloc+=(icount*jump),hashloc = hashloc%hashtablesize){
1204 icount++;
1205 }
1206 read_hash_collisions += icount;
1207 } else if (hash_report_level == 2) {
1208 hash_queries++;
1209 for (hashloc = (hashkey*AA+BB)%prime%hashtablesize; hash[2*hashloc] != (int)hashkey && hash[2*hashloc] != -1; hashloc+=(icount*jump),hashloc = hashloc%hashtablesize){
1210 icount++;
1211 if (icount > max_collisions_allowed) {
1212 printf("Error -- too many read hash collisions\n");
1213 exit(0);
1214 }
1215 }
1216 read_hash_collisions += icount;
1217 } else if (hash_report_level == 3) {
1218 hash_queries++;
1219 hashloc = (hashkey*AA+BB)%prime%hashtablesize;
1220 printf("%d: hashloc is %d hash[2*hashloc] = %d hashkey %lu ii %lu jj %lu\n",icount,hashloc,hash[2*hashloc],hashkey,hashkey%hash_stride,hashkey/hash_stride);
1221 for (hashloc = (hashkey*AA+BB)%prime%hashtablesize; hash[2*hashloc] != (int)hashkey && hash[2*hashloc] != -1; hashloc+=(icount*jump),hashloc = hashloc%hashtablesize){
1222 icount++;
1223 uint hashloctmp = hashloc+1;
1224 hashloctmp = hashloctmp%hashtablesize;
1225 printf("%d: hashloc is %d hash[2*hashloc] = %d hashkey %lu ii %lu jj %lu\n",icount,hashloctmp,hash[2*hashloctmp],hashkey,hashkey%hash_stride,hashkey/hash_stride);
1226 if (icount > max_collisions_allowed) {
1227 printf("Error -- too many read hash collisions\n");
1228 exit(0);
1229 }
1230 }
1231 read_hash_collisions += icount;
1232 }
1233 }
1234
1235 if (hash[2*hashloc] != -1) hashval = hash[2*hashloc+1];
1236 return(hashval);
1237}
1238
1239void write_hash_collision_report(void){
1240 if (! do_compact_hash) return;
1241 if (hash_report_level == 1) {
1242 write_hash_collisions_runsum += (double)write_hash_collisions/(double)hash_ncells;
1243 write_hash_collisions_count++;
1244 } else if (hash_report_level >= 2) {
1245 printf("Write hash collision report -- collisions per cell %lf, collisions %d cells %d\n",(double)write_hash_collisions/(double)hash_ncells,write_hash_collisions,hash_ncells);
1246 }
1247}
1248
1249void read_hash_collision_report(void){
1250 if (! do_compact_hash) return;
1251 if (hash_report_level == 1) {
1252 read_hash_collisions_runsum += (double)read_hash_collisions/(double)hash_queries;
1253 read_hash_collisions_count++;
1254 } else if (hash_report_level >= 2) {
1255 printf("Read hash collision report -- collisions per cell %lf, collisions %d cells %d\n",(double)read_hash_collisions/(double)hash_queries,read_hash_collisions,hash_queries);
1256 hash_queries = 0;
1257 read_hash_collisions = 0;
1258 }
1259}
1260
1261void final_hash_collision_report(void){
1262 if (hash_report_level >= 1 && read_hash_collisions_count > 0) {
1263 printf("Final hash collision report -- write/read collisions per cell %lf/%lf\n",write_hash_collisions_runsum/(double)write_hash_collisions_count,read_hash_collisions_runsum/(double)read_hash_collisions_count);
1264 }
1265}
1266
simplehash/simplehash.h +140 -0
……@@ -0,0 +1,140 @@
1/* Copyright 2013-14. Los Alamos National Security, LLC. This material was produced
2 * under U.S. Government contract DE-AC52-06NA25396 for Los Alamos National
3 * Laboratory (LANL), which is operated by Los Alamos National Security, LLC
4 * for the U.S. Department of Energy. The U.S. Government has rights to use,
5 * reproduce, and distribute this software. NEITHER THE GOVERNMENT NOR LOS
6 * ALAMOS NATIONAL SECURITY, LLC MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR
7 * ASSUMES ANY LIABILITY FOR THE USE OF THIS SOFTWARE. If software is modified
8 * to produce derivative works, such modified software should be clearly marked,
9 * so as not to confuse it with the version available from LANL.
10 *
11 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
12 * use this file except in compliance with the License. You may obtain a copy
13 * of the License at
14 *
15 * http://www.apache.org/licenses/LICENSE-2.0
16 *
17 * Unless required by applicable law or agreed to in writing, software distributed
18 * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
19 * CONDITIONS OF ANY KIND, either express or implied. See the License for the
20 * specific language governing permissions and limitations under the License.
21 *
22 * Under this license, it is required to include a reference to this work. We
23 * request that each derivative work contain a reference to LANL Copyright
24 * Disclosure C14043/LA-CC-14-003 so that this work's impact can be roughly
25 * measured. In addition, it is requested that a modifier is included as in
26 * the following example:
27 *
28 * //<Uses | improves on | modified from> LANL Copyright Disclosure C14043/LA-CC-14-003
29 *
30 * This is LANL Copyright Disclosure C14043/LA-CC-14-003
31 */
32
33#ifndef _HASH_H
34#define _HASH_H
35
36#include <stdio.h>
37#include <stdlib.h>
38
39#ifdef __cplusplus
40extern "C"
41{
42#endif
43
44typedef unsigned int uint;
45typedef unsigned long ulong;
46
47int *compact_hash_init(int ncells, uint isize, uint jsize, uint report_level);
48
49#ifdef _OPENMP
50 #ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
51 int *compact_hash_init_openmp(int ncells, uint isize, uint jsize, uint report_level);
52 #else
53 int *compact_hash_init_openmp(int ncells, uint isize, uint jsize, uint report_level, omp_lock_t **lock);
54 #endif
55#endif
56
57int get_hash_method(void);
58long long get_hash_table_size(void);
59
60void write_hash_perfect(uint ic, ulong hashkey, int *hash);
61void write_hash_linear(uint ic, ulong hashkey, int *hash);
62void write_hash_linear_report_level_1(uint ic, ulong hashkey, int *hash);
63void write_hash_linear_report_level_2(uint ic, ulong hashkey, int *hash);
64void write_hash_linear_report_level_3(uint ic, ulong hashkey, int *hash);
65void write_hash_quadratic(uint ic, ulong hashkey, int *hash);
66void write_hash_quadratic_report_level_1(uint ic, ulong hashkey, int *hash);
67void write_hash_quadratic_report_level_2(uint ic, ulong hashkey, int *hash);
68void write_hash_quadratic_report_level_3(uint ic, ulong hashkey, int *hash);
69void write_hash_primejump(uint ic, ulong hashkey, int *hash);
70void write_hash_primejump_report_level_1(uint ic, ulong hashkey, int *hash);
71void write_hash_primejump_report_level_2(uint ic, ulong hashkey, int *hash);
72void write_hash_primejump_report_level_3(uint ic, ulong hashkey, int *hash);
73extern void (*write_hash)(uint ic, ulong hashkey, int *hash); // declared in hash.c
74
75#ifdef _OPENMP
76 #ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
77 void write_hash_perfect_openmp(uint ic, ulong hashkey, int *hash);
78 void write_hash_linear_openmp(uint ic, ulong hashkey, int *hash);
79 void write_hash_linear_openmp_report_level_1(uint ic, ulong hashkey, int *hash);
80 void write_hash_linear_openmp_report_level_2(uint ic, ulong hashkey, int *hash);
81 void write_hash_linear_openmp_report_level_3(uint ic, ulong hashkey, int *hash);
82 void write_hash_quadratic_openmp(uint ic, ulong hashkey, int *hash);
83 void write_hash_quadratic_openmp_report_level_1(uint ic, ulong hashkey, int *hash);
84 void write_hash_quadratic_openmp_report_level_2(uint ic, ulong hashkey, int *hash);
85 void write_hash_quadratic_openmp_report_level_3(uint ic, ulong hashkey, int *hash);
86 void write_hash_primejump_openmp(uint ic, ulong hashkey, int *hash);
87 void write_hash_primejump_openmp_report_level_1(uint ic, ulong hashkey, int *hash);
88 void write_hash_primejump_openmp_report_level_2(uint ic, ulong hashkey, int *hash);
89 void write_hash_primejump_openmp_report_level_3(uint ic, ulong hashkey, int *hash);
90 extern void (*write_hash_openmp)(uint ic, ulong hashkey, int *hash); // declared in hash.c
91 #else
92 void write_hash_perfect_openmp(uint ic, ulong hashkey, int *hash, omp_lock_t *lock);
93 void write_hash_linear_openmp(uint ic, ulong hashkey, int *hash, omp_lock_t *lock);
94 void write_hash_linear_openmp_report_level_1(uint ic, ulong hashkey, int *hash, omp_lock_t *lock);
95 void write_hash_linear_openmp_report_level_2(uint ic, ulong hashkey, int *hash, omp_lock_t *lock);
96 void write_hash_linear_openmp_report_level_3(uint ic, ulong hashkey, int *hash, omp_lock_t *lock);
97 void write_hash_quadratic_openmp(uint ic, ulong hashkey, int *hash, omp_lock_t *lock);
98 void write_hash_quadratic_openmp_report_level_1(uint ic, ulong hashkey, int *hash, omp_lock_t *lock);
99 void write_hash_quadratic_openmp_report_level_2(uint ic, ulong hashkey, int *hash, omp_lock_t *lock);
100 void write_hash_quadratic_openmp_report_level_3(uint ic, ulong hashkey, int *hash, omp_lock_t *lock);
101 void write_hash_primejump_openmp(uint ic, ulong hashkey, int *hash, omp_lock_t *lock);
102 void write_hash_primejump_openmp_report_level_1(uint ic, ulong hashkey, int *hash, omp_lock_t *lock);
103 void write_hash_primejump_openmp_report_level_2(uint ic, ulong hashkey, int *hash, omp_lock_t *lock);
104 void write_hash_primejump_openmp_report_level_3(uint ic, ulong hashkey, int *hash, omp_lock_t *lock);
105 extern void (*write_hash_openmp)(uint ic, ulong hashkey, int *hash, omp_lock_t *lock); // declared in hash.c
106 #endif
107#endif
108
109int read_hash_perfect(ulong hashkey, int *hash);
110int read_hash_linear(ulong hashkey, int *hash);
111int read_hash_linear_report_level_1(ulong hashkey, int *hash);
112int read_hash_linear_report_level_2(ulong hashkey, int *hash);
113int read_hash_linear_report_level_3(ulong hashkey, int *hash);
114int read_hash_quadratic(ulong hashkey, int *hash);
115int read_hash_quadratic_report_level_1(ulong hashkey, int *hash);
116int read_hash_quadratic_report_level_2(ulong hashkey, int *hash);
117int read_hash_quadratic_report_level_3(ulong hashkey, int *hash);
118int read_hash_primejump(ulong hashkey, int *hash);
119int read_hash_primejump_report_level_1(ulong hashkey, int *hash);
120int read_hash_primejump_report_level_2(ulong hashkey, int *hash);
121int read_hash_primejump_report_level_3(ulong hashkey, int *hash);
122extern int (*read_hash)(ulong hashkey, int *hash); // declared in hash.c
123
124void compact_hash_delete(int *hash);
125#ifdef _OPENMP
126 #ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
127 void compact_hash_delete_openmp(int *hash);
128 #else
129 void compact_hash_delete_openmp(int *hash, omp_lock_t *lock);
130 #endif
131#endif
132
133void read_hash_collision_report(void);
134void final_hash_collision_report(void);
135
136#ifdef __cplusplus
137}
138#endif
139
140#endif // _HASH_H
simplehash/simplehash_kern.cl +181 -0
……@@ -0,0 +1,181 @@
1/* Copyright 2013-14. Los Alamos National Security, LLC. This material was produced
2 * under U.S. Government contract DE-AC52-06NA25396 for Los Alamos National
3 * Laboratory (LANL), which is operated by Los Alamos National Security, LLC
4 * for the U.S. Department of Energy. The U.S. Government has rights to use,
5 * reproduce, and distribute this software. NEITHER THE GOVERNMENT NOR LOS
6 * ALAMOS NATIONAL SECURITY, LLC MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR
7 * ASSUMES ANY LIABILITY FOR THE USE OF THIS SOFTWARE. If software is modified
8 * to produce derivative works, such modified software should be clearly marked,
9 * so as not to confuse it with the version available from LANL.
10 *
11 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
12 * use this file except in compliance with the License. You may obtain a copy
13 * of the License at
14 *
15 * http://www.apache.org/licenses/LICENSE-2.0
16 *
17 * Unless required by applicable law or agreed to in writing, software distributed
18 * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
19 * CONDITIONS OF ANY KIND, either express or implied. See the License for the
20 * specific language governing permissions and limitations under the License.
21 *
22 * Under this license, it is required to include a reference to this work. We
23 * request that each derivative work contain a reference to LANL Copyright
24 * Disclosure C14043/LA-CC-14-003 so that this work's impact can be roughly
25 * measured. In addition, it is requested that a modifier is included as in
26 * the following example:
27 *
28 * //<Uses | improves on | modified from> LANL Copyright Disclosure C14043/LA-CC-14-003
29 *
30 * This is LANL Copyright Disclosure C14043/LA-CC-14-003
31 */
32
33/*
34 * Authors: Bob Robey XCP-2 brobey@lanl.gov
35 * Peter Ahrens peter.ahrens@lanl.gov, ptrahrens@gmail.com
36 * Sara Hartse sara@lanl.gov, sara.hartse@gmail.com
37 * Rebecka Tumblin rtumblin@lanl.gov, rebeckatumblin@gmail.com
38 */
39
40/* neigh2d_kern.cl */
41
42void write_hash(
43 const int hash_method,
44 const ulong hash_table_size,
45 const ulong AA,
46 const ulong BB,
47 const uint giX,
48 const ulong hashkey,
49 __global int *hash);
50int read_hash(
51 const int hash_method,
52 const ulong hash_table_size,
53 const ulong AA,
54 const ulong BB,
55 const ulong hashkey,
56 __global const int *hash);
57
58#ifndef __HAVE_CL_DOUBLE_DEFINED__
59#define __HAVE_CL_DOUBLE_DEFINED__
60
61#ifdef HAVE_CL_DOUBLE
62#pragma OPENCL EXTENSION cl_khr_fp64 : enable
63typedef double real;
64#else
65typedef float real;
66#endif
67
68#endif
69
70__constant ulong prime = 4294967291;
71__constant uint hash_jump_prime = 41;
72
73void write_hash(
74 const int hash_method,
75 const ulong hash_table_size,
76 const ulong AA,
77 const ulong BB,
78 const uint giX,
79 const ulong hashkey,
80 __global int *hash)
81{
82 uint hashloc;
83 int icount = 0;
84 uint jump;
85 int old_key;
86 int MaxTries = 1000;
87#ifndef __APPLE_CC__
88 switch (hash_method) {
89 case -1:
90#endif
91 hash[hashkey] = giX;
92#ifndef __APPLE_CC__
93 break;
94 case 0:
95 hashloc = (hashkey*AA+BB)%prime%hash_table_size;
96 old_key = atomic_cmpxchg(&hash[2*hashloc],-1,hashkey);
97
98 for (int icount = 1; old_key != (int)hashkey && old_key != -1 && icount < MaxTries; icount++){
99 hashloc++;
100 hashloc %= hash_table_size;
101
102 old_key = atomic_cmpxchg(&hash[2*hashloc],-1,hashkey);
103 }
104
105 if (icount < MaxTries) hash[2*hashloc+1] = giX;
106 break;
107 case 1:
108 hashloc = (hashkey*AA+BB)%prime%hash_table_size;
109 old_key = atomic_cmpxchg(&hash[2*hashloc],-1,hashkey);
110
111 for (int icount = 1; old_key != (int)hashkey && old_key != -1 && icount < MaxTries; icount++){
112 hashloc+=(icount*icount);
113 hashloc %= hash_table_size;
114
115 old_key = atomic_cmpxchg(&hash[2*hashloc],-1,hashkey);
116 }
117
118 if (icount < MaxTries) hash[2*hashloc+1] = giX;
119 break;
120 case 2:
121 jump = 1+hashkey%hash_jump_prime;
122 hashloc = (hashkey*AA+BB)%prime%hash_table_size;
123 old_key = atomic_cmpxchg(&hash[2*hashloc],-1,hashkey);
124
125 for (int icount = 1; old_key != (int)hashkey && old_key != -1 && icount < MaxTries; icount++){
126 hashloc += (icount*jump);
127 hashloc %= hash_table_size;
128
129 old_key = atomic_cmpxchg(&hash[2*hashloc],-1,hashkey);
130 }
131
132 if (icount < MaxTries) hash[2*hashloc+1] = giX;
133 break;
134 }
135#endif
136}
137
138int read_hash(
139 const int hash_method,
140 const ulong hash_table_size,
141 const ulong AA,
142 const ulong BB,
143 const ulong hashkey,
144 __global const int *hash)
145{
146 int hashval = -1;
147 uint hashloc;
148 int icount = 0;
149 uint jump;
150
151#ifndef __APPLE_CC__
152 switch (hash_method) {
153 case -1:
154#endif
155 return(hash[hashkey]);
156#ifndef __APPLE_CC__
157 break;
158 case 0:
159 for (hashloc = (hashkey*AA+BB)%prime%hash_table_size; hash[2*hashloc] != (int)hashkey && hash[2*hashloc] != -1; hashloc++,hashloc %= hash_table_size);
160 if (hash[2*hashloc] != -1) hashval = hash[2*hashloc+1];
161 return(hashval);
162 break;
163 case 1:
164 for (hashloc = (hashkey*AA+BB)%prime%hash_table_size; hash[2*hashloc] != (int)hashkey && hash[2*hashloc] != -1; hashloc+=(icount*icount),hashloc %= hash_table_size){
165 icount++;
166 }
167 if (hash[2*hashloc] != -1) hashval = hash[2*hashloc+1];
168 return(hashval);
169 break;
170 case 2:
171 jump = 1+hashkey%hash_jump_prime;
172 for (hashloc = (hashkey*AA+BB)%prime%hash_table_size; hash[2*hashloc] != (int)hashkey && hash[2*hashloc] != -1; hashloc+=(icount*jump),hashloc %= hash_table_size){
173 icount++;
174 }
175 if (hash[2*hashloc] != -1) hashval = hash[2*hashloc+1];
176 return(hashval);
177 break;
178 }
179#endif
180 return(hashval);
181}
simplehash/simplehashlib.c +156 -0
……@@ -0,0 +1,156 @@
1/* Copyright 2013-14. Los Alamos National Security, LLC. This material was produced
2 * under U.S. Government contract DE-AC52-06NA25396 for Los Alamos National
3 * Laboratory (LANL), which is operated by Los Alamos National Security, LLC
4 * for the U.S. Department of Energy. The U.S. Government has rights to use,
5 * reproduce, and distribute this software. NEITHER THE GOVERNMENT NOR LOS
6 * ALAMOS NATIONAL SECURITY, LLC MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR
7 * ASSUMES ANY LIABILITY FOR THE USE OF THIS SOFTWARE. If software is modified
8 * to produce derivative works, such modified software should be clearly marked,
9 * so as not to confuse it with the version available from LANL.
10 *
11 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
12 * use this file except in compliance with the License. You may obtain a copy
13 * of the License at
14 *
15 * http://www.apache.org/licenses/LICENSE-2.0
16 *
17 * Unless required by applicable law or agreed to in writing, software distributed
18 * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
19 * CONDITIONS OF ANY KIND, either express or implied. See the License for the
20 * specific language governing permissions and limitations under the License.
21 *
22 * Under this license, it is required to include a reference to this work. We
23 * request that each derivative work contain a reference to LANL Copyright
24 * Disclosure C14043/LA-CC-14-003 so that this work's impact can be roughly
25 * measured. In addition, it is requested that a modifier is included as in
26 * the following example:
27 *
28 * //<Uses | improves on | modified from> LANL Copyright Disclosure C14043/LA-CC-14-003
29 *
30 * This is LANL Copyright Disclosure C14043/LA-CC-14-003
31 */
32
33#include <stdlib.h>
34//#ifdef HAVE_CONFIG_H
35//#include "config.h"
36//#endif
37#include "simplehashlib.h"
38#include "simplehashlib_kern.inc"
39#include "simplehash_kern.inc"
40
41static int reportLevel = 0;
42
43char *get_hash_kernel_source_string(void){
44 return (char*) simplehash_kern_source;
45}
46
47#ifdef HAVE_OPENCL
48cl_kernel init_kernel;
49void hash_lib_init(cl_context context){
50
51 cl_int error;
52
53 cl_program program = clCreateProgramWithSource(context, 1, (const char **)&simplehashlib_kern_source, NULL, &error);
54 if (error != CL_SUCCESS){
55 printf("clCreateProgramWithSource returned an error %d at line %d in file %s\n", error,__LINE__,__FILE__);
56 }
57
58 size_t nReportSize;
59 char* BuildReport;
60 #ifdef HAVE_CL_DOUBLE
61 error = clBuildProgram(program, 0, NULL, "-DHAVE_CL_DOUBLE", NULL, NULL);
62 #else
63 error = clBuildProgram(program, 0, NULL, "-DNO_CL_DOUBLE -cl-single-precision-constant", NULL, NULL);
64 #endif
65 if (error != CL_SUCCESS){
66 printf("clBuildProgram returned an error %d at line %d in file %s\n", error,__LINE__,__FILE__);
67
68 cl_device_id device;
69
70 clGetContextInfo(context, CL_CONTEXT_DEVICES, 1, &device, NULL);
71 if (context == NULL){
72 printf("EZCL_DEVTYPE_INIT: Failed to find device and setup context in file %s at line %d\n", __FILE__, __LINE__);
73 exit(-1); // No device is available, something is wrong
74 }
75
76 error = clGetProgramBuildInfo(program, device, CL_PROGRAM_BUILD_LOG, 0, NULL, &nReportSize);
77 if (error != CL_SUCCESS) {
78 switch (error){
79 case CL_INVALID_DEVICE:
80 printf("Invalid device in clProgramBuildInfo\n");
81 break;
82 case CL_INVALID_VALUE:
83 printf("Invalid value in clProgramBuildInfo\n");
84 break;
85 case CL_INVALID_PROGRAM:
86 printf("Invalid program in clProgramBuildInfo\n");
87 break;
88 }
89 }
90
91 BuildReport = (char *)malloc(nReportSize);
92
93 error = clGetProgramBuildInfo(program, device, CL_PROGRAM_BUILD_LOG, nReportSize, BuildReport, NULL);
94 if (error != CL_SUCCESS) {
95 switch (error){
96 case CL_INVALID_DEVICE:
97 printf("Invalid device in clProgramBuildInfo\n");
98 break;
99 case CL_INVALID_VALUE:
100 printf("Invalid value in clProgramBuildInfo\n");
101 break;
102 case CL_INVALID_PROGRAM:
103 printf("Invalid program in clProgramBuildInfo\n");
104 break;
105 }
106 }
107 printf("%s\n", BuildReport);
108 }
109
110
111 init_kernel = clCreateKernel(program, "init_kern", &error);
112 if (error != CL_SUCCESS) printf("Error is %d at line %d\n",error,__LINE__);
113}
114
115cl_mem hash_init (int hash_size, int TILE_SIZE, cl_context context, cl_command_queue queue, long *gpu_time)
116{
117 cl_int error;
118
119 long gpu_time_start, gpu_time_end;
120
121 cl_mem hash_buffer = clCreateBuffer(context, CL_MEM_READ_WRITE, hash_size*sizeof(int), NULL, &error);
122 if (error != CL_SUCCESS) printf("Error is %d at line %d\n",error,__LINE__);
123
124 //init to -1
125
126 error = clSetKernelArg(init_kernel, 0, sizeof(cl_uint), &hash_size);
127 if (error != CL_SUCCESS) printf("Error is %d at line %d\n",error,__LINE__);
128 error = clSetKernelArg(init_kernel, 1, sizeof(cl_mem), (void*)&hash_buffer);
129 if (error != CL_SUCCESS) printf("Error is %d at line %d\n",error,__LINE__);
130
131 size_t global_work_size;
132 size_t local_work_size;
133
134 local_work_size = TILE_SIZE;
135 global_work_size = ((hash_size+local_work_size-1)/local_work_size)*local_work_size;
136
137 cl_event hash_init_event;
138
139 error = clEnqueueNDRangeKernel(queue, init_kernel, 1, 0, &global_work_size, &local_work_size, 0, NULL, &hash_init_event);
140 if (error != CL_SUCCESS) printf("Error is %d at line %d\n",error,__LINE__);
141
142 clWaitForEvents(1,&hash_init_event);
143
144 clGetEventProfilingInfo(hash_init_event, CL_PROFILING_COMMAND_START, sizeof(gpu_time_start), &gpu_time_start, NULL);
145 clGetEventProfilingInfo(hash_init_event, CL_PROFILING_COMMAND_END, sizeof(gpu_time_end), &gpu_time_end, NULL);
146
147
148 *gpu_time = gpu_time_end - gpu_time_start;
149
150 clReleaseEvent(hash_init_event);
151
152 //if (DETAILED_TIMING) printf("\n\tinit %.6lf,", (double)(gpu_time_end - gpu_time_start)*1.0e-9);
153
154 return(hash_buffer);
155}
156#endif
simplehash/simplehashlib.h +50 -0
……@@ -0,0 +1,50 @@
1/* Copyright 2013-14. Los Alamos National Security, LLC. This material was produced
2 * under U.S. Government contract DE-AC52-06NA25396 for Los Alamos National
3 * Laboratory (LANL), which is operated by Los Alamos National Security, LLC
4 * for the U.S. Department of Energy. The U.S. Government has rights to use,
5 * reproduce, and distribute this software. NEITHER THE GOVERNMENT NOR LOS
6 * ALAMOS NATIONAL SECURITY, LLC MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR
7 * ASSUMES ANY LIABILITY FOR THE USE OF THIS SOFTWARE. If software is modified
8 * to produce derivative works, such modified software should be clearly marked,
9 * so as not to confuse it with the version available from LANL.
10 *
11 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
12 * use this file except in compliance with the License. You may obtain a copy
13 * of the License at
14 *
15 * http://www.apache.org/licenses/LICENSE-2.0
16 *
17 * Unless required by applicable law or agreed to in writing, software distributed
18 * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
19 * CONDITIONS OF ANY KIND, either express or implied. See the License for the
20 * specific language governing permissions and limitations under the License.
21 *
22 * Under this license, it is required to include a reference to this work. We
23 * request that each derivative work contain a reference to LANL Copyright
24 * Disclosure C14043/LA-CC-14-003 so that this work's impact can be roughly
25 * measured. In addition, it is requested that a modifier is included as in
26 * the following example:
27 *
28 * //<Uses | improves on | modified from> LANL Copyright Disclosure C14043/LA-CC-14-003
29 *
30 * This is LANL Copyright Disclosure C14043/LA-CC-14-003
31 */
32
33#include <stdio.h>
34//#ifdef HAVE_CONFIG_H
35//#include "config.h"
36//#endif
37
38#ifdef HAVE_OPENCL
39#ifdef __APPLE_CC__
40#include <OpenCL/OpenCL.h>
41#else
42#include <CL/cl.h>
43#endif
44#endif
45
46char *get_hash_kernel_source_string();
47#ifdef HAVE_OPENCL
48void hash_lib_init(cl_context context);
49cl_mem hash_init (int hash_size, int TILE_SIZE, cl_context context, cl_command_queue queue, long *gpu_time);
50#endif
simplehash/simplehashlib_kern.cl +65 -0
……@@ -0,0 +1,65 @@
1/* Copyright 2013-14. Los Alamos National Security, LLC. This material was produced
2 * under U.S. Government contract DE-AC52-06NA25396 for Los Alamos National
3 * Laboratory (LANL), which is operated by Los Alamos National Security, LLC
4 * for the U.S. Department of Energy. The U.S. Government has rights to use,
5 * reproduce, and distribute this software. NEITHER THE GOVERNMENT NOR LOS
6 * ALAMOS NATIONAL SECURITY, LLC MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR
7 * ASSUMES ANY LIABILITY FOR THE USE OF THIS SOFTWARE. If software is modified
8 * to produce derivative works, such modified software should be clearly marked,
9 * so as not to confuse it with the version available from LANL.
10 *
11 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
12 * use this file except in compliance with the License. You may obtain a copy
13 * of the License at
14 *
15 * http://www.apache.org/licenses/LICENSE-2.0
16 *
17 * Unless required by applicable law or agreed to in writing, software distributed
18 * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
19 * CONDITIONS OF ANY KIND, either express or implied. See the License for the
20 * specific language governing permissions and limitations under the License.
21 *
22 * Under this license, it is required to include a reference to this work. We
23 * request that each derivative work contain a reference to LANL Copyright
24 * Disclosure C14043/LA-CC-14-003 so that this work's impact can be roughly
25 * measured. In addition, it is requested that a modifier is included as in
26 * the following example:
27 *
28 * //<Uses | improves on | modified from> LANL Copyright Disclosure C14043/LA-CC-14-003
29 *
30 * This is LANL Copyright Disclosure C14043/LA-CC-14-003
31 */
32
33/*
34 * Authors: Bob Robey XCP-2 brobey@lanl.gov
35 * Peter Ahrens peter.ahrens@lanl.gov, ptrahrens@gmail.com
36 * Sara Hartse sara@lanl.gov, sara.hartse@gmail.com
37 * Rebecka Tumblin rtumblin@lanl.gov, rebeckatumblin@gmail.com
38 */
39
40/* neigh2d_kern.cl */
41
42#ifndef __HAVE_CL_DOUBLE_DEFINED__
43#define __HAVE_CL_DOUBLE_DEFINED__
44
45#ifdef HAVE_CL_DOUBLE
46#pragma OPENCL EXTENSION cl_khr_fp64 : enable
47typedef double real;
48#else
49typedef float real;
50#endif
51
52#endif
53
54
55__kernel void init_kern(
56 const uint size,
57 __global int *temp) {
58
59 const uint idx = get_global_id(0);
60
61 if (idx >= size) return;
62
63 temp[idx] = -1;
64}
65