Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7169529
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T15:00:36+00:00 2026-05-28T15:00:36+00:00

Given the following structure typedef struct { float3 position; float8 position1; } MyStruct; I’m

  • 0

Given the following structure

typedef struct
{
   float3 position;
   float8 position1;
} MyStruct;

I’m creating a buffer to pass it as a pointer to the kernel the buffer will have the previous buffer format.

I understand that I’ve to add 4 bytes in the buffer after writing the three floats to get the next power of two (16 bytes) but I don’t understand why I’ve to add another 16 bytes extra before writing the bytes of position1. Otherwise I get wrong values in position1.

Can someone explain me why?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T15:00:36+00:00Added an answer on May 28, 2026 at 3:00 pm

    A float8 is a vector of 8 floats, each float being 4 bytes. That makes a size of 32 bytes. As per section 6.1.5 of the OpenCL 1.2 specification, Alignment of Types, types are always aligned to their size; so the float8 must be 32 byte aligned. The same section also tells us that float3 takes 4 words. Also, since the sizeof for a struct is arranged to allow arrays of the struct, it won’t shrink from reordering these particular fields. On more complex structs you can save space by keeping the smaller fields together.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given the following structure: struct nmslist_elem_s { nmptr data; struct nmslist_elem_s *next; }; typedef
I have the following data structure in C: typedef struct { void* buffer; ...
Given the following code: typedef struct IntElement { struct IntElement *next; // use struct
Given the following XML structure <html> <body> <div> <span>Test: Text2</span> </div> <div> <span>Test: Text3</span>
I have an odd linq subquery issue. Given the following data structure: Parents Children
I have a necessity to sort a given HTML table of the following structure,
Following class structure is given: class Job { String description; Collection<JobHistory> history; } class
Given a pretty basic source tree structure like the following: trunk ------- QA |--------
I have this structure typedef struct fpinfo { unsigned long chunk_offset; unsigned long chunk_length;
Given the following structure: City Area User Every Area has 1 and only 1

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.