@@ -32,6 +32,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
3232THIS SOFTWARE,
3333EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3434**********/
35+ #include " cmdlineparser.h"
3536#include " xcl2.hpp"
3637#include < vector>
3738#define USE_IN_HOST
@@ -43,16 +44,25 @@ void sw_RgbToHsv(int *in, int *out, size_t image_size);
4344void sw_HsvToRgb (int *in, int *out, size_t image_size);
4445int compareImages (int *in, int *out, size_t image_size);
4546
46- int main (int argc, char *argv[]) {
47- if (argc != 3 ) {
48- std::cout << " Usage: " << argv[0 ] << " <XCLBIN File>"
49- << " <input bitmap>" << std::endl;
47+ int main (int argc, char **argv) {
48+ // Command Line Parser
49+ sda::utils::CmdLineParser parser;
50+
51+ // Switches
52+ // **************//"<Full Arg>", "<Short Arg>", "<Description>", "<Default>"
53+ parser.addSwitch (" --xclbin_file" , " -x" , " input binary file string" , " " );
54+ parser.addSwitch (" --input_file" , " -i" , " input test data flie" , " " );
55+ parser.parse (argc, argv);
56+
57+ // Read settings
58+ std::string binaryFile = parser.value (" xclbin_file" );
59+ std::string bitmapFilename = parser.value (" input_file" );
60+
61+ if (argc != 5 ) {
62+ parser.printHelp ();
5063 return EXIT_FAILURE;
5164 }
5265
53- std::string binaryFile = argv[1 ];
54- std::string bitmapFilename = argv[2 ];
55-
5666 cl_int err;
5767 cl::CommandQueue q;
5868 cl::Context context;
@@ -61,7 +71,7 @@ int main(int argc, char *argv[]) {
6171 BitmapInterface image (bitmapFilename.data ());
6272 bool result = image.readBitmapFile ();
6373 if (!result) {
64- std::cout << " ERROR:Unable to Read Bitmap File " << bitmapFilename.data ()
74+ std::cerr << " ERROR:Unable to Read Bitmap File " << bitmapFilename.data ()
6575 << std::endl;
6676 return EXIT_FAILURE;
6777 }
@@ -88,8 +98,8 @@ int main(int argc, char *argv[]) {
8898 for (unsigned int i = 0 ; i < devices.size (); i++) {
8999 auto device = devices[i];
90100 // Creating Context and Command Queue for selected Device
91- OCL_CHECK (err, context = cl::Context ({ device} , NULL , NULL , NULL , &err));
92- OCL_CHECK (err, q = cl::CommandQueue (context, { device} ,
101+ OCL_CHECK (err, context = cl::Context (device, NULL , NULL , NULL , &err));
102+ OCL_CHECK (err, q = cl::CommandQueue (context, device,
93103 CL_QUEUE_PROFILING_ENABLE, &err));
94104
95105 std::cout << " Trying to program device[" << i
@@ -105,7 +115,7 @@ int main(int argc, char *argv[]) {
105115 }
106116 }
107117 if (valid_device == 0 ) {
108- std::cout << " Failed to program any device found, exit!\n " ;
118+ std::cerr << " Failed to program any device found, exit!\n " ;
109119 exit (EXIT_FAILURE);
110120 }
111121
@@ -263,7 +273,7 @@ int compareImages(int *_in, int *_out, size_t image_size) {
263273 out = out & 0xffffff ;
264274 if (in != out) {
265275 cnt++;
266- std::cout << " ERROR: Pixel=" << i << " mismatch Expected=" << in
276+ std::cerr << " ERROR: Pixel=" << i << " mismatch Expected=" << in
267277 << " and Got=" << out << std::endl;
268278 return EXIT_FAILURE;
269279 }
0 commit comments