C++amp Acceleration Settings

Source: Internet
Author: User

Reference from: https://msdn.microsoft.com/en-us/library/hh873132.aspx

1#include <amp.h>2#include <iostream>3 4 using namespaceConcurrency;5 6 //Default acceleration Device7 voiddefault_properties ()8 {9 accelerator DEFAULT_ACC;TenStd::wcout << Default_acc.device_path <<"\ n"; OneStd::wcout << default_acc.dedicated_memory <<"\ n"; A } -  - //List all acceleration devices the voidlist_all_accelerators () - { -Std::vector<accelerator> ACCs =Accelerator::get_all (); -      for(inti =0; I < accs.size (); i++) +     { -Std::wcout << Accs[i].device_path <<"\ n"; +Std::wcout << accs[i].dedicated_memory <<"\ n"; AStd::wcout << (accs[i].supports_cpu_shared_memory? at             "CPU shared Memory:true":"CPU shared Memory:false") <<"\ n"; -Std::wcout << (accs[i].supports_double_precision?  -             "Double Precision:true":"Double Precision:false") <<"\ n"; -Std::wcout << (accs[i].supports_limited_double_precision?  -             "Limited Double Precision:true":"Limited Double Precision:false") <<"\ n"; -Std::wcout << accs[i].description <<"\n\n\n"; in     } - } to  + //Select the maximum acceleration device - voidpick_with_most_memory () the { *Std::vector<accelerator> ACCs =Accelerator::get_all (); $Accelerator Acc_chosen = accs[0];Panax Notoginseng      for(inti =0; I < accs.size (); i++) -     { the         if(Accs[i].dedicated_memory >acc_chosen.dedicated_memory) +         { AAcc_chosen =Accs[i]; the         } +     } -  $Std::wcout <<"The accelerator with the most memory is" $<< Acc_chosen.device_path <<"\ n" -<< acc_chosen.dedicated_memory <<". \ n"; - } the  - //shared memory with CPUWuyi voidsharedmemory () the { -Accelerator ACC =Accelerator (accelerator::d efault_accelerator); Wu  -     //Early out if the default accelerator doesn ' t support shared memory About     if(!acc.supports_cpu_shared_memory) $     { -Std::cout <<"The default accelerator does not support shared memory"<<Std::endl; -         return; -     } A  +     //Override The default CPU access type the Acc.set_default_cpu_access_type (access_type_read_write); -  $     //Create an accelerator_view from the default acclerator. the the     //Accelerator_view reflects the Default_cpu_access_type of the the     //Accelerator It ' s associated with. theAccelerator_view Acc_v =Acc.default_view; the } -  in //Select an acceleration device the BOOLPick_accelerator () the { AboutStd::vector<accelerator> ACCs =Accelerator::get_all (); the accelerator Chosen_one; the  theAuto result = Std::find_if (Accs.begin (), Accs.end (), [] (Constaccelerator&ACC) +     { -         return!acc.is_emulated && acc.supports_double_precision &&!Acc.has_display; the     });Bayi  the     if(Result! =accs.end ()) the     { -Chosen_one = *(result); -     } the  theStd::wcout << chosen_one.description <<Std::endl; the  the     BOOLSuccess =Accelerator::set_default (chosen_one.device_path); -      the     returnsuccess; the } the 94 voidMain () the { the default_properties (); the     //list_all_accelerators ();98     //pick_with_most_memory (); About     //sharedmemory (); - 101 pick_accelerator ();102}

C++amp Acceleration Settings

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.