• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

STEllAR-GROUP / hpx / #882

31 Aug 2023 07:44PM UTC coverage: 41.798% (-44.7%) from 86.546%
#882

push

19442 of 46514 relevant lines covered (41.8%)

126375.38 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/examples/nqueen/nqueen_client.cpp
1
//  Copyright (c) 2007-2017 Hartmut Kaiser, Richard D Guidry Jr.
2
//  Copyright (c) 2011 Vinay C Amatya
3
//  Copyright (c) 2011 Bryce Lelbach
4
//
5
//  SPDX-License-Identifier: BSL-1.0
6
//  Distributed under the Boost Software License, Version 1.0. (See accompanying
7
//  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
8
//
9
//  Parts of this nqueen_client.cpp has been taken from the accumulator example
10
//  by Hartmut Kaiser.
11

12
#include <hpx/config.hpp>
13
#if !defined(HPX_COMPUTE_DEVICE_CODE)
14
#include <hpx/hpx.hpp>
15
#include <hpx/hpx_init.hpp>
16
#include <hpx/include/util.hpp>
17

18
#include <cstddef>
19
#include <iostream>
20
#include <list>
21
#include <string>
22
#include <vector>
23

24
#include "nqueen.hpp"
25

26
int hpx_main(hpx::program_options::variables_map&)
×
27
{
28
    std::size_t const default_size = 8;
29

30
    std::size_t soln_count_total = 0;
31

32
    hpx::id_type locality_ = hpx::find_here();
×
33

34
    std::cout << "Enter size of board. Default size is 8." << std::endl;
35
    std::cout << "Command Options: size[value] | default | print | quit"
36
              << std::endl;
37
    std::string cmd;
38
    std::cin >> cmd;
×
39

40
    while (std::cin.good())
×
41
    {
42
        if (cmd == "size")
×
43
        {
44
            soln_count_total = 0;
45
            std::string arg;
46
            std::cin >> arg;
×
47
            std::size_t sz = hpx::util::from_string<std::size_t>(arg);
×
48

49
            std::size_t i = 0;
50
            std::list<nqueen::board> b;
51
            nqueen::board bi = hpx::new_<nqueen::board>(locality_);
×
52
            while (i != sz)
×
53
            {
54
                b.push_back(bi);
55
                ++i;
×
56
            }
57

58
            i = 0;
59
            for (std::list<nqueen::board>::iterator iter = b.begin();
×
60
                iter != b.end(); ++iter)
×
61
            {
62
                iter->init_board(sz);
×
63
                soln_count_total +=
×
64
                    iter->solve_board(iter->access_board(), sz, 0, i);
×
65
                ++i;
×
66
            }
67
            std::cout << "soln_count:" << soln_count_total << std::endl;
68
            b.clear();
69
        }
70
        else if (cmd == "default")
×
71
        {
72
            soln_count_total = 0;
73
            nqueen::board a = hpx::new_<nqueen::board>(locality_);
×
74
            std::size_t i = 0;
75
            std::vector<nqueen::board> b;
×
76
            while (i != default_size)
×
77
            {
78
                b.push_back(a);
×
79
                ++i;
×
80
            }
81
            i = 0;
82
            for (std::vector<nqueen::board>::iterator iter = b.begin();
×
83
                iter != b.end(); ++iter)
×
84
            {
85
                iter->init_board(default_size);
×
86
                soln_count_total +=
×
87
                    iter->solve_board(iter->access_board(), default_size, 0, i);
×
88
                ++i;
×
89
            }
90
            std::cout << "soln_count:" << soln_count_total << std::endl;
91
            b.clear();
92
        }
×
93
        else if (cmd == "print")
×
94
        {
95
            std::cout << "soln_count : " << soln_count_total << std::endl;
96
        }
97
        else if (cmd == "quit")
×
98
        {
99
            //std::cout << "soln_count : " << soln_count_total << std::endl;
100
            break;
101
        }
102
        else
103
        {
104
            std::cout << "Invalid Command." << std::endl;
105
            std::cout << "Options: size[value] | default | print "
106
                      << "| quit" << std::endl;
107
        }
108
        std::cin >> cmd;
×
109
    }
110

111
    hpx::finalize();
112

113
    return 0;
×
114
}
115

116
int main(int argc, char* argv[])
×
117
{
118
    return hpx::init(argc, argv);
×
119
}
120
#endif
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc