Beispiel #1
0
int main(int argc, char *argv[])
{
	float *A_h, *A_d;
	float *Y_h, *Y_d;
	float *X_h, *X_d;

	hipDeviceProp_t props;
	CHECK(hipGetDeviceProperties(&props, 0/*deviceID*/));
	printf ("info: running on device %s\n", props.name);

//bug will appear if num_row is too big 3125*128
    //for(int i=1 ; i < 1e3; i*=2)
    int i = 131072/NB_X;
    { 
        size_t num_row = NB_X * i;
        
        no_cache(A_h, A_d, X_h, X_d, Y_h, Y_d, num_row);
    }
}
Beispiel #2
0
main()
{
  char *id_str, fname[FILENAME_MAX] ;
  FILE *fp ;
  int done ;
  char *begin_str, *end_str ;
  issue_desc_t issue ;

  decode_query_string(2, "set_id", &set_id, "issue_id", &id_str) ;

  get_issue(set_id, id_str, &issue) ;

  begin_str = (char *)malloc(sizeof(char) * (strlen(id_str)+8)) ;
  sprintf(begin_str, "BEGIN %s\n", id_str) ;
  end_str = (char *)malloc(sizeof(char) * (strlen(id_str)+6)) ;
  sprintf(end_str, "END %s\n", id_str) ;

  no_cache() ;
  return_header("text/html") ;

  if (difftime(issue.expire_time, time(NULL)) > 0) {
    char s[80] ;
    int val_count ;

    /* issue is still open */

    printf("<title>Vote on issue: %s</title>\n", issue.short_desc) ;
    printf("<h1>Vote on issue: %s</h1>\n", issue.short_desc) ;

    if (issue.secret_ballot) 
      printf("<b>This vote is using a secret ballot.</b><br>") ;
    else {
      printf("<b>This vote is NOT using a secret ballot. ") ;
      printf("Your name and vote will be known to everybody!</b><br>") ;
    }

    if (issue.constant_update) {
      printf("<b>Partial voting results will be constantly updated ") ;
      printf("and visible on this page.</b><br>") ;
    }

    if (issue.can_change_vote) {
      printf("<b>You can change your vote at any time before the ") ;
      printf("counting date by voting again.</b><br>") ;
    }
    else {
      printf("<b>You cannot change your vote once it is made.</b><br>") ;
    }

    printf("<form method=post action=\"/FLORA/cgi/voting_cast\">") ;
    printf("<input type=hidden name=\"set_id\" value=\"%s\">",
	   set_id) ;
    printf("<input type=hidden name=\"issue_id\" value=\"%s\">",
	   id_str) ;
    printf("Your voting username: <input type=text name=\"name\"> ") ;
    printf("Your password: <input type=password name=\"password\"><br>") ;

    printf("<b>Description of issue:</b>") ;
    printf("<pre>") ;
    sprintf(fname, "%s/%s.descriptions", file_prefix, set_id) ;
    fp = fopen(fname, "r") ;
    do {
      fgets(s, 80, fp) ;
    } while (strcmp(s, begin_str)) ;
    while (strcmp(s, end_str)) {
      fgets(s, 80, fp) ;
      if (strcmp(s, end_str))
	dump_line_with_links(s) ;
    }
    fclose(fp) ;
    printf("</pre>") ;
    if (issue.multiple_choice > 1)
      printf("<b>Select up to %d choices:</b>", issue.multiple_choice) ;
    else 
      printf("<b>Select a choice:</b>") ;
    printf("<pre>") ;
    sprintf(fname, "%s/%s.choices", file_prefix, set_id) ;
    fp = fopen(fname, "r") ;
    do {
      fgets(s, 80, fp) ;
    } while (strcmp(s, begin_str)) ;
    val_count = 1 ;
    while (strcmp(s, end_str)) {
      fgets(s, 80, fp) ;
      if (strcmp(s, end_str)) {
	printf("<input type=%s name=choice value=%d> ", 
	       issue.multiple_choice > 1 ? "checkbox" : "radio",
	       val_count++) ;
	dump_line_with_links(s) ;
      }
    }
    fclose(fp) ;
    printf("<input type=%s name=choice value=%d> Abstain\n", 
	   issue.multiple_choice > 1 ? "checkbox" : "radio", 
	   val_count) ;
    printf("</pre>\n") ;
    printf("<input type=submit value=\"Cast your vote\">") ;
    printf("</form>") ;

    if (issue.constant_update) {
      printf("<b>Current voting results:</b>\n") ;
      dump_issue_results(issue) ;
    }
  }
  else {
    char s[80] ;

    printf("<title>Results of vote on issue: %s</title>\n", 
	   issue.short_desc) ;
    printf("<h1>Results of vote on issue: %s</h1>\n", issue.short_desc) ;

    printf("<b>Description of issue:</b>") ;
    printf("<pre>") ;
    sprintf(fname, "%s/%s.descriptions", file_prefix, set_id) ;
    fp = fopen(fname, "r") ;
    do {
      fgets(s, 80, fp) ;
    } while (strcmp(s, begin_str)) ;
    while (strcmp(s, end_str)) {
      fgets(s, 80, fp) ;
      if (strcmp(s, end_str))
	dump_line_with_links(s) ;
    }
    fclose(fp) ;
    printf("</pre>") ;
    printf("<b>Voting results:</b>\n") ;

    dump_issue_results(issue) ;

  }
}