Disabled external gits
This commit is contained in:
343
cs440-acg/ext/tbb/examples/task_group/index.html
Normal file
343
cs440-acg/ext/tbb/examples/task_group/index.html
Normal file
@@ -0,0 +1,343 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:mso="urn:schemas-microsoft-com:office:office" xmlns:msdt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<style>
|
||||
::selection {
|
||||
background: #b7ffb7;
|
||||
}
|
||||
::-moz-selection {
|
||||
background: #b7ffb7;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
font-size: 16px;
|
||||
width: 800px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
#banner {
|
||||
/* Div for banner */
|
||||
float:left;
|
||||
margin: 0px;
|
||||
margin-bottom: 10px;
|
||||
width: 100%;
|
||||
background-color: #0071C5;
|
||||
z-index: 0;
|
||||
}
|
||||
#banner .logo {
|
||||
/* Apply to logo in banner. Add as class to image tag. */
|
||||
float: left;
|
||||
margin-right: 20px;
|
||||
margin-left: 20px;
|
||||
margin-top: 15px;
|
||||
padding-bottom: 5px;
|
||||
}
|
||||
h1 {
|
||||
text-align: center;
|
||||
font-size: 36px;
|
||||
}
|
||||
h1.title {
|
||||
/* Add as class to H1 in banner */
|
||||
font-family: "Intel Clear", Verdana, Arial, sans-serif;
|
||||
font-weight:normal;
|
||||
color: #FFFFFF;
|
||||
font-size: 170%;
|
||||
margin-right: 40px;
|
||||
margin-left: 40px;
|
||||
padding-right: 20px;
|
||||
text-indent: 20px;
|
||||
}
|
||||
.h3-alike {
|
||||
display:inline;
|
||||
font-size: 1.17em;
|
||||
font-weight: bold;
|
||||
color: #0071C5;
|
||||
}
|
||||
h3 {
|
||||
font-size: 1.17em;
|
||||
font-weight: bold;
|
||||
color: #0071C5;
|
||||
}
|
||||
.h4-alike {
|
||||
display:inline;
|
||||
font-size: 1.05em;
|
||||
font-weight: bold;
|
||||
}
|
||||
pre {
|
||||
font-family: "Consolas", Monaco, monospace;
|
||||
font-size:small;
|
||||
background: #fafafa;
|
||||
margin: 0;
|
||||
padding-left:20px;
|
||||
}
|
||||
#footer {
|
||||
font-size: small;
|
||||
}
|
||||
code {
|
||||
font-family: "Consolas", Monaco, monospace;
|
||||
}
|
||||
.code-block
|
||||
{
|
||||
padding-left:20px;
|
||||
}
|
||||
.changes {
|
||||
margin: 1em 0;
|
||||
}
|
||||
.changes input:active {
|
||||
position: relative;
|
||||
top: 1px;
|
||||
}
|
||||
.changes input:hover:after {
|
||||
padding-left: 16px;
|
||||
font-size: 10px;
|
||||
content: 'More';
|
||||
}
|
||||
.changes input:checked:hover:after {
|
||||
content: 'Less';
|
||||
}
|
||||
.changes input + .show-hide {
|
||||
display: none;
|
||||
}
|
||||
.changes input:checked + .show-hide {
|
||||
display: block;
|
||||
}
|
||||
|
||||
ul {
|
||||
margin: 0;
|
||||
padding: 0.5em 0 0.5em 2.5em;
|
||||
}
|
||||
ul li {
|
||||
margin-bottom: 3px;
|
||||
}
|
||||
ul li:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.disc {
|
||||
list-style-type:disc
|
||||
}
|
||||
.circ {
|
||||
list-style-type:circle
|
||||
}
|
||||
|
||||
.single {
|
||||
padding: 0 0.5em;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------- */
|
||||
/* Table styles */
|
||||
table{
|
||||
margin-bottom:5pt;
|
||||
border-collapse:collapse;
|
||||
margin-left:0px;
|
||||
margin-top:0.3em;
|
||||
font-size:10pt;
|
||||
}
|
||||
tr{
|
||||
vertical-align:top;
|
||||
}
|
||||
th,
|
||||
th h3{
|
||||
padding:4px;
|
||||
text-align:left;
|
||||
background-color:#0071C5;
|
||||
font-weight:bold;
|
||||
margin-top:1px;
|
||||
margin-bottom:0;
|
||||
color:#FFFFFF;
|
||||
font-size:10pt;
|
||||
vertical-align:middle;
|
||||
}
|
||||
th{
|
||||
border:1px #dddddd solid;
|
||||
padding-top:2px;
|
||||
padding-bottom:0px;
|
||||
padding-right:3px;
|
||||
padding-left:3px;
|
||||
}
|
||||
td{
|
||||
border:1px #dddddd solid;
|
||||
vertical-align:top;
|
||||
font-size:100%;
|
||||
text-align:left;
|
||||
margin-bottom:0;
|
||||
}
|
||||
td,
|
||||
td p{
|
||||
margin-top:0;
|
||||
margin-left:0;
|
||||
text-align:left;
|
||||
font-size:inherit;
|
||||
line-height:120%;
|
||||
}
|
||||
td p{
|
||||
margin-bottom:0;
|
||||
padding-top:5px;
|
||||
padding-bottom:5px;
|
||||
padding-right:5px;
|
||||
padding-left:1px;
|
||||
}
|
||||
.noborder{
|
||||
border:0px none;
|
||||
}
|
||||
.noborder1stcol{
|
||||
border:0px none;
|
||||
padding-left:0pt;
|
||||
}
|
||||
td ol{
|
||||
font-size:inherit;
|
||||
margin-left:28px;
|
||||
}
|
||||
td ul{
|
||||
font-size:inherit;
|
||||
margin-left:24px;
|
||||
}
|
||||
.DefListTbl{
|
||||
width:90%;
|
||||
margin-left:-3pt;
|
||||
}
|
||||
.syntaxdiagramtbl{
|
||||
margin-left:-3pt;
|
||||
}
|
||||
.sdtbl{
|
||||
}
|
||||
.sdrow{
|
||||
}
|
||||
.sdtblp{
|
||||
border:0px none;
|
||||
font-size:inherit;
|
||||
line-height:120%;
|
||||
margin-bottom:0;
|
||||
padding-bottom:0px;
|
||||
padding-top:5px;
|
||||
padding-left:0px;
|
||||
padding-right:5px;
|
||||
vertical-align:top;
|
||||
}
|
||||
.idepara, .ide_para{
|
||||
border:0px none;
|
||||
font-size:inherit;
|
||||
line-height:120%;
|
||||
margin-bottom:0;
|
||||
padding-bottom:0px;
|
||||
padding-top:5px;
|
||||
padding-left:0px;
|
||||
padding-right:5px;
|
||||
vertical-align:top;
|
||||
}
|
||||
|
||||
.specs {
|
||||
border-collapse:collapse;
|
||||
}
|
||||
.specs td, .specs th {
|
||||
font-size: 14px;
|
||||
}
|
||||
.specs td {
|
||||
border: 1px solid black;
|
||||
}
|
||||
.specs td td, .specs td th {
|
||||
border: none;
|
||||
}
|
||||
.specs td, .specs td td, .specs td th {
|
||||
padding: 0 0.2em 0.2em;
|
||||
text-align: center;
|
||||
}
|
||||
.specs td tr:last-child td,
|
||||
.specs td tr:last-child th {
|
||||
padding: 0 0.2em;
|
||||
}
|
||||
.serial-time {
|
||||
}
|
||||
.modified-time {
|
||||
width: 6.5em;
|
||||
}
|
||||
.compiler {
|
||||
}
|
||||
.comp-opt {
|
||||
}
|
||||
.sys-specs {
|
||||
width: 18em;
|
||||
}
|
||||
.note {
|
||||
font-size:small;
|
||||
font-style: italic;
|
||||
}
|
||||
</style>
|
||||
<title>Intel® Threading Building Blocks. Samples on task_group interface</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="banner">
|
||||
<img class="logo" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEMAAAAsCAYAAAA+aAX8AAAAAXNSR0IArs4c6QAAAARnQU1BAACx
|
||||
jwv8YQUAAAAJcEhZcwAALiIAAC4iAari3ZIAAAAZdEVYdFNvZnR3YXJlAEFkb2JlIEltYWdlUmVh
|
||||
ZHlxyWU8AAAIN0lEQVRoQ+WaCaxdUxSGW2ouatZWaVS15nkqkZhSVERQglLEPCam1BCixhqqCKUS
|
||||
NIiYpxhqHmouIeaY5ylFzA/v1fev8+/j3N5737v3vtf3buNP/uy9/7X2Ovuse4a997m9mgltbW2L
|
||||
wRHwcHgFfAx+AH+GCb/BT2fNmvUk5ZXwYOrrOsTcCU5CJ74pPBJeA5+Bn8LfOLmagf/f8Af4NrwD
|
||||
ngg3wdTHh2pOMMB1Gejx8AE4M85mNqD/A7+D78GXkXQFTIMPwUfhdPg6/AxWTRw29b8QruPD9zwY
|
||||
zPrwHPi2xxmg3QrfgDfD05BGU24EB1HvC3s7REXgtwDsDzeEY+Ak+AJsUfwE2sJdcBN37V4whiU4
|
||||
+KGUM2JEBtpzUInZEa5g9y4FcYfAo+GLPmwOND2HFrXrnAUHW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XBd2TtyKNhUOp1/dprgMQ
|
||||
rx9x16fcn1KbttrIyf9OkICWw1KApvY2YyXbpSBobKf7OGXApFtI+5d3Qq1BDoL6V87GcDVc9Ivq
|
||||
E4D+bjTQbc1i9demreDu8Ch0ffG6hdnmDMrvFbsSsAXczIGk3fwb4VYe+pwBB9Angkd83ADtqgkq
|
||||
AjetdTTV1icDlfl+Qi3AP4elHEjaDXscHgFjPdNt4ID6S9B9sNLiKoelmuFuJbCpDJi+hvqz2qFw
|
||||
iIfWc2AQusxPgvq484vH2eUgtpYHH0Hteeqb75ZwMQ+j+cDg9PlwFDwd6o9sr0KtbWI/tSPgp32M
|
||||
76H+s6mNX3030df5neGq1OtbZDUbOIlFoFaha0L9j0qfCHeAerDqVtODU8+hNThZfR1fHHbpG6kx
|
||||
9Or1LzUmVVz+HJXDAAAAAElFTkSuQmCC">
|
||||
<h1 class="title">Intel® Threading Building Blocks<br>Samples on <code>task_group</code> interface</h1>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
This directory has examples of how to use <code>task_group</code> interface.
|
||||
</p>
|
||||
|
||||
<div class="changes">
|
||||
<div class="h3-alike">Directories</div>
|
||||
<input type="checkbox" checked="checked">
|
||||
<div class="show-hide">
|
||||
<dl>
|
||||
<dt><a href="sudoku/readme.html">Sudoku</a>
|
||||
<dd>Compute all solutions for a Sudoku board.
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
<a href="../index.html">Up to parent directory</a>
|
||||
<hr>
|
||||
<div class="changes">
|
||||
<div class="h3-alike">Legal Information:</div>
|
||||
<input type="checkbox">
|
||||
<div class="show-hide">
|
||||
<p>
|
||||
Intel and the Intel logo are trademarks of Intel Corporation in the U.S. and/or other countries.
|
||||
<br>* Other names and brands may be claimed as the property of others.
|
||||
<br>© 2020, Intel Corporation
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@@ -0,0 +1,46 @@
|
||||
# Copyright (c) 2005-2020 Intel Corporation
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# Common Makefile that builds and runs example.
|
||||
|
||||
# Just specify your program basename
|
||||
PROG=sudoku
|
||||
ARGS= 4 input1 verbose
|
||||
PERF_RUN_ARGS=auto input1 silent
|
||||
|
||||
# Trying to find if icl.exe is set
|
||||
CXX1 = $(TBB_CXX)-
|
||||
CXX2 = $(CXX1:icl.exe-=icl.exe)
|
||||
CXX = $(CXX2:-=cl.exe)
|
||||
|
||||
# The C++ compiler options
|
||||
MYCXXFLAGS = /TP /EHsc /W3 /nologo /D _CONSOLE /D _MBCS /D WIN32 /D _CRT_SECURE_NO_DEPRECATE $(CXXFLAGS)
|
||||
MYLDFLAGS =/INCREMENTAL:NO /NOLOGO /DEBUG /FIXED:NO $(LDFLAGS)
|
||||
|
||||
all: release test
|
||||
release:
|
||||
$(CXX) *.cpp /MD /O2 /D NDEBUG $(MYCXXFLAGS) /link tbb.lib $(LIBS) $(MYLDFLAGS) /OUT:$(PROG).exe
|
||||
debug:
|
||||
$(CXX) *.cpp /MDd /Od /Zi /D TBB_USE_DEBUG /D _DEBUG $(MYCXXFLAGS) /link tbb_debug.lib $(LIBS) $(MYLDFLAGS) /OUT:$(PROG).exe
|
||||
clean:
|
||||
@cmd.exe /C del $(PROG).exe *.obj *.?db *.manifest
|
||||
test:
|
||||
$(PROG) $(ARGS)
|
||||
compiler_check:
|
||||
@$(CXX) >nul 2>&1 || echo "$(CXX) command not found. Check if CXX=$(CXX) is set properly"
|
||||
|
||||
perf_build: release
|
||||
|
||||
perf_run:
|
||||
$(PROG) $(PERF_RUN_ARGS)
|
19
cs440-acg/ext/tbb/examples/task_group/sudoku/input1
Normal file
19
cs440-acg/ext/tbb/examples/task_group/sudoku/input1
Normal file
@@ -0,0 +1,19 @@
|
||||
1 0 0 9 0 0 0 8 0 0 8 0 2 0 0 0 0 0 0 0 5 0 0 0 7 0 0 0 5 2 1 0 0 4 0 0 0 0 0 0 0 5 0 0 7 4 0 0 7 0 0 0 3 0 0 3 0 0 0 2 0 0 5 0 0 0 0 0 0 1 0 0 5 0 0 0 1 0 0 0 0
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
1 0 0 9 0 0 0 8 0
|
||||
0 8 0 2 0 0 0 0 0
|
||||
0 0 5 0 0 0 7 0 0
|
||||
|
||||
0 5 2 1 0 0 4 0 0
|
||||
0 0 0 0 0 5 0 0 7
|
||||
4 0 0 7 0 0 0 3 0
|
||||
|
||||
0 3 0 0 0 2 0 0 5
|
||||
0 0 0 0 0 0 1 0 0
|
||||
5 0 0 0 1 0 0 0 0
|
18
cs440-acg/ext/tbb/examples/task_group/sudoku/input2
Normal file
18
cs440-acg/ext/tbb/examples/task_group/sudoku/input2
Normal file
@@ -0,0 +1,18 @@
|
||||
2 0 1 0 0 0 0 8 0 0 8 0 2 1 9 6 0 0 0 0 5 0 0 0 7 0 0 0 5 2 1 0 0 4 0 0 0 0 0 0 0 5 0 0 7 4 0 0 7 0 0 0 3 0 0 3 0 0 0 2 0 0 5 0 0 0 0 3 0 1 0 0 5 0 0 0 8 0 0 0 6
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
2 0 1 0 0 0 0 8 0
|
||||
0 8 0 2 1 9 6 0 0
|
||||
0 0 5 0 0 0 7 0 0
|
||||
|
||||
0 5 2 1 0 0 4 0 0
|
||||
0 0 0 0 0 5 0 0 7
|
||||
4 0 0 7 0 0 0 3 0
|
||||
|
||||
0 3 0 0 0 2 0 0 5
|
||||
0 0 0 0 3 0 1 0 0
|
||||
5 0 0 0 8 0 0 0 6
|
19
cs440-acg/ext/tbb/examples/task_group/sudoku/input3
Normal file
19
cs440-acg/ext/tbb/examples/task_group/sudoku/input3
Normal file
@@ -0,0 +1,19 @@
|
||||
1 0 0 9 0 0 0 8 0 0 0 0 2 0 0 0 0 0 0 0 5 0 0 0 7 0 0 0 5 2 6 0 0 4 0 0 0 0 0 0 0 5 0 0 7 4 0 0 7 0 0 0 3 0 0 3 0 0 0 2 0 0 5 0 0 0 0 0 0 1 0 0 5 0 0 0 1 0 0 0 0
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
1 0 0 9 0 0 0 8 0
|
||||
0 0 0 2 0 0 0 0 0
|
||||
0 0 5 0 0 0 7 0 0
|
||||
|
||||
0 5 2 6 0 0 4 0 0
|
||||
0 0 0 0 0 5 0 0 7
|
||||
4 0 0 7 0 0 0 3 0
|
||||
|
||||
0 3 0 0 0 2 0 0 5
|
||||
0 0 0 0 0 0 1 0 0
|
||||
5 0 0 0 1 0 0 0 0
|
19
cs440-acg/ext/tbb/examples/task_group/sudoku/input4
Normal file
19
cs440-acg/ext/tbb/examples/task_group/sudoku/input4
Normal file
@@ -0,0 +1,19 @@
|
||||
1 0 0 9 0 0 0 8 0 0 0 0 2 0 0 0 0 0 0 0 5 0 0 0 7 0 0 0 0 2 6 0 0 0 0 0 0 0 0 0 0 5 0 0 7 4 0 0 0 0 0 0 3 0 0 3 0 0 0 2 0 0 5 0 0 0 0 0 0 1 0 0 5 0 0 0 1 0 0 0 0
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
1 0 0 9 0 0 0 8 0
|
||||
0 0 0 2 0 0 0 0 0
|
||||
0 0 5 0 0 0 7 0 0
|
||||
|
||||
0 0 2 6 0 0 0 0 0
|
||||
0 0 0 0 0 5 0 0 7
|
||||
4 0 0 0 0 0 0 3 0
|
||||
|
||||
0 3 0 0 0 2 0 0 5
|
||||
0 0 0 0 0 0 1 0 0
|
||||
5 0 0 0 1 0 0 0 0
|
417
cs440-acg/ext/tbb/examples/task_group/sudoku/readme.html
Normal file
417
cs440-acg/ext/tbb/examples/task_group/sudoku/readme.html
Normal file
@@ -0,0 +1,417 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:mso="urn:schemas-microsoft-com:office:office" xmlns:msdt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<style>
|
||||
::selection {
|
||||
background: #b7ffb7;
|
||||
}
|
||||
::-moz-selection {
|
||||
background: #b7ffb7;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
font-size: 16px;
|
||||
width: 800px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
#banner {
|
||||
/* Div for banner */
|
||||
float:left;
|
||||
margin: 0px;
|
||||
margin-bottom: 10px;
|
||||
width: 100%;
|
||||
background-color: #0071C5;
|
||||
z-index: 0;
|
||||
}
|
||||
#banner .logo {
|
||||
/* Apply to logo in banner. Add as class to image tag. */
|
||||
float: left;
|
||||
margin-right: 20px;
|
||||
margin-left: 20px;
|
||||
margin-top: 15px;
|
||||
padding-bottom: 5px;
|
||||
}
|
||||
h1 {
|
||||
text-align: center;
|
||||
font-size: 36px;
|
||||
}
|
||||
h1.title {
|
||||
/* Add as class to H1 in banner */
|
||||
font-family: "Intel Clear", Verdana, Arial, sans-serif;
|
||||
font-weight:normal;
|
||||
color: #FFFFFF;
|
||||
font-size: 170%;
|
||||
margin-right: 40px;
|
||||
margin-left: 40px;
|
||||
padding-right: 20px;
|
||||
text-indent: 20px;
|
||||
}
|
||||
.h3-alike {
|
||||
display:inline;
|
||||
font-size: 1.17em;
|
||||
font-weight: bold;
|
||||
color: #0071C5;
|
||||
}
|
||||
h3 {
|
||||
font-size: 1.17em;
|
||||
font-weight: bold;
|
||||
color: #0071C5;
|
||||
}
|
||||
.h4-alike {
|
||||
display:inline;
|
||||
font-size: 1.05em;
|
||||
font-weight: bold;
|
||||
}
|
||||
pre {
|
||||
font-family: "Consolas", Monaco, monospace;
|
||||
font-size:small;
|
||||
background: #fafafa;
|
||||
margin: 0;
|
||||
padding-left:20px;
|
||||
}
|
||||
#footer {
|
||||
font-size: small;
|
||||
}
|
||||
code {
|
||||
font-family: "Consolas", Monaco, monospace;
|
||||
}
|
||||
.code-block
|
||||
{
|
||||
padding-left:20px;
|
||||
}
|
||||
.changes {
|
||||
margin: 1em 0;
|
||||
}
|
||||
.changes input:active {
|
||||
position: relative;
|
||||
top: 1px;
|
||||
}
|
||||
.changes input:hover:after {
|
||||
padding-left: 16px;
|
||||
font-size: 10px;
|
||||
content: 'More';
|
||||
}
|
||||
.changes input:checked:hover:after {
|
||||
content: 'Less';
|
||||
}
|
||||
.changes input + .show-hide {
|
||||
display: none;
|
||||
}
|
||||
.changes input:checked + .show-hide {
|
||||
display: block;
|
||||
}
|
||||
|
||||
ul {
|
||||
margin: 0;
|
||||
padding: 0.5em 0 0.5em 2.5em;
|
||||
}
|
||||
ul li {
|
||||
margin-bottom: 3px;
|
||||
}
|
||||
ul li:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.disc {
|
||||
list-style-type:disc
|
||||
}
|
||||
.circ {
|
||||
list-style-type:circle
|
||||
}
|
||||
|
||||
.single {
|
||||
padding: 0 0.5em;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------- */
|
||||
/* Table styles */
|
||||
table{
|
||||
margin-bottom:5pt;
|
||||
border-collapse:collapse;
|
||||
margin-left:0px;
|
||||
margin-top:0.3em;
|
||||
font-size:10pt;
|
||||
}
|
||||
tr{
|
||||
vertical-align:top;
|
||||
}
|
||||
th,
|
||||
th h3{
|
||||
padding:4px;
|
||||
text-align:left;
|
||||
background-color:#0071C5;
|
||||
font-weight:bold;
|
||||
margin-top:1px;
|
||||
margin-bottom:0;
|
||||
color:#FFFFFF;
|
||||
font-size:10pt;
|
||||
vertical-align:middle;
|
||||
}
|
||||
th{
|
||||
border:1px #dddddd solid;
|
||||
padding-top:2px;
|
||||
padding-bottom:0px;
|
||||
padding-right:3px;
|
||||
padding-left:3px;
|
||||
}
|
||||
td{
|
||||
border:1px #dddddd solid;
|
||||
vertical-align:top;
|
||||
font-size:100%;
|
||||
text-align:left;
|
||||
margin-bottom:0;
|
||||
}
|
||||
td,
|
||||
td p{
|
||||
margin-top:0;
|
||||
margin-left:0;
|
||||
text-align:left;
|
||||
font-size:inherit;
|
||||
line-height:120%;
|
||||
}
|
||||
td p{
|
||||
margin-bottom:0;
|
||||
padding-top:5px;
|
||||
padding-bottom:5px;
|
||||
padding-right:5px;
|
||||
padding-left:1px;
|
||||
}
|
||||
.noborder{
|
||||
border:0px none;
|
||||
}
|
||||
.noborder1stcol{
|
||||
border:0px none;
|
||||
padding-left:0pt;
|
||||
}
|
||||
td ol{
|
||||
font-size:inherit;
|
||||
margin-left:28px;
|
||||
}
|
||||
td ul{
|
||||
font-size:inherit;
|
||||
margin-left:24px;
|
||||
}
|
||||
.DefListTbl{
|
||||
width:90%;
|
||||
margin-left:-3pt;
|
||||
}
|
||||
.syntaxdiagramtbl{
|
||||
margin-left:-3pt;
|
||||
}
|
||||
.sdtbl{
|
||||
}
|
||||
.sdrow{
|
||||
}
|
||||
.sdtblp{
|
||||
border:0px none;
|
||||
font-size:inherit;
|
||||
line-height:120%;
|
||||
margin-bottom:0;
|
||||
padding-bottom:0px;
|
||||
padding-top:5px;
|
||||
padding-left:0px;
|
||||
padding-right:5px;
|
||||
vertical-align:top;
|
||||
}
|
||||
.idepara, .ide_para{
|
||||
border:0px none;
|
||||
font-size:inherit;
|
||||
line-height:120%;
|
||||
margin-bottom:0;
|
||||
padding-bottom:0px;
|
||||
padding-top:5px;
|
||||
padding-left:0px;
|
||||
padding-right:5px;
|
||||
vertical-align:top;
|
||||
}
|
||||
|
||||
.specs {
|
||||
border-collapse:collapse;
|
||||
}
|
||||
.specs td, .specs th {
|
||||
font-size: 14px;
|
||||
}
|
||||
.specs td {
|
||||
border: 1px solid black;
|
||||
}
|
||||
.specs td td, .specs td th {
|
||||
border: none;
|
||||
}
|
||||
.specs td, .specs td td, .specs td th {
|
||||
padding: 0 0.2em 0.2em;
|
||||
text-align: center;
|
||||
}
|
||||
.specs td tr:last-child td,
|
||||
.specs td tr:last-child th {
|
||||
padding: 0 0.2em;
|
||||
}
|
||||
.serial-time {
|
||||
}
|
||||
.modified-time {
|
||||
width: 6.5em;
|
||||
}
|
||||
.compiler {
|
||||
}
|
||||
.comp-opt {
|
||||
}
|
||||
.sys-specs {
|
||||
width: 18em;
|
||||
}
|
||||
.note {
|
||||
font-size:small;
|
||||
font-style: italic;
|
||||
}
|
||||
</style>
|
||||
<title>Intel® Threading Building Blocks. Sudoku sample</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="banner">
|
||||
<img class="logo" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEMAAAAsCAYAAAA+aAX8AAAAAXNSR0IArs4c6QAAAARnQU1BAACx
|
||||
jwv8YQUAAAAJcEhZcwAALiIAAC4iAari3ZIAAAAZdEVYdFNvZnR3YXJlAEFkb2JlIEltYWdlUmVh
|
||||
ZHlxyWU8AAAIN0lEQVRoQ+WaCaxdUxSGW2ouatZWaVS15nkqkZhSVERQglLEPCam1BCixhqqCKUS
|
||||
NIiYpxhqHmouIeaY5ylFzA/v1fev8+/j3N5737v3vtf3buNP/uy9/7X2Ovuse4a997m9mgltbW2L
|
||||
wRHwcHgFfAx+AH+GCb/BT2fNmvUk5ZXwYOrrOsTcCU5CJ74pPBJeA5+Bn8LfOLmagf/f8Af4NrwD
|
||||
ngg3wdTHh2pOMMB1Gejx8AE4M85mNqD/A7+D78GXkXQFTIMPwUfhdPg6/AxWTRw29b8QruPD9zwY
|
||||
zPrwHPi2xxmg3QrfgDfD05BGU24EB1HvC3s7REXgtwDsDzeEY+Ak+AJsUfwE2sJdcBN37V4whiU4
|
||||
+KGUM2JEBtpzUInZEa5g9y4FcYfAo+GLPmw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Kx+hLs/ixsdjBXBd2TtyKNhUOp1/dprgMQ
|
||||
rx9x16fcn1KbttrIyf9OkICWw1KApvY2YyXbpSBobKf7OGXApFtI+5d3Qq1BDoL6V87GcDVc9Ivq
|
||||
E4D+bjTQbc1i9demreDu8Ch0ffG6hdnmDMrvFbsSsAXczIGk3fwb4VYe+pwBB9Angkd83ADtqgkq
|
||||
AjetdTTV1icDlfl+Qi3AP4elHEjaDXscHgFjPdNt4ID6S9B9sNLiKoelmuFuJbCpDJi+hvqz2qFw
|
||||
iIfWc2AQusxPgvq484vH2eUgtpYHH0Hteeqb75ZwMQ+j+cDg9PlwFDwd6o9sr0KtbWI/tSPgp32M
|
||||
76H+s6mNX3030df5neGq1OtbZDUbOIlFoFaha0L9j0qfCHeAerDqVtODU8+hNThZfR1fHHbpG6kx
|
||||
9Or1LzUmVVz+HJXDAAAAAElFTkSuQmCC">
|
||||
<h1 class="title">Intel® Threading Building Blocks.<br>Sudoku sample</h1>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
This directory contains a simple example that finds all solutions to a
|
||||
Sudoku board.
|
||||
<br><br>
|
||||
It uses a straightforward state-space search algorithm
|
||||
that exhibits OR-parallelism. It can be optionally run until it
|
||||
obtains just the first solution. The point of the example is to teach
|
||||
how to use the task_group interface.
|
||||
<br><br>
|
||||
The example can be built in the offload version to run on Intel® Many Integrated Core (Intel® MIC) Architecture based coprocessor (see <a href="../../index.html">build instructions</a>).
|
||||
</p>
|
||||
|
||||
<div class="changes">
|
||||
<div class="h3-alike">System Requirements</div>
|
||||
<input type="checkbox">
|
||||
<div class="show-hide">
|
||||
<p>
|
||||
For the most up to date system requirements, see the <a href="http://software.intel.com/en-us/articles/intel-threading-building-blocks-release-notes">release notes.</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="changes">
|
||||
<div class="h3-alike">Files</div>
|
||||
<input type="checkbox" checked="checked">
|
||||
<div class="show-hide">
|
||||
<dl>
|
||||
<dt><a href="sudoku.cpp">sudoku.cpp</a>
|
||||
<dd>Driver.
|
||||
<dt><a href="input1">input1</a>
|
||||
<dd>Sample input file with modest number of solutions.
|
||||
<dt><a href="input2">input2</a>
|
||||
<dd>Sample input file with small number of solutions.
|
||||
<dt><a href="input3">input3</a>
|
||||
<dd>Sample input file with larger number of solutions.
|
||||
<dt><a href="input4">input4</a>
|
||||
<dd>Sample input file with very large number of solutions.
|
||||
<dt><a href="Makefile">Makefile</a>
|
||||
<dd>Makefile for building the example.
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="changes">
|
||||
<div class="h3-alike">Directories</div>
|
||||
<input type="checkbox" checked="checked">
|
||||
<div class="show-hide">
|
||||
<dl>
|
||||
<dt><a href="msvs/">msvs</a>
|
||||
<dd>Contains Microsoft* Visual Studio* workspace for building and running the example with the Intel® C++ Compiler (Windows* systems only).
|
||||
<dt><a href="xcode/">xcode</a>
|
||||
<dd>Contains Xcode* IDE workspace for building and running the example (macOS* systems only).
|
||||
</dl>
|
||||
<p>For information about the minimum supported version of IDE, see <a href="http://software.intel.com/en-us/articles/intel-threading-building-blocks-release-notes">release notes.</a></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="changes">
|
||||
<div class="h3-alike">Build instructions</div>
|
||||
<input type="checkbox" checked="checked">
|
||||
<div class="show-hide">
|
||||
<p>General build directions can be found <a href="../../index.html">here</a>.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="changes">
|
||||
<div class="h3-alike">Usage</div>
|
||||
<input type="checkbox" checked="checked">
|
||||
<div class="show-hide">
|
||||
<dl>
|
||||
<dt><tt>sudoku <i>-h</i></tt>
|
||||
<dd>Prints the help for command line options
|
||||
<dt><tt>sudoku [<i>n-of-threads</i>=value] [<i>filename</i>=value] [<i>verbose</i>] [<i>silent</i>] [<i>find-one</i>]</tt>
|
||||
<dt><tt>sudoku [n-of-threads [filename]] [<i>verbose</i>] [<i>silent</i>] [<i>find-one</i>]</tt>
|
||||
<dd><i>n-of-threads</i> is the number of threads to use; a range of the form <i>low</i>[:<i>high</i>], where low and optional high are non-negative integers or 'auto' for a platform-specific default number.<br>
|
||||
<i>filename</i> is an input filename.<br>
|
||||
<i>verbose</i> - prints the first solution.<br>
|
||||
<i>silent</i> - no output except elapsed time.<br>
|
||||
<i>find-one</i> - stops after finding first solution.<br>
|
||||
<dt>To run a short version of this example, e.g., for use with Intel® Parallel Inspector:
|
||||
<dd>Build a <i>debug</i> version of the example
|
||||
(see the <a href="../../index.html">build instructions</a>).
|
||||
<br>Run it with a small problem size and the desired number of threads, e.g., <tt>sudoku 4 input2</tt>.
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<br>
|
||||
<a href="../index.html">Up to parent directory</a>
|
||||
<hr>
|
||||
<div class="changes">
|
||||
<div class="h3-alike">Legal Information</div>
|
||||
<input type="checkbox">
|
||||
<div class="show-hide">
|
||||
<p>
|
||||
Intel and the Intel logo are trademarks of Intel Corporation in the U.S. and/or other countries.
|
||||
<br>* Other names and brands may be claimed as the property of others.
|
||||
<br>© 2020, Intel Corporation
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
316
cs440-acg/ext/tbb/examples/task_group/sudoku/sudoku.cpp
Normal file
316
cs440-acg/ext/tbb/examples/task_group/sudoku/sudoku.cpp
Normal file
@@ -0,0 +1,316 @@
|
||||
/*
|
||||
Copyright (c) 2005-2020 Intel Corporation
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#include "../../common/utility/utility.h"
|
||||
#include "../../common/utility/get_default_num_threads.h"
|
||||
|
||||
#if __TBB_MIC_OFFLOAD
|
||||
#pragma offload_attribute (push,target(mic))
|
||||
#endif // __TBB_MIC_OFFLOAD
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <string>
|
||||
#include <atomic>
|
||||
|
||||
#include "tbb/tick_count.h"
|
||||
#include "tbb/task_group.h"
|
||||
#include "tbb/global_control.h"
|
||||
|
||||
#pragma warning(disable: 4996)
|
||||
|
||||
const unsigned BOARD_SIZE=81;
|
||||
const unsigned BOARD_DIM=9;
|
||||
|
||||
using namespace tbb;
|
||||
using namespace std;
|
||||
|
||||
std::atomic<unsigned> nSols;
|
||||
bool find_one = false;
|
||||
bool verbose = false;
|
||||
unsigned short init_values[BOARD_SIZE] = {1,0,0,9,0,0,0,8,0,0,8,0,2,0,0,0,0,0,0,0,5,0,0,0,7,0,0,0,5,2,1,0,0,4,0,0,0,0,0,0,0,5,0,0,7,4,0,0,7,0,0,0,3,0,0,3,0,0,0,2,0,0,5,0,0,0,0,0,0,1,0,0,5,0,0,0,1,0,0,0,0};
|
||||
task_group *g;
|
||||
double solve_time;
|
||||
|
||||
typedef struct {
|
||||
unsigned short solved_element;
|
||||
unsigned potential_set;
|
||||
} board_element;
|
||||
|
||||
void read_board(const char *filename) {
|
||||
FILE *fp;
|
||||
int input;
|
||||
fp = fopen(filename, "r");
|
||||
if (!fp) {
|
||||
fprintf(stderr, "sudoku: Could not open input file '%s'.\n", filename);
|
||||
exit(1);
|
||||
}
|
||||
for (unsigned i=0; i<BOARD_SIZE; ++i) {
|
||||
if (fscanf(fp, "%d", &input))
|
||||
init_values[i] = input;
|
||||
else {
|
||||
fprintf(stderr, "sudoku: Error in input file at entry %d, assuming 0.\n", i);
|
||||
init_values[i] = 0;
|
||||
}
|
||||
}
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
void print_board(board_element *b) {
|
||||
for (unsigned row=0; row<BOARD_DIM; ++row) {
|
||||
for (unsigned col=0; col<BOARD_DIM; ++col) {
|
||||
printf(" %d", b[row*BOARD_DIM+col].solved_element);
|
||||
if (col==2 || col==5) printf(" |");
|
||||
}
|
||||
printf("\n");
|
||||
if (row==2 || row==5) printf(" ---------------------\n");
|
||||
}
|
||||
}
|
||||
|
||||
void print_potential_board(board_element *b) {
|
||||
for (unsigned row=0; row<BOARD_DIM; ++row) {
|
||||
for (unsigned col=0; col<BOARD_DIM; ++col) {
|
||||
if (b[row*BOARD_DIM+col].solved_element)
|
||||
printf(" %4d ", b[row*BOARD_DIM+col].solved_element);
|
||||
else
|
||||
printf(" [%4d]", b[row*BOARD_DIM+col].potential_set);
|
||||
if (col==2 || col==5) printf(" |");
|
||||
}
|
||||
printf("\n");
|
||||
if (row==2 || row==5)
|
||||
printf(" ------------------------------------------------------------------\n");
|
||||
}
|
||||
}
|
||||
|
||||
void init_board(board_element *b) {
|
||||
for (unsigned i=0; i<BOARD_SIZE; ++i)
|
||||
b[i].solved_element = b[i].potential_set = 0;
|
||||
}
|
||||
|
||||
void init_board(board_element *b, unsigned short arr[81]) {
|
||||
for (unsigned i=0; i<BOARD_SIZE; ++i) {
|
||||
b[i].solved_element = arr[i];
|
||||
b[i].potential_set = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void init_potentials(board_element *b) {
|
||||
for (unsigned i=0; i<BOARD_SIZE; ++i)
|
||||
b[i].potential_set = 0;
|
||||
}
|
||||
|
||||
void copy_board(board_element *src, board_element *dst) {
|
||||
for (unsigned i=0; i<BOARD_SIZE; ++i)
|
||||
dst[i].solved_element = src[i].solved_element;
|
||||
}
|
||||
|
||||
bool fixed_board(board_element *b) {
|
||||
for (int i=BOARD_SIZE-1; i>=0; --i)
|
||||
if (b[i].solved_element==0) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool in_row(board_element *b, unsigned row, unsigned col, unsigned short p) {
|
||||
for (unsigned c=0; c<BOARD_DIM; ++c)
|
||||
if (c!=col && b[row*BOARD_DIM+c].solved_element==p) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool in_col(board_element *b, unsigned row, unsigned col, unsigned short p) {
|
||||
for (unsigned r=0; r<BOARD_DIM; ++r)
|
||||
if (r!=row && b[r*BOARD_DIM+col].solved_element==p) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool in_block(board_element *b, unsigned row, unsigned col, unsigned short p) {
|
||||
unsigned b_row = row/3 * 3, b_col = col/3 * 3;
|
||||
for (unsigned i=b_row; i<b_row+3; ++i)
|
||||
for (unsigned j=b_col; j<b_col+3; ++j)
|
||||
if (!(i==row && j==col) && b[i*BOARD_DIM+j].solved_element==p) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
void calculate_potentials(board_element *b) {
|
||||
for (unsigned i=0; i<BOARD_SIZE; ++i) {
|
||||
b[i].potential_set = 0;
|
||||
if (!b[i].solved_element) { // element is not yet fixed
|
||||
unsigned row = i/BOARD_DIM, col = i%BOARD_DIM;
|
||||
for (unsigned potential=1; potential<=BOARD_DIM; ++potential) {
|
||||
if (!in_row(b, row, col, potential) && !in_col(b, row, col, potential)
|
||||
&& !in_block(b, row, col, potential))
|
||||
b[i].potential_set |= 1<<(potential-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool valid_board(board_element *b) {
|
||||
bool success=true;
|
||||
for (unsigned i=0; i<BOARD_SIZE; ++i) {
|
||||
if (success && b[i].solved_element) { // element is fixed
|
||||
unsigned row = i/BOARD_DIM, col = i%BOARD_DIM;
|
||||
if (in_row(b, row, col, b[i].solved_element) || in_col(b, row, col, b[i].solved_element) || in_block(b, row, col, b[i].solved_element))
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
bool examine_potentials(board_element *b, bool *progress) {
|
||||
bool singletons = false;
|
||||
for (unsigned i=0; i<BOARD_SIZE; ++i) {
|
||||
if (b[i].solved_element==0 && b[i].potential_set==0) // empty set
|
||||
return false;
|
||||
switch (b[i].potential_set) {
|
||||
case 1: { b[i].solved_element = 1; singletons=true; break; }
|
||||
case 2: { b[i].solved_element = 2; singletons=true; break; }
|
||||
case 4: { b[i].solved_element = 3; singletons=true; break; }
|
||||
case 8: { b[i].solved_element = 4; singletons=true; break; }
|
||||
case 16: { b[i].solved_element = 5; singletons=true; break; }
|
||||
case 32: { b[i].solved_element = 6; singletons=true; break; }
|
||||
case 64: { b[i].solved_element = 7; singletons=true; break; }
|
||||
case 128: { b[i].solved_element = 8; singletons=true; break; }
|
||||
case 256: { b[i].solved_element = 9; singletons=true; break; }
|
||||
}
|
||||
}
|
||||
*progress = singletons;
|
||||
return valid_board(b);
|
||||
}
|
||||
|
||||
#if !__TBB_CPP11_LAMBDAS_PRESENT
|
||||
void partial_solve(board_element *b, unsigned first_potential_set);
|
||||
|
||||
class PartialSolveBoard {
|
||||
board_element *b;
|
||||
unsigned first_potential_set;
|
||||
public:
|
||||
PartialSolveBoard(board_element *_b, unsigned fps) :
|
||||
b(_b), first_potential_set(fps) {}
|
||||
void operator() () const {
|
||||
partial_solve(b, first_potential_set);
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
void partial_solve(board_element *b, unsigned first_potential_set) {
|
||||
if (fixed_board(b)) {
|
||||
if ( find_one )
|
||||
g->cancel();
|
||||
if (++nSols==1 && verbose) {
|
||||
print_board(b);
|
||||
}
|
||||
free(b);
|
||||
return;
|
||||
}
|
||||
calculate_potentials(b);
|
||||
bool progress=true;
|
||||
bool success = examine_potentials(b, &progress);
|
||||
if (success && progress) {
|
||||
partial_solve(b, first_potential_set);
|
||||
} else if (success && !progress) {
|
||||
board_element *new_board;
|
||||
while (b[first_potential_set].solved_element!=0) ++first_potential_set;
|
||||
for (unsigned short potential=1; potential<=BOARD_DIM; ++potential) {
|
||||
if (1<<(potential-1) & b[first_potential_set].potential_set) {
|
||||
new_board = (board_element *)malloc(BOARD_SIZE*sizeof(board_element));
|
||||
copy_board(b, new_board);
|
||||
new_board[first_potential_set].solved_element = potential;
|
||||
#if __TBB_CPP11_LAMBDAS_PRESENT
|
||||
g->run( [=]{ partial_solve(new_board, first_potential_set); } );
|
||||
#else
|
||||
g->run(PartialSolveBoard(new_board, first_potential_set));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
free(b);
|
||||
}
|
||||
else {
|
||||
free(b);
|
||||
}
|
||||
}
|
||||
|
||||
unsigned solve(int p) {
|
||||
tbb::global_control c(tbb::global_control::max_allowed_parallelism, p);
|
||||
nSols = 0;
|
||||
board_element *start_board = (board_element *)malloc(BOARD_SIZE*sizeof(board_element));
|
||||
init_board(start_board, init_values);
|
||||
g = new task_group;
|
||||
tick_count t0 = tick_count::now();
|
||||
partial_solve(start_board, 0);
|
||||
g->wait();
|
||||
solve_time = (tick_count::now() - t0).seconds();
|
||||
delete g;
|
||||
return nSols;
|
||||
}
|
||||
|
||||
#if __TBB_MIC_OFFLOAD
|
||||
#pragma offload_attribute (pop)
|
||||
#endif // __TBB_MIC_OFFLOAD
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
try {
|
||||
tbb::tick_count mainStartTime = tbb::tick_count::now();
|
||||
|
||||
utility::thread_number_range threads(utility::get_default_num_threads);
|
||||
string filename = "";
|
||||
bool silent = false;
|
||||
|
||||
utility::parse_cli_arguments(argc,argv,
|
||||
utility::cli_argument_pack()
|
||||
//"-h" option for displaying help is present implicitly
|
||||
.positional_arg(threads,"n-of-threads",utility::thread_number_range_desc)
|
||||
.positional_arg(filename,"filename","input filename")
|
||||
|
||||
.arg(verbose,"verbose","prints the first solution")
|
||||
.arg(silent,"silent","no output except elapsed time")
|
||||
.arg(find_one,"find-one","stops after finding first solution\n")
|
||||
);
|
||||
|
||||
if ( silent ) verbose = false;
|
||||
|
||||
if ( !filename.empty() )
|
||||
read_board( filename.c_str() );
|
||||
// otherwise (if file name not specified), the default statically initialized board will be used.
|
||||
for(int p = threads.first; p <= threads.last; p = threads.step(p) ) {
|
||||
unsigned number;
|
||||
#if __TBB_MIC_OFFLOAD
|
||||
#pragma offload target(mic) in(init_values, p, verbose, find_one) out(number, solve_time)
|
||||
{
|
||||
#endif // __TBB_MIC_OFFLOAD
|
||||
number = solve(p);
|
||||
#if __TBB_MIC_OFFLOAD
|
||||
}
|
||||
#endif // __TBB_MIC_OFFLOAD
|
||||
|
||||
if ( !silent ) {
|
||||
if ( find_one ) {
|
||||
printf("Sudoku: Time to find first solution on %d threads: %6.6f seconds.\n", p, solve_time);
|
||||
}
|
||||
else {
|
||||
printf("Sudoku: Time to find all %u solutions on %d threads: %6.6f seconds.\n", number, p, solve_time);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
utility::report_elapsed_time((tbb::tick_count::now() - mainStartTime).seconds());
|
||||
|
||||
return 0;
|
||||
} catch(std::exception& e) {
|
||||
std::cerr<<"error occurred. error text is :\"" <<e.what()<<"\"\n";
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
|
@@ -0,0 +1,262 @@
|
||||
// !$*UTF8*$!
|
||||
{
|
||||
archiveVersion = 1;
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 46;
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
A1F593A60B8F042A00073279 /* sudoku.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A1F593A50B8F042A00073279 /* sudoku.cpp */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXBuildRule section */
|
||||
C3C58961218C251E00DAC94C /* PBXBuildRule */ = {
|
||||
isa = PBXBuildRule;
|
||||
compilerSpec = com.intel.compilers.icc.latest;
|
||||
fileType = sourcecode.cpp;
|
||||
isEditable = 1;
|
||||
outputFiles = (
|
||||
);
|
||||
script = "# Type a script or drag a script file from your workspace to insert its path.\n";
|
||||
};
|
||||
/* End PBXBuildRule section */
|
||||
|
||||
/* Begin PBXCopyFilesBuildPhase section */
|
||||
8DD76F690486A84900D96B5E /* CopyFiles */ = {
|
||||
isa = PBXCopyFilesBuildPhase;
|
||||
buildActionMask = 12;
|
||||
dstPath = "";
|
||||
dstSubfolderSpec = 16;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXCopyFilesBuildPhase section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
8DD76F6C0486A84900D96B5E /* Sudoku */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = Sudoku; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
A1F593A50B8F042A00073279 /* sudoku.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = sudoku.cpp; path = ../sudoku.cpp; sourceTree = SOURCE_ROOT; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
8DD76F660486A84900D96B5E /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
08FB7794FE84155DC02AAC07 /* Sudoku */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
08FB7795FE84155DC02AAC07 /* Source */,
|
||||
1AB674ADFE9D54B511CA2CBB /* Products */,
|
||||
);
|
||||
name = Sudoku;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
08FB7795FE84155DC02AAC07 /* Source */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
A1F593A50B8F042A00073279 /* sudoku.cpp */,
|
||||
);
|
||||
name = Source;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
1AB674ADFE9D54B511CA2CBB /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
8DD76F6C0486A84900D96B5E /* Sudoku */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
8DD76F620486A84900D96B5E /* Sudoku */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 1DEB923108733DC60010E9CD /* Build configuration list for PBXNativeTarget "Sudoku" */;
|
||||
buildPhases = (
|
||||
8DD76F640486A84900D96B5E /* Sources */,
|
||||
8DD76F660486A84900D96B5E /* Frameworks */,
|
||||
8DD76F690486A84900D96B5E /* CopyFiles */,
|
||||
);
|
||||
buildRules = (
|
||||
C3C58961218C251E00DAC94C /* PBXBuildRule */,
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = Sudoku;
|
||||
productInstallPath = "$(HOME)/bin";
|
||||
productName = Sudoku;
|
||||
productReference = 8DD76F6C0486A84900D96B5E /* Sudoku */;
|
||||
productType = "com.apple.product-type.tool";
|
||||
};
|
||||
/* End PBXNativeTarget section */
|
||||
|
||||
/* Begin PBXProject section */
|
||||
08FB7793FE84155DC02AAC07 /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastUpgradeCheck = 1000;
|
||||
};
|
||||
buildConfigurationList = 1DEB923508733DC60010E9CD /* Build configuration list for PBXProject "sudoku" */;
|
||||
compatibilityVersion = "Xcode 3.2";
|
||||
developmentRegion = English;
|
||||
hasScannedForEncodings = 1;
|
||||
knownRegions = (
|
||||
en,
|
||||
);
|
||||
mainGroup = 08FB7794FE84155DC02AAC07 /* Sudoku */;
|
||||
projectDirPath = "";
|
||||
projectRoot = "";
|
||||
targets = (
|
||||
8DD76F620486A84900D96B5E /* Sudoku */,
|
||||
);
|
||||
};
|
||||
/* End PBXProject section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
8DD76F640486A84900D96B5E /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
A1F593A60B8F042A00073279 /* sudoku.cpp in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXSourcesBuildPhase section */
|
||||
|
||||
/* Begin XCBuildConfiguration section */
|
||||
A1F593C60B8F0E6E00073279 /* Debug64 */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
COPY_PHASE_STRIP = NO;
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
|
||||
HEADER_SEARCH_PATHS = "$(inherited)";
|
||||
ICC_CXX_LANG_DIALECT = "c++11";
|
||||
INSTALL_PATH = "$(HOME)/bin";
|
||||
LIBRARY_SEARCH_PATHS = "$(inherited)";
|
||||
PRODUCT_NAME = Sudoku;
|
||||
ZERO_LINK = NO;
|
||||
};
|
||||
name = Debug64;
|
||||
};
|
||||
A1F593C70B8F0E6E00073279 /* Release64 */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
|
||||
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
|
||||
HEADER_SEARCH_PATHS = "$(inherited)";
|
||||
ICC_CXX_LANG_DIALECT = "c++11";
|
||||
INSTALL_PATH = "$(HOME)/bin";
|
||||
LIBRARY_SEARCH_PATHS = "$(inherited)";
|
||||
PRODUCT_NAME = Sudoku;
|
||||
ZERO_LINK = NO;
|
||||
};
|
||||
name = Release64;
|
||||
};
|
||||
A1F593C80B8F0E6E00073279 /* Debug64 */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "c++0x";
|
||||
ENABLE_TESTABILITY = YES;
|
||||
GCC_ENABLE_CPP_RTTI = YES;
|
||||
GCC_MODEL_TUNING = "";
|
||||
GCC_VERSION = "";
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
HEADER_SEARCH_PATHS = (
|
||||
"$(TBBROOT)/include",
|
||||
/opt/intel/tbb/include,
|
||||
);
|
||||
ICC_CXX_LANG_DIALECT = "c++11";
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(TBBROOT)/lib /opt/intel/tbb/lib";
|
||||
LIBRARY_SEARCH_PATHS = (
|
||||
"$(TBBROOT)/lib",
|
||||
/opt/intel/tbb/lib,
|
||||
);
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.11;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
OTHER_CPLUSPLUSFLAGS = (
|
||||
"$(OTHER_CFLAGS)",
|
||||
"-m64",
|
||||
);
|
||||
OTHER_LDFLAGS = (
|
||||
"-m64",
|
||||
"-ltbb_debug",
|
||||
);
|
||||
PRECOMPS_INCLUDE_HEADERS_FROM_BUILT_PRODUCTS_DIR = NO;
|
||||
SYMROOT = "/tmp/tbb-$(USER)";
|
||||
VALID_ARCHS = x86_64;
|
||||
};
|
||||
name = Debug64;
|
||||
};
|
||||
A1F593C90B8F0E6E00073279 /* Release64 */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "c++0x";
|
||||
GCC_ENABLE_CPP_RTTI = YES;
|
||||
GCC_MODEL_TUNING = "";
|
||||
GCC_VERSION = "";
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
HEADER_SEARCH_PATHS = (
|
||||
"$(TBBROOT)/include",
|
||||
/opt/intel/tbb/include,
|
||||
);
|
||||
ICC_CXX_LANG_DIALECT = "c++11";
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(TBBROOT)/lib /opt/intel/tbb/lib";
|
||||
LIBRARY_SEARCH_PATHS = (
|
||||
"$(TBBROOT)/lib",
|
||||
/opt/intel/tbb/lib,
|
||||
);
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.11;
|
||||
OTHER_CPLUSPLUSFLAGS = (
|
||||
"$(OTHER_CFLAGS)",
|
||||
"-m64",
|
||||
);
|
||||
OTHER_LDFLAGS = (
|
||||
"-m64",
|
||||
"-ltbb",
|
||||
);
|
||||
PRECOMPS_INCLUDE_HEADERS_FROM_BUILT_PRODUCTS_DIR = NO;
|
||||
SYMROOT = "/tmp/tbb-$(USER)";
|
||||
VALID_ARCHS = x86_64;
|
||||
};
|
||||
name = Release64;
|
||||
};
|
||||
/* End XCBuildConfiguration section */
|
||||
|
||||
/* Begin XCConfigurationList section */
|
||||
1DEB923108733DC60010E9CD /* Build configuration list for PBXNativeTarget "Sudoku" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
A1F593C60B8F0E6E00073279 /* Debug64 */,
|
||||
A1F593C70B8F0E6E00073279 /* Release64 */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release64;
|
||||
};
|
||||
1DEB923508733DC60010E9CD /* Build configuration list for PBXProject "sudoku" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
A1F593C80B8F0E6E00073279 /* Debug64 */,
|
||||
A1F593C90B8F0E6E00073279 /* Release64 */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release64;
|
||||
};
|
||||
/* End XCConfigurationList section */
|
||||
};
|
||||
rootObject = 08FB7793FE84155DC02AAC07 /* Project object */;
|
||||
}
|
Reference in New Issue
Block a user